From 2dad9ba856defdf2db129401cd9a639cbbeedb01 Mon Sep 17 00:00:00 2001 From: Anyon Date: Thu, 18 Apr 2019 13:19:17 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]CompoerUpdate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vendor/autoload.php | 2 +- vendor/composer/autoload_classmap.php | 1 - vendor/composer/autoload_real.php | 14 ++-- vendor/composer/autoload_static.php | 9 +- vendor/composer/installed.json | 20 ++--- .../Tests/OptionsResolverTest.php | 38 ++++----- vendor/zoujingli/think-library/common.php | 13 ++- .../think-library/src/Controller.php | 13 +-- .../think-library/src/tools/Cors.php | 84 ------------------- .../think-library/src/tools/Data.php | 8 +- .../think-library/src/tools/Express.php | 42 ++++------ .../think-library/src/tools/Http.php | 4 + 12 files changed, 84 insertions(+), 164 deletions(-) delete mode 100644 vendor/zoujingli/think-library/src/tools/Cors.php diff --git a/vendor/autoload.php b/vendor/autoload.php index bd6d08955..b04511ef7 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit465606aa1bf7d5d08b4f37af5e5eec56::getLoader(); +return ComposerAutoloaderInitdfa1d29ab4d9811dd97c96c297f778d6::getLoader(); diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 0b38f6b32..60391a682 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -201,7 +201,6 @@ return array( 'library\\logic\\Page' => $vendorDir . '/zoujingli/think-library/src/logic/Page.php', 'library\\logic\\Query' => $vendorDir . '/zoujingli/think-library/src/logic/Query.php', 'library\\logic\\Save' => $vendorDir . '/zoujingli/think-library/src/logic/Save.php', - 'library\\tools\\Cors' => $vendorDir . '/zoujingli/think-library/src/tools/Cors.php', 'library\\tools\\Crypt' => $vendorDir . '/zoujingli/think-library/src/tools/Crypt.php', 'library\\tools\\Csrf' => $vendorDir . '/zoujingli/think-library/src/tools/Csrf.php', 'library\\tools\\Csv' => $vendorDir . '/zoujingli/think-library/src/tools/Csv.php', diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 19f8e7b59..67a3d1f38 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit465606aa1bf7d5d08b4f37af5e5eec56 +class ComposerAutoloaderInitdfa1d29ab4d9811dd97c96c297f778d6 { private static $loader; @@ -19,15 +19,15 @@ class ComposerAutoloaderInit465606aa1bf7d5d08b4f37af5e5eec56 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit465606aa1bf7d5d08b4f37af5e5eec56', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitdfa1d29ab4d9811dd97c96c297f778d6', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit465606aa1bf7d5d08b4f37af5e5eec56', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitdfa1d29ab4d9811dd97c96c297f778d6', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit465606aa1bf7d5d08b4f37af5e5eec56::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitdfa1d29ab4d9811dd97c96c297f778d6::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -48,19 +48,19 @@ class ComposerAutoloaderInit465606aa1bf7d5d08b4f37af5e5eec56 $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit465606aa1bf7d5d08b4f37af5e5eec56::$files; + $includeFiles = Composer\Autoload\ComposerStaticInitdfa1d29ab4d9811dd97c96c297f778d6::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire465606aa1bf7d5d08b4f37af5e5eec56($fileIdentifier, $file); + composerRequiredfa1d29ab4d9811dd97c96c297f778d6($fileIdentifier, $file); } return $loader; } } -function composerRequire465606aa1bf7d5d08b4f37af5e5eec56($fileIdentifier, $file) +function composerRequiredfa1d29ab4d9811dd97c96c297f778d6($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 8576bf4f2..8800f9ec9 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit465606aa1bf7d5d08b4f37af5e5eec56 +class ComposerStaticInitdfa1d29ab4d9811dd97c96c297f778d6 { public static $files = array ( '841780ea2e1d6545ea3a253239d59c05' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/functions.php', @@ -306,7 +306,6 @@ class ComposerStaticInit465606aa1bf7d5d08b4f37af5e5eec56 'library\\logic\\Page' => __DIR__ . '/..' . '/zoujingli/think-library/src/logic/Page.php', 'library\\logic\\Query' => __DIR__ . '/..' . '/zoujingli/think-library/src/logic/Query.php', 'library\\logic\\Save' => __DIR__ . '/..' . '/zoujingli/think-library/src/logic/Save.php', - 'library\\tools\\Cors' => __DIR__ . '/..' . '/zoujingli/think-library/src/tools/Cors.php', 'library\\tools\\Crypt' => __DIR__ . '/..' . '/zoujingli/think-library/src/tools/Crypt.php', 'library\\tools\\Csrf' => __DIR__ . '/..' . '/zoujingli/think-library/src/tools/Csrf.php', 'library\\tools\\Csv' => __DIR__ . '/..' . '/zoujingli/think-library/src/tools/Csv.php', @@ -346,9 +345,9 @@ class ComposerStaticInit465606aa1bf7d5d08b4f37af5e5eec56 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit465606aa1bf7d5d08b4f37af5e5eec56::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit465606aa1bf7d5d08b4f37af5e5eec56::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit465606aa1bf7d5d08b4f37af5e5eec56::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitdfa1d29ab4d9811dd97c96c297f778d6::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitdfa1d29ab4d9811dd97c96c297f778d6::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitdfa1d29ab4d9811dd97c96c297f778d6::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index e30c25f3a..25712428d 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -177,17 +177,17 @@ }, { "name": "symfony/options-resolver", - "version": "v3.4.24", - "version_normalized": "3.4.24.0", + "version": "v3.4.26", + "version_normalized": "3.4.26.0", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "926e3b797e6bb66c0e4d7da7eff3a174f7378bcf" + "reference": "ed3b397f9c07c8ca388b2a1ef744403b4d4ecc44" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/926e3b797e6bb66c0e4d7da7eff3a174f7378bcf", - "reference": "926e3b797e6bb66c0e4d7da7eff3a174f7378bcf", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/ed3b397f9c07c8ca388b2a1ef744403b4d4ecc44", + "reference": "ed3b397f9c07c8ca388b2a1ef744403b4d4ecc44", "shasum": "", "mirrors": [ { @@ -199,7 +199,7 @@ "require": { "php": "^5.5.9|>=7.0.8" }, - "time": "2019-02-23T15:06:07+00:00", + "time": "2019-04-10T16:00:48+00:00", "type": "library", "extra": { "branch-alias": { @@ -499,12 +499,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "e7269e7e70e885390d659dccd43437c3acc02b02" + "reference": "52e88c23ee806257ca2e9d577b00dc03beb45a9f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/e7269e7e70e885390d659dccd43437c3acc02b02", - "reference": "e7269e7e70e885390d659dccd43437c3acc02b02", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/52e88c23ee806257ca2e9d577b00dc03beb45a9f", + "reference": "52e88c23ee806257ca2e9d577b00dc03beb45a9f", "shasum": "", "mirrors": [ { @@ -523,7 +523,7 @@ "qiniu/php-sdk": "^7.2", "topthink/framework": "5.1.*" }, - "time": "2019-04-09T11:46:35+00:00", + "time": "2019-04-18T05:12:51+00:00", "type": "library", "installation-source": "dist", "autoload": { diff --git a/vendor/symfony/options-resolver/Tests/OptionsResolverTest.php b/vendor/symfony/options-resolver/Tests/OptionsResolverTest.php index abf0aa015..d85bbe8fd 100644 --- a/vendor/symfony/options-resolver/Tests/OptionsResolverTest.php +++ b/vendor/symfony/options-resolver/Tests/OptionsResolverTest.php @@ -531,13 +531,11 @@ class OptionsResolverTest extends TestCase $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'int[][]'); - $this->resolver->resolve( - [ - 'foo' => [ - [1.2], - ], - ] - ); + $this->resolver->resolve([ + 'foo' => [ + [1.2], + ], + ]); } /** @@ -1598,13 +1596,11 @@ class OptionsResolverTest extends TestCase 1, 2, ], ], - ], $this->resolver->resolve( - [ - 'foo' => [ - [1, 2], - ], - ] - )); + ], $this->resolver->resolve([ + 'foo' => [ + [1, 2], + ], + ])); } public function testNested2Arrays() @@ -1644,17 +1640,15 @@ class OptionsResolverTest extends TestCase $this->resolver->setDefined('foo'); $this->resolver->setAllowedTypes('foo', 'float[][][][]'); - $this->resolver->resolve( - [ - 'foo' => [ + $this->resolver->resolve([ + 'foo' => [ + [ [ - [ - [1, 2], - ], + [1, 2], ], ], - ] - ); + ], + ]); } /** diff --git a/vendor/zoujingli/think-library/common.php b/vendor/zoujingli/think-library/common.php index 34af7b6ff..434c22d37 100644 --- a/vendor/zoujingli/think-library/common.php +++ b/vendor/zoujingli/think-library/common.php @@ -207,7 +207,18 @@ if (!function_exists('emoji_clear')) { } } -// 注册系统指令 +// 注册跨域中间键 +\think\facade\Middleware::add(function (\think\Request $request, \Closure $next) { + if (($origin = $request->header('origin', '*')) !== '*') { + header("Access-Control-Allow-Origin:{$origin}"); + header('Access-Control-Allow-Methods:GET,POST'); + header('Access-Control-Expose-Headers:User-Token-Csrf'); + header('Access-Control-Allow-Headers:Content-Type,X-Requested-With'); + } + return $request->isOptions() ? \think\facade\Response::create() : $next($request); +}); + +// 注册系统常用指令 \think\Console::addDefaultCommands([ 'library\command\Sess', 'library\command\task\Stop', diff --git a/vendor/zoujingli/think-library/src/Controller.php b/vendor/zoujingli/think-library/src/Controller.php index d00a0a7ca..b4d7e6fc7 100644 --- a/vendor/zoujingli/think-library/src/Controller.php +++ b/vendor/zoujingli/think-library/src/Controller.php @@ -14,7 +14,6 @@ namespace library; -use library\tools\Cors; use library\tools\Csrf; /** @@ -43,7 +42,7 @@ class Controller extends \stdClass public $request; /** - * 表单CSRF验证 + * 表单CSRF验证状态 * @var boolean */ private $_isCsrf = false; @@ -53,8 +52,12 @@ class Controller extends \stdClass */ public function __construct() { + // 获取当前请求对象 $this->request = request(); - Cors::setOptionHandler($this->request); + // 禁用访问内部方法 + if (in_array($this->request->method(), get_class_methods(__CLASS__))) { + $this->error('Access without permission.'); + } } /** @@ -86,7 +89,7 @@ class Controller extends \stdClass { $result = ['code' => $code, 'info' => $info, 'data' => $data]; if ($this->_isCsrf) Csrf::clearFormToken(Csrf::getToken()); - throw new \think\exception\HttpResponseException(json($result, 200, Cors::getRequestHeader($this->request))); + throw new \think\exception\HttpResponseException(json($result)); } /** @@ -98,7 +101,7 @@ class Controller extends \stdClass public function error($info, $data = [], $code = 0) { $result = ['code' => $code, 'info' => $info, 'data' => $data]; - throw new \think\exception\HttpResponseException(json($result, 200, Cors::getRequestHeader($this->request))); + throw new \think\exception\HttpResponseException(json($result)); } /** diff --git a/vendor/zoujingli/think-library/src/tools/Cors.php b/vendor/zoujingli/think-library/src/tools/Cors.php deleted file mode 100644 index 53b665e9a..000000000 --- a/vendor/zoujingli/think-library/src/tools/Cors.php +++ /dev/null @@ -1,84 +0,0 @@ -isOptions()) { - header('Access-Control-Allow-Credentials:true'); - header('Access-Control-Allow-Methods:GET,POST,OPTIONS'); - header('Access-Control-Allow-Origin:' . self::getOrigin($request)); - header('Access-Control-Allow-Headers:' . self::getAllows($request)); - header('Access-Control-Expose-Headers:User-Token-Csrf'); - header('Content-Type:text/plain charset=UTF-8'); - header('Access-Control-Max-Age:1728000'); - header('HTTP/1.0 204 No Content'); - header('Content-Length:0'); - header('status:204'); - exit; - } - } - - /** - * 获取返回Header信息 - * @param Request $request - * @return array - */ - public static function getRequestHeader(Request $request) - { - return [ - 'Access-Control-Allow-Credentials' => 'true', - 'Access-Control-Allow-Methods' => 'GET,POST,OPTIONS', - 'Access-Control-Allow-Origin' => self::getOrigin($request), - 'Access-Control-Allow-Headers' => self::getAllows($request), - 'Access-Control-Expose-Headers' => 'User-Token-Csrf', - ]; - } - - /** - * 获取Origin信息 - * @param Request $request - * @return string - */ - private static function getOrigin(Request $request) - { - return $request->header('origin', '*'); - } - - /** - * 获取Allow信息 - * @param Request $request - * @return string - */ - private static function getAllows(Request $request) - { - return 'Host,Accept,Cookie,Origin,Pragma,Expires,Referer,User-Agent,Keep-Alive,Content-Type,Cache-Control,Last-Event-ID,Last-Modified,Content-Language,X-Requested-With,If-Modified-Since'; - } - -} \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/tools/Data.php b/vendor/zoujingli/think-library/src/tools/Data.php index c31462b1c..cfca3db6d 100644 --- a/vendor/zoujingli/think-library/src/tools/Data.php +++ b/vendor/zoujingli/think-library/src/tools/Data.php @@ -29,7 +29,7 @@ class Data * @param array $data 需要保存或更新的数据 * @param string $key 条件主键限制 * @param array $where 其它的where条件 - * @return boolean + * @return boolean|integer * @throws \think\Exception * @throws \think\exception\PDOException */ @@ -38,10 +38,10 @@ class Data $db = is_string($dbQuery) ? Db::name($dbQuery) : $dbQuery; list($table, $value) = [$db->getTable(), isset($data[$key]) ? $data[$key] : null]; $map = isset($where[$key]) ? [] : (is_string($value) ? [[$key, 'in', explode(',', $value)]] : [$key => $value]); - if (Db::table($table)->master()->where($where)->where($map)->count() > 0) { - return Db::table($table)->strict(false)->where($where)->where($map)->update($data) !== false; + if (is_array($info = Db::table($table)->master()->where($where)->where($map)->find()) && !empty($info)) { + return Db::table($table)->strict(false)->where($where)->where($map)->update($data) !== false ? $info[$key] : false; } - return Db::table($table)->strict(false)->insert($data) !== false; + return Db::table($table)->strict(false)->insertGetId($data); } /** diff --git a/vendor/zoujingli/think-library/src/tools/Express.php b/vendor/zoujingli/think-library/src/tools/Express.php index d07bd9fcf..38b42f429 100644 --- a/vendor/zoujingli/think-library/src/tools/Express.php +++ b/vendor/zoujingli/think-library/src/tools/Express.php @@ -21,35 +21,29 @@ namespace library\tools; */ class Express { - /** - * 通用物流单查询 - * @param string $code 快递物流编号 - * @return array - */ - public static function auto($code) - { - list($result, $client_ip) = [[], request()->ip()]; - $header = ['Host' => 'www.kuaidi100.com', 'CLIENT-IP' => $client_ip, 'X-FORWARDED-FOR' => $client_ip]; - $autoResult = Http::get("http://www.kuaidi100.com/autonumber/autoComNum?text={$code}", [], ['header' => $header, 'timeout' => 30]); - foreach (json_decode($autoResult)->auto as $vo) { - $item = self::query($vo->comCode, $code); - if (!empty($item) && $item['message'] === 'ok') $result[$vo->comCode] = $item; - } - return $result; - } - /** * 查询物流信息 - * @param string $expressCode 快递公司编辑 - * @param string $expressNo 快递物流编号 + * @param string $code 快递公司编辑 + * @param string $number 快递物流编号 * @return array */ - public static function query($expressCode, $expressNo) + public static function query($code, $number) { - list($microtime, $clientIp) = [microtime(true), request()->ip()]; - $header = ['Host' => 'www.kuaidi100.com', 'CLIENT-IP' => $clientIp, 'X-FORWARDED-FOR' => $clientIp]; - $location = "http://www.kuaidi100.com/query?type={$expressCode}&postid={$expressNo}&phone=&temp={$microtime}"; - return json_decode(Http::get($location, [], ['header' => $header, 'timeout' => 30]), true); + if (in_array($code, ['debangkuaidi'])) $code = 'debangwuliu'; + list($microtime, $clientIp, $list) = [time(), request()->ip(), []]; + $options = ['header' => ['Host' => 'www.kuaidi100.com', 'CLIENT-IP' => $clientIp, 'X-FORWARDED-FOR' => $clientIp], 'cookie_file' => env('runtime_path') . 'temp/cookie']; + $location = "https://sp0.baidu.com/9_Q4sjW91Qh3otqbppnN2DJv/pae/channel/data/asyncqury?cb=callback&appid=4001&com={$code}&nu={$number}&vcode=&token=&_={$microtime}"; + $result = json_decode(str_replace('/**/callback(', '', trim(http_get($location, [], $options), ')')), true); + if (empty($result['data']['info']['context'])) { // 第一次可能失败,这里尝试第二次查询 + $result = json_decode(str_replace('/**/callback(', '', trim(http_get($location, [], $options), ')')), true); + if (empty($result['data']['info']['context'])) { + return ['message' => 'ok', 'com' => $code, 'nu' => $number, 'data' => $list]; + } + } + foreach ($result['data']['info']['context'] as $vo) $list[] = [ + 'time' => date('Y-m-d H:i:s', $vo['time']), 'ftime' => date('Y-m-d H:i:s', $vo['time']), 'context' => $vo['desc'], + ]; + return ['message' => 'ok', 'com' => $code, 'nu' => $number, 'data' => $list]; } } \ No newline at end of file diff --git a/vendor/zoujingli/think-library/src/tools/Http.php b/vendor/zoujingli/think-library/src/tools/Http.php index c94ff7482..aa3f8fc85 100644 --- a/vendor/zoujingli/think-library/src/tools/Http.php +++ b/vendor/zoujingli/think-library/src/tools/Http.php @@ -68,6 +68,10 @@ class Http curl_setopt($curl, CURLOPT_HTTPHEADER, $options['headers']); } // Cookie 信息设置 + if (!empty($options['cookie_file'])) { + curl_setopt($curl, CURLOPT_COOKIEJAR, $options['cookie_file']); + curl_setopt($curl, CURLOPT_COOKIEFILE, $options['cookie_file']); + } if (!empty($options['cookie'])) { curl_setopt($curl, CURLOPT_COOKIE, $options['cookie']); }