<!--#include file="../inc/Conn.asp"-->
<!--#include file="../inc/base64.asp"-->
<!--#include file="../inc/Function.asp"-->
<!--#include file="../inc/md5.asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<%
HTTP_REFERER=request.Form("HTTP_REFERER")
if inStr(HTTP_REFERER,"reg_ok.asp")>0 then
HTTP_REFERER="user.asp"
end if
if inStr(HTTP_REFERER,"reg.asp")>0 then
HTTP_REFERER="user.asp"
end if
dim sql,rs
dim P_UserNames,P_PassWord,CheckCode
P_UserName=replace(trim(request("P_UserName")),"'","")
P_PassWord=replace(trim(Request("P_PassWord")),"'","")
CheckCode=replace(trim(Request("CheckCode")),"'","")
if P_UserName="" then
	Response.Write("<script language=""JavaScript"">alert(""错误提示：您的用户名不能为空！！"");history.go(-1);</script>")
	response.end
end if
if P_PassWord="" then
	Response.Write("<script language=""JavaScript"">alert(""错误提示：您的密码不能为空！！"");history.go(-1);</script>")
	response.end
end if

	P_PassWord=md5(P_PassWord)
	set rs=server.createobject("adodb.recordset")
	sql="select * from Dream_User where Dream_PassWord='"&P_PassWord&"' and Dream_UserName='"&P_UserName&"'"
	rs.open sql,conn,1,3
	if rs.bof and rs.eof then
		Response.Write("<script language=""JavaScript"">alert(""用户名或密码错误！！！"");history.go(-1);</script>")
		response.end
	else
		if P_PassWord<>rs("Dream_PassWord") then
			Response.Write("<script language=""JavaScript"">alert(""用户名或密码错误！！！"");history.go(-1);</script>")
		response.end
		else
		    RndPassword=GetRndPassword(16)
			rs("Dream_LastLoginIP")=Request.ServerVariables("REMOTE_ADDR")
			rs("Dream_LastLoginTime")=now()
			rs("Dream_LoginTimes")=rs("Dream_LoginTimes")+1
			rs("Dream_RndPassword")=RndPassword
			rs.update
			session.Timeout=30
			session("Dream_UserName")=rs("Dream_UserName")
			session("Dream_Rok")=rs("Dream_Rok")
			session("Dream_PassWord")=rs("Dream_PassWord")		
			session("Dream_RndPassword")=RndPassword
			rs.close
			set rs=nothing
			call CloseConn()

			Response.Write("<script language=""JavaScript"">alert(""提示：登录成功！！"");this.location.href='user.asp';</script>")

		end if
	end if
	rs.close
	set rs=nothing

call CloseConn()


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
%>