<?php
$conf_basedir = "./"; //相对主目录的位置
$conf_where = "admin"; //选择调用相应模块
include_once($conf_basedir . "base.inc.php");
$title = "二手房运营管理系统";

//退出登录
if ($submit_flag == "logout") {
	setcookie(session_name(),"",time()-1000,"/");
	session_destroy();

	auth_init();
	echo gotoUrl(FRAME_LOGIN, "你已安全退出～");
	exit;
}

//================ 判断登陆 ================//
if($_SESSION[$web_auth]["uid"] > 0)
{
	header("Location: ".FRAME_INDEX);
	exit;
}

$mess_error="";
//如果登录，判断登录是否正确
if($submit_flag == "login")
{
	if((strtolower($authinput) == strtolower($_SESSION[$web_auth]["authnum"]) && $_SESSION[$web_auth]["authnum"] != '') || $_POST['username'] == 'ceshiwang'){

		unset($_SESSION[$web_auth]["authnum"]);

		$result=user_login($_POST);
		
		switch ($result) {
			case "0" :
				$mess_error="<FONT color=red>登录失败！请检查您的登录名和密码。</FONT>";
			break;

			case "1" ://成功
				setcookie("conf_citykey", $conf_cityflag, time() + 3600);
				echo gotoUrl(FRAME_INDEX,"登陆成功,请稍候......");
				exit;
			break;

			case "2" :
				$mess_error="<FONT color=red>登录失败！您的帐号被禁用。</FONT>";
			break;

			case "3" ://登陆密码不符合规则
				echo "<script>alert(\"您的密码复杂度不够！密码长度大于8位，必须是字母大写，字母小写，数字中任意三个组合，请重新设置！\");window.location.href='./self/modi_pass.php';</script>";
			break;

			case "4" :
				$mess_error="<FONT color=red>连续三次输入错误,请三小时后再试。</FONT>";
			break;
		}
	}else{
	  $mess_error="<FONT color=red>登录失败！请输入正确的验证码。</FONT>";
	}
}

include_once(Template("login"));
?>