iwebshop 增加页面访问次数实时

class里面的主控制器初始化时添加如下代码

//更新页面访问次数
        $siteConfig = new Config('site_config');
        $sFilePath =$siteConfig->DATA_OTHER_PATH . "/csCount.txt";
        $file = fopen($sFilePath, "r");
        $txt=array();
        $i=0;
        while(!feof($file))
        {
            $txt[$i]= fgets($file);
            $i++;
        }
        fclose($file);
        $txt=array_filter($txt);
        
        $controller = IUrl::getInfo('controller');
        $action = IUrl::getInfo('action');
        if($controller == 'bmcs'){
            if ($action == 'gszc') {
                $txt[0] = ($txt[0] + 1).PHP_EOL;
            }else if($action == 'dljz') {
                $txt[1] = ($txt[1] + 1).PHP_EOL;
            }else if($action == 'sbzc') {
                $txt[2] = ($txt[2] + 1).PHP_EOL;
            }
            file_put_contents($sFilePath, $txt, LOCK_EX);
        }
        $this->csNum = $txt;

 txt文档内容如下

原文地址:https://www.cnblogs.com/Dong-Ge/p/6510270.html