%
'Dimension variables
Dim fsoObject 'File System Object
Dim tsObject 'Text Stream Object
Dim filObject 'File Object
Dim lngVisitorNumber 'Holds the visitor number
Dim intWriteDigitLoopCount 'Loop counter to display the graphical hit count
'Create a File System Object variable
Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")
'Initialise a File Object with the path and name of text file to open
Set filObject = fsoObject.GetFile(Server.MapPath("hit_count.txt"))
'Open the visitor counter text file
Set tsObject = filObject.OpenAsTextStream
'Read in the visitor number from the visitor counter file
lngVisitorNumber = CLng(tsObject.ReadAll)
'Increment the visitor counter number by 1
lngVisitorNumber = lngVisitorNumber + 1
'Create a new visitor counter text file over writing the previous one
Set tsObject = fsoObject.CreateTextFile(Server.MapPath("hit_count.txt"))
'Write the new visitor number to the text file
tsObject.Write CStr(lngVisitorNumber)
'Reset server objects
Set fsoObject = Nothing
Set tsObject = Nothing
Set filObject = Nothing
'Display the hit count as text
' Response.Write(lngVisitorNumber)
'Loop to display graphical digits
'For intWriteDigitLoopCount = 1 to Len(lngVisitorNumber)
'Display the graphical hit count
' Response.Write("")
'Next
'Wfile=server.mappath("\") & "\cgi-bin\hit_count.txt"
'Set fs = CreateObject("Scripting.FileSystemObject")
'Set a = fs.OpenTextFile(Wfile)
'hits = Clng(a.ReadLine)
'hits = hits + 1
'a.close
'Set a = fs.CreateTextFile(Wfile,True)
'a.WriteLine(hits)
'a.Close
' Lines 2. We will need a text file with a number as its unique content. The path to that file will be openned in variable "Wfile". Creating this page within cgi-bin directory is a good way to prevent visitor from accesing our counter (they will get an error when trying to access a ".txt
' file within cgi-bin directory).
' Lines 4-8. We will open our file, read the content to a variable ("hits"), and in line 7 the variable will be increased by one.
' Lines 10-12 . We will create a new file with the same name (overwriting the previous file) with the content in "hits".
' Line 14. The response page will be a javascript code containing the number of hits.
%>
| American Public Works Association | South
Bay Area Chapter |

Please excuse us as we transition our website... Visit our new website at southbay.apwa.net
2008
APWA Project of the Year Award
APWA
Monthly Luncheon Details and RSVP
Online at our new website
Monthly Newsletter - Visit our new website at southbay.apwa.net
Become a Chapter Supporter in 2008!
If you don't have a copy of Acrobat Reader, you can get a FREE copy from Adobe by going to their web site at: http://www.adobe.com.
Welcome to the APWA South Bay Area Chapter Website. Please feel free to send any comments or suggestions on how we can serve you better on this website to our webmaster.
| Comments? |
Home