www.gusucode.com > 中网景企业网站源码时尚版 2009.73码程序 > english/CheckLogin.asp

    <!--#include file="../opendb.asp" -->
<!-- #Include File="../common/md5.asp" -->
<%
'response.Charset = "gb2312"
select Case request("LoginAct")
case "CheckLogin"
response.write "<script>alert('hi');</script>"
Dim plippwd,iun,ipwd,stopus
plippwd="Please input username or password"
iun="invalid username"
ipwd="invalid password"
stopus="sorry, you have not be passed or stoped service"

Dim LoginUserName,Loginpassword,usercookies,userip,GetUserID
LoginUserName=left(trim(Request("username")),20)
Loginpassword=left(trim(Request("password")),20)
usercookies=Request.Form("usercookies")
LoginUserName=sqlchkchar(LoginUserName)
Loginpassword=sqlchkchar(Loginpassword)
Loginpassword=MD5(Loginpassword)

If LoginUserName="" or Loginpassword="" Then
	response.write "<div class=LoginMess_error>"&plippwd&"</div>"
End If
if usercookies="" then usercookies="0"

rs.open "select UserID,UserName,UserPassword,IsLocked,isPassed,weblevel from cnk_users where UserName='"&LoginUserName&"'",conn,1,3
If rs.recordcount=0 Then
	response.write "<div class=""LoginMess_error red"">"&iun&"</div>"
	rs.close
Else
	If rs("UserPassword")<>Loginpassword Then
		response.write "<div class=""LoginMess_error red"">"&ipwd&"</div>"
		rs.close
	Else
		If rs("IsLocked")=1 or rs("isPassed")=0 Then 
			response.write "<div class=""LoginMess_error red"">"&stopus&"</div>"
			rs.close
			'response.End
		Else'登录成功
			Select Case usercookies
			Case "0"
				Response.Cookies(cookies_name)("UserID")=rs("UserID")
	    		Response.Cookies(cookies_name)("UserName")=LoginUserName
				Response.Cookies(cookies_name)("UserPwd")=Loginpassword
				Response.Cookies(cookies_name)("weblevel")=rs("weblevel")
			Case "1"
   				Response.Cookies(cookies_name).Expires=Date+1
				Response.Cookies(cookies_name)("UserID")=rs("UserID")
	    		Response.Cookies(cookies_name)("UserName")=LoginUserName
				Response.Cookies(cookies_name)("UserPwd")=Loginpassword
				Response.Cookies(cookies_name)("weblevel")=rs("weblevel")
			Case "2"
				Response.Cookies(cookies_name).Expires=Date+30
				Response.Cookies(cookies_name)("UserID")=rs("UserID")
	    		Response.Cookies(cookies_name)("UserName")=LoginUserName
				Response.Cookies(cookies_name)("UserPwd")=Loginpassword
				Response.Cookies(cookies_name)("weblevel")=rs("weblevel")
			Case "3"
				Response.Cookies(cookies_name).Expires=Date+365
				Response.Cookies(cookies_name)("UserID")=rs("UserID")
	    		Response.Cookies(cookies_name)("UserName")=LoginUserName
				Response.Cookies(cookies_name)("UserPwd")=Loginpassword
				Response.Cookies(cookies_name)("weblevel")=rs("weblevel")
			End Select

			userip=GetRealIP()
			conn.execute("update cnk_users set Jifen=Jifen+2,LastLoginIP='"&userip&"',LastLoginTime='"&now()&"',LoginTimes=LoginTimes+1 where UserID="&rs("UserID")) '登录加分

			If isBBS=1 Then
			Call userjibie(LoginUserName)

			Dim rsjb,gc,gr
			set rsjb=conn.execute("select UserLevel,Jibie from cnk_users where UserName='"&LoginUserName&"'")
			set gc=conn.execute("select GroupRight from Cnk_Jibie where LevelName='"&rsjb(1)&"'")
			gr=gc(0)
			Response.Cookies(cookies_name)("UserGroupRight")=gr
			If rsjb(0)>0 Then
				session.timeout=60
				session("GroupRight")=gr
			End If
			End If

			rs.close
		End If
	End If
