<!--#include file = "../inc/dbconn.asp"-->
<!--#include file = "../inc/cache.asp"-->
<!--#include file = "../inc/md5.asp"-->
<!--#include file = "../inc/function.asp"-->
<%
if gqv("do") = "login" then
    Call PreventRefresh(1)
	Call dbconn
	Call tools_safefunction
	Call ChkPost()	
	dim uname,upass,scode,vcode,tcode
		uname = NoSqlHack(replace(trim(gfv("name")),"'","''"))
		upass = replace(trim(gfv("pass")),"'","''")
		scode = replace(trim(gfv("code")),"'","''")
		vcode = lcase(replace(trim(gfv("vcode")),"'",""))
	
	if uname = "" or upass = "" or  scode = "" or not isnumeric(scode) or vcode = "" or not isnumeric(vcode) then
		response.write("<script>alert(""请完整的填写登陆信息!"");location.href=""login.asp"";</script>")
		response.end()
	end if	
		
	if  vcode <> cstr(session("GetCode"))  then 
		response.write("<script>alert(""请输入正确的验证数字!"");location.href=""login.asp"";</script>")
		response.end()
	end if

	Dim	p_System:p_System = Request.ServerVariables("HTTP_USER_AGENT")
    if Instr(p_System,"Windows NT 5.2") then
	   p_System = "Win2003"
    elseif Instr(p_System,"Windows NT 5.0") then
	   p_System="Win2000"
    elseif Instr(p_System,"Windows NT 5.1") then
	   p_System = "WinXP"
    elseif Instr(p_System,"Windows NT") then
	   p_System = "WinNT"
    elseif Instr(p_System,"Windows 9") then
	   p_System = "Win9x"
    elseif Instr(p_System,"unix") or instr(p_System,"linux") or instr(p_System,"SunOS") or instr(p_System,"BSD") then
	   p_System = "类Unix"
    elseif Instr(p_System,"Mac") then
	   p_System = "Mac"
    else
	   p_System = "Other"
    end if
	
	dim Log_IP
	Log_IP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
    if Log_IP = ""  then
	   Log_IP=Request.ServerVariables("Remote_Addr")
    end if 
		
    dim codearr,tResult,cResult
	codearr = split(safepass,",")
	if codearr(0) = 1 then
		if codearr(3) = "1" then
			tResult = trim(cstr(cint(mid(session("GetCode"),cint(codearr(1)),1))+cint(mid(session("GetCode"),cint(codearr(2)),1))))
		else
			tResult = trim(cstr(cint(mid(session("GetCode"),cint(codearr(1)),1))*cint(mid(session("GetCode"),cint(codearr(2)),1))))
		end if
		if codearr(4) = "0" then
			cResult = left(scode,len(tResult))
			tcode = mid(scode,len(tResult) + 1)
		elseif cint(codearr(4)) > len(scode) - len(tResult) then
			cResult = right(scode,len(tResult))
			tcode = left(scode,len(scode) - len(tResult))
		else
			cResult = mid(scode,codearr(4) + 1,len(tResult))
			tcode = left(scode,codearr(4))&mid(scode,cint(codearr(4)) + len(tResult) + 1)
		end if
	else
		tcode = scode
	end if
	
	dim p_RsLogObj,p_SqlLog
	dim rs,sql
	set rs = server.createobject (G_654_RS) 
	sql = "select * from DH654_admin where uname='" & uname & "' and upass='" & md5(upass,32) & "' and scode=" & tcode & ""
	rs.open sql,conn,1,3
	if not rs.eof then
		if cint(rs("Admin_Is_Locked")) = 0 then
		   Set p_RsLogObj = Server.Createobject(G_654_RS)
	       p_SqlLog = "Select Admin_Name,Log_IP,Log_OS_Sys,Log_TF,Log_AB,Log_Time from DH654_Log where 1=0"
	       p_RsLogObj.Open p_SqlLog,Conn,3,3
	       p_RsLogObj.AddNew
	       p_RsLogObj("Admin_Name") = uname
	       p_RsLogObj("Log_IP") = Log_IP
	       p_RsLogObj("Log_OS_Sys") = p_System
	       p_RsLogObj("Log_TF") = 2 '2锁定
	       p_RsLogObj("Log_AB") = "A"
	       p_RsLogObj("Log_Time") = Now()
	       p_RsLogObj.Update
	       p_RsLogObj.Close:set p_RsLogObj = Nothing		
		   Call alertbox("错误:\n您已经被锁定,请与管理联系\n",2)
		   Response.End
	    end if
		session("GetCode") = ""
		session("uname") = rs("uname")
		Session("Admin_Pop_List") = rs("Admin_Pop_List")		
	    Set p_RsLogObj = Server.Createobject(G_654_RS)
	    p_SqlLog = "Select Admin_Name,Log_IP,Log_OS_Sys,Log_TF,Log_AB,Log_Time from DH654_Log where 1=0"
	    p_RsLogObj.Open p_SqlLog,Conn,3,3
	    p_RsLogObj.AddNew
	    p_RsLogObj("Admin_Name") = uname
	    p_RsLogObj("Log_IP") = Log_IP
	    p_RsLogObj("Log_OS_Sys") = p_System
	    p_RsLogObj("Log_TF") = 1 '1成功
	    p_RsLogObj("Log_AB") = "A"
	    p_RsLogObj("Log_Time") = Now()
	    p_RsLogObj.Update
	    p_RsLogObj.Close:set p_RsLogObj = Nothing
		
		rs("LoginTimes")=rs("LoginTimes")+1
        rs("LastLoginTime")=now()
        rs.Update
		rs.close:set rs = nothing
		conn.close:set conn = nothing
		response.redirect("index.asp")
	else	
		Set p_RsLogObj = Server.Createobject(G_654_RS)
	    p_SqlLog = "Select ID,Admin_Name,Log_IP,Log_OS_Sys,Log_Error_Pass,Log_TF,Log_AB,Log_Time from DH654_Log where 1=0"
	    p_RsLogObj.open p_SqlLog,Conn,3,3
	    p_RsLogObj.AddNew
	    p_RsLogObj("Admin_Name") = Request.Form("Name")
	    p_RsLogObj("Log_IP") = Log_IP
	    p_RsLogObj("Log_OS_Sys") = p_System
	    p_RsLogObj("Log_Error_Pass") = Request.Form("pass")
	    p_RsLogObj("Log_TF") = 0 '0失败
	    p_RsLogObj("Log_AB") = "A"
	    p_RsLogObj("Log_Time") = Now()
	    p_RsLogObj.Update
	    p_RsLogObj.Close:Set p_RsLogObj = Nothing	
		rs.close:set rs = nothing
		conn.close:set conn = nothing
		response.write("<script>alert(""抱歉!系统无法正确识别您的身份!"");location.href=""login.asp"";</script>")
		response.end()
	end if
