<!--#include file="../inc/cms_class.asp" -->
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><%=zset.siteTitle%>-后台登陆</title>
<script src="<%=sitepath%>js/jquery.min.js"></script>
<script src="<%=sitepath%>plugins/layer/layer.min.js"></script>
<%
if sitepath&adminPath <> getSitePath(getSiteURL()) then die "后台文件夹修改后，请修改""config/cms_config.asp""第13行</br> Const adminPath="""&getSitePath(getSiteURL())&""""

dim act : act=getForm("act","get")
select case act 
	case "login"		:	adminlogin()
	case "loginout"	:	loginout()
	case "loginesc" :	loginesc()
end select

sub adminlogin()
	dim UserName,Password,sql,code,Rs,atype,question,answer,rsObj
	UserName = filterPara(getForm("username","post"))	: if isnul(UserName) then alertgo "请输入管理账户","login.asp"
	atype = getForm("atype","post")
	Password = md5(getForm("Password","post"),16)
	question=getForm("question","post")
	answer=getForm("answer","post")
	code     = getForm("code","post")
	if isCode=1 then
		if isnul(getcookie("adminname")) then		
			if code <> getsession("imgcode") then back "验证码错误"
		end if
	end if
	if isOutSubmit then  back "非法外部提交被禁"
	
	if not(isnul(question) and isnul(answer)) then
		if dbcount("[dbpre]User","username = '"& UserName &"' and question = '"& question &"' and answer='"&answer&"'")=0 then back "问题和答案错误!"
	else
		if dbcount("[dbpre]User","username = '"& UserName &"' and Password='"&Password&"'")=0 then back "用户名或密码错误!"
	end if
	Set rsObj=dbsqlr1("select IsAdmin,G_OnOff,G_Name, U_OnOff, UID, G_Menu,G_Sort, U_LID,face,G_Mark from [dbpre]User as a, [dbpre]User_Group as b where UserName='"&UserName&"' and U_GID=GID")	
	if not rsObj.Eof Then
		if rsObj("IsAdmin")<>1 then back"对不起，你不是管理员"
		if rsObj("G_onoff")<>1 then back"对不起，您所在用户组已被禁用"
		if rsObj("U_onoff")<>1 then back"对不起，您的账号已被禁用"
		setcookie "adminname",UserName
		setSession "admingroup",rsObj("G_Name")
		setSession "adminpwd",getForm("Password","post")
		setSession "adminid",rsObj("UID")
		setSession "adminmenu",repnul(rsObj("G_Menu"))
		setSession "adminSort",repnul(rsObj("G_Sort"))
		setcookie "adminface",rsObj("face")
		setSession "adminmark",rsObj("G_Mark")
		
		'查找
		dim LID
		LID=rsObj("U_LID")

		if isnul(LID) then 				
			set rs=conn.exec("select LID,L_Path,L_Alias from [dbpre]Language where IsDefault=1","exe")
			if rs.eof then					
				echoErr err_15,15,"没有设置默认语言"
			else
				LID=rs(0)
			end if
		else 	
			set rs=conn.exec("select LID,L_Path,L_Alias from [dbpre]Language where LID="&LID,"exe")				
			LID=rs(0)	
		end if 
		
		dim randnum,dbbacktime,dbbackname	
		randomize
		randnum=clng(rnd*99999999)
		Conn.Exec"update [dbpre]User set adminrand='"& randnum &"' where UID="&rsObj("UID"),"exe"
		setSession "adminrand",randnum
		setSession "lid",LID			
		setSession "lpath",repnul(rs("L_Path"))
		setSession "lalias",rs("L_Alias")
		rs.close : set rs=nothing
		dim LastLoginTime	:	LastLoginTime=now()
		Conn.Exec"update [dbpre]User set LastLoginTime='"&LastLoginTime&"',LastLoginIP='"&getIp()&"',LoginCount=LoginCount+1 where UID="&rsObj("UID"),"exe"		
		if dbType=0 and dbaotoback>0 then				
			dbbacktime=dbsqlone("select addtime from [dbpre]log_dbbackup order by id desc")
			if dbbacktime="0" or datediff("d",dbbacktime,sqltime)>isnum(dbaotoback) then
			if not isfolder(sitePath&dbPath&"backup/") then NewFolder(sitePath&dbPath&"backup/")
			dbbackname=sitePath&dbPath&"backup/"&getrndname()&"_bak.asp"
			copyfile sitePath&dbPath&dbfile,dbbackname
			dbsql("insert into [dbpre]log_dbbackup (dbname,addtime,username,ip)values ('"&dbbackname&"','"&LastLoginTime&"','"&UserName&"','"&getip()&"')")
			end if			  
		end if	
		dbsql "delete from [dbpre]log_dbsql where logid not in (select top 1000 logid from [dbpre]log_dbsql order by logid desc)"	
		dbsql "delete from [dbpre]log_err	where logid not in (select top 1000 logid from [dbpre]log_err	order by logid desc)"	
		jsgo("index.asp")
	else
		back "账号不存在或管理员分组不匹配"
	end if
	rsObj.Close() : set rsObj=Nothing	
end sub

%>
<script type="text/javascript" src="<%=sitepath%>plugins/changebg/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="<%=sitepath%>plugins/changebg/main.css" />
<link rel="stylesheet" type="text/css" href="<%=sitepath%>plugins/changebg/bgstretcher.css" />
<script type="text/javascript" src="<%=sitepath%>plugins/changebg/bgstretcher.js"></script>
<link href="<%=sitepath%>css/bootstrap.min.css" rel="stylesheet">
<link href="<%=sitepath%>css/font-awesome.min.css" rel="stylesheet">
<link href="<%=sitepath%>css/animate.min.css" rel="stylesheet">
<link href="<%=sitepath%>css/style.min.css" rel="stylesheet">
<style>
.passico { position: absolute; top: 0px;  display: block; width: 34px; height: 34px; color:#ccc;padding: 10px; }
.eye{  right:35px; }
.forget{ right:15px; }
</style>
<script type="text/javascript">
	$(document).ready(function(){	
        //  Initialize Backgound Stretcher	   
		$('BODY').bgStretcher({
			images: ['<%=sitepath&adminpath%>images/bg/01.jpg'],
			imageWidth: 1024, 
			imageHeight: 768, 
			slideDirection: 'N',
			slideShowSpeed: 3000,
			transitionEffect: 'fade',
			sequenceMode: 'normal',
			buttonPrev: '#prev',
			buttonNext: '#next',
			pagination: '#nav',
			anchoring: 'left center',
			anchoringImg: 'left center'
		});		
	});
</script>
<!--[if lte IE 9]>
<script src="<%=sitepath%>js/respond.min.js"></script>
<script src="<%=sitepath%>js/html5.js"></script>
<![endif]-->
</head>
<%
sub loginesc()
	if isnul(getsession("adminid")) then jsgo "login.asp"
	setSession "adminrand",null
	setSession "adminid",null
	setSession "adminSort",null
	setSession "adminmenu",null
	setSession "admingroup",null
	setSession "lid",null
	setSession "lpath",null
	setSession "lalias",null
	setSession "adminmark",null
end sub
sub loginout()
	setcookie "adminname",null
	setSession "adminrand",null
	setcookie "adminface",null
	setSession "adminid",null
	setSession "adminSort",null
	setSession "adminmenu",null
	setSession "admingroup",null
	setSession "lid",null
	setSession "lpath",null
	setSession "lalias",null
	setSession "adminmark",null
	jsgo "login.asp"
end sub
%>
<body>
<div class="middle-box loginscreen  animated fadeInDown">
  <div>
    <%if isnul(getsession("adminid"))  and isnul(getcookie("adminname")) then%>
    <h1 class="logo-name"><img src="images/loginlogo.png"></h1>
  </div>
  <form class="form-horizontal m-t" method="post" action="?act=login">
    <div class="form-group">
      <div class="col-sm-12">
        <input type="text" name="username" class="form-control" placeholder="用户名" required tabindex="1">
      </div>
    </div>
    <div class="form-group password">
      <div class="col-sm-12">
        <input type="text" name="password"  id="password" autocomplete="off" class="form-control" placeholder="密码" tabindex="2">
</div>
    </div>
    <div class="form-group question" style="display:none">
      <div class="col-sm-12">
        <input type="text" name="question" class="form-control" placeholder="密码问题" >
       </div>
    </div>
    <div class="form-group answer" style="display:none">
      <div class="col-sm-12">
        <input type="text" name="answer" class="form-control" autocomplete="off" placeholder="密码答案" >
        </div>
    </div>
    <%if isCode=1 then%>
    <div class="form-group">
      <div class="col-sm-6">
        <input type="text" name="code" id="imgcode" class="form-control" placeholder="验证码" required tabindex="3">
      </div>
      <div class="col-sm-6 imgcode" style="display:none"> <img src="../inc/imgcode.asp" id="SeedImg" align="absmiddle" style="cursor:pointer;" border="0" onClick="this.src+='?'+Math.random();" /> </div>
    </div>
    <%end if%>
    <input  name="submit" type="submit" class="btn btn-primary block full-width m-b" value="登陆">
  </form>
  <%elseif  isnul(getsession("adminid"))  and not isnul(getcookie("adminname")) then%>
  <h3>请输入密码直接登陆</h3>
</div>
<div class="m-b-md"> <img alt="image" class="img-circle circle-border" src="<%=sitepath%>images/face/<%=getcookie("adminface")%>"> </div>
<h3><%=getcookie("adminname")%>，<a class="qhzh" href="?act=loginout">切换账号</a></h3>
<p>欢迎您回来，请输入管理密码</p>
<form  class="form-horizontal m-t" method="post" action="login.asp?act=login">
  <div class="form-group">
    <div class="col-sm-12">
      <input type="hidden" name="username" value="<%=getcookie("adminname")%>">
      <input type="password" class="form-control" name="password" placeholder="密码" required>     
    </div>
  </div>
  <button type="submit" class="btn btn-primary block full-width">登录</button>
</form>
<%else
aspgo "index.asp"
%>
<%end if%>
</div>
</div>
<div class="signup-footer">Copyright <%=year(now())%> KCMS © Design:<a href="http://www.kelvinvt.com" title="启点在线-官方网站" target="_blank"><strong style="color:#00c0ff;">Kelvinvt</strong></a> All Rights Reserved.</div>
<script type="text/javascript" language="javascript">
var demoInput = document.getElementById("password");
function hideShowPsw(){
  if (demoInput.type == "password") {
	  demoInput.type = "text";
	  $(".eye i").toggleClass("fa-eye-slash")	
  }else {
	  demoInput.type = "password";	
	   $(".eye i").toggleClass("fa-eye-slash")		
  }
}
$("input").focus(function(){
	 demoInput.type = "password";
});
$(".forget").click(function(){
	$(".password").hide();
	$(".question").show();
	$(".answer").show();
})
$(document).ready(function(){
var windowHeight = document.documentElement.clientHeight;   
$(".loginscreen").animate({marginTop:(windowHeight-419)/3});
}); 
$("#username").focus();
$("#imgcode").focus(function (){
	$(".imgcode").show()
});
$(document).keyup(function(event){
  if(event.keyCode ==13){
	  if ($("#imgcode").val()=="")
	  {layer.msg("验证码不能为空");
	 $("#imgcode").focus()}
 	  else
	  { $("#submit").trigger("click");}
  } 
});
</script>
</div>
</body>
</html>
