admin_log_action.asp

来自「eayanQuery思燕大学成绩查询系统 版本 V1.6」· ASP 代码 · 共 129 行

ASP
129
字号
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../KS_Cls/KS_CommonCls.asp"-->
<!--#include file="ChkCode.asp"-->
<%
'强制浏览器重新访问服务器下载页面,而不是从缓存读取页面
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
Dim KSCMS,SoftKeyBoardTF
'On Error Resume Next
Set KSCMS=New CommonCls

Select Case  KSCMS.G("Action")
'Select Case  "Action"
 Case "LoginCheck"
  Call CheckLogin()
 Case "LoginOut"
  Call LoginOut()
 Case Else
  server.transfer "admin_login.asp"
End Select
%>

 
<%
Sub CheckLogin()
  Dim PWD,UserName,LoginRS,SqlStr,RndPassword
  Dim ScriptName,AdminLoginCode
  AdminLoginCode=KSCMS.G("AdminLoginCode")
  IF Trim(Request.Form("Verifycode"))<>Trim(Session("Verifycode")) then 
   Call KSCMS.Alert("登录失败:\n\n验证码有误,请重新输入!","Admin_Login.asp")
   exit Sub
  end if
  If EnableSiteManageCode = True And AdminLoginCode <> SiteManageCode Then
   Call KSCMS.Alert("登录失败:\n\n您输入的后台管理认证码不对,请重新输入!","Admin_Login.asp")
   exit Sub
  End If
 Pwd =KSCMS.MD5(KSCMS.ReplaceBadChar(Request.form("pwd")),16)

  UserName = KSCMS.ReplaceBadChar(trim(Request.form("username")))
  RndPassword=KSCMS.ReplaceBadChar(KSCMS.MakeRandomChar(20))
  ScriptName=KSCMS.ReplaceBadChar(Trim(Request.ServerVariables("HTTP_REFERER")))
  
  Set LoginRS = Server.CreateObject("ADODB.RecordSet")
  SqlStr = "select * from KS_Admin where UserName='" & UserName & "'"
  LoginRS.Open SqlStr,Conn,1,3
  If LoginRS.EOF AND LoginRS.BOF Then
	  Call KSCMS.InsertLog(UserName,0,ScriptName,"输入了错误的帐号!")
      Call KSCMS.AlertHistory("登录失败:\n\n您输入了错误的帐号,请再次输入!",-1)
  Else
  
     IF LoginRS("PassWord")=pwd THEN
       IF Cint(LoginRS("Locked"))=1 Then
          Call KSCMS.Alert("登录失败:\n\n您的账号已被管理员锁定,请与您的系统管理员联系!","Admin_Login.asp")	
	      Response.End
	   Else
		  	 '登录成功,进行前台验证,并更新数据
			  Dim UserRS:Set UserRS=Server.CreateObject("Adodb.Recordset")
			  UserRS.Open "Select Score,LastLoginIP,LastLoginTime,LoginTimes,UserName,Password,RndPassWord From KS_User Where UserName='" & LoginRS("PrUserName") & "' and GroupID=4",Conn,1,3
			  IF Not UserRS.Eof Then
			  
						If datediff("n",UserRS("LastLoginTime"),now)>=KSCMS.GetConfig("LoginPerMinute") then '判断时间
						UserRS("Score")=UserRS("Score")+KSCMS.GetConfig("LoginPerTimeAddScore")
						end if
					 UserRS("LastLoginIP") = KSCMS.GetIP
					 UserRS("LastLoginTime") = Now()
					 UserRS("LoginTimes") = UserRS("LoginTimes") + 1
					 UserRS("RndPassWord") = RndPassWord
					 UserRS.Update		
	
					'置前台会员登录状态
					 Response.Cookies(KSCMS.SiteSn)("UserName") = KSCMS.ReplaceBadChar(UserRS("UserName"))
			         Response.Cookies(KSCMS.SiteSn)("Password") = UserRS("Password")
					 Response.Cookies(KSCMS.SiteSn)("RndPassword") = KSCMS.ReplaceBadChar(UserRS("RndPassword"))
					 Response.Cookies(KSCMS.SiteSn)("AdminLoginCode") = AdminLoginCode
					 Response.Cookies(KSCMS.SiteSn)("AdminName") =  UserName
					 Response.Cookies(KSCMS.SiteSn)("AdminPass")= pwd
					 Response.Cookies(KSCMS.SiteSn)("SuperTF")     = LoginRS("SuperTF")
					 Response.Cookies(KSCMS.SiteSn)("PowerList")   = LoginRS("PowerList")
					 Response.Cookies(KSCMS.SiteSn)("ModelPower")  = LoginRS("ModelPower")
             Else 
				   Call KSCMS.InsertLog(UserName,0,ScriptName,"找不到前台账号!")
				   Call KSCMS.Alert("登录失败:\n\n找不到前台账号!","Admin_Login.asp")	
				   Response.End
			 End If
			   UserRS.Close:Set UserRS=Nothing
			   
	  LoginRS("LastLoginTime")=Now
	  LoginRS("LastLoginIP")=KSCMS.GetIP
	  LoginRS("LoginTimes")=LoginRS("LoginTimes")+1
	  LoginRS.UpDate
	  Call KSCMS.InsertLog(UserName,1,ScriptName,"成功登录后台系统!")
	  Response.Redirect("Admin_Index.asp")
	End IF
  ELse
    Response.Cookies(KSCMS.SiteSn)("AdminName")=""
	Response.Cookies(KSCMS.SiteSn)("AdminPass")=""
	Response.Cookies(KSCMS.SiteSn)("SuperTF")=""
	Response.Cookies(KSCMS.SiteSn)("PowerList")=""
	Response.Cookies(KSCMS.SiteSn)("ModelPower")=""
	Call KSCMS.InsertLog(UserName,0,ScriptName,"输入了错误的口令:" & Request.form("pwd"))
    Call KSCMS.Alert("登录失败:\n\n您输入了错误的口令,请再次输入!","Admin_Login.asp")	
  END IF
 End If
END Sub
Sub LoginOut()
			Dim AdminDir,RSObj
			Set RSObj=Server.CreateObject("Adodb.RecordSet")
			 RSObj.Open "Select LastLogoutTime From KS_Admin where UserName='"&Request.Cookies(KSCMS.SiteSn)("AdminName") & "'",Conn,1,3
			 IF Not RSObj.Eof Then
			  RSObj(0)=Now
			  RSObj.Update
			 End IF
			 RSObj.Close
			 Set RSObj=Nothing
			AdminDir=KSCMS.GetConfig("AdminDir")
			Response.Cookies(KSCMS.SiteSn)("AdminName")=""
			Response.Cookies(KSCMS.SiteSn)("AdminPass")=""
			Response.Cookies(KSCMS.SiteSn)("SuperTF")=""
			Response.Cookies(KSCMS.SiteSn)("PowerList")=""
			Response.Cookies(KSCMS.SiteSn)("ModelPower")=""
			session.Abandon()
			Response.Write ("<script> top.location.href='" & KSCMS.GetConfig("WebUrl") & KSCMS.GetConfig("InstallDir") &  AdminDir & "Admin_Login.asp';</script>")
End Sub
Set KSCMS=Nothing
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?