<!--#include file="setup.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="myadmin.asp"-->
<%
Dim GetCode,CacheName
Dim RefreshTime,ValidCodes,LawlessNum
Dim IsCodes,IsCheckLogin,ExpiresTime
RefreshTime = 10      '设置防刷新时间
IsCheckLogin = 1       '是否开启锁定登陆，1=开启，0=关闭
LawlessNum = "3"       '设置非法登陆多少次锁定登陆
ExpiresTime = 3        '设置锁定登陆后多少天才能再次登陆
IsCodes = 0           '是否开启登陆验证码，1=开启，0=关闭
ValidCodes = "admin"   '设置登陆验证码
If CInt(IsCheckLogin) = 1 Then
	If Request.Cookies(DownsysClass.CacheName & "LawlessNum") => LawlessNum Then
		Response.Write "<META http-equiv=Content-Type content=text/html; charset=gb2312>"
		Response.Write "请不要非法登陆本系统！<BR>你的IP："&DownsysClass.GetUserip&"已被记录在案；时间：" & Now()
		Response.End
	End If
End If
If DateDiff("s",Session(DownsysClass.CacheName & "UserTime"),Now()) < RefreshTime Then
	Response.Write "<META http-equiv=Content-Type content=text/html; charset=gb2312><meta HTTP-EQUIV=REFRESH CONTENT="&RefreshTime&"><br>本页面起用了防刷新机制，请不要在"&RefreshTime&"秒内连续刷新本页面<BR>正在打开页面，请稍后……"
	Response.End
End If
FoundErr = False
Select Case request("action")
	Case "logout" '退出系统
		Call logout()
	Case "login" '登陆系统
		Call chklogin()
	Case Else
		Call main()
End Select
If FoundErr = True Then
	Session(DownsysClass.CacheName & "UserTime") = Now()
	If IsCheckLogin = 1 Then
		if Request.Cookies(DownsysClass.CacheName & "LawlessNum") = "" Then Response.Cookies(CacheName & "LawlessNum") = "0"
		Response.Cookies(DownsysClass.CacheName & "LawlessNum") = Request.Cookies(CacheName & "LawlessNum") + 1
		Response.Cookies(DownsysClass.CacheName & "LawlessNum").Expires = date + ExpiresTime
	End If
	Response.Redirect("showerr.asp?action=error&message=" & server.URLEncode(errmsg) & "")
End If
NothingObject
Sub main()
	If session(DownsysClass.CacheName & "AdminName") = "" Then
%>
<html>
<head>
<title>管理员登陆</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="Style.css" type="text/css">
</head>
<script language="javascript">
<!--//
function SetFocus()
{
if (document.myform.AdminName.value=="")
	document.myform.AdminName.focus();
else
	document.myform.AdminName.select();
}
function CheckBrowser()
{
  var app=navigator.appName;
  var verStr=navigator.appVersion;
  if (app.indexOf('Netscape') != -1) {
    alert("轩溪软件园友情提示：\n    你使用的是Netscape浏览器，可能会导致无法使用后台的部分功能。建议您使用 IE6.0 或以上版本。");
  }
  else if (app.indexOf('Microsoft') != -1) {
    if (verStr.indexOf("MSIE 3.0")!=-1 || verStr.indexOf("MSIE 4.0") != -1 || verStr.indexOf("MSIE 5.0") != -1 || verStr.indexOf("MSIE 5.1") != -1)
      alert("轩溪软件园友情提示：\n    您的浏览器版本太低，可能会导致无法使用后台的部分功能。建议您使用 IE6.0 或以上版本。");
  }
}
//-->
</script>
<body topmargin="0" leftmargin="0" rightmargin="0">
<div align="center"><BR>
  <p>&nbsp;</p>  <p>&nbsp;</p>
<form name=myform method="post" action="login.asp?action=login" target="_top">
    <table cellpadding="1" cellspacing="0" border="0" align=center style="border: outset 3px;width:0;">
      <tr>
        <td> <table width="605" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr> 
              <td><img src="images/admin_login_r1_c1.jpg" width="605" height="17"></td>
            </tr>
          </table>
          <table width="605" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr> 
              <td width="24"><img src="images/admin_login_r2_c1.jpg" width="23" height="212"></td>
              <td width="494" align="center" valign="top" bgcolor="#F7FAFF"><table width="100%" height="100"  border="0" cellpadding="0" cellspacing="0">
                  <tr> 
                    <td background="images/admin_login_r2_c2.jpg"><img src="images/admin_login_r2_c2.jpg" alt="江南源码资源站下载管理系统" width="494" height="101" border="0"></td>
                  </tr>
                </table>
                <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="5">
                  <tr> 
                    <td width="22%" align="center" rowspan="4"></td>
                    <td width="78%" align="left">用户名： 
                      <input name="AdminName" type="text" size="20" onmouseout="this.style.background='#F9F9F9'" onFocus="this.select();"> 
                      <%If IsCodes = 1 Then%>
                      验证码： 
                      <input name="Validate" type="password" size="15" onmouseout="this.style.background='#F9F9F9'" onFocus="this.select();"  >
                      <%End If%>
                    </td>
                  </tr>
                  <tr> 
                    <td align="left">密　码： 
                      <input name="PassWord" type="password" size="21" onmouseout="this.style.background='#F9F9F9'" onFocus="this.select();"></td>
                  </tr>
                  <tr> 
                    <td align="left">附加码： 
                      <input name="verifycode" type="text" size="20" maxlength="10" value="<%If GetCode=9999 Then Response.Write "9999"%>" onmouseout="this.style.background='#F9F9F9'" onFocus="this.select();">
                      请在附加码框输入 <%=GetCode1()%> </td>
                  </tr>
                  <tr> 
                    <td align="left"><input type="button" name="Submit4" onclick=window.location.reload() value="刷新本页" class=button>
                      　
                      <input type="button" name="Submit1" onclick="javascript:location.href='../'" value="返回首页" class=button>
                      　 
                      <input type="submit" name="Submit" value="管理登陆" class=button></td>
                  </tr>
                </table></td>
              <td width="88"><img src="images/admin_login_r2_c3.jpg" width="88" height="212"></td>
            </tr>
          </table>
          <table width="605" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr> 
              <td><img src="images/admin_login_r4_c1.jpg" width="605" height="21"></td>
            </tr>
          </table></td>
      </tr>
    </table>
  </form>
