<!-- #include file="include/config.asp" -->
<!-- #include file="include/admin_fir.asp" -->
<!-- #include file="include/jk_encrypt.asp" -->
<!-- #include file="include/jk_md5.asp" -->
<%
if action="logout" then
  session.abandon
  call format_redirect("../main.asp")
end if

if session(session_for&"admin")="joekoe_admin" and session(session_for&"admines")=login_username then
  call format_redirect("index.asp")
end if

dim achk,nsort,username2
nsort="login"
tit="管理后台"
%>
<html>
<head>
<title><%response.write joekoe_cms.web_name%> - <%response.write tit%></title>
<meta http-equiv=Content-Type content=text/html; charset=gb2312>
<link type=text/css href='../../../images/admin/admin_joekoe.css' rel=stylesheet>
<style>
<!--
body { background-color: #ffffff; }
tr { background-color: #ffffff; }
.tr_val { background-color: #fdfdfd; }
.input_login
{
  border-right: #ffffff 0px solid; border-top: #ffffff 0px solid; font-size: 9pt;
  border-left: #ffffff 0px solid; border-bottom: #ffffff 0px solid; height: 16px;
}
.input_val
{
  border-right: #ffffff 0px solid; border-top: #ffffff 0px solid; font-size: 9pt;
  border-left: #ffffff 0px solid; border-bottom: #c0c0c0 1px solid; height: 16px;
  background-color: #fdfdfd;
}
-->
</style>
<script language=javascript src='../../../images/admin/admin.js'></script>
<script language=javascript src='../../../style/joekoe_select.js'></script>
</head>
<body topmargin=0 leftmargin=0>
<center>
<table border=0 width='100%' height='96%'>
<tr>
<td width='100%' height='100%' align=center>
  <table border=0 width=350 height='96%'>
  <tr><td align=center>
<%
if trim(request.form("admin_log"))="ok" then
  achk=admin_chk()
  if achk then
    login_username=username2
    call admin_event("成功登陆管理后台。",0,0)
    call format_redirect("admin.asp")
  else
    login_username=username2
    call admin_event("登陆管理后台失败。",0,0)
    response.write "<script language=javascript>alert(""登陆失败！\n\n请重新登陆……"");history.back(1);</script>"
  end if
else
  call admin_login()
end if
%>  </td></tr>
  </table>
</td></tr>
<%
call admin_ender(0)

sub admin_login()
%>
<table border=0 cellspacing=0 cellpadding=0 width=526>
<form name=admin_frm action='?' method=post>
<input type=hidden name=admin_log value='ok'>
<tr><td colspan=2><img src='../../../images/admin/al_top.gif' border=0></td></tr>
<tr><td colspan=2>
  <table border=0 cellspacing=0 cellpadding=0 width=526>
  <tr>
  <td width=155><img src='../../../images/admin/al_username.gif' border=0></td>
  <td width=105 background='../../../images/admin/al_body_bg.gif'><input type=text name=username value='<%response.write login_username%>' size=15 maxlength=20 class=input_login></td>
  <td width=93><img src='../../../images/admin/al_password.gif' border=0></td>
  <td width=105 background='../../../images/admin/al_body_bg.gif'><input type=password name=password value='' size=15 maxlength=20 class=input_login onmouseover=this.focus()></td>
  <td width=68><img src='../../../images/admin/al_body_right.gif' border=0></td>
  </tr>
  </table>
</td></tr>
<tr><td colspan=2>
  <table border=0 cellspacing=0 cellpadding=0 width=526>
  <tr>
  <td width=77><img src='../../../images/admin/al_end_left.gif' border=0></td>
  <td width=339>
    <table border=0 cellspacing=0 cellpadding=0 width=339>
    <tr><td height=49 background='../../../images/admin/al_end_bg.gif' align=center>
      <table border=0>
      <tr class=tr_val>
      <td>验证码：</td>
      <td><input type=password name=valcode value='' size=18 maxlength=20 class=input_val></td>
      <td width=10></td>
      <td>同时登陆前台：</td>
      <td><input type=checkbox name=logins value='yes'></td>
      </tr>
      </table>
    </td></tr>
    <tr><td><img src='../../../images/admin/al_end_end.gif' border=0></td></tr>
    </table>
  </td>
  <td width=110>
	<img src='../../../images/admin/al_end_right.gif' border=0 onclick="javascript:admin_login_chk();" style="cursor: hand;"></td>
  </tr>
  </table>
</td></tr>
</form>
</table>
<script language=javascript>
<!--
function admin_login_chk()
{
  var username=document.admin_frm.username.value;
  var password=document.admin_frm.password.value;
  if (username=="" || username==null)
  {
    alert("&#23545;&#19981;&#36215;&#65281;\n\n&#35831;&#20808;&#36755;&#20837;&#30331;&#38470;&#29992;&#25143;&#21517;&#65281;");
    document.admin_frm.username.focus();
    return;
  }
  if (password=="" || password==null)
  {
    alert("&#23545;&#19981;&#36215;&#65281;\n\n&#35831;&#20808;&#36755;&#20837;&#30331;&#38470;&#23494;&#30721;&#65281;");
    document.admin_frm.password.focus();
    return;
  }
  document.admin_frm.submit();
}

document.admin_frm.password.focus();
-->
</script>
<%
end sub

function admin_chk()
  admin_chk=false
  dim username,password,founderr,rs,sql,id,power,hidden,valcode,logins
  username=code_admin("username",1,20)
  password=code_admin("password",1,20)
  valcode=trim(request.form("valcode"))
  logins=trim(request.form("logins"))
  username2=username
  founderr=""
  admin_chk=false
  if admin_valcode<>"" then
    if var_null(valcode)="" then exit function
    if jk_md5(valcode,"short")<>admin_valcode then exit function
  end if
  if symbol_name(username)=false or symbol_ok(password)=false then exit function
  if founderr="" then
    password=jk_md5(password,"short")
    sql="select top 1 popedom from user_data where username='"&username&"' and password='"&password&"' and power='"&format_power2(1,1)&"' and hidden=1"
    set rs=joekoe_cms.exec(sql,1)
    if rs.eof then
      rs.close
      exit function
    end if
    if logins="yes" then
      response.cookies(joekoe_cms.web_cookies)("login_username")=username
      response.cookies(joekoe_cms.web_cookies)("login_password")=jk_encrypt(password)
      response.cookies(joekoe_cms.web_cookies)("iscookies")="yes"
      response.cookies(joekoe_cms.web_cookies).expires=date+365
    end if
    session(session_for&"admin")="joekoe_admin"
    session(session_for&"admines")=username
    session(session_for&"popedom")=rs("popedom")
    rs.close
  end if
  admin_chk=true
end function
%>