users.php
author peter
Sun, 06 Jan 2008 11:49:17 +0000
changeset 67 2f8c29fc5e2e
parent 66 9e9876afefcc
child 69 025700cc92cd
permissions -rw-r--r--
[feladat @ 114] Patch for ticket 19. Because of the use of the quote function, empty strings where converted to NULL as MDB2_PORTABILITY_EMPTY_TO_NULL is set by default. This problem also applied to the active state of an user.
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"]);
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    40
			clean_page($BASE_URL . $BASE_PATH . "users.php");
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
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    57
	<div class="error"><? echo $error ; ?></div>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    58
<?
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    59
}
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    60
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    61
    <h2><? echo _('User admin'); ?></h2>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    62
<?
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
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    68
     <h3><? echo _('Current users'); ?></h3>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    69
<?
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>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    76
        <th><? echo _('Name'); ?></th>
60
6ffacb626294 [feladat @ 107]
rejo
parents: 47
diff changeset
    77
        <th><? echo _('Zones'); ?> (<? echo _('access'); ?>)</th>
6ffacb626294 [feladat @ 107]
rejo
parents: 47
diff changeset
    78
        <th><? echo _('Zones'); ?> (<? echo _('owner'); ?>)</th>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    79
        <th><? echo _('Zone list'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    80
        <th><? echo _('Level'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    81
        <th><? echo _('Status'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    82
       </tr>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    83
<?
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>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    91
        <td class="n"><a href="delete_user.php?id=<? echo $c["id"] ?>"><img src="images/delete.gif" alt="[ <? echo _('Delete user'); ?> ]"></a></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    92
        <td class="n"><a href="edit_user.php?id=<? echo $c["id"] ?>"><? echo $c["fullname"] ?></A> (<? echo $c["username"] ?>)</td>
60
6ffacb626294 [feladat @ 107]
rejo
parents: 47
diff changeset
    93
        <td class="n"><? echo $num_zones_access ?></td>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    94
        <td class="n"><? echo $c["numdomains"] ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    95
        <td class="n">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    96
        <?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    97
        foreach ($domains as $d)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    98
        {
60
6ffacb626294 [feladat @ 107]
rejo
parents: 47
diff changeset
    99
                ?><a href="delete_domain.php?id=<? echo $d["id"] ?>"><img src="images/delete.gif" alt="[ <? echo _('Delete domain'); ?> ]"></a>&nbsp;<a href="edit.php?id=<? echo $d["id"] ?>"><? echo $d["name"] ?><? if ($d["partial"] == "1") { echo " *"; } ; ?></a><br><?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   100
        }
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   101
        ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   102
	<td class="n"><? echo $c["level"] ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   103
	<td class="n"><? echo get_status($c["active"]) ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   104
       </tr><?
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>
60
6ffacb626294 [feladat @ 107]
rejo
parents: 47
diff changeset
   110
      <p><? echo _('Users may only change some of the records of zones marked with an (*).'); ?></p>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   111
      <p><? echo _('Number of users') ;?>: <? echo count($users); ?>.</p>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   112
      <div class="showmax">
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   113
<?
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   114
show_pages(count($users),ROWAMOUNT);
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   115
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   116
      </div> <? // eo div showmax ?>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   117
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   118
      <h3><? echo _('Create new user'); ?></h3>
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>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   122
         <td class="n"><? echo _('User name'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   123
         <td class="n"><input type="text" class="input" name="username" value="<? if ($error) print $_POST["username"]; ?>"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   124
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   125
	<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   126
	 <td class="n"><? echo _('Full name'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   127
	 <td class="n"><input type="text" class="input" NAME="fullname" VALUE="<? if ($error) print $_POST["fullname"]; ?>"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   128
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   129
	<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   130
	 <td class="n"><? echo _('Password'); ?>:</td>
66
9e9876afefcc [feladat @ 113]
rejo
parents: 60
diff changeset
   131
	 <td class="n"><input type="password" class="input" NAME="password" VALUE="<? 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>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   134
	 <td class="n"><? echo _('E-mail'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   135
	 <td class="n"><input type="text" class="input" NAME="email" VALUE="<? if ($error) print $_POST["email"]; ?>"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   136
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   137
	<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   138
	 <td class="n"><? echo _('User level'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   139
	 <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   140
	  <select name="level">
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   141
	   <option value="1">1 (<? echo leveldescription(1) ?>)</option>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   142
	   <option value="5">5 (<? echo leveldescription(5) ?>)</option>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   143
	   <option value="10">10 (<? echo leveldescription(10) ?>)</option>
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>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   148
	 <td class="n"><? echo _('Description'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   149
	 <td class="n"><textarea rows="6" cols="30" class="inputarea" name="description"><? if ($error) print $_POST["description"]; ?></textarea></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   150
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   151
	<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   152
	 <td class="n"><? echo _('Active'); ?>:</td>
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>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   157
	 <td class="n"><input type="submit" class="button" name="submit" value="<? echo _('Add user'); ?>"></td>
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>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   161
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   162
include_once("inc/footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   163
?>