diff --git a/js/animations.js b/js/animations.js index 8ef460c..6233bfd 100644 --- a/js/animations.js +++ b/js/animations.js @@ -121,7 +121,6 @@ function init() { if (pos.x && pos.y && pos.z) { pingGeometry.translate(pos.x, pos.y, pos.z) mergedGeometry.merge(pingGeometry) - // Reset ping item position. pingGeometry.translate(-pos.x, -pos.y, -pos.z) } } @@ -130,7 +129,7 @@ function init() { groups.tracePoints = total groups.tracePoints.name = 'Trace Points' scene.add(groups.tracePoints) - groups.tracePoints.rotation.y = groups.globePoints.rotation.y + groups.tracePoints.rotation.y = groups.globePoints.rotation.y - 0.05 } init.addTracePoints = addTracePoints; @@ -146,9 +145,10 @@ function init() { } function convertFlatCoordsToSphereCoords(x, y) { - // Convert latitude and longitude on the 90/180 degree axis. let latitude = ((x - globeWidth) / globeWidth) * -180 let longitude = ((y - globeHeight) / globeHeight) * -90 + latitude = (latitude * Math.PI) / 180 //(latitude / 180) * Math.PI + longitude = (longitude * Math.PI) / 180 //(longitude / 180) * Math.PI const radius = Math.cos(longitude) * globeRadius const targetX = Math.cos(latitude) * radius const targetY = Math.sin(longitude) * globeRadius @@ -177,13 +177,16 @@ function init() { var projected = position.project(camera.object) return { x: projected.x * width + width - contentWidth / 2, + y: -(projected.y * height) + height - contentHeight - 10, // -10 for a small offset } } function returnCameraAngles(x, y) { let targetAzimuthalAngle = ((x - globeWidth) / globeWidth) * Math.PI targetAzimuthalAngle = targetAzimuthalAngle + Math.PI / 2 + targetAzimuthalAngle += 0.3 let targetPolarAngle = (y / (globeHeight * 2)) * Math.PI + targetPolarAngle += 0.1 // Add a small vertical offset return { azimuthal: targetAzimuthalAngle, polar: targetPolarAngle, @@ -221,6 +224,7 @@ function init() { function render() { renderer.render(scene, camera.object) requestAnimationFrame(render) + //animate() groups.globePoints.rotation.y += 0.01 if (groups.tracePoints !== null) { groups.tracePoints.rotation.y += 0.01 diff --git a/php/traceroute.php b/php/traceroute.php index 86d2718..669cca6 100755 --- a/php/traceroute.php +++ b/php/traceroute.php @@ -20,12 +20,32 @@ function ip2geo ($host) { } } +function get_client_ip() { + $ipaddress = ''; + if (getenv('HTTP_CLIENT_IP')) + $ipaddress = getenv('HTTP_CLIENT_IP'); + else if(getenv('HTTP_X_FORWARDED_FOR')) + $ipaddress = getenv('HTTP_X_FORWARDED_FOR'); + else if(getenv('HTTP_X_FORWARDED')) + $ipaddress = getenv('HTTP_X_FORWARDED'); + else if(getenv('HTTP_FORWARDED_FOR')) + $ipaddress = getenv('HTTP_FORWARDED_FOR'); + else if(getenv('HTTP_FORWARDED')) + $ipaddress = getenv('HTTP_FORWARDED'); + else if(getenv('REMOTE_ADDR')) + $ipaddress = getenv('REMOTE_ADDR'); + else + $ipaddress = 'UNKNOWN'; + return $ipaddress; + +} + $data = array("points" => array()); $traceroute = ""; function traceroute() { global $data, $traceroute; - $traceroute = shell_exec("traceroute google.com"); + $traceroute = shell_exec("traceroute " . get_client_ip()); $first = true; foreach(preg_split("/((\r?\n)|(\r\n?))/", $traceroute) as $line){