File size: 2.37Kb
<?php
include ('../config.php');
$page='user';
include ('session.php');
include ($config->real() . $config->header);
require($config->real().$config->user);
if(!isset($globaladmin[$_GET['user']])){
header('Location: user.php');
die();
}
?>
<?php
if(isset($_GET) and isset($_GET['submit']) and isset($_POST)){
if(empty($_POST['user']) or empty($_POST['pass']))
{
$error='Username and Password should be supplied!';
}
else{
unset($globaladmin[$_GET['user']]);
$globaladmin[$_POST['user']]=array('password'=>$_POST['pass'],'rights'=>$_POST['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);
header('Location: user.php');
}}
?>
<?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">Edit 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_edit.php?submit=true&user=<?php echo $_GET['user']; ?>" method="POST">
Username: <input type="text" name="user" value="<?php echo $_GET['user']; ?>" /><br />
Password: <input type="password" name="pass" value="<?php echo $globaladmin[$_GET['user']]['password']; ?>" /><br />
Rights: <br />
<?php
$rights=explode('|',$globaladmin[$_GET['user']]['rights']);
$array=$functions;
unset($array['about'],$array['logout']);
foreach($array as $optname=>$opt):?>
<div class="item">
<?php if(in_array($optname,$rights)): ?>
<input name="rights[]" type="checkbox" value="<?php echo $optname; ?>" checked="TRUE" /><?php echo $opt['Name']; ?><br />
<?php else: ?>
<input name="rights[]" type="checkbox" value="<?php echo $optname; ?>" /><?php echo $opt['Name']; ?><br />
<?php endif; ?></div>
<?php endforeach; ?>
<div style="text-align: center;"><input type="submit" value="Edit" /></div>
</form>
</div>
<?php if($layout=='web'){
echo '</div></div></div>';
}
?>
<?php
include ($config->real() . $config->footer); ?>