Andreu | 8192d55 | 2019-09-22 16:51:39 +0200 | [diff] [blame] | 1 | <?php |
| 2 | require '../credentials.php'; |
| 3 | require '../php/utils.php'; |
Adrià Vilanova Martínez | 3636291 | 2022-11-20 01:30:13 +0100 | [diff] [blame] | 4 | |
| 5 | $credentials = new Credentials(); |
Adrià Vilanova Martínez | 6052433 | 2022-11-20 02:33:56 +0100 | [diff] [blame] | 6 | if ($credentials->adminToken() != ($_GET["token"] ?? "")) { |
Adrià Vilanova Martínez | 3636291 | 2022-11-20 01:30:13 +0100 | [diff] [blame] | 7 | exit(); |
| 8 | } |
Andreu | 8192d55 | 2019-09-22 16:51:39 +0200 | [diff] [blame] | 9 | |
| 10 | $dbname = $_GET['dbname']; |
Andreu | 0530b30 | 2019-09-24 04:18:20 +0200 | [diff] [blame] | 11 | $mortsname = $dbname . "_morts"; |
Andreu | 8192d55 | 2019-09-22 16:51:39 +0200 | [diff] [blame] | 12 | |
Andreu | 0530b30 | 2019-09-24 04:18:20 +0200 | [diff] [blame] | 13 | $queries = ["CREATE TABLE `$dbname` ( |
Andreu | 8192d55 | 2019-09-22 16:51:39 +0200 | [diff] [blame] | 14 | `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 15 | `nom` varchar(100) CHARACTER SET utf8 COLLATE utf8_spanish_ci NOT NULL, |
| 16 | `curs` tinyint(1) NOT NULL, |
| 17 | `grau` tinyint(1) NOT NULL, |
| 18 | `quimata` int(11) NOT NULL, |
| 19 | `requested` tinyint(1) NOT NULL DEFAULT 0, |
| 20 | `mort` tinyint(1) NOT NULL DEFAULT 0, |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 21 | `password` varchar(255) NOT NULL DEFAULT '', |
Andreu | 0530b30 | 2019-09-24 04:18:20 +0200 | [diff] [blame] | 22 | `bits` int(3) NOT NULL |
| 23 | )", |
| 24 | "CREATE TABLE `$mortsname` ( |
Andreu | 04f79ef | 2019-09-22 18:52:19 +0200 | [diff] [blame] | 25 | `id` int(11) NOT NULL, |
| 26 | `quimatava` int(11) NOT NULL, |
| 27 | `assassi` int(11) NOT NULL, |
| 28 | `curs` tinyint(1) NOT NULL, |
| 29 | `grau` tinyint(1) NOT NULL, |
Andreu | 20af6c2 | 2019-09-24 18:33:50 +0200 | [diff] [blame] | 30 | `data` timestamp NOT NULL DEFAULT current_timestamp() |
Adrià Vilanova Martínez | 6052433 | 2022-11-20 02:33:56 +0100 | [diff] [blame] | 31 | )", |
| 32 | "CREATE TABLE IF NOT EXISTS `missatges` ( |
| 33 | `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 34 | `sender_id` int(11) NOT NULL, |
| 35 | `receiver_id` int(11) NOT NULL, |
| 36 | `timestamp` timestamp NOT NULL DEFAULT current_timestamp(), |
| 37 | `content` text NOT NULL, |
| 38 | `seen` tinyint(1) DEFAULT 0 |
Andreu | 0530b30 | 2019-09-24 04:18:20 +0200 | [diff] [blame] | 39 | )"]; |
| 40 | |
Andreu | 20af6c2 | 2019-09-24 18:33:50 +0200 | [diff] [blame] | 41 | foreach ($queries as $query) if (!query($query)) die('An error ocurred. ' . $query); |
Andreu | 03d030d | 2019-09-25 21:52:01 +0200 | [diff] [blame] | 42 | die("<script>window.location.href = './?dbname=$dbname'</script>"); |