Adrià Vilanova MartÃnez | e2e00ba | 2022-12-22 11:20:35 +0100 | [diff] [blame] | 1 | <?php |
| 2 | require '../credentials.php'; |
| 3 | require '../php/utils.php'; |
| 4 | |
| 5 | $credentials = new Credentials(); |
| 6 | if ($credentials->adminToken() != ($_GET["token"] ?? "")) { |
| 7 | exit(); |
| 8 | } |
| 9 | |
| 10 | $dbname = $credentials->usersdb(); |
| 11 | $mortsname = $credentials->mortsdb(); |
| 12 | |
| 13 | while (true) { |
| 14 | $query = "SELECT u.id, u.quimata, ud.id FROM $dbname u LEFT JOIN $mortsname m ON u.id = m.assassi INNER JOIN $dbname ud ON ud.quimata = u.id WHERE m.assassi IS NULL AND u.mort = 0 LIMIT 1"; |
| 15 | $result = query($query); |
| 16 | |
| 17 | header('Content-Type: text/plain'); |
| 18 | |
| 19 | if ($r = $result->fetch_row()) { |
| 20 | var_dump($r); |
| 21 | $sid = (int)$r[0]; |
| 22 | $smata = (int)$r[1]; |
| 23 | $sassassi = (int)$r[2]; |
| 24 | query("UPDATE $dbname SET mort = 1, quimata = 0 WHERE id = $sid"); |
| 25 | query("UPDATE $dbname SET quimata = $smata WHERE id = $sassassi"); |
| 26 | } else break; |
| 27 | } |