あなたは
番目のアクセスです。
<HTML> <HEAD> <TITLE>Access Counter</TITLE> </HEAD> <BODY> あなたは <IMG SRC=counter.asp?col=4> <IMG SRC=counter.asp?col=3> <IMG SRC=counter.asp?col=2> <IMG SRC=counter.asp?col=1> <IMG SRC=counter.asp?col=0> 番目のアクセスです。 </HTML>
<%@Language=VBScript EnableSessionState=False%><%
Option Explicit
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const TristateUseDefault = -2
Const TristateTrue = -1 ' Unicode
Const TristateFalse = 0 ' ASCII
Dim o
Set o = Server.CreateObject("Scripting.FileSystemObject")
If IsEmpty(Application("gifs")) Then
Dim n
n = Array("0.gif", "1.gif", "2.gif", "3.gif", "4.gif", "5.gif", "6.gif", "7.gif", "8.gif", "9.gif")
Dim g(9)
Dim i
For i = 0 To 10 - 1
Dim f
Set f = o.OpenTextFile("c:\web\counter\" & n(i), ForReading, False, TristateTrue)
g(i) = f.Read(100000)
Call f.Close()
Set f = Nothing
Next
Application("gifs") = g
End If
Call Application.Lock()
On Error Resume Next
Dim x
Set x = o.OpenTextFile("c:\web\counter\counterinst.txt", ForReading, False, TristateUseDefault)
Dim s
If Err.Number = 0 Then
s = x.ReadLine()
Application("counter") = CLng(s)
Call x.Close()
ElseIf Err.Number = 53 Then ' ファイルが見つかりません。
On Error GoTo 0
Application("counter") = CLng(1) ' 1 オリジンの場合。
Else
Dim e
e = Err.Number
On Error GoTo 0
Call Err.Raise(e)
End If
Set x = Nothing
Call Application.Unlock()
Dim col
col = CLng(Request.QueryString("col"))
Dim c
c = CLng(Left(Right("0000000000" & CStr(Application("counter")), col + 1), 1))
Response.ContentType = "image/gif"
Call Response.BinaryWrite(Application("gifs")(c))
If col = 0 Then
Call Application.Lock()
Application("counter") = Application("counter") + 1
Set x = o.OpenTextFile("c:\web\counter\counterinst.txt", ForWriting, True, TristateUseDefault)
Call x.WriteLine(CStr(Application("counter")))
Call x.Close()
Set x = Nothing
Call Application.Unlock()
End If
Set o = Nothing
%>