<?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_id=SafeRequest("bid", "post");
	$cd_uid=SafeRequest("uid", "post");
	if(!IsNumID($CcTvAi_com_userid)) {exit();}
	if(!IsNumID($cd_id)) {exit();}
	if(!IsNumID($cd_uid)) {exit();}
	$sql="select cd_id,cd_uid from " . tname('blog') . " where cd_id='" . $cd_id . "'";
	if ($row=$db->getrow($sql)) {
		if ($row['cd_uid']==$CcTvAi_com_userid) {
			//主要数据
			$db->query("delete from " . tname('blog') . " where cd_uid='" . $cd_uid . "' and cd_id='" . $row['cd_id'] . "'");
			$db->query("delete from " . tname('comment') . " where cd_channel=9 and cd_dataid='" . $row['cd_id'] . "'");
			$db->query("delete from " . tname('feed') . " where cd_icon='miniblog' and cd_dataid='" . $row['cd_id'] . "'");
			if (cd_userdeletesaidpoints>=1) { //大于1才记录
				//记录账单
				$setarr=array(
					'cd_type' => 0, //1为加,0为减
					'cd_uid' => $row['cd_uid'],
					'cd_uname' => $row['cd_uname'],
					'cd_icon' => 'miniblog',
					'cd_title' => '说说被删除',
					'cd_points' => cd_userdeletesaidpoints,
					'cd_addtime' => date('Y-m-d H:i:s')
				);
				inserttable('bill', $setarr, 1);
			}
			$db->query("update " . tname('user') . " set cd_points=cd_points-'" . cd_userdeletesaidpoints . "',cd_rank=cd_rank-'" . cd_userdeletesaidrank . "' where cd_id='" . $row['cd_uid'] . "'");
			exit('004');
		}
	} else {
		exit('003');
	}
} else {
	exit('001');
}
?>