bfwsoa框架如何自动统计系统访问pv及ip等数据?
比如每日的pv和独立ip访问数,最近5分钟的访问数据,最近访问量较高的ip。
网友回复
bfwsoa框架内置简单的系统访问统计模块,只需要在dom的config目录下的config.php中开启即可
<?php //应用配置文件 $_config_arr['App'] = [ "stat_open" => true, "stat_driver" => "file", //redis或file "stat_redis_ip" => "127.0.0.1", "stat_redis_port" => 6379, "stat_token" => "888888",stat_driver可以选择redis或file,选择redis的话要指定redis的ip和端口,另外stat_token也要设置,这个是获取统计数据的关键,还能屏蔽指定的ip
下面是页面的php代码,用于显示站点下的访问统计信息
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title网站访问统计</title> <meta name="robots" content="all"> <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/bfw.css"> <!-- 引入Vue.js CDN --> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/vue@2.6.1-dev.js"></script> <!-- 引入Axios CDN --> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/axios.1.4.0.js"></script> <style> </style> </head> <body> <div style=""> <div class="bfw-middle bfw-color-b-w" > <div class="bfw-row-owner bfw-height-auto"> <div class="bfw-row-20 bfw-m-hide " style="background: #f3f3f3"> </div> <div id="app"> <h1 class="bfw-mar-l bfw-bline-1 bfw-pad-l">网站统计<span id="sitenamespan">{{response.host}}</span></h1> <div> <div class="bfw-row-owner bfw-mar-s" style="line-height: 90px; font-size: 30px;"> <div class="bfw-row-3 bfw-color-w bfw-align-c"> <div class="bfw-mar-s" style="background: #4CAF50;"> 本月PV/ <span id="monthpvspan">{{response.monthly_pv}}</span> </div> </div> <div class="bfw-row-3 bfw-color-w bfw-align-c"> <div class="bfw-mar-s" style="background: #2196F3;"> 本月IP/ <span id="monthipspan">{{response.monthly_unique_ips}}</span> </div> </div> <div class="bfw-row-3 bfw-color-w bfw-align-c"> <div class="bfw-mar-s" style="background: #FF9800;"> 今日PV/ <span id="todaypvspan">{{response.daily_pv}}</span> </div> </div> <div class="bfw-row-3 bfw-color-w bfw-align-c"> <div class="bfw-mar-s" style="background: #F44336;"> 今日IP/ <span id="todayipspan">{{response.daily_unique_ips}}</span> </div> </div> <div class="bfw-row-3 bfw-color-w bfw-align-c"> <div class="bfw-mar-s" style="background: #9C27B0;"> 5分钟内/ <span id="fivempvspan">{{response.five_minute_visits}}</span> </div> </div> <div ...
点击查看剩余70%