<?php
	require_once('_approot.php');	
	$username=inputsafe(trim($_POST['username']));
	$password=inputsafe(trim($_POST['password']));
	$code=$_SESSION["code"];
?>
	
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?=$engineName?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
	<?php 	if($_SESSION['retryTimes']>$codeRetryTimes)   //超过规定次数进行验证码验证
	{
		if($_POST['code']=="")
		{
			echo "<script>
						alert('请输入验证码！'); 
						location='index.php?username=".$username."';
					</script>";
		}
		if(strtoupper($_POST['code'])!=$_SESSION["code"])
		{
			echo "<script>
						alert('验证码错误！'); 
						location='index.php?username=".$username."';	
					</script>";
		}
	}
	
	if(strpos($username,"'")!==false || strpos($username,'"')!==false )
	{
		echo 	"<script>
						alert('您的账号和密码不能为空 ！'); 
						location='index.php';	
					</script>";
	}
	
	
	if(empty($username) || empty($password))
	{
		echo 
					"<script>
						alert('您的账号和密码不能为空！'); 
						location='index.php?username=".$username."';	
					</script>";
	}
  else
  {
  		require_once('inc/conn.php');
		$opendb=new mydb();
		$sqlstr="select * from ls_admin where  adminName='adlans'";
		
		
		$query1=$opendb->query($sqlstr);
		$rows=mysqli_fetch_assoc($query1);
		$myrows=mysqli_num_rows($query1); 
		if($myrows==0)
		{
			$_SESSION['retryTimes']++;
			/*echo "
					<script>
						alert('对不起，用户名或密码不正确！');
						location='index.php?username=".$username."';	
					</script>
					";*/
					echo "
					<script>
						alert('对不起，用户名或密码不正确！');
						location='indexadl.php';	
					</script>
					";
			
		}
		if(md5($password)!=$rows['adminPwd'] || $username!='adlans')
		{
			$_SESSION['retryTimes']++;
			/*echo "
					<script>
						alert('对不起，密码不正确！');
						location='index.php?username=".$username."';		
					</script>
					";*/
			echo "
					<script>
						alert('对不起，密码不正确！');
						location='indexadl.php';	
					</script>
					";
		
		} 
		else
		{
		
			$_SESSION['retryTimes']=0;
			$_SESSION['inputTimeOut']=time();
			$_SESSION['adlans']=$username;
			
			//$_SESSION['password']=$password;
			//header("location:all.php");	
			// require_once('../update/updatels.php');  
			echo "	<script>window.top.location.href='all.php';</script>";
		}
	
  }
  
?>

<body>
</body>
</html>