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

if web_login=0 then web_login=2
if session("joekoe_online_admin")="jzhaifeng_0928" and session("joekoe_online_admines")=login_username then
  format_redirect("admin.asp")
  response.end
end if
%>
<!-- #include file="include/jk_md5.asp" -->
<!-- #include file="include/conn.asp" -->
<html>
<head>
<title><%response.write web_var(web_config,1)%> - 管理后台登陆</title>
<meta http-equiv=Content-Type content=text/html; charset=gb2312>
<link rel=stylesheet href='images/<%response.write web_var(web_config,5)%>/joekoe.css' type=text/css>
</head>
<body leftmargin=0 topmargin=0 bgcolor=#ededed>
<table border=0 width=100% height=100% cellspacing=0 cellpadding=3>
<tr>
<td width=100% align=center height=100%>
<%
dim achk
if trim(request.form("admin_log"))="ok" then
  achk=admin_chk()
  if achk="yes" then
    close_conn
    response.redirect "admin.asp"
    response.end
  else
    response.write admin_login()
  end if
else
  response.write admin_login()
end if

close_conn

function admin_login()
            dim num1
			dim rndnum
			Randomize
			Do While Len(rndnum)<4
			num1=CStr(Chr((57-48)*rnd+48))
			rndnum=rndnum&num1
			loop
			session("verifycode")=rndnum
%><table border=0 width=400 border=0 cellspacing=0 cellpadding=3 class=tableBorder><tr>
<td align=center valign=center height=25 valign=top class=adminhead>
<font color=red>欢迎</font><font color=blue><%response.write web_var(web_config,1)%></font><font class=red><b>管理员登陆</b></font>
</td>
</tr>
<form action='admin_login.asp' method=post>
<input type=hidden name=admin_log value='ok'>
<tr height=25 align=center>
<td width="30%" class=forumRowHighlight>
用户名&nbsp;&nbsp;&nbsp;&nbsp;<input type=text name=username value='<%response.write login_username%>' size=20>
</td></tr>
<tr height=25 align=center>
<td width="30%" class=forumRowHighlight>
密&nbsp;&nbsp;&nbsp;码&nbsp;&nbsp;&nbsp;&nbsp;<input type=password name=password size=20 maxlength=20>
</td></tr>
<tr height=25 align=center>
<td width="30%" class=forumRowHighlight>
验证码&nbsp;&nbsp;&nbsp;&nbsp;<INPUT name=verifycode type=text size=6 maxlength=4>  请输入 <b><span style="background-color: #FFFFFF"><font color=#000000><%=session("verifycode")%></font></span></b></td></tr>
<tr height=25 align=center>
<td width="30%" class=forumRowHighlight>&nbsp;&nbsp;增加安全性&nbsp;<input type=checkbox name=safety value='yes' class=bg_3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;同时登陆前台&nbsp;<input type=checkbox name=logins value='yes' class=bg_3></td></tr>
<tr><td align=center height=30 class=forumRowHighlight>
<input type=submit value="确 定">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type=button value="取 消">
</td></form></tr class=forumRowHighlight>
<tr><td align=center height=60 align=bottom class=forumRowHighlight>
<font class=red_4>本次登陆在无活动状态20分钟后将自动注销</font>
</td></tr>
<tr><td align=center class=forumRowHighlight><%response.write web_var(web_error,4)%></td></tr>
</table><%
end function

function admin_chk()
  dim username,password,founderr,rs,sql,id,power,hidden,valcodes,valcode,safety,logins
  username=trim(request.form("username"))
  password=trim(request.form("password"))
  valcode=trim(request.form("valcode"))
  safety=trim(request.form("safety"))
  logins=trim(request.form("logins"))
  founderr="no"
  valcodes=web_var(web_config,12)
  if len(valcodes)>1 then
    if len(valcode)<1 then admin_chk=founderr:exit function
    if jk_md5(valcode,"short")<>valcodes then admin_chk=founderr:exit function
  end if


dim errmsg
	if request("verifycode")="" then
'errmsg=errmsg+"<br>"+"<li>请返回输入确认码。<li><b>返回后请刷新登陆页面后重新输入正确的信息。</b>"
'response.write errmsg
'response.end
    admin_chk=founderr:exit function
	elseif session("verifycode")="" then
'errmsg=errmsg+"<br>"+"<li>请不要重复提交，如需重新登陆请返回登陆页面。<li><b>返回后请刷新登陆页面后重新输入正确的信息。</b>"
'response.write errmsg
'response.end
    admin_chk=founderr:exit function
	elseif session("verifycode")<>trim(request("verifycode")) then
'errmsg=errmsg+"<br>"+"<li>您输入的确认码和系统产生的不一致，请重新输入。<li><b>返回后请刷新登陆页面后重新输入正确的信息。</b>"
'response.write errmsg
'response.end
		    admin_chk=founderr:exit function
	end if

	session("verifycode")=""


  if symbol_name(username)="no" then
    admin_chk=founderr:exit function
  end if
  if symbol_ok(password)="no" then
    admin_chk=founderr:exit function
  end if
  
  if founderr="no" then
    password=jk_md5(password,"short")
    sql="select popedom from user_data where username='"&username&"' and password='"&password&"' and power='"&format_power2(1,1)&"' and hidden=1"
    set rs=conn.execute(sql)
    if rs.eof and rs.bof then
      rs.close:set rs=nothing
      admin_chk=founderr:exit function
    else
      if login_username="" or logins="yes" then
        response.cookies("joekoe_online")("login_username")=username
        if safety<>"yes" and logins<>"yes" then response.cookies("joekoe_online")("login_password")=password
        call cookies_yes()
      end if
      session("joekoe_online_admin")="jzhaifeng_0928"
      session("joekoe_online_admines")=username
      session("joekoe_online_popedom")=rs("popedom")
      
      rs.close:set rs=nothing
      admin_chk="yes":exit function
    end if
    rs.close:set rs=nothing
  end if
end function
%></td></tr></table>
</body>
</HTML>