End If
call closedb()

case "LoginOut"
	Response.Cookies(cookies_name)("username")=""
	Response.Cookies(cookies_name)("userid")=""
	Response.Cookies(cookies_name)("UserLevel")=""
	Response.Cookies(cookies_name)("UserGroupRight")=""
end select

username=Request.Cookies(cookies_name)("username") '虽然重复,还得要这行
If username<>"" Then
%>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1">
 <form name="formu" method="post"> <tr>
    <td colspan="4" align="center"><div class="LoginMess_error">Welcome,<font color="#FF9900"><b><%=UserName%></b></font></div></td>
    </tr>
  <tr>
    <td width="6%">&gt;&gt;</td>
    <td width="47%"><a href="users.asp">User Center</a></td>
    <td width="5%">&gt;&gt;</td>
    <td width="42%"><a href="users.asp?action=modiinfo&subtitle=Edit My Info">Edit My Info</a></td>
  </tr>
  <tr>
    <td>&gt;&gt;</td>
    <td><a href="users.asp?action=myorder&subtitle=My Order">My Order</a></td>
    <td>&gt;&gt;</td>
    <td><a href="users.asp?action=modipwd&subtitle=Modify Password">Modify Password</a></td>
  </tr>
  <tr>
    <td>&gt;&gt;</td>
    <td><a href="users.asp?action=myguestbook&subtitle=My Guestbook">My Guestbook</a></td>
    <td>&gt;&gt;</td>
    <td><a href="users.asp?action=myfavorite&subtitle=My Favorite">My Favorite</a></td>
  </tr>
  <tr>
    <td colspan="4" align="center">
      <% If isImgButton=0 Then %>
		  <input type="button" name="btnb" value="Sign Out" class="button" onclick="UserLoginOut();" />
		<% Else %>
          <a href="javascript:void(0);" onclick="UserLoginOut();"><img src="<%=UpDir%>images/button_signout_en.gif" border="0" /></a>
		<% End If %>
      <input name="LoginAct" type="hidden" id="LoginAct" value="LoginOut" /></td>
    </tr>
  </form>
</table>
<%
else
response.write "<form name=""cmt"" method=""post"">"
response.write "<div class=""leftusernamebox"">User Name:</div>"
response.write "<div class=""leftinputbox""><input name=""username"" type=""text"" class=""input"" size=""13"" maxlength=""20"" /></div>"
response.write "<div class=""leftusernamebox"">Password:</div>"
response.write "<div class=""leftinputbox""><input name=""password"" type=""password"" class=""input"" size=""13"" maxlength=""20"" /></div>"
response.write "<div class=""clearboth""></div>"
response.write "<div id=userloginMess class=LoginErMess></div>"
response.write "<div align=""center"">"
If isImgButton=0 Then
response.write "<input type=""submit"" name=""LoginSubmit"" value=""Submit"" onclick=""UserNeedLogin();"" class=""button"" style=""width:50px"" /> <input type=""button"" name="""" value=""Register"" onclick=""window.open('users.asp?action=register');"" class=""button"" style=""width:60px"" />  <input type=""button"" name=""fgpwd"" value=""Forget?"" onclick=""window.open('users.asp?action=forgetpwd&subtitle=Get back Password');"" class=""button"" style=""width:60px"" />"
Else
response.write "<input type=""image"" name=""imageField"" src="""&UpDir&"images/button_signin_en.gif"" onclick=""UserNeedLogin();"" /> <a href=""javascript:void(0);"" onclick=""window.open('users.asp?action=forgetpwd');""><img src="""&UpDir&"images/button_fgpwd_en.gif"" border=""0"" /></a> <a href=""javascript:void(0);"" onclick=""window.open('users.asp?action=register');""><img src="""&UpDir&"images/button_register_en.gif"" border=""0"" /></a>"
End If
response.write "<input name=""yuyan"" type=""hidden"" id=""action"" value=""0"" />"
response.write "<input type=""hidden""value=""CheckLogin""  name=""LoginAct"" />"
response.write "</div>"
response.write "</form>"
end if	
%>