📄 ajcount.asp
字号:
<%@ CODEPAGE = "936" %>
<%
'#################################
'
' 阿江简易计数系统
' V 0.95
' Ajiang info@ajiang.net
' www.ajiang.net
'
' 版权所有·抄袭挪用必究
'
'#################################
'##### ★ 参 数 设 置 ★ #####
' 1、保存IP个数
SaveIP = 50
' 2、数据文件名
DataFile = "countdata.txt"
' 3、创建FSO(对象)的字符串
FSOstr = "Scripting.FileSystemObject"
' 4、统计器名称
CountName = "阿江守候访问统计"
' 说明:
' 1.比如设置为50,只有当你访问网页后又有超过50个人访问了这
' 个网页,你再访问才会计数,如果从你上次访问到这次访问之间没有
' 那么多人访问,则不计数。
' 2.计数数据将保存在这个文件中,可以使用带有相对路径的字串
' 3.已设置为FSO的默认名字,有的服务器已将FSO改名,
'##### ★ 代 码 开 始 ★ #####(以下请勿修改)
' 忽略所有错误
on error resume next
' 得到本文件的名字
mename=Request.ServerVariables("SCRIPT_NAME")
' 数据文件的绝对路径
thedatafile=server.MapPath(datafile)
'*******************************
' 转入相应的页面
'*******************************
tpage=Request("tpage")
select case tpage
'***************************************************************
' 查看页面
case "view"
'创建FSO对象,如果不支持FSO,则转入错误页
Set FSO = CreateObject(FSOstr)
If Err<>0 then Response.Redirect mename & "?tpage=nofso"
' 检查数据文件是否存在
infile=fso.FileExists(thedatafile)
%>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="CopyRight" content="Ajiang http://www.ajiang.net info@ajiang.net">
<TITLE><%=CountName%> - 查看统计数据</TITLE>
<style>
<!--
BODY
{
FONT-FAMILY: 宋体;
FONT-SIZE: 9pt
}
TD
{
FONT-SIZE: 9pt
}
A
{
COLOR: #000000;
TEXT-DECORATION: none
}
A:hover
{
COLOR: #3F8805;
TEXT-DECORATION: underline
}
.input
{
BORDER: #111111 1px solid;
FONT-SIZE: 9pt;
BACKGROUND-color: #F8FFF0
}
.backs
{
BACKGROUND-COLOR: #3F8805;
COLOR: #ffffff;
}
.backq
{
BACKGROUND-COLOR: #EEFEE0
}
.backc
{
BACKGROUND-COLOR: #3F8805;
BORDER: medium none;
COLOR: #ffffff;
HEIGHT: 18px;
font-size: 9pt
}
.fonts
{
COLOR: #3F8805
}
-->
</STYLE>
</HEAD>
<BODY>
<%
if infile then
set thefile=fso.OpenTextFile(thedatafile)
stroldfile=thefile.readall
thefile.close
set thefile=nothing
'分解数据文件,获得数据
vstr=split(stroldfile,vbcrlf)
'访问天数、平均每天访问量
vdays=now()-cdate(vstr(4))
vdayavg=vstr(1)/vdays
vdays=int((vdays*10^3)+0.5)/10^3
if vdays<1 then vdays="0" & vdays
vdayavg=int((vdayavg*10^3)+0.5)/10^3
%>
<table width="100%" height="95%">
<tr>
<td width="100%" valign=middle>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#3F8805" width="300" align=center>
<tr height=18 class=backs align=center><td width=300 colspan=2><%=CountName%></td></tr>
<tr height="18" class=backq>
<td align=left width="130"> 总浏览量</td>
<td align=left width="170"> <%=vstr(0)%></td>
</tr>
<tr height="18" class=backq>
<td align=left> 总访问数</td>
<td align=left> <%=vstr(1)%></td>
</tr>
<tr height="18" class=backq>
<td align=left> 今日访问数</td>
<td align=left> <%=vstr(2)%></td>
</tr>
<tr height="18" class=backq>
<td align=left> 昨日访问数</td>
<td align=left> <%=vstr(3)%></td>
</tr>
<tr height="18" class=backq>
<td align=left> 开始统计日期</td>
<td align=left> <%=vstr(4)%></td>
</tr>
<tr height="18" class=backq>
<td align=left> 统计天数</td>
<td align=left> <%=vdays%></td>
</tr>
<tr height="18" class=backq>
<td align=left> 平均日访问量</td>
<td align=left> <%=vdayavg%></td>
</tr>
<tr height="18" class=backq>
<td align=left> 最高日访问量</td>
<td align=left> <%=vstr(7)%></td>
</tr>
<tr height="18" class=backq>
<td align=left> 发生日期</td>
<td align=left> <%=vstr(8)%></td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#3F8805" width="300" align=center>
<tr height="18">
<td align=center width=300 height=40>AJ-Stat <a href="http://www.ajiang.net" target="_blank">www.ajiang.net</a> (c)2002</td>
</tr>
</table>
</td>
</tr>
</table>
<%else%>
<table width="100%" height="95%">
<tr>
<td width="100%" valign=middle>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#3F8805" width="250" align=center>
<tr height="18" class=backq>
<td align=center width=250 height=80>还没有任何统计数据。请将嵌入代码放<br>在您要统计的页面。</td>
</tr>
</table>
</td>
</tr>
</table>
<%end if%>
</body>
</html>
<%
'***************************************************************
' 不支持FSO的错误页面
case "nofso"
%>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE><%=CountName%> - 错误信息</TITLE>
<style>
<!--
BODY
{
FONT-FAMILY: 宋体;
FONT-SIZE: 9pt
}
TD
{
FONT-SIZE: 9pt
}
A
{
COLOR: #000000;
TEXT-DECORATION: none
}
A:hover
{
COLOR: #3F8805;
TEXT-DECORATION: underline
}
.input
{
BORDER: #111111 1px solid;
FONT-SIZE: 9pt;
BACKGROUND-color: #F8FFF0
}
.backs
{
BACKGROUND-COLOR: #3F8805;
COLOR: #ffffff;
}
.backq
{
BACKGROUND-COLOR: #EEFEE0
}
.backc
{
BACKGROUND-COLOR: #3F8805;
BORDER: medium none;
COLOR: #ffffff;
HEIGHT: 18px;
font-size: 9pt
}
.fonts
{
COLOR: #3F8805
}
-->
</STYLE>
</HEAD>
<BODY>
<table width="100%" height="95%">
<tr>
<td width="100%" valign=middle>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#3F8805" width="250" align=center>
<tr height="18" class=backq>
<td align=center width="250" height=80>对不起,您的服务器不支持FSO组<br>件,无法使用本系统。</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<%
'***************************************************************
' 计数页面
case else
'创建FSO对象,如果不支持FSO,则转入错误页
Set FSO = CreateObject(FSOstr)
If Err<>0 then Response.Redirect mename & "?tpage=nofso"
' 检查数据文件是否存在
infile=fso.FileExists(thedatafile)
' 网页立即过期,防止漏统计
Response.Expires = -1
' 检查客户端IP
vip=Request.ServerVariables("Remote_Addr")
if infile=false then
vtop=1
vips=1
vtoday=1
vyesterday=0
vstarttime=now()
vtodaytime=date()
vmax=1
vmaxtime=date()
SaveStr=vtop & VbCrlf & vips & VbCrlf & vtoday & VbCrlf & vyesterday & VbCrlf & _
vstarttime & VbCrlf & vtodaytime & vbcrlf & "#" & vip & "#" & vbcrlf & vmax & vbcrlf & vmaxtime
'set thefile=fso.OpenTextFile(thedatafile,ForWriting)
set thefile=fso.CreateTextFile (thedatafile)
thefile.write(savestr)
thefile.close
set thefile=nothing
set fso=nothing
'如果数据文件本已存在
else
'先从数据文件中读取数据
set thefile=fso.OpenTextFile(thedatafile)
stroldfile=thefile.readall
thefile.close
set thefile=nothing
'分解数据文件,获得数据
vstr=split(stroldfile,vbcrlf)
vtop=vstr(0)
vips=vstr(1)
vtoday=vstr(2)
vyesterday=vstr(3)
vstarttime=vstr(4)
vtodaytime=vstr(5)
vsaveips=vstr(6)
if ubound(vstr)>7 then
vmax=vstr(7)
vmaxtime=vstr(8)
else
vmax=0
end if
'向现有数据中追加值
vtop=vtop+1
if instr(vsaveips,"#" & vip & "#")=false then
vips=vips+1
if cdate(vtodaytime)=date() then
vtoday=vtoday+1
else
vyesterday=vtoday
vtoday=1
vtodaytime=date()
end if
if clng(vtoday)>clng(vmax) then
vmax=vtoday
vmaxtime=date()
end if
vsaveips=left(vsaveips,len(vsaveips)-1)
vsaveips=right(vsaveips,len(vsaveips)-1)
howip=split(vsaveips,"#")
if ubound(howip) < SaveIP then
vsaveips="#" & vsaveips & "#" & vip & "#"
else
vsaveips=replace("#" & vsaveips,"#" & howip(0) & "#","#") & "#" & vip & "#"
end if
end if
'写入数据文件
SaveStr=vtop & VbCrlf & vips & VbCrlf & vtoday & VbCrlf & vyesterday & VbCrlf & _
vstarttime & VbCrlf & vtodaytime & vbcrlf & vsaveips & vbcrlf & vmax & vbcrlf & vmaxtime
set thefile=fso.CreateTextFile (thedatafile)
thefile.write(savestr)
thefile.close
set thefile=nothing
set fso=nothing
end if
'根据要求输出
style=Request("style")
select case style
case "counter" 'LOGO
outstr="<table width='88' border='0' cellspacing='0' cellpadding='0' height='31' background='http://www.ajiang.net/count/images/stat_counter.gif'><tr><td height='5' width='24'></td><td height='5' width='57'></td><td height='5' width='7'></td></tr><tr><td height='16'></td><td height='16' align='center' valign='top'><marquee behavior='loop' scrollDelay='100' scrollAmount='3' style='font-size: 12px; line-height=15px'><a href='" & mename & "?tpage=view' target='_blank' style='color: #ffffff; text-decoration: none'>"
outstr=outstr & "<font face='Arial, Verdana, san-serif' color='#407526'>总访问量: " & vtips & " 今日访问: " & vtoday & " 昨日访问: " & vyesterday & " 最高日访问: " & vmax & " 发生日期: " & vmaxtime
outstr=outstr & "</font>"
outstr=outstr & "</a></marquee></td><td height='16'></td></tr><tr><td height='10'></td><td height='10'></td><td height='10'></td></tr></table>"
case "icon" 'ICON
outstr="<a href='" & mename & "?tpage=view' title='" & CountName & _
"\n访问总量: " & vtop & _
"\n今日访问量: " & vtoday & "\n昨日访问量: " & vyesterday & _
"\n最高每日: " & vmax & _
"\n发生日期: " & vmaxtime
outstr=outstr & "' target='_blank'><img border='0' src='" & theurl & _
"http://www.ajiang.net/count/images/stat_icon.gif'></a>"
case "atext" '带有连接的访问数
outstr="<a href='" & mename & "?tpage=view' title='" & CountName & _
"\n总量: " & vtop & _
"\n今日访问量: " & vtoday & "\n昨日访问量: " & vyesterday & _
"\n最高每日: " & vmax & _
"\n发生日期: " & vmaxtime
outstr=outstr & "' target='_blank'>" & vips & "</a>"
case "textview" '不带连接的浏览数
outstr=vtop
case "textip" '不带连接的访问数
outstr=vips
end select
'输出
Response.Write "document.write(" & chr(34) & outstr & chr(34) & ")"
end select '选择要浏览的页面
'****************** 自定义函数 ********************
'检查组件是否被支持的自定义函数
Function IsObj(strObj)
on error resume next
IsObj=false
dim TestObj
set TestObj=server.CreateObject (strObj)
If -2147221005 <> Err then
IsObj = True
set testobj=nothing
end if
isobj=false
End function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -