-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmysql.php
executable file
·69 lines (69 loc) · 2.37 KB
/
mysql.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
global $db;
$db = null;
function ConnectDB(): bool {
global $db;
if ($db !== null) {
return true;
}
try {
$db = new PDO(DBAddress, DBUsername, DBPassword, (DBPersistent ? [PDO::ATTR_PERSISTENT => true] : []));
if ($db !== null) {
return true;
}
} catch (Throwable $e) {
dieHTML("DB Error: {$e}.");
}
dieHTML("DB Error.");
return false;
}
function Install() {
global $db;
if ($db === null) {
return;
}
$db->exec("CREATE TABLE `download_history` (
`id` bigint NOT NULL AUTO_INCREMENT,
`source` varchar(11) NOT NULL,
`user_id` int NOT NULL,
`torrent_id` bigint NOT NULL,
`download_id` bigint NOT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `index_unique` (`source`,`user_id`,`torrent_id`,`download_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=2195 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci");
$db->exec("CREATE TABLE `users` (
`id` bigint NOT NULL AUTO_INCREMENT,
`username` varchar(123) NOT NULL,
`email` varchar(123) NOT NULL,
`password` varchar(123) NOT NULL,
`status` tinyint(1) DEFAULT 0,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `index_unique_username` (`username`) USING BTREE,
UNIQUE KEY `index_unique_email` (`email`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci");
$db->exec("CREATE TABLE `fonts` (
`id` bigint NOT NULL,
`fontname` varchar(123) DEFAULT NULL,
`fontfullname` varchar(123) DEFAULT NULL,
`fontpsname` varchar(123) DEFAULT NULL,
`fontsubfamily` varchar(123) DEFAULT NULL,
KEY `index_id` (`id`),
KEY `index_fontname` (`fontname`),
KEY `index_fontfullname` (`fontfullname`),
KEY `index_fontpsname` (`fontpsname`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci");
$db->exec("CREATE TABLE `fonts_meta` (
`id` bigint NOT NULL AUTO_INCREMENT,
`uploader` int DEFAULT NULL,
`fontfile` varchar(255) DEFAULT NULL,
`fontsize` bigint DEFAULT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `index_unique` (`fontfile`)
) ENGINE=InnoDB AUTO_INCREMENT=19230 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci");
}
?>