<?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_password=SafeRequest("password", "post");
	$cd_question=unescape(SafeRequest("question", "post"));
	$cd_answer=unescape(SafeRequest("answer", "post"));
	if ($cd_question==$cd_answer) {exit('1014');}
	$sql="select cd_id from " . tname('user') . " where cd_name='" . $CcTvAi_com_username . "' and cd_password='" . substr(md5($cd_password), 8, 16) . "'";
	$cd_id=$db->getone($sql);
	if ($cd_id) {
		$db->query("update " . tname('user') . " set cd_question='" . $cd_question . "',cd_answer='" . substr(md5($cd_answer), 8, 16) . "' where cd_id='" . $CcTvAi_com_userid . "'");
	} else {
		exit('1015');
	}
} else {
	exit('1001');
}
?>