summaryrefslogtreecommitdiffstats
path: root/api/remove.php
diff options
context:
space:
mode:
authorMaksymilian Jopek <maks@jopek.eu>2022-03-16 23:20:59 +0100
committerMaksymilian Jopek <maks@jopek.eu>2022-03-16 23:20:59 +0100
commitbf7852bccce954aff2d7c94161f4d301a0f29684 (patch)
treefc3f2aac4f843990b02992e02903df22857a1928 /api/remove.php
downloadmlos-bf7852bccce954aff2d7c94161f4d301a0f29684.tar.gz
mlos-bf7852bccce954aff2d7c94161f4d301a0f29684.tar.zst
mlos-bf7852bccce954aff2d7c94161f4d301a0f29684.zip
Initial commit w/ v1.0.0
Diffstat (limited to 'api/remove.php')
-rw-r--r--api/remove.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/api/remove.php b/api/remove.php
new file mode 100644
index 0000000..65f1a82
--- /dev/null
+++ b/api/remove.php
@@ -0,0 +1,19 @@
+<?php
+if (empty($_POST["id"])) {
+ http_response_code(400);
+ exit(0);
+}
+$path = "/home/maks/school/clientApps/mlos/src/db.xml";
+require_once "/home/maks/school/clientApps/mlos/src/data.php";
+
+$id = $_POST["id"];
+$doc = get_doc();
+$xpath = new DOMXpath($doc);
+$game = $xpath->query('//game[@id="' . $id . '"]')->item(0);
+$game->parentNode->removeChild($game);
+
+$count = $doc->getElementsByTagName("count")->item(0);
+$count->nodeValue = intval($count->nodeValue) - 1;
+
+$doc->save($path);
+header("Location: " . $_SERVER["HTTP_REFERER"]);