网站总的访问统计
作者:未知 来源:转载 发布时间:2005-8-18 20:59:52 发布人:acx
[flash+asp]
1.在第1帧中插入动态文本,并命名变量名为:count
2.新建一fla文件,在第2帧中插入关键帧,添加以下代码:
this.loadVariables("count.txt?num="+random(999));
这行代码是将count.txt文件load进flash里,待flash调用count.txt里的数据(就是访问的人数)
3.在第40帧中插入关键帧,添加以下代码:
gotoAndPlay(2);
回放到第2帧
4.在第1帧中插入关键帧,添加以下代码:
this.loadVariables("counter.asp?num="+random(99));
读取asp文件counter.asp,实现访问人数加1
5.asp文件代码如下:
<%
Option Explicit
dim path
’----读写文本文件内容函数
function counter(path)
dim fs,file_names,index_s,out
Set fs = CreateObject("scripting.FileSystemObject")
Set file_names = fs.OpenTextFile(path)
index_s=file_names.readline
index_s=index_s+1
file_names.close
Set out=fs.CreateTextFile(path)
out.WriteLine(index_s)
out.close
set fs=nothing
end function
path=server.mappath("count.txt")
call counter(path)
%>
Option Explicit
dim path
’----读写文本文件内容函数
function counter(path)
dim fs,file_names,index_s,out
Set fs = CreateObject("scripting.FileSystemObject")
Set file_names = fs.OpenTextFile(path)
index_s=file_names.readline
index_s=index_s+1
file_names.close
Set out=fs.CreateTextFile(path)
out.WriteLine(index_s)
out.close
set fs=nothing
end function
path=server.mappath("count.txt")
call counter(path)
%>
[flash+php]
1.在第1帧中插入动态文本,并命名变量名为:count
2.新建一fla文件,在第2帧中插入关键帧,添加以下代码:
this.loadVariables("count.txt?num="+random(999));
这行代码是将count.txt文件load进flash里,待flash调用count.txt里的数据(就是访问的人数)
3.在第40帧中插入关键帧,添加以下代码:
gotoAndPlay(2);
回放到第2帧
4.在第1帧中插入关键帧,添加以下代码:
this.loadVariables("counter.php?num="+random(99));
读取php文件counter.php,实现访问人数加1
5.php文件代码如下:
<?php
$count = file_get_contents("count.txt");
$count = explode("=", $count);
$count[1] = $count[1]+1;
$file = fopen("count.txt", "w+");
fwrite($file, "count=".$count[1]);
fclose($file);
print "count=".$count[1];
?>
附源文件:
$count = file_get_contents("count.txt");
$count = explode("=", $count);
$count[1] = $count[1]+1;
$file = fopen("count.txt", "w+");
fwrite($file, "count=".$count[1]);
fclose($file);
print "count=".$count[1];
?>
附源文件: