After you have edited the code according to the instructions in the source, you install it by
uploading the code into the root of your webserver with the filename
tr151.php
Source:
<html><body>
<?php
// TrackMyPath PHP
// version 1.2
// released 22 Feb 2011
//
// Configuration:
// edit the AllowedIMEIs under to your trackers IMEI numbers, you can find it inside the battey lid
// If you have only one tracker, just write the same IMEI number in both. (Or edit the code if you prefer)
//
$AllowedIMEI1 = "357248013712345"; //<- insert your GlobalSat trackers IMEI number here.
$AllowedIMEI2 = "357248013712346"; //<- insert your 2nd GlobalSat trackers IMEI number here.
//$AllowedIMEI3 = "insert 3rd imei nuber here" ;
//$AllowedIMEI4 = "insert 3rd imei nuber here" ;
// if you need more trackers, you have to edit the code. se example on line above, and at the "IMEI check section below"
// TESTING:
// you can test it by sending a http request like the one in the line below from your web browser
//
// http://www.myhost.com/tr151.php?RMC=$357248013712345,A1,3,280810,095601,E01741.2111,N6839.7750,129.2,0.94,21.26,7,1.14!
// where you have to replace www.myhost.com with your actual webservers address.
// it should respond by sending a message saying "ERROR!!! IMEI not in allowed list"
// if you change the part of the string with the number $357248013712345 into your trackers actual number,
// it should reply with a empty website, and a file should be written to your server with the name
//
// The actual code:
if (isset($_GET['RMC']))
{
$string = $_GET['RMC'];
$words = array(); // array to store each name
$words = explode(",", $string); // Multiple names
$IMEI = str_replace("$", "", $words[0]);
//IMEI check section
if (($IMEI == $AllowedIMEI1) || ($IMEI == $AllowedIMEI2)){ // Here a check is performed to verify that nobody is spamming your server...
// If you need more trackers, you have to add "|| ($IMEI == $AllowedIMEI3)" (without the ") before the last end bracket part "){"
//see example on line below for 4 trackers
//if (($IMEI == $AllowedIMEI1) || ($IMEI == $AllowedIMEI2) || ($IMEI == $AllowedIMEI3) || ($IMEI == $AllowedIMEI4)){
//END IMEI check section
$mindecLong = $words[5];
$mindecLat = $words[6];
//to find E/W or N/S, access characters within a PHP string using the index of the caracter in curly braces
$hemisphereLong = $mindecLong{0};
$hemisphereLat = $mindecLat{0};
for( $i = 1; $i < 4 ; $i++ ) {
$degLong .= $mindecLong{$i};
}
(int) $degLong;
for( $i = 4; $i < 11 ; $i++ ) {
$minLong .= $mindecLong{$i};
}
(float) $minLong;
$minLong = $minLong/60;
for( $i = 1; $i < 3 ; $i++ ) {
$degLat .= $mindecLat{$i};
}
(int) $degLat;
for( $i = 3; $i < 10 ; $i++ ) {
$minLat .= $mindecLat{$i};
}
(float) $minLat;
$minLat = $minLat/60;
(int) $decimaldegreeLong;
$decimaldegreeLong = $degLong+$minLong;
if ( $hemisphereLong == "W" ){
$decimaldegreeLong = -$decimaldegreeLong;
}
(int) $decimaldegreeLat;
$decimaldegreeLat = $degLat+$minLat;
if ( $hemisphereLat == "S" ){
$decimaldegreeLat = -$decimaldegreeLat;
}
$texthtml = <<<TEXT
<html><head><title>TrackMyPath PHP </title></head><body><br> Tracker with IMEI nr:
$IMEI sent at UTC (GMT) date,time: $words[3],$words[4] <br />
<a href="http://kart.finn.no?lng=$decimaldegreeLong&lat=$decimaldegreeLat&zoom=15&mapType=finnhybrid&WT.mc_id=
hp_map_cb&title=TrackerPosition&showPin=true">Position, shown on Finn.no</a><br /><br />
<a href="http://maps.google.com/maps?q=$decimaldegreeLat,+$decimaldegreeLong+(Position)&iwloc=A&hl=en">
Position, shown on Googlemaps</a><br /><br />
<a href="http://maps.msn.com/(4namhj45oykuaq3cjmweqcyl)/map.aspx?&lats1=$decimaldegreeLat&lons1=$decimaldegreeLong
&alts1=7&name=Position®n1=1"> Position, shown on MSNmaps</a><br /><br />
<a href="http://atlas.mapquest.com/maps/map.adp?searchtype=address&formtype=latlong&latlongtype=decimal&latitude=
$decimaldegreeLat&longitude=$decimaldegreeLong"> Position, shown on MapQuest</a><br />
</body>
</html>
TEXT;
$FileName = "$IMEI.htm";
$FileHandle = fopen($FileName, 'w') or die("can't open file");
fwrite($FileHandle, $texthtml);
fclose($FileHandle);
}
else //IMEI is wrong
echo "<html><head><title>TrackMyPath PHP </title></head><body>ERROR!!! IMEI not in allowed list</body></html>";
}
?>
</body></html>
Thanks to Paul Sanders for pointing out an error in the Lat/Long conversion routines!