www.gusucode.com > 艺术签名文章资讯网源代码 > 艺术签名文章资讯网源代码/624/user/login.asp

    <!--#include file="config.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../api/cls_api.asp"-->
<!--#include file="../inc/cls_public.asp"-->
<%
Dim HtmlContent,ChannelRootDir
ChannelRootDir = Newasp.InstallDir & "user/"
Newasp.LoadTemplates 9999, 5, 0

HtmlContent = Newasp.HtmlContent
HtmlContent = Replace(HtmlContent,"{$InstallDir}", Newasp.InstallDir)
HtmlContent = Replace(HtmlContent, "{$ChannelID}", 0)
'--频道目录
HtmlContent = Replace(HtmlContent,"{$ChannelRootDir}", ChannelRootDir)
HtmlContent = Replace(HtmlContent,"{$PageTitle}","用户登录")
HtmlContent = ReadClassMenu(HtmlContent)
HtmlContent = ReadClassMenubar(HtmlContent)
HtmlContent = HTML.ReadAnnounceList(HtmlContent)
HtmlContent = HTML.ReadStatistic(HtmlContent)
HtmlContent = HTML.ReadUserRank(HtmlContent)

If CheckLogin Then
	Response.Redirect ("./index.asp")
End If
If LCase(Request("action")) = "login" Then
	Call MemberLogin
Else
	HtmlContent = Replace(HtmlContent,"{$UserManageContent}", Newasp.HtmlSetting(7))
	HtmlContent = Replace(HtmlContent,"{$SiteName}", Newasp.SiteName)
	Response.Write HtmlContent
End If
If Founderr = True Then
	Call Returnerr(ErrMsg)
