<?php
	include("../include/global.php");
	include("ZC_Check_admin.php");
	if(isset($_GET['aid'])){
		$aid=safe_check($_GET['aid'],0);
	}
	
	//添加关键词
	if(isset($_GET['action'])&&safe_check($_GET['action'],1)=='add'){
		$name=trim($_POST['name']);
		$password=md5(trim($_POST['newpass']).ZZCMS);
		
		$rs=$db->query("select * from `".PRE."admin` where name='".$name."'");
		if(is_array($row=$db->fetch_array($rs))){
			echo "<SCRIPT LANGUAGE='JavaScript'>alert('此管理员已存在！');history.go(-1);</SCRIPT>";
			exit;
		}
		$sql="insert into `".PRE."admin` (`uid`,`grade`,`name`,`password`) values(0,0,'".$name."','".$password."')";
		$db->query($sql) or die("添加管理员失败".mysql_error());
		echo "<script type='text/javascript'> if(confirm('是否要继续添加?')){ window.location.href='ZC_Admin_Manager.php?action=add';}else{ window.location.href='ZC_Admin_List.php';	}</script>";
	//修改关键词
	}elseif(isset($_GET['action'])&&safe_check($_GET['action'],1)=='modify'){
		$password=md5(trim($_POST['newpass']).ZZCMS);
		$sql="update `".PRE."admin` set `password`='".$password."' where `id`=$aid";		
		$db->query($sql) or die("修改管理员失败".mysql_error());
		echo "<script type='text/javascript'>alert('修改成功！'); window.location.href='ZC_Admin_List.php';</script>";
	//删除单页
	}else{
		$sql="delete from `".PRE."admin` where `id`=".$aid;
		$db->query($sql) or die ("删除单页出现错误");
		echo "<script type='text/javascript'>alert('删除成功！'); window.location.href='ZC_Admin_List.php';</script>";
		exit;
		set_keywords();
	}
?>
