<!--#include virtual="/incs/config.asp"-->
<%chk_log()%>
<%
if  session("agentname")=""  or isnull(session("agentname")) then
chk_newpwr 4,17,1
end if
'''''''
if session("sysclass")<1 and (session("agentname")=""  or isnull(session("agentname")))  then
call errorpage(-2,"非法操作(001)！")
end if
'''''''
'''''''''
   Nlogname=trim(SafeRequest("lognme"))
   Nlogname=replace(Nlogname,"'","单引")

yourname=Nlogname

   		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)

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
if session("agentname")=""  or isnull(session("agentname")) then
l_agt=session("usrname")
else
l_agt=session("agentname")
end if
query="insert lgnlst(l_unme,l_agt,l_ip,l_addtme,l_os,l_vs,l_prv,l_ifok,l_dot) values('"&yourname&"','"&l_agt&"','"&l_ip&"',getdate(),'"&l_os&"','"&l_vs&"','"&l_prv&"',0,'"&l_dot&"')"
conn.execute query,1,1
findlastid logid
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
recs=chk_usrpss(Nlogname,"会员名称",4,16)

''''''''''''''''''目的会员是否存在 
      query="select * from v_memlst where u_nme='"&Nlogname&"'"
      rs.open query,conn,1,1
      if rs.RecordCount<=0 then
       call errorpage(-2,"对不起！非法操作！(002)...")
      end if
	  tagsysclass=cint(rs("u_sys"))
''''''''''''''''''目的会员是否存在
''''''''''''''''''''''''''''''''判断是否可以代替目的会员操作
  adminpass=false  //以此值为true判断是否可以代替目的会员操作 
	 if session("agentname")=""  or isnull(session("agentname")) then'''若没有以某目的会员身份操作 
	    chk_newpwr 4,17,9
	    if  Nlogname=lcase(trim(session("usrname"))) then
               call errorpage(-2,"您没有必要执行此切换，谢谢！")
	    elseif   session("sysclass")>=4 then
		  if session("sysclass")<tagsysclass then   ''######################如果平级之间不能切换，则把<号改为<=,平级之间能切换，则用<
		     call errorpage(-2,"对不起，您不能切换到此会员！")
		  else
		   adminpass=true
		   session("agentname")=session("usrname")
		   session("agentpass")=session("usrpass")
		   end if
		end if
	 else//已经以某目的会员身份操作 
 
	     if  Nlogname=lcase(trim(session("agentname"))) then
		    adminpass=true
			session("agentname")=""
			session("agentpass")=""
		 else
		    query="select * from v_memlst where u_nme='"&session("agentname")&"'"
			rs1.open query,conn,1,1
			if rs1.recordcount<>1 then
               call errorpage(-2,"非法操作！(003)")
               response.end
			else
			Rsysclass=rs1("u_sys")
			
			   if Rsysclass>=1 then
			   if Rsysclass<tagsysclass then   ''######################如果平级之间不能切换，则把<号改为<=,平级之间能切换，则用<
			     call errorpage(-2,"对不起，您不能切换到此会员下！")
				else
		       	  adminpass=true
				end if  
			   end if
		    end if
			rs1.close
	    end if 
  end if
''''''''''''''''''''''''''''''''判断是否可以代替目的会员操作
''''''''''''''''''''''''''''''''''''''''''''''''''''进行身份替代 

if  adminpass=true then
       temppower=session("syspower")
	   session("oldpower")=temppower
        session("usrid")=rs("u_id")
		session("usrname")=trim(rs("u_nme"))
		session("usrpass")=trim(rs("u_pss"))
		session("usrlock")=rs("u_lck")
		session("usrclass")=clng(rs("u_prc"))
		session("sysclass")=rs("u_sys")
		session("usremail")=rs("u_eml")
		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")=trim(rs("c_nme"))

		query="select  pw_str,pw_nme from pwrlst where pw_id="&rs("u_pwr")
		rs1.open query,conn,1,1
		if rs1.recordcount=1 then
		session("syspower")=trim(rs1("pw_str"))
		  session("syspwrcls")=rs("u_pwr")
		  session("syspwrnme")=trim(rs1("pw_nme"))
		end if
		rs1.close
        rs.close
		query="update lgnlst set l_ifok=1 where l_id="&logid
		conn.execute query,1,1
		conn.close
		response.write "<script>"
		response.write "top.location.href='/master/';"
		response.write "</script>"		
		response.end
else   
       call errorpage(-2,"对不起！非法操作！(004)...")

end if
conn.close
''''''''''''''''''''''''''''''''''''''''''''''''''''进行身份替代  
				function transip(sip)
	tip=cstr(sip)
	sip1=left(tip,cint(instr(tip,".")-1))
	tip=mid(tip,cint(instr(tip,".")+1))
	sip2=left(tip,cint(instr(tip,".")-1))
	tip=mid(tip,cint(instr(tip,".")+1))
	sip3=left(tip,cint(instr(tip,".")-1))
	sip4=mid(tip,cint(instr(tip,".")+1))
	transip=cint(sip1)*256*256*256+cint(sip2)*256*256+cint(sip3)*256+cint(sip4)
end function
%>
