blob: 07ad97915e91124a90c548d836d758c53b84c75a [file] [log] [blame]
Andreu8192d552019-09-22 16:51:39 +02001<?php
2 require '../credentials.php';
3 require '../php/utils.php';
Adrià Vilanova Martínez36362912022-11-20 01:30:13 +01004
5 $credentials = new Credentials();
6 if ($credentials->adminToken != ($_GET["token"] ?? "")) {
7 exit();
8 }
Andreu8192d552019-09-22 16:51:39 +02009
10 $dbname = $_GET['dbname'];
Andreu0530b302019-09-24 04:18:20 +020011 $mortsname = $dbname . "_morts";
Andreu8192d552019-09-22 16:51:39 +020012
Andreu0530b302019-09-24 04:18:20 +020013 $queries = ["CREATE TABLE `$dbname` (
Andreu8192d552019-09-22 16:51:39 +020014 `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ínez13cf0cd2022-11-20 01:02:20 +010021 `password` varchar(255) NOT NULL DEFAULT '',
Andreu0530b302019-09-24 04:18:20 +020022 `bits` int(3) NOT NULL
23 )",
24 "CREATE TABLE `$mortsname` (
Andreu04f79ef2019-09-22 18:52:19 +020025 `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,
Andreu20af6c22019-09-24 18:33:50 +020030 `data` timestamp NOT NULL DEFAULT current_timestamp()
Andreu0530b302019-09-24 04:18:20 +020031 )"];
32
Andreu20af6c22019-09-24 18:33:50 +020033 foreach ($queries as $query) if (!query($query)) die('An error ocurred. ' . $query);
Andreu03d030d2019-09-25 21:52:01 +020034 die("<script>window.location.href = './?dbname=$dbname'</script>");