<!-- #include file="../include/skin.asp" -->
<!-- #include file="../include/jk_md5.asp" -->
<!-- #include file="../include/jk_ip_stop.asp" -->

<%

dim useripstop,ipopen,iplock,iplock2,username
useripstop=0

 sql="select * from jk_stopip where s_ip='"&user_ip&"'"
 set rs=joekoe_cms.exec(sql,1)
 if not rs.eof then
 iplock=rs("s_style")
 iplock2=rs("s_yj_stop")
 end if
 rs.close

if action="logout" then
  if symbol_name(login_username) then
    call joekoe_cms.exec("delete from user_login where l_username='"&login_username&"'",0)
  end if
  call cookies_clear(1)

  	   session("user_data")=empty
	   session("user_on")=""
  dim o_url
  o_url=trim(request.servervariables("http_referer"))
  if instr(o_url,"login.asp")>0 or instr(o_url,"user_")>1 or o_url="" then o_url="./"
  call format_redirect(o_url)
end if

if login_username<>"" and login_password<>"" then
  call format_redirect("./")
end if


index_url="index"
tit_fir=format_menu(index_url)
tit="用户登陆"

call web_head(0,0,2,0,0)
%>

<%
ipopen=int(format_mid_num(33))

	  select case action
        case "login_chk"
        call login_chk()
        case else
        call login_main()
      end select
%>

<table><tr><td height="50"></td></tr></table>
<%if int(format_mid_num(46))=0 then%>
<script language=JavaScript src='../style/softkeyboard.js'></script>
<script>
window.onload=
	function ()
	{
		password1=null;		
		initCalc();
		Load();
	}
</script>
<%
end if



call web_end(0,0)

sub login_main()

' if iplock<>0 or iplock2<>0 then
'  call user_ip_stop1(1)
' end if
 if useripstop=0 then
  dim old_url
  old_url=trim(request.querystring("old_url"))
  if var_null(old_url)<>"" then
    if old_url="back" then old_url=request.servervariables("http_referer")
    old_url="&old_url="&server.urlencode(old_url)
   ' response.write "<font class=red>请先注册并登陆本站再浏览前一页面</font>"
  end if
%>


            <TABLE cellSpacing=0 cellPadding=0 width=600 height="300" align=center border=0>
			<form name=login_frm method=post action='login.asp?action=login_chk<%response.write old_url%>' onsubmit="return login_true()">
              <TR>
                <TD width=27>
				<IMG height=300 src="login/login_main_02.gif"  width=162></TD>
                <TD vAlign=top width=547>
				
                  <TABLE cellSpacing=0 cellPadding=0 width=412 border=0  >
                    <TR>
                      <TD colspan="2">
					  <IMG height=116 src="login/login_main_03.gif" width=412></TD></TR>
                      <TR ><td>
							<table cellpadding="0" cellspacing="0" background=login/login_main_05.gif width=412 height=65>
							<tr >
                            <TD class=font width=250 align=center valign="middle"  >
                              用户名：&nbsp;<input class=txt type=text name=username size=15 maxlength=20 tabindex=1><br>
							  密　码：&nbsp;<input class=txt type=password name=password size=15 maxlength=20 tabindex=2<%if int(format_mid_num(46))=0 then%> readOnly onKeyDown="Calc.password.value=this.value" onChange="Calc.password.value=this.value" onclick="password1=this;showkeyboard();this.readOnly=1;Calc.password.value=''"<%end if%>><br>
							 &nbsp;&nbsp;<input type=checkbox id=id_memery_info name=memery_info value='yes' class=nocolor>&nbsp;<label for=id_memery_info id=label_memery_info>记住登陆</label>&nbsp;&nbsp;<a href='register.asp?action=resend'>重发验证邮件！</a>
							  </TD>
							
                            <TD width=162 height=65  align=left valign="middle">
							<input type=image src="login/login_main_09.gif"   class=logimg> 
							</TD>
							</TR>
                        </table></td></tr>

					  <TR>
                      <TD  colspan="2"><IMG name="login_main_04" height=119 src="login/login_main_04.gif" width=412 border=0 usemap="#m_login_main_04"></TD></TR>
<map name="m_login_main_04">
<area shape="poly" coords="10,50,241,50,241,92,10,92,10,50" href="getpass.asp" title="找回密码" alt="找回密码" >
<area shape="poly" coords="10,5,241,5,241,47,10,47,10,5" href="register.asp" title="注册新用户" alt="注册新用户" >
</map>
					  </TABLE>
			</TD></TR>
				</FORM>
			</TABLE>


<%
end if
end sub

sub login_chk()
  GetCode=trim(request.form("Code"))
  valicode=trim(session("Code"))
  if GetCode<>"" and GetCode<>valicode then
