<!--#include file="Inc.asp"-->
<!--#include file="Inc/Md5.asp"-->
<%
BBS94KK.Head"论坛登陆"
Dim Action
Action=Lcase(Request.querystring("action"))
If len(Action)>10 Then BBS94KK.GotoErr(1)
Select Case Action
	Case"exit":ExitLogin()
	Case"login":CheckLogin()
	Case else:Mian()
End select
BBS94KK.Footer()
Set BBS94KK=Nothing


Sub Mian()
Dim S
S=Request.ServerVariables("HTTP_REFERER")
If instr(lcase(S),"login.asp")>0 or instr(lcase(S),"error.asp")>0 then
Else
Session(CacheName&"BackURL")=S
End If
S="<form method=""post"" style=""margin:0px"" action=""login.asp?action=login"">"
S=S&BBS94KK.Row("<b>请输入您的用户名：</b>","<input name=""name"" type=""text"" class=""submit"" size=""20"" /> <a href=""Register.asp"">没有注册？</a>","65%","")
S=S&BBS94KK.Row("<b>请输入您的密码：</b>","<input name=""Password"" type=""password"" size=""20"" /> <a href=""UserSetup.asp?Action=ForgetPassword"">忘记密码？</a>","65%","")
If BBS94KK.Info(14)="1" Then
	S=S&BBS94KK.Row("<b>请输入右边的验证码：</b>",BBS94KK.GetSafeCode,"65%","")
Else
	S=S&"<input name=""safecode"" type=""hidden"" value=""94kk"" />"
End If
S=S&BBS94KK.Row("<b>Cookie 选项：</b>","<input type=radio  name=""cookies"" value=""0"" checked />不保存<br /><input type=radio  name=cookies value=""1"" />保存一天<br /><input type=radio  name=cookies value=""30"" />保存一月<br /><input type=radio  name=cookies value=""365"" />保存一年","65%","")
S=S&BBS94KK.Row("<b>选择登陆方式：</b>","<input type=radio value=""1"" checked name='hidden' />正常登陆<br /><input type='radio' value='2' name='hidden' />隐身登陆","65%","")
S=S&"<div style="" padding:5px;BACKGROUND: "&BBS94KK.SkinsPIC(2)&";"" align=""center""><input Class='login' type=""submit"" value="" 登  陆 "" /></div></form>"
BBS94KK.ShowTable"用户登陆",S
End Sub

Sub CheckLogin()
	With BBS94KK
	Dim Rs,UserName,Password,IsHidden,CookiesDate,Content,SafeCode,S
	.CheckMake
	If .Info(10)<>"0" Then
		If Session(CacheName&"LoginTime")+.Info(10)/1440>now() then .GotoErr(5)
	End If
	UserName=Request.Form("name")
	Password=Request.Form("password")
	IsHidden=Request.Form("hidden")
	SafeCode=Request.Form("safecode")
	CookiesDate=.CheckNum(Request.Form("cookies"))
	If UserName="" or Password="" Then .GoToErr(6)
	If .Info(14)="1" Then
		If SafeCode<>Session("Safecode") or Session("SafeCode")="" Then .GotoErr(8)
	End If
	If Not (.Fun.Checkname(UserName) OR .Fun.CheckPassword(Password)) then .GotoErr(16)
	If .SafeBuckler(UserName,.MyIP,0) Then .Alert"94KKBBS安全盾已启动！\n\n对不起，你尝试登陆错误超过3次，今天不能再登陆论坛。\n你的信息已被系统记录！","Index.asp"
	Password=MD5(Password)
	Set Rs = .Execute("select top 1 Id,Name,Password,Isdel,LastTime From [KK_User] where name='"&UserName&"' and password='"&Password&"' and (Isdel=0 or Isdel=2)")
	If Rs.Eof then
		.SafeBuckler UserName,.MyIP,1
		.GotoErr(9)
	ElseIf Rs(3)=2 Then
		.GotoErr(78)
	Else
		.LetMemor "","MyID",Rs(0)
		.LetMemor "","MyName",Rs(1)
		.LetMemor "","MyPassword",Password
		.LetMemor "","MyHidden",IsHidden
		.LetMemor "","CookiesDate",CookiesDate
		.LetMemor "","LastTime",Rs(4)
		Session(CacheName & "login")="1"
		If Int(CookiesDate)>0 Then	Response.Cookies(CacheName).Expires=date+Int(CookiesDate)
		.Execute("update [KK_user] set LastTime='"&.NowBbsTime&"',LastIp='"&.MyIp&"' where ID="&Rs(0))
		Session(CacheName&"LoginTime")=now()
		S=Session(CacheName&"BackURL")
		If S="" Then S="Index.asp"
		Content="<meta http-equiv=refresh content=2;url=index.asp /><div style='margin: 15px;line-height: 150%'><li><b>3</b> 秒钟后将自动返回首页</li><li><a href='index.asp'>立即进入论坛首页</a></li><li><a href="&S&">返回刚才浏览的页面</a><br></div>"
	End if
	Rs.Close
	Set Rs=Nothing
	.ShowTable"登陆成功",Content
	End With
End Sub

Sub ExitLogin()
	BBS94KK.SetMemorEmpty()
	BBS94KK.ShowTable "退出论坛","<div style='margin: 15px;line-height: 150%'><li>已经成功的退出论坛</li><li><a href='login.asp'>重新登陆</a></li><li><a href='index.asp'>进入论坛首页</a></li></div>"
End Sub
%>
