<?php
include_once('IsLogined.php');
include_once("../config/databaseConfig.inc.php");
$purl = $HTTP_SERVER_VARS['HTTP_REFERER'];
if($_GET['all']=='yes'){
		/*
		批量删除ALL记录
		*/
		$sqlDel = "Delete FROM GuestBook";   
		echo $sqlDel;
		$db->Execute($sqlDel);  
		$db->close();
		exit("<meta http-equiv=\"refresh\" content=\"0;URL=Admin_GuestBook.php\">");
}
if ($_POST['more']=='del'){
	$ID= $_POST['ID'];
	if(is_array($ID)){
		$ids = $comma = "";
		foreach($ID as $id){
			$ids .= "{$comma}{$id}";
			$comma = ",";
		}
		//print($ids);
		/*
		批量删除记录
		*/
		$sqlDel = "Delete FROM GuestBook Where ID IN ({$ids})";   
		echo $sqlDel;
		$db->Execute($sqlDel);  
		$db->close();
		exit("<meta http-equiv=\"refresh\" content=\"0;URL={$purl}\">");
	}else{
		echo "<script>alert('没有勾选项目！');window.location =\"$purl\";</script>"; 
		exit();
	}
}else{
/*
从url得到ID
*/
$Qid    = $_GET["ID"];
if (empty($Qid)==true){
    die(参数传递错误！非法操作！);
}else{
    if (!is_numeric($Qid)) die(参数传递错误！非法操作！);
}
/*
删除单个记录
*/
$sqlDel = "Delete FROM GuestBook Where ID = {$Qid}";   
$db->Execute($sqlDel);  
$db->close();
exit("<meta http-equiv=\"refresh\" content=\"0;URL={$purl}\">");	
}
?>