countpath = "/homepage/count/"'程序安装目录
if Request.QueryString("acms") 1 then %>
document.write("");
else
folderMonth = server.MapPath("/")&countpath&Year(date())&"-"&Month(date())'本月目录
fileToday = folderMonth&"/"&Day(Date())&".txt"'今日文件
fileCount = server.MapPath("/")&countpath&"count.txt"
function openfile(fpath)
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists(fpath) then
Set a = fso.OpenTextFile(fpath)
openfile = a.ReadAll
a.Close
end if
end function
Sub crtfile(fpath,ftext)
Set fso = CreateObject("Scripting.FileSystemObject")
Set a = fso.CreateTextFile(fpath)
a.Write(ftext)
a.Close
end Sub
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.FolderExists(folderMonth) then'建立本月文件夹
else
fso.CreateFolder(folderMonth)
end if
readToday = openfile(fileToday)
'IP|web|comeweb|time
UserIp = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
if UserIp = "" then UserIp = Request.ServerVariables("REMOTE_ADDR")'获取来访ip
readTodayNew = UserIp&"|"& _
Request.ServerVariables("HTTP_REFERER")&"|"& _
Request.QueryString("webcome")&"|"& _
time()&CHR(10)&readToday
Call crtfile(fileToday,readTodayNew)
if fso.FileExists(fileCount) then
Set a = fso.OpenTextFile(fileCount)
Counter = Split(openfile(fileCount),"|")
else
Counter = Split("2005-1-1|2005-1-1|0|1|0|0|0|0|0|0","|")
end if
vIP = Instr(readToday,UserIp)
'上次日期(0),开始统计(1),总访问(2),IP访问(3),今日(4),今日IP(5);
'昨日(6),昨日IP(7),本月(8),本月ip(9)
if Month(Counter(0)) Month(date()) then'月份
if Month(date()) = 1 then
syue = (year(date()) - 1)&"-12.txt"
else
syue = year(date())&"-"&(Month(date()) - 1)&".txt"
end if
Call crtfile(server.MapPath("/")&countpath&"month/"&syue,Counter(8)&"|"&Counter(9))
Counter8 = 1
Counter9 = 1
else
counter8 = counter(8) + 1
if vIP = 0 then
Counter9 = Counter(9) + 1
else
Counter9 = Counter(9)
end if
end if
if Day(Counter(0)) Day(Date()) then'日期
Counter4 = 1
Counter5 = 1
Counter6 = Counter(4)
Counter7 = Counter(5)
syue = year(date())&"-"&Month(date())&".txt"
Call crtfile(server.MapPath("/")&countpath&"month/"&syue,Counter(8)&"|"&Counter(9))
else
Counter4 = Counter(4) + 1
if vIP = 0 then
Counter5 = Counter(5) + 1
else
Counter5 = Counter(5)
end if
Counter6 = Counter(6)
Counter7 = Counter(7)
end if
Counter0 = Date()
Counter1 = Counter(1)
Counter2 = Counter(2) + 1
if vIP = 0 then
Counter3 = Counter(3) + 1
else
Counter3 = Counter(3)
end if
CounterNew = Counter0&"|"&Counter1&"|"&Counter2&"|"&Counter3&"|"&Counter4&"|"&Counter5&"|"&Counter6&"|"&Counter7&"|"&Counter8&"|"&Counter9
Call crtfile(fileCount,CounterNew)
end if
%>