访客次数统计

插件方法

  <script type="text/javascript" charset="gb2312" src="{dede:field name='phpurl'/}/stat.php"></script>

目录文件放入(见文件dedecms插件实现您是本站的多少位访客)

另一种方法

1.将count.php文件放到网站根目录,内容如下

<?
//创作来自亳州淮中网:http://www.guoyangnet.cn使用请保留版权。
session_start();
$max_len = 8;
$CounterFile = "counter.dat";
if(!file_exists($CounterFile))
{
$Counter = 0;
$cf= fopen($CounterFile,"w");
flock($cf,3);
fputs($cf,"0");
fclose($cf);
}
else
{
$cf = fopen($CounterFile,"r");
flock($cf,3);
$Counter = trim(fgets($cf,$max_len));
fclose($cf);
}
if (session_is_registered("in")==false){
$Counter++;
$cf = fopen($CounterFile,"w");
flock($cf,3);
fputs($cf,$Counter);
fclose($cf);
session_register("in");
}

$strCount = strval($Counter); //获得的记数转成字符串
echo "document.write(\"".$strCount."\");";
?>

 

2.在需要显示网站访客数量的地方加入下面的代码

<script src="/count.php"></script>

 

posted @ 2017-04-07 11:55  简单就好zyx  阅读(397)  评论(0编辑  收藏  举报