<?php 

//禁止直接访问
!defined('IN_SYSTEM') && exit('Access Denied');

if(isset($_POST["SelMsg"])){
	$SelMsgArr = explode(',', $_POST['SelMsg']);
	//过滤处理
	$SelMsgArr = ToUtf8($SelMsgArr);	//转换为UTF8编码格式
	//安全验证
	if(CheckSelMsg($SelMsgArr) == false){
		echo '0';
		exit();
	}	
	$DelMsgArr = '';
	$CheckV = 1;
	foreach($SelMsgArr as $v){
		if(check_zzs($v) !== true){
			$CheckV = 0;
		}
		else{
			$DelMsgArr = $DelMsgArr."'".$v."',";
		}
	}
	if($CheckV == 1){
		//连接到MYSQL并打开系统数据库
		$DataBase->open_db();
		$DelMsgArr = rtrim($DelMsgArr, ",");
		//来路判断，如果是回收站过来的请求，则直接删除
		if($AdminLogin->CheckHttpReferer(WEB_URL.'/admin/index.php?location=recycle') == true){
			$DELETEMODE = 1;
		}
		else{
			$DELETEMODE = DELETEMODE;
		}		
		switch($DELETEMODE){
			case 1:
				//直接删除
				if($DataBase->Del('message', "WHERE `id` in (".$DelMsgArr.")")){
					echo "1";
				}
				else{
					echo "0";
				}
				break;
			case 0:
				//放入回收站
				if($DataBase->up('message', "`check` = '2'", "WHERE `id` in (".$DelMsgArr.")")){
					echo "1";
				}
				else{
					echo "0";
				}
				break;
		}	
		//关闭数据库连接
		$DataBase->close_dblink();				
	}
}
	
?>