📄 admin_login.asp
字号:
<%@language=vbscript codepage=936%>
<%
'强制浏览器重新访问服务器下载页面,而不是从缓存读取页面
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
'主要是使随机出现的图片数字随机
%>
<!--#include file="config.asp"-->
<!--#include file="conn.asp"-->
<!--#include file="code.asp"-->
<!--#include file="inc/md5.asp"-->
<%
dim Action,FoundErr,ErrMsg
Action=trim(request("Action"))
if Action="Login" then
call ChkLogin()
elseif Action="Logout" then
call Logout()
else
call main()
end if
if FoundErr=True then
call WriteErrMsg()
end if
call CloseConn()
sub main()
%>
<html>
<head>
<title>管理员登录</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="image/css.css">
<script language=javascript>
<!--
function SetFocus()
{
if (document.Login.UserName.value=="")
document.Login.UserName.focus();
else
document.Login.UserName.select();
}
function CheckForm()
{
if(document.Login.UserName.value=="")
{
alert("请输入用户名!");
document.Login.UserName.focus();
return false;
}
if(document.Login.Password.value == "")
{
alert("请输入密码!");
document.Login.Password.focus();
return false;
}
if (document.Login.CheckCode.value==""){
alert ("请输入您的验证码!");
document.Login.CheckCode.focus();
return(false);
}
}
//-->
</script>
</head>
<body>
<p> </p>
<p> </p>
<form name="Login" action="Admin_Login.asp" method="post" target="_parent" onSubmit="return CheckForm();">
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"><img src="Image/Admin_Login1.gif" width="600" height="126"></td>
</tr>
<tr>
<td width="508" valign="top" background="Image/Admin_Login2.gif"><table width="508" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="37" colspan="7"> </td>
</tr>
<tr>
<td width="75" rowspan="2"> </td>
<td width="126"><font color="#043BC9">用户名称:</font></td>
<td width="39" rowspan="2"> </td>
<td width="131"><font color="#043BC9">用户密码:</font></td>
<td width="33"> </td>
<td colspan="2"><font color="#043BC9">验证码:</font></td>
</tr>
<tr>
<td><input name="UserName" type="text" id="UserName" maxlength="20" style="width:110px; BORDER-RIGHT: #F7F7F7 0px solid; BORDER-TOP: #F7F7F7 0px solid; FONT-SIZE: 9pt; BORDER-LEFT: #F7F7F7 0px solid; BORDER-BOTTOM: #c0c0c0 1px solid; HEIGHT: 16px; BACKGROUND-COLOR: #F7F7F7" onmouseover="this.style.background='#ffffff';" onmouseout="this.style.background='#F7F7F7'" onFocus="this.select(); "></td>
<td><input name="Password" type="password" maxlength="20" style="width:110px; BORDER-RIGHT: #F7F7F7 0px solid; BORDER-TOP: #F7F7F7 0px solid; FONT-SIZE: 9pt; BORDER-LEFT: #F7F7F7 0px solid; BORDER-BOTTOM: #c0c0c0 1px solid; HEIGHT: 16px; BACKGROUND-COLOR: #F7F7F7" onmouseover="this.style.background='#ffffff';" onmouseout="this.style.background='#F7F7F7'" onFocus="this.select(); "></td>
<td> </td>
<td width="53"><input name="CheckCode" size="6" maxlength="6" style="width:50px; BORDER-RIGHT: #F7F7F7 0px solid; BORDER-TOP: #F7F7F7 0px solid; FONT-SIZE: 9pt; BORDER-LEFT: #F7F7F7 0px solid; BORDER-BOTTOM: #c0c0c0 1px solid; HEIGHT: 16px; BACKGROUND-COLOR: #F7F7F7" onmouseover="this.style.background='#ffffff';" onmouseout="this.style.background='#F7F7F7'" onFocus="this.select(); "></td>
<td width="51"><img src="inc/checkcode.asp"></td>
</tr>
</table></td>
<td><input type='hidden' name='Action' value='Login'>
<input name="Submit" type="image" style="width:92px; HEIGHT: 126px;" src="Image/Admin_Login3.gif" width="92" height="126"></td>
</tr>
</table>
</form>
<script language="JavaScript" type="text/JavaScript">
SetFocus();
</script>
</body>
</html>
<%
end sub
sub ChkLogin()
dim sql,rs
dim username,password,CheckCode,RndPassword
UserName = ReplaceBadChar(Trim(Request("UserName")))
Password = ReplaceBadChar(Trim(Request("Password")))
CheckCode = LCase(ReplaceBadChar(Trim(Request("CheckCode"))))
if UserName="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名不能为空!</li>"
end if
if Password="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>密码不能为空!</li>"
end if
If CheckCode = "" Then
FoundErr = True
ErrMsg = ErrMsg & "<br><li>验证码不能为空!</li>"
End If
If Trim(Session("CheckCode")) = "" Then
FoundErr = True
ErrMsg = ErrMsg & "<br><li>你登录时间过长,请重新返回登录页面进行登录。</li>"
End If
If CheckCode <> Session("CheckCode") Then
FoundErr = True
ErrMsg = ErrMsg & "<br><li>您输入的确认码和系统产生的不一致,请重新输入。</li>"
End If
if FoundErr=True then
exit sub
end if
If UserTrueIP = "" Then
TrueIP = Trim(Request.ServerVariables("HTTP_X_FORWARDED_FOR"))
If TrueIP = "" Then TrueIP = Request.ServerVariables("REMOTE_ADDR")
Else
TrueIP = UserTrueIP
End If
password=md5(password,16)
set rs=server.createobject("adodb.recordset")
sql="select * from "&AdminTable&" where password='"&password&"' and username='"&username&"'"
rs.open sql,conn,1,3
if rs.bof and rs.eof then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名或密码错误!!!</li>"
else
if password<>rs("password") then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名或密码错误!!!</li>"
end if
end if
if FoundErr=True then
session("AdminName")=""
session("AdminPassword")=""
session("RndPassword")=""
rs.close
set rs=nothing
exit sub
end if
RndPassword=GetRndPassword(16)
rs("LastLoginIP")=TrueIP
rs("LastLoginTime")=now()
rs("LoginTimes")=rs("LoginTimes")+1
rs("RndPassword")=RndPassword
rs.update
Response.Cookies(webkey)("AdminName") = rs("username")
Response.Cookies(webkey)("AdminPassword") = rs("Password")
Response.Cookies(webkey)("RndPassword") = RndPassword
rs.close
set rs=nothing
call CloseConn()
Response.Redirect "Admin_main.asp"
end sub
sub Logout()
set rs=server.createobject("adodb.recordset")
sql="select * from "&AdminTable&" where username='"&ReplaceBadChar(Trim(Request.Cookies(webkey)("AdminName")))&"'"
rs.open sql,conn,1,3
rs("LastLogoutTime")=now()
rs.update
rs.close
set rs=nothing
Response.Cookies(webkey)("AdminName") = ""
Response.Cookies(webkey)("AdminPassword") = ""
Response.Cookies(webkey)("RndPassword") = ""
call CloseConn()
Response.Redirect "Admin_login.asp"
end sub
'****************************************************
'过程名:WriteErrMsg
'作 用:显示错误提示信息
'参 数:无
'****************************************************
sub WriteErrMsg()
dim strErr
strErr=strErr & "<html><head><title>错误信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbcrlf
strErr=strErr & "<link href='image/css.css' rel='stylesheet' type='text/css'></head><body>" & vbcrlf
strErr=strErr & "<table cellpadding=2 cellspacing=1 border=0 width=400 align=center>" & vbcrlf
strErr=strErr & " <tr align='center'><td height='25'><strong>错误信息</strong></td></tr>" & vbcrlf
strErr=strErr & " <tr><td height='100' valign='top'><b>产生错误的可能原因:</b><br>" & errmsg &"</td></tr>" & vbcrlf
strErr=strErr & " <tr align='center'><td><a href='Admin_Login.asp'><< 返回登录页面</a></td></tr>" & vbcrlf
strErr=strErr & "</table>" & vbcrlf
strErr=strErr & "</body></html>" & vbcrlf
response.write strErr
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -