兔子专栏

刘晓逸(liuxiaoyi666)的小地盘

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

<!-- #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
%>
阅读更多
个人分类: Asp3编程
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