<?php
error_reporting(0);
close_browse();
if (!eregi($_SERVER['SERVER_NAME'], $_SERVER['HTTP_REFERER'])) {exit();}
global $db, $CcTvAi_com_userid;
if ($CcTvAi_com_userid) {
	$cd_uid=SafeRequest("uid", "get");
	if(!IsNumID($CcTvAi_com_userid)) {exit();}
	if(!IsNumID($cd_uid)) {exit();}
	$sql="select cd_id,cd_uids,cd_unames from " . tname('friend') . " where cd_uid='$CcTvAi_com_userid' and cd_uids='$cd_uid'";
	if ($row=$db->getrow($sql)) {
		$db->query("delete from " . tname('friend') . " where cd_id='" . $row['cd_id'] . "'");
		$db->query("update " . tname('friend') . " set cd_lock=0 where cd_uid='$cd_uid' and cd_uids='$CcTvAi_com_userid'");
		$db->query("update " . tname('user') . " set cd_ufans=cd_ufans-1 where cd_ufans>=1 and cd_id='$cd_uid'");
		$db->query("update " . tname('user') . " set cd_ufav=cd_ufav-1 where cd_ufav>=1 and cd_id='$CcTvAi_com_userid'");
		//提交通知
		$setarr=array(
			'cd_uid' => $CcTvAi_com_userid,
			'cd_uname' => $CcTvAi_com_username,
			'cd_uids' => $row['cd_uids'],
			'cd_unames' => $row['cd_unames'],
			'cd_icon' => 'fans',
			'cd_data' => '已取消对您的关注&nbsp;<a href="' . linkweburl($CcTvAi_com_userid, $CcTvAi_com_username) . '" target="_blank">立即查看</a>',
			'cd_dataid' => 0,
			'cd_state' => 1,
			'cd_addtime' => date('Y-m-d H:i:s')
		);
		inserttable('notice', $setarr, 1);
		exit($_GET['callback'] . '({"error":10000})');
	} else {
		exit($_GET['callback'] . '({"error":10004})');
	}
} else {
	exit($_GET['callback'] . '({"error":20001})');
}
?>