The following files exists in this folder. Click to view.
create-user.php
index.php
initialize-db.php
insert.php
insert_page.php
test.php
translate.php
initialize-db.php
62 lines ASCII Windows (CRLF)
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
<?php
include "../util/db_connect.php";
$enabled = true;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (!$enabled)
die("Script not enabled");
$db->query("DROP TABLE IF EXISTS `word`");
$db->query("
CREATE TABLE `word` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`word` varchar(255) COLLATE latin1_general_ci NOT NULL,
`user_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE(`word`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
");
$db->query("DROP TABLE IF EXISTS `translation`");
$db->query("
CREATE TABLE `translation` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`word_id` int(10) unsigned NOT NULL,
`translation` varchar(255) NOT NULL,
`user_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
");
$db->query("DROP TABLE IF EXISTS `try_record`");
$db->query("
CREATE TABLE `try_record` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`translation_id` int(10) unsigned NOT NULL,
`success` tinyint(1) NOT NULL,
`time` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
");
$db->query("DROP TABLE IF EXISTS `user`");
$db->query("
CREATE TABLE `user` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`email` varchar(255) NOT NULL,
`password_hash` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE(`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
");
echo "db initialized";
}
?>
<form method="POST">
<button>Submit</button>
</form>