Looking for a counter just now, because the website has too few visits, it is a bit shabby to put a counter there, so the call can only be simple, you can record it once for one visit to support the facade first. I used to have one, but I was depressed that I couldn't find it. I finally got it through SO on the Internet. The specific program code is as follows.
The count. asp code is:
Copy codeThe Code is as follows: <%
Option explicit
Dim fs, filename, txt, content, total, counter_lenth
Counter_lenth = 1' sets the minimum length of the displayed data. If the length is smaller than the actual length, the actual length prevails.
Set fs = Server. CreateObject ("Scripting. FileSystemObject ")
Filename = server. MapPath ("count.txt ")
If not fs. FileExists (filename) then
Fs. CreateTextFile filename, True, True
Set txt = fs. OpenTextFile (filename, 2, true)
Txt. write 0' if the file for saving data does not exist, create a new file and write DATA 0.
Set fs = nothing
End if
Set txt = fs. OpenTextFile (filename)
If txt. AtEndOfStream Then
Application ("Counter") = 0' if the file contains no data, the value of Application ("Counter") is initialized (for fault tolerance)
Else
Application ("Counter") = txt. readline
End if
Application. Lock
Application ("Counter") = Application ("Counter") + 1
Application. UnLock
Function save _ 'Save the count Function
Set fs = Server. CreateObject ("Scripting. FileSystemObject ")
Filename = server. MapPath ("count.txt ")
Content = Application ("Counter ")
Set txt = fs. OpenTextFile (filename, 2, true)
Txt. write content
Set fs = nothing
End Function
Save _ 'Call the save Function to save data
Function Digital (counter) 'display data Functions
Dim I, MyStr, sCounter
SCounter = CStr (counter)
For I = 1 To counter_lenth-Len (sCounter)
MyStr = MyStr & "0"
'Mystr = MyStr & "Next
For I = 1 To Len (sCounter)
MyStr = MyStr & Mid (sCounter, I, 1)
'Mystr = MyStr & " "'can be called with this statement if there is an image
Next
Digital = MyStr
End Function
Function count_show 'read count Function
Set fs = Server. CreateObject ("Scripting. FileSystemObject ")
Filename = server. MapPath ("count.txt ")
Set txt = fs. opentextfile (filename, 1, true)
Total = txt. readline
Total = cint (total)
'Response. write total
Response. write Digital (total) 'Call the display function
Set fs = nothing
End Function
%>
Then create a new count.txt (which must be in the same level as count. asp Directory), open the file, enter any number in it (don't be so embarrassed), and add it to the top of the page where the counter needs to be displayedCopy codeThe Code is as follows: <! -- # Include file = "count. asp" -->
Add the Code where the counter needs to be displayed.Copy codeThe Code is as follows: <% = count_show %>
OK.