<?php
error_reporting(0);
close_browse();
if (!eregi($_SERVER['SERVER_NAME'], $_SERVER['HTTP_REFERER'])) {exit();}
global $db, $CcTvAi_com_userid;
$callback=SafeRequest("callback", "get");
if ($CcTvAi_com_userid) {
	$cd_friend_uid=SafeRequest("friend_uid", "post");
	$cd_uid=SafeRequest("uid", "post");
	if(!IsNumID($CcTvAi_com_userid)) {exit();}
	if(!IsNumID($cd_uid)) {exit();}
	if(!IsNumID($cd_friend)) {exit();}
	if ($CcTvAi_com_userid!=$cd_uid) {exit('20002');}
	$sql="select cd_id,cd_unames from " . tname('friend') . " where cd_uid='$CcTvAi_com_userid' and cd_uids='$cd_friend_uid'";
	if ($row=$db->getrow($sql)) {
		$db->query("delete from " . tname('friend') . " where cd_id='" . $row['cd_id'] . "'");
		$db->query("update " . tname('user') . " set cd_ufans=cd_ufans-1 where cd_ufans>=1 and cd_id='$cd_friend_uid'");
		$db->query("update " . tname('user') . " set cd_ufav=cd_ufav-1 where cd_ufav>=1 and cd_id='$CcTvAi_com_userid'");
	} else {
		exit('10000');
	}
} else {
	exit('20001');
}
?>