<?php
ob_start();
session_start();
date_default_timezone_set('PRC');
if($_SERVER['HTTP_APPVERSION']){
include "./saesiteinfo.php";
}else{
 if(!file_exists("./install/install.lock")){
header('location:./install');
exit;
 }else{
include "./siteinfo.php";
 }
}
include "./function.php";
//连接数据库
$localhost=mysql_connect($sqlhost,$sqluser,$sqlpass)or die("无法连接服务器");
mysql_select_db($sqldata,$localhost);
?>
<html>
<head>
<meta content="width=device-width,user-scalable=no" name="viewport">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="3;url=index.php">
<title>注册小提示 - <?php echo $sitename; ?></title>
<script src="js/jquery-1.8.0.min.js" type="text/javascript" ></script>
<link rel="stylesheet" type="text/css" href="css/register.css"/>
</head>
<body>
<div class='signup_container'>

    <h1 class='signup_title'><?php echo $sitename; ?>小提示!</h1>
<p><font size="4">
<?php
$user=$_POST['user'];
$pass=$_POST['pass'];
$passpass=$_POST['passpass'];
$email=$_POST['email'];
$yzm=$_POST['yzm'];
$date=date("Y-m-d H:i:s");
$regip =ip();

$mysql = mysql_query("SELECT * FROM user WHERE user='$user'");
$sql=mysql_fetch_array($mysql);
//判断是否为空
	if($user==""){
	echo'用户账户不能为空';
	}elseif($pass==""){
	echo'用户密码不能为空';
	}elseif($passpass==""){
	echo'确认密码不能为空';
	}elseif($email==""){
	echo'联系邮箱不能为空';
    }elseif($yzm==""){
    echo"验证码不能为空格";
}else{
//判断是否为正确
        if(!@ereg('^[0-9a-zA-Z\_]*$',$user)){
			echo'用户账户必须为数字或者英文字符。';
		}elseif(!@ereg('^[0-9a-zA-Z\_]*$',$pass)){
			echo'密码必须为数字或者英文字符。';
		}elseif(strlen($user)<3||strlen($user)>15){
			echo'账号长度必须在3到15位之间。';
		}elseif(strlen($pass)<1||strlen($pass)>15){
			echo'密码长度必须在1到15位之间。';
		}elseif($pass!=$passpass){
			echo'密码不一致。';
		}elseif(!@ereg("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*$",$email)){
		echo'请输入正确邮箱';
		}elseif($yzm!=$_SESSION['yzm']){
			echo"验证码输入错误";
		}elseif($user==$sql['user']){
			echo'该账号已注册。';
		}else{
	//判断全部正确开始增加用户
	        mysql_query("INSERT INTO user (user,pass,email,regdate,regip) VALUES ('$user','$pass','$email','$date','$regip')");
			header("refresh:3;url=./index.php");
			echo'注册成功';
			setcookie("SHANIUUSER","$user",time()+1800);
			setcookie("SHANIUPASS","$pass",time()+1800);
		}
}
unset($_SESSION['yzm']);
?>
<br />3秒后跳转页面</font></p></div>
</body>
</html>