?? 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 + -