diff --git a/README.md b/README.md index 6e8d092..aa12b33 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,24 @@ ![gpstracker](https://raw.githubusercontent.com/nickfox/GpsTracker/master/gpstracker_small.png)Gps Tracker v4.0.3 ------------- -##### Google Map Gps Cell Phone Tracker +##### Google Map Gps Cell Phone Tracker Server -This project allows you to track cell phones periodically. For instance every minute or every five minutes. You can watch the cell phone being tracked in real time using google maps and you can store and reload routes easily. The map display page is built using bootstrap which makes the page responsive and also uses bootswatch which gives you the choice of 17 differeent themes. There are 4 clients, ios, android, windows phone and java me. +This project allows you to track cell phones periodically. For instance every minute or every five minutes. You can watch the cell phone being tracked in real time using Google Maps and you can store and reload routes easily. The map display page is built using bootstrap which makes the page responsive and also uses bootswatch which gives you the choice of 17 different themes. There are 4 clients, iOS, Android, Windows Phone and Java ME. -You have the choice of two server stacks. Either using asp.net and sql server or using php and mysql. Both are now in the same download but you only need to use one. +You have the choice of two server stacks. Either using: +1. ASP.NET with SQL Server + + or +2. using PHP with your choice of: + * MySQL + * PostgreSQL + * SQLite + +Both stacks are now in the same download but you only need to use one. + +By default the Tracker server is set up to use the included SQLite database. If you want to use one of the other supported database systems, edit the dbconnect.php file included with the Tracker Server. + +**Note:** This is only the server portion of the system. You will also need a client app running on your phone. Have a look at the Quick Start Guide in the link below for information on how to get the client apps. If you need help, please go to: diff --git a/servers/php/dbconnect.php b/servers/php/dbconnect.php index 0261563..b64b175 100644 --- a/servers/php/dbconnect.php +++ b/servers/php/dbconnect.php @@ -1,10 +1,36 @@ PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC); -$pdo = new PDO('mysql:host=localhost;dbname=gpstracker;charset=utf8', $dbuser, $dbpass, $params); - +switch ($dbType) { + case DB_MYSQL: + $pdo = new PDO('mysql:host=localhost;dbname=gpstracker;charset=utf8', $dbuser, $dbpass, $params); + $sqlFunctionCallMethod = 'CALL '; + break; + case DB_POSTGRESQL: + $pdo = new PDO('pgsql:host=localhost;dbname=gpstracker', $dbuser, $dbpass, $params); + $sqlFunctionCallMethod = 'select '; + break; + case DB_SQLITE3: + $pdo = new PDO('sqlite:'.$pathToSQLite, $dbuser, $dbpass, $params); + $sqlFunctionCallMethod = 'select '; + break; +} ?> \ No newline at end of file diff --git a/servers/php/deleteroute.php b/servers/php/deleteroute.php index 2484af5..30a1718 100644 --- a/servers/php/deleteroute.php +++ b/servers/php/deleteroute.php @@ -2,8 +2,17 @@ include 'dbconnect.php'; $sessionid = isset($_GET['sessionid']) ? $_GET['sessionid'] : '0'; - - $stmt = $pdo->prepare('CALL prcDeleteRoute(:sessionID)'); + + switch ($dbType) { + case DB_MYSQL: + $stmt = $pdo->prepare($sqlFunctionCallMethod.'prcDeleteRoute(:sessionID)'); + break; + case DB_POSTGRESQL: + case DB_SQLITE3: + $stmt = $pdo->prepare('DELETE FROM gpslocations WHERE sessionID = :sessionID'); + break; + } + $stmt->execute(array(':sessionID' => $sessionid)); ?> diff --git a/servers/php/getallroutesformap.php b/servers/php/getallroutesformap.php index c3e58bb..101e780 100644 --- a/servers/php/getallroutesformap.php +++ b/servers/php/getallroutesformap.php @@ -1,8 +1,17 @@ prepare('CALL prcGetAllRoutesForMap();'); + + switch ($dbType) { + case DB_MYSQL: + $stmt = $pdo->prepare('CALL prcGetAllRoutesForMap();'); + break; + case DB_POSTGRESQL: + case DB_SQLITE3: + $stmt = $pdo->prepare('select * from v_GetAllRoutesForMap;'); + break; + } + $stmt->execute(); $json = '{ "locations": ['; diff --git a/servers/php/getrouteformap.php b/servers/php/getrouteformap.php index 816b047..a7afcec 100644 --- a/servers/php/getrouteformap.php +++ b/servers/php/getrouteformap.php @@ -2,8 +2,17 @@ include 'dbconnect.php'; $sessionid = isset($_GET['sessionid']) ? $_GET['sessionid'] : '0'; - - $stmt = $pdo->prepare('CALL prcGetRouteForMap(:sessionID)'); + + switch ($dbType) { + case DB_MYSQL: + $stmt = $pdo->prepare('CALL prcGetRouteForMap(:sessionID)'); + break; + case DB_POSTGRESQL: + case DB_SQLITE3: + $stmt = $pdo->prepare("select * from v_GetRouteForMap where sessionID = :sessionID"); + break; + } + $stmt->execute(array(':sessionID' => $sessionid)); $json = '{ "locations": ['; diff --git a/servers/php/getroutes.php b/servers/php/getroutes.php index 4082b4a..59159cd 100644 --- a/servers/php/getroutes.php +++ b/servers/php/getroutes.php @@ -1,7 +1,16 @@ prepare('CALL prcGetRoutes();'); + switch ($dbType) { + case DB_MYSQL: + $stmt = $pdo->prepare('CALL prcGetRoutes();'); + break; + case DB_POSTGRESQL: + case DB_SQLITE3: + $stmt = $pdo->prepare('select * from v_GetRoutes;'); + break; + } + $stmt->execute(); $json = '{ "routes": ['; diff --git a/servers/php/updatelocation.php b/servers/php/updatelocation.php index 8ce4b1c..afe6b7d 100644 --- a/servers/php/updatelocation.php +++ b/servers/php/updatelocation.php @@ -9,7 +9,7 @@ $direction = isset($_GET['direction']) ? $_GET['direction'] : 0; $distance = isset($_GET['distance']) ? $_GET['distance'] : '0'; $distance = (float)str_replace(",", ".", $distance); - $date = isset($_GET['date']) ? $_GET['date'] : '0000-00-00 00:00:00'; + $date = isset($_GET['date']) ? $_GET['date'] : '0001-01-01 00:00:00'; $date = urldecode($date); $locationmethod = isset($_GET['locationmethod']) ? $_GET['locationmethod'] : ''; $locationmethod = urldecode($locationmethod); @@ -40,7 +40,9 @@ ':eventtype' => $eventtype ); - $stmt = $pdo->prepare('CALL prcSaveGPSLocation( + switch ($dbType) { + case DB_MYSQL: + $stmt = $pdo->prepare( $sqlFunctionCallMethod.'prcSaveGPSLocation( :latitude, :longitude, :speed, @@ -55,7 +57,12 @@ :extrainfo, :eventtype);' ); - + break; + case DB_POSTGRESQL: + case DB_SQLITE3: + $stmt = $pdo->prepare('INSERT INTO gpslocations (latitude, longitude, speed, direction, distance, gpsTime, locationMethod, userName, phoneNumber, sessionID, accuracy, extraInfo, eventType) VALUES (:latitude, :longitude, :speed, :direction, :distance, :date, :locationmethod, :username, :phonenumber, :sessionid, :accuracy, :extrainfo, :eventtype)'); + break; + } $stmt->execute($params); $timestamp = $stmt->fetchColumn(); echo $timestamp;