blob: 61a4dce1b05a40f65f93ed312cfc09aad567f735 [file] [log] [blame]
<?php
require '../credentials.php';
require '../php/utils.php';
$credentials = new Credentials();
if ($credentials->adminToken() != ($_GET["token"] ?? "")) {
exit();
}
$dbname = $credentials->usersdb();
$mortsname = $credentials->mortsdb();
while (true) {
$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";
$result = query($query);
header('Content-Type: text/plain');
if ($r = $result->fetch_row()) {
var_dump($r);
$sid = (int)$r[0];
$smata = (int)$r[1];
$sassassi = (int)$r[2];
query("UPDATE $dbname SET mort = 1, quimata = 0 WHERE id = $sid");
query("UPDATE $dbname SET quimata = $smata WHERE id = $sassassi");
} else break;
}