diff --git a/icons/download-speed.png b/icons/download-speed.png new file mode 100644 index 0000000..d7fd342 Binary files /dev/null and b/icons/download-speed.png differ diff --git a/icons/mia.png b/icons/mia.png new file mode 100644 index 0000000..a9231a6 Binary files /dev/null and b/icons/mia.png differ diff --git a/icons/mountain.png b/icons/mountain.png new file mode 100644 index 0000000..0354782 Binary files /dev/null and b/icons/mountain.png differ diff --git a/icons/speed.png b/icons/speed.png new file mode 100644 index 0000000..2ba9a7f Binary files /dev/null and b/icons/speed.png differ diff --git a/includes/class.utils.php b/includes/class.utils.php new file mode 100644 index 0000000..708bbb7 --- /dev/null +++ b/includes/class.utils.php @@ -0,0 +1,91 @@ + array(_YEAR, _YEARS), + 2592000 => array(_MONTH, _MONTHS), + 604800 => array(_WEEK, _WEEKS), + 86400 => array(_DAY, _DAYS), + 3600 => array(_HOUR, _HOURS), + 60 => array(_MINUTE, _MINUTES), + 1 => array(_SECOND, _SECONDS) + ); + + foreach ($tokens as $unit => $text) { + if ($dateTime < $unit) continue; + $numberOfUnits = floor($dateTime / $unit); + return $numberOfUnits . "" . ($sendUnis ? (($numberOfUnits > 1) ? " " . $text[1] : " " . $text[0]) : "") . ""; + } + } + + function convertUnit($meterPerSec,$unit='kilometer_per_hour',$label=false){ + $units=array( + "kilometer_per_hour"=>"0.2777778", + "mile_per_hour"=>"0.44704" + ); + $unitsLabels=array( + "kilometer_per_hour"=>"km/h", + "mile_per_hour"=>" mi/h" + ); + if($label){ + return number_format(($meterPerSec*$units[$unit]),0,",","")." ".$unitsLabels[$unit]; + }else{ + return number_format(($meterPerSec*$units[$unit]),0,",",""); + } + + } + + function generateRandomPoint($centre, $radius="") { + $radius_earth = 5; //miles + + //Pick random distance within $distance; + $distance = lcg_value()*$radius; + + //Convert degrees to radians. + $centre_rads = array_map( 'deg2rad', $centre ); + + //First suppose our point is the north pole. + //Find a random point $distance miles away + $lat_rads = (pi()/2) - $distance/$radius_earth; + $lng_rads = lcg_value()*2*pi(); + + + //($lat_rads,$lng_rads) is a point on the circle which is + //$distance miles from the north pole. Convert to Cartesian + $x1 = cos( $lat_rads ) * sin( $lng_rads ); + $y1 = cos( $lat_rads ) * cos( $lng_rads ); + $z1 = sin( $lat_rads ); + + + //Rotate that sphere so that the north pole is now at $centre. + + //Rotate in x axis by $rot = (pi()/2) - $centre_rads[0]; + $rot = (pi()/2) - $centre_rads[0]; + $x2 = $x1; + $y2 = $y1 * cos( $rot ) + $z1 * sin( $rot ); + $z2 = -$y1 * sin( $rot ) + $z1 * cos( $rot ); + + //Rotate in z axis by $rot = $centre_rads[1] + $rot = $centre_rads[1]; + $x3 = $x2 * cos( $rot ) + $y2 * sin( $rot ); + $y3 = -$x2 * sin( $rot ) + $y2 * cos( $rot ); + $z3 = $z2; + + + //Finally convert this point to polar co-ords + $lng_rads = atan2( $x3, $y3 ); + $lat_rads = asin( $z3 ); + + return array_map( 'rad2deg', array( $lat_rads, $lng_rads ) ); + } + + } +} \ No newline at end of file diff --git a/includes/settings.php b/includes/settings.php new file mode 100644 index 0000000..58e0a59 --- /dev/null +++ b/includes/settings.php @@ -0,0 +1,50 @@ + - -

You probably want the Map page.

- - diff --git a/index.php b/index.php new file mode 100644 index 0000000..f30757a --- /dev/null +++ b/index.php @@ -0,0 +1,71 @@ +timeAgo(date("Y-m-d H:i:s",substr($info['timestamp'],0,-3))); + $altitude=number_format($info['altitude'],0,",","")." m"; + $speedLabel=$ClassUtils->convertUnit($info['speed'],$unitForSpeed,true); + $speed=$ClassUtils->convertUnit($info['speed'],$unitForSpeed); + + if($_GET['realgps']==$secretRealGPSKey){ + $lat = $info['reallat']; + $lon = $info['reallon']; + }else{ + $lat = $info['fakelat']; + $lon = $info['fakelon']; + } + + if($speed>0){ + $statusIcon="marker-lg-417505-$speed"; + }else{ + $statusIcon="marker-lg-f2231f-$speed"; + } + //$statusIcon=$trackerURL."icons/mia.png"; + + $staticUrl = 'https://www.mapquestapi.com/staticmap/v5/map?'; + $staticUrl = $staticUrl."size=$width,$height&type=map&imagetype=jpeg&key=$apikey"; + $staticUrl = $staticUrl . "&locations=$lat,$lon|".$statusIcon."&size=@2x|&zoom=$zoom¢er=$lat,$lon"; + $mapUrl = 'https://www.openstreetmap.org'; + $mapUrl = $mapUrl . "?mlat=$lat&mlon=$lon"; + }else{ + die(_LOCATION_FILE_DOES_NOT_EXIST); + } + + /* Note that you can embed an interactive map using: + $bbox = 0.01; // Zoom. 0.1 gives an overview, 0.01 is quite zoomed in, 0.001 is street-level. + $bboxleft = $lon - $bbox; + $bboxbottom = $lat - $bbox; + $bboxright = $lon + $bbox; + $bboxtop = $lat + $bbox; + $bb = urlencode($bboxleft . ',' . $bboxbottom . ',' . $bboxright . ',' . $bboxtop); + + The issue is that you cannot place a marker (not that I have found). + */ + echo " + + $pageTitle + ".($refreshTime>0?"":"")." + + +
+ ".($timeAgo>0?"

".$yourName." "._STATUS_AS_OF." ".$timeAgo."

":"")." +

+ ".($speed>0?"".$speedLabel."":""._IT_IS_STOPPED."")." + ".$altitude."

+

+

"._CLICK_TO_SEE_INTERACTIVE_MAP."

+ "._PAGE_GENERATED_AT." ".date("H:i")." +
+ + "; + + diff --git a/languages/en.php b/languages/en.php new file mode 100644 index 0000000..746c06a --- /dev/null +++ b/languages/en.php @@ -0,0 +1,31 @@ +https://developer.mapquest.com/"); + +DEFINE ("_WARNING_NEED_TO_CHANGE_SECRET_KEY", "This application is not functional yet. See the README how to set it up (hint: edit settings.php)."); +DEFINE ("_LOCATION_FILE_DOES_NOT_EXIST", "The localtion file needed to run this application is not yet available, please return later."); + +DEFINE ("_YEAR", "year"); +DEFINE ("_YEARS", "years"); +DEFINE ("_MONTH", "month"); +DEFINE ("_MONTHS", "months"); +DEFINE ("_WEEK", "week"); +DEFINE ("_WEEKS", "weeks"); +DEFINE ("_DAY", "day"); +DEFINE ("_DAYS", "days"); +DEFINE ("_HOUR", "hour"); +DEFINE ("_HOURS", "hours"); +DEFINE ("_MINUTE", "minute"); +DEFINE ("_MINUTES", "minutes"); +DEFINE ("_SECOND", "second"); +DEFINE ("_SECONDS", "seconds"); + + diff --git a/languages/pt.php b/languages/pt.php new file mode 100644 index 0000000..9c8dae0 --- /dev/null +++ b/languages/pt.php @@ -0,0 +1,29 @@ +https://developer.mapquest.com/"); +DEFINE ("_WARNING_NEED_TO_CHANGE_SECRET_KEY", "Este aplicativo ainda não está funcional. Veja o README como configurá-lo (dica: edite o settings.php e altere a chave secreta)."); +DEFINE ("_LOCATION_FILE_DOES_NOT_EXIST", "O arquivo de localização necessário para executar este aplicativo ainda não está disponível, por favor volte mais tarde."); + +DEFINE ("_YEAR", "ano"); +DEFINE ("_YEARS", "anos"); +DEFINE ("_MONTH", "mês"); +DEFINE ("_MONTHS", "meses"); +DEFINE ("_WEEK", "semana"); +DEFINE ("_WEEKS", "semanas"); +DEFINE ("_DAY", "dia"); +DEFINE ("_DAYS", "dias"); +DEFINE ("_HOUR", "hora"); +DEFINE ("_HOURS", "horas"); +DEFINE ("_MINUTE", "minuto"); +DEFINE ("_MINUTES", "minutos"); +DEFINE ("_SECOND", "segundo"); +DEFINE ("_SECONDS", "segundos"); \ No newline at end of file diff --git a/map.php b/map.php deleted file mode 100644 index 665a222..0000000 --- a/map.php +++ /dev/null @@ -1,46 +0,0 @@ - - - - - <?php echo $name?>'s Location - - - -

