-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.php
103 lines (86 loc) · 2.85 KB
/
install.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
error_reporting( 0 );
if (!file_exists('config.php')) {
die("<p>The file 'config.php' not exists.</p></body></html>"); }
include("config.php");
include('sources/Auth.php');
include('sources/core.php');
$db = new MySQL();
$db->connect($host,$username,$password,$database);
$hey = new Auth();
print("HELO, go to install.php?mode=install\n");
$mode = $_GET['mode'];
switch($mode)
{
case 'register':
print "<form action = 'install.php?mode=register' method = 'POST'>";
print "username: <input type = 'text' name = 'username'><br>";
print "password: <input type = 'password' name = 'password'><br>";
print "retype password: <input type = 'password' name = 'repeat'><br>";
print "<p>email admin: <input type = 'text' name = 'email'></p>";
print "<input type = 'submit' value = 'register'>";
print "</form>";
if(!empty($_POST['username']) && !empty($_POST['password']) && !empty($_POST['repeat']) && eregi("^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$",$_POST['email']) )
{
$username = htmlentities($_POST['username']);
$password = htmlentities($_POST['password']);
$repeat = htmlentities($_POST['repeat']);
$email = $_POST['email'];
$level = 'admin';
if($password == $repeat)
{
$password = md5(sha1($password));
$hey->register($username,$password,$email,$level);
}
else
{
print "Passwords do not match";
}
}
$db->close();
break;
case 'install':
$db->query("
CREATE TABLE `users` (
`id` INT (11) NOT NULL AUTO_INCREMENT,
`username` TEXT NOT NULL,
`password` TEXT NOT NULL,
`level` TEXT NOT NULL,
`email` TEXT NOT NULL,
PRIMARY KEY (`id`)
);
");
$db->query("
CREATE TABLE `pages` (
`name` TEXT NOT NULL,
`content` TEXT NOT NULL,
`id` INT (11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
);
");
$db->query("
CREATE TABLE `articles` (
`name` TEXT NOT NULL,
`author` TEXT NOT NULL,
`content` TEXT NOT NULL,
`date` TEXT NOT NULL,
`hour` TEXT NOT NULL,
`id` INT (11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
);
");
$db->query("
CREATE TABLE `comments` (
`comment` TEXT NOT NULL,
`author` TEXT NOT NULL,
`date` TEXT NOT NULL,
`hour` TEXT NOT NULL,
`post_id` INT (11) NOT NULL,
`id` INT (11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
);
");
print("installed, go to install.php?mode=register\n");
break;
}
?>