1
|
1 |
<?php |
|
2 |
|
47
|
3 |
/* PowerAdmin, a friendly web-based admin tool for PowerDNS. |
|
4 |
* See <https://rejo.zenger.nl/poweradmin> for more details. |
|
5 |
* |
|
6 |
* Copyright 2007, 2008 Rejo Zenger <rejo@zenger.nl> |
|
7 |
* |
|
8 |
* This program is free software: you can redistribute it and/or modify |
|
9 |
* it under the terms of the GNU General Public License as published by |
|
10 |
* the Free Software Foundation, either version 3 of the License, or |
|
11 |
* (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20 |
*/ |
|
21 |
|
1
|
22 |
require_once("inc/toolkit.inc.php"); |
|
23 |
|
|
24 |
if($_POST["submit"] |
|
25 |
&& $_POST["username"] != "" |
|
26 |
&& $_POST["password"] != "" |
|
27 |
&& $_POST["fullname"] != "" |
|
28 |
&& $_POST["email"] != "" |
|
29 |
&& $_POST["level"] > 0) |
|
30 |
{ |
|
31 |
if(substr_count($_POST["username"], " ") == 0) |
|
32 |
{ |
13
|
33 |
if(strlen($_POST["password"]) < 8) |
|
34 |
{ |
|
35 |
$error = _('Password length should be at least 8 characters.'); |
|
36 |
} |
|
37 |
else |
|
38 |
{ |
|
39 |
add_user($_POST["username"], $_POST["password"], $_POST["fullname"], $_POST["email"], $_POST["level"], $_POST["description"], $_POST["active"]); |
69
|
40 |
clean_page("users.php"); |
13
|
41 |
} |
|
42 |
} |
1
|
43 |
else |
|
44 |
{ |
3
|
45 |
$error = _('Usernames can\'t contain spaces'); |
1
|
46 |
} |
|
47 |
} |
|
48 |
elseif($_POST["submit"]) |
|
49 |
{ |
2
|
50 |
$error = _('Please fill in all fields'); |
1
|
51 |
} |
|
52 |
|
|
53 |
include_once("inc/header.inc.php"); |
13
|
54 |
if ($error != "") |
|
55 |
{ |
1
|
56 |
?> |
13
|
57 |
<div class="error"><? echo $error ; ?></div> |
|
58 |
<? |
|
59 |
} |
|
60 |
?> |
|
61 |
<h2><? echo _('User admin'); ?></h2> |
|
62 |
<? |
1
|
63 |
if (!level(10)) |
|
64 |
{ |
|
65 |
error(ERR_LEVEL_10); |
|
66 |
} |
13
|
67 |
?> |
|
68 |
<h3><? echo _('Current users'); ?></h3> |
|
69 |
<? |
1
|
70 |
$users = show_users(''); |
13
|
71 |
?> |
1
|
72 |
|
13
|
73 |
<table> |
|
74 |
<tr> |
|
75 |
<th> </th> |
|
76 |
<th><? echo _('Name'); ?></th> |
60
|
77 |
<th><? echo _('Zones'); ?> (<? echo _('access'); ?>)</th> |
|
78 |
<th><? echo _('Zones'); ?> (<? echo _('owner'); ?>)</th> |
13
|
79 |
<th><? echo _('Zone list'); ?></th> |
|
80 |
<th><? echo _('Level'); ?></th> |
|
81 |
<th><? echo _('Status'); ?></th> |
|
82 |
</tr> |
1
|
83 |
<? |
|
84 |
$users = show_users('',ROWSTART,ROWAMOUNT); |
|
85 |
foreach ($users as $c) |
|
86 |
{ |
60
|
87 |
$domains = get_domains_from_userid($c["id"]); |
|
88 |
$num_zones_access = count($domains); |
13
|
89 |
?> |
|
90 |
<tr> |
|
91 |
<td class="n"><a href="delete_user.php?id=<? echo $c["id"] ?>"><img src="images/delete.gif" alt="[ <? echo _('Delete user'); ?> ]"></a></td> |
|
92 |
<td class="n"><a href="edit_user.php?id=<? echo $c["id"] ?>"><? echo $c["fullname"] ?></A> (<? echo $c["username"] ?>)</td> |
60
|
93 |
<td class="n"><? echo $num_zones_access ?></td> |
13
|
94 |
<td class="n"><? echo $c["numdomains"] ?></td> |
|
95 |
<td class="n"> |
1
|
96 |
<? |
|
97 |
foreach ($domains as $d) |
|
98 |
{ |
60
|
99 |
?><a href="delete_domain.php?id=<? echo $d["id"] ?>"><img src="images/delete.gif" alt="[ <? echo _('Delete domain'); ?> ]"></a> <a href="edit.php?id=<? echo $d["id"] ?>"><? echo $d["name"] ?><? if ($d["partial"] == "1") { echo " *"; } ; ?></a><br><? |
1
|
100 |
} |
13
|
101 |
?></td> |
|
102 |
<td class="n"><? echo $c["level"] ?></td> |
|
103 |
<td class="n"><? echo get_status($c["active"]) ?></td> |
|
104 |
</tr><? |
1
|
105 |
print "\n"; |
|
106 |
} |
|
107 |
?> |
60
|
108 |
|
13
|
109 |
</table> |
60
|
110 |
<p><? echo _('Users may only change some of the records of zones marked with an (*).'); ?></p> |
13
|
111 |
<p><? echo _('Number of users') ;?>: <? echo count($users); ?>.</p> |
|
112 |
<div class="showmax"> |
|
113 |
<? |
|
114 |
show_pages(count($users),ROWAMOUNT); |
|
115 |
?> |
|
116 |
</div> <? // eo div showmax ?> |
1
|
117 |
|
13
|
118 |
<h3><? echo _('Create new user'); ?></h3> |
|
119 |
<form method="post" action="users.php"> |
|
120 |
<table> |
|
121 |
<tr> |
|
122 |
<td class="n"><? echo _('User name'); ?>:</td> |
|
123 |
<td class="n"><input type="text" class="input" name="username" value="<? if ($error) print $_POST["username"]; ?>"></td> |
|
124 |
</tr> |
|
125 |
<tr> |
|
126 |
<td class="n"><? echo _('Full name'); ?>:</td> |
|
127 |
<td class="n"><input type="text" class="input" NAME="fullname" VALUE="<? if ($error) print $_POST["fullname"]; ?>"></td> |
|
128 |
</tr> |
|
129 |
<tr> |
|
130 |
<td class="n"><? echo _('Password'); ?>:</td> |
66
|
131 |
<td class="n"><input type="password" class="input" NAME="password" VALUE="<? if ($error) print $_POST["password"]; ?>"></td> |
13
|
132 |
</tr> |
|
133 |
<tr> |
|
134 |
<td class="n"><? echo _('E-mail'); ?>:</td> |
|
135 |
<td class="n"><input type="text" class="input" NAME="email" VALUE="<? if ($error) print $_POST["email"]; ?>"></td> |
|
136 |
</tr> |
|
137 |
<tr> |
|
138 |
<td class="n"><? echo _('User level'); ?>:</td> |
|
139 |
<td class="n"> |
|
140 |
<select name="level"> |
|
141 |
<option value="1">1 (<? echo leveldescription(1) ?>)</option> |
|
142 |
<option value="5">5 (<? echo leveldescription(5) ?>)</option> |
|
143 |
<option value="10">10 (<? echo leveldescription(10) ?>)</option> |
|
144 |
</select> |
|
145 |
</td> |
|
146 |
</tr> |
|
147 |
<tr> |
|
148 |
<td class="n"><? echo _('Description'); ?>:</td> |
|
149 |
<td class="n"><textarea rows="6" cols="30" class="inputarea" name="description"><? if ($error) print $_POST["description"]; ?></textarea></td> |
|
150 |
</tr> |
|
151 |
<tr> |
|
152 |
<td class="n"><? echo _('Active'); ?>:</td> |
|
153 |
<td class="n"><input type="checkbox" name="active" value="1" checked></td> |
|
154 |
</tr> |
|
155 |
<tr> |
|
156 |
<td class="n"> </td> |
|
157 |
<td class="n"><input type="submit" class="button" name="submit" value="<? echo _('Add user'); ?>"></td> |
|
158 |
</tr> |
|
159 |
</table> |
|
160 |
</form> |
1
|
161 |
<? |
|
162 |
include_once("inc/footer.inc.php"); |
|
163 |
?> |