<!-- #include file="conn.asp" -->
<!-- #include file="cls_main.asp" -->
<!-- #include file="cls_md5.asp" -->
<% 	Dim Mesky
	Set Mesky = New cls_main
	Call Mesky.Loadsetting()
	dim arrPage,arrMainPage
	arrPage = Split(Mesky.ReadStylePage("Style_Down_Search"),"<!--|||-->")
	arrMainPage = Split(Mesky.ReadStylePage("Style_Down_Main"),"<!--|||-->")
	Response.Write(Replace(arrMainPage(0),"{$page_title}","用户注册"))
	Response.Write(arrMainPage(1))
	Response.Write(arrMainPage(2))
	
	Select Case Request("action")
	Case "login"	
		call checklogin()
	Case "logout"
		Call logout()
	Case Else
		'Response.Write Mesky.System_Sn
		Call loginMain()
	End Select
	
	Response.Write(arrMainPage(5))
	
	Set Mesky = Nothing
	
Sub logout()
		Response.Cookies(Mesky.System_Sn)("MemberUserName") = ""
		Response.Cookies(Mesky.System_Sn)("MemBerUserID") = ""
		Response.Cookies(Mesky.System_Sn)("MemberUserPassword") = ""
		Response.Cookies(Mesky.System_Sn)("MemberUserClass") = ""
		Response.Cookies(Mesky.System_Sn)("MemberVipType") = ""
		Mesky.strMsg = "退出登录成功！"
		Call Mesky.SystemMsg()
End Sub
Sub checklogin()
    If Mesky.ChkPost = False Then
        Mesky.strMsg = "非法操作，不要从外部提交数据。"
        Call Mesky.SystemMsg
        Exit Sub
    End If
	Dim Rs
	dim UserName,Password,verifycode,CookieDate,FoundErr
	UserName = Mesky.checkStr(Trim(Request.Form("UserName")))
	Password = Trim(Request.Form("Password"))
	verifycode = Trim(Request.Form("CodeStr"))
	CookieDate = Request.Form("CookieDate")
	FoundErr = False
	
	If UserName = "" then
		FoundErr = True
		Mesky.strMsg = Mesky.strMsg & "<li>登录用户名不能为空！</li>"
	End If
	If Instr(username,"=")>0 or Instr(username,"%")>0 or Instr(username,chr(32))>0 or Instr(username,"?")>0 or Instr(username,"&")>0 or Instr(username,";")>0 or Instr(username,",")>0 or Instr(username,"'")>0 or Instr(username,",")>0 or Instr(username,chr(34))>0 or Instr(username,chr(9))>0 or Instr(username,"")>0 or Instr(username,"$")>0 Then
		FoundErr = True
		Mesky.strMsg = Mesky.strMsg & "<li>您填写的用户名中包含非法字符，请返回刷新页面后重新输入。"
	End If
	If Password = "" then
		FoundErr = True
		Mesky.strMsg = Mesky.strMsg & "<li>登录密码不能为空！"
	End If
	If verifycode = "" Then
		FoundErr = True
		Mesky.strMsg = Mesky.strMsg & "<li>登录验证码不能为空！"
	End If
	If Not Mesky.CodeIsTrue() Then
		founderr = True
		Mesky.strMsg = Mesky.strMsg & "<li>验证码校验失败，请返回刷新页面后再输入验证码。"
	End If
	If FoundErr then
		Call Mesky.SystemMsg()
		Exit Sub
	End If
	Set Rs = Mesky.Execute("select UserID,UserName,UserPassword,UserState,UserClass,VipType,VipStartDate,VipEndDate,Points from Mesky_User where UserName = '" & UserName & "'")
	If Rs.eof and Rs.bof then
		Mesky.strMsg = "<li>系统中不存在您输入的用户名！"
		Set Rs = Nothing
		Call Mesky.SystemMsg
	Else
		If Rs("UserState") = 0 then
			FoundErr = True
			Mesky.strMsg = "<li>此用户已经锁定，请联系管理员。"
		ElseIf Rs("UserState") = 2 then
			FoundErr = True
			Mesky.strMsg = "<li>此用户正处于等待验证状态，不能登录系统，请联系管理员。"
		End If
		If Rs("VipType") = 2 Then
			If Rs("VipEndDate") < Now() then
				FoundErr = True
				Mesky.strMsg = "<li>此用户为限期用户，用户帐号已经过期，请联系管理员。"
			End If
		End If
		'Response.Write md5(Password,32)
		If Rs("UserPassword") <> md5(Password,32) then
			FoundErr = True
			Mesky.strMsg = "<li>你输入的密码错误，请返回后重新输入。"
		End If
		If FoundErr Then
			Set Rs = nothing
			Call Mesky.SystemMsg()
			Exit Sub
		End If
		Response.Cookies(Mesky.System_Sn).path="/"
		If isnull(CookieDate) or CookieDate="" then CookieDate="0"
		select case CookieDate
		case "0"
			Response.Cookies(Mesky.System_Sn)("usercookies") = CookieDate
		case "1"
  		 	Response.Cookies(Mesky.System_Sn).Expires=Date+1
			Response.Cookies(Mesky.System_Sn)("usercookies") = CookieDate
		case "2"
			Response.Cookies(Mesky.System_Sn).Expires=Date+31
			Response.Cookies(Mesky.System_Sn)("usercookies") = CookieDate
		case "3"
			Response.Cookies(Mesky.System_Sn).Expires=Date+365
			Response.Cookies(Mesky.System_Sn)("usercookies") = CookieDate
		End select
		Response.Cookies(Mesky.System_Sn)("MemberUserName") = Rs("UserName")
		Response.Cookies(Mesky.System_Sn)("MemBerUserID") = Rs("UserID")
		Response.Cookies(Mesky.System_Sn)("MemberUserPassword") = Rs("UserPassWord")
		Response.Cookies(Mesky.System_Sn)("MemberUserClass") = Rs("UserClass")
		Response.Cookies(Mesky.System_Sn)("MemberVipType") = Rs("VipType")
		Mesky.strMsg = "用户登录成功！"
		Call Mesky.SystemMsg()
	End If
	Set Rs = Nothing
