Skip to content

Commit

Permalink
added databases
Browse files Browse the repository at this point in the history
  • Loading branch information
brentfraser committed Aug 21, 2015
1 parent 357e40c commit 2b59e17
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 15 deletions.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:

Expand Down
30 changes: 28 additions & 2 deletions servers/php/dbconnect.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
<?php

const DB_MYSQL = 0;
const DB_POSTGRESQL = 1;
const DB_SQLITE3 = 2;

// ======== Start of user-configurable variables =======================
// --- set this to use YOUR database type: ------
$dbType = DB_SQLITE3;

// if your database is DB_SQLITE3, you need to set the path to your database file:
$pathToSQLite = 'sqlite\gpstracker.sqlite';

// ======== End of user-configurable variables =======================

$dbuser = 'gpstracker_user';
$dbpass = 'gpstracker';

$params = array(PDO::ATTR_ERRMODE => 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;
}
?>
13 changes: 11 additions & 2 deletions servers/php/deleteroute.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

?>
13 changes: 11 additions & 2 deletions servers/php/getallroutesformap.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
<?php

include 'dbconnect.php';

$stmt = $pdo->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": [';
Expand Down
13 changes: 11 additions & 2 deletions servers/php/getrouteformap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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": [';
Expand Down
11 changes: 10 additions & 1 deletion servers/php/getroutes.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
<?php
include 'dbconnect.php';

$stmt = $pdo->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": [';
Expand Down
13 changes: 10 additions & 3 deletions servers/php/updatelocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -40,7 +40,9 @@
':eventtype' => $eventtype
);

$stmt = $pdo->prepare('CALL prcSaveGPSLocation(
switch ($dbType) {
case DB_MYSQL:
$stmt = $pdo->prepare( $sqlFunctionCallMethod.'prcSaveGPSLocation(
:latitude,
:longitude,
:speed,
Expand All @@ -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;
Expand Down

0 comments on commit 2b59e17

Please sign in to comment.