diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index a38d97da0..6b272396a 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -239,8 +239,8 @@ return array( 'app\\wechat\\controller\\api\\Js' => $baseDir . '/app/wechat/controller/api/Js.php', 'app\\wechat\\controller\\api\\Login' => $baseDir . '/app/wechat/controller/api/Login.php', 'app\\wechat\\controller\\api\\Push' => $baseDir . '/app/wechat/controller/api/Push.php', - 'app\\wechat\\controller\\api\\Review' => $baseDir . '/app/wechat/controller/api/Review.php', 'app\\wechat\\controller\\api\\Test' => $baseDir . '/app/wechat/controller/api/Test.php', + 'app\\wechat\\controller\\api\\View' => $baseDir . '/app/wechat/controller/api/View.php', 'app\\wechat\\service\\FansService' => $baseDir . '/app/wechat/service/FansService.php', 'app\\wechat\\service\\MediaService' => $baseDir . '/app/wechat/service/MediaService.php', 'app\\wechat\\service\\WechatService' => $baseDir . '/app/wechat/service/WechatService.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index c28fdd03e..b088149bd 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -367,8 +367,8 @@ class ComposerStaticInit4f89fd0e0503ccf740f2fa5757825d7b 'app\\wechat\\controller\\api\\Js' => __DIR__ . '/../..' . '/app/wechat/controller/api/Js.php', 'app\\wechat\\controller\\api\\Login' => __DIR__ . '/../..' . '/app/wechat/controller/api/Login.php', 'app\\wechat\\controller\\api\\Push' => __DIR__ . '/../..' . '/app/wechat/controller/api/Push.php', - 'app\\wechat\\controller\\api\\Review' => __DIR__ . '/../..' . '/app/wechat/controller/api/Review.php', 'app\\wechat\\controller\\api\\Test' => __DIR__ . '/../..' . '/app/wechat/controller/api/Test.php', + 'app\\wechat\\controller\\api\\View' => __DIR__ . '/../..' . '/app/wechat/controller/api/View.php', 'app\\wechat\\service\\FansService' => __DIR__ . '/../..' . '/app/wechat/service/FansService.php', 'app\\wechat\\service\\MediaService' => __DIR__ . '/../..' . '/app/wechat/service/MediaService.php', 'app\\wechat\\service\\WechatService' => __DIR__ . '/../..' . '/app/wechat/service/WechatService.php', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index c4262f344..d7982cdcb 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -937,12 +937,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "7689af12e89d95c0ca5ddacd4142fcfa0af6ad5f" + "reference": "528022c763c694f9c2bc3e0d4e6a2aaef5715f07" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/7689af12e89d95c0ca5ddacd4142fcfa0af6ad5f", - "reference": "7689af12e89d95c0ca5ddacd4142fcfa0af6ad5f", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/528022c763c694f9c2bc3e0d4e6a2aaef5715f07", + "reference": "528022c763c694f9c2bc3e0d4e6a2aaef5715f07", "shasum": "", "mirrors": [ { @@ -959,7 +959,7 @@ "ext-mbstring": "*", "topthink/framework": "^6.0" }, - "time": "2020-11-18T02:17:40+00:00", + "time": "2020-11-21T08:43:45+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index 3e01b3762..8a0e531f8 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\admin\\Library', diff --git a/vendor/zoujingli/think-library/src/multiple/command/Clear.php b/vendor/zoujingli/think-library/src/multiple/command/Clear.php index f547490af..becab581b 100644 --- a/vendor/zoujingli/think-library/src/multiple/command/Clear.php +++ b/vendor/zoujingli/think-library/src/multiple/command/Clear.php @@ -21,17 +21,29 @@ use think\console\input\Argument; use think\console\input\Option; use think\console\Output; +/** + * 清理运行缓存 + * Class Clear + * @package think\admin\multiple\command + */ class Clear extends Command { protected function configure() { - $this->setName('clear')->addArgument('app', Argument::OPTIONAL, 'app name .'); + $this->setName('clear')->addArgument('app', Argument::OPTIONAL, 'app name'); + $this->addOption('path', 'd', Option::VALUE_OPTIONAL, 'path to clear', null); $this->addOption('cache', 'c', Option::VALUE_NONE, 'clear cache file'); $this->addOption('log', 'l', Option::VALUE_NONE, 'clear log file'); $this->addOption('dir', 'r', Option::VALUE_NONE, 'clear empty dir'); + $this->addOption('expire', 'e', Option::VALUE_NONE, 'clear cache file if cache has expired'); $this->setDescription('Clear runtime file'); } + /** + * @param Input $input + * @param Output $output + * @return int|void|null + */ protected function execute(Input $input, Output $output) { $app = $input->getArgument('app') ?: ''; @@ -41,23 +53,47 @@ class Clear extends Command } elseif ($input->getOption('log')) { $path = $runtimePath . 'log'; } else { - $path = $runtimePath; + $path = $input->getOption('path') ?: $runtimePath; } $rmdir = $input->getOption('dir') ? true : false; - $this->clear(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, $rmdir); + // --expire 仅当 --cache 时生效 + $expire = $input->getOption('expire') && $input->getOption('cache'); + $this->clear(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, $rmdir, $expire); $output->writeln("Clear Successed"); } - protected function clear(string $path, bool $rmdir): void + /** + * 清处理指定目录 + * @param string $path 待清理目录 + * @param boolean $rmdir 是否目录 + * @param boolean $expire 有效时间 + */ + private function clear(string $path, bool $rmdir, bool $expire): void { - $files = is_dir($path) ? scandir($path) : []; - foreach ($files as $file) { - if ('.' != $file && '..' != $file && is_dir($path . $file)) { - array_map('unlink', glob($path . $file . DIRECTORY_SEPARATOR . '*.*')); - if ($rmdir) rmdir($path . $file); + foreach (is_dir($path) ? scandir($path) : [] as $file) { + if ('.' !== $file && '..' !== $file && is_dir($path . $file)) { + $this->clear($path . $file . DIRECTORY_SEPARATOR, $rmdir, $expire); + if ($rmdir) @rmdir($path . $file); } elseif ('.gitignore' != $file && is_file($path . $file)) { - unlink($path . $file); + if ($expire) { + if ($this->cacheHasExpired($path . $file)) { + @unlink($path . $file); + } + } else { + @unlink($path . $file); + } } } } + + /** + * 缓存文件是否已过期 + * @param $filename string 文件路径 + * @return boolean + */ + private function cacheHasExpired(string $filename): bool + { + $expire = (int)substr(file_get_contents($filename), 8, 12); + return 0 != $expire && time() - $expire > filemtime($filename); + } } diff --git a/vendor/zoujingli/think-library/src/service/SystemService.php b/vendor/zoujingli/think-library/src/service/SystemService.php index 3b469c941..7c151db7d 100644 --- a/vendor/zoujingli/think-library/src/service/SystemService.php +++ b/vendor/zoujingli/think-library/src/service/SystemService.php @@ -259,7 +259,7 @@ class SystemService extends Service public function clearRuntime(): void { $data = $this->getRuntime(); - $this->app->console->call('clear'); + $this->app->console->call('clear', ['--dir']); $this->setRuntime($data['mode'], $data['appmap'], $data['domain']); } diff --git a/vendor/zoujingli/think-library/src/service/ZtSmsService.php b/vendor/zoujingli/think-library/src/service/ZtSmsService.php index 19d768011..063c7843f 100644 --- a/vendor/zoujingli/think-library/src/service/ZtSmsService.php +++ b/vendor/zoujingli/think-library/src/service/ZtSmsService.php @@ -79,8 +79,7 @@ class ZtSmsService extends Service */ public function checkVerifyCode(string $code, string $phone, string $template = 'ztsms.register_verify'): bool { - $ckey = md5("code-{$template}-{$phone}"); - $cache = $this->app->cache->get($ckey, []); + $cache = $this->app->cache->get($ckey = md5("code-{$template}-{$phone}"), []); if (is_array($cache) && isset($cache['code']) && $cache['code'] == $code) { $this->app->cache->delete($ckey); return true; @@ -102,9 +101,8 @@ class ZtSmsService extends Service public function sendVerifyCode(string $phone, int $wait = 120, string $template = 'ztsms.register_verify'): array { $time = time(); - $ckey = md5("code-{$template}-{$phone}"); - $cache = $this->app->cache->get($ckey, []); // 检查是否已经发送 + $cache = $this->app->cache->get($ckey = md5("code-{$template}-{$phone}"), []); if (is_array($cache) && isset($cache['time']) && $cache['time'] + $wait > $time) { $dtime = $cache['time'] + $wait < $time ? 0 : $cache['time'] + $wait - $time; return [1, '短信验证码已经发送!', ['time' => $dtime]];