<?php
require_once('tgydapicommon.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='/admin';</script>");}
	if($ntime>=4 and $ntime<11){exit("<script language='javascript'>alert('{$row[user]}，早上好！');window.location.href='/admin';</script>");}
	if($ntime>=11 and $ntime<14){exit("<script language='javascript'>alert('{$row[user]}，中午好！');window.location.href='/admin';</script>");}
	if($ntime>=14 and $ntime<18){exit("<script language='javascript'>alert('{$row[user]}，下午好！');window.location.href='/admin';</script>");}
	if($ntime>=18 and $ntime<24){exit("<script language='javascript'>alert('{$row[user]}，晚上好！');window.location.href='/admin';</script>");}
		}else{
			$msg="Email/用户名/手机号与密码不匹配";
		}
	}
}










//************************执行代码结束**************************

C('webtitle','会员登录');
C('pageid','login');
?>
<html>
<head>
<title>管理员登录-<?=C('webname')?></title>
<meta name="Keywords" content="<?=C('webname')?>,秒赞平台,秒赞网,秒赞,离线秒赞,免费24h秒赞,秒赞吧,爱空间app"/>
<meta name="Description" content="<?=C('webname')?>帐号登陆，24小时不间断离线秒赞空间说说！"/>
<!-- Custom Theme files -->
<link href="/public/css/style.css" rel="stylesheet" type="text/css" media="all"/>
<!-- Custom Theme files -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<!--Google Fonts-->
<link href='http://fonts.useso.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<!--Google Fonts-->

</head>
<body>
<div class="login">
	<div class="login-top">
		<h2>欢迎</h2>
		<?php if($msg){?><h3><?=$msg?></h3><?php }?>
    </div>
	<div class="login-bottom">
	   <form action="?" method="post" >
	   <div class="user">
					<input type="hidden" name="do" value="login"/>
					<input type="hidden" name="type" value="1"/>
					<input type="text" name="user" id="inputEmail" placeholder="用户名/手机号/邮箱" required autofocus>
                </div>
		<div class="user-in">
			<input type="password" name="pwd" id="inputPassword" placeholder="输入密码" required>
			<i></i>
		</div>
	  
	  <div class="keepme">
	  	<div class="keep-loginbutton">
	  	  <form>
	  		<input type="submit" value="登录" />
	  	 </form>
	  	</div>
	  	<div class="clear"> </div>
	  </div>
	  </form>
	</div>
	
</div>
<div class="copyright">
	<p>Template by <a href="/" target="_blank"> Justin秒赞 </a></p>
</div>
</body>
</html>