Tack för era tips, jag lyckades lösa problemet såhär:
ReadTextFile.asp
Kod:
<%
Function ReadTextFile(strFilePath)
Dim objFSO, objFile, strAllFile
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFilePath)
strAllFile = ""
If Not(objFile.AtEndOfStream) Then
*strAllFile = objFile.ReadAll
End If
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
strAllFile = Replace(strAllFile, Chr(13)&Chr(10), Chr(13))
strAllFile = Replace(strAllFile, Chr(10)&Chr(13), Chr(13))
ReadTextFile = Split(strAllFile, Chr(13))
End Function
%>
Referrercheck.asp
Kod:
<%referer = Request.ServerVariables("HTTP_REFERER")
If referer <> "" Then
Dim WordArray
WordArray = Split(referer, "/")
url = WordArray(2)
check_visitor = Request.Cookies("visitor")
If check_visitor <> "counted_for" Then
<!--#include file="ReadTextFile.asp"-->
*Const FILE_NAME="referrer-blocked.txt"
*strFilter = ReadTextFile(Server.MapPath(FILE_NAME))
For i = 0 To UBound(strFilter)
If not InStr(1, url, strFilter(i)) > 0 Then
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &Server.MapPath("databas\ref_db.mdb")
Set RecSet = Server.CreateObject("ADODB.RecordSet")
'Response.Write (url)
SQL = "SELECT * FROM referer WHERE url like '%"&url&"%'"
RecSet.Open SQL, Conn
'uppdatbesok = RecSet("antal") + 1
*
*If RecSet.EOF Then
* Response.Cookies("visitor") = "counted_for"
* Response.Cookies("visitor").Expires = Date() + 1
* adress = url
* besok * = 1
* SQL = "Insert Into referer (url,antal) Values('" & adress & "','" & besok & "')"
* Conn.Execute(SQL)
*Else
* Response.Cookies("visitor") = "counted_for"
* Response.Cookies("visitor").Expires = Date() + 1
* datum *= date()
* tid *= Time()
* besok = RecSet("antal") + 1
* Conn.execute("Update referer Set antal='" & besok & "' *WHERE url='" & url & "'")
*End If
*Else
End If
Next
Else
End If
Else
End If%>
referrer-blocked.txt