| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- /*
- * @Author: 凯
- * @Date: 2021-05-06 10:01:08
- * @LastEditTime: 2021-05-06 10:14:11
- * @LastEditors: Please set LastEditors
- * @Description: In User Settings Edit
- * @FilePath: \admin_php\modules\admin\models\CacheForm.php
- */
- namespace app\modules\admin\models;
- use yii\base\Model;
- class CacheForm extends Model
- {
- // 清除服务商证书密钥缓存
- public function clearServerMchKey()
- {
- $dir = \Yii::$app->basePath . '/utils/WechatMerchant/cert';
- $this->delFileUnderDir($dir);
- }
- /**
- * @description:
- * @param {*}
- * @return {*}
- */
- public function clearImages()
- {
- $dir = \Yii::$app->basePath . '/runtime/image';
- $this->delFileUnderDir($dir);
- $dir = \Yii::$app->basePath . '/web/temp';
- $this->delFileUnderDir($dir);
- }
- /**
- * @description:
- * @param {*}
- * @return {*}
- */
- public function clearData()
- {
- return cache()->flush();
- }
- /**
- * @description:
- * @param {*}
- * @return {*}
- */
- public function clearUpdata()
- {
- $dir = \Yii::$app->basePath . '/temp/update';
- $this->delFileUnderDir($dir);
- }
- //循环目录下的所有文件
- private function delFileUnderDir($dirName, $delDir = false, $ignoreList = [])
- {
- // 判断是否存在该目录
- if (file_exists("$dirName")) {
- if ($handle = opendir("$dirName")) {
- while (false !== ($item = readdir($handle))) {
- if ($item != "." && $item != ".." && !in_array($item, $ignoreList)) {
- if (is_dir("$dirName/$item")) {
- $this->delFileUnderDir("$dirName/$item", true, $ignoreList);
- } else {
- unlink("$dirName/$item");
- }
- }
- }
- closedir($handle);
- if ($delDir) {
- rmdir("$dirName");
- }
- }
- }
- }
- }
|