summaryrefslogtreecommitdiffstats
path: root/api/remove.php
diff options
context:
space:
mode:
Diffstat (limited to 'api/remove.php')
-rw-r--r--api/remove.php20
1 files changed, 17 insertions, 3 deletions
diff --git a/api/remove.php b/api/remove.php
index 65f1a82..0ef23e5 100644
--- a/api/remove.php
+++ b/api/remove.php
@@ -1,10 +1,11 @@
<?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";
+$path = "%PWD%src/db.xml";
+require_once "%PWD%src/data.php";
$id = $_POST["id"];
$doc = get_doc();
@@ -13,7 +14,20 @@ $game = $xpath->query('//game[@id="' . $id . '"]')->item(0);
$game->parentNode->removeChild($game);
$count = $doc->getElementsByTagName("count")->item(0);
-$count->nodeValue = intval($count->nodeValue) - 1;
+$icount = intval($count->nodeValue) - 1;
+$count->nodeValue = $icount;
+
+
+[$data, $_] = get_data();
+$i = 1;
+foreach($data as $d) {
+ if($d["id"] === $id) continue;
+ $g = $xpath->query('//game[@id="' . $d["id"] . '"]')->item(0);
+ var_dump('//game[@id="' . $d["id"] . '"]');
+ $g->setAttribute("order", $i);
+ $i++;
+}
$doc->save($path);
header("Location: " . $_SERVER["HTTP_REFERER"]);
+