<% 
on error resume next
response.Expires=-1
%>

<!--#include virtual="/incs/config.asp"-->
<!--#include virtual="/incs/md5.asp" -->
<%
response.Expires=-1
dud_url=session("dud_url")
If SafeRequest("usrname")<>"" And SafeRequest("usrpass")<>""  Then
	yourname    =lcase(trim(SafeRequest("usrname")))
	yourpass= trim(SafeRequest("usrpass"))

   yourname=replace(yourname,"'","单引")
		screenwidth=SafeRequest("screenwidth")
		screenheight=SafeRequest("screenheight")
		l_dot=screenwidth&"*"&screenheight
	conn.open constr
	
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
browsestr=Request.ServerVariables("HTTP_USER_AGENT")
' 浏览器
if instr(browsestr,"NetCaptor") then
	l_vs="NetCaptor"
elseif instr(browsestr,"MSIE 6") then
	l_vs="MSIE 6.x"
elseif instr(browsestr,"MSIE 5") then
	l_vs="MSIE 5.x"
elseif instr(browsestr,"MSIE 4") then
	l_vs="MSIE 4.x"
elseif instr(browsestr,"Netscape") then
	l_vs="Netscape"
elseif instr(browsestr,"Opera") then
	l_vs="Opera"
else
	l_vs="Other"
end if
' 操作系统
if instr(browsestr,"Windows NT 5.0") then
	l_os="Win 2000"
elseif instr(browsestr,"Windows NT 5.1") then
	l_os="Win XP"
elseif instr(browsestr,"Windows NT") then
	l_os="Win NT"
elseif instr(browsestr,"Windows 9") then
	l_os="Win 9x"
elseif instr(browsestr,"unix") or instr(browsestr,"linux") or instr(browsestr,"SunOS") or instr(browsestr,"BSD") then
	l_os="Unix..."
elseif instr(browsestr,"Mac") then
	l_os="Mac"
else
	l_os="Other"
end if
' 访问者所在地区

l_ip=request.servervariables("remote_addr")
theip=transip(l_ip)
hrdip=l_ip
'''''''''''''''''自动封锁功能开始
query="select * from iplck where (l_ipnum<=" & theip & " and l_ipendnum>=" & theip & ")"
rs.Open query,conn,1,1
if not  rs.eof then '被锁
l_id=rs("l_id")
oldip=rs("l_ip")
hrdip=oldip
end if
rs.close
query="select * from iplck where (l_ipnum<=" & theip & " and l_ipendnum>=" & theip & ") and (l_sft=1 or l_hrd=1)"
rs.open query,conn,1,1
if rs.eof then
ckeerrs=clng(request.Cookies("hzhost")("loginerrs"))
if  (ckeerrs>=clng(pl_ipsfttms)) or (cheerrs>=clng(pl_iphrdtms)) then
    Response.Cookies("hzhost")("loginerrs") =0
    Response.Cookies("hzhost").path = "/"
    Response.Cookies("hzhost").expires =dateadd("yyyy",1,now())
	'call errorpage(-2,"您当前已成功 解除了IP锁定，请返回重新登录！")
end if
end if
rs.close
'''''############如果有软锁定过期，则解锁
if pl_ipsfttms<>"0"  then
query="select * from iplck where (l_ipnum<=" & theip & " and l_ipendnum>=" & theip & ") and l_sft=1"
rs.Open query,conn,1,1
if not  rs.eof then '被锁
l_id=rs("l_id")
oldlip=rs("l_ip")
l_exptme=rs("l_exptme")
l_errlgn=clng(rs("l_errlgn"))
if  l_exptme<=now() then '解锁
query="update iplck set l_sft=0   where  l_id="&l_id
conn.execute query,1,1
    Response.Cookies("hzhost")("loginerrs") =0
    Response.Cookies("hzhost").path = "/"
    Response.Cookies("hzhost").expires =dateadd("yyyy",1,now())
else 
'如果软封锁未过期，则判断硬封锁。  
ckeerrs=clng(request.Cookies("hzhost")("loginerrs"))
ckeerrs=clng(ckeerrs+1)
 Response.Cookies("hzhost")("loginerrs") =ckeerrs	
doresult=hardlock
 call errorpage(-2,"对不起，由于登录本系统连续失败次数过多，您的IP地址当前已被锁定！")
end if
end if
rs.close
end if
'''''''''''''''''自动解锁功能结束	

'''''''''''''''''检测IP所属地市	
query="select * from iplst where (ip1<=" & theip & " and ip2>=" & theip & ")"
rs.Open query,conn,1,1

if rs.EOF then
    l_prv="未知"     
else
    l_prv=trim(rs("ip_prv"))    
