This repository has been archived by the owner on Jan 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
add.php
118 lines (113 loc) · 4.34 KB
/
add.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
<?php
require './config.inc.php';
require './header.inc.php';
if (empty($_SERVER['REQUEST_METHOD']))
$method = $REQUEST_METHOD;
else
$method = $_SERVER['REQUEST_METHOD'];
if ($_SERVER['REQUEST_METHOD'] == "GET")
$id = $_GET['id'];
else
$id = $_POST['id'];
read_passwd_file($id);
if (isset($_POST['submit'])) {
$username = trim($_POST['username']);
$password = trim($_POST['password']);
$passwordv = trim($_POST['passwordv']);
$realname = trim($_POST['realname']);
$realname = ucwords($realname);
$email = trim($_POST['email']);
$email = strtolower($email);
if (is_user($username)) {
echo "<font class=\"tdmain\">User \"$username\" already exists</font><p>\n";
$username = '';
}
elseif (is_valid_string($username)) {
echo "<font class=\"tdmain\">Username contains bad characters</font><p>\n";
$username = '';
}
elseif (is_valid_string($password)) {
echo "<font class=\"tdmain\">Password contains bad characters</font><p>\n";
}
elseif (is_valid_string($passwordv)) {
echo "<font class=\"tdmain\">Password (Verify) contains bad characters</font><p>\n";
}
elseif ($password != $passwordv) {
echo "<font class=\"tdmain\">Passwords don't match</font><p>\n";
}
elseif (is_valid_realname($realname)) {
echo "<font class=\"tdmain\">Realname contains bad characters</font><p>\n";
$realname = '';
}
elseif (is_valid_email($email)) {
echo "<font class=\"tdmain\">E-Mail contains bad characters</font><p>\n";
$email = '';
}
else {
echo "<font class=\"tdmain\">User \"$username\" addedd successfuly<p>\n";
$userid = count($htpUser);
$htpUser[$userid]['username'] = $username;
$htpUser[$userid]['password'] = crypt_password($username, $password);
$htpUser[$userid]['realname'] = $realname;
$htpUser[$userid]['email'] = $email;
write_passwd_file($id);
read_passwd_file($id);
# clean form
$username = '';
$realname = '';
$email = '';
}
}
else {
$username = '';
$realname = '';
$email = '';
}
?>
<table border="0" cellspacing="3" cellpadding="2" width="600">
<form method="post" action="<?php echo $PHP_SELF.'?'.random() ?>">
<input type="hidden" name="id" value="<?php echo $id ?>">
<tr>
<td colspan="2" width="100%" align="left" class="tdheader"><?php echo $cfgProgName.' '.$cfgVersion ?></td>
</tr>
<tr>
<td colspan="2" width="100%" align="left" class="tdheader">[ <?php echo $cfgHTPasswd[$id]['D'] ?> ]</td>
</tr>
<tr>
<td width="30%" align="right" class="tdmain">Username:</td>
<td width="70%" align="left" class="tdmain"><input type="text" name="username" size="25" maxlength="25" value="<?php echo $username ?>"></td>
</tr>
<tr>
<td width="30%" align="right" class="tdmain">Password:</td>
<td width="70%" align="left" class="tdmain"><input type="password" name="password" size="25" maxlength="25"></td>
</tr>
<tr>
<td width="30%" align="right" class="tdmain">Password (Verify):</td>
<td width="70%" align="left" class="tdmain"><input type="password" name="passwordv" size="25" maxlength="25"></td>
</tr>
<tr>
<td width="30%" align="right" class="tdmain">Realname:</td>
<td width="70%" align="left" class="tdmain"><input type="text" name="realname" size="25" maxlength="100" value="<?php echo $realname ?>"></td>
</tr>
<tr>
<td width="30%" align="right" class="tdmain">E-Mail:</td>
<td width="70%" align="left" class="tdmain"><input type="text" name="email" size="25" maxlength="150" value="<?php echo $email ?>"></td>
</tr>
<tr>
<td colspan="2" width="100%" align="center" class="tdmain"><input type="submit" name="submit" value=" Add User "></td>
</tr>
</form>
</table>
<table border="0" cellspacing="3" cellpadding="2" width="600">
<tr>
<td width="100%" align="left" class="tdmain">[
<a href="index.php?<?php echo random() ?>">Main Page</a> |
<a href="browse.php?id=<?php echo $id ?>&sid=<?php echo random() ?>">Browse User List</a> |
Add New User |
<a href="view-htpasswd.php?id=<?php echo $id ?>&sid=<?php echo random() ?>">View .htpasswd file</a> |
<a href="create-htaccess.php?id=<?php echo $id ?>&sid=<?php echo random() ?>">Create a Simple .htaccess File</a> ]</td>
</tr>
</table>
<?php
require './footer.inc.php';
?>