<!--#include file="base.asp"-->
<%
''' EYCMS 登录
''' ==================================================================
	
	'是否启用验证码
	const verify_code=True
	sub check()
		dim t0,t1,t2,t3
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.enhtml(eycms.fpost("t1",0))
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.loadsession("imgcode")
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#29992;&#25143;&#21517;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t1)=0 then eycms.ajaxjson "&#23494;&#30721;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if verify_code then
		if eycms.strlen(t2)=0 then eycms.ajaxjson "&#39564;&#35777;&#30721;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t3)=0 then eycms.ajaxjson "&#26080;&#27861;&#33719;&#21462;&#31995;&#32479;&#39564;&#35777;&#30721;",0:exit sub
		if t2<>t3 then eycms.ajaxjson "&#39564;&#35777;&#30721;&#19981;&#27491;&#30830;",0:exit sub
		end if
		if not(eycms.checkpost) then
			eycms.ajaxjson "&#31105;&#27490;&#22806;&#37096;&#25552;&#20132;&#25968;&#25454;",0:exit sub
		end if
		dim data
		data=eycms.db.dbload(1,"adminid,logintimes,islock,groupid,penname,adminname,adminpass","ey_admin","adminname='"&t0&"' and adminpass='"&md5(t1)&"'","")
		if ubound(data)<0 then
			eycms.ajaxjson "&#29992;&#25143;&#21517;&#25110;&#23494;&#30721;&#38169;&#35823;",0:exit sub
		else
			if data(2,0)=0 then
				eycms.ajaxjson "&#29992;&#25143;&#34987;&#38145;&#23450;&#65292;&#19981;&#33021;&#30331;&#24405;",0
			else
				dim datanew
				datanew=array(array("logintimes",data(1,0)+1,0,0),array("lastlogindate",sqltime,0,0),array("lastloginip",eycms.getip,17,1))
				eycms.db.dbupdate "ey_admin","adminid="&data(0,0)&"",datanew
				eycms.setsession "adminid",data(0,0)
				eycms.setsession "adminname",t0
				eycms.setcookie "adminname",t1
				eycms.setsession "admingroupid",data(3,0)
				eycms.setcookie "adminid",data(0,0)
				dim penname:penname=data(4,0)
				if eycms.strlen(penname)=0 Then penname="eycms"
				eycms.setcookie "penname",penname
				dim key:key=eycms.getkey()
				eycms.setcookie "adminid",data(0,0)
				eycms.setcookie "loginkey",key
				eycms.setcookie "loginpwd",md5(data(5,0)&data(6,0)&key)
				eycms.ajaxjson "&#30331;&#24405;&#25104;&#21151;",1
			end if
		end if
		data=""
	end sub
	
	sub sitechange()
		dim t0
		t0=eycms.enhtml(eycms.fget("t0",0))
		session("currentsite")=t0
		session("prefixsite")=prefix
		eycms.clearcache
		eycms.echo "1"
	end Sub
	
	sub screenlock_super()
		dim t0,t1,t2,t3,t4,t5
		t0=eycms.enhtml(eycms.fget("t0",0))
		t1=eycms.loadsession("adminnamelock_super")
		t4=eycms.loadsession("adminpwdlock_super")
		t5=eycms.loadsession("adminkeylock_super")
		t2=eycms.loadsession("logintimes")
		If t2="" Or IsNull(t2) Then t2=0
		t3 = 9-t2
		if eycms.strlen(t1)=0 then eycms.echo "-1|"&t3:exit sub
		if eycms.strlen(t0)=0 then eycms.echo "0|"&t3:exit sub
		dim data
		If t2 < 10 then
			if md5("eycms"&t0&"2015admin")<>super_save_code Then
				eycms.echo "0|" & t3
				Exit Sub
			End if
			data=eycms.db.dbload(1,"adminid,logintimes,islock,groupid,penname,adminname,adminpass","ey_admin","adminname='"&t1&"'","")
			if ubound(data)<0 Then
				eycms.echo "0|" & t3
			Else
				if md5(data(5,0)&data(6,0)&t5)<>t4 or data(2,0)=0 then
					eycms.echo "0|" & t3
				else
					eycms.setsession "adminid",data(0,0)
					eycms.setsession "adminname",t1
					eycms.setcookie "adminname",t1
					eycms.setsession "admingroupid",data(3,0)
					eycms.setcookie "adminid",data(0,0)
					dim penname:penname=data(4,0)
					if eycms.strlen(penname)=0 Then penname="eycms"
					eycms.setcookie "penname",penname
					dim key:key=eycms.getkey()
					eycms.setcookie "loginkey",key
					eycms.setcookie "loginpwd",md5(t1&data(6,0)&key)
					eycms.setcookie "adminlock_super","yes"
					eycms.echo "1"
				end If
			end If
		Else
			eycms.echo "3"
		End If
		eycms.setsession "logintimes",t2+1
		data=""
	end Sub

	sub screenlock()
		dim t0,t1,t2,t3
		t0=eycms.enhtml(eycms.fget("t0",0))
		t1=eycms.loadsession("adminnamelock")
		t2=eycms.loadsession("logintimes")
		If t2="" Or IsNull(t2) Then t2=0
		t3 = 9-t2
		if eycms.strlen(t1)=0 then eycms.echo "-1|"&t3:exit sub
		if eycms.strlen(t0)=0 then eycms.echo "0|"&t3:exit sub
		dim data
		If t2 < 10 then
			data=eycms.db.dbload(1,"adminid,logintimes,islock,groupid,penname,adminname,adminpass","ey_admin","adminname='"&t1&"' and adminpass='"&md5(t0)&"'","")
			if ubound(data)<0 Then
				eycms.echo "0|" & t3
			Else
				if data(2,0)=0 then
					eycms.echo "0|" & t3
				else
					eycms.setsession "adminid",data(0,0)
					eycms.setsession "adminname",t1
					eycms.setcookie "adminname",t1
					eycms.setsession "admingroupid",data(3,0)
					eycms.setcookie "adminid",data(0,0)
					dim penname:penname=data(4,0)
					if eycms.strlen(penname)=0 Then penname="eycms"
					eycms.setcookie "penname",penname
					dim key:key=eycms.getkey()
					eycms.setcookie "loginkey",key
					eycms.setcookie "loginpwd",md5(t1&data(6,0)&key)
					eycms.echo "1"
				end If
			end If
		Else
			eycms.echo "3"
		End If
		eycms.setsession "logintimes",t2+1
		data=""
	end Sub

	sub setlock
		dim t0
		t0=eycms.loadsession("adminname")
		eycms.setsession "adminnamelock",t0
		eycms.setsession "logintimes",""
		eycms.setsession "adminid",""
		eycms.setsession "adminname",""
		eycms.setcookie "penname",empty
		eycms.setsession "admingroupid",""
		eycms.setcookie "adminname",empty
		eycms.setcookie "loginkey",empty
		eycms.setcookie "loginpwd",empty
		eycms.echo "111"
	end Sub

	sub out()
		eycms.setsession "adminid",""
		eycms.setsession "adminname",""
		eycms.setcookie "penname",empty
		eycms.setsession "admingroupid",""
		eycms.setcookie "adminid",empty
		eycms.setcookie "loginkey",empty
		eycms.setcookie "loginpwd",Empty
		eycms.setcookie "adminlock_super",Empty
		eycms.go "login.asp"
	end sub
	
	dim act:act=lcase(eycms.fget("act",0))
	select case act
		case "check":check
		case "screenlock":screenlock
		case "screenlock_super":screenlock_super
		case "sitechange":sitechange
		case "setlock":setlock
		case "out":out
		case else
		if eycms.loadsession("adminid")<>"" then eycms.go "./"
		dim t:t=eycms.getint(eycms.fget("t",0),0)
		dim s:s=eycms.strlen(eycms.getsys("qq.login"))
		eycms.setcookie "adminlock_super",Empty
		load theme_login
	end select
	eycms.db.dbclose
%>