end if
rs.Close
'''''''增加登录记录
query="insert lgnlst(l_unme,l_agt,l_ip,l_addtme,l_os,l_vs,l_prv,l_ifok,l_dot) values('"&yourname&"','','"&l_ip&"',getdate(),'"&l_os&"','"&l_vs&"','"&l_prv&"',0,'"&l_dot&"')"
conn.execute query,1,1
findlastid logid

if pl_ifsecnum="1" then 
usrverify=SafeRequest("usrverify")
if  usrverify="" then
    call errorpage(-2,"对不起，请输入验证码！")
elseif trim(usrverify)<>cstr(Session("loginnumber"))  then
    call errorpage(-2,"对不起，验证码不符！")
end if
end if

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        recs=chk_usrpss(yourname,"登录名称",4,16)
        recs=chk_usrpss(yourpass,"登录密码",6,16)
		yourpass    = md5(yourpass)

	if yourname=pl_usrnme_gst or yourname=pl_usrnme_sys then
	call errorpage(-2,"对不起，该用户禁止登录！")
	end if
	

	rs.open "select * from memlst where u_nme='"& yourname&"' " ,conn,1,3
	If rs.eof And rs.bof Then
		rs.close
		conn.close
    call errorpage(-2,"对不起，您不是本站的合法用户，请返回(101)！")
	  else

	    if  trim(rs("u_pss"))<>trim(yourpass) then 
		
'''''''''''''''''自动封锁功能开始	
'''''读coolies
ckeerrs=clng(request.Cookies("hzhost")("loginerrs"))
ckeerrs=clng(ckeerrs+1)
 Response.Cookies("hzhost")("loginerrs") =ckeerrs	
'''''读coolies结束
''''如果达到软锁，则加入软锁开始 
if  clng(ckeerrs)>=clng(pl_ipsfttms)  and pl_ipsfttms<>"0" then
query="select * from memlst where u_nme='"&pl_usrnme_sys&"'"
rs1.open query,conn,1,1
if rs1.eof then
    call errorpage(-2,"对不起，意外错误(105)！")
end if
pl_usrpss_sys=trim(rs1("u_pss"))
rs1.close
if chk_int(l_id) then
   substrContent = "entryclass:sys2_mng"&VEnd
    substrContent =substrContent& "entrytype:lckip_sftedt"&VEnd
   substrContent =substrContent& "entryuser:"&pl_usrnme_sys&VEnd
   substrContent =substrContent& "entrypass:"&pl_usrpss_sys&VEnd
   substrContent =substrContent& "agentname:"&agentname&VEnd
   substrContent = substrContent & "l_ip:" &oldip& VEnd
   substrContent = substrContent & "l_sft:" &"1"& VEnd
   substrContent = substrContent & "." & VEnd
 doresult = hzsocket(substrContent)
    substrContent = "entryclass:sys2_mng"&VEnd
   substrContent =substrContent& "entrytype:lckip_exptmeedt"&VEnd
   substrContent =substrContent& "entryuser:"&pl_usrnme_sys&VEnd
   substrContent =substrContent& "entrypass:"&pl_usrpss_sys&VEnd
   substrContent =substrContent& "agentname:"&agentname&VEnd
   substrContent = substrContent & "l_ip:" &oldip& VEnd
   substrContent = substrContent & "l_exptme:" &dateadd("h",pl_ipsftday,now())& VEnd
   substrContent = substrContent & "." & VEnd
else
   substrContent = "entryclass:sys2_mng"&VEnd
   substrContent =substrContent& "entrytype:lckip_add"&VEnd
   substrContent =substrContent& "entryuser:"&pl_usrnme_sys&VEnd
   substrContent =substrContent& "entrypass:"&pl_usrpss_sys&VEnd
   substrContent =substrContent& "agentname:"&agentname&VEnd
   substrContent = substrContent & "l_ip:" &l_ip& VEnd
   substrContent = substrContent & "l_ipend:" &l_ip& VEnd
   substrContent = substrContent & "l_msk:" &"255.255.255.255"& VEnd
   substrContent = substrContent & "l_tpe:" &"1"& VEnd
   substrContent = substrContent & "l_exptme:" &dateadd("h",pl_ipsftday,now())& VEnd
   substrContent = substrContent & "." & VEnd
