users.php
author rejo
Tue, 10 Apr 2007 22:40:43 +0000
changeset 1 58094faf794d
child 2 9a485c41cfcf
permissions -rw-r--r--
[feladat @ 2] Creation of initial working branch.
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
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     4
// | PowerAdmin								|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     5
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     6
// | Copyright (c) 1997-2002 The PowerAdmin Team			|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     7
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     8
// | This source file is subject to the license carried by the overal	|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     9
// | program PowerAdmin as found on http://poweradmin.sf.net		|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    10
// | The PowerAdmin program falls under the QPL License:		|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    11
// | http://www.trolltech.com/developer/licensing/qpl.html		|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    12
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    13
// | Authors: Roeland Nieuwenhuis <trancer <AT> trancer <DOT> nl>	|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    14
// |          Sjeemz <sjeemz <AT> sjeemz <DOT> nl>			|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    15
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    16
//
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    17
// $Id: users.php,v 1.11 2003/02/05 23:22:33 azurazu Exp $
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    18
//
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    19
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    20
require_once("inc/toolkit.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    21
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    22
if($_POST["submit"]
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
&& $_POST["username"] != ""
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
&& $_POST["password"] != "" 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    25
&& $_POST["fullname"] != ""
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    26
&& $_POST["email"] != ""
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    27
&& $_POST["level"] > 0)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    28
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    29
	if(substr_count($_POST["username"], " ") == 0)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    30
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
		add_user($_POST["username"], $_POST["password"], $_POST["fullname"], $_POST["email"], $_POST["level"], $_POST["description"], $_POST["active"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    32
        	clean_page($BASE_URL . $BASE_PATH . "users.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    33
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
        else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    35
        {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    36
        	$error = "Usernames cant contain spaces";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    37
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    38
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    39
elseif($_POST["submit"])
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    40
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    41
	$error = "Please fill in all fields";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    42
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    43
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    44
// Dirty hack, maybe revise?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    45
include_once("inc/header.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    46
?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    47
<H2>User Admin</H2>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    48
<P CLASS="nav">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    49
<A HREF="index.php">DNS Admin</A>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    50
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
if (level(10))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    52
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    53
	?> <A HREF="seq_update.php">Synchronize Database</A> <?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    54
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    55
?><A HREF="search.php">Search records</A></P><BR><?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    56
// End
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    57
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    58
if (!level(10)) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    59
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    60
	error(ERR_LEVEL_10);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    61
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    62
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    63
if ($error != "") 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    64
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    65
        ?><H3><FONT COLOR="red">Error: <?= $error ?></FONT></H3><?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    66
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    67
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    68
echo "<B>Current users (click to edit):</B>";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    69
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    70
$users = show_users('');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    71
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    72
echo "<br /><br /><small><b>Number of users:</b> ".count($users);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    73
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    74
show_pages(count($users),ROWAMOUNT);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    75
?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    76
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    77
<br /><br /><TABLE BORDER="0" CELLSPACING="4">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    78
<TR STYLE="font-weight: Bold;"><TD CLASS="tdbg">&nbsp;</TD><TD CLASS="tdbg">Name</TD><TD CLASS="tdbg">Domains</TD><TD CLASS="tdbg">Domain list</TD><TD CLASS="tdbg">Level</TD><TD CLASS="tdbg">Status</TD></TR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    79
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    80
$users = show_users('',ROWSTART,ROWAMOUNT);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    81
foreach ($users as $c)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    82
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    83
        ?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    84
        <TR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    85
        <TD VALIGN="top" CLASS="tdbg"><A HREF="delete_user.php?id=<?= $c["id"] ?>"><IMG SRC="images/delete.gif" ALT="[ delete user ]" BORDER="0"></A></TD>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    86
        <TD VALIGN="top" CLASS="tdbg"><A HREF="edit_user.php?id=<?= $c["id"] ?>"><?= $c["fullname"] ?></A> (<?= $c["username"] ?>)</TD>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    87
        <TD VALIGN="top" CLASS="tdbg"><?= $c["numdomains"] ?></TD>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    88
        <TD CLASS="tdbg">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    89
        <?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    90
        $domains = get_domains_from_userid($c["id"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    91
        foreach ($domains as $d)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    92
        {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    93
                ?><A HREF="delete_domain.php?id=<?= $d["id"] ?>"><IMG SRC="images/delete.gif" ALT="[ delete domain ]" BORDER="0"></A>&nbsp;<A HREF="edit.php?id=<?= $d["id"] ?>"><?= $d["name"] ?></A><BR><?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    94
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    95
        ?></TD><TD CLASS="tdbg"><?= $c["level"] ?></TD><TD VALIGN="middle" CLASS="tdbg"><?= get_status($c["active"]) ?></TD></TR><?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    96
        print "\n";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    97
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    98
?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    99
</TABLE>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   100
<BR><BR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   101
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   102
<FORM METHOD="post" action="users.php">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   103
<B>Create new user:</B><BR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   104
<TABLE BORDER="0" CELLSPACING="4">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   105
<TR><TD CLASS="tdbg">User name:</TD><TD WIDTH="510" CLASS="tdbg"><INPUT TYPE="text" CLASS="input" NAME="username" VALUE="<? if ($error) print $_POST["username"]; ?>"></TD></TR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   106
<TR><TD CLASS="tdbg">Full name:</TD><TD CLASS="tdbg"><INPUT TYPE="text" CLASS="input" NAME="fullname" VALUE="<? if ($error) print $_POST["fullname"]; ?>"></TD></TR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   107
<TR><TD CLASS="tdbg">Password:</TD><TD CLASS="tdbg"><INPUT TYPE="text" CLASS="input" NAME="password" VALUE="<? if ($error) print $_POST["password"]; ?>"></TD></TR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   108
<TR><TD CLASS="tdbg">E-mail:</TD><TD CLASS="tdbg"><INPUT TYPE="text" CLASS="input" NAME="email" VALUE="<? if ($error) print $_POST["email"]; ?>"></TD></TR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   109
<TR><TD CLASS="tdbg">User level:</TD><TD CLASS="tdbg"><SELECT NAME="level"><OPTION VALUE="1">1 (<?= leveldescription(1) ?>)</OPTION><OPTION VALUE="5">5 (<?= leveldescription(5) ?>)</OPTION><OPTION VALUE="10">10 (<?= leveldescription(10) ?>)</OPTION></SELECT></TD></TR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   110
<TR><TD CLASS="tdbg">Description:</TD><TD CLASS="tdbg"><TEXTAREA ROWS="6" COLS="30" CLASS="inputarea" NAME="description"><? if ($error) print $_POST["description"]; ?></TEXTAREA></TD></TR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   111
<TR><TD CLASS="tdbg">Active:</TD><TD CLASS="tdbg"><INPUT TYPE="checkbox" NAME="active" VALUE="1" CHECKED></TD></TR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   112
<TR><TD CLASS="tdbg">&nbsp;</TD><TD CLASS="tdbg"><INPUT TYPE="submit" CLASS="button" NAME="submit" VALUE="Add user"></TD></TR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   113
</TABLE>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   114
</FORM>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   115
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   116
include_once("inc/footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   117
?>