blob: 9db621ecb34aa6d1ed1f659b6fdd92331ea98ac2 [file] [log] [blame]
<?php
require '../credentials.php';
require '../php/utils.php';
$credentials = new Credentials();
if ($credentials->adminToken() != ($_GET["token"] ?? "")) {
exit();
}
$dbname = $_GET['dbname'];
$mortsname = $dbname . "_morts";
$queries = ["CREATE TABLE `$dbname` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`nom` varchar(100) CHARACTER SET utf8 COLLATE utf8_spanish_ci NOT NULL,
`curs` tinyint(1) NOT NULL,
`grau` tinyint(1) NOT NULL,
`quimata` int(11) NOT NULL,
`requested` tinyint(1) NOT NULL DEFAULT 0,
`mort` tinyint(1) NOT NULL DEFAULT 0,
`password` varchar(255) NOT NULL DEFAULT '',
`bits` int(3) NOT NULL
)",
"CREATE TABLE `$mortsname` (
`id` int(11) NOT NULL,
`quimatava` int(11) NOT NULL,
`assassi` int(11) NOT NULL,
`curs` tinyint(1) NOT NULL,
`grau` tinyint(1) NOT NULL,
`data` timestamp NOT NULL DEFAULT current_timestamp()
)",
"CREATE TABLE IF NOT EXISTS `missatges` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`sender_id` int(11) NOT NULL,
`receiver_id` int(11) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
`content` text NOT NULL,
`seen` tinyint(1) DEFAULT 0
)"];
foreach ($queries as $query) if (!query($query)) die('An error ocurred. ' . $query);
die("<script>window.location.href = './?dbname=$dbname'</script>");