<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<% startime=timer()	%>

<!--#include file="inc.asp"-->
<!--#include file="../conn/cls_wry.asp"-->
<!--#include file="../GLOBAL.ASA"-->
outstr=""
<%
 
	
	'收集需要统计的信息
	lyurl=Request.ServerVariables("HTTP_REFERER") 									
	vIp	= request.ServerVariables("Remote_Addr")							'访问者IP
	vSoft=Request.ServerVariables("HTTP_USER_AGENT")
	vReferer = request("referer")
	
	iReferer = request("referer")
	if vReferer="" then
		vReferer=lyurl
		iReferer=lyurl
	else	
		vReferer=Mid(vReferer,8)
		vReferer="http://"&Mid(vReferer,1,instr(vReferer,"/"))
	end if
	
if instr(vSoft,"NetCaptor") then											' 浏览器
		vExplorer="NetCaptor"
		
	elseif instr(vSoft,"MSIE 6") then
		vExplorer="Internet Explorer 6.x"
		
	elseif instr(vSoft,"MSIE 7") then
		vExplorer="Internet Explorer 7.x"
		
	elseif instr(vSoft,"MSIE 5") then
		vExplorer="Internet Explorer 5.x"
		
	elseif instr(vSoft,"MSIE 4") then
		vExplorer="Internet Explorer 4.x"
		
	elseif instr(vSoft,"Netscape") then
		vExplorer="Netscape"
		
	elseif instr(vSoft,"Opera") then
		vExplorer="Opera"
		
	else
		vExplorer="Other"
		
	end if

	if instr(vSoft,"Windows NT 5.0") then										' 操作系统
		vOS="Windows 2000"
		
	elseif instr(vSoft,"Windows NT 5.1") then
		vOS="Windows XP"
		
	elseif instr(vSoft,"Windows NT 5.2") then
		vOS="Windows 2003"
		
	elseif instr(vSoft,"Windows NT") then
		vOS="Windows NT"
		
	elseif instr(vSoft,"Windows 9") then
		vOS="Windows 9x"
		
	elseif instr(vSoft,"unix") or instr(vSoft,"linux") or instr(vSoft,"SunOS") or instr(vSoft,"SunOS") or instr(vSoft,"BSD") or instr(vSoft,"Mac") then 
	
		vOS="Unix & Unix 类"
	else
		vOS="Other"
	end if
	
	vYear=year(now())          	'年
	vMonth=month(now())        	'月
	vDay=day(now())            	'日
	vHour=hour(now())          	'时
	vTime=now()                	'时间 xxxx-xx-xx xx:xx:xx
	vDate=date()
	Tp_Ip = vIp	


	Conn.execute "update websen_flux set refurbish=refurbish+1 where id=1" 		
	
	if DateDiff(DaType,Session("isVisit"),Now()) >= ExpTime then
		vWhereB = Look_Ip(Format_Ip(ReqIP()))
		call RValue("select cWhere as cv,cCWC as cc from websen_cW where cWhere='"&vWhereB&"'",vWhereB)
		call RValue("select cReferer as cv,cCRC as cc from websen_cR where cReferer='"&vReferer&"'",vReferer)
		
	
		Conn.execute "update websen_cH set cTHC=0 where DATEDIFF(hh,HMD,GetDate()) > 1 and cHour=" & vHour 
		Conn.execute "update websen_cD set cTDC=0 where DATEDIFF(dd,DMD,GetDate()) > 1 and cDay=" & vDay 
		Conn.execute "update websen_cM set cTMC=0 where DATEDIFF(mm,MMD,GetDate()) > 1 and cMonth=" & vMonth 
	set rs=server.CreateObject("adodb.recordset")
  sqlk="select * from (select * from websen_cM where cMonth=datepart(mm,getdate())) as lcM,(select * from websen_cD where cDay=datepart(dd,getdate()) ) as lcD,(select * from websen_cH where cHour=datepart(hh,getdate() )) as lcH" 
  rs.open sqlk,Conn,1,3
   rs("cTMC")=clng(rs("cTMC"))+1
   rs("cCMC")=clng(rs("cCMC"))+1
   rs("MMD")=now()
   rs.update
   rs("cTDC")=Application("OnLine")
   rs("cCDC")=Application("OnLine")
   rs("DMD")=now()
   rs.update
   rs("cTHC")=clng(rs("cTHC"))+1
   rs("cCHC")=clng(rs("cCHC"))+1
   rs("HMD")=now()
   rs.update
   rs.close 
sqlk="SELECT * from websen_cE where  cExplorer='" & vExplorer & "'"
rs.open sqlk,Conn,1,3
rs("cCEC")=clng(rs("cCEC"))+1
rs.update
rs.close

sqlk="SELECT * from websen_cO where cOS='" & vOS & "'"
rs.open sqlk,Conn,1,3
rs("cCOC")=clng(rs("cCOC"))+1
rs.update
rs.close
Conn.execute"insert into websen_Last20Vister(cCT,cCIP,cCOS,cCEXP,cCW,cCR)values(getdate(),'"&ReqIP()&"','"&vOS&"','"&vExplorer&"','"&vWhereB&"','"&iReferer&"')"
session("isVisit")=Now()
end if
	
	'1或者没有参数显示图标,0不显示图标,2显示文字
	style = request("style")

	Select Case style
		Case "0"
			c_debug=0

		Case "1",""
			vSql = "select websen_cD.cTDC as todaycount,SumCount.ccount from websen_cD,(select sum(cCMC) as ccount from websen_cM) as SumCount where websen_cD.cDay="&vDay
			Set vRs = GetRs(vSql)
			vCount = vRs("ccount")
			vToday = vRs("todaycount")
			vRs.close

			vTheurl="http://" & Request.ServerVariables("http_host") & Fn_Dir(Request.ServerVariables("url"))
			
			outstr="<a href='" & vTheurl & "login.asp' target='_blank' style='color: #ffffff; text-decoration: none'>"
			outstr=outstr & "<img src='" & vTheurl & "images/mc.gif' border=0 width='15' height='15'>"
			outstr=outstr & "</a><br>"

		Case "2"
			vSql = "select websen_cD.cTDC as todaycount,SumCount.ccount from websen_cD,(select sum(cCMC) as ccount from websen_cM) as SumCount where websen_cD.cDay="&vDay
			Set vRs = GetRs(vSql)
			vCount = vRs("ccount")
			vToday = vRs("todaycount")
			vRs.close
			
            
            vSql="select  * from websen_WebInfo "
	         set vRs=GetRs(vSql)
			 countid = vRs("countid")
			 cRs.close
			 Dim countlen,u
			 
	        countlen = Len(vToday)
			For i = 1 To countlen

 %>
	outstr=outstr+"<img src='/counter/imges/<%=countid%>/<%=mid(vToday,i,1)%>.gif' border=0 width='15' height='15'></img>"	
		
	<%	 
		Next
	End Select

	if c_debug=1 then
		endtime=timer()
		outstr = outstr & "Or:"&FormatNumber((endtime-startime)*1000,3)&"ms"
	end if
	if style="" then 
	Response.Write "document.write(" & chr(34) & outstr & chr(34) & ")"
	else
	 if style=2 then
%>

document.write("共有"+outstr+"人访问本网站")

<%
 end if
end if%>