users.php
author rejo
Tue, 01 Jan 2008 20:36:17 +0000
changeset 56 6db9adfa86ac
parent 47 ae140472d97c
child 60 6ffacb626294
permissions -rw-r--r--
[feladat @ 103] Created function to add a so-called sub-owner to a record.
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>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    77
        <th><? echo _('Zones'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    78
        <th><? echo _('Zone list'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    79
        <th><? echo _('Level'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    80
        <th><? echo _('Status'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    81
       </tr>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    82
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    83
$users = show_users('',ROWSTART,ROWAMOUNT);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    84
foreach ($users as $c)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    85
{
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    86
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    87
       <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    88
        <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
    89
        <td class="n"><a href="edit_user.php?id=<? echo $c["id"] ?>"><? echo $c["fullname"] ?></A> (<? echo $c["username"] ?>)</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    90
        <td class="n"><? echo $c["numdomains"] ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    91
        <td class="n">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    92
        <?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    93
        $domains = get_domains_from_userid($c["id"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    94
        foreach ($domains as $d)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    95
        {
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    96
                ?><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"] ?></a><br><?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    97
        }
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    98
        ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    99
	<td class="n"><? echo $c["level"] ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   100
	<td class="n"><? echo get_status($c["active"]) ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   101
       </tr><?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   102
        print "\n";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   103
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   104
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   105
      </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   106
      <p><? echo _('Number of users') ;?>: <? echo count($users); ?>.</p>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   107
      <div class="showmax">
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   108
<?
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   109
show_pages(count($users),ROWAMOUNT);
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   110
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   111
      </div> <? // eo div showmax ?>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   112
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   113
      <h3><? echo _('Create new user'); ?></h3>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   114
      <form method="post" action="users.php">
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   115
       <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   116
        <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   117
         <td class="n"><? echo _('User name'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   118
         <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
   119
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   120
	<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   121
	 <td class="n"><? echo _('Full name'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   122
	 <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
   123
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   124
	<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   125
	 <td class="n"><? echo _('Password'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   126
	 <td class="n"><input type="text" class="input" NAME="password" VALUE="<? if ($error) print $_POST["password"]; ?>"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   127
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   128
	<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   129
	 <td class="n"><? echo _('E-mail'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   130
	 <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
   131
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   132
	<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   133
	 <td class="n"><? echo _('User level'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   134
	 <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   135
	  <select name="level">
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   136
	   <option value="1">1 (<? echo leveldescription(1) ?>)</option>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   137
	   <option value="5">5 (<? echo leveldescription(5) ?>)</option>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   138
	   <option value="10">10 (<? echo leveldescription(10) ?>)</option>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   139
	  </select>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   140
	 </td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   141
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   142
        <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   143
	 <td class="n"><? echo _('Description'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   144
	 <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
   145
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   146
	<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   147
	 <td class="n"><? echo _('Active'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   148
	 <td class="n"><input type="checkbox" name="active" value="1" checked></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   149
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   150
	<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   151
	 <td class="n">&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   152
	 <td class="n"><input type="submit" class="button" name="submit" value="<? echo _('Add user'); ?>"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   153
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   154
       </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   155
      </form>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   156
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   157
include_once("inc/footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   158
?>