<%data_path="../"%>
<!--#include file="../conn/conn.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../inc/safe.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="css/stylechk.css" rel=stylesheet type=text/css>
<title>后台登陆验证</title>
<%
if Not ChkPost then response.redirect (HOPE_InstallDir&"login/chklogin.asp?login=4")
Response.Expires = 0
Response.AddHeader "Pragma", "no-cache"
Response.AddHeader "cache-control", "no-store"
  
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
dim uid,upwd
uid=Replace_Text(Request.Form("userid"))
upwd=md5(Replace_Text(Request.Form("password")),16)
Verifycode=Replace_Text(request.Form("verifycode"))
 
'=================================IP验证 Begin==============================================
HOPE_Ip=Request.ServerVariables("REMOTE_ADDR")

Set rs=Server.Createobject("Adodb.recordset")
			Sql="Select * From Websen_IPSet"
			rs.open sql,conn,1,3
if not rs.eof then 
	do while not rs.eof 
		if rs("HOPE_IP")=HOPE_Ip then 
			Call HOPE_err("登录失败","当前登录的IP地址已经锁定<br><br>请联系系统管理员!","返回上一页","javascript:history.go(-1);")
			Response.end
		end if
	rs.movenext
	if rs.eof then exit do
	loop
end if
	rs.close
	set rs=nothing
'=================================IP验证 End==============================================
 	
	if not isnumeric(Verifycode) then
		call Logerr()
		Call  ErroFy()
	end if
	if issession=0 then
	if Replace_Text(request.Cookies("safecode"))<>"" then
	 safecode=Replace_Text(request.Cookies("safecode"))
	end if
	else
	 safecode=Session("SafeCode")
	end if
 
if cstr(Verifycode)<>cstr(safecode) then
	call Logerr()
	Call  ErroFy()
	
	Sub ErroFy()
response.write"<table width=100% border=0 cellspacing=0 cellpadding=0>"
response.write"          <tr>"
response.write"            <td height=500 valign=top><table width=100% border=0 align=center cellpadding=0 cellspacing=0 height=600>"
response.write"            <tr>"
response.write"              <td width=33% height=65 background=images/lotop.gif>&nbsp;</td>"
response.write"              </tr>"
response.write"            <tr></tr>"
response.write"                <tr>"
response.write"                  <td valign=middle bgcolor=#3F63AD><table width=100% border=0 align=center cellpadding=0 cellspacing=0 height='100%'>"
response.write"                    <tr>"
response.write"                      <td width=532 height=400 align=right valign=middle><table border=0 align=right cellpadding=0 cellspacing=0>"
response.write"                        <tr>"
response.write"                          <td><img src=/images/logo.png width=188 height=83></td>"
response.write"                          <td width=40>&nbsp;</td>"
response.write"                        </tr>"
response.write"                      </table>"
response.write"                      </td>"
response.write"                      <td width=30 height=300 valign=middle><table width=1 border=0 cellspacing=0 cellpadding=0>"
response.write"                        <tr>"
response.write"                          <td width=1 ><img src=images/loc.gif width=1 height=326></td>"
response.write"                        </tr>"
response.write"                      </table></td>"
response.write"                      <td width=525 height=400 valign=middle><table width=90% border=0 cellspacing=0 cellpadding=0>"
response.write"                        <tr>"
response.write"                          <td><font color=#FFFFFF><p>登陆失败！<br>"
response.write"                          验证码输入错误！<br><a href='login.asp'><font color=#ffffff>&lt;&lt; 返回上一页</font></a>"
response.write"                          </p></font>"
response.write"                          </td>"
response.write"                        </tr>"
response.write"                      </table></td>"
response.write"                    </tr>"
response.write"                  </table></td>"
response.write"              </tr>"
response.write"              <tr></tr>"
response.write"                <tr>"
response.write"                  <td width=33%  height=65 valign=bottom background=images/lobut.gif></td>"
response.write"              </tr>"
response.write"        </table></td>"
response.write"  </tr>"
response.write"</table>" 
		Response.End()
	End Sub
else
 