end if
doresult = hzsocket(substrContent)
if_addsft=true
end if
'''''硬封锁 
doresult=hardlock()
if doresult<>"" then
    call errorpage(-2,"对不起，您连续登录失败次数过多，已被系统自动锁定！")
end if
''''如果达到软锁，则加入软锁结束
'''''''''''''''''自动封锁功能结束	
		
		rs.close
		conn.close
    call errorpage(-2,"对不起，您不是本站的合法用户，请返回(102)！")
		elseif  rs("u_lck")=1 then
		call errorpage(-2,"对不起，该用户已被禁登录，请联系管理人员！")
		elseif rs("u_sys")<4 then
		call errorpage(-2,"对不起，用户权限不够，请联系管理人员！")
		else
		
'''''''''''''''''自动封锁功能开始	
'''''写coolies为0
    Response.Cookies("hzhost")("loginerrs") =0
    Response.Cookies("hzhost").path = "/"
    Response.Cookies("hzhost").expires =dateadd("yyyy",1,now())
'''''写coolies为0结束
'''''''''''''''''自动封锁功能结束	

query="select c_nme from clslst where c_cls="&rs("u_prc")

rs1.open query,conn,1,1
		if rs1.recordcount<>1 then
		call errorpage(-2,"对不起，系统发生错误，请返回！")
		else
		levelname=trim(rs1("c_nme"))
		pwid=rs("u_pwr")
		rs("u_lgncnt")=clng(rs("u_lgncnt"))+1
		rs("u_lsttme")=now()
		rs("u_lstip")=request.servervariables("remote_addr")
		rs.update
		session("usrid")=rs("u_id")
		session("usrname")=trim(rs("u_nme"))
		session("usrpass")=yourpass
		session("usrclass")=clng(rs("u_prc"))
		session("sysclass")=rs("u_sys")
		session("sysrotnme")=rs("u_rotnme")
		session("sysare")=rs("u_are")
		tempstr=split(session("sysare"),",")
		tempstring=""
		for tempc=0 to ubound(tempstr)
		tempvar=trim(tempstr(tempc))
		if chk_int(tempvar) then
		if tempstring="" then
		tempstring="u_myare="&tempvar
		else
		tempstring=tempstring &" or u_myare="&tempvar
		end if
		end if
		next
		if tempstring="" then
		tempstring=" 1=1 "
		end if
        session("sysarestr")=tempstring
		session("usrclassname")=levelname
		session("usremail")=rs("u_eml")
		rs.close
		query="select  pw_str,pw_nme from pwrlst where pw_id="&pwid
		rs.open query,conn,1,1
		if rs.recordcount=1 then
		session("syspower")=trim(rs("pw_str"))
                session("syspwrcls")=pwid
				session("syspwrnme")=trim(rs("pw_nme"))
		end if
		rs.close
		query="update lgnlst set l_ifok=1 where l_id="&logid
		conn.execute query,1,1
		conn.close
		response.write "<script language='javascript'>"+vbcrlf
        response.write "parent.location.href='/master/index.asp';"+vbcrlf
        response.write "</script>"
		'response.redirect "/control/"		
		response.end
		end if		
		rs1.close
		end if 
	End If
End If


function hardlock()
if  clng(ckeerrs)>=clng(pl_iphrdtms) and pl_iphrdtms<>"0" then
query="select * from memlst where u_nme='"&pl_usrnme_sys&"'"
rs1.open query,conn,1,1
if rs1.eof then
    call errorpage(-2,"对不起，意外错误(105)！")
end if
pl_usrpss_sys=trim(rs1("u_pss"))
rs1.close
if chk_int(l_id) or  if_addsft then
   substrContent = "entryclass:sys2_mng"&VEnd
   substrContent =substrContent& "entrytype:lckip_hrdedt"&VEnd
   substrContent =substrContent& "entryuser:"&pl_usrnme_sys&VEnd
   substrContent =substrContent& "entrypass:"&pl_usrpss_sys&VEnd
   substrContent =substrContent& "agentname:"&agentname&VEnd
   substrContent = substrContent & "l_ip:" &hrdip& VEnd
   substrContent = substrContent & "l_hrd:" &"1"& VEnd
   substrContent = substrContent & "." & VEnd
else
   substrContent = "entryclass:sys2_mng"&VEnd
   substrContent =substrContent& "entrytype:lckip_add"&VEnd
   substrContent =substrContent& "entryuser:"&pl_usrnme_sys&VEnd
   substrContent =substrContent& "entrypass:"&pl_usrpss_sys&VEnd
   substrContent =substrContent& "agentname:"&agentname&VEnd
   substrContent = substrContent & "l_ip:" &l_ip& VEnd
   substrContent = substrContent & "l_ipend:" &l_ip& VEnd
   substrContent = substrContent & "l_msk:" &"255.255.255.255"& VEnd
   substrContent = substrContent & "l_tpe:" &"2"& VEnd
   substrContent = substrContent & "l_exptme:" &dateadd("h",pl_ipsftday,now())& VEnd
   substrContent = substrContent & "." & VEnd
end if
doresult = hzsocket(substrContent)
else
doresult=""
end if
hardlock=doresult
end function		
%>

<html>
<head>
<title>系统登录</title>
<meta http-equiv="Content-Type" content="text/html;">
<link rel="stylesheet" href="/CSS/green.css" type="text/css">
</head>
<body bgcolor="#DEF1D8" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="javascript:document.reg_form.usrname.focus();">
<table width="100%" border="0" height="100%" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td valign="top"> <br>
      <br>
      <br>
      <br>
      <br>
      <br>
      <table width="611" border="0" align="center" cellpadding="3" class="tableborder">
        <tr> 
          <td> 
            <table width="611" border="0" cellpadding="0" cellspacing="0" align="center">
              <tr bgcolor="#FFFFFF"> 
                <td valign="top"><img src="../images/logo.gif" width="191" height="58"></td>
                <td> 
                  <div align="right"><img name="n2_r2_c3" src="../images/login2.gif" width="317" height="146" border="0"></div>
                </td>
              </tr>
            </table>
            <table width="100%" border="0" height="1" bgcolor="#FFFFFF" cellpadding="0" cellspacing="0" align="center">
              <tr> 
                <td></td>
              </tr>
            </table>
            <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#B3BCB1" align="center">
              <tr> 
                <td width="55%">&nbsp; </td>
                <td> 
                  <p>&nbsp;</p>
                  <table border="0" cellspacing="0" cellpadding="0">
                    <form method="post" action="login.asp" name="reg_form" >
                      <tr> 
                        <td width="42"> 
                          <div align="center" style="font-size:12px">用户名:</div>
                        </td>
                        <td colspan="2"> 
                          <input type="text" name="usrname" size="12" style="BORDER-BOTTOM-COLOR: #F6F6F6; BORDER-BOTTOM-STYLE: groove; BORDER-LEFT-COLOR: #F6F6F6; BORDER-LEFT-STYLE: groove; BORDER-RIGHT-COLOR: #F6F6F6; BORDER-RIGHT-STYLE: groove; BORDER-TOP-COLOR: #F6F6F6; BORDER-TOP-STYLE: groove" maxlength="16">
                          <input name=screenwidth value="" type=hidden>
                          <input name=screenheight value="" type=hidden>
                        </td>
                      </tr>
                      <tr> 
                        <td> 
                          <div align="center" style="font-size:12px">密&nbsp;&nbsp;码:</div>
                        </td>
                        <td> 
                          <input type="password" name="usrpass" size="12" style="BORDER-BOTTOM-COLOR: #F6F6F6; BORDER-BOTTOM-STYLE: groove; BORDER-LEFT-COLOR: #F6F6F6; BORDER-LEFT-STYLE: groove; BORDER-RIGHT-COLOR: #F6F6F6; BORDER-RIGHT-STYLE: groove; BORDER-TOP-COLOR: #F6F6F6; BORDER-TOP-STYLE: groove" maxlength="16">
                        </td>
                        <td width="70"> 
                          <div align="center"> </div>
                        </td>
                      </tr>
					  <% if pl_ifsecnum="1" then %>
                      <tr> 
                        <td> 
                          <div align="center" style="font-size:12px">验证码:</div>
                        </td>
                        <td> 
                          <input type="password" name="usrverify" size="4" style="BORDER-BOTTOM-COLOR: #F6F6F6; BORDER-BOTTOM-STYLE: groove; BORDER-LEFT-COLOR: #F6F6F6; BORDER-LEFT-STYLE: groove; BORDER-RIGHT-COLOR: #F6F6F6; BORDER-RIGHT-STYLE: groove; BORDER-TOP-COLOR: #F6F6F6; BORDER-TOP-STYLE: groove" maxlength="4">&nbsp;<img  src="/incs/loginverify.asp">
                        </td>
                        <td width="70"> 
                          <div align="center"> </div>
                        </td>
                      </tr>
					  <% end if %>
                      <tr> 
                        <td>&nbsp;</td>
                        <td> 
                          <input type="image" src="../images/login3.jpg" width="52" height="27" name="image">
                        </td>
                        <td width="70">&nbsp; </td>
                      </tr>
                    </form>
                  </table>
                  <p>&nbsp;</p>
                </td>
              </tr>
            </table>
            <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#6AD500">
              <tr> 
                <td width="62%">&nbsp;</td>
                <td class="StatusBarTitle" height=60> Power By www.vvx.cn
                
                </td>
              </tr>
            </table>
            <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#191643" align="center">
              <tr> 
                <td>&nbsp;</td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table><script>
				reg_form.screenwidth.value=screen.width;
				reg_form.screenheight.value=screen.height;
				</script>
				
</body>
</html>
