<?php
include('../start.php');
include(ADM_PATH.'/adminstart.php');
//$users=$db->gets("select * from aduser");
$auid=(int)$input->get('auid');
$item=array(
'auid'=>'0',
'auname'=>'',
'passwd'=>'',
);
if($auid>0){
$item=$db->get("select * from aduser where auid='{$auid}'");
if(!$item){
exit("meiyouyonghu");
}
}
if($input->get('do')=='save'){
$auid=(int)$input->post('auid');
$auname= trim($input->post('auname'));
$passwd= trim($input->post('passwd'));
if(empty($auname)){
exit("yonghumingbunengweikong");
}
if($auid<1){
if(empty($passwd)){
exit("sd");
}
$usercheck=$db->get("select * from aduser where auname='{$auname}'");
if(is_array($usercheck)){
exit("cz");
}
}
if($auid<1){
$passwd=md5($passwd);
$sql="insert into aduser (auname,passwd) values ('{$auname}','{$passwd}')";
}
else {
if(empty($passwd)){
$sql="update aduser set auname='{$auname}' where auid='$auid'";
}else{
$passwd=md5($passwd);
$sql="update aduser set passwd='{$passwd}' where auid='$auid'";
}
}
$db->query($sql);
header("location:".ADM_URL_PATH."/admin.php");
exit;
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>后台管理</title>
<link rel="stylesheet" href="../public/bootstrap/css/bootstrap.min.css">
<script src="../public/jquery.min.js"></script>
<script src="../public/bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://localhost/blog/web/admin/adindex.php">AdminPannel</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li ><a href="http://localhost/blog/web/admin/blog.php">日志管理</a></li>
<li><a href="http://localhost/blog/web/admin/admin.php">管理员管理</a></li>
<li class="dropdown">
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<!-- <li><a href="#">Link</a></li>-->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">welcome! <?php echo $user['auname']?><span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="<?php echo URL_PATH;?>/admin/login.php?do=out">退出登录</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="container" >
<div class="page-header">
<h1>管理员管理<a href="http://localhost/blog/web/admin/admin.php" class="btn btn-primary pull-right"><span class="glyphicon glyphicon-chevron-left">返回</span></a></h1>
</div>
<div class="col-md-offset-3 col-md-6">
<form class="form-horizontal" action="<?php echo URL_PATH;?>/admin/add.php?do=save" method="post" >
<input type="hidden" name="auid" value="<?php echo $auid;?>" />
<div class="form-group">
<label for="auname" class="col-sm-2 control-label">用户名</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="auname" id="auname" value="<?php echo $item['auname'];;?>" >
</div>
</div>
<div class="form-group">
<label for="passwd" class="col-sm-2 control-label">密码</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="passwd" name="passwd" placeholder="请输入密码">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">提交</button>
</div>
</div>
</form>
</div>
</div>
</body>
</html>