set rs=server.createobject("adodb.recordset")
sqltext="select * from Websen_worldec_master where Username='" & uid & "' and [PassWord]='" & upwd & "'"
rs.open sqltext,conn,1,1
If Rs.Eof And Rs.Bof Then
response.write"<table width=100% border=0 cellspacing=0 cellpadding=0>"
response.write"          <tr>"
response.write"            <td height=500 valign=top><table width=100% border=0 align=center cellpadding=0 cellspacing=0 height=600>"
response.write"            <tr>"
response.write"              <td width=33% height=65 background=images/lotop.gif>&nbsp;</td>"
response.write"              </tr>"
response.write"            <tr></tr>"
response.write"                <tr>"
response.write"                  <td valign=middle bgcolor=#3F63AD><table width=100% border=0 align=center cellpadding=0 cellspacing=0 height='100%'>"
response.write"                    <tr>"
response.write"                      <td width=532 height=400 align=right valign=middle><table border=0 align=right cellpadding=0 cellspacing=0>"
response.write"                        <tr>"
response.write"                          <td><img src=/images/logo.png width=188 height=83></td>"
response.write"                          <td width=40>&nbsp;</td>"
response.write"                        </tr>"
response.write"                      </table>"
response.write"                      </td>"
response.write"                      <td width=30 height=300 valign=middle><table width=1 border=0 cellspacing=0 cellpadding=0>"
response.write"                        <tr>"
response.write"                          <td width=1 ><img src=images/loc.gif width=1 height=326></td>"
response.write"                        </tr>"
response.write"                      </table></td>"
response.write"                      <td width=525 height=400 valign=middle><table width=90% border=0 cellspacing=0 cellpadding=0>"
response.write"                        <tr>"
response.write"                          <td><font color=#FFFFFF><p>登陆失败！<br>"
response.write"                          用户名及密码输入错误！<br><a href='login.asp'><font color=#ffffff>&lt;&lt; 返回上一页</font></a>"
response.write"                          </p></font>"
response.write"                          </td>"
response.write"                        </tr>"
response.write"                      </table></td>"
response.write"                    </tr>"
response.write"                  </table></td>"
response.write"              </tr>"
response.write"              <tr></tr>"
response.write"                <tr>"
response.write"                  <td width=33%  height=65 valign=bottom background=images/lobut.gif></td>"
response.write"              </tr>"
response.write"        </table></td>"
response.write"  </tr>"
response.write"</table>" 
		call Logerr()
		
	 Sub Logerr()'登录错误
		'===========================================http://www.websen.net =========================================
		If Database_type=1 Then
			Set rsLog=server.CreateObject("adodb.recordset")
			SqlLog="select ip,admin_username,dat1,dat,EndLogin,cs From  Websen_web_manage_log "
			rsLog.open SqlLog,conn,1,3
			  rsLog.addnew()
				rsLog("ip")=Request.ServerVariables("REMOTE_ADDR")
				rsLog("admin_username")=uid
				rsLog("dat1")=now()
				rsLog("dat")=now()
				rsLog("Cs")=1
				rsLog("EndLogin")=0
			  rsLog.update()
				rsLog.close
				Set rsLog=nothing
		'===========================================http://www.websen.net =========================================
		
		else
		'===========================================http://www.websen.net =========================================
			Set rsLog=server.CreateObject("adodb.recordset")
			SqlLog="select ip,admin_username,dat1,dat,EndLogin,cs From  Websen_web_manage_log "
			rsLog.open SqlLog,conn,1,3
			  rsLog.addnew()
				rsLog("ip")=Request.ServerVariables("REMOTE_ADDR")
				rsLog("admin_username")=uid
				rsLog("dat1")=now()
				rsLog("dat")=now()
				rsLog("Cs")=1
				rsLog("EndLogin")=0
			  rsLog.update()
				rsLog.close
				Set rsLog=nothing
		
		'===========================================http://www.websen.net =========================================		
		end if
	End Sub
	
else
  
	if isSession=1 then
     session("globalecmaster")=rs("username")
     session("masterflag")=rs("flag")
     session("adminid")=rs("id")
     session.timeout=60
 	else
     Response.Cookies("username")=rs("username")
     Response.Cookies("usernames")=rs("id")
     Response.Cookies("userlist")=rs("PassWord")
	 Response.Cookies("userlists")=md5(rs("flag"),16)
	 Response.Cookies("usertime")=now()
 	 Response.Cookies("userip")=Request.ServerVariables("REMOTE_ADDR")
     Response.Cookies("username").Expires=dateadd("n",time_score,now())
     Response.Cookies("usernames").Expires=dateadd("n",time_score,now())
     Response.Cookies("userlist").Expires=dateadd("n",time_score,now())
     Response.Cookies("userlists").Expires=dateadd("n",time_score,now())
	 Response.Cookies("userip").Expires=dateadd("n",time_score,now())
     Response.Cookies("usertime").Expires=dateadd("n",time_score,now())
    end if
  
  if issession=0 then
    globalname=request.Cookies("username")
  else
    globalname=session("globalecmaster")
  end if
 If Database_type=1 Then
	conn.execute("update Websen_worldec_master set LastLogin=getdate(),LastLoginIP='"&getIP&"' where username='"&uid&"'")
	
	'===========================================http://www.websen.net =========================================
	Set rsLog=server.CreateObject("adodb.recordset")
		SqlLog="select ip,admin_username,dat1,dat,EndLogin,cs From  Websen_web_manage_log Where admin_username='"&globalname&"'"
		rsLog.open SqlLog,conn,1,3
		if not rsLog.eof then 
			rsLog("ip")=Request.ServerVariables("REMOTE_ADDR")
			rsLog("dat")=now()
 			rsLog("Cs")=Cint(rsLog("Cs"))+1
			rsLog("EndLogin")=1
			rsLog.update()
		else
			rsLog.addnew()
			rsLog("ip")=Request.ServerVariables("REMOTE_ADDR")
			rsLog("admin_username")=globalname
			rsLog("dat1")=now()
			rsLog("dat")=now()
			rsLog("Cs")=1
			rsLog("EndLogin")=1
			rsLog.update()
		end if
		rsLog.close
		Set rsLog=nothing
	'===========================================http://www.websen.net =========================================
			
