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
?>
71
+ − 57
<div class="error"> <?php echo $error ; ?> </div>
+ − 58
<?php
13
+ − 59
}
+ − 60
?>
71
+ − 61
<h2> <?php echo _ ( 'User admin' ); ?> </h2>
+ − 62
<?php
1
+ − 63
if ( ! level ( 10 ))
+ − 64
{
+ − 65
error ( ERR_LEVEL_10 );
+ − 66
}
13
+ − 67
?>
71
+ − 68
<h3> <?php echo _ ( 'Current users' ); ?> </h3>
+ − 69
<?php
1
+ − 70
$users = show_users ( '' );
13
+ − 71
?>
1
+ − 72
13
+ − 73
<table>
+ − 74
<tr>
+ − 75
<th> </th>
71
+ − 76
<th> <?php echo _ ( 'Name' ); ?> </th>
+ − 77
<th> <?php echo _ ( 'Zones' ); ?> ( <?php echo _ ( 'access' ); ?> )</th>
+ − 78
<th> <?php echo _ ( 'Zones' ); ?> ( <?php echo _ ( 'owner' ); ?> )</th>
+ − 79
<th> <?php echo _ ( 'Zone list' ); ?> </th>
+ − 80
<th> <?php echo _ ( 'Level' ); ?> </th>
+ − 81
<th> <?php echo _ ( 'Status' ); ?> </th>
13
+ − 82
</tr>
71
+ − 83
<?php
1
+ − 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>
71
+ − 91
<td class="n"><a href="delete_user.php?id= <?php echo $c [ "id" ] ?> "><img src="images/delete.gif" alt="[ <?php echo _ ( 'Delete user' ); ?> ]"></a></td>
+ − 92
<td class="n"><a href="edit_user.php?id= <?php echo $c [ "id" ] ?> "> <?php echo $c [ "fullname" ] ?> </A> ( <?php echo $c [ "username" ] ?> )</td>
+ − 93
<td class="n"> <?php echo $num_zones_access ?> </td>
+ − 94
<td class="n"> <?php echo $c [ "numdomains" ] ?> </td>
13
+ − 95
<td class="n">
71
+ − 96
<?php
1
+ − 97
foreach ( $domains as $d )
+ − 98
{
71
+ − 99
?> <a href="delete_domain.php?id= <?php echo $d [ "id" ] ?> "><img src="images/delete.gif" alt="[ <?php echo _ ( 'Delete domain' ); ?> ]"></a> <a href="edit.php?id= <?php echo $d [ "id" ] ?> "> <?php echo $d [ "name" ] ?><?php if ( $d [ "partial" ] == "1" ) { echo " *" ; } ; ?> </a><br> <?php
1
+ − 100
}
13
+ − 101
?> </td>
71
+ − 102
<td class="n"> <?php echo $c [ "level" ] ?> </td>
+ − 103
<td class="n"> <?php echo get_status ( $c [ "active" ]) ?> </td>
+ − 104
</tr> <?php
1
+ − 105
print " \n " ;
+ − 106
}
+ − 107
?>
60
+ − 108
13
+ − 109
</table>
71
+ − 110
<p> <?php echo _ ( 'Users may only change some of the records of zones marked with an (*).' ); ?> </p>
+ − 111
<p> <?php echo _ ( 'Number of users' ) ; ?> : <?php echo count ( $users ); ?> .</p>
13
+ − 112
<div class="showmax">
71
+ − 113
<?php
13
+ − 114
show_pages ( count ( $users ), ROWAMOUNT );
+ − 115
?>
71
+ − 116
</div> <?php // eo div showmax ?>
1
+ − 117
71
+ − 118
< h3 ><? php echo _ ( 'Create new user' ); ?> </h3>
13
+ − 119
<form method="post" action="users.php">
+ − 120
<table>
+ − 121
<tr>
71
+ − 122
<td class="n"> <?php echo _ ( 'User name' ); ?> :</td>
+ − 123
<td class="n"><input type="text" class="input" name="username" value=" <?php if ( $error ) print $_POST [ "username" ]; ?> "></td>
13
+ − 124
</tr>
+ − 125
<tr>
71
+ − 126
<td class="n"> <?php echo _ ( 'Full name' ); ?> :</td>
+ − 127
<td class="n"><input type="text" class="input" NAME="fullname" VALUE=" <?php if ( $error ) print $_POST [ "fullname" ]; ?> "></td>
13
+ − 128
</tr>
+ − 129
<tr>
71
+ − 130
<td class="n"> <?php echo _ ( 'Password' ); ?> :</td>
+ − 131
<td class="n"><input type="password" class="input" NAME="password" VALUE=" <?php if ( $error ) print $_POST [ "password" ]; ?> "></td>
13
+ − 132
</tr>
+ − 133
<tr>
71
+ − 134
<td class="n"> <?php echo _ ( 'E-mail' ); ?> :</td>
+ − 135
<td class="n"><input type="text" class="input" NAME="email" VALUE=" <?php if ( $error ) print $_POST [ "email" ]; ?> "></td>
13
+ − 136
</tr>
+ − 137
<tr>
71
+ − 138
<td class="n"> <?php echo _ ( 'User level' ); ?> :</td>
13
+ − 139
<td class="n">
+ − 140
<select name="level">
71
+ − 141
<option value="1">1 ( <?php echo leveldescription ( 1 ) ?> )</option>
+ − 142
<option value="5">5 ( <?php echo leveldescription ( 5 ) ?> )</option>
+ − 143
<option value="10">10 ( <?php echo leveldescription ( 10 ) ?> )</option>
13
+ − 144
</select>
+ − 145
</td>
+ − 146
</tr>
+ − 147
<tr>
71
+ − 148
<td class="n"> <?php echo _ ( 'Description' ); ?> :</td>
+ − 149
<td class="n"><textarea rows="6" cols="30" class="inputarea" name="description"> <?php if ( $error ) print $_POST [ "description" ]; ?> </textarea></td>
13
+ − 150
</tr>
+ − 151
<tr>
71
+ − 152
<td class="n"> <?php echo _ ( 'Active' ); ?> :</td>
13
+ − 153
<td class="n"><input type="checkbox" name="active" value="1" checked></td>
+ − 154
</tr>
+ − 155
<tr>
+ − 156
<td class="n"> </td>
71
+ − 157
<td class="n"><input type="submit" class="button" name="submit" value=" <?php echo _ ( 'Add user' ); ?> "></td>
13
+ − 158
</tr>
+ − 159
</table>
+ − 160
</form>
71
+ − 161
<?php
1
+ − 162
include_once ( "inc/footer.inc.php" );
+ − 163
?>