blob: b4986057f0ac1fe09c225d1b43eb478104915ba3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
<?php
if (empty($_POST["old-order"]) || empty($_POST["new-order"])) {
http_response_code(400);
error_log("not enough post");
exit(0);
}
$path = "/home/maks/school/clientApps/mlos/src/db.xml";
require_once "/home/maks/school/clientApps/mlos/src/data.php";
$old_order = $_POST["old-order"];
$new_order = $_POST["new-order"];
$count = $doc->getElementsByTagName("count")->item(0)->nodeValue;
if ($new_order === strval(intval($count) + 1) || $new_order === "0") {
exit();
}
$doc = get_doc();
$xpath = new DOMXpath($doc);
$old_game = $xpath->query('//game[@order="' . $old_order . '"]')->item(0);
$new_game = $xpath->query('//game[@order="' . $new_order . '"]')->item(0);
$old_game->setAttribute("order", $new_order);
$new_game->setAttribute("order", $old_order);
// check for first
$doc->save($path);
header("Location: " . $_SERVER["HTTP_REFERER"]);
|