您当前的位置: 首页 > 

苗先生的PHP记录

暂无认证

  • 0浏览

    0关注

    190博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

删除tp runtime中log

苗先生的PHP记录 发布时间:2021-09-11 17:02:31 ,浏览量:0

设置log权限  我懒得弄直接777

定时执行下面的方法就可以了

 public function clear_log_chache() {
        $this->delDirAndFile('/www/wwwroot/tzzzdj.1qqqq.com/runtime/log');
//        foreach ($path as $item) {
//            array_map( 'unlink', glob( $item.DS.'.' ) );
//            rmdir( $item );
//        }
        $this->success( '清除成功', 'index/index' );
    }


    public function delDirAndFile($path, $delDir = FALSE)
    {
        if (is_array($path)) {
            foreach ($path as $subPath){
                $this->delDirAndFile($subPath, $delDir);
            }
        }
        if (is_dir($path)) {
            @mkdir($path,0777,true);
            $handle = opendir($path);
            if ($handle) {
                while (false !== ($item = readdir($handle))) {
                    if ($item != "." && $item != "..")
                        is_dir("$path/$item") ? $this->delDirAndFile("$path/$item", $delDir) : unlink("$path/$item");
//                    {
//                        dump("$path/$item");
//                        die;
//                    }

                }
                closedir($handle);
                if ($delDir)
                    return rmdir($path);
            }
        } else {
            if (file_exists($path)) {
                return unlink($path);
            } else {
                return FALSE;
            }
        }
        clearstatcache();
    }

关注
打赏
1665468453
查看更多评论
立即登录/注册

微信扫码登录

0.1259s