www.gusucode.com > 全球营销软件站整站源码4月最新数据 4.0源码程序 > 801wyxqf\ask\login.asp

    <!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/md5.asp"-->
<!--#include file="inc/chkinput.asp"-->
<%
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"

Dim HtmlContent,Action,strReturnURL,Direct
strReturnURL = Trim(Request("ReturnURL"))
If CheckeIsURL(strReturnURL) Then
	If LCase(Mid(strReturnURL,8,Len(Request.ServerVariables("SERVER_NAME"))))=LCase(Request.ServerVariables("SERVER_NAME")) Then
		strReturnURL = Server.HTMLEncode(strReturnURL)
	Else
		strReturnURL = ""
	End If
Else
	strReturnURL = ""
End If
Action = NewAsp.CheckBadstr(Request("action"))
Direct = NewAsp.ChkNumeric(Request("direct"))
If NewAsp.UserID > 0 Then
	Response.Redirect (NewAsp.InstallDir)
End If

Select Case LCase(Action)
	Case "chklogin","chk"
		NewAsp.ChcekProxy(NewAsp.Asked_Setting(21))
		Call ChkLogin()
	Case "login"
		Call UserLogin()
	Case Else
		Call showmain()
End Select

NewAsp.CloseConn()

Sub showmain()
	HtmlContent = NewAsp.LoadTemplate("login")
	HtmlContent = Replace(HtmlContent, "{$HeadTitle}", "用户登录")
	HtmlContent = Replace(HtmlContent, "{$ReturnURL}", strReturnURL)
	HtmlContent = Replace(HtmlContent, "{$ClassID}", 0)
	Response.Write NewAsp.ArchiveHtml(HtmlContent)
End Sub

Sub ChkLogin()
	Dim Rs,SQL,i
	Dim username,loginpass,UserPassword,usercookies,strRandomcode,UserTitle
	Dim usersex
	Response.Write "<script language=""JavaScript"">function resetcode(){try{var obj=parent.document.getElementById('verifycodeimg');obj.src='" & NewAsp.InstallDir & "inc/getcode.asp?t='+Math.random();}catch(e){}}</script>"
	username = Trim(Request.Form("username"))
	If len(username)<2 Then
		Response.Write "<script>alert('友情提示!\n\n请填写您的用户名!');resetcode();</script>"
		Exit Sub
	Else
		If ChkIsBadstr(username) = False Then
			Response.Write "<script>alert('友情提示!\n\n用户名中包含非法字符!');resetcode();</script>"
			Exit Sub
		End If
		Dim RegSplitWords,RegValidWords
		RegValidWords = "update,select"
		RegSplitWords = Split(RegValidWords,",")
		For i = 0 To Ubound(RegSplitWords)
			If Instr(LCase(username),RegSplitWords(i))>0 Then
				Response.Write "<script>alert('友情提示!\n\n用户名中包含限制字符!');resetcode();</script>"
				Exit Sub
			End If
		Next
	End If
	username = NewAsp.RequestForm("username",35)
	loginpass = Trim(Request.Form("loginpass"))
	usercookies = NewAsp.ChkNumeric(Request.Form("usercookies"))
	If Len(loginpass) = 0 Then
		loginpass = Trim(Request.Form("password"))
	End If
	If loginpass = "" Then
		Response.Write "<script>alert('友情提示!\n\n您的密码不能为空!');resetcode();</script>"
		Exit Sub
	End If
	If CLng(NewAsp.Asked_Setting(23))=1 Then
		If Not NewAsp.CodeIsTrue() Then
			Response.Write "<script>alert('友情提示!\n\n您的验证码输入错误!');resetcode();</script>"
			Exit Sub
		End If
	End If
	UserPassword = Md5(loginpass,16)
	strRandomcode = NewAsp.Createpass
	If Not IsObject(Conn) Then ConnectionDatabase
	Set Rs = NewAsp.CreateAXObject("ADODB.Recordset")
	SQL = "SELECT * FROM NC_Ask_Users WHERE username='" & NewAsp.Checkstr(username) & "'"
	Rs.Open SQL, Conn, 1, 3
	If Rs.BOF And Rs.EOF Then
		Response.Write "<script>alert('友情提示!\n\n此用户不存在,请换一个用户名再登录!');resetcode();</script>"
		Exit Sub
	Else
		If UserPassword <> Rs("password") Then
			Response.Write "<script>alert('友情提示!\n\n用户或者密码输入错误,请重新填写用户信息!');resetcode();</script>"
			Exit Sub
		End If
		If Rs("Userlock") <> 0 Then
			Response.Write "<script>alert('友情提示!\n\n你的用户名已被锁定,如要开通此帐号,请联系管理员。!');resetcode();</script>"
			Exit Sub
		End If
		NewAsp.UserID = Rs(0)
		UserTitle = Rs("UserTitle")
		usersex = Rs("usersex")
		Rs("Randomcode") = strRandomcode
		Rs("lastIP") = NewAsp.UserTrueIP
		Rs("Enternum") = Rs("Enternum") + 1
		If DateDiff("h",ChkDateAndTime(Rs("lastime")),Now()) > 12 Then
			Rs("Points") = Rs("Points") + Newasp.ChkNumeric(NewAsp.Point_Setting(2))
			Rs("Experience") = Rs("Experience") + Newasp.ChkNumeric(NewAsp.Point_Setting(3))
			Rs("lastime") = Now()
		End If
		Rs.Update
	End If
	Rs.Close
	Set Rs = Nothing
	Dim StatUserID,UserSessionID
	StatUserID = NewAsp.checkStr(Trim(Request.Cookies(NewAsp.Asked_sn)("StatUserID")))
	If Not IsNumeric(StatUserID) Or StatUserID = "0" Then
		StatUserID = Replace(NewAsp.UserTrueIP,".","")
		UserSessionID = Replace(Startime,".","")
		If IsNumeric(StatUserID) = 0 or StatUserID = "" Then StatUserID = 0
		StatUserID = Ccur(StatUserID) + Ccur(UserSessionID)
	End If
	StatUserID = Ccur(StatUserID)

	Response.Cookies(NewAsp.Asked_sn).Path="/"
	If usercookies > 0 Then
		Response.Cookies(NewAsp.Asked_sn).Expires=Date+365
	End If
	Response.Cookies(NewAsp.Asked_sn)("UserName") = username
	Response.Cookies(NewAsp.Asked_sn)("StatUserID") = StatUserID
	Response.Cookies(NewAsp.Asked_sn)("UserTitle") = UserTitle
	Response.Cookies(NewAsp.Asked_sn)("PassWord") = UserPassword
	Response.Cookies(NewAsp.Asked_sn)("Randomcode") = strRandomcode
	Response.Cookies(NewAsp.Asked_sn)("usersex") = usersex
	Response.Cookies(NewAsp.Asked_sn)("userid") = NewAsp.UserID
	NewAsp.Execute("DELETE FROM NC_Ask_Online WHERE username='" & NewAsp.Checkstr(username) & "' Or id="&StatUserID)
	NewAsp.ReloadSetupCache NewAsp.AskedOnline-1,12
	If Len(strReturnURL) > 8 Then
		strReturnURL = strReturnURL
	Else
		strReturnURL = NewAsp.InstallDir
	End If
	Response.Write "<script language=""JavaScript"">"
	If Direct = 0 Then Response.Write "alert('恭喜您!登录成功');"
	Response.Write "try{top.location='" &strReturnURL& "';"
	Response.Write "}catch(e){}"
	Response.Write "</script>"