response.write"<script>alert(""验证码错误！"");location.href=""javascript:history.go(-1)"";</script>"
response.end
end if

   if iplock<>0 or iplock2<>0 then
     call user_ip_stop1(1)
   end if
   if useripstop=0 then
  dim password,gname,found_err,id,power,abate,hidden,face,old_url,num,startim,endtim,s_id
  old_url=var_null(request.querystring("old_url"))
  if symbol_name(login_username)=true then
    username=login_username
  else
    username=trim(request.form("username"))
  end if
  if symbol_ok(login_password)=true then
    password=login_password
  else
    password=trim(request.form("password"))
    password=jk_md5(password,"short")
  end if

  found_err=""
  if symbol_name(username)=false then
    found_err=found_err&"+您输入的 <font class=red>用户名称</font> 为空或不符合相关规则！<br>"
  end if
  if symbol_ok(password)=false then
    found_err=found_err&"+您输入的 <font class=red2>登陆密码</font> 为空或不符合相关规则！<br>"
  end if
  



 if found_err="" then
  	sql="select top 1 id,username,u_ip,power,abate,hidden from user_data where username='"&username&"' and password='"&password&"'"
    set rs=joekoe_cms.exec(sql,1)
    if rs.eof then
	  if ipopen=1 then
        found_err=found_err&"+您输入的 <font class=red>用户名称</font> 和 <font class=red>登陆密码</font>  有错误！<br>" & _
        found_err&"+请重新输入以并继续登陆本站！"
        response.write found_error(found_err,260)
	    rs.close
	    exit sub
	  else
	    call user_ip_stop2(0)
	 end if
    else
      username=rs("username")
      power=rs("power")
      abate=rs("abate")
      hidden=rs("hidden")
'--------------------------------用户登陆IP限制开始----------------------------------------
 if rs("u_ip")="" then
 else
  if rs("u_ip")<>joekoe_cms.ip_sys(0) then 
   response.write"<script>alert('您现在登陆的用户帐号为"&username&"，登陆IP是"&joekoe_cms.ip_jks(0)&"。\n\n该帐号已经指定为IP是"&rs("u_ip")&"的用户登录。系统禁止同一帐号同时在不同IP多次登陆！\n\n如需修改指定IP，请及时与管理员"&web_dim(3)&"（E_mail："&web_dim(4)&"）联系。');window.close(); </script>"
   response.end  
  end if
 end if
'--------------------------------用户登陆IP限制结束----------------------------------------

      if hidden=true and abate=false then
          call user_dl_cf()
		  if usercf=1 then
		  exit sub
		  else
		response.cookies(joekoe_cms.web_cookies).path=joekoe_cms.web_path
        response.cookies(joekoe_cms.web_cookies)("time_load")=DateAdd("s",-5,joekoe_cms.now_time)
        response.cookies(joekoe_cms.web_cookies)("login_username")=username
        response.cookies(joekoe_cms.web_cookies)("login_password")=jk_encrypt(password)

        sql="update user_data set last_tim='"&joekoe_cms.now_time&"',login_num=login_num+1,last_ip='"&joekoe_cms.ip_sys(0)&"' where username='"&username&"'"
          call joekoe_cms.exec(sql,0)
        gname=request.cookies(joekoe_cms.web_cookies)("guest_name")
        gname=joekoe_cms.code_html(gname,1,0)
        if var_null(gname)<>"" then
          call joekoe_cms.exec("delete from user_login where l_username='"&gname&"'",0)
        end if
        
      if trim(request.form("memery_info"))="yes" then
	    response.cookies(joekoe_cms.web_cookies)("iscookies")="yes"
      end if
        if old_url<>"" then
	    rs.close
	    call format_redirect(old_url)
        end if
	  if trim(request.form("re_log"))="yes" or trim(request.servervariables("http_referer"))<>"" then
	  rs.close
	  call format_redirect(request.servervariables("http_referer"))
	 end if	
	    response.write "<meta http-equiv='refresh' content='"&dim_num(21)&"; url="&index_url&".asp'><br><br><br>你好，<font class=red>"&username&"</font>&nbsp;你现在是 <font class=red>"&format_power(power,1)&"</font> 登陆模式<br><br>" & _
		       vbcrlf & "<a href='user_main.asp'>进入用户中心</a>&nbsp;┋&nbsp;<a href='login.asp?action=logout'>退出本次登陆</a><br><br><br>"
     end if    
     else
        if abate=true then
          response.write "<font class=red>您的计时用户帐号已过期！</font><br><br>请与网站管理员联系申请续费计时。"
        else
          response.write "<font class=red>您的用户帐号还未审核！</font><br><br>请与查收您在注册时的电子邮箱并确认您的注册信息。"
        end if
      end if
    end if

  else
  call user_ip_stop2(0)
 end if
end if
end sub
%>
