<?
defined('ROOT_PHPLEFT') or exit('phpleft: Not page');
/*
	phpleftDms Copyright (c) 2011 phpleft.COM
	商业授权：QQ45150208
	
*/
$rs = new admin;
if ($post<>''){
switch($post) {
   case 'add':
   $sql = sql_list("table=admin&where=username='".$add['username']."'&order=id asc");
   if($sql){
   msg('管理员已经存在', 'phpleft.php?file=admin&show='.$post,0,1,1,'n');
   }else{
   $add['userpwd']=md5($pwd.md5(DMS));
   $add['logn'] = 0;
   $add['addtime'] = time();
   $rs->update_post($add,'admin','addtime');
   msg('添加成功', 'phpleft.php?file=admin');
   }
   break;
   case 'del':
   $db->query("DELETE FROM ".$PL_CFG['tb_pre']."admin WHERE id=".$id);
   msg('删除成功', 'phpleft.php?file=admin');
   break;
   case 'bj':
   if($pwd) $add['userpwd'] = md5($pwd.md5(DMS));
   $end = $pwd?'userpwd':'username';
   $rs->update_posts($add,'admin',$end,$id);
   msg('编辑成功', 'phpleft.php?file=admin');
   break;
}
}else{
$menu = array (
	array('','phpleft.php?file=admin', '管理员管理',0),
    array('add','phpleft.php?file=admin&show=add', '添加管理员',0),
);
if ($id) $add = sql_show("table=admin&where=id='".$id."'&order=id asc");
$list = sql_list("table=admin&order=id asc");
include FTemplate(ThisFile);
}
?>