forked from mig0s/BullyTrack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_create_u.php
executable file
·132 lines (120 loc) · 3.29 KB
/
admin_create_u.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/*
UserCake Version: 2.0.2
http://usercake.com
*/
require_once("models/config.php");
if (!securePage($_SERVER['PHP_SELF'])){die();}
//Forms posted
if(!empty($_POST))
{
$errors = array();
$email = trim($_POST["email"]);
$username = trim($_POST["username"]);
$displayname = trim($_POST["displayname"]);
$password = trim($_POST["password"]);
$confirm_pass = trim($_POST["passwordc"]);
if(minMaxRange(5,25,$username))
{
$errors[] = lang("ACCOUNT_USER_CHAR_LIMIT",array(5,25));
}
if(!ctype_alnum($username)){
$errors[] = lang("ACCOUNT_USER_INVALID_CHARACTERS");
}
if(minMaxRange(5,25,$displayname))
{
$errors[] = lang("ACCOUNT_DISPLAY_CHAR_LIMIT",array(5,25));
}
if(!ctype_alnum($displayname)){
$errors[] = lang("ACCOUNT_DISPLAY_INVALID_CHARACTERS");
}
if(minMaxRange(8,50,$password) && minMaxRange(8,50,$confirm_pass))
{
$errors[] = lang("ACCOUNT_PASS_CHAR_LIMIT",array(8,50));
}
else if($password != $confirm_pass)
{
$errors[] = lang("ACCOUNT_PASS_MISMATCH");
}
if(!isValidEmail($email))
{
$errors[] = lang("ACCOUNT_INVALID_EMAIL");
}
//End data validation
if(count($errors) == 0)
{
//Construct a user object
$user = new User($username,$displayname,$password,$email);
//Checking this flag tells us whether there were any errors such as possible data duplication occured
if(!$user->status)
{
if($user->username_taken) $errors[] = lang("ACCOUNT_USERNAME_IN_USE",array($username));
if($user->displayname_taken) $errors[] = lang("ACCOUNT_DISPLAYNAME_IN_USE",array($displayname));
if($user->email_taken) $errors[] = lang("ACCOUNT_EMAIL_IN_USE",array($email));
}
else
{
//Attempt to add the user to the database, carry out finishing tasks like emailing the user (if required)
if(!$user->userCakeAddUser())
{
if($user->mail_failure) $errors[] = lang("MAIL_ERROR");
if($user->sql_failure) $errors[] = lang("SQL_ERROR");
}
}
}
if(count($errors) == 0) {
$successes[] = $user->success;
}
}
require_once("models/header.php");
echo "
</div>
<div id='main' class='col-md-10'>";
echo resultBlock($errors,$successes);
echo "
<h2>Add user:</h2>
<div id='regbox'>
<form name='newUser' action='".$_SERVER['PHP_SELF']."' method='post' class='form-horizontal'>
<div class='form-group'>
<label class='col-sm-2 control-label'>User Name:</label>
<div class='col-sm-5'>
<input class='form-control' type='text' name='username' />
</div>
</div>
<div class='form-group'>
<label class='col-sm-2 control-label'>Display Name:</label>
<div class='col-sm-5'>
<input class='form-control' type='text' name='displayname' />
</div>
</div>
<div class='form-group'>
<label class='col-sm-2 control-label'>Password:</label>
<div class='col-sm-5'>
<input class='form-control' type='password' name='password' />
</div>
</div>
<div class='form-group'>
<label class='col-sm-2 control-label'>Confirm:</label>
<div class='col-sm-5'>
<input class='form-control' type='password' name='passwordc' />
</div>
</div>
<div class='form-group'>
<label class='col-sm-2 control-label'>Email:</label>
<div class='col-sm-5'>
<input class='form-control' type='text' name='email' />
</div>
</div>
<div class='form-group'>
<div class='col-sm-offset-2 col-sm-5'>
<input type='submit' value='Register' class='btn btn-default'/>
</div>
</div>
</form>
</div>
</div>
<div id='bottom'></div>
</div>
</body>
</html>";
?>