elseif gqv("do") = "out" then
  session.abandon
  session("uname") = ""
  Session("Admin_Pop_List")=""
  
  
  response.write("<script>top.location.href=""login.asp"";</script>")
  response.end()
end if
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<title>IT猫扑上网导航后台登陆</title>
<meta name="keywords" content="IT猫扑上网导航管理系统">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta content="MSHTML 6.00.3790.2491" name="GENERATOR" />
<meta name="Keywords" content="IT猫扑上网导航,上网导航的领先者。" />
<style>
a{text-decoration: none;} /* 链接无下划线,有为underline */ 
a:link {color: #232323;} /* 未访问的链接 */
a:visited {color: #232323;} /* 已访问的链接 */
a:hover{color: #FFCC00;} /* 鼠标在链接上 */ 
a:active {color: #FFCC00;} /* 点击激活链接 */
td ,body{
	color:#232323;
	font-size:12px;
	line-height: 18px;
}
.input{
    FONT-FAMILY: "新宋体";
    FONT-SIZE: 12px;
	COLOR:#F3F3F3;
    text-decoration: none;
    line-height: 150%;
    background:#0099CC;
	border-top-width: 1px;
	border-right-width: 1px;
	border-bottom-width: 1px;
	border-left-width: 1px;
    border-top-style: solid;
	border-right-style: solid;
	border-bottom-style: solid;
	border-left-style: solid;
	border-top-color: #FFFFFF;
	border-right-color: #FFFFFF;
	border-bottom-color: #FFFFFF;
	border-left-color: #FFFFFF;
	padding:0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 0px;
}
.input_1{
    FONT-FAMILY: "新宋体";
    FONT-SIZE: 12px;
	COLOR:#006699;
    text-decoration: none;
    line-height: normal;
    background:#FFFFFF;
	border-top-width: 1px;
	border-right-width: 1px;
	border-bottom-width: 1px;
	border-left-width: 1px;
    border-top-style: solid;
	border-right-style: solid;
	border-bottom-style: solid;
	border-left-style: solid;
	border-top-color: #80CCFF;
	border-right-color: #80CCFF;
	border-bottom-color: #80CCFF;
	border-left-color: #80CCFF;
	padding:0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 0px;
}
</style>
<head>
<body background="Images/log_bg.gif" topmargin="80">
<table width="486" border="0" align="center" cellpadding="0" cellspacing="3" bgcolor="#00CCFF">
  <tr>
    <td height="287" bgcolor="#FFFFFF"> 
      <TABLE WIDTH=486 BORDER=0 CELLPADDING=0 CELLSPACING=0>
        <TR> 
          <TD COLSPAN=2> <IMG SRC="images/log_1.gif" ALT="" WIDTH=486 HEIGHT=87 border="0" usemap="#Map" target="_blank"></TD>
        </TR>
        <TR> 
          <TD width="339" background="images/log_2.gif">
		  <table width="317" height="112" border="0" align="center" cellpadding="0" cellspacing="0">
              <form name="login" action="?do=login" method="post">
                <tr> 
                  <td width="23%" height="16"> <div align="center">用户名称：</div></td>
                  <td width="77%" height="16">                    <input name="name" type="text" onMouseOver="this.focus()" style="width:100px;height:20px;" maxlength="20" value=""></td>
                </tr>
                <tr> 
                  <td height="15"> <div align="center">用户密码：</div></td>
                  <td height="15"><input name="pass" type="password" onMouseOver="this.focus()" style="width:100px;height:20px;" maxlength="20" value=""></td>
                </tr>
                <tr> 
                  <td height="19"> <div align="center">安全密码：</div></td>
                  <td height="19"><input name="code" type="password" onMouseOver="this.focus()" style="width:100px;height:20px;" maxlength="20" value=""></td>
                </tr>
                <tr class="back"> 
                  <td height="21" class="hback"><div align="center">验证数字：</div></td>
                  <td height="21" class="hback"><input name="vcode" type="text" onMouseOver="this.focus()" style="width:100px;height:20px;" maxlength="6" value=""> ←<img src="../inc/vcode.asp" style="cursor:hand" alt="图片看不清？点击重新得到验证码" onClick="this.src='../inc/vcode.asp';"> </td>
                </tr>
                <tr class="back">
                  <td height="21" class="hback">&nbsp;</td>
                  <td height="21" class="hback"><input class="input" type="submit" value="确定登陆" name="Submit" />
                  <input class="input" onClick="javascript:location.href='../'" type="button" value="返回首页" name="Submit1" />
                  <input class="input" onClick="window.location.reload()" type="button" value="刷新本页" name="Submit4" /></td>
                </tr>
              </form>
            </table> </TD>
          <TD width="147"><IMG SRC="images/log_3.gif" WIDTH=147 HEIGHT=124 ALT=""></TD>
        </TR>
        <TR valign="bottom"> 
          <TD height="77" COLSPAN=2 background="images/log_4.jpg"> <font color="#FFFFFF"><br>
            </font></TD>
        </TR>
      </TABLE>
    </td>
  </tr>
</table>
</body>
</html>
