diff --git a/phoneClients/android/.idea/libraries/appcompat_v7_19_1_0.xml b/phoneClients/android/.idea/libraries/appcompat_v7_19_1_0.xml deleted file mode 100644 index 700d529..0000000 --- a/phoneClients/android/.idea/libraries/appcompat_v7_19_1_0.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/phoneClients/android/.idea/libraries/appcompat_v7_20_0_0.xml b/phoneClients/android/.idea/libraries/appcompat_v7_20_0_0.xml new file mode 100644 index 0000000..ff9c6c1 --- /dev/null +++ b/phoneClients/android/.idea/libraries/appcompat_v7_20_0_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/phoneClients/android/.idea/libraries/play_services_4_3_23.xml b/phoneClients/android/.idea/libraries/play_services_4_3_23.xml index a3a6599..0f3af43 100644 --- a/phoneClients/android/.idea/libraries/play_services_4_3_23.xml +++ b/phoneClients/android/.idea/libraries/play_services_4_3_23.xml @@ -1,8 +1,8 @@ - - + + diff --git a/phoneClients/android/.idea/libraries/support_annotations_20_0_0.xml b/phoneClients/android/.idea/libraries/support_annotations_20_0_0.xml new file mode 100644 index 0000000..9e4620b --- /dev/null +++ b/phoneClients/android/.idea/libraries/support_annotations_20_0_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/phoneClients/android/.idea/libraries/support_v4_19_1_0.xml b/phoneClients/android/.idea/libraries/support_v4_19_1_0.xml deleted file mode 100644 index 3f6ff2d..0000000 --- a/phoneClients/android/.idea/libraries/support_v4_19_1_0.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/phoneClients/android/.idea/libraries/support_v4_20_0_0.xml b/phoneClients/android/.idea/libraries/support_v4_20_0_0.xml new file mode 100644 index 0000000..0db4e14 --- /dev/null +++ b/phoneClients/android/.idea/libraries/support_v4_20_0_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/phoneClients/android/.idea/workspace.xml b/phoneClients/android/.idea/workspace.xml index a34b4fa..f0b7cd4 100644 --- a/phoneClients/android/.idea/workspace.xml +++ b/phoneClients/android/.idea/workspace.xml @@ -41,7 +41,22 @@ + + + + + + + + + + + + + + + @@ -96,8 +111,8 @@ @@ -105,51 +120,31 @@ - + - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - + + @@ -502,9 +497,14 @@ - @@ -1010,7 +1012,7 @@ - + @@ -1018,9 +1020,15 @@ + - + + @@ -1030,21 +1038,11 @@ - - - - - - @@ -1054,19 +1052,19 @@ @@ -1076,31 +1074,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1167,19 +1252,6 @@ - + - - - + + + + - - - - - - - + + + + + + + - + - - - + + + - @@ -1387,15 +1472,15 @@ - - - + + + - + @@ -1408,8 +1493,8 @@ - + @@ -1525,14 +1610,14 @@ + + + - - - @@ -1704,13 +1789,6 @@ - - - - - - - @@ -1730,13 +1808,6 @@ - - - - - - - @@ -1751,24 +1822,6 @@ - - - - - - - - - - - - - - - - - - @@ -1776,14 +1829,6 @@ - - - - - - - - @@ -1792,26 +1837,72 @@ - + - - - - - - - - - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/phoneClients/android/android.iml b/phoneClients/android/android.iml index edb62a6..0bb6048 100644 --- a/phoneClients/android/android.iml +++ b/phoneClients/android/android.iml @@ -1,5 +1,12 @@ + + + + + + diff --git a/phoneClients/android/app/app.iml b/phoneClients/android/app/app.iml index fa9ba3f..82b2a60 100644 --- a/phoneClients/android/app/app.iml +++ b/phoneClients/android/app/app.iml @@ -56,15 +56,34 @@ - + + + + + + + + + + + + + + + + + + + - + - - + + + diff --git a/phoneClients/android/app/build.gradle b/phoneClients/android/app/build.gradle index 90383f3..f914464 100644 --- a/phoneClients/android/app/build.gradle +++ b/phoneClients/android/app/build.gradle @@ -1,18 +1,18 @@ apply plugin: 'android' android { - compileSdkVersion 19 - buildToolsVersion "19.1.0" + compileSdkVersion 20 + buildToolsVersion "20.0.0" defaultConfig { + applicationId "com.websmithing.gpstracker" minSdkVersion 10 - targetSdkVersion 19 - versionCode 4 - versionName "3.2.4" + targetSdkVersion 20 + versionCode 5 + versionName "3.2.5" } buildTypes { release { - debuggable false runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } @@ -20,7 +20,7 @@ } dependencies { - compile 'com.android.support:appcompat-v7:+' compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:20.0.0' compile 'com.google.android.gms:play-services:4.3.23' } diff --git a/phoneClients/android/app/src/main/AndroidManifest.xml b/phoneClients/android/app/src/main/AndroidManifest.xml index 4fb95b0..3895fff 100644 --- a/phoneClients/android/app/src/main/AndroidManifest.xml +++ b/phoneClients/android/app/src/main/AndroidManifest.xml @@ -9,7 +9,6 @@ - - - - - - Gps Tracker - https://www.websmithing.com/gpstracker/updatelocation.php + https://www.websmithing.com/gpstracker2/updatelocation.php Tracking is Off Tracking is On @@ -14,10 +14,7 @@ user name upload website - How often to update website. Updating more often wears down the battery faster. Update every: + Update website every: 1 minute 5 minutes - 15 minutes - 30 minutes - 1 hour diff --git a/phoneClients/android/build.gradle b/phoneClients/android/build.gradle index 4c8f6d8..c722660 100644 --- a/phoneClients/android/build.gradle +++ b/phoneClients/android/build.gradle @@ -5,7 +5,7 @@ mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:0.11.+' + classpath 'com.android.tools.build:gradle:0.12.2' } } diff --git a/phoneClients/android/build/intermediates/dex-cache/cache.xml b/phoneClients/android/build/intermediates/dex-cache/cache.xml index 2aa96cb..c2c12f6 100644 --- a/phoneClients/android/build/intermediates/dex-cache/cache.xml +++ b/phoneClients/android/build/intermediates/dex-cache/cache.xml @@ -2,11 +2,17 @@ + revision="20.0.0" + sha1="9d9013e9ff35fc3756411e62873c363c70c638fa"/> + + revision="20.0.0" + sha1="e40b3078e3fbd353c9f44da8df25a8fc0078209d"/> + revision="20.0.0" + sha1="7676c0cb230efa6ac41c47867d372ed5913029d4"/> + + diff --git a/servers/php/dbconnect.php b/servers/php/dbconnect.php index 3a23fe5..fca412e 100644 --- a/servers/php/dbconnect.php +++ b/servers/php/dbconnect.php @@ -1,15 +1,15 @@ PDO::ERRMODE_EXCEPTION, + PDO::ATTR_EMULATE_PREPARES => false, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC); -$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname); +$pdo = new PDO('mysql:host=localhost;dbname=gpstracker2;charset=utf8', $dbuser, $dbpass, $params); -if (mysqli_connect_errno()) { - echo "Connection failed: " . mysqli_connect_error(); - exit(); +if (version_compare(PHP_VERSION, '5.3.6', '<')) { + $pdo->exec('set names utf8'); } ?> \ No newline at end of file diff --git a/servers/php/deleteroute.php b/servers/php/deleteroute.php index bc195e1..9f6cd9b 100644 --- a/servers/php/deleteroute.php +++ b/servers/php/deleteroute.php @@ -1,15 +1,7 @@ prepare('CALL prcDeleteRoute(:sessionID, :phoneNumber)'); + $stmt->execute(array(':sessionID' => $_GET['sessionID'], ':phoneNumber' => $_GET['phoneNumber'])); - isset($_GET['sessionID']) ? $sessionID = $_GET['sessionID'] : $sessionID = '0'; - isset($_GET['phoneNumber']) ? $phoneNumber = $_GET['phoneNumber'] : $phoneNumber = '0'; - - $query = 'CALL prcDeleteRoute(\'' . $sessionID . '\',\'' . $phoneNumber . '\')'; - - // execute query - if (!$mysqli->multi_query($query)) { - die('$mysqli->multi_query: ' . $mysqli->error); - } - - $mysqli->close(); ?> diff --git a/servers/php/getallroutesformap.php b/servers/php/getallroutesformap.php index 4499e8f..c3e58bb 100644 --- a/servers/php/getallroutesformap.php +++ b/servers/php/getallroutesformap.php @@ -2,26 +2,14 @@ include 'dbconnect.php'; + $stmt = $pdo->prepare('CALL prcGetAllRoutesForMap();'); + $stmt->execute(); - $query = 'CALL prcGetAllRoutesForMap()'; - $json = '{ "locations": ['; - // execute query - if ($mysqli->multi_query($query)) { - - do { // build our json array - if ($result = $mysqli->store_result()) { - while ($row = $result->fetch_row()) { - $json .= $row[2]; - $json .= ','; - } - $result->close(); - } - } while ($mysqli->more_results() && $mysqli->next_result()); - } - else { - die('error: ' . $mysqli->error); + foreach ($stmt as $row) { + $json .= $row['json']; + $json .= ','; } $json = rtrim($json, ","); @@ -30,5 +18,4 @@ header('Content-Type: application/json'); echo $json; - $mysqli->close(); ?> \ No newline at end of file diff --git a/servers/php/getgpslocations.php b/servers/php/getgpslocations.php deleted file mode 100644 index fec87e4..0000000 --- a/servers/php/getgpslocations.php +++ /dev/null @@ -1,36 +0,0 @@ -multi_query($query)) { - - do { // build our json array - if ($result = $mysqli->store_result()) { - while ($row = $result->fetch_row()) { - $json .= $row[0]; - $json .= ','; - } - $result->close(); - } - } while ($mysqli->more_results() && $mysqli->next_result()); - } - else { - die('error: ' . $mysqli->error); - } - - $json = rtrim($json, ","); - $json .= '] }'; - - header('Content-Type: application/json'); - echo $json; - - $mysqli->close(); -?> \ No newline at end of file diff --git a/servers/php/getrouteformap.php b/servers/php/getrouteformap.php index fec87e4..651b043 100644 --- a/servers/php/getrouteformap.php +++ b/servers/php/getrouteformap.php @@ -1,29 +1,14 @@ prepare('CALL prcGetRouteForMap(:sessionID, :phoneNumber)'); + $stmt->execute(array(':sessionID' => $_GET['sessionID'], ':phoneNumber' => $_GET['phoneNumber'])); $json = '{ "locations": ['; - // execute query - if ($mysqli->multi_query($query)) { - - do { // build our json array - if ($result = $mysqli->store_result()) { - while ($row = $result->fetch_row()) { - $json .= $row[0]; - $json .= ','; - } - $result->close(); - } - } while ($mysqli->more_results() && $mysqli->next_result()); - } - else { - die('error: ' . $mysqli->error); + foreach ($stmt as $row) { + $json .= $row['json']; + $json .= ','; } $json = rtrim($json, ","); @@ -31,6 +16,4 @@ header('Content-Type: application/json'); echo $json; - - $mysqli->close(); ?> \ No newline at end of file diff --git a/servers/php/getroutes.php b/servers/php/getroutes.php index 9eb770f..4082b4a 100644 --- a/servers/php/getroutes.php +++ b/servers/php/getroutes.php @@ -1,32 +1,19 @@ prepare('CALL prcGetRoutes();'); + $stmt->execute(); $json = '{ "routes": ['; - // execute query - if ($mysqli->multi_query($query)) { - - do { // build our json array - if ($result = $mysqli->store_result()) { - while ($row = $result->fetch_row()) { - $json .= $row[0]; - $json .= ','; - } - $result->close(); - } - } while ($mysqli->more_results() && $mysqli->next_result()); + foreach ($stmt as $row) { + $json .= $row['json']; + $json .= ','; } - else { - die('error: ' . $mysqli->error); - } - + $json = rtrim($json, ","); $json .= '] }'; header('Content-Type: application/json'); echo $json; - - $mysqli->close(); ?> diff --git a/servers/php/js/maps.js b/servers/php/js/maps.js index 6441013..58db3c6 100644 --- a/servers/php/js/maps.js +++ b/servers/php/js/maps.js @@ -4,13 +4,11 @@ var map = document.getElementById('map-canvas'); var autoRefresh = false; var intervalID = 0; - var zoom = 12; var sessionIDArray; - var viewingAllRoutes = false; getAllRoutesForMap(); - load(); + loadRoutesIntoDropdownBox(); $("#routeSelect").change(function() { if (hasMap()) { @@ -45,17 +43,8 @@ $("#viewall").click(function() { getAllRoutesForMap(); }); - - function setTheme() { - //var bodyBackgroundColor = $('body').css('backgroundColor'); - //$('.container').css('background-color', bodyBackgroundColor); - //$('body').css('background-color', '#ccc'); - // $('head').append(''); - } - - function getAllRoutesForMap() { - // when the page first loads, get the routes from the DB and load them into the dropdown box. + function getAllRoutesForMap() { viewingAllRoutes = true; routeSelect.selectedIndex = 0; showPermanentMessage('Please select a route below'); @@ -65,19 +54,16 @@ type: 'GET', dataType: 'json', success: function(data) { - // console.log(JSON.stringify(data)); loadGPSLocations(data); }, error: function (xhr, status, errorThrown) { - //console.log("responseText in error: " + xhr.responseText); console.log("error status: " + xhr.status); console.log("errorThrown: " + errorThrown); } }); } - function load() { - // when the page first loads, get the routes from the DB and load them into the dropdown box. + function loadRoutesIntoDropdownBox() { $.ajax({ url: 'getroutes.php', type: 'GET', @@ -128,19 +114,10 @@ } } - // this will get the map and route, the route is selected from the dropdown box - - function getRouteForMap() { - - + function getRouteForMap() { if (hasMap()) { - - // get selected index // console.log($("#routeSelect").prop("selectedIndex")); - // get selected value - // use this instead $('#routeSelect').val(); - var url = 'getrouteformap.php' + routeSelect.options[routeSelect.selectedIndex].value; // console.log("testing route: " + $('#routeSelect').val()); @@ -159,9 +136,6 @@ }); } - // else { - // alert("Please select a route before trying to refresh map."); - // } } // check to see if we have a map loaded, don't want to autorefresh or delete without it @@ -180,7 +154,6 @@ map.innerHTML = ''; } else { - // make sure we only create map object once if (map.id == 'map-canvas') { // clear any old map objects document.getElementById('map-canvas').outerHTML = "
"; @@ -201,10 +174,10 @@ // https://github.com/shramov/leaflet-plugins/issues/62 L.polyline([[0, 0], ]).addTo(gpsTrackerMap); - // this sets which map layer will first be displayed, go ahead and change it to bingMapsLayer or openStreetMapsLayer to see + // this sets which map layer will first be displayed gpsTrackerMap.addLayer(googleMapsLayer); - // this is the switcher control to switch between map types (upper right hand corner of map) + // this is the switcher control to switch between map types gpsTrackerMap.addControl(new L.Control.Layers({ 'Bing Maps':bingMapsLayer, 'Google Maps':googleMapsLayer, @@ -346,7 +319,6 @@ } } - // this chooses the proper image for our litte compass in the popup window function getCompassImage(azimuth) { if ((azimuth >= 337 && azimuth <= 360) || (azimuth >= 0 && azimuth < 23)) return "compassN"; @@ -426,8 +398,8 @@ if (hasMap()) { // comment out these two lines to get delete working - var answer = confirm("Disabled here on test website, this works fine."); - return false; + // var answer = confirm("Disabled here on test website, this works fine."); + // return false; var answer = confirm("This will permanently delete this route\n from the database. Do you want to delete?"); if (answer){ @@ -490,5 +462,12 @@ } return str; } + + function setTheme() { + //var bodyBackgroundColor = $('body').css('backgroundColor'); + //$('.container').css('background-color', bodyBackgroundColor); + //$('body').css('background-color', '#ccc'); + // $('head').append(''); + } }); diff --git a/servers/php/updatelocation.php b/servers/php/updatelocation.php index 6ba502e..e91c4c1 100644 --- a/servers/php/updatelocation.php +++ b/servers/php/updatelocation.php @@ -1,48 +1,36 @@ $_POST['latitude'], + ':longitude' => $_POST['longitude'], + ':speed' => $_POST['speed'], + ':direction' => $_POST['direction'], + ':distance' => $_POST['distance'], + ':date' => urldecode($_POST['date']), + ':locationmethod' => urldecode($_POST['locationmethod']), + ':phonenumber' => $_POST['phonenumber'], + ':sessionid' => $_POST['sessionid'], + ':accuracy' => $_POST['accuracy'], + ':extrainfo' => $_POST['extrainfo'], + ':eventtype' => $_POST['eventtype'] + ); - // save the gps location to the database - // i'm not to worried about sql injection here since i'm calling a stored procedure here - $query = 'CALL prcSaveGPSLocation(\'' - . $latitude . '\',\'' - . $longitude . '\',\'' - . $speed . '\',\'' - . $direction . '\',\'' - . $distance . '\',\'' - . $date . '\',\'' - . $locationMethod . '\',\'' - . $phoneNumber . '\',\'' - . $sessionID . '\',\'' - . $accuracy . '\',\'' - . $extraInfo . '\',\'' - . $eventType . '\')'; + $stmt = $pdo->prepare('CALL prcSaveGPSLocation( + :latitude, + :longitude, + :speed, + :direction, + :distance, + :date, + :locationmethod, + :phonenumber, + :sessionid, + :accuracy, + :extrainfo, + :eventtype);' + ); - if (!$mysqli->multi_query($query)) { - die('$mysqli->multi_query: ' . $mysqli->error); - } - - $mysqli->close(); - - echo '0'; - + $stmt->execute($params); + echo '0'; ?>