那就建立一个统一的数据库表(这种问题用文件不好,因为还要flock(),麻烦,效率低)
表中各记录结构大致为:create table visitlog(
dir varchar(80) not null, #目录名
counter int unsigned not null, #访问计数
recent int unsigned not null, #最近访问时间
...
)初始化时插入各目录对应的记录,counter设为0
以后只要执行
$sql = "update visitlog set counter=counter+1 where dir='$dir'"
...
就可以了这样的好处是便于统一管理,统一显示对比

解决方案 »

  1.   

    问题是怎样实现动态的更新呢?
    这样好象还是要加入到每个文件里能不能利用apache下的log日志
    它是不是记录每个页面的访问,还是只保存出错信息
      

  2.   

    问题是你的虚拟主机能访问apache的log日志吗?
    反正我的虚拟主机不支持。
    你可以用php的外部js脚本,最大限度地简化这个问题:
    每个页面(*.htm即可,不必*.php)开头加如下行,不用做别的改动
    <script language=jscript src=counter.php?dir=dirname></script>counter.php:<?
    ...
    mysql_query("update visitlog set counter=counter+1 where dir='$dir'", ...)
    ...
    $query = mysql_query("select counter from visitlog where dir='$dir'"...)
    $row = mysql_fetch_row($query);
    $counter = $row[0];
    echo "var nCounter=$counter;";
    ?>这样,每个HTML页面便有了一个名为nCounter的JS变量,后面可以利用这个变量显示计数值,最简单的:document.write(nCounter),当然也可以做出复杂的效果
      

  3.   

    最后还是得依靠Apache的log日志.
    你可以修改httpd.conf中的配置看看,具体我也没做过.
      

  4.   

    在httpd.conf中找到了,用CustomLog配合VirtualHost,以下是有关内容:#
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    LogFormat "%{Referer}i -> %U" referer
    LogFormat "%{User-agent}i" agent#
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    CustomLog logs/access.log common#
    # VirtualHost example:
    # Almost any Apache directive may go into a VirtualHost container.
    # The first VirtualHost section is used for requests without a known
    # server name.
    #
    #<VirtualHost *>
    #    ServerAdmin [email protected]
    #    DocumentRoot /www/docs/dummy-host.example.com
    #    ServerName dummy-host.example.com
    #    ErrorLog logs/dummy-host.example.com-error_log
    #    CustomLog logs/dummy-host.example.com-access_log common
    #</VirtualHost>
      

  5.   

    up一下好象只有从log入手了
    alexxing(赤铸)的方法本来是可行的,但我不能修改用户页面(这样就越权了)
    好象apache有自己的统计命令
      

  6.   

    apache是网页服务器嘛。
    我想她只要工作起来,应该能纪录一些东东吧。
    我没有做过,要继续关注。不过网页跟用户之间是一次握手信号。
    一次送不出也就算了,捕获的东西应该有限吧。