<?php
require_once('azcommon.php');
//************************执行代码开始*************************
if($_POST['do']=='login'){
	$user=safestr($_POST['user']);
	$pwd=safestr($_POST['pwd']);
	$ip=getip();
	if(!$user || !$pwd){
		$msg="账号密码不能为空";
	}elseif(strlen($user) < 5){
		$msg="用户名太短";
	}elseif(strlen($pwd) < 5){
		$msg="密码太简单";//exit("<script language='javascript'>alert('密码太简单！');history.go(-1);</script>");
	}else{
		$pwd=md5(md5($pwd).md5('815856515'));
		if(is_numeric($user)){
			$where="(user='$user' or phone='$user') and pwd='$pwd'";
		}else{
			$where="(user='$user' or mail='$user') and pwd='$pwd'";
		}
		if($row=$db->get_row("select uid,user from ".C('DB_PREFIX')."users where {$where} limit 1")){
			$sid=md5(uniqid().rand(1,1000));
			$now=date("Y-m-d H:i:s");
			$ip=getip();
			$db->query("update ".C('DB_PREFIX')."users set sid='$sid',lasttime='$now',lastip='$ip' where uid='{$row[uid]}'");
			setcookie("klsf_sid",$sid,time()+3600*24*14,'/');
			$ntime=date("G"); //取得现在的时间
	if($ntime>=0 and $ntime<4){exit("<script language='javascript'>alert('{$row[user]}，午夜好！');window.location.href='/home';</script>");}
	if($ntime>=4 and $ntime<11){exit("<script language='javascript'>alert('{$row[user]}，早上好！');window.location.href='/home';</script>");}
	if($ntime>=11 and $ntime<14){exit("<script language='javascript'>alert('{$row[user]}，中午好！');window.location.href='/home';</script>");}
	if($ntime>=14 and $ntime<18){exit("<script language='javascript'>alert('{$row[user]}，下午好！');window.location.href='/home';</script>");}
	if($ntime>=18 and $ntime<24){exit("<script language='javascript'>alert('{$row[user]}，晚上好！');window.location.href='/home';</script>");}
		}else{
			echo"<script language='javascript'>alert('账号或密码错误！');window.location.href='/login.php';</script>";
		}
	}
}
//************************执行代码结束**************************
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link href="/indexs/css/pace-theme-flash.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="/indexs/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="/indexs/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css"/>
<link href="/indexs/css/font-awesome.css" rel="stylesheet" type="text/css"/>
<link href="/indexs/css/animate.min.css" rel="stylesheet" type="text/css"/>
<link rel="shortcut icon" type="image/x-icon" href="http://www.2nlby.cn/favicon.ico"/>
<!-- END CORE CSS FRAMEWORK -->
<!-- BEGIN CSS TEMPLATE -->
<link href="/indexs/css/style.css" rel="stylesheet" type="text/css"/>
<link href="/indexs/css/responsive.css" rel="stylesheet" type="text/css"/>
<link href="/indexs/css/magic_space.css" rel="stylesheet" type="text/css"/>
<link href="/indexs/css/custom-icon-set.css" rel="stylesheet" type="text/css"/>
<body class="error-body no-top lazy" style="background: url(/img/hero3.jpg);background-size: cover;"> 
<title>系统登陆 - <?=C('webname')?></title>
<body class="error-body no-top">

<div class="container">
  <div class="row login-container column-seperation">  
        <div class="col-md-5 col-md-offset-1">
          <h2><?=C('webname')?></h2>
          <p>目前,已经实现了更快捷的方式.<br>
           
          <br><br><br><br>
		   
		   <a href="/reg.php" class="btn btn-block btn-success col-md-8" type="button">
            <span class="pull-left"><i class="fa fa-key"></i></span>
            <span class="bold">用户注册</span> </a>
        </div>
        <div class="col-md-5 "> <br>
		 <form class="login-form" action="?" method="post">
		 <input type="hidden" name="do" value="login"/>
		<input type="hidden" name="type" value="1"/>
<div class="alert alert-info"><div class="alert-content">信息：登陆后才能继续享受服务哦!<br>如果忘记密码请在QQ上联系站长！</div></div>		 <div class="row">
		 <div class="form-group col-md-10">
            <label class="form-label">用户名Username</label>
            <div class="controls">
				<div class="input-with-icon  right">
					<i class=""></i>
					<input type="text" name="user" id="txtusername" class="form-control" placeholder="用户名/邮箱/手机号/QQ均可登录" required autofocus>
				</div>
            </div>
          </div>
          </div>
		  <div class="row">
          <div class="form-group col-md-10">
            <label class="form-label">密码Password</label>
            <span class="help"></span>
            <div class="controls">
				<div class="input-with-icon  right">
					<i class=""></i>
					<input type="password" name="pwd" id="txtpassword" class="form-control" placeholder="输入密码" required>
				</div>
            </div>
          </div>
          </div>
          <div class="row">
            <div class="col-md-10">
              <button class="btn btn-primary btn-cons pull-right" type="submit">登录Login</button>
            </div>
          </div>
		  </form>
        </div>
     
    
  </div>
</div>

<script src="/indexs/js/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="/indexs/js/bootstrap.min.js" type="text/javascript"></script>
<script src="/indexs/js/pace.min.js" type="text/javascript"></script>
<script src="/indexs/js/jquery.validate.min.js" type="text/javascript"></script>
<script src="/indexs/js/login.js" type="text/javascript"></script>

</body>
</html>