gpstools/setup.php
Klaus-Uwe Mitterer 72a37d9f1a Add auth
2017-10-05 14:43:11 +02:00

21 lines
811 B
PHP

<?php
require_once("config.php");
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$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, $sql2)) die('Error: ' . mysqli_error($conn));
if (!mysqli_query($conn, $sql3)) die('Error: ' . mysqli_error($conn));
mysqli_close($conn);
echo "OK";