<?php
error_reporting(0);
if (!eregi($_SERVER['SERVER_NAME'], $_SERVER['HTTP_REFERER'])) {exit();}
close_browse();
global $db, $CcTvAi_com_userid;
if ($CcTvAi_com_userid) {
	if (!IsNumID($CcTvAi_com_userid)) {exit();}
	$cd_nickname=unescape(SafeRequest("nickname", "post"));
	$sql="select * from " . tname(user) . " where cd_id<>'" . $CcTvAi_com_userid . "' and cd_nicheng='" . $cd_nickname . "'";
	$result=$db->query($sql);
	if ($row=$db->fetch_array($result)) {exit('10002');} else {
		$db->query("update " . tname('user') . " set cd_nicheng='" . $cd_nickname . "' where cd_id='" . $CcTvAi_com_userid . "'");
		$setarrs=array(
			'cd_uid' => $CcTvAi_com_userid,
			'cd_uname' => $CcTvAi_com_username,
			'cd_icon' => 'setting',
			'cd_title' => '修改了昵称',
			'cd_data' => '将昵称从【' . $CcTvAi_com_nicheng . '】 修改为 【' . $cd_nickname . '】。',
			'cd_image' => '',
			'cd_imagelink' => '',
			'cd_dataid' => $row['cd_id'],
			'cd_addtime' => date('Y-m-d H:i:s')
		);
		inserttable('feed', $setarrs, 1);
		exit('10000');
	}
} else {
	exit('20001');
}
?>