diff --git a/managment/Dockerfile b/managment/Dockerfile
index 52dbcb7..4c03c01 100644
--- a/managment/Dockerfile
+++ b/managment/Dockerfile
@@ -1,16 +1,10 @@
FROM docker.io/library/php:7.2-apache
-RUN apt-get update -y && apt-get install -y git
-
RUN docker-php-ext-install -j$(nproc) mysqli
-WORKDIR /
-
-RUN git clone https://gitlab.com/merspieler/osm2city-scripts.git && cp /osm2city-scripts/web/index.php /var/www/html/ && rm -rf /osm2city-scripts
-
WORKDIR /var/www/html/
-COPY config.php .
+COPY www/* .
# Set default env vars
ENV SQL_HOST mysql
diff --git a/managment/www/api.php b/managment/www/api.php
new file mode 100644
index 0000000..c318b6d
--- /dev/null
+++ b/managment/www/api.php
@@ -0,0 +1,216 @@
+success = False;
+ $ret->version = $GLOBALS["API_VERSION"];
+ echo(json_encode($ret));
+ exit();
+}
+
+$ret = new stdClass;
+$ret->success = True;
+$ret->version = $API_VERSION;
+
+// Make sure we've got at least auth and an action in the request
+if (isset($_POST['auth']) && $_POST['auth'] != "" && isset($_POST['action']) && $_POST['action'] != "")
+{
+ $auth = $_POST['auth'];
+ $action = $_POST['action'];
+}
+else
+{
+ quit();
+}
+
+// Connect to DB
+$con = new mysqli($SQL_SERVER, $SQL_USER, $SQL_PASSWORD, $SQL_DATABASE, $SQL_PORT);
+if ($con->connect_error)
+{
+ quit();
+}
+
+// Check auth
+$stmt = $con->prepare("SELECT id FROM auth WHERE token = ?");
+$stmt->bind_param("s", $auth);
+$stmt->execute();
+$result = $stmt->get_result();
+$res = $result->fetch_assoc();
+$stmt->close();
+if ($res == Null)
+{
+ quit();
+}
+
+// Setup helper functions
+function get_lock($con)
+{
+ $sql = "SELECT GET_LOCK('tile-status-lock', 10)";
+ $ret = $con->query($sql)->fetch_array()[0];
+ if ($ret == 0)
+ {
+ quit();
+ }
+}
+
+function rel_lock($con)
+{
+ $con->query("SELECT RELEASE_LOCK('tile-status-lock')");
+}
+
+function set_status($con, $name, $status, $type)
+{
+ if ($type == "area")
+ {
+ // Get parent ID
+ $sql = "SELECT id FROM secondLevel WHERE name = ?";
+ $stmt = $con->prepare($sql);
+ $stmt->bind_param("s", $name);
+ $stmt->execute();
+ $result = $stmt->get_result();
+ $stmt->close();
+ if ($result == False)
+ {
+ rel_lock($con);
+ quit();
+ }
+ $pid = $result->fetch_array()[0];
+
+ // Get status ID
+ $sql = "SELECT id FROM status WHERE name = ?";
+ $stmt = $con->prepare($sql);
+ $stmt->bind_param("s", $status);
+ $stmt->execute();
+ $result = $stmt->get_result();
+ $stmt->close();
+ if ($result == False)
+ {
+ rel_lock($con);
+ quit();
+ }
+ $sid = $result->fetch_array()[0];
+
+ // Update tiles in area
+ $sql = "UPDATE tile SET status_id = ? WHERE parent_id = ?";
+ $stmt = $con->prepare($sql);
+ $stmt->bind_param("ii", $sid, $pid);
+ $stmt->execute();
+ $stmt->close();
+ }
+ else
+ {
+ $sql = "UPDATE tile SET status_id = (SELECT id FROM status WHERE name = ?) WHERE id = ?";
+ $stmt = $con->prepare($sql);
+ $stmt->bind_param("si", $status, $name);
+ $stmt->execute();
+ $stmt->close();
+ }
+}
+
+if ($action == "set")
+{
+ if (isset($_POST['tile']) && $_POST['tile'] != "")
+ {
+ get_lock($con);
+ set_status($con, $_POST['tile'], $_POST['status'], "tile");
+ rel_lock($con);
+ }
+ else if (isset($_POST['area']) && $_POST['area'] != "")
+ {
+ get_lock($con);
+ set_status($con, $_POST['area'], $_POST['status'], "area");
+ rel_lock($con);
+ }
+ else
+ {
+ quit();
+ }
+}
+else if ($action == "get-job")
+{
+ get_lock($con);
+ if (isset($_POST["additional-type"]) && $_POST["additional-type"] != "")
+ {
+ $sql = "SELECT id FROM tile WHERE status_id = (SELECT id FROM status WHERE name = 'pending') OR status_id = (SELECT id FROM status WHERE name = ?) ORDER BY parent_id LIMIT 1";
+ $stmt = $con->prepare($sql);
+ $stmt->bind_param("s", $_POST["additional-type"]);
+ }
+ else
+ {
+ $sql = "SELECT id FROM tile WHERE status_id = (SELECT id FROM status WHERE name = 'pending') ORDER BY parent_id LIMIT 1";
+ $stmt = $con->prepare($sql);
+ }
+ $stmt->execute();
+ $result = $stmt->get_result();
+ $stmt->close();
+ if ($result == False)
+ {
+ quit();
+ }
+ $ret->job = $result->fetch_array()[0];
+ if ($ret->job == Null)
+ {
+ $ret->job = "None";
+ }
+ else
+ {
+ set_status($con, $ret->job, "started", "tile");
+ }
+ rel_lock($con);
+}
+else if ($action == "get-done")
+{
+ $sql = "SELECT name FROM secondLevel WHERE status_id = (SELECT id FROM status WHERE name = 'done') LIMIT 1";
+ $ret->job = $con->query($sql)->fetch_array()[0];
+ if ($ret->job == Null)
+ {
+ $ret->job = "None";
+ }
+}
+else if ($action == "status")
+{
+ if (isset($_POST['tile']) && $_POST['tile'] != "")
+ {
+ $sql = "SELECT name FROM status WHERE id = (SELECT status_id FROM tile WHERE id = ?)";
+ $pattern = "i";
+ $req = $_POST['tile'];
+ }
+ else if (isset($_POST['area']) && $_POST['area'] != "")
+ {
+ $sql = "SELECT name FROM status WHERE id = (SELECT status_id FROM secondLevel WHERE name = ?)";
+ $pattern = "s";
+ $req = $_POST['area'];
+ }
+ else
+ {
+ quit();
+ }
+ $stmt = $con->prepare($sql);
+ $stmt->bind_param($pattern, $req);
+ $stmt->execute();
+ $result = $stmt->get_result();
+ if ($result == False)
+ {
+ quit();
+ }
+ $res = $result->fetch_assoc();
+ $stmt->close();
+ if ($res == Null)
+ {
+ quit();
+ }
+ $ret->status = $res["name"];
+}
+else
+{
+ quit();
+}
+
+// https://www.w3schools.com/php/php_mysql_prepared_statements.asp
+
+$con->close();
+echo(json_encode($ret));
+?>
diff --git a/managment/config.php b/managment/www/config.php
similarity index 100%
rename from managment/config.php
rename to managment/www/config.php
diff --git a/managment/www/index.php b/managment/www/index.php
new file mode 100644
index 0000000..04105ae
--- /dev/null
+++ b/managment/www/index.php
@@ -0,0 +1,92 @@
+connect_error)
+ {
+ quit();
+ }
+?>
+
+
+
+ Osm2City Worldbuild Progress
+
+
+
+ Osm2City Worldbuild Progress
+ Colors:
+
+ query($sql)->fetch_all(MYSQLI_ASSOC);
+ if ($ret != False)
+ {
+ foreach($ret as $row)
+ {
+ echo '' . $row["name"] . ' |
';
+ }
+ }
+ ?>
+
+ Click on a tile to see it's detailed status.
+
+ -
+
+
+
+ -
+
+
+
+
+
diff --git a/managment/www/map.png b/managment/www/map.png
new file mode 100644
index 0000000..e095167
Binary files /dev/null and b/managment/www/map.png differ
diff --git a/managment/www/progressinfo.php b/managment/www/progressinfo.php
new file mode 100644
index 0000000..8d2258c
--- /dev/null
+++ b/managment/www/progressinfo.php
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+ connect_error)
+ {
+ quit();
+ }
+ $stmt = $con->prepare("SELECT status.name AS status, COUNT(*) AS sCount, status.color AS color FROM secondLevel JOIN status ON secondLevel.status_id = status.id WHERE secondLevel.parent_id = (SELECT id FROM topLevel WHERE name = ?) GROUP BY status.id");
+ $stmt->bind_param("s", $tile);
+ $stmt->execute();
+ $result = $stmt->get_result();
+ $ret = $result->fetch_all(MYSQLI_ASSOC);
+ echo 'Tile Name | ' . $tile . ' |
';
+ foreach ($ret as $row)
+ {
+ echo '' . $row["status"] . ' | ' . $row["sCount"] . ' |
';
+ }
+ echo '
';
+ }
+ ?>
+
+
diff --git a/managment/www/style.css b/managment/www/style.css
new file mode 100644
index 0000000..6b8429f
--- /dev/null
+++ b/managment/www/style.css
@@ -0,0 +1,6 @@
+#container {
+ display: flex;
+ flex-wrap: wrap;
+ list-style: none;
+ align-content: flex-start;
+}