关闭

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

标签: aspfunctionwindowsoperasqlunix
3689人阅读 评论(4) 收藏 举报
分类:
<!-- #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
%>
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:174174次
    • 积分:2682
    • 等级:
    • 排名:第15848名
    • 原创:57篇
    • 转载:0篇
    • 译文:0篇
    • 评论:164条
    最新评论
    友情链接