This repository was archived by the owner on Oct 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.php
More file actions
55 lines (48 loc) · 1.41 KB
/
setup.php
File metadata and controls
55 lines (48 loc) · 1.41 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Setting up database</title>
</head>
<body>
<h3>Creating tables</h3>
<?php
include_once 'src/Database.php';
$db = new Database();
$db->createTable('members',
'user VARCHAR(16),
pass VARCHAR(128),
INDEX(user(6))');
$db->createTable('messages',
'id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
auth VARCHAR(16),
recip VARCHAR(16),
pm CHAR(1),
time INT UNSIGNED,
message VARCHAR(4096),
INDEX(auth(6)),
INDEX(recip(6))');
$db->createTable('friends',
'user VARCHAR(16),
friend VARCHAR(16),
INDEX(user(6)),
INDEX(friend(6))');
$db->createTable('profiles',
'user VARCHAR(16),
text VARCHAR(4096),
INDEX(user(6))');
?>
<br>...done.
<h3>Inserting admin user</h3>
<?php
$result = $db->queryMysql("SELECT * FROM members WHERE user='admin'");
if ($result->rowCount() == 0) {
$db->queryMysql("INSERT INTO members VALUES('admin', '21232f297a57a5a743894a0e4a801fc3')");
$db->queryMysql("INSERT INTO profiles VALUES('admin', 'The admin user. Can do anything.')");
echo "Admin user inserted";
} else {
echo "Admin user already exists";
}
?>
<br>...done.
</body>
</html>