<?php require_once 'autoloader.php'; $storage = new sqlite_storage(); if (isset($_GET["lat"]) && preg_match("/^-?\\d+\\.\\d+\$/", $_GET["lat"]) && isset($_GET["lon"]) && preg_match("/^-?\\d+\\.\\d+\$/", $_GET["lon"]) && isset($_GET["device_id"]) && isset($_GET["key"])) { $t = null; if (isset($_GET["t"]) && preg_match("/^\\d+\$/", $_GET["t"])) { $t = $_GET["t"]; } $device_id = !empty($_GET["device_id"]) ? $_GET["device_id"] : "default"; try { $storage->start(); $storage->save_pos($_GET["lat"], $_GET["lon"], $t, $_GET["device_id"], $_GET["key"]); $storage->stop(); echo "OK"; } catch (auth_exception $e) { header('HTTP/1.0 401 Unauthorized'); echo $e->getMessage(); } } elseif (isset($_GET["tracker"])) { // do whatever you want here... echo "OK"; } else { header('HTTP/1.0 400 Bad Request'); echo 'Please type this URL in the <a href="https://play.google.com/store/apps/details?id=fr.herverenault.selfhostedgpstracker">Self-Hosted GPS Tracker</a> Android app on your phone.'; }
<?php require_once '../autoloader.php'; $device_id = !empty($_GET['device_id']) ? $_GET['device_id'] : 'default'; $storage = new sqlite_storage(); $storage->start(); echo implode('_', $storage->get_last_pos($device_id)); $storage->stop();
<?php require_once '../autoloader.php'; $storage = new sqlite_storage(); $storage->start(); if (isset($_POST['device_id']) && isset($_POST['key'])) { switch ($_POST['action']) { case 'Add user': $storage->add_device($_POST['device_id'], $_POST['key']); break; case 'Remove': $storage->remove_device($_POST['device_id'], $_POST['key']); break; default: throw new unknown_action_exception('Unknown action "' . $_POST['action'] . '"'); break; } $storage->stop(); header('Location: ' . $_SERVER['REQUEST_URI'], true, 303); die; } $devices = $storage->get_devices(); $storage->stop(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset=utf-8> <title>Users</title> </head> <body>