From 72a37d9f1aa68df545fc8c483c81ca8ec658128f Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Thu, 5 Oct 2017 14:43:11 +0200 Subject: [PATCH] Add auth --- access.php | 31 ++++++++++++++++--------------- config.dist.php | 8 ++++++-- location.php | 11 +++++++---- setup.php | 10 ++++++---- 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/access.php b/access.php index ef8dc64..7d0e897 100644 --- a/access.php +++ b/access.php @@ -1,10 +1,14 @@ num_rows > 0) { echo ' - -#yellowPoly + + + #style + 1a1ac94e + #ffff00 + 0.4980392156862745 + 4 + #00ff00 + 0.4980392156862745 + -1 -1 -absolute '; diff --git a/config.dist.php b/config.dist.php index 62cba9c..bc05578 100644 --- a/config.dist.php +++ b/config.dist.php @@ -6,8 +6,12 @@ $password = "password"; $dbname = "database"; $endpoint = True; -$access = False; -$location = False; +$access = True; +$location = True; + +$endpointverification = True; +$accessverification = True; +$locationverification = True; $headercode = << diff --git a/location.php b/location.php index a00dea7..49bd45d 100644 --- a/location.php +++ b/location.php @@ -1,16 +1,19 @@ connect_error) { +if ($conn->connect_error) die("Connection failed: " . $conn->connect_error); -} $sql = "SELECT ts, lat, lon FROM tracker WHERE device='" . mysqli_real_escape_string($conn, $_GET["device"]) . "' ORDER BY ts DESC LIMIT 1;"; $result = $conn->query($sql); diff --git a/setup.php b/setup.php index 04de2bd..aa0fb19 100644 --- a/setup.php +++ b/setup.php @@ -8,11 +8,13 @@ if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } -$sql = "CREATE TABLE tracker ( ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP, device VARCHAR(38), lat DOUBLE, lon DOUBLE, PRIMARY KEY(ts, device) );"; +$sql = "CREATE TABLE IF NOT EXISTS tracker ( ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP, device VARCHAR(38), lat DOUBLE, lon DOUBLE, PRIMARY KEY(ts, device) );"; +$sql2 = "CREATE TABLE IF NOT EXISTS users ( user VARCHAR(64) PRIMARY KEY, password VARCHAR(128), admin BOOLEAN );"; +$sql3 = "CREATE TABLE IF NOT EXISTS device ( device VARCHAR(38) PRIMARY KEY, passkey VARCHAR(128) );"; -if (!mysqli_query($conn, $sql)) { - die('Error: ' . mysqli_error($conn)); -} +if (!mysqli_query($conn, $sql)) die('Error: ' . mysqli_error($conn)); +if (!mysqli_query($conn, $sql2)) die('Error: ' . mysqli_error($conn)); +if (!mysqli_query($conn, $sql3)) die('Error: ' . mysqli_error($conn)); mysqli_close($conn);