防刷新计数器
来源:互联网 发布:sql语言有两种使用方式 编辑:程序博客网 时间:2024/04/29 00:27
需要支持fso 需建立文本文件count.txt
调用格式<%=read_%>
文件counter.asp代码
<%
dim fs,filename,txt,content,total,counter_lenth
counter_lenth=10 '设置显示数据的最小长度,如果小于实际长度则以实际长度为准
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 '如不存在保存数据的文件则创建新文件并写入数据0
set fs=nothing
end if
set txt=fs.OpenTextFile(filename)
If txt.AtEndOfStream Then
Application("Counter")=0 '如果文件中没有数据,则初始化Application("Counter")的值(为了容错)
else
Application("Counter")=txt.readline
end if
'判断是否访问过,系统默认一个小时为刷新访问期间,需要客户端支持cookie,可通过更改DateAdd的参数值来更改
if Request.Cookies("countcookie")="" then
Response.Cookies("countcookie")="visited"
Response.Cookies("countcookie").Expires=DateAdd("h", 1, now)
Application.Lock
Application("Counter") = Application("Counter") + 1
Application.UnLock
end if
save_ '调用保存函数保存数据
Function save_ '保存计数函数
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
Function Digital ( counter ) '显示数据函数
Dim i,MyStr,sCounter
sCounter = CStr(counter)
For i = 1 To Len(sCounter)
MyStr = MyStr & Mid(sCounter, i, 1)
'MyStr = MyStr & "<IMG SRC=改成你自己的图片存放的相对目录/" & Mid(sCounter, i, 1) & ".gif>"
'如有图片,可用此语句调用
Next
Digital = MyStr
End Function
Function read_ '读取计数函数
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 right(Digital (total),4) '调用显示函数
set fs=nothing
End Function
%>
- 防刷新计数器
- 防刷新的php文本计数器
- 简单的网站页面计数器(防刷新)
- 一个简单的图形计数器(防刷新增加访客人数)
- PHP简单防刷计数器
- PHP简单防刷计数器
- php简单防刷计数器
- php简单防刷计数器
- jsp防刷新记数器
- 防刷新方法
- jsp防刷新记数器
- 防刷新重复提交
- 防恶意刷新代码
- net 防刷新
- PHP防刷新Solution
- 防页面刷新提交
- 防刷新页面
- 防刷新倒计时
- asp.net学习资源列表
- asp分页函数
- ACE的安装,输出hello ace
- 关于datagrid超级链接列传参数到新的页面的方法求助
- Tomcat启动分析
- 防刷新计数器
- 某县政府网下载的文件变成灰鸽子 Backdoor.Win32.Hupigon.aku 了
- 编程方式的思考
- 主键表和外键表别搞混了
- 未来的操作系统
- c#程序打包,同时把netframework也打包进去
- 莉香
- 3D游戏从入门到精通-31
- 测试VGA12H直接写屏速度 V1.1