HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot//douyin.dsfnj.com/application/common/behavior/InitConfigBehavior.php
<?php
// +----------------------------------------------------------------------
// | Description: 加载动态配置
// +----------------------------------------------------------------------
// | Author:  ming <1006941410@qq.com>
// +----------------------------------------------------------------------
namespace app\common\behavior;

class InitConfigBehavior
{
    public function run(&$content)
    {
        //读取数据库中的配置
        $system_config = [];
        // config($system_config); //添加配置

        /**
         * 数据库名称,用于云平台区分项目
         */
        define('DB_NAME', \config('database.database'));

        // 生成临时目录
        if (!file_exists('./public/temp')) {
            mkdir('./public/temp', 0777, true);
        }

        /**
         * 自定义临时文件目录的绝对路径,暂时用于存放导入导出时的临时文件
         */
        define('TEMP_DIR', realpath('.' . DS . 'public' . DS . 'temp') . DS);

        $this->clearTemp();
    }

    /**
     * 清理自定义临时文件目录文件
     */
    public function clearTemp()
    {
        $cache = \cache('CLEAR_TEMP');
        if (!$cache) {
            $today = (int) date('Ymd');
            \cache('CLEAR_TEMP', true, new \DateTime(date('Y-m-d'). ' 23:59'));
            
            $dh = opendir(TEMP_DIR);
            while ($dir = readdir($dh)) {
                // 日期目录
                if (\strlen($dir) == 8 && is_numeric($dir)) {
                    // 超过一周的删除
                    if ($today - (int) $dir > 7) {
                        delDir(TEMP_DIR . $dir);
                    }
                }
            }
            closedir($dh);
        }
    }
}