users.php
author rejo
Mon, 04 Jun 2007 18:43:11 +0000
changeset 13 2ff220cfde13
parent 9 d55459cd1712
child 47 ae140472d97c
permissions -rw-r--r--
[feladat @ 60] Merged 1.4.0 changes r23:59 into trunk.
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
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     3
require_once("inc/toolkit.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     4
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     5
if($_POST["submit"]
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     6
&& $_POST["username"] != ""
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     7
&& $_POST["password"] != "" 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     8
&& $_POST["fullname"] != ""
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     9
&& $_POST["email"] != ""
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    10
&& $_POST["level"] > 0)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    11
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    12
	if(substr_count($_POST["username"], " ") == 0)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    13
	{
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    14
		if(strlen($_POST["password"]) < 8)
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    15
		{
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    16
		$error = _('Password length should be at least 8 characters.');
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    17
		}
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    18
		else
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    19
		{
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    20
			add_user($_POST["username"], $_POST["password"], $_POST["fullname"], $_POST["email"], $_POST["level"], $_POST["description"], $_POST["active"]);
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    21
			clean_page($BASE_URL . $BASE_PATH . "users.php");
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    22
		}
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    23
	}
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
        else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    25
        {
3
64525a2eb098 [feladat @ 4]
rejo
parents: 2
diff changeset
    26
        	$error = _('Usernames can\'t contain spaces');
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    27
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    28
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    29
elseif($_POST["submit"])
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    30
{
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
    31
	$error = _('Please fill in all fields');
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    32
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    33
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
include_once("inc/header.inc.php");
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    35
if ($error != "") 
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    36
{
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    37
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    38
	<div class="error"><? echo $error ; ?></div>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    39
<?
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    40
}
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    41
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    42
    <h2><? echo _('User admin'); ?></h2>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    43
<?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    44
if (!level(10)) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    45
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    46
	error(ERR_LEVEL_10);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    47
}
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    48
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    49
     <h3><? echo _('Current users'); ?></h3>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    50
<?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
$users = show_users('');
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    52
?>  
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    53
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    54
      <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    55
       <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    56
        <th>&nbsp;</th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    57
        <th><? echo _('Name'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    58
        <th><? echo _('Zones'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    59
        <th><? echo _('Zone list'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    60
        <th><? echo _('Level'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    61
        <th><? echo _('Status'); ?></th>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    62
       </tr>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    63
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    64
$users = show_users('',ROWSTART,ROWAMOUNT);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    65
foreach ($users as $c)
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
       <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    69
        <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
    70
        <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
    71
        <td class="n"><? echo $c["numdomains"] ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    72
        <td class="n">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    73
        <?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    74
        $domains = get_domains_from_userid($c["id"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    75
        foreach ($domains as $d)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    76
        {
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    77
                ?><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
    78
        }
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    79
        ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    80
	<td class="n"><? echo $c["level"] ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    81
	<td class="n"><? echo get_status($c["active"]) ?></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    82
       </tr><?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    83
        print "\n";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    84
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    85
?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    86
      </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    87
      <p><? echo _('Number of users') ;?>: <? echo count($users); ?>.</p>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    88
      <div class="showmax">
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    89
<?
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    90
show_pages(count($users),ROWAMOUNT);
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    91
?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    92
      </div> <? // eo div showmax ?>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    93
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    94
      <h3><? echo _('Create new user'); ?></h3>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    95
      <form method="post" action="users.php">
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    96
       <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    97
        <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    98
         <td class="n"><? echo _('User name'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
    99
         <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
   100
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   101
	<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   102
	 <td class="n"><? echo _('Full name'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   103
	 <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
   104
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   105
	<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   106
	 <td class="n"><? echo _('Password'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   107
	 <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
   108
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   109
	<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   110
	 <td class="n"><? echo _('E-mail'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   111
	 <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
   112
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   113
	<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   114
	 <td class="n"><? echo _('User level'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   115
	 <td class="n">
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   116
	  <select name="level">
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   117
	   <option value="1">1 (<? echo leveldescription(1) ?>)</option>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   118
	   <option value="5">5 (<? echo leveldescription(5) ?>)</option>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   119
	   <option value="10">10 (<? echo leveldescription(10) ?>)</option>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   120
	  </select>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   121
	 </td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   122
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   123
        <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   124
	 <td class="n"><? echo _('Description'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   125
	 <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
   126
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   127
	<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   128
	 <td class="n"><? echo _('Active'); ?>:</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   129
	 <td class="n"><input type="checkbox" name="active" value="1" checked></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   130
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   131
	<tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   132
	 <td class="n">&nbsp;</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   133
	 <td class="n"><input type="submit" class="button" name="submit" value="<? echo _('Add user'); ?>"></td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   134
	</tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   135
       </table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 9
diff changeset
   136
      </form>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   137
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   138
include_once("inc/footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   139
?>