<?php
/**
 * 登录
**/
$is_defend=true;
include("../includes/common.php");
if(isset($_POST['user']) && isset($_POST['pass'])){
	$user=daddslashes($_POST['user']);
	$pass=daddslashes($_POST['pass']);
	$row=$DB->get_row("SELECT * FROM shua_site WHERE user='$user' limit 1");
	if($user==$row['user'] && $pass==$row['pwd']) {
		if($row['status']==0){
			@header('Content-Type: text/html; charset=UTF-8');
			exit("<script language='javascript'>alert('当前分站已关闭！');history.go(-1);</script>");
		}
		elseif($row['endtime']<$date){
			@header('Content-Type: text/html; charset=UTF-8');
			exit("<script language='javascript'>alert('你的账号已到期，请联系管理员续费！');history.go(-1);</script>");
		}
		$session=md5($user.$pass.$password_hash);
		$token=authcode("{$user}\t{$session}", 'ENCODE', SYS_KEY);
		setcookie("user_token", $token, time() + 604800, '/');
		log_result('分站登录', 'User:'.$user.' IP:'.$clientip, null, 1);
		@header('Content-Type: text/html; charset=UTF-8');
		exit("<script language='javascript'>alert('登陆用户中心成功！');window.location.href='./';</script>");
	}else {
		@header('Content-Type: text/html; charset=UTF-8');
		exit("<script language='javascript'>alert('用户名或密码不正确！');history.go(-1);</script>");
	}
}elseif(isset($_GET['logout'])){
	setcookie("user_token", "", time() - 604800, '/');
	@header('Content-Type: text/html; charset=UTF-8');
	exit("<script language='javascript'>alert('您已成功注销本次登陆！');window.location.href='./login.php';</script>");
}elseif($islogin2==1){
	@header('Content-Type: text/html; charset=UTF-8');
	exit("<script language='javascript'>alert('您已登陆！');window.location.href='./';</script>");
}
$title='用户登录';
include './head.php';
?>
<!DOCTYPE html>
<!--[if IE 9]>         <html class="no-js lt-ie10" lang="en"> <![endif]-->
<!--[if gt IE 9]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <title>自助下单管理系统</title>
        <meta name="author" content="王小大">
        <meta name="robots" content="noindex, nofollow">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <link rel="shortcut icon" href="favicon.png">
        <link rel="stylesheet" href="assets/goubi/css/bootstrap.min.css">
        <link rel="stylesheet" href="assets/goubi/css/plugins.css">
        <link rel="stylesheet" href="assets/goubi/css/main.css">
        <link rel="stylesheet" href="assets/goubi/css/themes.css">
        <script src="assets/goubi/js/modernizr-3.3.1.min.js"></script>
    </head>
    <body>
 
        <img src="http://img-cdnw.b0.upaiyun.com/cdn/zip-img/2.jpg!gzipimgw" alt="Full Background" class="full-bg full-bg-bottom animation-pulseSlow">
        <div id="login-container">
		<div class="widget-content themed-background-flat2 text-center push-top-bottom animation-slideDown">
            <p class="text-center push-top-bottom animation-slideDown">
                <img src="//q4.qlogo.cn/headimg_dl?dst_uin=<?php echo $conf['qq']?$conf['qq']:$conf['kfqq']?>&spec=100" width="100" class="img-circle img-thumbnail img-thumbnail-avatar-1x">
            </p>
            <h4 class="text-center text-light push-top-bottom animation-fadeInQuick">
                <strong>自助下单系统管理中心</strong><br>
            </h4>
            <form action="./login.php" method="post" class="form-horizontal push animation-fadeInQuick" role="form">
                <div class="form-group">
                    <div class="col-xs-10 col-xs-offset-1 col-sm-8 col-sm-offset-2">
						<div class="input-group  input-group-lg">
						<div class="input-group-btn">
                                <a class="btn btn-effect-ripple btn-block btn-primary"><i class="fa fa-user"></i></a>
                            </div>
								<input type="text" name="user" value="" class="form-control form-control-borderless" placeholder="用户名" required="required">
						</div><br>
                        <div class="input-group input-group-lg">
                            <input type="password" name="pass" class="form-control" placeholder="密码" required="required">
                            <div class="input-group-btn">
                                <button type="submit" class="btn btn-effect-ripple btn-block btn-primary"><i class="fa fa-arrow-right"></i></button>
                            </div>                     
                        </div>
                    </div>
                </div>
            </form>
            <p class="text-center animation-fadeInQuick">
                <a href="reg.php" class="label label-danger"><small>开通分站</small></a> - <a href="findpwd.php" class="label label-info"><small>找回密码</small></a> - <a href="../" class="label label-primary"><small>返回首页</small></a>
            </p>
        </div>
</div>
  <script src="assets/goubi/js/jquery-2.2.4.min.js"></script>
        <script src="assets/goubi/js/bootstrap.min.js"></script>
        <script src="assets/goubi/js/plugins.js"></script>
        <script src="assets/goubi/js/app.js"></script>
    </body>
</html>