%
Dim count,fs,counterfile,txt,numhits,showcounter,i
' 計數器
If Request.Cookies("ETN_Counter") <> "Yes" Then
Set fs = Server.CreateObject("Scripting.FileSystemObject")
CounterFile = Server.MapPath("images\counter\counter.txt")
If fs.FileExists(CounterFile) Then
' 讀取計數資料
Set txt = fs.OpenTextFile(CounterFile)
count = CLng(txt.ReadLine)
Else
' 找不到計數器資料檔,建立新的計數資料檔
Set txt = fs.CreateTextFile(CounterFile)
txt.WriteLine CStr(count)
End If
txt.close
count = count + 1 ' 計數值加1
' 覆寫新值回計數檔
Set txt = fs.CreateTextFile(CounterFile, True)
txt.WriteLine(CStr(count))
txt.Close
numHits = count
Response.cookies("ETN_Counter") = "Yes"
else
Set fs = Server.CreateObject("Scripting.FileSystemObject")
CounterFile = Server.MapPath("images\counter\Counter.txt")
If fs.FileExists(CounterFile) Then
' 讀取計數資料
Set txt = fs.OpenTextFile(CounterFile)
count = CLng(txt.ReadLine)
txt.Close
End If
numHits = count
End If
' 顯示計數器
showcounter = ""
for i = 1 to len(numHits)
showcounter = showcounter & ""
next
set txt = nothing
set fs = nothing
%>