End Sub
Sub loginMain()
%>
<script language="javascript">
<!--
function focus_in(){
	if (document.LoginForm.UserName.value ==""){
		document.LoginForm.UserName.focus();
	}else{
		document.LoginForm.Password.focus();
	}
}

function checkLoginForm(){
	var f = document.LoginForm;

	if (f.UserName.value == "") {
		alert("请输入会员帐号!");
		f.UserName.focus();
		return false;
	}

	if (f.Password.value == "") {
		alert("请输入帐号密码!");
		f.Password.focus();
		return false;
	}
	if (f.CodeStr.value == "") {
		alert("请键入您在图片中看到的字符,填写入验证码框!");
		f.CodeStr.focus();
		return false;
	}

	var checkOKv = "0123456789";
	var checkStrv = f.CodeStr.value;
	var allValidv = true;
	for (i = 0;  i < checkStrv.length;  i++)
	{
		ch = checkStrv.charAt(i);
		for (j = 0;  j < checkOKv.length;  j++)
		if (ch == checkOKv.charAt(j))
			break;
		if (j == checkOKv.length)
		{
			allValidv = false;
			break;
		}
	}

	if (!allValidv){
	alert("输入验证码字符不正规,请检查!");
	f.CodeStr.focus();
	return false;
	}
}
//-->
</script>
<TABLE cellSpacing=0 cellPadding=0 width=640 align=center border=0>
  <TR>
    <TD><IMG height=11 src="images/login_top.gif" width=640></TD>
  </TR>
  <TR>
    <TD background=images/login_top_bg.gif height=44><TABLE cellSpacing=0 cellPadding=0 width=590 align=center border=0>
        <TR>
          <TD width=128><IMG height=44 src="images/login.gif" width=100> </TD>
          <TD><FONT color=#888888>对不起,您所访问的内容需要本站<B>会员</B>才能查看,请输入会员帐号和密码!<BR>
            如果您不是本站的会员,请<B><A href="UserReg.asp">点此注册</A></B>成为我们的会员.</FONT></TD>
        </TR>
      </TABLE></TD>
  </TR>
  <TR>
    <TD background=images/login_bg.gif><TABLE cellSpacing=0 cellPadding=0 width=599 align=center border=0>
        <TR>
          <TD vAlign=top colSpan=2 height=4></TD>
        </TR>
        <TR>
          <TD vAlign=top width=350 height=300><TABLE cellSpacing=0 cellPadding=0 width=248 border=0>
              <TR>
                <TD width=10></TD>
                <TD vAlign=bottom width=238 height=20>&nbsp;</TD>
              </TR>
              <TR>
                <TD width=10></TD>
                <TD vAlign=bottom width=238 height=20><B><FONT color=#666666>请在下面输入您的帐号和密码</FONT><FONT color=#333333>.</FONT></B></TD>
              </TR>
            </TABLE>
            <FORM name=LoginForm onsubmit="return checkLoginForm()" action="UserLogin.asp" method=post target=_top>
              <input type="hidden" name="action" value="login">
              <TABLE cellSpacing=0 cellPadding=0 width=260 border=0>
                <TR>
                  <TD background=images/login_bg1.gif height=180><table  border="0" align="center" cellpadding="3" cellspacing="1">
                      <tr>
                        <td>用户名：
                          <input name="UserName" type="text" id="UserName" size="20" maxlength="20"></td>
                      </tr>
                      <tr>
                        <td>密　码：
                          <input name="Password" type="Password" id="Password" size="20" maxlength="20"></td>
                      </tr>
                      <tr>
                        <td>验证码： <input name="CodeStr" type="text" size="5" maxlength=4> 左框输入<img src="GetCode.asp"></td>
                      </tr>
                      <tr>
                        <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td valign="top">Cookie：</td>
                            <td><input type=radio name=CookieDate value=0 checked>不保存，关闭浏览器就失效<br>
	            <input type=radio name=CookieDate value=1>保存一天<br>
	            <input type=radio name=CookieDate value=2>保存一月<br>
	            <input type=radio name=CookieDate value=3>保存一年</td>
                          </tr>
                        </table>
                        </td>
                      </tr>
                    </table></TD>
                </TR>
                <TR>
                  <TD height=5></TD>
                </TR>
              </TABLE>
              <TABLE cellSpacing=0 cellPadding=0 width=260 border=0>
                <TR>
                  <TD width=10></TD>
                  <TD width=238 height=30 align="right"><input type="submit" name="Submit" value=" 登  录 ">
                  ·<A href="UserGetPassword.asp">取回密码</A>
				  ·<A href="UserReg.asp" target=_blank>注册帐号</A></TD>
                </TR>
                <TR>
                  <TD></TD>
                  <TD height=35><FONT color=#999999>本站注册会员享有增值服务以及全新的个人服务,请查看会员服务条款!</FONT></TD>
                </TR>
              </TABLE>
            </form></TD>
          <TD vAlign=center align=middle width=250 height=350></TD>
        </TR>
      </TABLE>
      <TABLE cellSpacing=0 cellPadding=0 width=599 align=center border=0>
        <TR bgColor=#e8e8e8>
          <TD noWrap colSpan=2 height=2></TD>
        </TR>
        <TR bgColor=#f7f7f7>
          <TD width=249 height=30>&nbsp;&nbsp;&nbsp; <FONT color=#2a46bd><B><FONT color=#55802b>广告信息</FONT></B></FONT></TD>
          <TD align=middle width=350 height=30>&nbsp;</TD>
        </TR>
        <TR bgColor=#f7f7f7>
          <TD colSpan=2 align=middle bgColor=#f7f7f7><table width="98%"  border="0" cellspacing="1" cellpadding="3">
              <tr align="center">
                <td><img src="images/login_ad.gif" width="161" height="83"></td>
                <td><img src="images/login_ad.gif" width="161" height="83"></td>
                <td><img src="images/login_ad.gif" width="161" height="83"></td>
              </tr>
            </table></TD>
        </TR>
        <TR bgColor=#f7f7f7>
          <TD colSpan=2>&nbsp;</TD>
        </TR>
        <TR>
          <TD noWrap bgColor=#e8e8e8 colSpan=2 height=2></TD>
        </TR>
      </TABLE>
	<TR>
    <TD><IMG src="images/login_dw.gif" width="640" height="13"></TD>
  </TR>
</TABLE>
<br>
<% End sub %>