End Sub

Function ChkDateAndTime(datime)
	If IsNull(datime) Or IsDate(datime) = False Then
		ChkDateAndTime = Now()-1
		Exit Function
	End If
	ChkDateAndTime = datime
End Function

Sub UserLogin()
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<title>用户登录</title>
<style type="text/css" media="all">
body,td,input,select,textarea,a,div{font:12px Verdana, Arial, 宋体, sans-serif;color:#000;text-decoration:none;line-height:16px;}
body{background:#fff;margin:auto;}
li{list-style:none;padding:0;line-height:20px;}
form{margin:0;padding:0;}
h1,h2,h3,h4,h5,h6 {font-family:Verdana;font-size:12px;font-weight:400;}
.mainBody {background:#fff;border-top:1px solid #b5cfe8;line-height:18px;margin-bottom:8px;}
.mainBody h2 {clear:both;margin:0;letter-spacing:2px;height:22px;line-height:22px;background:#e7f5ff;color:#004299;text-align:center;font-weight:bold;}
</style>
<script language="JavaScript">
<!--
function chkloginform(obj){
	if(obj.username.value==""){
		alert("友情提示\n\n请输入用户名!");
		obj.username.focus();
		return false;
	}
	if(obj.loginpass.value==""){
		alert("友情提示\n\n请输入登录密码!");
		obj.loginpass.focus();
		return false;
	}
	try{
		if(obj.verifycode.value=="" || obj.verifycode.value==0){
			alert("友情提示\n\n请输入验证码!");
			obj.verifycode.focus();
			return false;
		}
	}
	catch(e){}
}
//-->
</script>
</head>
<body>
<div class="mainBody">
	<h2><span>用户登陆</span></h2>
	<iframe name="_hideframe" style="display:none;"></iframe>
	<table align="center" border="0" cellpadding="0" cellspacing="6">
	<form name="login_form" method="post" action="?action=chklogin" onSubmit="return chkloginform(this);" target="_hideframe">
	<input type="hidden" name="ReturnURL" id="ReturnURL" value="<%=strReturnURL%>"/>
	<input type="hidden" name="direct" id="direct" value="1"/>
		<tr>
		<td width="25%" align="right"><b>用 户 名:</b></td>
		<td width="75%"><input type="text" size="35" name="username" id="username" maxlength="30"/></td>
	</tr>
	<tr>
		<td align="right"><b>登录密码:</b></td>
		<td><input type="password" name="loginpass" id="loginpass" size="35" maxlength="35"/></td>
	</tr>
	<tr>
		<td align="right"><b>记住密码:</b></td>
		<td><input type="radio" name="usercookies" value="0" checked="checked"/>否&nbsp;&nbsp;
			<input type="radio" name="usercookies" value="1"/>是</td>
	</tr>
	<tr>
		<td align="right"><b>验 证 码:</b></td>
		<td><input type="text" size="10" name="verifycode" id="verifycode" maxlength="5"/>
		<img id="verifycodeimg" src="<%=NewAsp.InstallDir%>inc/getcode.asp" alt="验证码,看不清楚?请点击刷新验证码" style="cursor:pointer; vertical-align:middle;height:18px;" onclick="this.src='<%=NewAsp.InstallDir%>inc/getcode.asp?t='+Math.random()"/></td>
	</tr>
	<tr>
		<td align="right"></td>
		<td><input type="submit" name="submit" id="submit" value="用户登录"/>
		<input type="reset" name="reset" id="reset" value="重新填写"/></td>
	</tr>
	</form>
	</table>
</div>
<div style="clear:both"></div>
</body>
</html>
<%
End Sub

%>