</div>
<p align=center></p>
<%
Else
	Response.Redirect "admin_index.asp"
End If
End Sub

Sub logout()
	'清除COOKIES中管理员身份的验证信息.
	Session.Abandon
	session(DownsysClass.CacheName & "AdminName") = ""
	session(DownsysClass.CacheName & "Purview") = ""
	session(DownsysClass.CacheName & "adminid") = ""
	Response.Redirect ("../")
End Sub

Sub chklogin()
	Dim adminname, password
	adminname = Trim(Replace(request("adminname"), "'", ""))
	password = md5(Trim(Replace(request("password"), "'", "")))
	If DownsysClass.IsValidStr(Request("adminname")) = False Then
		Errmsg = Errmsg + "<li>用户名中含有非法字符。</li>"
		Founderr = true
		Exit Sub
	End If
	If DownsysClass.IsValidPassword(Request("password")) = False Then
		Errmsg = Errmsg + "<li>密码中含有非法字符。</li>"
		Founderr = true
		Exit Sub
	End If
	If IsCodes = 1 Then
		If Trim(Request.Form("Validate")) <> ValidCodes Or Trim(Request.Form("Validate")) = "" Then
			Errmsg=Errmsg+"<li>您输入的验证无效，请重新输入！</li>"
			Founderr=true
			Exit Sub
		End if
	End If
	If request("verifycode") = "" Then
		errmsg = errmsg + "<br>" + "<li>请返回输入确认码。<li><b>返回后请刷新登陆页面后重新输入正确的信息。</b>"
		founderr = true
		Exit Sub
	ElseIf session("getcode") = "9999" Then
		session("getcode") = ""
		errmsg = errmsg + "<br>" + "<li>请不要重复提交，如需重新登陆请返回登陆页面。<li><b>返回后请刷新登陆页面后重新输入正确的信息。</b>"
		founderr = true
		Exit Sub
	ElseIf CStr(session("getcode"))<>CStr(Trim(request("verifycode"))) Then
		errmsg = errmsg + "<br>" + "<li>您输入的确认码和系统产生的不一致，请重新输入。<li><b>返回后请刷新登陆页面后重新输入正确的信息。</b>"
		founderr = true
		Exit Sub
	End If
	session("getcode") = ""
	If adminname = "" Or password = "" Then
		founderr = true
		Errmsg = Errmsg + "<br>" + "<li>请输入您的用户名或密码。<li><b>返回后请刷新登陆页面后重新输入正确的信息。</b>"
		Exit Sub
	End If
	If founderr Then Exit Sub
	Set rs = conn.Execute("select * from " & Admintable & " where adminname='"&adminname&"'")
	If rs.EOF And rs.bof Then
		rs.Close
		Set rs = Nothing
		founderr = true
		errmsg = "您输入的用户名和密码不正确或者您不是系统管理员。请<a href=admin_login.asp>重新输入</a>您的密码。<b>返回后请刷新登陆页面后重新输入正确的信息。</b>"
		Exit Sub
	Else
		If rs("isActive") = 0 Then
			founderr = true
			errmsg = "你的用户名已被锁定,你不能登陆!请联系管理员."
			Exit Sub
		End If
		If Trim(rs("password"))<>password Then
			founderr = true
			errmsg = "您输入的用户名和密码不正确或者您不是系统管理员。请<a href=login.asp>重新输入</a>您的密码。<li><b>返回后请刷新登陆页面后重新输入正确的信息。</b>"
			Exit Sub
		Else
			Session(DownsysClass.CacheName & "AdminName") = rs("adminname")
			session(DownsysClass.CacheName & "Purview") = rs("Purview")
			session(DownsysClass.CacheName & "Flag") = rs("Flag")
			session(DownsysClass.CacheName & "adminid") = rs("id")
			conn.Execute("update " & Admintable & " set Logintime="&DownsysClass.SqlString&",loginip='"&DownsysClass.GetUserip&"' where adminname='"&adminname&"'")
			rs.Close
			Set rs = Nothing
			response.redirect("admin_index.asp")
		End If
	End If

End Sub

Function GetCode1()
	Dim Test
	On Error Resume Next
	Set Test = Server.CreateObject("Adodb.Stream")
	Set Test = Nothing
	If Err Then
		Dim zNum
		Randomize Timer
		zNum = CInt(8999 * Rnd + 1000)
		Session("GetCode") = zNum
		getcode1 = Session("GetCode")
	Else
		getcode1 = "<img src=""../getcode.asp"">"
	End If
End Function
%>
</div>
</body>
</html>
