Add feature to kill everybody who hasn't killed anybody
Change-Id: Idb1a1cf1edda51ab3a25bf32922a3ba66a74525f
diff --git a/admin/killnotkillers.php b/admin/killnotkillers.php
new file mode 100644
index 0000000..61a4dce
--- /dev/null
+++ b/admin/killnotkillers.php
@@ -0,0 +1,27 @@
+<?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;
+ }