<!--#include file="conn/hl_conn.asp"-->
<!--#include file="inc/a_upiconfig.asp"-->
<!--#include file="inc/md5.asp"-->
<!--#include file="Admin_ManageCode.asp"-->
<%
'……………………版权信息……………………
'本软件已登记软件著作权，版权归广州恒浪网络科技有限公司所有。所有代码都已经注册登记！
'任何未经许可的修改、复制、提供下载、出售等均属违法侵权行为，请尊重版权，勿以身试法！谢谢！
'请保留此版权信息，请尊重版权，勿以身试法！谢谢！
'网    址：http://www.Howave.Net
'技术论坛：http://BBS.Howave.Net
'联系邮箱：websky888@gmail.com 
'……………………版权信息……………………
%>
<%

dim UserName,UserPassword,CookieDate,verifycode,fanhuicanshu

UserName = ReplaceBadChar(Trim(Request("userId")))
UserPassword =Replace(Trim(Request("password")),"'","")
UserPassword=MD5(UserPassword,32)
CookieDate=Trim(Request("CookieDate"))
verifycode=Trim(Request("verifycode"))

If UserName = "" Then
    FoundErr = True
   ErrMsg = ErrMsg & "<br><li>管理员帐号不能为空！</li>"
   call  WriteErrMsg(ErrMsg)
	response.End()
End If

If UserPassword = "" Then
    FoundErr = True
    ErrMsg = ErrMsg & "<br><li>管理员密码不能为空！</li>"
	call  WriteErrMsg(ErrMsg)
	response.End()
End If
CheckCode = LCase(ReplaceBadChar(Trim(Request("CheckCode"))))
If CheckCode = "" Then
   FoundErr = True
   ErrMsg = ErrMsg & "<br><li>验证码不能为空！</li>"
   call  WriteErrMsg(ErrMsg)
   response.End()
End If
If Trim(Session("CheckCode")) = "" Then
   FoundErr = True
   ErrMsg = ErrMsg & "<br><li>你登录时间过长，请重新返回登录页面进行登录。</li>"
	call  WriteErrMsg(ErrMsg)
	response.End()
End If
If CheckCode <> Session("CheckCode") Then
FoundErr = True
ErrMsg = ErrMsg & "<br><li>您输入的确认码和系统产生的不一致，请重新输入。</li>"
call  WriteErrMsg(ErrMsg)
response.End()
End If

If Trim(Request("ManageCode"))<>ManageCode Then
FoundErr= True
ErrMsg = ErrMsg & "<br><li>您输入的管理验证码错误，请重新输入。</li>"
call  WriteErrMsg(ErrMsg)
response.End()
End If

If CookieDate = "" Or (Not IsNumeric(CookieDate)) Then
    CookieDate = 0
Else
   CookieDate = CLng(CookieDate)
End If
If FoundErr <> True Then
    
    Set rs = server.CreateObject("adodb.recordset")
    sql = "select * from hl_admin where hl_adminuser='" & UserName & "' and hl_adminpass='" & UserPassword & "'"
    rs.open sql, conn, 1, 3
    If rs.bof And rs.EOF Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>用户名或密码错误！！！</li>"
		call  WriteErrMsg(ErrMsg)
	    response.End()
    Else
        If UserPassword <> rs("hl_adminpass") Then
            FoundErr = True
            ErrMsg = ErrMsg & "<br><li>密码错误！！！</li>"
			call  WriteErrMsg(ErrMsg)
	        response.End()
        end if
	end if
	
		   
            rs("loginIP") = Request.ServerVariables("REMOTE_ADDR")
            rs("LastLogin") = Now()
            rs("Logins") = rs("Logins") + 1
            rs.Update
		   Response.Cookies("hl_manage")("username")=rs("hl_adminuser")
		   Response.Cookies("hl_manage")("password")=rs("hl_adminpass")
		   Response.Cookies("hl_manage")("ManageCode")=Replace(Trim(Request("ManageCode")),"'","")
		   
		    GoUrl="Admin_Index.asp"
				If SecurityKey <> Empty And IsArray(HLUpi) Then 
			    HLUpi = Split(arrUpiUrls, "|")
			    MD5Info=MD5(UserName & SecurityKey, 32)
		        Response.Write "<html>" & vbCrLf
                Response.Write "<head>" & vbCrLf
                Response.Write "<meta http-equiv=""refresh"" content=""" & RefreshTime & ";URL=" & GoUrl & """ />" & vbCrLf
                Response.Write "<title>登陆后台</title>" & vbCrLf                
                    Dim iNum
				    For iNum = 0 To UBound(HLUpi)
             Response.Write "<iframe id='LoginUser' width='100%' height='0' frameborder='0' src='" & LCase(HLUpi(iNum)) & "?action=LoginUser&Md5Info=" &  MD5Info & "&name=" & UserName & "&pass=" & UserPassword & "&save=" & CookieDate & "'></iframe>" & vbCrLf			
			 
			    response.Flush
					Next
                Response.Write "</head>" & vbCrLf
                Response.Write "<body>" & vbCrLf				
				Response.Write "<br><br><br><br><br>"
                Response.Write "<div align='center'><span style='font-size:9pt'>正在登陆后台系统，请稍等，" & RefreshTime & "秒后返回...</span></div>" & vbCrLf
                Response.Write "<div align='center'><img src='img/interface.gif' /></div>"
                Response.Write "</body>" & vbCrLf
                Response.Write "</html>" & vbCrLf ' 
				      
            End If
    rs.Close
    Set rs = Nothing
	
End If

'****************************************************
'过程名：WriteErrMsg
'作  用：显示错误提示信息
'参  数：无
'****************************************************
Sub WriteErrMsg(ErrMsg)
    Dim strErr
    strErr = strErr & "<html><head><title>错误信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbCrLf
    strErr = strErr & "<link href='img/css.css' rel='stylesheet' type='text/css'></head><body>" & vbCrLf
    strErr = strErr & "<table border='1' width='400' align='center' cellpadding='2' cellspacing='0' bordercolor='#A0D3FE' bgcolor='#EEF9FD' style='BORDER-COLLAPSE: collapse'>" & vbCrLf
    strErr = strErr & "  <tr align='center'><td height='22' class='title'><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"">&lt;&lt; 返回登录页面</a></td></tr>" & vbCrLf
    strErr = strErr & "</table>" & vbCrLf
    strErr = strErr & "</body></html>" & vbCrLf
    Response.Write strErr
End Sub
'**************************************************
'函数名：ReplaceBadChar
'作  用：过滤非法的SQL字符
'参  数：strChar-----要过滤的字符
'返回值：过滤后的字符
'**************************************************
Function ReplaceBadChar(strChar)
    If strChar = "" Or IsNull(strChar) Then
        ReplaceBadChar = ""
        Exit Function
    End If
    Dim strBadChar, arrBadChar, tempChar, i
    strBadChar = "',%,^,&,?,(,),<,>,[,],{,},/,\,;,:," & Chr(34) & "," & Chr(0) & ""
    arrBadChar = Split(strBadChar, ",")
    tempChar = strChar
    For i = 0 To UBound(arrBadChar)
        tempChar = Replace(tempChar, arrBadChar(i), "")
    Next
    ReplaceBadChar = tempChar
End Function

Function PE_CLng(ByVal str1)
    If IsNumeric(str1) Then
        PE_CLng = CLng(str1)
    Else
        PE_CLng = 0
    End If
End Function

Function PE_CDbl(ByVal str1)
    If IsNumeric(str1) Then
        PE_CDbl = CDbl(str1)
    Else
        PE_CDbl = 0
    End If
End Function
%>
