diff options
Diffstat (limited to 'api/remove.php')
| -rw-r--r-- | api/remove.php | 19 |
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"]); |
