2009-09-07 11:07:59 +00:00
< ? php
2008-03-09 22:49:53 +00:00
echo ( " <div style='margin: 10px;'> " );
2011-03-28 10:48:43 +00:00
if ( $_SESSION [ 'userlevel' ] < '10' )
2010-03-06 01:10:05 +00:00
{
2009-08-12 15:20:20 +00:00
include ( " includes/error-no-perm.inc.php " );
2011-03-17 00:09:20 +00:00
}
else
2010-03-06 01:10:05 +00:00
{
2008-03-09 22:49:53 +00:00
echo ( " <h3>Add User</h3> " );
2010-03-06 01:10:05 +00:00
if ( auth_usermanagement ())
{
2011-03-17 00:09:20 +00:00
if ( $_POST [ 'action' ] == " add " )
{
if ( $_POST [ 'new_username' ])
2010-03-06 01:10:05 +00:00
{
if ( ! user_exists ( $_POST [ 'new_username' ]))
{
2011-09-20 09:55:11 +00:00
2011-05-05 14:54:12 +00:00
if ( isset ( $_POST [ 'can_modify_passwd' ])) {
$_POST [ 'can_modify_passwd' ] = 1 ;
} else {
$_POST [ 'can_modify_passwd' ] = 0 ;
}
2011-09-20 09:55:11 +00:00
2010-03-06 01:10:05 +00:00
# FIXME: missing email field here on the form
2011-05-05 14:54:12 +00:00
if ( adduser ( $_POST [ 'new_username' ], $_POST [ 'new_password' ], $_POST [ 'new_level' ], '' , $_POST [ 'realname' ], $_POST [ 'can_modify_passwd' ]))
2011-03-17 00:09:20 +00:00
{
echo ( " <span class=info>User " . $_POST [ 'username' ] . " added!</span> " );
2010-03-06 01:10:05 +00:00
}
}
else
{
echo ( '<div class="red">User with this name already exists!</div>' );
}
}
else
{
echo ( '<div class="red">Please enter a username!</div>' );
}
2009-03-16 15:19:44 +00:00
}
2008-03-09 22:49:53 +00:00
2011-09-21 13:08:51 +00:00
echo ( " <form method='post' action='adduser/'> <input type='hidden' value='add' name='action'> " );
2010-03-06 01:10:05 +00:00
echo ( " Username <input style='margin: 1px;' name='new_username'></input><br /> " );
2009-03-16 15:19:44 +00:00
?>
Password < input style = 'margin: 1px;' name = 'new_password' id = 'new_password' type = password />< br />
< ? php
2011-03-17 00:09:20 +00:00
if ( $_POST [ 'action' ] == " add " && ! $_POST [ 'new_password' ])
2010-03-06 01:10:05 +00:00
{
echo ( " <span class=red>Please enter a password!</span><br /> " );
}
echo ( " Realname <input style='margin: 1px;' name='new_realname'></input><br /> " );
echo ( " Level <select style='margin: 5px;' name='new_level'>
2008-03-09 22:49:53 +00:00
< option value = '1' > Normal User </ option >
< option value = '5' > Global Read </ option >
< option value = '10' > Administrator </ option >
2011-05-05 14:54:12 +00:00
</ select >< br /> " );
echo ( " <input type='checkbox' checked='checked' style='margin: 1px;' name='can_modify_passwd'></input> Allow the user to change his password.<br /><br /> " );
2010-03-06 01:10:05 +00:00
echo ( " <input type='submit' Value='Add' > " );
echo ( " </form> " );
}
else
{
echo ( '<span class="red">Auth module does not allow user management!</span><br />' );
}
2008-03-09 22:49:53 +00:00
}
echo ( " </div> " );
2011-03-17 00:09:20 +00:00
?>