<?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_fgid=SafeRequest("fgid", "get");
	if(!IsNumID($CcTvAi_com_userid)) {exit();}
	if(!IsNumID($cd_fgid)) {exit();}
	$db->query("delete from " . tname('friendgroup') . " where cd_uid='" . $CcTvAi_com_userid . "' and cd_id='" . $cd_fgid . "'");
	$db->query("update " . tname('friend') . " set cd_group='0' where cd_group='" . $cd_fgid . "'");
	$db->query("update " . tname('user') . " set cd_groupnum=cd_groupnum-1 where cd_groupnum>=1 and cd_id='$CcTvAi_com_userid'");
	exit($_GET['callback'] . '({"error":20000})');
} else {
	exit($_GET['callback'] . '({"error":20001})');
}
?>