From 9132120745af469f5b5688bc6ee9a8964f9e4e7c Mon Sep 17 00:00:00 2001 From: Anyon Date: Thu, 23 Apr 2020 17:17:51 +0800 Subject: [PATCH] ComposerUpdate --- composer.lock | 8 +-- vendor/composer/installed.json | 8 +-- vendor/services.php | 2 +- vendor/zoujingli/think-library/src/Helper.php | 5 +- .../think-library/src/command/Version.php | 4 +- vendor/zoujingli/think-library/src/common.php | 38 ++++++------- .../think-library/src/extend/CodeExtend.php | 2 +- .../think-library/src/helper/FormHelper.php | 2 +- .../think-library/src/helper/QueryHelper.php | 2 +- .../src/service/CaptchaService.php | 42 +++++++------- .../src/service/InstallService.php | 2 +- .../src/service/SystemService.php | 56 ++++++++++++------- .../src/storage/LocalStorage.php | 2 +- 13 files changed, 93 insertions(+), 80 deletions(-) diff --git a/composer.lock b/composer.lock index f6dc2dbcb..9d0465d66 100644 --- a/composer.lock +++ b/composer.lock @@ -909,12 +909,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "89beab0c55d0fb9167913764b78ede9859485fad" + "reference": "2858d5d77526e064d7dd89f793ae9269310a6cba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/89beab0c55d0fb9167913764b78ede9859485fad", - "reference": "89beab0c55d0fb9167913764b78ede9859485fad", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/2858d5d77526e064d7dd89f793ae9269310a6cba", + "reference": "2858d5d77526e064d7dd89f793ae9269310a6cba", "shasum": "", "mirrors": [ { @@ -958,7 +958,7 @@ ], "description": "ThinkPHP v6.0 Development Library", "homepage": "http://framework.thinkadmin.top", - "time": "2020-04-22T06:44:38+00:00" + "time": "2020-04-23T09:13:17+00:00" }, { "name": "zoujingli/wechat-developer", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index fbabf68c1..fb7135408 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -935,12 +935,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "89beab0c55d0fb9167913764b78ede9859485fad" + "reference": "2858d5d77526e064d7dd89f793ae9269310a6cba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/89beab0c55d0fb9167913764b78ede9859485fad", - "reference": "89beab0c55d0fb9167913764b78ede9859485fad", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/2858d5d77526e064d7dd89f793ae9269310a6cba", + "reference": "2858d5d77526e064d7dd89f793ae9269310a6cba", "shasum": "", "mirrors": [ { @@ -956,7 +956,7 @@ "ext-json": "*", "topthink/framework": "^6.0" }, - "time": "2020-04-22T06:44:38+00:00", + "time": "2020-04-23T09:13:17+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index 228e37e2d..f9e2902a9 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\app\\Service', diff --git a/vendor/zoujingli/think-library/src/Helper.php b/vendor/zoujingli/think-library/src/Helper.php index e37ebf64b..c11062e0f 100644 --- a/vendor/zoujingli/think-library/src/Helper.php +++ b/vendor/zoujingli/think-library/src/Helper.php @@ -17,6 +17,7 @@ namespace think\admin; use think\App; use think\Container; +use think\Db; use think\db\Query; /** @@ -58,9 +59,9 @@ abstract class Helper /** * 获取数据库对象 * @param string|Query $dbQuery - * @return Query + * @return Db|Query */ - protected function buildQuery($dbQuery): Query + protected function buildQuery($dbQuery) { return is_string($dbQuery) ? $this->app->db->name($dbQuery) : $dbQuery; } diff --git a/vendor/zoujingli/think-library/src/command/Version.php b/vendor/zoujingli/think-library/src/command/Version.php index c3dd40b86..c61606a93 100644 --- a/vendor/zoujingli/think-library/src/command/Version.php +++ b/vendor/zoujingli/think-library/src/command/Version.php @@ -36,7 +36,7 @@ class Version extends Command protected function execute(Input $input, Output $output) { - $output->writeln("ThinkAdmin " . ProcessService::instance()->version()); - $output->writeln('ThinkPHPCore ' . App::VERSION); + $output->writeln('ThinkLib ' . ProcessService::instance()->version()); + $output->writeln('ThinkPHP ' . App::VERSION); } } \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/common.php b/vendor/zoujingli/think-library/src/common.php index aa5425ed0..15145e2a1 100644 --- a/vendor/zoujingli/think-library/src/common.php +++ b/vendor/zoujingli/think-library/src/common.php @@ -47,9 +47,9 @@ if (!function_exists('auth')) { } if (!function_exists('sysuri')) { /** - * 生成最短URL地址 + * 生成最短 URL 地址 * @param string $url 路由地址 - * @param array $vars 变量 + * @param array $vars PATH 变量 * @param boolean|string $suffix 后缀 * @param boolean|string $domain 域名 * @return string @@ -212,6 +212,23 @@ if (!function_exists('data_save')) { return SystemService::instance()->save($dbQuery, $data, $key, $where); } } +if (!function_exists('format_bytes')) { + /** + * 文件字节单位转换 + * @param integer $size + * @return string + */ + function format_bytes($size) + { + if (is_numeric($size)) { + $units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024; + return round($size, 2) . ' ' . $units[$i]; + } else { + return $size; + } + } +} if (!function_exists('format_datetime')) { /** * 日期格式标准输出 @@ -264,21 +281,4 @@ if (!function_exists('down_file')) { $result = Storage::down($source, $force, $expire); return isset($result['url']) ? $result['url'] : $source; } -} -if (!function_exists('format_bytes')) { - /** - * 文件字节单位转换 - * @param integer $size - * @return string - */ - function format_bytes($size) - { - if (is_numeric($size)) { - $units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; - for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024; - return round($size, 2) . ' ' . $units[$i]; - } else { - return $size; - } - } } \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/extend/CodeExtend.php b/vendor/zoujingli/think-library/src/extend/CodeExtend.php index 8a96b5b3c..b40062cab 100644 --- a/vendor/zoujingli/think-library/src/extend/CodeExtend.php +++ b/vendor/zoujingli/think-library/src/extend/CodeExtend.php @@ -67,7 +67,7 @@ class CodeExtend { $time = time() . ''; if ($size < 10) $size = 10; - $string = $prefix . ($time[0] + $time[1]) . substr($time, 2) . rand(0, 9); + $string = $prefix . (intval($time[0]) + intval($time[1])) . substr($time, 2) . rand(0, 9); while (strlen($string) < $size) $string .= rand(0, 9); return $string; } diff --git a/vendor/zoujingli/think-library/src/helper/FormHelper.php b/vendor/zoujingli/think-library/src/helper/FormHelper.php index 35506511a..dd26d0dd4 100644 --- a/vendor/zoujingli/think-library/src/helper/FormHelper.php +++ b/vendor/zoujingli/think-library/src/helper/FormHelper.php @@ -39,7 +39,7 @@ class FormHelper extends Helper /** * 数据对象主键名称 - * @var array|string + * @var string */ protected $field; diff --git a/vendor/zoujingli/think-library/src/helper/QueryHelper.php b/vendor/zoujingli/think-library/src/helper/QueryHelper.php index eafcf2ddd..f5171e8f1 100644 --- a/vendor/zoujingli/think-library/src/helper/QueryHelper.php +++ b/vendor/zoujingli/think-library/src/helper/QueryHelper.php @@ -29,7 +29,7 @@ class QueryHelper extends Helper { /** - * Query call. + * QueryHelper call. * @param string $name 调用方法名称 * @param array $args 调用参数内容 * @return $this diff --git a/vendor/zoujingli/think-library/src/service/CaptchaService.php b/vendor/zoujingli/think-library/src/service/CaptchaService.php index 8e31e20f5..fef0a3e21 100644 --- a/vendor/zoujingli/think-library/src/service/CaptchaService.php +++ b/vendor/zoujingli/think-library/src/service/CaptchaService.php @@ -27,13 +27,11 @@ class CaptchaService extends Service private $code; // 验证码 private $uniqid; // 唯一序号 private $charset = 'ABCDEFGHKMNPRSTUVWXYZ23456789'; // 随机因子 - private $codelen = 4; // 验证码长度 - private $width = 130; // 宽度 - private $height = 50; // 高度 - private $img; // 图形资源句柄 - private $font; // 指定的字体 + private $width = 130; // 图片宽度 + private $height = 50; // 图片高度 + private $length = 4; // 验证码长度 + private $fontfile; // 指定字体文件 private $fontsize = 20; // 指定字体大小 - private $fontcolor; // 指定字体颜色 /** * 服务初始化 @@ -48,11 +46,11 @@ class CaptchaService extends Service $this->uniqid = uniqid('captcha') . mt_rand(1000, 9999); // 生成验证码字符串 $length = strlen($this->charset) - 1; - for ($i = 0; $i < $this->codelen; $i++) { + for ($i = 0; $i < $this->length; $i++) { $this->code .= $this->charset[mt_rand(0, $length)]; } // 设置字体文件路径 - $this->font = __DIR__ . '/bin/font.ttf'; + $this->fontfile = __DIR__ . '/bin/font.ttf'; // 缓存验证码字符串 $this->app->cache->set($this->uniqid, $this->code, 360); // 返回当前对象 @@ -143,34 +141,34 @@ class CaptchaService extends Service private function createImage() { // 生成背景 - $this->img = imagecreatetruecolor($this->width, $this->height); - $color = imagecolorallocate($this->img, mt_rand(220, 255), mt_rand(220, 255), mt_rand(220, 255)); - imagefilledrectangle($this->img, 0, $this->height, $this->width, 0, $color); + $img = imagecreatetruecolor($this->width, $this->height); + $color = imagecolorallocate($img, mt_rand(220, 255), mt_rand(220, 255), mt_rand(220, 255)); + imagefilledrectangle($img, 0, $this->height, $this->width, 0, $color); // 生成线条 for ($i = 0; $i < 6; $i++) { - $color = imagecolorallocate($this->img, mt_rand(0, 50), mt_rand(0, 50), mt_rand(0, 50)); - imageline($this->img, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $color); + $color = imagecolorallocate($img, mt_rand(0, 50), mt_rand(0, 50), mt_rand(0, 50)); + imageline($img, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $color); } // 生成雪花 for ($i = 0; $i < 100; $i++) { - $color = imagecolorallocate($this->img, mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255)); - imagestring($this->img, mt_rand(1, 5), mt_rand(0, $this->width), mt_rand(0, $this->height), '*', $color); + $color = imagecolorallocate($img, mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255)); + imagestring($img, mt_rand(1, 5), mt_rand(0, $this->width), mt_rand(0, $this->height), '*', $color); } // 生成文字 - $_x = $this->width / $this->codelen; - for ($i = 0; $i < $this->codelen; $i++) { - $this->fontcolor = imagecolorallocate($this->img, mt_rand(0, 156), mt_rand(0, 156), mt_rand(0, 156)); + $_x = $this->width / $this->length; + for ($i = 0; $i < $this->length; $i++) { + $fontcolor = imagecolorallocate($img, mt_rand(0, 156), mt_rand(0, 156), mt_rand(0, 156)); if (function_exists('imagettftext')) { - imagettftext($this->img, $this->fontsize, mt_rand(-30, 30), $_x * $i + mt_rand(1, 5), $this->height / 1.4, $this->fontcolor, $this->font, $this->code[$i]); + imagettftext($img, $this->fontsize, mt_rand(-30, 30), $_x * $i + mt_rand(1, 5), $this->height / 1.4, $fontcolor, $this->fontfile, $this->code[$i]); } else { - imagestring($this->img, 15, $_x * $i + mt_rand(10, 15), mt_rand(10, 30), $this->code[$i], $this->fontcolor); + imagestring($img, 15, $_x * $i + mt_rand(10, 15), mt_rand(10, 30), $this->code[$i], $fontcolor); } } ob_start(); - imagepng($this->img); + imagepng($img); $data = ob_get_contents(); ob_end_clean(); - imagedestroy($this->img); + imagedestroy($img); return base64_encode($data); } } \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/service/InstallService.php b/vendor/zoujingli/think-library/src/service/InstallService.php index b395b2adc..b65c30e0e 100644 --- a/vendor/zoujingli/think-library/src/service/InstallService.php +++ b/vendor/zoujingli/think-library/src/service/InstallService.php @@ -26,7 +26,7 @@ use think\admin\Service; class InstallService extends Service { /** - * 目录地址 + * 代码地址 * @var string */ protected $uri; diff --git a/vendor/zoujingli/think-library/src/service/SystemService.php b/vendor/zoujingli/think-library/src/service/SystemService.php index 6acdec3c0..f279844cd 100644 --- a/vendor/zoujingli/think-library/src/service/SystemService.php +++ b/vendor/zoujingli/think-library/src/service/SystemService.php @@ -121,6 +121,23 @@ class SystemService extends Service return [$type, $field, strtolower($outer)]; } + /** + * 生成最短URL地址 + * @param string $url 路由地址 + * @param array $vars PATH 变量 + * @param boolean|string $suffix 后缀 + * @param boolean|string $domain 域名 + * @return string + */ + public function sysuri($url = '', array $vars = [], $suffix = true, $domain = false) + { + $d1 = $this->app->config->get('app.default_app'); + $d3 = $this->app->config->get('route.default_action'); + $d2 = $this->app->config->get('route.default_controller'); + $location = $this->app->route->buildUrl($url, $vars)->suffix($suffix)->domain($domain)->build(); + return preg_replace('|/\.html$|', '', preg_replace(["|^/{$d1}/{$d2}/{$d3}(\.html)?$|i", "|/{$d2}/{$d3}(\.html)?$|i", "|/{$d3}(\.html)?$|i"], ['$1', '$1', '$1'], $location)); + } + /** * 保存数据内容 * @param string $name @@ -215,18 +232,23 @@ class SystemService extends Service * 设置实时运行配置 * @param array|null $map 应用映射 * @param string|null $run 支持模式 + * @param array|null $uri 域名映射 * @return boolean 是否调试模式 */ - public function setRuntime($map = [], $run = null) + public function setRuntime($map = [], $run = null, $uri = []) { $data = $this->getRuntime(); if (is_array($map) && count($map) > 0 && count($data['app_map']) > 0) { foreach ($data['app_map'] as $kk => $vv) if (in_array($vv, $map)) unset($data['app_map'][$kk]); } + if (is_array($uri) && count($uri) > 0 && count($data['app_uri']) > 0) { + foreach ($data['app_uri'] as $kk => $vv) if (in_array($vv, $uri)) unset($data['app_uri'][$kk]); + } $file = "{$this->app->getRootPath()}runtime/config.json"; $data['app_run'] = is_null($run) ? $data['app_run'] : $run; $data['app_map'] = is_null($map) ? [] : array_merge($data['app_map'], $map); - file_put_contents($file, json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + $data['app_uri'] = is_null($uri) ? [] : array_merge($data['app_uri'], $uri); + file_put_contents($file, json_encode($data, JSON_UNESCAPED_UNICODE)); return $this->bindRuntime($data); } @@ -241,6 +263,7 @@ class SystemService extends Service $data = file_exists($file) ? json_decode(file_get_contents($file), true) : []; if (empty($data) || !is_array($data)) $data = []; if (empty($data['app_map']) || !is_array($data['app_map'])) $data['app_map'] = []; + if (empty($data['app_uri']) || !is_array($data['app_uri'])) $data['app_uri'] = []; if (empty($data['app_run']) || !is_string($data['app_run'])) $data['app_run'] = 'developer'; return is_null($key) ? $data : (isset($data[$key]) ? $data[$key] : null); } @@ -252,8 +275,8 @@ class SystemService extends Service */ public function bindRuntime($data = []) { - // 动态绑定应用映射 if (empty($data)) $data = $this->getRuntime(); + // 动态绑定应用 if (!empty($data['app_map'])) { $maps = $this->app->config->get('app.app_map', []); if (is_array($maps) && count($maps) > 0 && count($data['app_map']) > 0) { @@ -261,25 +284,16 @@ class SystemService extends Service } $this->app->config->set(['app_map' => array_merge($maps, $data['app_map'])], 'app'); } - // 动态设置当前运行模式 + // 动态绑定域名 + if (!empty($data['app_uri'])) { + $uris = $this->app->config->get('app.domain_bind', []); + if (is_array($uris) && count($uris) > 0 && count($data['app_uri']) > 0) { + foreach ($uris as $kk => $vv) if (in_array($vv, $data['app_uri'])) unset($uris[$kk]); + } + $this->app->config->set(['domain_bind' => array_merge($uris, $data['app_uri'])], 'app'); + } + // 动态设置运行模式 return $this->app->debug($data['app_run'] !== 'product')->isDebug(); } - /** - * 生成最短URL地址 - * @param string $url 路由地址 - * @param array $vars 变量 - * @param boolean|string $suffix 后缀 - * @param boolean|string $domain 域名 - * @return string - */ - public function sysuri($url = '', array $vars = [], $suffix = true, $domain = false) - { - $d1 = $this->app->config->get('app.default_app'); - $d2 = $this->app->config->get('route.default_controller'); - $d3 = $this->app->config->get('route.default_action'); - $location = $this->app->route->buildUrl($url, $vars)->suffix($suffix)->domain($domain)->build(); - return preg_replace(["|^/{$d1}/{$d2}/{$d3}(\.html)?$|i", "|/{$d2}/{$d3}(\.html)?$|i", "|/{$d3}(\.html)?$|i", '|/\.html$|'], ['$1', '$1', '$1', ''], $location); - } - } \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/storage/LocalStorage.php b/vendor/zoujingli/think-library/src/storage/LocalStorage.php index 1bafc5e53..3e50357fe 100644 --- a/vendor/zoujingli/think-library/src/storage/LocalStorage.php +++ b/vendor/zoujingli/think-library/src/storage/LocalStorage.php @@ -169,7 +169,7 @@ class LocalStorage extends Storage */ public function upload() { - return url('@admin/api.upload/file')->build(); + return url('admin/api.upload/file')->build(); } } \ No newline at end of file