forked from opendocman/opendocman
-
Notifications
You must be signed in to change notification settings - Fork 1
/
signup.php
188 lines (169 loc) · 5.84 KB
/
signup.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?php
use Aura\Html\Escaper as e;
/*
add.php - adds files to the repository
Copyright (C) 2002-2007 Stephen Lawrence Jr., Jon Miner
Copyright (C) 2008-2014 Stephen Lawrence Jr.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// You can add signup_header.html and signup_footer.html files to display on this page automatically
include('odm-load.php');
if ($GLOBALS['CONFIG']['allow_signup'] == 'True') {
// Submitted so insert data now
if (isset($_REQUEST['adduser'])) {
// Check to make sure user does not already exist
$query = "
SELECT
username
FROM
{$GLOBALS['CONFIG']['db_prefix']}user
WHERE
username = :username
";
$stmt = $pdo->prepare($query);
$stmt->bindParam(':username', $_POST['username']);
$stmt->execute();
// If the above statement returns more than 0 rows, the user exists, so display error
if ($stmt->rowCount() > 0) {
echo msg('message_user_exists');
exit;
} else {
$phonenumber = (!empty($_REQUEST['phonenumber']) ? $_REQUEST['phonenumber'] : '');
// INSERT into user
$query = "
INSERT INTO
{$GLOBALS['CONFIG']['db_prefix']}user
(
username,
password,
department,
phone,
Email,
last_name,
first_name
) VALUES (
:username,
md5(:password),
:department,
:phonenumber,
:email,
:last_name,
:first_name
)";
$stmt = $pdo->prepare($query);
$stmt->bindParam(':username', $_POST['username']);
$stmt->execute(array(
':username' => $_POST['username'],
':password' => $_POST['password'],
':department' => $_POST['department'],
':phonenumber' => $phonenumber,
':email' => $_POST['Email'],
':last_name' => $_POST['last_name'],
':first_name' => $_POST['first_name']
));
// INSERT into admin
$userid = $pdo->lastInsertId();
// mail user telling him/her that his/her account has been created.
echo msg ('message_account_created') . ' ' . $_POST['username'].'<br />';
if($GLOBALS['CONFIG']['authen'] == 'mysql')
{
echo msg('message_account_created_password') . ': '. e::h($_REQUEST['password']) . PHP_EOL . PHP_EOL;
echo '<br><a href="' . $GLOBALS['CONFIG']['base_url'] . '">' . msg('login'). '</a>';
exit;
}
}
}
?>
<html>
<head><title>Sign Up</title></head>
<body>
<?php
if (is_readable("signup_header.html")) {
include("signup_header.html");
}
?>
<font size=6>Sign Up</font>
<br><script type="text/javascript" src="FormCheck.js"></script>
<table border="0" cellspacing="5" cellpadding="5">
<form name="add_user" action="signup.php" method="POST" enctype="multipart/form-data">
<tr><td><b><?php echo msg('label_last_name');
?></b></td><td><input name="last_name" type="text"></td></tr>
<tr><td><b><?php echo msg('label_first_name');
?></b></td><td><input name="first_name" type="text"></td></tr>
<tr><td><b><?php echo msg('username');
?></b></td><td><input name="username" type="text"></td></tr>
<tr>
<td><b>Phone Number</b></td>
<td>
<input name="phonenumber" type="text">
</td>
</tr>
<tr>
<td><b>Example</b></td>
<td><b>999 9999999</b></td>
</tr>
<tr>
<td><b>E-mail Address</b></td>
<td>
<input name="Email" type="text">
</td>
</tr>
<tr>
<?php
// If mysqlauthentication, then ask for password
if ($GLOBALS['CONFIG']['authen'] =='mysql') {
$rand_password = makeRandomPassword();
echo '<INPUT type="hidden" name="password" value="' . $rand_password . '">';
}
?>
<tr>
<td><b>Department</b></td>
<td>
<select name="department">
<?php
// query to get a list of departments
$query = "
SELECT
id,
name
FROM
{$GLOBALS['CONFIG']['db_prefix']}department
ORDER BY
name
";
$stmt = $pdo->prepare($query);
$stmt->execute();
$result = $stmt->fetchAll();
foreach ($result as $row) {
echo '<option value=' . e::h($row['id']) . '>' . e::h($row['name']) . '</option>';
}
?>
</select>
</td>
<tr>
<td></td>
<td columnspan=3 align="center"><input type="Submit" name="adduser" onClick="return validatemod(add_user);" value="<?php echo msg('submit');
?>">
</form>
</td>
</tr>
</table>
<?php
if (is_readable("signup_footer.html")) {
include("signup_footer.html");
}
?>
</body>
</html>
<?php
}