Created
August 20, 2014 20:23
-
-
Save reinvented/6cd15333bb587ba373ae to your computer and use it in GitHub Desktop.
A small PHP script that can act as the server-side for the Androind geolocation-tracking app Backtitude.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$mysqli = new mysqli("localhost", "loc", "[password redacted]", "loc"); | |
if ($mysqli->connect_errno) { | |
printf("Connect failed: %s\n", $mysqli->connect_error); | |
exit(); | |
} | |
if ($_POST) { | |
$query = sprintf("INSERT into locations (latitude, longitude, loc_timestamp, req_timestamp, accuracy, offset) values ('%s', '%s', '%s', '%s', '%s', '%s')", | |
mysqli_real_escape_string($mysqli, $_POST['latitude']), | |
mysqli_real_escape_string($mysqli, $_POST['longitude']), | |
mysqli_real_escape_string($mysqli, $_POST['loc_timestamp']), | |
mysqli_real_escape_string($mysqli, $_POST['req_timestamp']), | |
mysqli_real_escape_string($mysqli, $_POST['accuracy']), | |
mysqli_real_escape_string($mysqli, $_POST['offset'])); | |
if (mysqli_query($mysqli, $query) === TRUE) { | |
header("HTTP/1.1 201 OK"); | |
} | |
else { | |
printf("INSERT failed: %s\n", $mysqli->connect_error); | |
exit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment