<%
'Dim objFSO,objCountFile ' object vars for FSO and File
'Dim strCountFileName ' filename of count text file
'Dim iCount ' count variable
'Dim I ' standard looping var
'' Determine whether we use images or plain text
' 'You could just set this to True or False instead
' 'Compute our count file's filename
' 'This is based on the file from which you call count.asp
' 'It basically takes that name and appends a .cnt so I don't
' 'accidently overwrite any files. If for some reason you have
' 'a file named script_name.asp.cnt then change this or watch out!
'strCountFileName = Server.MapPath(Request.ServerVariables("SCRIPT_NAME") & ".cnt")
'' Create FileSystemObject to deal with file access
'Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'' Open the file as a text stream (1 = ForReading, True = Create)
'Set objCountFile = objFSO.OpenTextFile(strCountFileName, 1, True)
'' Read the current count from the file
'If Not objCountFile.AtEndOfStream Then
' ' Set value to contents of the file
' iCount = CLng(objCountFile.ReadAll)
'Else
' ' If no file exists or it's empty start at 0
' iCount = 0
'End If
'' Close the file and destroy the object
'objCountFile.Close
'Set objCountFile = Nothing
'' Increment the count
'iCount = iCount + 1
'' Overwrite existing file and get a text stream to new one
'Set objCountFile = objFSO.CreateTextFile(strCountFileName, True)
' 'Write updated count
'objCountFile.Write iCount
'' Close the file and destroy the object
'objCountFile.Close
'Set objCountFile = Nothing
' 'Destroy the FSO object
'Set objFSO = Nothing
Dim ObjCounterFile, ReadCounterFile, WriteCounterFile
Dim CounterFile
Dim CounterHits
counterhits=0
Set ObjCounterFile = Server.CreateObject("Scripting.FileSystemObject")
CounterFile = Server.MapPath ("counter.txt")
Set ReadCounterFile= ObjCounterFile.OpenTextFile (CounterFile, 1, True)
If Not ReadCounterFile.AtEndOfStream Then
CounterHits = Trim(ReadCounterFile.ReadLine)
If CounterHits = "" Then CounterHits = 0
Else
CounterHits = 0
End If
ReadCounterFile.Close
Set ReadCounterFile = Nothing
CounterHits = CounterHits + 1
Set WriteCounterFile= ObjCounterFile.CreateTextFile (CounterFile, True)
WriteCounterFile.WriteLine(CounterHits)
WriteCounterFile.Close
Set WriteCounterFile = Nothing
Set ObjCounterFile = Nothing
%>
Visitor Number
<%
=Response.Write(CounterHits)%>