corsasport.co.uk
 

Corsa Sport » Message Board » General Chat » Little help needed with ASP script... » Post Reply

Post Reply
Who Can Post? All users can post new topics and all users can reply.
Icon:
Formatting Mode:
Normal
Advanced
Help

Insert Bold text Insert Italicized text Insert Underlined text Insert Centered text Insert a Hyperlink Insert Email Hyperlink Insert an Image Insert Code Formatted text Insert Quoted text
Message:
HTML is Off
Smilies are On
BB Code is On
[img] Code is On
Post Options: Disable smileys?
Turn BBCode off?
Receive email notification of new replies?

Ian

posted on 1st May 04 at 10:37

I wouldn't check what's already in there on the write.

Just log the line, the use a grouping query to do the counting. That's how the post distribution thing in your profile works, group by forum and order by the count, descending. There's also a bit of maths in there to divide the count figure by post total and give percentage but the SQL is identical.

But yeah, if you're going to go those lenths.... :lol:


Dom

posted on 30th Apr 04 at 19:54

quote:
Originally posted by Ian
Also, why are you logging HTML tags!?

Either write them to a db or csv or something, then write a script to traverse the data and make you a page. Anything else gives you huge web pages very quickly.


its probably because it nice and easy mate :) Although yea, i agree, loading a 10+mb html page isnt the nicest thing in the world :lol:
TBH, there are loads of ways to do it, like dumping the data into a db etc But then you could add a part where it will compare the sent HTTP_REFERER head to whats in the database (storage solution) then if it isnt in the db then it will add it, otherwise it will increase a value next to the already existing HTTP_REFERER website string. But then you start to write a full blown website logger and if thats the case you might as well just download a freebie logger...plenty of them and will offer loads more info :thumbs:


Dom

posted on 30th Apr 04 at 19:51

put it in anyways mate and tell the head that its impossible etc :)

Also, btw mate, that code can be written alot simpler, by doing:

code:

<%
Dim strReferer
strReferer = Request.ServerVariables("HTTP_REFERER")

If strReferer <> "http://stnicholas-school.org.uk" or strReferer <> "http://www.stnicholas-school.org.uk" or strReferer <> "" or not IsEmpty(Session("LogIn")) then
Const ForAppending = 8
Const Create = True
Dim FSO
Dim TS
Dim strLog

Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set TS = FSO.OpenTextFile(Server.MapPath("logs\referers.htm"), ForAppending, Create)
strlog = "<table width=""100%"" border=""1"" cellspacing=""0"">"
strlog = strlog & "<tr>"
strlog = strlog & "<td width=""20%"" class=""style5"">" & NOW() & "</td>"
strlog = strlog & "<td width=""20%"" class=""style5"">" & Request.ServerVariables("URL") & "?" & Request.ServerVariables("QUERY_STRING") & "</td>"
strlog = strlog & "<td width=""20%"" class=""style5""><a href=""" & Request.ServerVariables("HTTP_REFERER") & """ target=""_blank"">" & Request.ServerVariables("HTTP_REFERER") & "</a></td>"
strlog = strlog & "<td width=""40%"" class=""style1 style4"">" & Request.ServerVariables("HTTP_USER_AGENT") & "</td>"
strlog = strlog & "</tr></table>"

TS.write strlog
TS.Writeline ""

Session("LogIn") = "yes"
Set TS = Nothing
Set FSO = Nothing

End If
%>



although im not sure how many "or" statments you can use :lol: so it might not work, but im 90% sure that the way i just chopped it, it will :)


Ian

posted on 30th Apr 04 at 19:39

Also, why are you logging HTML tags!?

Either write them to a db or csv or something, then write a script to traverse the data and make you a page. Anything else gives you huge web pages very quickly.


Ian

posted on 30th Apr 04 at 19:37

Impossible - if the browser isn't providing this variable then you've no way of forcing it to be there. I'm sure some of the more obscure browsers can be configurered to turn it off as well - you'd never see it from these.


PaulW

posted on 30th Apr 04 at 19:16

aye I'm already getting that via the normal web-logs, its I was just asked to get this info by the head as he wants to know who is linking to us...

bugger :(


Dom

posted on 30th Apr 04 at 19:13

no, when a new window is opened, there isnt a referer heading :( Only way to do it mate, if you want to log where there from is by IP address, then do a DNS on them and do it that way :) Atleast you will know what ISP there using, but thats about it mate :)


PaulW

posted on 30th Apr 04 at 18:02

Thought I best include the whole code...

code:
<%
Dim blnValidEntry

blnValidEntry = True

If not IsEmpty(Session("LogIn")) then blnValidEntry = False

If Left(Request.ServerVariables("HTTP_REFERER"), 31)="http://stnicholas-school.org.uk" Then
blnValidEntry = False
End If

If Left(Request.ServerVariables("HTTP_REFERER"), 35)="http://www.stnicholas-school.org.uk" Then
blnValidEntry = False
End If

If Request.ServerVariables("HTTP_REFERER") = "" Then
blnValidEntry = False
End If

If blnValidEntry Then
Const ForAppending = 8
Const Create = True
Dim FSO
Dim TS
Dim LogFileName
Dim strLog

LogFileName = Server.MapPath("logs\referers.htm")

Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set TS = FSO.OpenTextFile(LogFileName, ForAppending, Create)
strlog = "<table width=""100%"" border=""1"" cellspacing=""0"">"
strlog = strlog & "<tr>"
strlog = strlog & "<td width=""20%"" class=""style5"">" & NOW() & "</td>"
strlog = strlog & "<td width=""20%"" class=""style5"">" & Request.ServerVariables("URL") & "?" & Request.ServerVariables("QUERY_STRING") & "</td>"
strlog = strlog & "<td width=""20%"" class=""style5""><a href=""" & Request.ServerVariables("HTTP_REFERER") & """ target=""_blank"">" & Request.ServerVariables("HTTP_REFERER") & "</a></td>"
strlog = strlog & "<td width=""40%"" class=""style1 style4"">" & Request.ServerVariables("HTTP_USER_AGENT") & "</td>"
strlog = strlog & "</tr></table>"

TS.write strlog
TS.Writeline ""

Session("LogIn") = "yes"
Set TS = Nothing
Set FSO = Nothing

End If
%>


PaulW

posted on 30th Apr 04 at 18:00

I'm trying to log reffering urls to a site I have to look out for, but it only seems to catch them if the referer is from the same window (ie like if you click a link from google), but if its a site which opens links in a new window (like when you click a link on a post here, it opens a new window) it won't catch the referer.

I'm guessing its because its a new window, it doesnt tag it maybe...

I'm using this method to get the referer...

Request.ServerVariables("HTTP_REFERER")

Any other ideas?