<!--#include file="conn/hl_conn.asp"-->
<!--#include file="inc/hl_function.asp"-->
<!--#include file="inc/UpiConfig.asp"-->
<!--#include file="inc/md5.asp"-->
<!--#include file="inc/HL_RegSet.asp"-->
<style type="text/css">
<!--
body,td,th {
	font-size: 13px;
}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
-->
</style>
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide

function killErrors() {
return true;
}

window.onerror = killErrors;

// -->
</SCRIPT>
<!--容错代码结束-->
<%
Dim TempPassword
UserName = ReplaceBadChar(Trim(Request("UserName")))
UserPassword=Trim(Request("UserPassword"))
checkcode=ReplaceBadChar(Trim(Request("checkcode")))
CookieDate=ReplaceBadChar(Trim(Request("CookieDate")))
ComeUrl = Trim(Request("ComeUrl"))
If UserPassword="" Then UserPassword= ReplaceBadChar(Trim(Request("Password")))
If ComeUrl = "" Then ComeUrl = Request.ServerVariables("HTTP_REFERER")
if Instr(ComeUrl,"User_Login.asp")>0 Then ComeUrl="User_Index.asp"
if Instr(ComeUrl,"logging.php")>0 Then ComeUrl=Replace( Request.ServerVariables("HTTP_REFERER"),"logging.php?action=login","index.php")
If Instr(ComeUrl,"login.asp")>0 Then ComeUrl=Replace(ComeUrl,"login.asp","")

If UserName = "" Then
    FoundErr = True
    ErrMsg = ErrMsg & "<br><li>用户名不能为空！</li>"
	call  WriteErrMsg(ErrMsg)
	response.End()
ElseIF Len(UserName)>16 Then
    FoundErr = True
    ErrMsg = ErrMsg & "<br><li>用户名过长！</li>"
	call  WriteErrMsg(ErrMsg)
	response.End()
Else
    UserName = ReplaceBadChar(UserName)
End If
If UserPassword = "" 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'--------A-----Begin
     	If LoginCheckCode=1 Then
		   If Request("LoginType")="hl" Then'B----------Begin		  
		     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
		   End IF
		End if'----------B--------End
		 
	Set rs = server.CreateObject("adodb.recordset")
    sql = "select top 1 * from hl_user where username='" & UserName & "'" 
    rs.open sql,conn,1,3
	If rs.bof And rs.EOF Then'D------------Begin
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>用户名或密码错误1！！！</li>"
		call  WriteErrMsg(ErrMsg)
	    response.End()
    Else    
	       TempPassword=rs("userpassword")
		   If Len(TempPassword)=32 Then TempPassword=Mid(TempPassword,9,16)'判断数据库密码是否为32位，是则将密码转为16位 
		   If TempPassword<>Md5(UserPassword,16) Then'将数据库密码跟用户的16位密码相比较'------E---Begin   
            FoundErr = True
            ErrMsg = ErrMsg & "<br><li>用户名或密码错误2！！！</li>"
			call  WriteErrMsg(ErrMsg)
	        response.End()
            Else
            rs("loginIP") = Request.ServerVariables("REMOTE_ADDR")
            rs("LastLogin") = Now()
            rs("Logins") = rs("Logins") + 1
            rs.Update
          Select Case CookieDate
              Case 0
             ' not save
              Case 1
              Response.Cookies(Site_Sn).Expires = Date + 1
              Case 2
              Response.Cookies(Site_Sn).Expires = Date + 31
              Case 3
              Response.Cookies(Site_Sn).Expires = Date + 365
              End Select
		      'CookieDate=1
		     session("hl_user")="hl_user_center"
			 Response.Cookies("hl_user")("username")=UserName
		     Response.Cookies("hl_user")("password")=TempPassword
			If Domainname<>"" Then Response.Cookies("hl_user").Domain=Domainname
            If HLIntegration = False Then'------F----Begin--------
                rs.Close
                Set rs = Nothing
                conn.close
				set conn=nothing
                Response.redirect ComeUrl
           	End if'------------------F-------End-------------
				Md5Info=MD5(UserName & SecurityKey, 32)
			      pass=MD5(UserPassword, 32)
			    answer=MD5(Answer, 32)
				
			If IsNull(SecurityKey) = False And SecurityKey <> "" And IsNull(arrUpiUrls) = False And arrUpiUrls <> "" Then'H--Begin
                 HLUpi = Split(arrUpiUrls, "|")
                    Dim iNum
					on error resume next					
                For iNum = 0 To UBound(HLUpi)
				 Response.Write "<script src=""" & HLUpi(iNum) & "?action=LoginUser&Md5Info=" & Md5Info & "&name=" & UserName & "&pass=" & pass & "&answer=" & answer & "&save="&CookieDate&"&usertype="&request("usertype")&"""></script>" & vbCrLf
                 Response.Write "&nbsp;"
				Next
               response.Write("<script language=JavaScript>top.location='"&ComeUrl&"';</script>")
             End If'---------H-----End
			
        End If'-----E---------End
    End If'--------D---------End
    rs.Close
    Set rs = Nothing
End If'--------A--------End

If FoundErr = True Then
    Call WriteErrMsg
End If
conn.close
set conn=nothing
%>

