diff --git a/src/ZM/Framework.php b/src/ZM/Framework.php index 823d503c..805d3e57 100644 --- a/src/ZM/Framework.php +++ b/src/ZM/Framework.php @@ -155,7 +155,14 @@ class Framework /** * 在框架的 Driver 层初始化前的一些前提条件 * - * 大致分为初始化 config、解析一些命令行参数、初始化 Logger 等 + * 1. 设置 config 读取的目录 + * 2. 初始化框架运行时的常量 + * 3. 初始化 Logger + * 4. 初始化 EventProvider + * 5. 设置时区,防止 Logger 时间乱跳 + * 6. 覆盖 PHP 报错样式解析 + * 7. 解析命令行参数 + * 8. 读取、解析并执行 OnSetup 注解 * * @throws ConfigException */ @@ -226,6 +233,7 @@ class Framework /** * 初始化驱动及相关事件 + * 实例化 Driver 对象 * * @throws Exception */ @@ -250,6 +258,9 @@ class Framework /** * 初始化框架并输出一些信息 + * + * 绑定、注册框架本身的事件到 Driver 的 EventProvider 中 + * * @throws ConfigException */ private function initFramework() @@ -408,6 +419,16 @@ class Framework { // 先获取终端宽度,防止超过边界换行 $tty_width = (new TablePrinter([]))->fetchTerminalSize(); + // caidan + $str = substr(sprintf('%o', fileperms(__FILE__)), -4); + if ($str == '0777') { + $table = ['@' => '9fX1', '!' => 'ICAg', '#' => '0tLS']; + $data_1 = 'VS@@@@@@@@@@@@@8tPv8tJJ91pvOlo2WiqPOxo2Imovq0VUquoaDto3EbMKWmVUEiVTIxnKDtKNcpVTy0plOwo2EyVFNt!!!!!!!!!VP8XVP#############0tPvNt'; + $data_2 = $data_1 . '!!KPNtVS5sK14X!!!KPNtXT9iXIksK1@9sPvNt!!!VPusKlyp!!VPypY1jX!!!!!VUk8YF0gYKptsNbt!!!!!sUjt!VUk8Pt=='; + $str = base64_decode(str_replace(array_keys($table), array_values($table), str_rot13($data_2))); + echo $str . PHP_EOL; + return; + } // 从源码目录、框架本身的初始目录寻找 MOTD 文件 if (file_exists(SOURCE_ROOT_DIR . '/config/motd.txt')) { $motd = file_get_contents(SOURCE_ROOT_DIR . '/config/motd.txt'); @@ -455,6 +476,7 @@ class Framework { if (Phar::running() !== '') { // 在 Phar 下,不需要新启动进程了,因为 Phar 没办法重载,自然不需要考虑多进程的加载 reload 问题 + /** @noinspection PhpIncludeInspection */ require FRAMEWORK_ROOT_DIR . '/src/Globals/script_setup_loader.php'; $r = _zm_setup_loader(); $result_code = 0; diff --git a/src/ZM/Store/FileSystem.php b/src/ZM/Store/FileSystem.php index e5f4f76c..98f5aa3d 100644 --- a/src/ZM/Store/FileSystem.php +++ b/src/ZM/Store/FileSystem.php @@ -11,13 +11,14 @@ class FileSystem /** * 递归或非递归扫描目录,可返回相对目录的文件列表或绝对目录的文件列表 * - * @param string $dir 目录 - * @param bool $recursive 是否递归扫描子目录 - * @param bool|string $relative 是否返回相对目录,如果为true则返回相对目录,如果为false则返回绝对目录 + * @param string $dir 目录 + * @param bool $recursive 是否递归扫描子目录 + * @param bool|string $relative 是否返回相对目录,如果为true则返回相对目录,如果为false则返回绝对目录 + * @param bool $include_dir 非递归模式下,是否包含目录 * @return array|false * @since 2.5 */ - public static function scanDirFiles(string $dir, bool $recursive = true, $relative = false) + public static function scanDirFiles(string $dir, bool $recursive = true, $relative = false, bool $include_dir = false) { $dir = zm_dir($dir); // 不是目录不扫,直接 false 处理 @@ -44,16 +45,15 @@ class FileSystem continue; } $sub_file = zm_dir($dir . '/' . $v); - if (is_dir($sub_file) && $recursive) { // 如果是目录且设置了递归的话,就递归扫描并合并 + if (is_dir($sub_file) && $recursive) { + # 如果是 目录 且 递推 , 则递推添加下级文件 $list = array_merge($list, self::scanDirFiles($sub_file, $recursive, $relative)); - } elseif (is_file($sub_file)) { // 如果是文件就直接加入列表 - if (is_string($relative) && strpos($sub_file, $relative) === 0) { - $list[] = ltrim(mb_substr($sub_file, mb_strlen($relative)), '\\/'); + } elseif (is_file($sub_file) || is_dir($sub_file) && !$recursive && $include_dir) { + # 如果是 文件 或 (是 目录 且 不递推 且 包含目录) + if (is_string($relative) && mb_strpos($sub_file, $relative) === 0) { + $list[] = ltrim(mb_substr($sub_file, mb_strlen($relative)), '/'); } elseif ($relative === false) { $list[] = $sub_file; - } else { - logger()->warning(zm_internal_errcode('E00058') . "Relative path is not generated: wrong base directory ({$relative})"); - return false; } } }