<?php
	if (!Tourists()){
		prompt ('<p>您还没有登录，不能进行此操作！</p><meta http-equiv="refresh" content="3;url=index.php?act=login">');
		exit;
	}else{
		if (!empty ($_GET['lx']) and !empty ($_GET['qq']) and !empty ($_GET['qid'])){
			$qq = $_GET['qq'];
			$qid = $_GET['qid'];
			$qqinfo = mysql_fetch_array(mysql_query("SELECT * FROM `qqlist` WHERE `qid`='$qid' and `qq`='$qq'"));
			$fwq = $qqinfo['fwq'];
			if ($fwq != Null){
				mysql_query ("DELETE FROM `$fwq` WHERE `qid`='$qid' and `qq`='$qq'");
				mysql_query ("DELETE FROM `qqlist` WHERE `qid`='$qid' and `qq`='$qq'");
				$sql = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `user`='".AnYue_User."'"));
				$qqnum = $sql['qqnum'] - 1;
				mysql_query("UPDATE `user` SET `qqnum`='$qqnum' WHERE `user`='".AnYue_User."'");
				$info = "<p>QQ: $qq --- 删除成功</p>";
			}else{
				$info = "<p>QQ: $qq --- <font color='red'>删除失败</font></p>";
			}
		}else{
			$qid = $_POST['qid'];
			$qqs = count($qid);
			if ($qqs > 0){
				for ($i=0;$i<$qqs;$i++){
					$qqlist=mysql_fetch_array(mysql_query("SELECT * FROM `qqlist` WHERE `qid`='{$qid[$i]}' and `myqq`='".AnYue_User."'"));
					if ($qqlist['qid'] == $qid[$i]){
						$qqinfo = mysql_fetch_array(mysql_query("SELECT * FROM `qqlist` WHERE `qid`='{$qid[$i]}' and `myqq`='".AnYue_User."'"));
						$qq = $qqinfo['qq'];
						mysql_query("DELETE FROM `{$qqinfo[fwq]}` WHERE `qid`='{$qid[$i]}'");
						mysql_query("DELETE FROM `qqlist` WHERE `qid`='{$qid[$i]}'");
						$sl++;
						$info .= "<p>QQ: $qq ---- 删除成功</p>";
					}else{
						$info .= "<p>QQ: $qq ---- <font color='red'>删除失败</font></p>";
					}
				}
				$sql = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `user`='".AnYue_User."'"));
				$qqnum = $sql['qqnum'] - $sl;
				mysql_query("UPDATE `user` SET `qqnum`='$qqnum' WHERE `user`='".AnYue_User."'");
			}else{
				$info = '<p>请选择欲删除的QQ号码！</p>';
			}
		}
	}

	$AnYue_Smarty -> assign ('info',$info);
	$AnYue_Smarty -> display ('delete.html');

