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