%@language=vbscript codepage=936 %>
<%
dim sql,rs,sqls,rss
dim username,password,CheckCode
username=dvHTMLEncode(request.Form("username"))
username=replace(trim(Request.Form("username")),"'","")
password=replace(trim(Request.Form("password")),"'","")
CheckCode=replace(trim(Request.Form("CheckCode")),"'","")
if UserName="" then
FoundErr=true
ErrMsg=ErrMsg & "
用户名不能为空!
"
end if
if Password="" then
FoundErr=true
ErrMsg=ErrMsg & "
密码不能为空!
"
end if
if CheckCode="" then
FoundErr=true
ErrMsg=ErrMsg & "
验证码不能为空!
"
end if
if session("CheckCode")="" then
FoundErr=true
ErrMsg=ErrMsg & "
你登录时间过长,请重新返回登录页面进行登录。
"
end if
if CheckCode<>CStr(session("CheckCode")) then
FoundErr=true
ErrMsg=ErrMsg & "
您输入的确认码和系统产生的不一致,请重新输入。
"
end if
if FoundErr<>True then
password=md5(password)
set rs=server.createobject("adodb.recordset")
sql="select * from MCadmin where password='"&password&"' and username='"&username&"'"
rs.open sql,conn,1,3
if rs.bof and rs.eof then
FoundErr=true
ErrMsg=ErrMsg & "
用户名或密码错误!!!
"
else
if password<>rs("password") then
FoundErr=true
ErrMsg=ErrMsg & "
用户名或密码错误!!!
"
else
if rs("admintrue")<>true then
FoundErr=true
ErrMsg=ErrMsg & "
帐户没有启用或是根本不存在!!!
"
else
RndPassword=GetRndPassword(16)
rs("LastLoginIP")=Request.ServerVariables("REMOTE_ADDR")
rs("LastLoginTime")=now()
rs("LoginTimes")=rs("LoginTimes")+1
rs("RndPassword")=RndPassword
rs.update
session("AdminName")=rs("username")
session("AdminPassword")=rs("Password")
session("RndPassword")=RndPassword
session("MCID")=rs("ID")
rs.close
set rs=nothing
set rss=server.createobject("adodb.recordset")
sqls="select * from MClog "
rss.open sqls,conn,1,3
rss.addnew
rss("MCID")=session("MCID")
rss("MCuname")=session("AdminName")
rss("MClogurl")=request.ServerVariables("URL")
rss("MClogtime")=now()
rss("MCIP")=Request.ServerVariables("REMOTE_ADDR")
rss.update
rss.close
set rss=nothing
call CloseConn()
Response.Redirect "default.asp"
end if
end if
end if
rs.close
set rs=nothing
end if
if FoundErr=true then
call WriteErrMsg()
end if
call CloseConn()
'****************************************************
'过程名:WriteErrMsg
'作 用:显示错误提示信息
'参 数:无
'****************************************************
sub WriteErrMsg()
dim strErr
response.write" "
response.write" "
response.write" "
response.write" "
response.write" "
response.write" "
response.write""
strErr=strErr & "鸿均传媒----错误信息" & vbcrlf
strErr=strErr & "" & vbcrlf
strErr=strErr & "
" & vbcrlf
strErr=strErr & "" & vbcrlf
response.write strErr
response.write""
end sub
Function GetRndPassword(PasswordLen)
Dim Ran,i,strPassword
strPassword=""
For i=1 To PasswordLen
Randomize
Ran = CInt(Rnd * 2)
Randomize
If Ran = 0 Then
Ran = CInt(Rnd * 25) + 97
strPassword =strPassword & UCase(Chr(Ran))
ElseIf Ran = 1 Then
Ran = CInt(Rnd * 9)
strPassword = strPassword & Ran
ElseIf Ran = 2 Then
Ran = CInt(Rnd * 25) + 97
strPassword =strPassword & Chr(Ran)
End If
Next
GetRndPassword=strPassword
End Function
%>