<!-- #include file="include/skin.asp" -->
<!-- #include file="include/jk_md5.asp" -->
<%
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)
  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("user_main.asp")
end if

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

call web_head(0,0,3,0,0)
%>
<table border=0 cellspacing=0 cellpadding=0>
<tr><td><img src='<%response.write joekoe_cms.web_dir_skin%>main/user_login_main.gif' border=0><td></tr>
<tr><td align=center height=150 background='<%response.write joekoe_cms.web_dir_skin%>main/user_login_bg.gif'>
<%
select case action
case "login_chk"
  call login_chk()
case else
  call login_main()
end select
%>
<td></tr>
<tr><td><img src='<%response.write joekoe_cms.web_dir_skin%>main/user_login_end.gif' border=0><td></tr>
</table>
<%
call web_end(0,0)

sub login_main()
  dim old_url
  old_url=trim(request.querystring("old_url"))
  if var_null(old_url)<>"" then
    old_url="&old_url="&server.urlencode(old_url)
    response.write "<font class=red>请先注册并登陆本站再浏览前一页面</font>"
  end if
%>
<table border=0>
<form name=login_frm method=post action='login.asp?action=login_chk<%response.write old_url%>' onsubmit="return login_true()">
<tr><td align=center height=25>用户名称：&nbsp;<input type=text name=username size=15 maxlength=20 tabindex=1></td></tr>
<tr><td align=center>登陆密码：&nbsp;<input type=password name=password size=15 maxlength=20 tabindex=2></td></tr>
<tr><td align=center height=25 align=center><input type=checkbox id=id_memery_info name=memery_info value='yes'>&nbsp;<label for=id_memery_info id=label_memery_info>记住本次登陆</label>&nbsp;&nbsp;<input type=image src='skin/<%response.write joekoe_cms.web_skin%>/main/user_login_button.gif' border=0 align=absmiddle></td></tr>
<tr><td align=center>
  <table border=0>
  <tr>
  <td><a href='register.asp'><img src='images/index/user_register.gif' border=0></a></td>
  <td width=10></td>
  <td><a href='user_getpass.asp'><img src='images/index/user_getpass.gif' border=0></a></td>
  </tr>
  </table>
</td></tr>
</table>
<%
end sub

sub login_chk()
  dim username,password,gname,found_err,id,power,abate,hidden,face,old_url
  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,power,abate,hidden from user_data where username='"&username&"' and password='"&password&"'"
    set rs=joekoe_cms.exec(sql,1)
    if rs.eof then
      found_err=found_err&"+您输入的 <font class=red>用户名称</font> 和 <font class=red>登陆密码</font>  有错误！<br>" & _
	       found_err&"+请重新输入以并继续登陆本站！"
      response.write found_error(found_err,260)
    else
      username=rs("username")
      power=rs("power")
      abate=rs("abate")
      hidden=rs("hidden")
      if hidden=true and abate=false then
        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&"' 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" and 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>"
      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
    rs.close
  else
    found_err=found_err&"+请查阅有关 <a href='help.asp?action=register' target=_blank class=red>用户注册注意事项</a> 并重新填写。"
    response.write found_error(found_err,280)
  end if
end sub
%>