您的位置:首页 > 编程语言 > ASP

用asp文件制作的网站流量统计工具

2006-06-02 14:25 411 查看
<!-- #include virtual = "/include/conn.asp" -->
<%
   str_referrer=str_inject(request("referrer"))
  Response.Expires = 0
  queryurl=str_inject(Request.ServerVariables("HTTP_REFERER"))
  str_url=str_inject(Request.ServerVariables("URL"))
  str_ip=str_inject(Request.ServerVariables("REMOTE_ADDR"))
  membername=str_inject(session("member_id"))
  domainurl=str_inject(Request.ServerVariables("SERVER_NAME"))
  thesoft=Request.ServerVariables("HTTP_USER_AGENT")
' 浏览器
if instr(thesoft,"NetCaptor") then
 vsoft="NetCaptor"
elseif instr(thesoft,"MSIE 6") then
 vsoft="MSIE 6.x"
elseif instr(thesoft,"MSIE 5") then
 vsoft="MSIE 5.x"
elseif instr(thesoft,"MSIE 4") then
 vsoft="MSIE 4.x"
elseif instr(thesoft,"Netscape") then
 vsoft="Netscape"
elseif instr(thesoft,"Opera") then
 vsoft="Opera"
else
 vsoft="Other"
end if
' 操作系统
if instr(thesoft,"Windows NT 5.0") then
 vOS="Win 2000"
elseif instr(thesoft,"Windows NT 5.1") then
 vOs="Win XP"
elseif instr(thesoft,"Windows NT") then
 vOs="Win NT"
elseif instr(thesoft,"Windows 9") then
 vOs="Win 9x"
elseif instr(thesoft,"unix") or instr(thesoft,"linux") or instr(thesoft,"SunOS") or instr(thesoft,"BSD") then
 vOs="类Unix"
elseif instr(thesoft,"Mac") then
 vOs="Mac"
else
 vOs="Other"
end if
if len(membername)=0 then
   membername="游客"
end if
  str_ip=cip(str_ip)
  sql="select top 1 * from ip where onip<=" & str_ip & " and offip>=" & str_ip
  set rs=conn.execute(sql)
  if not rs.eof then
     addr=rs("addj") & " " & rs("addf")
  else
     addr=""
  end if
  rs.close
  queryurl=replace(queryurl,"http://","")
  if len(queryurl)<>0 then
  queryurl=mid(queryurl,instr(queryurl,"/")+1,len(queryurl)-1)
   if instr(queryurl,"?")<>0 then
  queryurl=left(queryurl,instr(queryurl,"?")-1)
  end if
    if instrrev(queryurl,"/",-1)=len(queryurl) then
         queryurl=queryurl & "default.asp"
     end if
  end if
  sql="insert into urlcount(refferer,queryurl,visittime,domainurl,membername,ip,addr,vos,vsoft) values('" & str_referrer & "','" & queryurl & "',getdate(),'" & domainurl & "','" & membername & "','" & str_ip & "','" & addr & "','" & vOS & "','" & vsoft & "')"
  conn.execute(sql)
 
  connclose
 
  function str_inject(str)
     if len(str)<>0 then
      str_inject=replace(str,"'","''")
   else
      str_inject=""
   end if
  end function
 
  function cip(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))
 cip=cint(sip1)*256*256*256+cint(sip2)*256*256+cint(sip3)*256+cint(sip4)
end function
%>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息