End If
CloseConn
Sub MemberLogin()
	On Error Resume Next
	Dim Rs,SQL,username, password,usercookies,Group_Setting,UserRegIP
	If Trim(Request("username")) <> "" And Trim(Request("password")) <> "" Then
		username = Newasp.CheckBadstr(Request("username"))
		password = md5(Request("password"))
	Else
		ErrMsg = ErrMsg + "<li>用户名和密码不能为空!</li>"
		Founderr = True
		Exit Sub
	End If
	If Newasp.IsValidStr(Request("username")) = False Then
		ErrMsg = ErrMsg + "<li>用户名中含有非法字符!</li>"
		Founderr = True
	End If
	If Newasp.IsValidPassword(Request("password")) = False Then
		ErrMsg = ErrMsg + "<li>密码中含有非法字符!</li>"
		Founderr = True
	End If
	usercookies = Newasp.ChkNumeric(request("CookieDate"))
	'-----------------------------------------------------------------
	'系统整合
	'-----------------------------------------------------------------
	Dim API_Newasp,API_SaveCookie,SysKey
	If API_Enable Then
		Set API_Newasp = New API_Conformity
		API_Newasp.NodeValue "action","login",0,False
		API_Newasp.NodeValue "username",UserName,1,False
		Md5OLD = 1
		SysKey = Md5(API_Newasp.XmlNode("username") & API_ConformKey)
		Md5OLD = 0
		API_Newasp.NodeValue "syskey",SysKey,0,False
		API_Newasp.NodeValue "password",Request("password"),0,False
		API_Newasp.SendHttpData
		If API_Newasp.Status = "1" Then
			Founderr = True
			ErrMsg =  API_Newasp.Message
			Exit Sub
		Else
			API_SaveCookie = API_Newasp.SetCookie(SysKey,UserName,Password,usercookies)
		End If
		Set API_Newasp = Nothing
	End If
	'-----------------------------------------------------------------
	If Founderr = True Then Exit Sub
	Set Rs = Server.CreateObject("ADODB.Recordset")
	SQL = "SELECT * FROM [NC_User] WHERE username='" & username & "'"
	Rs.Open SQL, Conn, 1, 3
	If Rs.BOF And Rs.EOF Then
		FoundErr = True
		ErrMsg = ErrMsg + "<li>您输入的用户名和密码不正确,请联系管理员!</li>"
		Exit Sub
	Else
		If password <> Rs("password") Then
			FoundErr = True
			ErrMsg = ErrMsg + "<li>用户名或密码错误!!!</li>"
			Exit Sub
		End If
		If Rs("UserLock") <> 0 Then
			Founderr = True
			ErrMsg = Newasp.HtmlSetting(8)
			Exit Sub
		End If
		
		Response.Cookies(Newasp.Cookies_Name)("LastTimeDate") = Rs("LastTime")
		Response.Cookies(Newasp.Cookies_Name)("LastTimeIP") = Rs("userlastip")
		Response.Cookies(Newasp.Cookies_Name)("LastTime") = Rs("LastTime")
		Group_Setting=Split(Newasp.UserGroupSetting(Rs("UserGrade")), "|||")
		UserRegIP = Rs("ip") & ""
		If Newasp.ChkNumeric(Group_Setting(41)) = 1 Then
			If Newasp.GetUserip <> UserRegIP Then
				FoundErr = True
				ErrMsg = ErrMsg + "<li>非法登陆,请使用你注册时的IP地址登陆本系统。</li><li>您当前的IP:" & Newasp.GetUserIP & "</li><li>如果要修改登陆IP地址,请联系管理员。</li>"
				Exit Sub
			End If
		End If
		If Datediff("d",Now(),Rs("LastTime")) <> 0 Then 
			If Rs("userpoint") < 0 Then
				Rs("userpoint") = CLng(Group_Setting(25))
			Else
				Rs("userpoint") = Rs("userpoint") + CLng(Group_Setting(25))
			End If
			If Rs("experience") < 0 Then
				Rs("experience") = CLng(Group_Setting(32))
			Else
				Rs("experience") = Rs("experience") + CLng(Group_Setting(32))
			End If
			If Rs("charm") < 0 Then
				Rs("charm") = CLng(Group_Setting(33))
			Else
				Rs("charm") = Rs("charm") + CLng(Group_Setting(33))
			End If
		End If
		Rs("LastTime") = Now()
		Rs("userlastip") = Newasp.GetUserIP
		Rs("UserLogin") = Rs("UserLogin") + 1
		If Len(UserRegIP) < 8 Then
			Rs("ip") = Newasp.GetUserIP
		End If
		Rs.Update
		'If isnull(usercookies) Or usercookies="" Then usercookies=0
		Select Case usercookies
		Case 0
			Response.Cookies(Newasp.Cookies_Name)("usercookies") = usercookies
		Case 1
			Response.Cookies(Newasp.Cookies_Name).Expires=Date+1
			Response.Cookies(Newasp.Cookies_Name)("usercookies") = usercookies
		Case 2
			Response.Cookies(Newasp.Cookies_Name).Expires=Date+31
			Response.Cookies(Newasp.Cookies_Name)("usercookies") = usercookies
		Case 3
			Response.Cookies(Newasp.Cookies_Name).Expires=Date+365
			Response.Cookies(Newasp.Cookies_Name)("usercookies") = usercookies
		End Select
		'Response.Cookies(Newasp.Cookies_Name).path = "/"
		Response.Cookies(Newasp.Cookies_Name)("userid") = Rs("userid")
		Response.Cookies(Newasp.Cookies_Name)("username") = Rs("username")
		Response.Cookies(Newasp.Cookies_Name)("password") = Rs("password")
		Response.Cookies(Newasp.Cookies_Name)("nickname") = Rs("nickname")
		Response.Cookies(Newasp.Cookies_Name)("UserGrade") = Rs("UserGrade")
		Response.Cookies(Newasp.Cookies_Name)("UserGroup") = Rs("UserGroup")
		Response.Cookies(Newasp.Cookies_Name)("UserClass") = Rs("UserClass")
		Response.Cookies(Newasp.Cookies_Name)("UserToday") = Rs("UserToday")
		Response.Cookies(Newasp.Cookies_Name)("userlastip") = Newasp.GetUserIP
	End If
	Rs.Close
	Set Rs = Nothing
	'-----------------------------------------------------------------
	'系统整合
	'-----------------------------------------------------------------
	If API_Enable Then
		Response.Write API_SaveCookie
		Response.Flush
		If API_LoginUrl <> "0" Then
			Response.Write "<script language=JavaScript>"
			Response.Write "setTimeout(""window.location='"& API_LoginUrl &"'"",1000);"
			Response.Write "</script>"
			Response.End
		End If
	End If
	'-----------------------------------------------------------------
	'Response.Redirect("index.asp")
	Dim comeurlname,comeurl,Returnstr
	comeurl = Trim(Request("comeurl"))
	If Len(comeurl) = 0 Then
		comeurl = Request.ServerVariables("HTTP_REFERER")
	End If
	If instr(lcase(comeurl),"reg.asp")>0 Or instr(lcase(comeurl),"user/login.asp")>0 Or Trim(comeurl)="" Or (Not Newasp.CheckPost) Then
		comeurlname=""
		comeurl="index.asp"
		Returnstr = "<span id=jump>3</span> 秒钟后系统将自动返回控制中心"
	Else
		comeurl=comeurl
		comeurlname="<li><a href="&comeurl&">"&comeurl&"</a></li>"
		Returnstr = "<span id=jump>3</span> 秒钟后系统将自动返回"
	End If
	HtmlContent = Replace(HtmlContent,"{$UserManageContent}", Newasp.HtmlSetting(9))
	HtmlContent = Replace(HtmlContent,"{$SiteName}", Newasp.SiteName)
	HtmlContent = Replace(HtmlContent,"{$UserName}", Request("username"))
	HtmlContent = Replace(HtmlContent,"{$ComeUrl}", comeurl)
	HtmlContent = Replace(HtmlContent,"{$ComeUrlName}", comeurlname)
	HtmlContent = Replace(HtmlContent,"{$ReturnStr}", Returnstr)
	Response.Write HtmlContent
End Sub
%>