's status as of minutes ago:

-

Speed: m/s

- >
-

Click for an interactive map

- &layer=mapnik" width=800 height=600> - - The issue is that you cannot place a marker (not that I have found). - */ - ?> - - - - diff --git a/settings.php b/settings.php deleted file mode 100644 index a56a7ae..0000000 --- a/settings.php +++ /dev/null @@ -1,25 +0,0 @@ - random_int(-90, 90 - 1) + (random_int(0, PHP_INT_MAX - 1) / PHP_INT_MAX ), + 'y' => random_int(-180, 180 - 1) + (random_int(0, PHP_INT_MAX - 1) / PHP_INT_MAX ) + ); + + $min=1; + $max=300; + $hdop=($min+lcg_value()*(abs($max-$min))); + $altitude=($min+lcg_value()*(abs($max-$min))); + $speed=($min+lcg_value()*(abs($max-$min))); + $timestamp=time(); + + $info['lat'] = round($point['x'], $accuracy); + $info['lon'] = round($point['y'], $accuracy); + $info['timestamp'] = intval($timestamp)."000"; + $info['hdop'] = floatval($hdop); + $info['altitude'] = floatval($altitude); + $info['speed'] = floatval($speed); + $url=$trackerURL."/tracker.php?lat=".$info['lat']."&lon=".$info['lon']."×tamp=".$info['timestamp']."&hdop=".$info['hdop']."&altitude=".$info['altitude']."&speed=".$info['speed']."&key=".$secretKey; + echo "$url"; + $fh = fopen($filePath, 'w'); + fwrite($fh, serialize($info)); + fclose($fh); \ No newline at end of file diff --git a/tracker.php b/tracker.php index 057d30c..f39f751 100644 --- a/tracker.php +++ b/tracker.php @@ -1,17 +1,23 @@ generateRandomPoint(array($atualLongitude,$atualLatitude),"0,5"); + $info['fakelat'] = round($fakeGPS[0], $accuracy); + $info['fakelon'] = round($fakeGPS[1], $accuracy); - $info['lat'] = round($_GET['lat'], $accuracy); - $info['lon'] = round($_GET['lon'], $accuracy); $info['timestamp'] = intval($_GET['timestamp']); $info['hdop'] = floatval($_GET['hdop']); $info['altitude'] = floatval($_GET['altitude']);