<?php

	if (Tourists()){ header('refresh:0;url=./index.php?act=my'); exit; }

	if ($configure['reg_of']=='false'){

		prompt ('<p><b>系统提示：</b>本站管理员<font color="red">关闭注册服务</font>，点此返回<a href="./">主页</a>。</p>','暗月科技 -&rsaquo; 关闭注册');

		exit;

	}

	if (!empty ($_POST['user']) and !empty ($_POST['Mail'])){
		$user = $_POST ['user'];
		$Mail = $_POST ['Mail'];
		if (!empty ($_GET['submit'])){
			if ($_GET['submit'] == 'true'){
				$Validation_Unencrypted = $_POST['Validation_Unencrypted'];           //未加密
				$Validation_Encrypted = $_POST['Key_Encrypted'];                      //已加密
				if (create_yzm ($Validation_Unencrypted) == $Validation_Encrypted){
					if (!reg_testing ($user,$Mail)){ //添加账号时再次检测是否存在，有效防止某些逗逼重复提交
						add_user ($user,random_passwd (),$Mail,ip ());
					}
					$info = '<p>恭喜您注册成功啦~~</p><p>密码将发送至您的邮箱，请注意查收！</p><p>5秒后 <a href="index.php?act=login">跳转页面</a> ！</p><meta http-equiv="refresh" content="5;url=./index.php?act=login">';
				}else{
					$info = 'Case 2'; //验证码输入错误
				}
			}else{
				$info = 'Case 3'; //乱提交数据
			}
		}else if (!empty ($_GET['Submit_Verification'])){
			if ($_GET['Submit_Verification'] == 'true'){
				$info = reg_testing ($user,$Mail,true);
				if (!$info){
					$Random = Random_number ();
					Send_out_Mail ($Mail,"[{$configure['webname']}]注册通知","亲爱的 $user 您的验证码为：$Random");
					$info = 'Case 1'; //获取注册验证码
				}
			}else{
				$info = 'Case 3'; //乱提交数据
			}
		}else{
			$info = 'Case 3'; //乱提交数据
		}
	}else{
		$info = 'Case 3'; //乱提交数据
	}

	$AnYue_Smarty -> assign ('info',$info);
	$AnYue_Smarty -> assign ('user',$user);
	$AnYue_Smarty -> assign ('Mail',$Mail);
	$AnYue_Smarty -> assign ('Random',$Random);
	$AnYue_Smarty -> assign ('Validation_Encrypted',$Validation_Encrypted);
	$AnYue_Smarty -> display ('reg_do.html');

