Home
22 | 02 | 2012
Newsflash
Welcome to the Frontpage
TrackMyPath Webserver PHP version 1.2 PDF Print E-mail
Written by Manager   
Sunday, 12 September 2010 00:00

TrackMyPath

GPS and GPRS based position server for the GlobalSat TR-151


The PHP version 1.2 of TrackMyPath FREE open source GPRS server for Webservers is now released!

Finnno3d

Show your Trackers Position like this on Finn.no, Google Maps and similar.

 

 

Trackers Position in 3D on Finn.no.

 

This release features:

Runs on most webserver running PHP

 Only trackers allowed by you can use your server! 

You setup the server to only allow the trackers you want.

 Parses string sent from tracker, extracting the following information

 IMEI number sendt by tracker

  • Date & Time (in UTC format)
  • Longitude
  • Latitude

Output to HTML file

File contains links to maps with position of tracker alreade inserted as direct links,

using maps from

  • Finn.no
  • GoogleMaps.com
  • MSNmaps
  • MapQuest 

Each tracker gets its own, uniqe html file

Outputfiles name is based on IMEI nr, so you can easily distinquish between several trackers!

Installs easily on most webserver, you can now host your own Tracking webserver, ensuring privacy!

 Simply copy the TrackMyPath php script to the web server root path, and  access your trackers latest position using www.myhost.com/12345678912345.html!

Open Source

Full PHP source code is available, under the GPL license


 

Configuration

On the webserver:

The code has been made to only save the trackers you have allowed.

The filtering is based on the IMEI number of your tracker. This number

is uniqe for all tracker.

 

On the tracker:

Setup of the tracker by sendinga setup sms similar to the following to the tracker:
?7,357248013712345,A,80,internet,,,www.myhost.com,A0,30!

explaination:

?7,Your trackers IMEI goes here,A,your webservers portnumber goes here,Your mobile phone providers nameserver goes here,,,Your webservers address goes here,A0,30!

Installation

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!

 

Feel free to contact me at

asgeir{a}asgeirs.com


Last Updated on Monday, 27 June 2011 20:08