<?
	if (!isset($_REQUEST["vcode"]) || empty($_REQUEST["vcode"])):
		$last = mysql_fetch_array(mysql_query("SELECT MAX(id) FROM vcode"));
		mysql_query("DELETE FROM vcode WHERE uid=".$_COOKIE["UID"]);
		mysql_query ("INSERT INTO vcode (`id`,`code`,`uid`) VALUES ('','".md5(($last[0]+1).$_COOKIE["UID"])."','".$_COOKIE["UID"]."')");
	endif;
	
	$info = mysql_fetch_array(mysql_query("SELECT * FROM vcode WHERE uid=".$_COOKIE["UID"]));
	if (!is_array($info)):
		header ("location: /quit.php");
	else:
		if (md5($info["id"].$_COOKIE["UID"])==$info["code"] && $info["code"]==$_REQUEST["vcode"]):
			define (VALID,true);
		endif;
		$last = mysql_fetch_array(mysql_query("SELECT MAX(id) FROM vcode"));
		mysql_query("DELETE FROM vcode WHERE uid=".$_COOKIE["UID"]);
		mysql_query ("INSERT INTO vcode (`id`,`code`,`uid`) VALUES ('','".md5(($last[0]+1).$_COOKIE["UID"])."','".$_COOKIE["UID"]."')");
		$info = mysql_fetch_array(mysql_query("SELECT * FROM vcode WHERE uid=".$_COOKIE["UID"]));
		define (VCODE,$info["code"]);
	endif;

	unset($info);
?>