|
<html>
<head>
<title>Hit
Counter</title>
</head>
<body
bgcolor="white"
text="black">
<div
align="center">
<h3>Hit
Counter</h3>
<%
Dim
FileSystemObject,
TextStreamObject,
FileObject,
NumberVisitors,
LoopCount
'-----------------------------------------------------------
' Get and open hit count
file
'-----------------------------------------------------------
Set
FileSystemObject= Server.CreateObject("Scripting.FileSystemObject")
Set
FileObject =
FileSystemObject.GetFile(Server.MapPath("hit_counter.txt"))
Set
TextStreamObject =
FileObject.OpenAsTextStream
'-----------------------------------------------------------
' Increment count
'-----------------------------------------------------------
NumberVisitors
= CLng(TextStreamObject.ReadAll)
NumberVisitors
= NumberVisitors
+ 1
Set
TextStreamObject =
FileSystemObject.CreateTextFile(Server.MapPath("hit_counter.txt"))
TextStreamObject.Write
CStr(NumberVisitors)
Set
FileSystemObject= Nothing
Set
TextStreamObject = Nothing
Set
FileObject = Nothing
'-----------------------------------------------------------
'Display the hit count as
text
'-----------------------------------------------------------
%>
Text Version of Count
<br>
<%= NumberVisitors
%>
<br>
<br>
'----------------------------------------------------------
'Display the hit count as
images using loop
'-----------------------------------------------------------
For
LoopCount
= 1 to
Len(NumberVisitors)
%>
<img src="counter_images/<%=
Mid(NumberVisitors,
LoopCount,
1) %>.gif" alt="<%=
Mid(NumberVisitors,
LoopCount,
1) %>">
<% Next %>
<br>
</div>
</body>
</html> |