在哪能买到军用开山刀:关于Dreamweaver计数器的一个问题

来源:百度文库 编辑:高考问答 时间:2024/05/03 07:57:47
请问我这个计数器为什么一刷新,次数就+2啊,这样得到的数据信息也不准确啊!!请高手指教,谢谢!!

代码如下(含注释);

<%
CountFile=Server.MapPath("simplecounter.txt")
'文件aspconter.txt是用来储存数字的文本文件,初始内容一般是0
Set FileObject=Server.CreateObject("Scripting.FileSystemObject")
Set Out=FileObject.OpenTextFile(CountFile,1,FALSE,FALSE)
counter=Out.ReadLine
'读取计数器文件中的值
Out.Close
'关闭文件
SET FileObject=Server.CreateObject("Scripting.FileSystemObject")
Set Out=FileObject.CreateTextFile(CountFile,TRUE,FALSE)
Application.lock
'方法Application.lock禁止别的用户更改计数器的值
counter= counter + 1
'计数器的值增加1
Out.WriteLine(counter)
'把新的计数器值写入文件
Application.unlock
'使用方法Application.unlock后,允许别的用户更改计数器的值
Response.Write("您是第")
Response.Write("<font color=red>")
Response.Write(counter)
'把计数器的值传送到浏览器,以红(red)色显示给用户
Response.Write("</font>")
Response.Write("位访问者")
Out.Close
'关闭文件
%>
有朋友告诉我说可以加上IP限制,让每个IP访问每天只算1次,请问怎么弄啊,有没有代码的??

谢谢