Else
	conn.execute("update Websen_worldec_master set LastLogin=date(),LastLoginIP='"&getIP&"' where username='"&uid&"'")
	
	'===========================================http://www.websen.net =========================================
	Set rsLog=server.CreateObject("adodb.recordset")
		SqlLog="select ip,admin_username,dat1,dat,EndLogin,cs From  Websen_web_manage_log Where admin_username='"&globalname&"'"
		rsLog.open SqlLog,conn,1,3
		
		if not rsLog.eof then 
			rsLog("ip")=Request.ServerVariables("REMOTE_ADDR")
			rsLog("dat")=now()
			rsLog("Cs")=Cint(rsLog("Cs"))+1
			rsLog("EndLogin")=1
			rsLog.update()
		else
			rsLog.addnew()
			rsLog("ip")=Request.ServerVariables("REMOTE_ADDR")
			rsLog("admin_username")=globalname
			rsLog("dat1")=now()
			rsLog("dat")=now()
			rsLog("Cs")=1
			rsLog("EndLogin")=1
			rsLog.update()
		end if
		rsLog.close
		Set rsLog=nothing
	'===========================================http://www.websen.net =========================================
 	
End If

  if issession=0 then
 		 response.Cookies("safecode")=""
 		else
		 Session("SafeCode")=""
  end if
response.write"<table width=100% border=0 cellspacing=0 cellpadding=0>"
response.write"          <tr>"
response.write"            <td height=500 valign=top><table width=100% border=0 align=center cellpadding=0 cellspacing=0 height=600>"
response.write"            <tr>"
response.write"              <td width=33% height=65 background=images/lotop.gif>&nbsp;</td>"
response.write"              </tr>"
response.write"            <tr></tr>"
response.write"                <tr>"
response.write"                  <td valign=middle bgcolor=#3F63AD><table width=100% border=0 align=center cellpadding=0 cellspacing=0 height='100%'>"
response.write"                    <tr>"
response.write"                      <td width=532 height=400 align=right valign=middle><table border=0 align=right cellpadding=0 cellspacing=0>"
response.write"                        <tr>"
response.write"                          <td><img src=/images/logo.png width=188 height=83></td>"
response.write"                          <td width=40>&nbsp;</td>"
response.write"                        </tr>"
response.write"                      </table>"
response.write"                      </td>"
response.write"                      <td width=30 height=300 valign=middle><table width=1 border=0 cellspacing=0 cellpadding=0>"
response.write"                        <tr>"
response.write"                          <td width=1 ><img src=images/loc.gif width=1 height=326></td>"
response.write"                        </tr>"
response.write"                      </table></td>"
response.write"                      <td width=525 height=400 valign=middle><table width=90% border=0 cellspacing=0 cellpadding=0>"
response.write"                        <tr>"
response.write"                          <td><font color=#FFFFFF><p>登陆成功！<br>"
response.write"                          后台文件准备中...<br>"
response.write"                          </p></font>"
response.write"                          </td>"
response.write"                        </tr>"
response.write"                      </table></td>"
response.write"                    </tr>"
response.write"                  </table></td>"
response.write"              </tr>"
response.write"              <tr></tr>"
response.write"                <tr>"
response.write"                  <td width=33%  height=65 valign=bottom background=images/lobut.gif></td>"
response.write"              </tr>"
response.write"        </table></td>"
response.write"  </tr>"
response.write"</table>"
%>
<meta HTTP-EQUIV=refresh Content='2;url=index.asp'>
<%
end if
rs.close
set rs=nothing
end if
%>
<br>
<script src="log/contpage.asp"></script>
 