<?php
error_reporting(0);
global $db, $CcTvAi_com_userid;
if (!eregi($_SERVER['SERVER_NAME'], $_SERVER['HTTP_REFERER'])) {exit();}
close_browse();
if ($CcTvAi_com_userid) {
	$cd_fromUid=SafeRequest("fromUid", "post");
	$cd_toUid=SafeRequest("toUid", "post");
	$cd_type=SafeRequest("type", "post");
	if(!IsNumID($CcTvAi_com_userid)) {exit();}
	if(!IsNumID($cd_fromUid)) {exit();}
	if(!IsNumID($cd_toUid)) {exit();}
	if(!IsNumID($cd_type)) {exit();}
	if ($cd_fromUid==0) {
		$row=$db->getrow("select cd_uids from " . tname('message') . " where cd_id='" . $cd_toUid . "'");
		if ($row['cd_uids']==$CcTvAi_com_userid) {
			$db->query("delete from " . tname('message') . " where cd_id='" . $cd_toUid . "'");
			exit('004');
		} else {
			exit('003');
		}
	} elseif ($cd_fromUid==1) {
		$sql="select * from " . tname('message') . " where cd_uids='" . $CcTvAi_com_userid . "'";
		if ($row=$db->getrow($sql)) {
			$db->query("delete from " . tname('message') . " where cd_uids='" . $CcTvAi_com_userid . "'");
			exit('004');
		} else {
			exit('003');
		}
	}
} else {
	exit('001');
}
?>