View file aiv2 AutoIndex/panel/user_new.php

File size: 2.02Kb
<?php
include ('../config.php');
$page='user';
include ('session.php');
include ($config->real() . $config->header);
?>
<?php
if(isset($_GET) and isset($_GET['submit']) and isset($_POST)){
require($config->real().$config->user);
if(empty($_POST['user']) or empty($_POST['pass']))
{
$error='Username and Password should be supplied!';
}
else if(isset($globaladmin[$_POST['user']])){
$error='The supplied Username is already taken!';
}
else{
$rights=null;
foreach($_POST['rights'] as $rig):
$rights.=$rig.'|';
endforeach;
$globaladmin[$_POST['user']]=array('password'=>$_POST['pass'],'rights'=>$rights);
$adminrawdata='<?php
$globaladmin=array(';
foreach($globaladmin as $adminname=>$admindata){
$adminrawdata.='\''.$adminname.'\'=>array(\'password\'=>\''.$admindata['password'].'\',\'rights\'=>\''.$admindata['rights'].'\'),';
}
$adminrawdata.=');
?>';
file_put_contents($config->real().$config->user,$adminrawdata);
$error='New user created successfully!';
}}
?>
<?php
if($layout=='web'){?>
<div class="wrap">
<div style="float: left; width: 18%; margin-bottom: 5px;" class="container">
<?php include('sidebar.php'); ?>
</div>
<div style="float: right; width:80%;">
<?php
}?>
<div class="container"><div class="title">Create User</div>
<?php if($layout=='web'){
echo '<div style="padding:5px;">';
}
if(isset($error)):?>
<div style="text-align: center;"><?php echo $error; ?></div>
<?php endif; ?>
<form action="user_new.php?submit=true" method="POST">
Username: <input type="text" name="user" /><br />
Password: <input type="password" name="pass" /><br />
Rights:<br />
<?php
$array=$functions;
unset($array['about'],$array['logout']);
foreach($array as $optname=>$opt):?>
<input name="rights[]" type="checkbox" value="<?php echo $optname; ?>" /><?php echo $opt['Name']; ?><br />
<?php endforeach; ?>
<div style="text-align: center;"><input type="submit" value="Create" /></div>
</form>
</div>
<?php if($layout=='web'){
echo '</div></div></div>';
}
?>
<?php
include ($config->real() . $config->footer); ?>