Ignorere IP adresse
Hej alleJeg bruger følgende kode:
<%
mailtype = 1
Set Con = Server.CreateObject(\"ADODB.Connection\")
DBPath = \"DBQ=\" & server.mappath(\"counter/mdkcounter.mdb\")
Con.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; \" & DBPath
Function fixQuotes( theString )
fixQuotes = Replace( theString, \"\'\", \"\'\'\" )
End Function
If Session(\"Count\") = \"\" Then
Session(\"Count\") = \"Hit\"
IP = Request.ServerVariables(\"REMOTE_ADDR\")
Referent = Request.ServerVariables(\"HTTP_REFERER\")
Browser = Request.ServerVariables(\"HTTP_USER_AGENT\")
Sprog = Request.ServerVariables(\"HTTP_ACCEPT_LANGUAGE\")
Host = Request.ServerVariables(\"HTTP_HOST\")
Tid = Time
Dato = Date
If Referent = \"\" Then
Referent = \"Direkte forespørgsel\"
End If
Sql = \"INSERT INTO count (IP, Referent, Browser, Sprog, Host, Tid, Dato) VALUES(\'\" & fixQuotes(IP) & \"\',\'\" & fixQuotes(Referent) & \"\',\'\" & fixQuotes(Browser) & \"\',\'\" & fixQuotes(Sprog) & \"\',\'\" & fixQuotes(Host) & \"\',\'\" & fixQuotes(Tid) & \"\',\'\" & fixQuotes(Dato) & \"\')\"
Con.Execute(Sql)
End If
If mailtype <> \"3\" Then
SqlMail = \"SELECT * FROM mail WHERE ID=1\"
Set RS = Con.Execute(SqlMail)
Dato = RS(\"Dato\")
If DateDiff(\"d\", Dato, Now) > 7 Then
SqlCount = \"SELECT COUNT(*) AS CountHits FROM count\"
Set RSCount = Con.Execute(SqlCount)
TotalHits = RSCount(\"CountHits\")
UgeHits = RSCount(\"CountHits\") - RS(\"Hits\")
If mailtype = 1 Then
Set JMail = Server.CreateObject(\"JMail.SMTPMail\")
JMail.ServerAddress = \"smtp.netsite.dk\"
JMail.Sender = \"sk@autonorden.dk\"
JMail.SenderName = \"Søren Kølander\"
JMail.Subject = \"Website statistik - \" & Date()
JMail.AddRecipient \"sk@autonorden.dk\"
\' JMail.AddRecipientBCC \"din@email.dk\" <- tilføjes hvis der skal sendes en CC mail (kan undlades)
JMail.Body = \"Statistik for website - \" & Date() & vbcrlf & \"- - - - - - - - - - - - - -\" & vbcrlf & \"Totale hits : \" & TotalHits & vbcrlf & vbcrlf & \"Hits siden sidste mail : \" & UgeHits & vbcrlf & \"- - - - - - - - - - - - - -\" & vbcrlf & \"Mere statistik : http://www.dit-domæne.dk/counter/statistik.asp\" & vbcrlf & vbcrlf & \"(C) - MDK WEB I/S\" & vbcrlf & \"http://mdk-web.dk, info@mdk-web.dk\"
JMail.Priority = 3
JMail.Execute
JMail.Close
Set JMail = Nothing
SqlUpdate = \"UPDATE mail SET Dato = \'\" & Now() & \"\', Hits = \'\" & TotalHits & \"\' WHERE ID=1\"
Con.Execute(SqlUpdate)
End If
If mailtype = 2 Then
Set Mailer = Server.CreateObject(\"SMTPsvg.Mailer\")
Mailer.RemoteHost = \"mail.dit-domain.dk\"
Mailer.FromName = \"Dit Navn\"
Mailer.FromAddress = \"afsenderNavn@dit-domain.dk\"
Mailer.Subject = \"Website statistik - \" & Date()
Mailer.AddRecipient \"Modtager Navn\",\"email@dit-domain.dk\"
\' Mailer.AddCC \"modtager.navn\",\"email@adresse.dk\" <- tilføjes hvis der skal sendes en CC mail (kan undlades)
Mailer.BodyText = \"Statistik for website - \" & Date() & vbcrlf & \"- - - - - - - - - - - - - -\" & vbcrlf & \"Totale hits : \" & TotalHits & vbcrlf & vbcrlf & \"Hits siden sidste mail : \" & UgeHits & vbcrlf & \"- - - - - - - - - - - - - -\" & vbcrlf & \"Mere statistik : http://www.dit-domæne.dk/counter/statistik.asp\"
Mailer.SendMail
Set Mailer = Nothing
SqlUpdate = \"UPDATE mail SET Dato = \'\" & Now() & \"\', Hits = \'\" & TotalHits & \"\' WHERE ID=1\"
Con.Execute(SqlUpdate)
End If
End If
Con.Close
Set Con = Nothing
End If
%>
Det hele virker fint, men jeg kunne godt tænke mig at kunne ignore 1 IP adresse, der ikke skulle registreres af tæller systemet.
Mvh
Søren
