blob: 61a4dce1b05a40f65f93ed312cfc09aad567f735 [file] [log] [blame]
Adrià Vilanova Martíneze2e00ba2022-12-22 11:20:35 +01001<?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 }