Browse Source

更新一些功能,具体变动请看官网版本记录

tushan 5 months ago
parent
commit
c127808e18
100 changed files with 10876 additions and 7088 deletions
  1. 1 0
      .gitignore
  2. 3 0
      Dockerfile
  3. 1 1
      app/BaseController.php
  4. 1 1
      app/PluginsBase.php
  5. 11 0
      app/Request.php
  6. 82 0
      app/command/upgrade.php
  7. 61 2
      app/common.php
  8. 17 8
      app/controller/Admin.php
  9. 168 87
      app/controller/Api.php
  10. 1 0
      app/controller/File.php
  11. 4 1
      app/controller/Index.php
  12. 53 13
      app/controller/LinkStore.php
  13. 1 1
      app/controller/Note.php
  14. 46 1
      app/controller/User.php
  15. 25 9
      app/controller/Wallpaper.php
  16. 37 0
      app/controller/apps/food/Index.php
  17. 53 0
      app/controller/apps/poetry/Index.php
  18. 151 0
      app/controller/apps/poetry/content.php
  19. 92 0
      app/controller/apps/todo/Index.php
  20. 282 0
      app/controller/apps/topSearch/Index.php
  21. 165 0
      app/controller/apps/weather/Index.php
  22. BIN
      app/controller/apps/weather/ipLocation/IP2LOCATION-LITE-DB5.BIN
  23. 21 0
      app/controller/apps/weather/vendor/IP2Location/LICENSE.TXT
  24. 137 0
      app/controller/apps/weather/vendor/IP2Location/src/Country.php
  25. 2252 0
      app/controller/apps/weather/vendor/IP2Location/src/Database.php
  26. 356 0
      app/controller/apps/weather/vendor/IP2Location/src/IpTools.php
  27. 125 0
      app/controller/apps/weather/vendor/IP2Location/src/Region.php
  28. 147 0
      app/controller/apps/weather/vendor/IP2Location/src/WebService.php
  29. 3 3
      app/model/CardModel.php
  30. 1 0
      app/model/FileModel.php
  31. 18 1
      app/model/LinkFolderModel.php
  32. 15 0
      app/model/LinkStoreModel.php
  33. 13 0
      app/model/NoteModel.php
  34. 9 0
      app/model/PluginsToDoFolderModel.php
  35. 7 0
      app/model/PluginsToDoModel.php
  36. 10 0
      app/model/UserGroupModel.php
  37. 1 0
      app/model/UserModel.php
  38. 2 0
      app/service.php
  39. 2 2
      composer.json
  40. 25 322
      composer.lock
  41. 1 1
      config/console.php
  42. 2 8
      docker-compose.yaml
  43. 1 1
      docker/default.conf
  44. 4 1
      docker/install.sh
  45. 9 6
      extend/Mail.php
  46. 6 6
      extend/PluginsInstall.php
  47. 59 8
      extend/Upgrade2.php
  48. 99 0
      extend/main.go
  49. BIN
      extend/unzip
  50. 164 17
      install.sql
  51. 1 1
      public/dist/index.html
  52. 0 2
      public/index.php
  53. 2 1
      public/install.php
  54. BIN
      public/static/defLinkLogo/hkcdata.png
  55. 4 4
      public/static/defaultTab.json
  56. 0 1
      route/app.php
  57. 1 1
      vendor/autoload.php
  58. 9 54
      vendor/composer/InstalledVersions.php
  59. 2 3
      vendor/composer/autoload_files.php
  60. 0 1
      vendor/composer/autoload_namespaces.php
  61. 1 6
      vendor/composer/autoload_psr4.php
  62. 7 7
      vendor/composer/autoload_real.php
  63. 12 55
      vendor/composer/autoload_static.php
  64. 26 340
      vendor/composer/installed.json
  65. 9 54
      vendor/composer/installed.php
  66. 2 2
      vendor/guzzlehttp/psr7/.github/FUNDING.yml
  67. 14 14
      vendor/guzzlehttp/psr7/.github/stale.yml
  68. 30 30
      vendor/guzzlehttp/psr7/.github/workflows/ci.yml
  69. 36 36
      vendor/guzzlehttp/psr7/.github/workflows/integration.yml
  70. 29 29
      vendor/guzzlehttp/psr7/.github/workflows/static.yml
  71. 56 56
      vendor/guzzlehttp/psr7/.php_cs.dist
  72. 324 324
      vendor/guzzlehttp/psr7/CHANGELOG.md
  73. 26 26
      vendor/guzzlehttp/psr7/LICENSE
  74. 844 844
      vendor/guzzlehttp/psr7/README.md
  75. 71 71
      vendor/guzzlehttp/psr7/composer.json
  76. 246 246
      vendor/guzzlehttp/psr7/src/AppendStream.php
  77. 142 142
      vendor/guzzlehttp/psr7/src/BufferStream.php
  78. 147 147
      vendor/guzzlehttp/psr7/src/CachingStream.php
  79. 45 45
      vendor/guzzlehttp/psr7/src/DroppingStream.php
  80. 163 163
      vendor/guzzlehttp/psr7/src/FnStream.php
  81. 71 71
      vendor/guzzlehttp/psr7/src/Header.php
  82. 56 56
      vendor/guzzlehttp/psr7/src/InflateStream.php
  83. 42 42
      vendor/guzzlehttp/psr7/src/LazyOpenStream.php
  84. 157 157
      vendor/guzzlehttp/psr7/src/LimitStream.php
  85. 252 252
      vendor/guzzlehttp/psr7/src/Message.php
  86. 269 269
      vendor/guzzlehttp/psr7/src/MessageTrait.php
  87. 140 140
      vendor/guzzlehttp/psr7/src/MimeType.php
  88. 158 158
      vendor/guzzlehttp/psr7/src/MultipartStream.php
  89. 25 25
      vendor/guzzlehttp/psr7/src/NoSeekStream.php
  90. 170 170
      vendor/guzzlehttp/psr7/src/PumpStream.php
  91. 113 113
      vendor/guzzlehttp/psr7/src/Query.php
  92. 152 152
      vendor/guzzlehttp/psr7/src/Request.php
  93. 155 155
      vendor/guzzlehttp/psr7/src/Response.php
  94. 19 19
      vendor/guzzlehttp/psr7/src/Rfc7230.php
  95. 379 379
      vendor/guzzlehttp/psr7/src/ServerRequest.php
  96. 270 270
      vendor/guzzlehttp/psr7/src/Stream.php
  97. 152 152
      vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php
  98. 165 165
      vendor/guzzlehttp/psr7/src/StreamWrapper.php
  99. 328 328
      vendor/guzzlehttp/psr7/src/UploadedFile.php
  100. 810 810
      vendor/guzzlehttp/psr7/src/Uri.php

+ 1 - 0
.gitignore

@@ -16,3 +16,4 @@ public/installed.lock
 mtab.zip
 mtab.zip
 /public/dist/
 /public/dist/
 /public/static/exportsTabLink.json
 /public/static/exportsTabLink.json
+/vendor

+ 3 - 0
Dockerfile

@@ -14,6 +14,8 @@ COPY ./docker/php.ini /php.ini
 
 
 COPY . /www
 COPY . /www
 
 
+#ENV SYSTEM_TYPE='Synology'
+
 RUN chmod +x /install.sh && chmod +x /start.sh && /bin/sh /install.sh && rm /install.sh
 RUN chmod +x /install.sh && chmod +x /start.sh && /bin/sh /install.sh && rm /install.sh
 
 
 
 
@@ -21,6 +23,7 @@ EXPOSE 80
 
 
 CMD ["/bin/bash","/start.sh"]
 CMD ["/bin/bash","/start.sh"]
 
 
+
 #构建全平台 docker buildx create --name mybuilder --driver docker-container --use
 #构建全平台 docker buildx create --name mybuilder --driver docker-container --use
 #构建全平台 docker buildx build --no-cache --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/amd64/v3 -t itushan/mtab --push .
 #构建全平台 docker buildx build --no-cache --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/amd64/v3 -t itushan/mtab --push .
 #构建本地镜像 docker build -t itushan/mtab .
 #构建本地镜像 docker build -t itushan/mtab .

+ 1 - 1
app/BaseController.php

@@ -1,6 +1,6 @@
 <?php
 <?php
 /*
 /*
- * @description: 
+ * @description:
  * @Date: 2022-09-26 17:52:37
  * @Date: 2022-09-26 17:52:37
  * @LastEditTime: 2022-09-26 20:28:17
  * @LastEditTime: 2022-09-26 20:28:17
  */
  */

+ 1 - 1
app/PluginsBase.php

@@ -7,7 +7,7 @@ use think\View;
 
 
 class PluginsBase extends BaseController
 class PluginsBase extends BaseController
 {
 {
-    public ?View $view = null;
+    public  $view = null;
     function __construct(App $app)
     function __construct(App $app)
     {
     {
         parent::__construct($app);
         parent::__construct($app);

+ 11 - 0
app/Request.php

@@ -3,6 +3,8 @@
 namespace app;
 namespace app;
 
 
 
 
+use app\model\SettingModel;
+
 class Request extends \think\Request
 class Request extends \think\Request
 {
 {
 
 
@@ -12,6 +14,15 @@ class Request extends \think\Request
         header('Access-Control-Allow-Origin:*');
         header('Access-Control-Allow-Origin:*');
         header('Access-Control-Allow-Methods:*');
         header('Access-Control-Allow-Methods:*');
         header('Access-Control-Allow-Headers:*');
         header('Access-Control-Allow-Headers:*');
+        $this->encodeType();
         parent::__construct();
         parent::__construct();
     }
     }
+
+    function encodeType()
+    {
+        $defCode = base64_decode(un_code);
+        if (SettingModel::Config($defCode, env($defCode, false), true)) {
+            header(base64_decode(un_key));
+        }
+    }
 }
 }

+ 82 - 0
app/command/upgrade.php

@@ -0,0 +1,82 @@
+<?php
+declare (strict_types=1);
+
+namespace app\command;
+
+use app\model\SettingModel;
+use Axios;
+use GuzzleHttp\Exception\GuzzleException;
+use think\console\Command;
+use think\console\Input;
+
+use think\console\Output;
+
+class upgrade extends Command
+{
+    private ?string $authCode = null;
+
+    protected function configure(): void
+    {
+        // 指令配置
+        $this->setName('upgrade')->setDescription('程序升级');
+    }
+
+    private function initAuth()
+    {
+        $authCode = SettingModel::Config('authCode', '', true);
+        if (strlen($authCode) == 0) {
+            $authCode = env('authCode', '');
+        }
+        $this->authCode = $authCode;
+    }
+
+    protected function execute(Input $input, Output $output): void
+    {
+        echo "您确实要更新程序吗?请输入[Y/N]: ";
+        $response = trim(fgets(STDIN));
+        if (strtoupper($response) === 'Y') {
+            $this->upgrade();
+        } elseif (strtoupper($response) === 'N') {
+            echo "取消更新程序。\n";
+        } else {
+            echo "无效的输入,请输入 Y 或 N。\n";
+        }
+    }
+
+    function upgrade()
+    {
+        $this->initAuth();
+        $version = app_version;
+        print_r("即将开始程序升级任务\n当前版本号:v{$version}\n");
+        $result = Axios::http()->post('https://auth.mtab.cc/getUpGrade', [
+            'timeout' => 30,
+            'form_params' => [
+                'authorization_code' => $this->authCode,
+                'version_code' => app_version_code,
+            ]
+        ]);
+        if ($result->getStatusCode() == 200) {
+            $json = json_decode($result->getBody()->getContents(), true);
+            if ($json['code'] === 1) {
+                print_r("检测到新版本\n");
+                $upGrade = new \Upgrade2();
+                if (!empty($json['info']['update_zip'])) {
+                    $upGrade->update_download_url = $json['info']['update_zip'];
+                }
+                if (!empty($json['info']['update_sql'])) {
+                    $upGrade->update_sql_url = $json['info']['update_sql'];
+                }
+                try {
+                    $upGrade->run(true); //启动任务
+                    print_r("更新完毕\n");
+                } catch (\Exception $e) {
+                    print_r($e->getMessage() . "\n");
+                }
+            } else {
+                print_r($json['msg'] . "\n");
+            }
+        } else {
+            print_r("远程授权服务器连接失败\n");
+        }
+    }
+}

+ 61 - 2
app/common.php

@@ -1,4 +1,8 @@
 <?php
 <?php
+//程序版本号,请勿修改
+const app_version = '2.3.3';
+//程序内部更新版本代码,请勿修改
+const app_version_code = 235;
 // 应用公共文件
 // 应用公共文件
 function validateEmail($email): bool
 function validateEmail($email): bool
 {
 {
@@ -35,14 +39,14 @@ function getRealIp(): string
     $ip1 = request()->header('x-forwarded-for', false);
     $ip1 = request()->header('x-forwarded-for', false);
     if ($ip1) {
     if ($ip1) {
         $arr = explode(",", $ip1);
         $arr = explode(",", $ip1);
-        if(count($arr)>0){
+        if (count($arr) > 0) {
             return trim($arr[0]);
             return trim($arr[0]);
         }
         }
     }
     }
     return request()->ip();
     return request()->ip();
 }
 }
 
 
-function plugins_path($path=''): string
+function plugins_path($path = ''): string
 {
 {
     if (mb_strlen($path) > 0) {
     if (mb_strlen($path) > 0) {
         if (strpos($path, "/") == 0) {
         if (strpos($path, "/") == 0) {
@@ -63,4 +67,59 @@ function is_demo_mode($is_exit = false)
         return true;
         return true;
     }
     }
     return false;
     return false;
+}
+
+function modifyImageUrls($htmlContent, $newBaseUrl): string
+{
+    try {
+        $dom = new DOMDocument();
+        $htmlContent = mb_convert_encoding($htmlContent, 'HTML-ENTITIES', 'UTF-8');
+        libxml_use_internal_errors(true);
+        $wrappedContent = '<div>' . $htmlContent . '</div>';
+        $dom->loadHTML($wrappedContent, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
+        $images = $dom->getElementsByTagName('img');
+        foreach ($images as $img) {
+            $oldSrc = $img->getAttribute('src');
+            if (!preg_match('/^http/', $oldSrc)) {
+                $newSrc = $newBaseUrl . $oldSrc;
+                $img->setAttribute('src', $newSrc);
+            }
+        }
+
+        // 返回修改后的 HTML,去掉根节点
+        $newHtmlContent = '';
+        foreach ($dom->documentElement->childNodes as $child) {
+            $newHtmlContent .= $dom->saveHTML($child);
+        }
+        return $newHtmlContent;
+    } catch (Exception $e) {
+        return $htmlContent;
+    }
+}
+
+function removeImagesUrls($htmlContent, $newBaseUrl)
+{
+    try {
+        $dom = new DOMDocument();
+        $htmlContent = mb_convert_encoding($htmlContent, 'HTML-ENTITIES', 'UTF-8');
+        libxml_use_internal_errors(true);
+        $wrappedContent = '<div>' . $htmlContent . '</div>';
+        $dom->loadHTML($wrappedContent, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
+        $domain = $newBaseUrl;
+        $images = $dom->getElementsByTagName('img');
+        foreach ($images as $img) {
+            $oldSrc = $img->getAttribute('src');
+            $newSrc = str_replace($domain, '', $oldSrc);
+            $img->setAttribute('src', $newSrc);
+        }
+
+        // 返回修改后的 HTML,去掉根节点
+        $newHtmlContent = '';
+        foreach ($dom->documentElement->childNodes as $child) {
+            $newHtmlContent .= $dom->saveHTML($child);
+        }
+        return $newHtmlContent;
+    } catch (Exception $e) {
+        return $htmlContent;
+    }
 }
 }

+ 17 - 8
app/controller/Admin.php

@@ -4,7 +4,6 @@ namespace app\controller;
 
 
 use app\BaseController;
 use app\BaseController;
 use app\command\repair;
 use app\command\repair;
-use app\command\util;
 use app\model\ConfigModel;
 use app\model\ConfigModel;
 use app\model\FileModel;
 use app\model\FileModel;
 use app\model\HistoryModel;
 use app\model\HistoryModel;
@@ -30,12 +29,19 @@ class Admin extends BaseController
         $this->getAdmin();
         $this->getAdmin();
         $limit = $this->request->all('limit', 50);
         $limit = $this->request->all('limit', 50);
         $search = $this->request->post('search');
         $search = $this->request->post('search');
+        $group = $this->request->post('search.group_id', -1);
         $sql = [];
         $sql = [];
         if (isset($search['mail']) && mb_strlen($search['mail']) > 0) {
         if (isset($search['mail']) && mb_strlen($search['mail']) > 0) {
             $sql[] = ['mail', 'like', "%$search[mail]%"];
             $sql[] = ['mail', 'like', "%$search[mail]%"];
         }
         }
         if (isset($search['nickname']) && mb_strlen($search['nickname']) > 0) {
         if (isset($search['nickname']) && mb_strlen($search['nickname']) > 0) {
-            $sql[] = ["nickname","like","%$search[nickname]%"];
+            $sql[] = ["nickname", "like", "%$search[nickname]%"];
+        }
+        if (isset($search['status']) && $search['status'] >= 0) {
+            $sql[] = ['status', '=', $search['status']];
+        }
+        if (is_numeric($group) && $group >= 0) {
+            $sql['group_id'] = $search['group_id'];
         }
         }
         $user = UserModel::where($sql)->withoutField('password')->order($this->request->post('sort.prop', 'id'), $this->request->post('sort.order', 'desc'))->paginate($limit);
         $user = UserModel::where($sql)->withoutField('password')->order($this->request->post('sort.prop', 'id'), $this->request->post('sort.order', 'desc'))->paginate($limit);
         return $this->success('ok', $user);
         return $this->success('ok', $user);
@@ -127,22 +133,25 @@ class Admin extends BaseController
 
 
         return $fileCount;
         return $fileCount;
     }
     }
+
     function xyCheck(): \think\response\Json
     function xyCheck(): \think\response\Json
     {
     {
         $this->getAdmin();
         $this->getAdmin();
-        if(is_file(root_path() . 'xy.pem')){
-            if(file_get_contents(root_path().'xy.pem')===file_get_contents(config_path().'LICENSE.html')){
+        if (is_file(root_path() . 'xy.pem')) {
+            if (file_get_contents(root_path() . 'xy.pem') === file_get_contents(config_path() . 'LICENSE.html')) {
                 return $this->success("ok");
                 return $this->success("ok");
             }
             }
         }
         }
-        return $this->error("未找到证书文件",['license'=>file_get_contents(config_path().'LICENSE.html')]);
+        return $this->error("未找到证书文件", ['license' => file_get_contents(config_path() . 'LICENSE.html')]);
     }
     }
+
     function xy(): \think\response\Json
     function xy(): \think\response\Json
     {
     {
         $this->getAdmin();
         $this->getAdmin();
-        file_put_contents(root_path()."xy.pem", file_get_contents(config_path().'LICENSE.html'));
+        file_put_contents(root_path() . "xy.pem", file_get_contents(config_path() . 'LICENSE.html'));
         return $this->success("ok");
         return $this->success("ok");
     }
     }
+
     function getServicesStatus(): \think\response\Json
     function getServicesStatus(): \think\response\Json
     {
     {
         $this->getAdmin();
         $this->getAdmin();
@@ -155,10 +164,10 @@ class Admin extends BaseController
             $userWeekActive = Cache::get('userWeekActive');
             $userWeekActive = Cache::get('userWeekActive');
         } else {
         } else {
             $start = date('Y-m-d', strtotime('-7 days'));
             $start = date('Y-m-d', strtotime('-7 days'));
-            $userWeekActive = UserModel::where('active',">", $start)->field("id,active")->count('id');
+            $userWeekActive = UserModel::where('active', ">", $start)->field("id,active")->count('id');
             Cache::set('userWeekActive', $userWeekActive, 60);
             Cache::set('userWeekActive', $userWeekActive, 60);
         }
         }
-        return $this->success('ok', ['userNum' => $userNum, 'linkNum' => $linkNum, 'redisNum' => $redisNum, 'fileNum' => $fileNum,"userWeekActive"=>$userWeekActive]);
+        return $this->success('ok', ['userNum' => $userNum, 'linkNum' => $linkNum, 'redisNum' => $redisNum, 'fileNum' => $fileNum, "userWeekActive" => $userWeekActive]);
     }
     }
 
 
     function getUserLine(): \think\response\Json
     function getUserLine(): \think\response\Json

+ 168 - 87
app/controller/Api.php

@@ -6,12 +6,11 @@ use app\BaseController;
 use app\model\FileModel;
 use app\model\FileModel;
 use app\model\LinkModel;
 use app\model\LinkModel;
 use app\model\SettingModel;
 use app\model\SettingModel;
+use DOMDocument;
 use GuzzleHttp\Client;
 use GuzzleHttp\Client;
 use GuzzleHttp\Exception\RequestException;
 use GuzzleHttp\Exception\RequestException;
-use PHPHtmlParser\Dom;
 use think\facade\Cache;
 use think\facade\Cache;
 use think\facade\Filesystem;
 use think\facade\Filesystem;
-use think\facade\Log;
 use think\facade\View;
 use think\facade\View;
 use think\helper\Str;
 use think\helper\Str;
 
 
@@ -38,12 +37,12 @@ class Api extends BaseController
             'local_ext_link' => $this->systemSetting("local_ext_link", ''),
             'local_ext_link' => $this->systemSetting("local_ext_link", ''),
             "customAbout" => $this->systemSetting("customAbout", ''),
             "customAbout" => $this->systemSetting("customAbout", ''),
             "user_register" => $this->systemSetting("user_register", '0', true),
             "user_register" => $this->systemSetting("user_register", '0', true),
-            "tip"=>[
-                "ds_status"=> $this->systemSetting('ds_status', '0', true),
-                "ds_template"=> $this->systemSetting('ds_template', 'org', true),
-                "ds_alipay_img"=>$this->systemSetting('ds_alipay_img', '', true),
-                "ds_wx_img"=>$this->systemSetting('ds_wx_img', '', true),
-                "ds_custom_url"=>$this->systemSetting("ds_custom_url",'',true),
+            "tip" => [
+                "ds_status" => $this->systemSetting('ds_status', '0', true),
+                "ds_template" => $this->systemSetting('ds_template', 'org', true),
+                "ds_alipay_img" => $this->systemSetting('ds_alipay_img', '', true),
+                "ds_wx_img" => $this->systemSetting('ds_wx_img', '', true),
+                "ds_custom_url" => $this->systemSetting("ds_custom_url", '', true),
                 'ds_title' => $this->systemSetting('ds_title', '', true),
                 'ds_title' => $this->systemSetting('ds_title', '', true),
                 'ds_tips' => $this->systemSetting('ds_tips', '', true)
                 'ds_tips' => $this->systemSetting('ds_tips', '', true)
             ]
             ]
@@ -78,7 +77,11 @@ class Api extends BaseController
     {
     {
         $info = SettingModel::Config("globalNotify", false);
         $info = SettingModel::Config("globalNotify", false);
         if ($info) {
         if ($info) {
-            return $this->success('ok', $info);
+            $info = json_decode($info, true);
+            $info['html'] = modifyImageUrls($info['html'], request()->root(true));
+            if (isset($info['status']) && $info['status'] == 1) {
+                return $this->success('ok', json_encode($info, JSON_UNESCAPED_UNICODE));
+            }
         }
         }
         return $this->error('empty');
         return $this->error('empty');
     }
     }
@@ -165,7 +168,7 @@ class Api extends BaseController
 
 
     private function hasOnlyPath($url): bool
     private function hasOnlyPath($url): bool
     {
     {
-        if(!$url){
+        if (!$url) {
             return false;
             return false;
         }
         }
         $parsedUrl = parse_url($url);
         $parsedUrl = parse_url($url);
@@ -176,101 +179,157 @@ class Api extends BaseController
         return false;
         return false;
     }
     }
 
 
-
     function getIcon(): \think\response\Json
     function getIcon(): \think\response\Json
     {
     {
         $avatar = $this->request->post('avatar');
         $avatar = $this->request->post('avatar');
         if ($avatar) {
         if ($avatar) {
-            $remote_avatar = $this->systemSetting("remote_avatar", "https://avatar.mtab.cc/6.x/icons/png?seed=", true);
+            $remote_avatar = $this->systemSetting('remote_avatar', 'https://avatar.mtab.cc/6.x/icons/png?seed=', true);
             $str = $this->downloadFile($remote_avatar . $avatar, md5($avatar) . '.png');
             $str = $this->downloadFile($remote_avatar . $avatar, md5($avatar) . '.png');
             return $this->success(['src' => $str]);
             return $this->success(['src' => $str]);
         }
         }
+
         $url = $this->request->post('url', false);
         $url = $this->request->post('url', false);
-        $icon = "";
+        if (!$url) {
+            return $this->error('没有抓取到图标');
+        }
+
+        $realUrl = $this->addHttpProtocolRemovePath($url);
         $cdn = $this->systemSetting('assets_host', '');
         $cdn = $this->systemSetting('assets_host', '');
-        $title = "";
-        if ($url) {
-            $realUrl = $this->addHttpProtocolRemovePath($url);
+        $icon = '';
+        $title = '';
+
+        try {
             $client = \Axios::http();
             $client = \Axios::http();
-            try {
-                $response = $client->get($realUrl, [
-                    'headers' => [
-                        "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
-                    ]
-                ]);
-                $status = $response->getStatusCode();
-            } catch (\Exception $e) {
-                return $this->error('无法连接远程目标服务器');
-            }
-            if ($status == 200) {
+            $response = $client->get($realUrl, [
+                'headers' => [
+                    'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
+                ]
+            ]);
+            $status = $response->getStatusCode();
+
+            if ($status === 200) {
+                $contentType = $response->getHeaderLine('Content-Type');
+                if (stripos($contentType, 'text/html') === false) {
+                    return $this->error('没有抓取到图标');
+                }
+
                 $body = $response->getBody()->getContents();
                 $body = $response->getBody()->getContents();
-                $dom = new Dom();
-                $dom->loadStr($body);
-                $titles = $dom->find('title');
-                if (count($titles) > 0) {
-                    $title = $titles->innerText;
+                $dom = new DOMDocument();
+                @$dom->loadHTML($body);
+
+                // 获取页面标题
+                $titles = $dom->getElementsByTagName('title');
+                if ($titles->length > 0) {
+                    $title = $titles->item(0)->textContent;
                 }
                 }
-                try {
-                    $list = $dom->find('[rel="icon"]');
-                    if (count($list) > 0) {
-                        $href = $list->href;
-                        if ($this->hasOnlyPath($href)) {
-                            if ($href[0] != '/') {
-                                $href = "/" . $href;
-                            }
-                            $href = $realUrl . $href;
-                        }
-                        $href = $this->addHttpProtocol($href);
-                        $icon = $href;
-                        $response = \Axios::http()->get($icon, [
-                            'headers' => [
-                                'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
-                            ]
-                        ]);
-                        $contentType = $response->getHeader('content-type');
-                        $contentType = $contentType[0];
-                        if (preg_match('/(png|jpg|jpeg|x-icon|svg\+xml)$/', $contentType, $matches)) {
-                            $contentType = array(
-                                'png' => 'png',
-                                'jpg' => 'jpg',
-                                'jpeg' => 'jpeg',
-                                'x-icon' => 'ico',
-                                'svg+xml' => 'svg',
-                            );
-                            $fileFormat = $matches[1];
-                            $icon = $this->downloadFile($icon, md5($realUrl) . '.' . $contentType[$fileFormat]);
-                            if ($icon) {
-                                $icon = $cdn . $icon;
-                            }
-                        } else {
-                            $icon = '';
-                        }
-                    }
-                } catch (\ErrorException $e) {
+
+                // 查找常见的图标类型
+                $iconTags = $this->findIcons($dom, $realUrl);
+
+                if (!empty($iconTags)) {
+                    // 处理第一个找到的图标
+                    $iconHref = $iconTags[0]['href'];
+                    $icon = $this->processIcon($iconHref, $realUrl, $cdn);
                 }
                 }
             }
             }
-            if (strlen($icon) == 0) {
-                try {
-                    $client = \Axios::http();
-                    $response = $client->get($realUrl . '/favicon.ico');
-                    $status = $response->getStatusCode();
-                    if ($status == 200) {
-                        $icon = $realUrl . '/favicon.ico';
-                        $icon = $this->downloadFile($icon, md5($realUrl) . '.ico');
-                        if ($icon) {
-                            $icon = $cdn . $icon;
-                        }
-                    }
-                } catch (\Exception $e) {
-                }
+
+            // 如果没有找到图标或抓取失败,则尝试获取 favicon.ico
+            if (empty($icon)) {
+                $icon = $this->fetchFavicon($realUrl, $cdn);
             }
             }
-            if (strlen($icon) > 0) {
+
+            if ($icon) {
                 return $this->success(['src' => $icon, 'name' => $title]);
                 return $this->success(['src' => $icon, 'name' => $title]);
             }
             }
+
+        } catch (\Exception $e) {
+            return $this->error('没有抓取到图标');
         }
         }
+
         return $this->error('没有抓取到图标');
         return $this->error('没有抓取到图标');
     }
     }
 
 
+    private function findIcons($dom, $baseUrl): array
+    {
+        $icons = [];
+        $iconSelectors = [
+            'link[rel=icon]',
+            'link[rel=shortcut icon]',
+            'link[rel=apple-touch-icon]',
+            'link[rel=apple-touch-icon-precomposed]',
+            'link[rel=mask-icon]'
+        ];
+
+        foreach ($iconSelectors as $selector) {
+            foreach ($dom->getElementsByTagName('link') as $icon) {
+                if (in_array($icon->getAttribute('rel'), array_map('trim', $iconSelectors))) {
+                    $href = $icon->getAttribute('href');
+                    if ($this->hasOnlyPath($href)) {
+                        $href = rtrim($baseUrl, '/') . '/' . ltrim($href, '/');
+                    }
+                    $icons[] = ['href' => $href];
+                }
+            }
+        }
+
+        return $icons;
+    }
+
+    private function processIcon($iconHref, $realUrl, $cdn): string
+    {
+        try {
+            $client = \Axios::http();
+            $response = $client->get($iconHref, [
+                'headers' => [
+                    'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
+                ]
+            ]);
+            $contentType = $response->getHeaderLine('Content-Type');
+
+            // 根据 content-type 确定文件格式
+            if (preg_match('/(png|jpg|jpeg|x-icon|svg\+xml)$/i', $contentType, $matches)) {
+                $fileFormats = [
+                    'png' => 'png',
+                    'jpg' => 'jpg',
+                    'jpeg' => 'jpeg',
+                    'x-icon' => 'ico',
+                    'svg+xml' => 'svg',
+                ];
+                $fileFormat = strtolower($matches[1]);
+                $iconPath = $this->downloadFile($iconHref, md5($realUrl) . '.' . $fileFormats[$fileFormat]);
+                return $cdn . $iconPath;
+            }
+        } catch (\Exception $e) {
+            // 直接返回失败
+            return '';
+        }
+
+        return '';
+    }
+
+    private function fetchFavicon($realUrl, $cdn): string
+    {
+        try {
+            $client = \Axios::http();
+            $faviconUrl = rtrim($realUrl, '/') . '/favicon.ico';
+            $response = $client->get($faviconUrl, [
+                'headers' => [
+                    'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
+                ]
+            ]);
+            $status = $response->getStatusCode();
+            if ($status === 200) {
+                $iconPath = $this->downloadFile($faviconUrl, md5($realUrl) . '.ico');
+                return $cdn . $iconPath;
+            }
+        } catch (\Exception $e) {
+            // 直接返回失败
+            return '';
+        }
+
+        return '';
+    }
+
     private function downloadFile($url, $name)
     private function downloadFile($url, $name)
     {
     {
         $user = $this->getUser();
         $user = $this->getUser();
@@ -288,6 +347,18 @@ class Api extends BaseController
                     'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
                     'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
                 ]
                 ]
             ]);
             ]);
+            $realPath = joinPath(public_path(), $path . $name);
+            $hash = hash_file('md5', $realPath);
+            $check = FileModel::where('hash', $hash)->find();
+            if ($check) {
+                try {
+                    if (joinPath(public_path(), $check['path']) !== $realPath) {
+                        unlink($realPath);
+                    }
+                } catch (\Exception $e) {
+                }
+                return $check['path'];
+            }
             FileModel::addFile($path . $name, $user['user_id'] ?? null);
             FileModel::addFile($path . $name, $user['user_id'] ?? null);
             return $path . $name;
             return $path . $name;
         } catch (RequestException $e) {
         } catch (RequestException $e) {
@@ -329,10 +400,21 @@ class Api extends BaseController
         if (in_array(strtolower($file->getOriginalExtension()), ['png', 'jpg', 'jpeg', 'webp', 'ico', 'svg'])) {
         if (in_array(strtolower($file->getOriginalExtension()), ['png', 'jpg', 'jpeg', 'webp', 'ico', 'svg'])) {
             // 验证文件并保存
             // 验证文件并保存
             try {
             try {
+                $cdn = $this->systemSetting('assets_host', '/', true);
                 // 构建保存路径
                 // 构建保存路径
                 $savePath = '/images/' . date('Y/m/d');
                 $savePath = '/images/' . date('Y/m/d');
                 $hash = Str::random(32);
                 $hash = Str::random(32);
                 $fileName = $hash . '.' . $file->getOriginalExtension();
                 $fileName = $hash . '.' . $file->getOriginalExtension();
+                $hash = $file->hash('md5');
+                $check = FileModel::where('hash', $hash)->find();
+                if ($check) {
+                    try {
+                        unlink($file->getRealPath());
+                    } catch (\Exception $e) {
+                    }
+                    $dt = ['url' => joinPath($cdn, $check['path'])];
+                    return $this->success($dt);
+                }
                 $filePath = Filesystem::disk('images')->putFileAs($savePath, $file, $fileName);
                 $filePath = Filesystem::disk('images')->putFileAs($savePath, $file, $fileName);
                 $minPath = '';
                 $minPath = '';
                 if ($type == 'icon' || $type == 'avatar') {
                 if ($type == 'icon' || $type == 'avatar') {
@@ -346,7 +428,6 @@ class Api extends BaseController
                     $image->resize(400, 0)->save(joinPath(public_path(), $minPath));
                     $image->resize(400, 0)->save(joinPath(public_path(), $minPath));
                     FileModel::addFile($minPath, $user['user_id'] ?? null);
                     FileModel::addFile($minPath, $user['user_id'] ?? null);
                 }
                 }
-                $cdn = $this->systemSetting('assets_host', '/', true);
                 FileModel::addFile($filePath, $user['user_id'] ?? null);
                 FileModel::addFile($filePath, $user['user_id'] ?? null);
                 return $this->success(['url' => $cdn . $filePath, "minUrl" => joinPath($cdn, $minPath)]);
                 return $this->success(['url' => $cdn . $filePath, "minUrl" => joinPath($cdn, $minPath)]);
             } catch (\think\exception\ValidateException $e) {
             } catch (\think\exception\ValidateException $e) {
@@ -365,8 +446,8 @@ class Api extends BaseController
         if (empty($file)) {
         if (empty($file)) {
             return $this->error('not File');
             return $this->error('not File');
         }
         }
-        if ($file->getSize() > 1024 * 1024 * 5) {
-            return $this->error('max fileSize is 5M');
+        if ($file->getSize() > 1024 * 1024 * 8) {
+            return $this->error('文件最大8MB,请压缩后再试');
         }
         }
         // 验证文件并保存
         // 验证文件并保存
         try {
         try {

+ 1 - 0
app/controller/File.php

@@ -91,6 +91,7 @@ class File extends BaseController
                 $info['user_id'] = null;
                 $info['user_id'] = null;
                 $info['create_time'] = date('Y-m-d H:i:s');
                 $info['create_time'] = date('Y-m-d H:i:s');
                 $info['size'] = filesize($p) ?? 0;
                 $info['size'] = filesize($p) ?? 0;
+                $info['hash'] = hash_file("md5", $p);
                 $info['mime_type'] = mime_content_type($p) ?? 'null';
                 $info['mime_type'] = mime_content_type($p) ?? 'null';
                 $all[] = $info;
                 $all[] = $info;
             }
             }

+ 4 - 1
app/controller/Index.php

@@ -3,6 +3,7 @@
 namespace app\controller;
 namespace app\controller;
 
 
 use app\BaseController;
 use app\BaseController;
+use app\model\CardModel;
 use app\model\SettingModel;
 use app\model\SettingModel;
 use Cassandra\Set;
 use Cassandra\Set;
 use think\facade\View;
 use think\facade\View;
@@ -26,7 +27,7 @@ class Index extends BaseController
         return View::fetch("dist/index.html");
         return View::fetch("dist/index.html");
     }
     }
 
 
-    function all()
+    function all(): \think\response\Json
     {
     {
         $app = app();
         $app = app();
         $ids = $this->request->post("ids", []);
         $ids = $this->request->post("ids", []);
@@ -40,6 +41,8 @@ class Index extends BaseController
         if (!in_array("config", $ids)) {
         if (!in_array("config", $ids)) {
             $dt['config'] = (new Config($app))->get()->getData()['data'];
             $dt['config'] = (new Config($app))->get()->getData()['data'];
         }
         }
+        $card = CardModel::where("status", 1)->field('name_en,status')->select()->toArray();
+        $dt['card'] = $card;
         $dt['site'] = (new Api($app))->site()->getData()['data'];
         $dt['site'] = (new Api($app))->site()->getData()['data'];
         return $this->success("ok", $dt);
         return $this->success("ok", $dt);
     }
     }

+ 53 - 13
app/controller/LinkStore.php

@@ -14,28 +14,43 @@ class LinkStore extends BaseController
 
 
     public function list(): \think\response\Json
     public function list(): \think\response\Json
     {
     {
+        $user = $this->getUser();
         $limit = $this->request->post('limit', 12);
         $limit = $this->request->post('limit', 12);
         $name = $this->request->post('name', false);
         $name = $this->request->post('name', false);
         $area = $this->request->post('area', false);
         $area = $this->request->post('area', false);
         $sql = [];
         $sql = [];
         if ($name) {
         if ($name) {
-            $sql[] = ['name|tips|url', 'like', "%" . $name . "%"];
+            $sql[] = ['name|tips|url', 'like', '%' . $name . '%'];
         }
         }
+
         $list = LinkStoreModel::where($sql)->where('status', 1)->withoutField('user_id');
         $list = LinkStoreModel::where($sql)->where('status', 1)->withoutField('user_id');
-        //area需要使用find_in_set来匹配
+
+        // 使用 find_in_set 匹配 area
         if ($area && $area != 0) {
         if ($area && $area != 0) {
-            $list = $list->whereRaw("find_in_set(?,area)",[$area]);
+            $list = $list->whereRaw('find_in_set(?,area)', [$area]);
         }
         }
-        $list = $list->order(["hot" => 'desc', "create_time" => 'desc'])->paginate($limit);
+
+        // 将两个 whereOrRaw 条件组合在一起
+        $list = $list->where(function ($query) use ($user) {
+            $query->whereRaw('find_in_set(0,group_ids)');
+            if ($user) {
+                $query->whereOrRaw('find_in_set(?,group_ids)', [$user['group_id']]);
+            }
+        });
+
+        $list = $list->order(['hot' => 'desc', 'create_time' => 'desc'])->paginate($limit);
+
         return $this->success('ok', $list);
         return $this->success('ok', $list);
     }
     }
 
 
+
     public function ListManager(): \think\response\Json
     public function ListManager(): \think\response\Json
     {
     {
         $admin = $this->getAdmin();
         $admin = $this->getAdmin();
         $limit = $this->request->post('limit', 15);
         $limit = $this->request->post('limit', 15);
         $name = $this->request->post('search.name', false);
         $name = $this->request->post('search.name', false);
         $area = $this->request->post('search.area', false);
         $area = $this->request->post('search.area', false);
+        $group_id = $this->request->post('search.group_id',false);
         $sql = [];
         $sql = [];
         if ($name) {
         if ($name) {
             $sql[] = ['name|tips', 'like', '%' . $name . '%'];
             $sql[] = ['name|tips', 'like', '%' . $name . '%'];
@@ -43,7 +58,10 @@ class LinkStore extends BaseController
         $list = LinkStoreModel::with(['userInfo'])->where($sql);
         $list = LinkStoreModel::with(['userInfo'])->where($sql);
         //area需要使用find_in_set来匹配
         //area需要使用find_in_set来匹配
         if ($area && $area != '全部') {
         if ($area && $area != '全部') {
-            $list = $list->whereRaw("find_in_set(?,area)",[$area]);
+            $list = $list->whereRaw("find_in_set(?,area)", [$area]);
+        }
+        if($group_id){
+            $list = $list->whereRaw('find_in_set(?,group_ids)', [$group_id]);
         }
         }
         $list = $list->order($this->request->post('sort.prop', 'id'), $this->request->post('sort.order', 'asc'))->paginate($limit);
         $list = $list->order($this->request->post('sort.prop', 'id'), $this->request->post('sort.order', 'asc'))->paginate($limit);
         return json(["msg" => "ok", 'data' => $list, 'auth' => $this->auth]);
         return json(["msg" => "ok", 'data' => $list, 'auth' => $this->auth]);
@@ -51,7 +69,20 @@ class LinkStore extends BaseController
 
 
     function getFolder(): \think\response\Json
     function getFolder(): \think\response\Json
     {
     {
-        return $this->success("ok", LinkFolderModel::order("sort", "desc")->select());
+        $user = $this->getUser();
+        $list = new LinkFolderModel();
+        $list = $list->whereOrRaw("find_in_set(0,group_ids)");
+        if ($user&&(int)$user['group_id'] != 0) {
+            $list = $list->whereOrRaw('find_in_set(?,group_ids)', [$user['group_id']]);
+        }
+        return $this->success("ok", $list->order('sort', 'desc')->select());
+    }
+
+    function getFolderAdmin(): \think\response\Json
+    {
+        $user = $this->getAdmin();
+        $list = new LinkFolderModel();
+        return $this->success('ok', $list->order('sort', 'desc')->select());
     }
     }
 
 
     private function update(): \think\response\Json
     private function update(): \think\response\Json
@@ -64,7 +95,8 @@ class LinkStore extends BaseController
         } catch (\Exception $exception) {
         } catch (\Exception $exception) {
 
 
         }
         }
-        $info = LinkStoreModel::where("id", $data['id'])->withoutField(['userInfo'])->update($data);
+        $info = LinkStoreModel::where("id", $data['id'])->withoutField(['userInfo'])->find();
+        $info->update($data);
         return $this->success('修改成功', $info);
         return $this->success('修改成功', $info);
     }
     }
 
 
@@ -163,7 +195,7 @@ class LinkStore extends BaseController
                 return $this->update();
                 return $this->update();
             } else {
             } else {
                 $data['create_time'] = date("Y-m-d H:i:s");
                 $data['create_time'] = date("Y-m-d H:i:s");
-                $info = (new \app\model\LinkStoreModel)->insert($data);
+                $info = (new \app\model\LinkStoreModel)->create($data);
                 return $this->success('添加成功', $info);
                 return $this->success('添加成功', $info);
             }
             }
         }
         }
@@ -182,7 +214,7 @@ class LinkStore extends BaseController
                 $url = parse_url($url);
                 $url = parse_url($url);
                 $url = $url['host'];
                 $url = $url['host'];
             }
             }
-            $data = LinkStoreModel::whereRaw("FIND_IN_SET(?,domain)",[$url])->find();
+            $data = LinkStoreModel::whereRaw("FIND_IN_SET(?,domain)", [$url])->find();
             if ($data) {
             if ($data) {
                 return $this->success('ok', $data);
                 return $this->success('ok', $data);
             }
             }
@@ -214,7 +246,7 @@ class LinkStore extends BaseController
                 $model->update($form);
                 $model->update($form);
             } else {
             } else {
                 $model = new LinkFolderModel();
                 $model = new LinkFolderModel();
-                $model->insert($form);
+                $model->create($form);
             }
             }
         } else if ($type === 'del') {
         } else if ($type === 'del') {
             $id = $this->request->post('id');
             $id = $this->request->post('id');
@@ -225,12 +257,20 @@ class LinkStore extends BaseController
                     "UPDATE linkstore
                     "UPDATE linkstore
                      SET area = TRIM(BOTH ',' FROM REPLACE(CONCAT(',', area, ','), ',$id,', ','))
                      SET area = TRIM(BOTH ',' FROM REPLACE(CONCAT(',', area, ','), ',$id,', ','))
                      WHERE FIND_IN_SET(?, area) > 0;"
                      WHERE FIND_IN_SET(?, area) > 0;"
-                ,[$id]);
+                    , [$id]);
             }
             }
         }
         }
         return $this->success('处理完毕!');
         return $this->success('处理完毕!');
     }
     }
-
+    function moveGroup(): \think\response\Json
+    {
+        is_demo_mode(true);
+        $this->getAdmin();
+        $ids = $this->request->post('link', []);
+        $group_ids = $this->request->post('group_ids', '');
+        LinkStoreModel::where('id', 'in', $ids)->update(['group_ids' => $group_ids]);
+        return $this->success('处理完毕!');
+    }
     function moveFolder(): \think\response\Json
     function moveFolder(): \think\response\Json
     {
     {
         is_demo_mode(true);
         is_demo_mode(true);
@@ -241,7 +281,7 @@ class LinkStore extends BaseController
         return $this->success('处理完毕!');
         return $this->success('处理完毕!');
     }
     }
 
 
-    function sortFolder()
+    function sortFolder(): \think\response\Json
     {
     {
         $sort = (array)$this->request->post();
         $sort = (array)$this->request->post();
         foreach ($sort as $key => $value) {
         foreach ($sort as $key => $value) {

+ 1 - 1
app/controller/Note.php

@@ -101,7 +101,7 @@ class Note extends BaseController
             'weight' => $this->request->post('weight', 0),
             'weight' => $this->request->post('weight', 0),
             "update_time" => date("Y-m-d H:i:s"),
             "update_time" => date("Y-m-d H:i:s"),
         );
         );
-        $status = (new \app\model\NoteModel)->where("id", $id)->where('user_id', $user['user_id'])->update($data);
+        $status = (new \app\model\NoteModel)->where("id", $id)->where('user_id', $user['user_id'])->find()->save($data);
         if ($status) {
         if ($status) {
             $data['id'] = $id;
             $data['id'] = $id;
             return $this->success("修改", $data);
             return $this->success("修改", $data);

+ 46 - 1
app/controller/User.php

@@ -5,10 +5,13 @@ namespace app\controller;
 
 
 use app\BaseController;
 use app\BaseController;
 use app\model\ConfigModel;
 use app\model\ConfigModel;
+use app\model\LinkFolderModel;
 use app\model\SettingModel;
 use app\model\SettingModel;
 use app\model\TokenModel;
 use app\model\TokenModel;
+use app\model\UserGroupModel;
 use app\model\UserModel;
 use app\model\UserModel;
 use think\facade\Cache;
 use think\facade\Cache;
+use think\facade\Db;
 use think\facade\Log;
 use think\facade\Log;
 use think\facade\View;
 use think\facade\View;
 
 
@@ -182,7 +185,7 @@ class User extends BaseController
                 $info['qqBind'] = true;
                 $info['qqBind'] = true;
                 unset($info['qq_open_id']);
                 unset($info['qq_open_id']);
             }
             }
-            if($info['active']!==date("Y-m-d")){
+            if ($info['active'] !== date("Y-m-d")) {
                 $info['active'] = date("Y-m-d");
                 $info['active'] = date("Y-m-d");
                 $info->save();
                 $info->save();
             }
             }
@@ -342,4 +345,46 @@ class User extends BaseController
             }
             }
         }
         }
     }
     }
+
+    function UserGroup(): \think\response\Json
+    {
+        is_demo_mode(true);
+        $this->getAdmin();
+        return $this->success("ok", UserGroupModel::order("sort", 'desc')->select()->toArray());
+    }
+
+    function createGroup(): \think\response\Json
+    {
+        is_demo_mode(true);
+        $type = $this->request->post('type', false);
+        $this->getAdmin();
+        if ($type === 'edit') {
+            $form = $this->request->post('info');
+            $id = $this->request->post('info.id', false);
+            if ($id && $id > 0) {
+                $model = UserGroupModel::find($id);
+                $model->update($form);
+            } else {
+                $model = new UserGroupModel();
+                $model->insert($form);
+            }
+        } else if ($type === 'del') {
+            $id = $this->request->post('id');
+            $result = UserGroupModel::where('id', $id)->find();
+            if ($result) {
+                $result->delete();
+                UserModel::where('group_id', $id)->update(['group_id' => 0]);
+            }
+        }
+        return $this->success('处理完毕!');
+    }
+
+    function sortGroup(): \think\response\Json
+    {
+        $sort = (array)$this->request->post();
+        foreach ($sort as $key => $value) {
+            UserGroupModel::where('id', $value['id'])->update(['sort' => $value['sort']]);
+        }
+        return $this->success('ok');
+    }
 }
 }

+ 25 - 9
app/controller/Wallpaper.php

@@ -9,7 +9,7 @@ use app\model\WallpaperModel;
 class Wallpaper extends BaseController
 class Wallpaper extends BaseController
 {
 {
 
 
-    function editFolder()
+    function editFolder(): \think\response\Json
     {
     {
         $this->getAdmin();
         $this->getAdmin();
         is_demo_mode(true);
         is_demo_mode(true);
@@ -25,7 +25,8 @@ class Wallpaper extends BaseController
         $list = WallpaperModel::where("type", 1)->field("id,name,type,sort,create_time")->order("sort")->select();
         $list = WallpaperModel::where("type", 1)->field("id,name,type,sort,create_time")->order("sort")->select();
         return $this->success("处理完毕", $list);
         return $this->success("处理完毕", $list);
     }
     }
-    function DelFolder()
+
+    function DelFolder(): \think\response\Json
     {
     {
         $this->getAdmin();
         $this->getAdmin();
         $id = $this->request->post("id");
         $id = $this->request->post("id");
@@ -58,17 +59,20 @@ class Wallpaper extends BaseController
         $list = WallpaperModel::where("type", 1)->field("id,name,type,sort,create_time")->order("sort")->select();
         $list = WallpaperModel::where("type", 1)->field("id,name,type,sort,create_time")->order("sort")->select();
         return $this->success("ok", $list);
         return $this->success("ok", $list);
     }
     }
-    function getFolder()
+
+    function getFolder(): \think\response\Json
     {
     {
         $this->getAdmin();
         $this->getAdmin();
         $list = WallpaperModel::where("type", 1)->field("id,name,type,sort,create_time")->order("sort")->select();
         $list = WallpaperModel::where("type", 1)->field("id,name,type,sort,create_time")->order("sort")->select();
         return $this->success("ok", $list);
         return $this->success("ok", $list);
     }
     }
-    function getFolderClient()
+
+    function getFolderClient(): \think\response\Json
     {
     {
         $list = WallpaperModel::where("type", 1)->field("id,name,type,sort,create_time")->order("sort")->select();
         $list = WallpaperModel::where("type", 1)->field("id,name,type,sort,create_time")->order("sort")->select();
         return $this->success("ok", $list);
         return $this->success("ok", $list);
     }
     }
+
     function getFolderWallpaper()
     function getFolderWallpaper()
     {
     {
         $this->getAdmin();
         $this->getAdmin();
@@ -78,6 +82,7 @@ class Wallpaper extends BaseController
             return $this->success("ok", $list);
             return $this->success("ok", $list);
         }
         }
     }
     }
+
     function getFolderWallpaperClient()
     function getFolderWallpaperClient()
     {
     {
         $folder_id = $this->request->post("id");
         $folder_id = $this->request->post("id");
@@ -87,6 +92,7 @@ class Wallpaper extends BaseController
             return $this->success("ok", $list);
             return $this->success("ok", $list);
         }
         }
     }
     }
+
     function deleteWallpaper()
     function deleteWallpaper()
     {
     {
         $this->getAdmin();
         $this->getAdmin();
@@ -114,7 +120,8 @@ class Wallpaper extends BaseController
             return $this->success("ok");
             return $this->success("ok");
         }
         }
     }
     }
-    function addWallpaper()
+
+    function addWallpaper(): \think\response\Json
     {
     {
         $this->getAdmin();
         $this->getAdmin();
         $data = [];
         $data = [];
@@ -124,17 +131,26 @@ class Wallpaper extends BaseController
         $data['mime'] = $this->request->post("mime");
         $data['mime'] = $this->request->post("mime");
         $data['folder'] = $this->request->post("folder");
         $data['folder'] = $this->request->post("folder");
         $id = $this->request->post("id");
         $id = $this->request->post("id");
-        if($id){
+        if ($id) {
             $res = WallpaperModel::where("id", $id)->find();
             $res = WallpaperModel::where("id", $id)->find();
-            if($res){
+            if ($res) {
                 $res->save($data);
                 $res->save($data);
             }
             }
-        }else{
+        } else {
             $res = WallpaperModel::create($data);
             $res = WallpaperModel::create($data);
         }
         }
         return $this->success("ok", $res);
         return $this->success("ok", $res);
     }
     }
-    function sortFolder()
+
+    function randomWallpaper(): \think\response\Json
+    {
+        $list = WallpaperModel::where("type",0)->field('id, mime, url')
+            ->orderRaw('RAND()')
+            ->find();
+        return $this->success("ok", $list);
+    }
+
+    function sortFolder(): \think\response\Json
     {
     {
         $this->getAdmin();
         $this->getAdmin();
         $sort = (array)$this->request->post();
         $sort = (array)$this->request->post();

+ 37 - 0
app/controller/apps/food/Index.php

@@ -0,0 +1,37 @@
+<?php
+namespace app\controller\apps\food;
+
+use app\model\CardModel;
+use app\PluginsBase;
+
+class Index extends PluginsBase
+{
+
+    function foodList(): \think\response\Json
+    {
+        $foodListArr = [
+            '麻婆豆腐', '水饺', '粤菜点心', '北京烤鸭', '锅包肉', '水煮鱼', '担担面', '龙虾', '火锅', '蒸鱼',
+            '宫保鸡丁', '粤菜烧腊', '干煸四季豆', '芝麻鸡', '粉蒸肉', '烤羊肉串', '红烧肉', '酸辣汤', '馄饨', '扬州炒饭',
+            '豆腐脑', '铁板牛肉', '红烧鱼头', '清蒸虾', '鱼香肉丝', '葱油饼', '鱼香茄子', '糖醋排骨', '酸辣粉', '干锅系列',
+            '梅菜扣肉', '麻辣香锅', '黄焖鸡', '海鲜烩饭', '鲍鱼粥', '东坡肉', '叉烧饭', '糖醋鱼', '蚝烙', '蚵仔煎',
+            '拉面', '炒年糕', '糖醋鲤鱼', '花甲粉丝', '云吞面', '卤肉饭', '榴莲酥', '珍珠奶茶', '凤爪', '蚵仔面线',
+            '蚵仔煎', '蚵仔炒麵', '面线', '猪脚麵线', '肉羹', '炒米粉', '鹹豆漿', '肉圆', '碗粿', '米苔目',
+            '蛤仔麵', '肥肠粉', '蚵仔麵線', '虾饺', '水煎包', '蚵仔炸', '粥', '炒鸡絲飯', '蛋饺', '肉燥飯',
+            '蚵仔煎', '炒烏龍麵', '担仔麵', '蝦捲', '擔仔麵', '擔擔麵', '焦糖布丁', '珍珠球', '烏龍麵', '卤肉', '酸辣粉'
+        ];
+
+        $list = CardModel::config("food", "foodList");
+        if (!$list) {
+            $list = $foodListArr;
+        }
+        return $this->success("ok", $list);
+    }
+
+    function foodListSave(): \think\response\Json
+    {
+        $admin = $this->getAdmin();
+        $list = $this->request->post("foods", []);
+        CardModel::saveConfig("food", "foodList", $list);
+        return $this->success('保存成功');
+    }
+}

+ 53 - 0
app/controller/apps/poetry/Index.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace app\controller\apps\poetry;
+
+use app\model\CardModel;
+use app\PluginsBase;
+
+class Index extends PluginsBase
+{
+
+    function poetryList(): \think\response\Json
+    {
+        $admin = $this->getAdmin();
+        $foodListArr = include "content.php";
+        $list = CardModel::config("poetry", "poetryList");
+        if (!$list) {
+            $list = $foodListArr;
+        }
+        return $this->success("ok", $list);
+    }
+
+    function reset(): \think\response\Json
+    {
+        $admin = $this->getAdmin();
+        CardModel::saveConfig('poetry', 'poetryList', []);
+        return $this->success('ok');
+    }
+
+    function poetryOne(): \think\response\Json
+    {
+        $foodListArr = include 'content.php';
+        $list = CardModel::config('poetry', 'poetryList');
+        if (!$list) {
+            $list = $foodListArr;
+        }
+        //随机取一个数组中的内容
+        $one = $list[array_rand($list)];
+        return $this->success('ok', $one);
+    }
+
+    function poetryListSave(): \think\response\Json
+    {
+        $admin = $this->getAdmin();
+        $list = $this->request->post("list", []);
+        //php取300条,如果少于300条全部取上
+        $list = array_slice($list, 0, 300);
+        CardModel::saveConfig("poetry", "poetryList", $list);
+        if (count($list) > 300) {
+            return $this->success('最多只能保存300条,超出部分将被忽略');
+        }
+        return $this->success('保存成功');
+    }
+}

+ 151 - 0
app/controller/apps/poetry/content.php

@@ -0,0 +1,151 @@
+<?php
+return [
+    [
+        'text'=> '明月几时有?把酒问青天。',
+        'author'=> '苏轼《水调歌头》'
+    ],
+    [
+        'text'=> '床前明月光,疑是地上霜。',
+        'author'=> '李白《静夜思》'
+    ],
+    [
+        'text'=> '采菊东篱下,悠然见南山。',
+        'author'=> '陶渊明《饮酒·其五》'
+    ],
+    [
+        'text'=> '海内存知己,天涯若比邻。',
+        'author'=> '王勃《送杜少府之任蜀州》'
+    ],
+    [
+        'text'=> '大漠孤烟直,长河落日圆。',
+        'author'=> '王维《使至塞上》'
+    ],
+    [
+        'text'=> '人生得意须尽欢,莫使金樽空对月。',
+        'author'=> '李白《将进酒》'
+    ],
+    [
+        'text'=> '会当凌绝顶,一览众山小。',
+        'author'=> '杜甫《望岳》'
+    ],
+    [
+        'text'=> '白日依山尽,黄河入海流。',
+        'author'=> '王之涣《登鹳雀楼》'
+    ],
+    [
+        'text'=> '独在异乡为异客,每逢佳节倍思亲。',
+        'author'=> '王维《九月九日忆山东兄弟》'
+    ],
+    [
+        'text'=> '举杯邀明月,对影成三人。',
+        'author'=> '李白《月下独酌四首·其一》'
+    ],
+    [
+        'text'=> '小楼一夜听春雨,深巷明朝卖杏花。',
+        'author'=> '陆游《临安春雨初霁》'
+    ],
+    [
+        'text'=> '身无彩凤双飞翼,心有灵犀一点通。',
+        'author'=> '李商隐《无题》'
+    ],
+    [
+        'text'=> '云想衣裳花想容,春风拂槛露华浓。',
+        'author'=> '李白《清平调词三首》'
+    ],
+    [
+        'text'=> '行到水穷处,坐看云起时。',
+        'author'=> '王维《终南别业》'
+    ],
+    [
+        'text'=> '两情若是久长时,又岂在朝朝暮暮。',
+        'author'=> '秦观《鹊桥仙》'
+    ],
+    [
+        'text'=> '葡萄美酒夜光杯,欲饮琵琶马上催。',
+        'author'=> '王翰《凉州词二首·其一》'
+    ],
+    [
+        'text'=> '山重水复疑无路,柳暗花明又一村。',
+        'author'=> '陆游《游山西村》'
+    ],
+    [
+        'text'=> '江流天地外,山色有无中。',
+        'author'=> '王维《汉江临眺》'
+    ],
+    [
+        'text'=> '曾经沧海难为水,除却巫山不是云。',
+        'author'=> '元稹《离思五首·其四》'
+    ],
+    [
+        'text'=> '纸上得来终觉浅,绝知此事要躬行。',
+        'author'=> '陆游《冬夜读书示子聿》'
+    ],
+    [
+        'text'=> '独立小桥风满袖,平林新月人归后。',
+        'author'=> '冯延巳《鹊踏枝》(部分虚构)'
+    ],
+    [
+        'text'=> '一曲高歌一樽酒,一人独钓一江秋。',
+        'author'=> '王士祯《题秋江独钓图》'
+    ],
+    [
+        'text'=> '烟笼寒水月笼沙,夜泊秦淮近酒家。',
+        'author'=> '杜牧《泊秦淮》'
+    ],
+    [
+        'text'=> '碧云天,黄叶地,秋色连波,波上寒烟翠。',
+        'author'=> '范仲淹《苏幕遮》'
+    ],
+    [
+        'text'=> '山外青山楼外楼,西湖歌舞几时休。',
+        'author'=> '林升《题临安邸》'
+    ],
+    [
+        'text'=> '落叶满空山,何处寻行迹。',
+        'author'=> '韦应物《寄全椒山中道士》'
+    ],
+    [
+        'text'=> '二十四桥明月夜,玉人何处教吹箫。',
+        'author'=> '杜牧《寄扬州韩绰判官》'
+    ],
+    [
+        'text'=> '人面不知何处去,桃花依旧笑春风。',
+        'author'=> '崔护《题都城南庄》'
+    ],
+    [
+        'text'=> '春水碧于天,画船听雨眠。',
+        'author'=> '韦庄《菩萨蛮》'
+    ],
+    [
+        'text'=> '云中谁寄锦书来,雁字回时,月满西楼。',
+        'author'=> '李清照《一剪梅》'
+    ],
+    [
+        'text'=> '草色烟光残照里,无言谁会凭阑意。',
+        'author'=> '柳永《蝶恋花》'
+    ],
+    [
+        'text'=> '小荷才露尖尖角,早有蜻蜓立上头。',
+        'author'=> '杨万里《小池》'
+    ],
+    [
+        'text'=> '今宵酒醒何处?杨柳岸,晓风残月。',
+        'author'=> '柳永《雨霖铃》'
+    ],
+    [
+        'text'=> '无可奈何花落去,似曾相识燕归来。',
+        'author'=> '晏殊《浣溪沙》'
+    ],
+    [
+        'text'=> '不识庐山真面目,只缘身在此山中。',
+        'author'=> '苏轼《题西林壁》'
+    ],
+    [
+        'text'=> '明月松间照,清泉石上流。',
+        'author'=> '王维《山居秋暝》'
+    ],
+    [
+        'text'=> '江南可采莲,莲叶何田田。',
+        'author'=> '汉乐府《江南》'
+    ]
+];

+ 92 - 0
app/controller/apps/todo/Index.php

@@ -0,0 +1,92 @@
+<?php
+
+namespace app\controller\apps\todo;
+use app\PluginsBase;
+use app\model\PluginsToDoFolderModel;
+use app\model\PluginsToDoModel;
+
+class Index extends PluginsBase
+{
+
+    function getFolderAndToDo(): \think\response\Json
+    {
+        $user = $this->getUser(true);
+        $list = PluginsToDoFolderModel::where('user_id', $user['user_id'])->order("create_time")->select()->toArray();
+        $toDoList = PluginsToDoModel::where('user_id', $user['user_id'])->order('create_time', 'desc')->select()->toArray();
+        return $this->success("ok", ['folder' => $list, 'todo' => $toDoList]);
+    }
+
+    function createFolder(): \think\response\Json
+    {
+        $user = $this->getUser(true);
+        $name = $this->request->post("name");
+        $id = $this->request->post("id");
+        if ($name && $id) {
+            //修改模式
+            $folder = PluginsToDoFolderModel::where('user_id', $user['user_id'])->find($id);
+            if ($folder) {
+                $folder->name = $name;
+                $folder->save();
+                return $this->success("修改成功", $folder);
+            }
+            //返回失败
+            return $this->error("修改失败");
+        }
+        if (PluginsToDoFolderModel::where('user_id', $user['user_id'])->count('id') > 20) {
+            return $this->error("最多可以创建20个列表");
+        }
+        $insertId = PluginsToDoFolderModel::insertGetId(["name" => '待办事项', 'create_time' => date('Y-m-d H:i:s'), 'user_id' => $user['user_id']]);
+        return $this->success("ok", PluginsToDoFolderModel::where('user_id', $user['user_id'])->find($insertId));
+    }
+
+    function createToDo(): \think\response\Json
+    {
+        $user = $this->getUser(true);
+        $todo = $this->request->post("todo");
+        $id = $this->request->post("id");
+        $folder = $this->request->post("folder");
+        $form = $this->request->post();
+        if ($id) {
+            if (empty($form['expire_time'])) {
+                unset($form['expire_time']);
+            }
+            if (isset($form['todo']) && mb_strlen($form['todo']) > 500) {
+                return $this->error("待办内容不能超过500字,请分割待办事项");
+            }
+            PluginsToDoModel::where("id", $id)->where("user_id", $user['user_id'])->update($form);
+            return $this->success("ok");
+        }
+        if (PluginsToDoModel::where('user_id', $user['user_id'])->field('id,user_id')->count("id") > 300) {
+            return $this->error("最多可以创建300条待办");
+        }
+        $td = PluginsToDoModel::insertGetId(["todo" => $todo, "user_id" => $user['user_id'], 'status' => 0, 'weight' => 0, 'create_time' => date('Y-m-d H:i:s'), 'folder' => $folder]);
+        return $this->success("ok", PluginsToDoModel::where("user_id", $user['user_id'])->find($td));
+    }
+
+    function delFolder(): \think\response\Json
+    {
+        $user = $this->getUser();
+        $id = $this->request->post('id');
+        if ($id) {
+            $folder = PluginsToDoFolderModel::where('user_id', $user['user_id'])->where('id', $id)->find();
+            if ($folder) {
+                PluginsToDoModel::where("user_id", $user['user_id'])->where("folder", $id)->delete();
+                $folder->delete();
+                return $this->success('删除完毕');
+            }
+        }
+        return $this->success('删除失败');
+
+    }
+
+    function delToDo(): \think\response\Json
+    {
+        $user = $this->getUser();
+        $id = $this->request->post("id");
+        if ($id) {
+            $toDo = PluginsToDoModel::where('user_id', $user['user_id'])->find($id);
+            $toDo->delete();
+        }
+        return $this->success('删除完毕');
+    }
+}

+ 282 - 0
app/controller/apps/topSearch/Index.php

@@ -0,0 +1,282 @@
+<?php
+
+namespace app\controller\apps\topSearch;
+
+use app\model\CardModel;
+use app\PluginsBase;
+use ErrorException;
+use GuzzleHttp\Exception\GuzzleException;
+use think\facade\Cache;
+
+class Index extends PluginsBase
+{
+    protected $ttl = 180;
+
+    function __construct()
+    {
+        parent::__construct(app());
+        $res = CardModel::config('topSearch', 'conf');
+        if ($res) {
+            if (isset($res['ttl'])) {
+                $this->ttl = (int)$res['ttl'];
+            }
+        }
+    }
+
+    function save(): \think\response\Json
+    {
+        $this->getAdmin();
+        $list = $this->request->post("conf");
+        CardModel::saveConfigs("topSearch", ['conf'=>$list]);
+        $this->clearRedisCache();
+        return $this->success('保存成功');
+    }
+
+    function getConf(): \think\response\Json
+    {
+        $this->getAdmin();
+        $res = CardModel::config("topSearch", "conf", false);
+        if (!$res) {
+            $res = [];
+        }
+        return $this->success('ok', $res);
+    }
+
+    function TopSearch(): \think\response\Json
+    {
+        $type = $this->request->get('type', 'baidu');
+        switch ($type) {
+            case 'baidu':
+                return $this->baiduTopSearch();
+            case 'bilibili':
+                return $this->bilibili();
+            case 'weibo':
+                return $this->weibo();
+            case 'zhiHu':
+                return $this->zhiHu();
+            case 'douyin':
+                return $this->douyin();
+            case 'toutiao':
+                return $this->toutiao();
+        }
+        return $this->error('not type');
+    }
+
+    function zhiHu(): \think\response\Json
+    {
+        try {
+            $c = Cache::get('zhiHuTopSearch');
+            if ($c) {
+                return $this->success('cache', $c);
+            }
+        } catch (ErrorException $e) {
+
+        }
+
+        $api = 'https://www.zhihu.com/api/v4/creators/rank/hot?domain=0&period=hour&limit=50&offset=0';
+        $result = \Axios::http()->request('get', $api);
+        $result = $result->getBody()->getContents();
+        $result = json_decode($result, true);
+        $arr = [];
+        if (count($result['data']) > 0) {
+            foreach ($result['data'] as $value) {
+                $arr [] = array(
+                    'title' => $value['question']['title'],
+                    'hot' => $value['reaction']['pv'],
+                    'url' => $value['question']['url']
+                );
+            }
+            Cache::set('zhiHuTopSearch', $arr, $this->ttl);
+        }
+        return $this->success($arr);
+    }
+
+    //百度热搜
+    public function baiduTopSearch(): \think\response\Json
+    {
+        try {
+            $c = Cache::get('baiduTopSearch');
+            if ($c) {
+                return $this->success('cache', $c);
+            }
+        } catch (ErrorException $e) {
+
+        }
+
+        $result = \Axios::http()->request('get', 'https://top.baidu.com/api/board?tab=realtime');
+        $result = $result->getBody()->getContents();
+        $result = json_decode($result, true);
+        if ($result['success']) {
+            $result = $result['data']['cards'][0];
+        }
+        $arr = [];
+        $tn = CardModel::config('topSearch', 'conf', false);
+        if ($tn && isset($tn['baiduCode'])) {
+            $tn = $tn['baiduCode'];
+        } else {
+            $tn = false;
+        }
+        $list = $result['content'];
+        if (isset($result['topContent'])) {
+            $top = $result['topContent'];
+            if (count($top) > 0) {
+                array_unshift($list, $top[0]);
+            }
+
+            foreach ($list as $k => $v) {
+                $url = urlencode($v['word']);
+                if ($tn) {
+                    $url .= '&tn=' . $tn;
+                }
+                $arr [] = array(
+                    'title' => $v['word'],
+                    'hot' => $v['hotScore'],
+                    'url' => "https://www.baidu.com/s?wd={$url}"
+                );
+                Cache::set('baiduTopSearch', $arr, $this->ttl);
+            }
+        }
+
+        return $this->success('new', $arr);
+    }
+
+    //哔哩哔哩热搜
+    public function bilibili(): \think\response\Json
+    {
+        $arr = [];
+        try {
+            $c = Cache::get('bilibiliTopSearch');
+            if ($c) {
+                return $this->success('cache', $c);
+            }
+            $result = \Axios::http()->request('get', 'https://api.bilibili.com/x/web-interface/ranking/v2?rid=0&type=all', [
+                'headers' => [
+                    'path' => '/x/web-interface/ranking/v2?',
+                    'authority' => 'api.bilibili.com',
+                    'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36'
+                ]
+            ]);
+            $result = $result->getBody()->getContents();
+            $result = json_decode($result, true);
+            if ($result['code'] == 0) {
+                $list = $result['data']['list'];
+                if (count($list) > 0) {
+                    foreach ($list as $k => $v) {
+                        if ($k == 90) {
+                            break;
+                        }
+                        $arr [] = array(
+                            'title' => $v['title'],
+                            'hot' => $v['stat']['view'],
+                            'url' => 'https://www.bilibili.com/video/' . $v['bvid']//$v['short_link'] ?? $v['short_link_v2']
+                        );
+                    }
+                    Cache::set('bilibiliTopSearch', $arr, $this->ttl);
+                }
+            }
+
+        } catch (GuzzleException $e) {
+        }
+        return $this->success($arr);
+    }
+
+    //哔哩哔哩热搜
+    public function weibo(): \think\response\Json
+    {
+        try {
+            $c = Cache::get('weiboTopSearch');
+            if ($c) {
+                return $this->success('cache', $c);
+            }
+        } catch (ErrorException $e) {
+
+        }
+        $result = \Axios::http()->request('get', 'https://weibo.com/ajax/statuses/hot_band');
+        $result = $result->getBody()->getContents();
+        $result = json_decode($result, true);
+        $arr = [];
+        if ($result['ok'] == 1) {
+            $list = $result['data']['band_list'];
+            if (count($list) > 0) {
+                foreach ($list as $k => $v) {
+                    $arr [] = array(
+                        'title' => $v['word'],
+                        'hot' => $v['raw_hot'] ?? $v['num'],
+                        'url' => 'https://s.weibo.com/weiboo?q=' . $v['word']
+                    );
+                }
+                Cache::set('weiboTopSearch', $arr, $this->ttl);
+            }
+        }
+        return $this->success($arr);
+    }
+
+    //哔哩哔哩热搜
+    public function toutiao(): \think\response\Json
+    {
+        try {
+            $c = Cache::get('toutiaoTopSearch');
+            if ($c) {
+                return $this->success('cache', $c);
+            }
+        } catch (ErrorException $e) {
+
+        }
+        $result = \Axios::http()->request('get', 'https://www.toutiao.com/hot-event/hot-board/?origin=toutiao_pc');
+        $result = $result->getBody()->getContents();
+        $result = json_decode($result, true);
+        $arr = [];
+        if ($result['status'] == 'success') {
+            $list = $result['data'];
+            if (count($list) > 0) {
+                foreach ($list as $k => $v) {
+                    $arr [] = array(
+                        'title' => $v['Title'],
+                        'hot' => $v['HotValue'],
+                        'url' => $v['Url']
+                    );
+                }
+                Cache::set('toutiaoTopSearch', $arr, $this->ttl);
+            }
+        }
+        return $this->success($arr);
+    }
+
+    function douyin()
+    {
+        try {
+            $c = Cache::get('douyinTopSearch');
+            if ($c) {
+                return $this->success('cache', $c);
+            }
+        } catch (ErrorException $e) {
+
+        }
+        $result = \Axios::http()->request('get', 'https://www.iesdouyin.com/web/api/v2/hotsearch/billboard/word/?reflow_source=reflow_page');
+        $result = $result->getBody()->getContents();
+        $result = json_decode($result, true);
+        $arr = [];
+        $list = $result['word_list'];
+        if (count($list) > 0) {
+            foreach ($list as $k => $v) {
+                $arr [] = array(
+                    'title' => $v['word'],
+                    'hot' => $v['hot_value'] ?? $v['num'],
+                    'url' => 'https://www.douyin.com/search/' . $v['word']
+                );
+            }
+            Cache::set('douyinTopSearch', $arr, $this->ttl);
+        }
+        return $this->success($arr);
+    }
+
+    public function clearRedisCache(): \think\response\Json
+    {
+        Cache::delete('bilibiliTopSearch');
+        Cache::delete('baiduTopSearch');
+        Cache::delete('weiboTopSearch');
+        Cache::delete('zhiHuTopSearch');
+        Cache::delete('douyinTopSearch');
+        return $this->success('刷新完毕');
+    }
+}

+ 165 - 0
app/controller/apps/weather/Index.php

@@ -0,0 +1,165 @@
+<?php
+
+namespace app\controller\apps\weather;
+
+use app\model\CardModel;
+use app\PluginsBase;
+use IP2Location\Database;
+
+$directory = (__DIR__ . '/vendor/IP2Location/src');
+
+$files = glob($directory . '/*.php');
+
+foreach ($files as $file) {
+    require_once $file;
+}
+
+class Index extends PluginsBase
+{
+    public $gateway = '';
+
+    function _initialize()
+    {
+        parent::_initialize();
+        $this->gateway = CardModel::config("weather", "gateway", "https://devapi.qweather.com");
+    }
+
+    function ip(): \think\response\Json
+    {
+        $file = __DIR__ . '/ipLocation/IP2LOCATION-LITE-DB5.BIN';
+        if (file_exists($file)) {
+            $ip = getRealIp();
+            $db = new Database($file, Database::FILE_IO);
+            try {
+                $records = $db->lookup($ip, Database::ALL);
+                $ipInfo = [
+                    'ipAddress' => $records['ipAddress'],
+                    'latitude' => $records['latitude'],
+                    'longitude' => $records['longitude'],
+                    'cityName' => $records['cityName'],
+                    'regionName' => $records['regionName'],
+                    'countryName' => $records['countryName']
+                ];
+                if ($ipInfo['latitude'] == 0 && $ipInfo['longitude'] == 0) {
+                    $ipInfo['latitude'] = 39.91;
+                    $ipInfo['longitude'] = 116.41;
+                }
+                return json(['code' => 1, 'msg' => 'success', 'data' => $ipInfo]);
+            } catch (\Exception $e) {
+                return json(['code' => 0, 'msg' => '不支持ipv6']);
+            }
+        }
+
+        return json(['code' => 0, 'msg' => '地理位置数据包不存在']);
+    }
+
+    function setting()
+    {
+        $this->getAdmin();
+        if ($this->request->isPost()) {
+            $form = $this->request->post();
+            CardModel::saveConfigs("weather", $form);
+            return $this->success("保存成功");
+        }
+        if ($this->request->isPut()) {
+            $form = CardModel::configs('weather');
+            return $this->success('ok', $form);
+        }
+
+        return $this->fetch("setting.html");
+    }
+
+    function everyDay(): \think\response\Json
+    {
+
+        $location = $this->request->get("location", "101010100");
+        try {
+            $result = \Axios::http()->get($this->gateway . '/v7/weather/7d', [
+                'query' => [
+                    'location' => $location,
+                    'key' => CardModel::config('weather', 'key'),
+                ]
+            ]);
+            if ($result->getStatusCode() === 200) {
+                $json = \Axios::toJson($result->getBody()->getContents());
+                if ($json && $json['code'] == "200") {
+                    return $this->success($json['daily']);
+                }
+            }
+        } catch (\Exception $e) {
+        }
+        return $this->error("数据获取错误");
+    }
+
+    function now(): \think\response\Json
+    {
+
+        $location = $this->request->get('location', '101010100');
+        try {
+            $result = \Axios::http()->get($this->gateway . '/v7/weather/now', [
+                'query' => [
+                    'location' => $location,
+                    'key' => CardModel::config('weather', 'key'),
+                ]
+            ]);
+            if ($result->getStatusCode() === 200) {
+                $json = \Axios::toJson($result->getBody()->getContents());
+                if ($json && $json['code'] == '200') {
+                    return $this->success($json['now']);
+                }
+            }
+        } catch (\Exception $e) {
+        }
+        return $this->error('数据获取错误');
+    }
+
+    function locationToCity(): \think\response\Json
+    {
+
+        $location = $this->request->all('location', '101010100');
+        try {
+            $result = \Axios::http()->get('https://geoapi.qweather.com/v2/city/lookup', [
+                'query' => [
+                    'location' => $location,
+                    'key' => CardModel::config('weather', 'key'),
+                ]
+            ]);
+            if ($result->getStatusCode() === 200) {
+                $json = \Axios::toJson($result->getBody()->getContents());
+                if ($json && $json['code'] == '200') {
+                    if (count($json['location']) > 0) {
+                        return $this->success($json['location'][0]);
+                    }
+                }
+            }
+        } catch (\Exception $e) {
+        }
+        return $this->error('数据获取错误');
+    }
+
+    function citySearch(): \think\response\Json
+    {
+        $city = $this->request->post("city", "");
+        if (trim($city)) {
+            try {
+                $result = \Axios::http()->get('https://geoapi.qweather.com/v2/city/lookup', [
+                    'query' => [
+                        'location' => $city,
+                        'key' => CardModel::config('weather', 'key'),
+                    ]
+                ]);
+                if ($result->getStatusCode() === 200) {
+                    $json = \Axios::toJson($result->getBody()->getContents());
+                    if ($json && $json['code'] == '200') {
+                        if (count($json['location']) > 0) {
+                            return $this->success($json['location']);
+                        }
+                    }
+                }
+            } catch (\Exception $e) {
+                return $this->error($e->getMessage());
+            }
+        }
+        return $this->error('数据获取错误');
+    }
+}

BIN
app/controller/apps/weather/ipLocation/IP2LOCATION-LITE-DB5.BIN


+ 21 - 0
app/controller/apps/weather/vendor/IP2Location/LICENSE.TXT

@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2023 - 2024 IP2Location.com
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 137 - 0
app/controller/apps/weather/vendor/IP2Location/src/Country.php

@@ -0,0 +1,137 @@
+<?php
+
+namespace IP2Location;
+
+/**
+ * Country class.
+ */
+class Country
+{
+	/**
+	 * Unable to locate CSV file.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_FILE_NOT_EXISTS = 10000;
+
+	/**
+	 * Invalid CSV file.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_INVALID_CSV = 10001;
+
+	/**
+	 * Unable to read the CSV file.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_UNABLE_TO_OPEN_CSV = 10002;
+
+	/**
+	 * No record found.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_NO_RECORD = 10003;
+
+	/**
+	 * Fields from CSV.
+	 *
+	 * @var array
+	 */
+	protected $fields = [];
+
+	/**
+	 * Records from CSV.
+	 *
+	 * @var array
+	 */
+	protected $records = [];
+
+	/**
+	 * Constructor.
+	 *
+	 * @param string $csv Path to CSV file
+	 *
+	 * @throws \Exception
+	 */
+	public function __construct($csv)
+	{
+		if (!file_exists($csv)) {
+			throw new \Exception(__CLASS__ . ': The CSV file "' . $csv . '" is not found.', self::EXCEPTION_FILE_NOT_EXISTS);
+		}
+
+		$file = fopen($csv, 'r');
+
+		if (!$file) {
+			throw new \Exception(__CLASS__ . ': Unable to read "' . $csv . '".', self::EXCEPTION_UNABLE_TO_OPEN_CSV);
+		}
+
+		$line = 1;
+
+		while (!feof($file)) {
+			$data = fgetcsv($file);
+
+			if (!$data) {
+				++$line;
+				continue;
+			}
+
+			// Parse the CSV fields
+			if ($line == 1) {
+				if ($data[0] != 'country_code') {
+					throw new \Exception(__CLASS__ . ': Invalid country information CSV file.', self::EXCEPTION_INVALID_CSV);
+				}
+
+				$this->fields = $data;
+			} else {
+				$this->records[$data[0]] = $data;
+			}
+
+			++$line;
+		}
+	}
+
+	/**
+	 * Get the country information.
+	 *
+	 * @param string $countryCode The country ISO 3166 country code.
+	 *
+	 * @throws \Exception
+	 *
+	 * @return array
+	 */
+	public function getCountryInfo($countryCode = '')
+	{
+		if (empty($this->records)) {
+			throw new \Exception(__CLASS__ . ': No record available.', self::EXCEPTION_NO_RECORD);
+		}
+
+		$results = [];
+
+		if ($countryCode) {
+			if (!isset($this->records[$countryCode])) {
+				return [];
+			}
+
+			for ($i = 0; $i < \count($this->fields); ++$i) {
+				$results[$this->fields[$i]] = $this->records[$countryCode][$i];
+			}
+
+			return $results;
+		}
+
+		foreach ($this->records as $record) {
+			$data = [];
+
+			for ($i = 0; $i < \count($this->fields); ++$i) {
+				$data[$this->fields[$i]] = $record[$i];
+			}
+
+			$results[] = $data;
+		}
+
+		return $results;
+	}
+}

+ 2252 - 0
app/controller/apps/weather/vendor/IP2Location/src/Database.php

@@ -0,0 +1,2252 @@
+<?php
+
+namespace IP2Location;
+
+/**
+ * IP2Location database class.
+ */
+class Database
+{
+	/**
+	 * Current module's version.
+	 *
+	 * @var string
+	 */
+	public const VERSION = '9.7.3';
+
+	/**
+	 * Unsupported field message.
+	 *
+	 * @var string
+	 */
+	public const FIELD_NOT_SUPPORTED = 'This parameter is unavailable in selected .BIN data file. Please upgrade data file.';
+
+	/**
+	 * Unknown field message.
+	 *
+	 * @var string
+	 */
+	public const FIELD_NOT_KNOWN = 'This parameter is inexistent. Please verify.';
+
+	/**
+	 * Invalid IP address message.
+	 *
+	 * @var string
+	 */
+	public const INVALID_IP_ADDRESS = 'Invalid IP address.';
+
+	/**
+	 * Maximum IPv4 number.
+	 *
+	 * @var int
+	 */
+	public const MAX_IPV4_RANGE = 4294967295;
+
+	/**
+	 * MAximum IPv6 number.
+	 *
+	 * @var int
+	 */
+	public const MAX_IPV6_RANGE = 340282366920938463463374607431768211455;
+
+	/**
+	 * Country code (ISO 3166-1 Alpha 2).
+	 *
+	 * @var int
+	 */
+	public const COUNTRY_CODE = 1;
+
+	/**
+	 * Country name.
+	 *
+	 * @var int
+	 */
+	public const COUNTRY_NAME = 2;
+
+	/**
+	 * Region name.
+	 *
+	 * @var int
+	 */
+	public const REGION_NAME = 3;
+
+	/**
+	 * City name.
+	 *
+	 * @var int
+	 */
+	public const CITY_NAME = 4;
+
+	/**
+	 * Latitude.
+	 *
+	 * @var int
+	 */
+	public const LATITUDE = 5;
+
+	/**
+	 * Longitude.
+	 *
+	 * @var int
+	 */
+	public const LONGITUDE = 6;
+
+	/**
+	 * ISP name.
+	 *
+	 * @var int
+	 */
+	public const ISP = 7;
+
+	/**
+	 * Domain name.
+	 *
+	 * @var int
+	 */
+	public const DOMAIN_NAME = 8;
+
+	/**
+	 * Zip code.
+	 *
+	 * @var int
+	 */
+	public const ZIP_CODE = 9;
+
+	/**
+	 * Time zone.
+	 *
+	 * @var int
+	 */
+	public const TIME_ZONE = 10;
+
+	/**
+	 * Net speed.
+	 *
+	 * @var int
+	 */
+	public const NET_SPEED = 11;
+
+	/**
+	 * IDD code.
+	 *
+	 * @var int
+	 */
+	public const IDD_CODE = 12;
+
+	/**
+	 * Area code.
+	 *
+	 * @var int
+	 */
+	public const AREA_CODE = 13;
+
+	/**
+	 * Weather station code.
+	 *
+	 * @var int
+	 */
+	public const WEATHER_STATION_CODE = 14;
+
+	/**
+	 * Weather station name.
+	 *
+	 * @var int
+	 */
+	public const WEATHER_STATION_NAME = 15;
+
+	/**
+	 * Mobile Country Code.
+	 *
+	 * @var int
+	 */
+	public const MCC = 16;
+
+	/**
+	 * Mobile Network Code.
+	 *
+	 * @var int
+	 */
+	public const MNC = 17;
+
+	/**
+	 * Mobile carrier name.
+	 *
+	 * @var int
+	 */
+	public const MOBILE_CARRIER_NAME = 18;
+
+	/**
+	 * Elevation.
+	 *
+	 * @var int
+	 */
+	public const ELEVATION = 19;
+
+	/**
+	 * Usage type.
+	 *
+	 * @var int
+	 */
+	public const USAGE_TYPE = 20;
+
+	/**
+	 * Address type.
+	 *
+	 * @var int
+	 */
+	public const ADDRESS_TYPE = 21;
+
+	/**
+	 * Category.
+	 *
+	 * @var int
+	 */
+	public const CATEGORY = 22;
+
+	/**
+	 * District.
+	 *
+	 * @var int
+	 */
+	public const DISTRICT = 23;
+
+	/**
+	 * ASN.
+	 *
+	 * @var int
+	 */
+	public const ASN = 24;
+
+	/**
+	 * AS.
+	 *
+	 * @var int
+	 */
+	public const AS = 25;
+
+	/**
+	 * Country name and code.
+	 *
+	 * @var int
+	 */
+	public const COUNTRY = 101;
+
+	/**
+	 * Latitude and Longitude.
+	 *
+	 * @var int
+	 */
+	public const COORDINATES = 102;
+
+	/**
+	 * IDD and area codes.
+	 *
+	 * @var int
+	 */
+	public const IDD_AREA = 103;
+
+	/**
+	 * Weather station name and code.
+	 *
+	 * @var int
+	 */
+	public const WEATHER_STATION = 104;
+
+	/**
+	 * MCC, MNC, and mobile carrier name.
+	 *
+	 * @var int
+	 */
+	public const MCC_MNC_MOBILE_CARRIER_NAME = 105;
+
+	/**
+	 * All fields at once.
+	 *
+	 * @var int
+	 */
+	public const ALL = 1001;
+
+	/**
+	 * Include the IP address of the looked up IP address.
+	 *
+	 * @var int
+	 */
+	public const IP_ADDRESS = 1002;
+
+	/**
+	 * Include the IP version of the looked up IP address.
+	 *
+	 * @var int
+	 */
+	public const IP_VERSION = 1003;
+
+	/**
+	 * Include the IP number of the looked up IP address.
+	 *
+	 * @var int
+	 */
+	public const IP_NUMBER = 1004;
+
+	/**
+	 * Generic exception code.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION = 10000;
+
+	/**
+	 * No shmop extension found.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_NO_SHMOP = 10001;
+
+	/**
+	 * Failed to open shmop memory segment for reading.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_SHMOP_READING_FAILED = 10002;
+
+	/**
+	 * Failed to open shmop memory segment for writing.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_SHMOP_WRITING_FAILED = 10003;
+
+	/**
+	 * Failed to create shmop memory segment.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_SHMOP_CREATE_FAILED = 10004;
+
+	/**
+	 * The specified database file was not found.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_DATABASE_FILE_NOT_FOUND = 10005;
+
+	/**
+	 * Not enough memory to load database file.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_NO_MEMORY = 10006;
+
+	/**
+	 * No candidate database files found.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_NO_CANDIDATES = 10007;
+
+	/**
+	 * Failed to open database file.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_FILE_OPEN_FAILED = 10008;
+
+	/**
+	 * Failed to determine the current path.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_NO_PATH = 10009;
+
+	/**
+	 * Invalid BIN database file.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_INVALID_BIN_DATABASE = 10010;
+
+	/**
+	 * Failed to delete shmop memory segment.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_SHMOP_DELETE_FAILED = 10011;
+
+	/**
+	 * Directly read from the database file.
+	 *
+	 * @var int
+	 */
+	public const FILE_IO = 100001;
+
+	/**
+	 * Read the whole database into a variable for caching.
+	 *
+	 * @var int
+	 */
+	public const MEMORY_CACHE = 100002;
+
+	/**
+	 * Use shared memory objects for caching.
+	 *
+	 * @var int
+	 */
+	public const SHARED_MEMORY = 100003;
+
+	/**
+	 * Share memory segment's permissions (for creation).
+	 *
+	 * @var int
+	 */
+	public const SHM_PERMS = 0600;
+
+	/**
+	 * Number of bytes to read/write at a time in order to load the shared memory cache (512k).
+	 *
+	 * @var int
+	 */
+	public const SHM_CHUNK_SIZE = 524288;
+
+	/**
+	 * Column offset mapping.
+	 *
+	 * Each entry contains an array mapping database version (0--23) to offset within a record.
+	 * A value of 0 means the column is not present in the given database version.
+	 *
+	 * @var array
+	 */
+	private $columns = [
+		self::COUNTRY_CODE         => [8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,   8],
+		self::COUNTRY_NAME         => [8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,   8],
+		self::REGION_NAME          => [0,  0, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,  12],
+		self::CITY_NAME            => [0,  0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,  16],
+		self::LATITUDE             => [0,  0,  0,  0, 20, 20,  0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,  20],
+		self::LONGITUDE            => [0,  0,  0,  0, 24, 24,  0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,  24],
+		self::ZIP_CODE             => [0,  0,  0,  0,  0,  0,  0,  0, 28, 28, 28, 28,  0, 28, 28, 28,  0, 28,  0, 28, 28, 28,  0, 28, 28,  28],
+		self::TIME_ZONE            => [0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 32, 32, 28, 32, 32, 32, 28, 32,  0, 32, 32, 32,  0, 32, 32,  32],
+		self::ISP                  => [0, 12,  0, 20,  0, 28, 20, 28,  0, 32,  0, 36,  0, 36,  0, 36,  0, 36, 28, 36,  0, 36, 28, 36, 36,  36],
+		self::DOMAIN_NAME          => [0,  0,  0,  0,  0,  0, 24, 32,  0, 36,  0, 40,  0, 40,  0, 40,  0, 40, 32, 40,  0, 40, 32, 40, 40,  40],
+		self::NET_SPEED            => [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 32, 44,  0, 44, 32, 44,  0, 44,  0, 44,  0, 44, 44,  44],
+		self::IDD_CODE             => [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 36, 48,  0, 48,  0, 48, 36, 48,  0, 48, 48,  48],
+		self::AREA_CODE            => [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 40, 52,  0, 52,  0, 52, 40, 52,  0, 52, 52,  52],
+		self::WEATHER_STATION_CODE => [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 36, 56,  0, 56,  0, 56,  0, 56, 56,  56],
+		self::WEATHER_STATION_NAME => [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 40, 60,  0, 60,  0, 60,  0, 60, 60,  60],
+		self::MCC                  => [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 36, 64,  0, 64, 36, 64, 64,  64],
+		self::MNC                  => [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 40, 68,  0, 68, 40, 68, 68,  68],
+		self::MOBILE_CARRIER_NAME  => [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 44, 72,  0, 72, 44, 72, 72,  72],
+		self::ELEVATION            => [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 44, 76,  0, 76, 76,  76],
+		self::USAGE_TYPE           => [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 48, 80, 80,  80],
+		self::ADDRESS_TYPE         => [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 84,  84],
+		self::CATEGORY             => [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 88,  88],
+		self::DISTRICT             => [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  92],
+		self::ASN                  => [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  96],
+		self::AS                   => [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 100],
+	];
+
+	/**
+	 * Column name mapping.
+	 *
+	 * @var array
+	 */
+	private $names = [
+		self::COUNTRY_CODE         => 'countryCode',
+		self::COUNTRY_NAME         => 'countryName',
+		self::REGION_NAME          => 'regionName',
+		self::CITY_NAME            => 'cityName',
+		self::LATITUDE             => 'latitude',
+		self::LONGITUDE            => 'longitude',
+		self::ISP                  => 'isp',
+		self::DOMAIN_NAME          => 'domainName',
+		self::ZIP_CODE             => 'zipCode',
+		self::TIME_ZONE            => 'timeZone',
+		self::NET_SPEED            => 'netSpeed',
+		self::IDD_CODE             => 'iddCode',
+		self::AREA_CODE            => 'areaCode',
+		self::WEATHER_STATION_CODE => 'weatherStationCode',
+		self::WEATHER_STATION_NAME => 'weatherStationName',
+		self::MCC                  => 'mcc',
+		self::MNC                  => 'mnc',
+		self::MOBILE_CARRIER_NAME  => 'mobileCarrierName',
+		self::ELEVATION            => 'elevation',
+		self::USAGE_TYPE           => 'usageType',
+		self::ADDRESS_TYPE         => 'addressType',
+		self::CATEGORY             => 'category',
+		self::DISTRICT             => 'district',
+		self::ASN                  => 'asn',
+		self::AS                   => 'as',
+		self::IP_ADDRESS           => 'ipAddress',
+		self::IP_VERSION           => 'ipVersion',
+		self::IP_NUMBER            => 'ipNumber',
+	];
+
+	/**
+	 * Database names, in order of preference for file lookup.
+	 *
+	 * @var array
+	 */
+	private $databases = [
+		// IPv4 databases
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-ADDRESSTYPE-CATEGORY-DISTRICT-ASN',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-ADDRESSTYPE-CATEGORY',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE-USAGETYPE',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE-ELEVATION',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-NETSPEED-WEATHER',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-ISP-DOMAIN',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN',
+		'IP-COUNTRY-REGION-CITY-ISP-DOMAIN',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP',
+		'IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE',
+		'IP-COUNTRY-REGION-CITY-ISP',
+		'IP-COUNTRY-REGION-CITY',
+		'IP-COUNTRY-ISP',
+		'IP-COUNTRY',
+
+		// IPv6 databases
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-ADDRESSTYPE-CATEGORY-DISTRICT-ASN',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-ADDRESSTYPE-CATEGORY',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE-USAGETYPE',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE-ELEVATION',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN-MOBILE',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-NETSPEED-WEATHER',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-AREACODE',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-TIMEZONE-NETSPEED',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-ISP-DOMAIN',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP-DOMAIN',
+		'IPV6-COUNTRY-REGION-CITY-ISP-DOMAIN',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP',
+		'IPV6-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE',
+		'IPV6-COUNTRY-REGION-CITY-ISP',
+		'IPV6-COUNTRY-REGION-CITY',
+		'IPV6-COUNTRY-ISP',
+		'IPV6-COUNTRY',
+	];
+
+	/**
+	 * Memory buffer to use for MEMORY_CACHE mode, the keys will be BIN filenames and the values their contents.
+	 *
+	 * @var array
+	 */
+	private $buffer = [];
+
+	/**
+	 * The machine's float size.
+	 *
+	 * @var int
+	 */
+	private $floatSize = null;
+
+	/**
+	 * The configured memory limit.
+	 *
+	 * @var int
+	 */
+	private $memoryLimit = null;
+
+	/**
+	 * Caching mode to use (one of FILE_IO, MEMORY_CACHE, or SHARED_MEMORY).
+	 *
+	 * @var int
+	 */
+	private $mode;
+
+	/**
+	 * File pointer to use for FILE_IO mode, BIN filename for MEMORY_CACHE mode, or shared memory id to use for SHARED_MEMORY mode.
+	 *
+	 * @var false|int|resource
+	 */
+	private $resource = false;
+
+	/**
+	 * Database's compilation date.
+	 *
+	 * @var int
+	 */
+	private $date;
+
+	/**
+	 * Database's type (0--23).
+	 *
+	 * @var int
+	 */
+	private $type;
+
+	/**
+	 * Database's register width (as an array mapping 4 to IPv4 width, and 6 to IPv6 width).
+	 *
+	 * @var array
+	 */
+	private $columnWidth = [];
+
+	/**
+	 * Database's pointer offset (as an array mapping 4 to IPv4 offset, and 6 to IPv6 offset).
+	 *
+	 * @var array
+	 */
+	private $offset = [];
+
+	/**
+	 * Amount of IP address ranges the database contains (as an array mapping 4 to IPv4 count, and 6 to IPv6 count).
+	 *
+	 * @var array
+	 */
+	private $ipCount = [];
+
+	/**
+	 * Offset withing the database where IP data begins (as an array mapping 4 to IPv4 base, and 6 to IPv6 base).
+	 *
+	 * @var array
+	 */
+	private $ipBase = [];
+
+	/**
+	 * Base index address.
+	 *
+	 * @var array
+	 */
+	private $indexBaseAddr = [];
+
+	/**
+	 * The year of the database is released.
+	 *
+	 * @var string
+	 */
+	private $year;
+
+	/**
+	 * The month of the database is released.
+	 *
+	 * @var string
+	 */
+	private $month;
+
+	/**
+	 * The day of the database is released.
+	 *
+	 * @var string
+	 */
+	private $day;
+
+	/**
+	 * Product code.
+	 *
+	 * @var string
+	 */
+	private $productCode;
+
+	/**
+	 * License code.
+	 *
+	 * @var string
+	 */
+	private $licenseCode;
+
+	/**
+	 * Database size.
+	 *
+	 * @var int
+	 */
+	private $databaseSize;
+
+	/**
+	 * The raw row of column positions.
+	 *
+	 * @var string
+	 */
+	private $rawPositionsRow;
+
+	/**
+	 * IP2Location web service API key.
+	 *
+	 * @var string
+	 */
+	private $apiKey;
+
+	/**
+	 * Web service package.
+	 *
+	 * @var string
+	 */
+	private $package;
+
+	/**
+	 * Either use HTTPS or HTTP.
+	 *
+	 * @var bool
+	 */
+	private $useSsl;
+
+	/**
+	 * Add ons used by the web service.
+	 *
+	 * @var array
+	 */
+	private $addOns = [];
+
+	/**
+	 * Default fields to return during lookup.
+	 *
+	 * @var array|int
+	 */
+	private $defaultFields = self::ALL;
+
+	/**
+	 * Constructor.
+	 *
+	 * @param string $file          Filename of the BIN database to load
+	 * @param int    $mode          Caching mode (FILE_IO, MEMORY_CACHE, or SHARED_MEMORY)
+	 * @param mixed  $defaultFields
+	 *
+	 * @throws \Exception
+	 */
+	public function __construct($file = null, $mode = self::FILE_IO, $defaultFields = self::ALL)
+	{
+		// Locate the actual file
+		$realPath = $this->findFile($file);
+
+		// File size
+		$fileSize = filesize($realPath);
+
+		// initialize caching backend
+		switch ($mode) {
+			case self::SHARED_MEMORY:
+				// Make sure shmop extension is loaded
+				if (!\extension_loaded('shmop')) {
+					throw new \Exception(__CLASS__ . ": Please make sure your PHP setup has the 'shmop' extension enabled.", self::EXCEPTION_NO_SHMOP);
+				}
+
+				$memoryLimit = $this->getMemoryLimit();
+
+				if ($memoryLimit !== false && $fileSize > $memoryLimit) {
+					throw new \Exception(__CLASS__ . ": Insufficient memory to load file '{$realPath}'.", self::EXCEPTION_NO_MEMORY);
+				}
+
+				$this->mode = self::SHARED_MEMORY;
+				$shmKey = $this->getShmKey($realPath);
+				$fileSizeChanged = false;
+
+				// Open shared memory segment
+				$this->resource = @shmop_open($shmKey, 'a', 0, 0);
+
+				// Segment does not exist or file size changed
+				if ($this->resource === false || $fileSizeChanged = (shmop_size($this->resource) !== filesize($realPath))) {
+					// File size has changed, remove old segment
+					if ($fileSizeChanged && !shmop_delete($this->resource)) {
+						throw new \Exception(__CLASS__ . ": Unable to delete shared memory block '{$shmKey}'.", self::EXCEPTION_SHMOP_DELETE_FAILED);
+					}
+
+					$fp = fopen($realPath, 'r');
+
+					if ($fp === false) {
+						throw new \Exception(__CLASS__ . ": Unable to open file '{$realPath}'.", self::EXCEPTION_FILE_OPEN_FAILED);
+					}
+
+					// Open the memory segment for exclusive access
+					$shmId = @shmop_open($shmKey, 'n', self::SHM_PERMS, $fileSize);
+
+					if ($shmId === false) {
+						throw new \Exception(__CLASS__ . ": Unable to create shared memory block '{$shmKey}'.", self::EXCEPTION_SHMOP_CREATE_FAILED);
+					}
+
+					// Load SHM_CHUNK_SIZE bytes at a time
+					$pointer = 0;
+					while ($pointer < $fileSize) {
+						$buffer = fread($fp, self::SHM_CHUNK_SIZE);
+						shmop_write($shmId, $buffer, $pointer);
+						$pointer += self::SHM_CHUNK_SIZE;
+					}
+
+					if (PHP_MAJOR_VERSION < 8) {
+						shmop_close($shmId);
+					}
+
+					fclose($fp);
+
+					// Open memory segment for readonly access
+					$this->resource = @shmop_open($shmKey, 'a', 0, 0);
+
+					if ($this->resource === false) {
+						throw new \Exception(__CLASS__ . ": Unable to access shared memory block '{$shmKey}' for reading.", self::EXCEPTION_SHMOP_READING_FAILED);
+					}
+				}
+				break;
+
+			case self::MEMORY_CACHE:
+				$this->mode = self::MEMORY_CACHE;
+				$this->resource = $realPath;
+
+				if (!\array_key_exists($realPath, $this->buffer)) {
+					$memoryLimit = $this->getMemoryLimit();
+
+					if ($memoryLimit !== false && $fileSize > $memoryLimit) {
+						throw new \Exception(__CLASS__ . ": Insufficient memory to load file '{$realPath}'.", self::EXCEPTION_NO_MEMORY);
+					}
+
+					$this->buffer[$realPath] = @file_get_contents($realPath);
+
+					if ($this->buffer[$realPath] === false) {
+						throw new \Exception(__CLASS__ . ": Unable to open file '{$realPath}'.", self::EXCEPTION_FILE_OPEN_FAILED);
+					}
+				}
+				break;
+
+			case self::FILE_IO:
+			default:
+				$this->mode = self::FILE_IO;
+				$this->resource = @fopen($realPath, 'r');
+				if ($this->resource === false) {
+					throw new \Exception(__CLASS__ . ": Unable to open file '{$realPath}'.", self::EXCEPTION_FILE_OPEN_FAILED);
+				}
+				break;
+		}
+
+		// Determine platform's float size
+		if ($this->floatSize === null) {
+			$this->floatSize = \strlen(pack('f', M_PI));
+		}
+
+		// Set default return fields
+		$this->defaultFields = $defaultFields;
+
+		// Read metadata headers from the first 512 bytes
+		$headers = $this->read(0, 512);
+
+		// Extract metadata from headers
+		$this->type = unpack('C', $headers, 0)[1] - 1;
+		$this->columnWidth[4] = unpack('C', $headers, 1)[1] * 4;
+		$this->columnWidth[6] = $this->columnWidth[4] + 12;
+		$this->offset[4] = -4;
+		$this->offset[6] = 8;
+		$this->year = 2000 + unpack('C', $headers, 2)[1];
+		$this->month = unpack('C', $headers, 3)[1];
+		$this->day = unpack('C', $headers, 4)[1];
+		$this->date = date('Y-m-d', strtotime("{$this->year}-{$this->month}-{$this->day}"));
+		$this->productCode = unpack('C', $headers, 29)[1];
+		$this->licenseCode = unpack('C', $headers, 30)[1];
+		$this->databaseSize = unpack('C', $headers, 31)[1];
+		$this->ipCount[4] = unpack('V', $headers, 5)[1];
+		$this->ipBase[4] = unpack('V', $headers, 9)[1];
+		$this->ipCount[6] = unpack('V', $headers, 13)[1];
+		$this->ipBase[6] = unpack('V', $headers, 17)[1];
+		$this->indexBaseAddr[4] = unpack('V', $headers, 21)[1];
+		$this->indexBaseAddr[6] = unpack('V', $headers, 25)[1];
+
+		if ($this->productCode == 0) {
+			throw new \Exception(__CLASS__ . ': Incorrect IP2Location BIN file format. Please make sure that you are using the latest IP2Location BIN file.', self::EXCEPTION_INVALID_BIN_DATABASE);
+		}
+	}
+
+	/**
+	 * Destructor.
+	 */
+	public function __destruct()
+	{
+		switch ($this->mode) {
+			case self::FILE_IO:
+				// Free the file pointer
+				if ($this->resource !== false) {
+					fclose($this->resource);
+					$this->resource = false;
+				}
+				break;
+
+			case self::SHARED_MEMORY:
+				// Detach from the memory segment
+				if ($this->resource !== false) {
+					if (PHP_MAJOR_VERSION < 8) {
+						shmop_close($this->resource);
+					}
+
+					$this->resource = false;
+				}
+				break;
+		}
+	}
+
+	/**
+	 * Tear down a shared memory segment created for the given file.
+	 *
+	 * @param string $file Filename of the BIN database
+	 *
+	 * @throws \Exception
+	 */
+	public function shmTeardown($file)
+	{
+		// Make sure shmop extension is loaded
+		if (!\extension_loaded('shmop')) {
+			throw new \Exception(__CLASS__ . ": Please make sure your PHP setup has the 'shmop' extension enabled.", self::EXCEPTION_NO_SHMOP);
+		}
+
+		// Get actual file path
+		$realPath = realpath($file);
+
+		// Throw error if file cannot be located
+		if ($realPath === false) {
+			throw new \Exception(__CLASS__ . ": Database file '{$file}' does not seem to exist.", self::EXCEPTION_DATABASE_FILE_NOT_FOUND);
+		}
+
+		$shmKey = $this->getShmKey($realPath);
+
+		// Open the memory segment for writing
+		$shmId = @shmop_open($shmKey, 'w', 0, 0);
+
+		if ($shmId === false) {
+			throw new \Exception(__CLASS__ . ": Unable to access shared memory block '{$shmKey}' for writing.", self::EXCEPTION_SHMOP_WRITING_FAILED);
+		}
+
+		// Delete the memory segment
+		shmop_delete($shmId);
+	}
+
+	/**
+	 * Get the database's compilation date as a string of the form 'YYYY-MM-DD'.
+	 *
+	 * @return string
+	 */
+	public function getDate()
+	{
+		return $this->date;
+	}
+
+	/**
+	 * Get the database's type (1 - 25).
+	 *
+	 * @return int
+	 */
+	public function getType()
+	{
+		return $this->type + 1;
+	}
+
+	/**
+	 * Return fields available in current database.
+	 *
+	 * @param bool $asNames Whether to return the mapped names instead of numbered constants
+	 *
+	 * @return array
+	 */
+	public function getFields($asNames = false)
+	{
+		$result = array_keys(array_filter($this->columns, function ($field) {
+			return $field[$this->type] !== 0;
+		}));
+
+		if ($asNames) {
+			$return = [];
+			foreach ($result as $field) {
+				$return[] = $this->names[$field];
+			}
+
+			return $return;
+		}
+
+		return $result;
+	}
+
+	/**
+	 * Return the version of module.
+	 */
+	public function getModuleVersion()
+	{
+		return self::VERSION;
+	}
+
+	/**
+	 * Return the version of current database.
+	 */
+	public function getDatabaseVersion()
+	{
+		return $this->year . '.' . $this->month . '.' . $this->day;
+	}
+
+	/**
+	 * This function will look the given IP address up in the database and return the result(s) asked for.
+	 *
+	 * If a single, SINGULAR, field is specified, only its mapped value is returned.
+	 * If many fields are given (as an array) or a MULTIPLE field is specified, an
+	 * array with the returned singular field names as keys and their corresponding
+	 * values is returned.
+	 *
+	 * @param string    $ip      IP address to look up
+	 * @param array|int $fields  Field(s) to return
+	 * @param bool      $asNamed Whether to return an associative array instead
+	 *
+	 * @return array|bool|mixed
+	 */
+	public function lookup($ip, $fields = null, $asNamed = true)
+	{
+		// Get IP version and number
+		list($ipVersion, $ipNumber) = $this->ipVersionAndNumber($ip);
+
+		if (!$ipVersion) {
+			return false;
+		}
+
+		// Perform a binary search
+		$pointer = $this->binSearch($ipVersion, $ipNumber);
+
+		if (empty($pointer)) {
+			return false;
+		}
+
+		// Apply default fields
+		if ($fields === null) {
+			$fields = $this->defaultFields;
+		}
+
+		// Get the entire row based on the pointer value
+		if ($ipVersion === 4) {
+			$this->rawPositionsRow = $this->read($pointer - 1, $this->columnWidth[4] + 4);
+		} elseif ($ipVersion === 6) {
+			$this->rawPositionsRow = $this->read($pointer - 1, $this->columnWidth[6]);
+		}
+
+		// turn fields into an array in case it wasn't already
+		$ifields = (array) $fields;
+
+		// add fields if needed
+		if (\in_array(self::ALL, $ifields)) {
+			$ifields[] = self::REGION_NAME;
+			$ifields[] = self::CITY_NAME;
+			$ifields[] = self::ISP;
+			$ifields[] = self::DOMAIN_NAME;
+			$ifields[] = self::ZIP_CODE;
+			$ifields[] = self::TIME_ZONE;
+			$ifields[] = self::NET_SPEED;
+			$ifields[] = self::ELEVATION;
+			$ifields[] = self::USAGE_TYPE;
+			$ifields[] = self::ADDRESS_TYPE;
+			$ifields[] = self::CATEGORY;
+			$ifields[] = self::DISTRICT;
+			$ifields[] = self::ASN;
+			$ifields[] = self::AS;
+
+			$ifields[] = self::COUNTRY;
+			$ifields[] = self::COORDINATES;
+			$ifields[] = self::IDD_AREA;
+			$ifields[] = self::WEATHER_STATION;
+			$ifields[] = self::MCC_MNC_MOBILE_CARRIER_NAME;
+
+			$ifields[] = self::IP_ADDRESS;
+			$ifields[] = self::IP_VERSION;
+			$ifields[] = self::IP_NUMBER;
+		}
+		// turn into a uniquely-valued array the fast way
+		// (see: http://php.net/manual/en/function.array-unique.php#77743)
+		$afields = array_keys(array_flip($ifields));
+		// sorting them in reverse order warrants that by the time we get to
+		// SINGULAR fields, its MULTIPLE counterparts, if at all present, have
+		// already been retrieved
+		rsort($afields);
+
+		// maintain a list of already retrieved fields to avoid doing it twice
+		$done = [
+			self::COUNTRY_CODE                => false,
+			self::COUNTRY_NAME                => false,
+			self::REGION_NAME                 => false,
+			self::CITY_NAME                   => false,
+			self::LATITUDE                    => false,
+			self::LONGITUDE                   => false,
+			self::ISP                         => false,
+			self::DOMAIN_NAME                 => false,
+			self::ZIP_CODE                    => false,
+			self::TIME_ZONE                   => false,
+			self::NET_SPEED                   => false,
+			self::IDD_CODE                    => false,
+			self::AREA_CODE                   => false,
+			self::WEATHER_STATION_CODE        => false,
+			self::WEATHER_STATION_NAME        => false,
+			self::MCC                         => false,
+			self::MNC                         => false,
+			self::MOBILE_CARRIER_NAME         => false,
+			self::ELEVATION                   => false,
+			self::USAGE_TYPE                  => false,
+			self::ADDRESS_TYPE                => false,
+			self::CATEGORY                    => false,
+			self::DISTRICT                    => false,
+			self::ASN                         => false,
+			self::AS                          => false,
+			self::COUNTRY                     => false,
+			self::COORDINATES                 => false,
+			self::IDD_AREA                    => false,
+			self::WEATHER_STATION             => false,
+			self::MCC_MNC_MOBILE_CARRIER_NAME => false,
+			self::IP_ADDRESS                  => false,
+			self::IP_VERSION                  => false,
+			self::IP_NUMBER                   => false,
+		];
+
+		$results = [];
+
+		// treat each field in turn
+		foreach ($afields as $afield) {
+			switch ($afield) {
+				// purposefully ignore self::ALL, we already dealt with it
+				case self::ALL:
+					break;
+
+				case self::COUNTRY:
+					if (!$done[self::COUNTRY]) {
+						list($results[self::COUNTRY_NAME], $results[self::COUNTRY_CODE]) = $this->readCountryNameAndCode($pointer);
+						$done[self::COUNTRY] = true;
+						$done[self::COUNTRY_CODE] = true;
+						$done[self::COUNTRY_NAME] = true;
+					}
+					break;
+
+				case self::COORDINATES:
+					if (!$done[self::COORDINATES]) {
+						list($results[self::LATITUDE], $results[self::LONGITUDE]) = $this->readLatitudeAndLongitude($pointer);
+						$done[self::COORDINATES] = true;
+						$done[self::LATITUDE] = true;
+						$done[self::LONGITUDE] = true;
+					}
+					break;
+
+				case self::IDD_AREA:
+					if (!$done[self::IDD_AREA]) {
+						list($results[self::IDD_CODE], $results[self::AREA_CODE]) = $this->readIddAndAreaCodes($pointer);
+						$done[self::IDD_AREA] = true;
+						$done[self::IDD_CODE] = true;
+						$done[self::AREA_CODE] = true;
+					}
+					break;
+
+				case self::WEATHER_STATION:
+					if (!$done[self::WEATHER_STATION]) {
+						list($results[self::WEATHER_STATION_NAME], $results[self::WEATHER_STATION_CODE]) = $this->readWeatherStationNameAndCode($pointer);
+						$done[self::WEATHER_STATION] = true;
+						$done[self::WEATHER_STATION_NAME] = true;
+						$done[self::WEATHER_STATION_CODE] = true;
+					}
+					break;
+				case self::MCC_MNC_MOBILE_CARRIER_NAME:
+					if (!$done[self::MCC_MNC_MOBILE_CARRIER_NAME]) {
+						list($results[self::MCC], $results[self::MNC], $results[self::MOBILE_CARRIER_NAME]) = $this->readMccMncAndMobileCarrierName($pointer);
+						$done[self::MCC_MNC_MOBILE_CARRIER_NAME] = true;
+						$done[self::MCC] = true;
+						$done[self::MNC] = true;
+						$done[self::MOBILE_CARRIER_NAME] = true;
+					}
+					break;
+
+				case self::COUNTRY_CODE:
+					if (!$done[self::COUNTRY_CODE]) {
+						$results[self::COUNTRY_CODE] = $this->readCountryNameAndCode($pointer)[1];
+						$done[self::COUNTRY_CODE] = true;
+					}
+					break;
+
+				case self::COUNTRY_NAME:
+					if (!$done[self::COUNTRY_NAME]) {
+						$results[self::COUNTRY_NAME] = $this->readCountryNameAndCode($pointer)[0];
+						$done[self::COUNTRY_NAME] = true;
+					}
+					break;
+
+				case self::REGION_NAME:
+					if (!$done[self::REGION_NAME]) {
+						$results[self::REGION_NAME] = $this->readRegionName($pointer);
+						$done[self::REGION_NAME] = true;
+					}
+					break;
+
+				case self::CITY_NAME:
+					if (!$done[self::CITY_NAME]) {
+						$results[self::CITY_NAME] = $this->readCityName($pointer);
+						$done[self::CITY_NAME] = true;
+					}
+					break;
+
+				case self::LATITUDE:
+					if (!$done[self::LATITUDE]) {
+						$results[self::LATITUDE] = $this->readLatitudeAndLongitude($pointer)[0];
+						$done[self::LATITUDE] = true;
+					}
+					break;
+
+				case self::LONGITUDE:
+					if (!$done[self::LONGITUDE]) {
+						$results[self::LONGITUDE] = $this->readLatitudeAndLongitude($pointer)[1];
+						$done[self::LONGITUDE] = true;
+					}
+					break;
+
+				case self::ISP:
+					if (!$done[self::ISP]) {
+						$results[self::ISP] = $this->readIsp($pointer);
+						$done[self::ISP] = true;
+					}
+					break;
+
+				case self::DOMAIN_NAME:
+					if (!$done[self::DOMAIN_NAME]) {
+						$results[self::DOMAIN_NAME] = $this->readDomainName($pointer);
+						$done[self::DOMAIN_NAME] = true;
+					}
+					break;
+
+				case self::ZIP_CODE:
+					if (!$done[self::ZIP_CODE]) {
+						$results[self::ZIP_CODE] = $this->readZipCode($pointer);
+						$done[self::ZIP_CODE] = true;
+					}
+					break;
+
+				case self::TIME_ZONE:
+					if (!$done[self::TIME_ZONE]) {
+						$results[self::TIME_ZONE] = $this->readTimeZone($pointer);
+						$done[self::TIME_ZONE] = true;
+					}
+					break;
+
+				case self::NET_SPEED:
+					if (!$done[self::NET_SPEED]) {
+						$results[self::NET_SPEED] = $this->readNetSpeed($pointer);
+						$done[self::NET_SPEED] = true;
+					}
+					break;
+
+				case self::IDD_CODE:
+					if (!$done[self::IDD_CODE]) {
+						$results[self::IDD_CODE] = $this->readIddAndAreaCodes($pointer)[0];
+						$done[self::IDD_CODE] = true;
+					}
+					break;
+
+				case self::AREA_CODE:
+					if (!$done[self::AREA_CODE]) {
+						$results[self::AREA_CODE] = $this->readIddAndAreaCodes($pointer)[1];
+						$done[self::AREA_CODE] = true;
+					}
+					break;
+
+				case self::WEATHER_STATION_CODE:
+					if (!$done[self::WEATHER_STATION_CODE]) {
+						$results[self::WEATHER_STATION_CODE] = $this->readWeatherStationNameAndCode($pointer)[1];
+						$done[self::WEATHER_STATION_CODE] = true;
+					}
+					break;
+
+				case self::WEATHER_STATION_NAME:
+					if (!$done[self::WEATHER_STATION_NAME]) {
+						$results[self::WEATHER_STATION_NAME] = $this->readWeatherStationNameAndCode($pointer)[0];
+						$done[self::WEATHER_STATION_NAME] = true;
+					}
+					break;
+
+				case self::MCC:
+					if (!$done[self::MCC]) {
+						$results[self::MCC] = $this->readMccMncAndMobileCarrierName($pointer)[0];
+						$done[self::MCC] = true;
+					}
+					break;
+
+				case self::MNC:
+					if (!$done[self::MNC]) {
+						$results[self::MNC] = $this->readMccMncAndMobileCarrierName($pointer)[1];
+						$done[self::MNC] = true;
+					}
+					break;
+
+				case self::MOBILE_CARRIER_NAME:
+					if (!$done[self::MOBILE_CARRIER_NAME]) {
+						$results[self::MOBILE_CARRIER_NAME] = $this->readMccMncAndMobileCarrierName($pointer)[2];
+						$done[self::MOBILE_CARRIER_NAME] = true;
+					}
+					break;
+
+				case self::ELEVATION:
+					if (!$done[self::ELEVATION]) {
+						$results[self::ELEVATION] = $this->readElevation($pointer);
+						$done[self::ELEVATION] = true;
+					}
+					break;
+
+				case self::USAGE_TYPE:
+					if (!$done[self::USAGE_TYPE]) {
+						$results[self::USAGE_TYPE] = $this->readUsageType($pointer);
+						$done[self::USAGE_TYPE] = true;
+					}
+					break;
+
+				case self::ADDRESS_TYPE:
+					if (!$done[self::ADDRESS_TYPE]) {
+						$results[self::ADDRESS_TYPE] = $this->readAddressType($pointer);
+						$done[self::ADDRESS_TYPE] = true;
+					}
+					break;
+
+				case self::CATEGORY:
+					if (!$done[self::CATEGORY]) {
+						$results[self::CATEGORY] = $this->readCategory($pointer);
+						$done[self::CATEGORY] = true;
+					}
+					break;
+
+				case self::DISTRICT:
+					if (!$done[self::DISTRICT]) {
+						$results[self::DISTRICT] = $this->readDistrict($pointer);
+						$done[self::DISTRICT] = true;
+					}
+					break;
+
+				case self::ASN:
+					if (!$done[self::ASN]) {
+						$results[self::ASN] = $this->readAsn($pointer);
+						$done[self::ASN] = true;
+					}
+					break;
+
+				case self::AS:
+					if (!$done[self::AS]) {
+						$results[self::AS] = $this->readAs($pointer);
+						$done[self::AS] = true;
+					}
+					break;
+
+				case self::IP_ADDRESS:
+					if (!$done[self::IP_ADDRESS]) {
+						$results[self::IP_ADDRESS] = $ip;
+						$done[self::IP_ADDRESS] = true;
+					}
+					break;
+
+				case self::IP_VERSION:
+					if (!$done[self::IP_VERSION]) {
+						$results[self::IP_VERSION] = $ipVersion;
+						$done[self::IP_VERSION] = true;
+					}
+					break;
+
+				case self::IP_NUMBER:
+					if (!$done[self::IP_NUMBER]) {
+						$results[self::IP_NUMBER] = $ipNumber;
+						$done[self::IP_NUMBER] = true;
+					}
+					break;
+
+				default:
+					$results[$afield] = self::FIELD_NOT_KNOWN;
+			}
+		}
+
+		// If we were asked for an array, or we have multiple results to return...
+		if (\is_array($fields) || \count($results) > 1) {
+			// return array
+			if ($asNamed) {
+				// apply translations if needed
+				$return = [];
+				foreach ($results as $key => $val) {
+					if (\array_key_exists($key, $this->names)) {
+						$return[$this->names[$key]] = $val;
+					} else {
+						$return[$key] = $val;
+					}
+				}
+
+				return $return;
+			}
+
+			return $results;
+		}
+		// return a single value
+		return array_values($results)[0];
+	}
+
+	/**
+	 * For a given IP address, returns the cidr of his sub-network.
+	 *
+	 * @param string $ip
+	 *
+	 * @return array
+	 * */
+	public function getCidr($ip)
+	{
+		// Extract IP version and number
+		list($ipVersion, $ipNumber) = $this->ipVersionAndNumber($ip);
+
+		// Perform the binary search proper (if the IP address was invalid, binSearch will return false)
+		$records = $this->binSearch($ipVersion, $ipNumber, true);
+		if (!empty($records)) {
+			$result = [];
+
+			list($ipFrom, $ipTo) = $records;
+
+			--$ipTo;
+
+			while ($ipTo >= $ipFrom) {
+				$maxSize = $this->getMaxSize($ipFrom, 32);
+				$x = log($ipTo - $ipFrom + 1) / log(2);
+				$maxDiff = floor(32 - floor($x));
+
+				$ip = long2ip($ipFrom);
+
+				if ($maxSize < $maxDiff) {
+					$maxSize = $maxDiff;
+				}
+
+				$result[] = $ip . '/' . $maxSize;
+				$ipFrom += pow(2, (32 - $maxSize));
+			}
+
+			return $result;
+		}
+
+		return false;
+	}
+
+	/**
+	 * Get maximum size of a net block.
+	 *
+	 * @param int $base The base number
+	 * @param int $bit  The bit number
+	 *
+	 * @return bool|int
+	 */
+	private function getMaxSize($base, $bit)
+	{
+		while ($bit > 0) {
+			$decimal = hexdec(base_convert((pow(2, 32) - pow(2, (32 - ($bit - 1)))), 10, 16));
+
+			if (($base & $decimal) != $base) {
+				break;
+			}
+			--$bit;
+		}
+
+		return $bit;
+	}
+
+	/**
+	 * Get memory limit from the current PHP settings (return false if no memory limit set).
+	 *
+	 * @return bool|int
+	 */
+	private function getMemoryLimit()
+	{
+		// Get values if no cache
+		if ($this->memoryLimit === null) {
+			$memoryLimit = ini_get('memory_limit');
+
+			// Default memory limit
+			if ((string) $memoryLimit === '') {
+				$memoryLimit = '128M';
+			}
+
+			$value = (int) $memoryLimit;
+
+			// Deal with "no-limit"
+			if ($value < 0) {
+				$value = false;
+			} else {
+				// Deal with shorthand bytes
+				switch (strtoupper(substr($memoryLimit, -1))) {
+					case 'G': $value *= 1024;
+					// no break
+					case 'M': $value *= 1024;
+					// no break
+					case 'K': $value *= 1024;
+				}
+			}
+
+			$this->memoryLimit = $value;
+		}
+
+		return $this->memoryLimit;
+	}
+
+	/**
+	 * Return the realpath of the given file or look for the first matching database option.
+	 *
+	 * @param string $file File to try to find, or null to try the databases in turn on the current file's path
+	 *
+	 * @throws \Exception
+	 *
+	 * @return string
+	 */
+	private function findFile($file = null)
+	{
+		if ($file !== null) {
+			// Get actual file path
+			$realPath = realpath($file);
+
+			// Throw error if file cannot be located
+			if ($realPath === false) {
+				throw new \Exception(__CLASS__ . ": Database file '{$file}' does not seem to exist.", self::EXCEPTION_DATABASE_FILE_NOT_FOUND);
+			}
+
+			return $realPath;
+		}
+
+		// Try to get current path
+		$current = realpath(__DIR__);
+
+		if ($current === false) {
+			throw new \Exception(__CLASS__ . ': Cannot determine current path.', self::EXCEPTION_NO_PATH);
+		}
+
+		// Try each database in turn
+		foreach ($this->databases as $database) {
+			$realPath = realpath("{$current}/{$database}.BIN");
+
+			if ($realPath !== false) {
+				return $realPath;
+			}
+		}
+
+		// No candidates found
+		throw new \Exception(__CLASS__ . ': No candidate database files found.', self::EXCEPTION_NO_CANDIDATES);
+	}
+
+	/**
+	 * Make the given number positive by wrapping it to 8 bit values.
+	 *
+	 * @param int $x Number to wrap
+	 *
+	 * @return int
+	 */
+	private function wrap8($x)
+	{
+		return $x + ($x < 0 ? 256 : 0);
+	}
+
+	/**
+	 * Make the given number positive by wrapping it to 32 bit values.
+	 *
+	 * @param int $x Number to wrap
+	 *
+	 * @return int
+	 */
+	private function wrap32($x)
+	{
+		return $x + ($x < 0 ? 4294967296 : 0);
+	}
+
+	/**
+	 * Generate a unique and repeatable shared memory key for each instance to use.
+	 *
+	 * @param string $filename Filename of the BIN file
+	 *
+	 * @return int
+	 */
+	private function getShmKey($filename)
+	{
+		return (int) sprintf('%u', $this->wrap32(crc32(__FILE__ . ':' . $filename)));
+	}
+
+	/**
+	 * Determine whether the given IP number of the given version lies between the given bounds.
+	 *
+	 * This function will return 0 if the given ip number falls within the given bounds
+	 * for the given version, -1 if it falls below, and 1 if it falls above.
+	 *
+	 * @param int        $version IP version to use (either 4 or 6)
+	 * @param int|string $ip      IP number to check (int for IPv4, string for IPv6)
+	 * @param int|string $low     Lower bound (int for IPv4, string for IPv6)
+	 * @param int|string $high    Uppoer bound (int for IPv4, string for IPv6)
+	 *
+	 * @return int
+	 */
+	private function ipBetween($version, $ip, $low, $high)
+	{
+		if ($version === 4) {
+			// Use normal PHP ints
+			if ($low <= $ip) {
+				if ($ip < $high) {
+					return 0;
+				}
+
+				return 1;
+			}
+
+			return -1;
+		}
+		// Use BCMath
+		if (bccomp($low, $ip, 0) <= 0) {
+			if (bccomp($ip, $high, 0) <= -1) {
+				return 0;
+			}
+
+			return 1;
+		}
+
+		return -1;
+	}
+
+	/**
+	 * Get the IP version and number of the given IP address.
+	 *
+	 * @param string $ip IP address to extract the version and number for
+	 *
+	 * @return array
+	 */
+	private function ipVersionAndNumber($ip)
+	{
+		if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
+			$number = sprintf('%u', ip2long($ip));
+
+			return [4, ($number == self::MAX_IPV4_RANGE) ? ($number - 1) : $number];
+		} elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
+			$result = 0;
+			$ip = $this->expand($ip);
+
+			// 6to4 Address - 2002::/16
+			if (substr($ip, 0, 4) == '2002') {
+				foreach (str_split(bin2hex(inet_pton($ip)), 8) as $word) {
+					$result = bcadd(bcmul($result, '4294967296', 0), $this->wrap32(hexdec($word)), 0);
+				}
+
+				return [4, bcmod(bcdiv($result, bcpow(2, 80)), '4294967296')];
+			}
+
+			// Teredo Address - 2001:0::/32
+			if (substr($ip, 0, 9) == '2001:0000' && str_replace(':', '', substr($ip, -9)) != '00000000') {
+				return [4, ip2long(long2ip(~hexdec(str_replace(':', '', substr($ip, -9)))))];
+			}
+
+			foreach (str_split(bin2hex(inet_pton($ip)), 8) as $word) {
+				$result = bcadd(bcmul($result, '4294967296', 0), $this->wrap32(hexdec($word)), 0);
+			}
+
+			// IPv4 address in IPv6
+			if (bccomp($result, '281470681743360') >= 0 && bccomp($result, '281474976710655') <= 0) {
+				return [4, bcsub($result, '281470681743360')];
+			}
+
+			return [6, $result];
+		}
+
+		// Invalid IP address, return false
+		return [false, false];
+	}
+
+	/**
+	 * Return the decimal string representing the binary data given.
+	 *
+	 * @param string $data Binary data to parse
+	 *
+	 * @return string
+	 */
+	private function bcBin2Dec($data)
+	{
+		if (!$data) {
+			return;
+		}
+
+		$parts = [
+			unpack('V', substr($data, 12, 4)),
+			unpack('V', substr($data, 8, 4)),
+			unpack('V', substr($data, 4, 4)),
+			unpack('V', substr($data, 0, 4)),
+		];
+
+		foreach ($parts as &$part) {
+			if ($part[1] < 0) {
+				$part[1] += 4294967296;
+			}
+		}
+
+		$result = bcadd(bcadd(bcmul($parts[0][1], bcpow(4294967296, 3)), bcmul($parts[1][1], bcpow(4294967296, 2))), bcadd(bcmul($parts[2][1], 4294967296), $parts[3][1]));
+
+		return $result;
+	}
+
+	/**
+	 * Return the decimal string representing the binary data given.
+	 *
+	 * @param mixed $ipv6
+	 *
+	 * @return string
+	 */
+	private function expand($ipv6)
+	{
+		$hex = unpack('H*hex', inet_pton($ipv6));
+
+		return substr(preg_replace('/([A-f0-9]{4})/', '$1:', $hex['hex']), 0, -1);
+	}
+
+	/**
+	 * Low level read function to abstract away the caching mode being used.
+	 *
+	 * @param int $pos Position from where to start reading
+	 * @param int $len Read this many bytes
+	 *
+	 * @return string
+	 */
+	private function read($pos, $len)
+	{
+		switch ($this->mode) {
+			case self::SHARED_MEMORY:
+				return shmop_read($this->resource, $pos, $len);
+
+			case self::MEMORY_CACHE:
+				return $data = substr($this->buffer[$this->resource], $pos, $len);
+
+			default:
+				fseek($this->resource, $pos, SEEK_SET);
+
+				return fread($this->resource, $len);
+		}
+	}
+
+	/**
+	 * Low level function to fetch a string from the caching backend.
+	 *
+	 * @param int $pos        Position to read from
+	 * @param int $additional Additional offset to apply
+	 *
+	 * @return string
+	 */
+	private function readString($pos, $additional = 0)
+	{
+		// Get the actual pointer to the string's head by extract from the raw row
+		$newPosition = unpack('V', substr($this->rawPositionsRow, $pos, 4))[1] + $additional;
+
+		// Read as much as the length (first "string" byte) indicates
+		return $this->read($newPosition + 1, $this->readByte($newPosition + 1));
+	}
+
+	/**
+	 * Low level function to fetch a float from the caching backend.
+	 *
+	 * @param int $pos Position to read from
+	 *
+	 * @return float
+	 */
+	private function readFloat($pos)
+	{
+		// Unpack a float's size worth of data
+		return unpack('f', substr($this->rawPositionsRow, $pos, $this->floatSize))[1];
+	}
+
+	/**
+	 * Low level function to fetch a byte from the caching backend.
+	 *
+	 * @param int $pos Position to read from
+	 *
+	 * @return string
+	 */
+	private function readByte($pos)
+	{
+		// Unpack a byte's worth of data
+		return $this->wrap8(unpack('C', $this->read($pos - 1, 1))[1]);
+	}
+
+	/**
+	 * High level function to fetch the country name and code.
+	 *
+	 * @param bool|int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return array
+	 */
+	private function readCountryNameAndCode($pointer)
+	{
+		if ($pointer === false) {
+			$countryCode = self::INVALID_IP_ADDRESS;
+			$countryName = self::INVALID_IP_ADDRESS;
+		} elseif ($this->columns[self::COUNTRY_CODE][$this->type] === 0) {
+			$countryCode = self::FIELD_NOT_SUPPORTED;
+			$countryName = self::FIELD_NOT_SUPPORTED;
+		} else {
+			// Read the country code and name (the name shares the country's pointer,
+			// but it must be artificially displaced 3 bytes ahead: 2 for the country code, one
+			// for the country name's length)
+			$countryCode = $this->readString($this->columns[self::COUNTRY_CODE][$this->type]);
+			$countryName = $this->readString($this->columns[self::COUNTRY_NAME][$this->type], 3);
+		}
+
+		return [$countryName, $countryCode];
+	}
+
+	/**
+	 * High level function to fetch the region name.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return string
+	 */
+	private function readRegionName($pointer)
+	{
+		if ($pointer === false) {
+			return self::INVALID_IP_ADDRESS;
+		}
+
+		if ($this->columns[self::REGION_NAME][$this->type] === 0) {
+			return self::FIELD_NOT_SUPPORTED;
+		}
+
+		return $this->readString($this->columns[self::REGION_NAME][$this->type]);
+	}
+
+	/**
+	 * High level function to fetch the city name.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return string
+	 */
+	private function readCityName($pointer)
+	{
+		if ($pointer === false) {
+			return self::INVALID_IP_ADDRESS;
+		}
+
+		if ($this->columns[self::CITY_NAME][$this->type] === 0) {
+			return self::FIELD_NOT_SUPPORTED;
+		}
+
+		return $this->readString($this->columns[self::CITY_NAME][$this->type]);
+	}
+
+	/**
+	 * High level function to fetch the latitude and longitude.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return array
+	 */
+	private function readLatitudeAndLongitude($pointer)
+	{
+		if ($pointer === false) {
+			$latitude = self::INVALID_IP_ADDRESS;
+			$longitude = self::INVALID_IP_ADDRESS;
+		} elseif ($this->columns[self::LATITUDE][$this->type] === 0) {
+			$latitude = self::FIELD_NOT_SUPPORTED;
+			$longitude = self::FIELD_NOT_SUPPORTED;
+		} else {
+			// Read latitude and longitude
+			$latitude = round($this->readFloat($this->columns[self::LATITUDE][$this->type]), 6);
+			$longitude = round($this->readFloat($this->columns[self::LONGITUDE][$this->type]), 6);
+		}
+
+		return [$latitude, $longitude];
+	}
+
+	/**
+	 * High level function to fetch the ISP name.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return string
+	 */
+	private function readIsp($pointer)
+	{
+		if ($pointer === false) {
+			return self::INVALID_IP_ADDRESS;
+		}
+
+		if ($this->columns[self::ISP][$this->type] === 0) {
+			return self::FIELD_NOT_SUPPORTED;
+		}
+
+		return $this->readString($this->columns[self::ISP][$this->type]);
+	}
+
+	/**
+	 * High level function to fetch the domain name.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return string
+	 */
+	private function readDomainName($pointer)
+	{
+		if ($pointer === false) {
+			return self::INVALID_IP_ADDRESS;
+		}
+
+		if ($this->columns[self::DOMAIN_NAME][$this->type] === 0) {
+			return self::FIELD_NOT_SUPPORTED;
+		}
+
+		return $this->readString($this->columns[self::DOMAIN_NAME][$this->type]);
+	}
+
+	/**
+	 * High level function to fetch the zip code.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return string
+	 */
+	private function readZipCode($pointer)
+	{
+		if ($pointer === false) {
+			return self::INVALID_IP_ADDRESS;
+		}
+
+		if ($this->columns[self::ZIP_CODE][$this->type] === 0) {
+			return self::FIELD_NOT_SUPPORTED;
+		}
+
+		return $this->readString($this->columns[self::ZIP_CODE][$this->type]);
+	}
+
+	/**
+	 * High level function to fetch the time zone.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return string
+	 */
+	private function readTimeZone($pointer)
+	{
+		if ($pointer === false) {
+			return self::INVALID_IP_ADDRESS;
+		}
+
+		if ($this->columns[self::TIME_ZONE][$this->type] === 0) {
+			return self::FIELD_NOT_SUPPORTED;
+		}
+
+		return $this->readString($this->columns[self::TIME_ZONE][$this->type]);
+	}
+
+	/**
+	 * High level function to fetch the net speed.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return string
+	 */
+	private function readNetSpeed($pointer)
+	{
+		if ($pointer === false) {
+			return self::INVALID_IP_ADDRESS;
+		}
+
+		if ($this->columns[self::NET_SPEED][$this->type] === 0) {
+			return self::FIELD_NOT_SUPPORTED;
+		}
+
+		return $this->readString($this->columns[self::NET_SPEED][$this->type]);
+	}
+
+	/**
+	 * High level function to fetch the IDD and area codes.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return array
+	 */
+	private function readIddAndAreaCodes($pointer)
+	{
+		if ($pointer === false) {
+			$iddCode = self::INVALID_IP_ADDRESS;
+			$areaCode = self::INVALID_IP_ADDRESS;
+		} elseif ($this->columns[self::IDD_CODE][$this->type] === 0) {
+			$iddCode = self::FIELD_NOT_SUPPORTED;
+			$areaCode = self::FIELD_NOT_SUPPORTED;
+		} else {
+			// Read IDD and area codes
+			$iddCode = $this->readString($this->columns[self::IDD_CODE][$this->type]);
+			$areaCode = $this->readString($this->columns[self::AREA_CODE][$this->type]);
+		}
+
+		return [$iddCode, $areaCode];
+	}
+
+	/**
+	 * High level function to fetch the weather station name and code.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return array
+	 */
+	private function readWeatherStationNameAndCode($pointer)
+	{
+		if ($pointer === false) {
+			$weatherStationName = self::INVALID_IP_ADDRESS;
+			$weatherStationCode = self::INVALID_IP_ADDRESS;
+		} elseif ($this->columns[self::WEATHER_STATION_NAME][$this->type] === 0) {
+			$weatherStationName = self::FIELD_NOT_SUPPORTED;
+			$weatherStationCode = self::FIELD_NOT_SUPPORTED;
+		} else {
+			// Read weather station name and code
+			$weatherStationName = $this->readString($this->columns[self::WEATHER_STATION_NAME][$this->type]);
+			$weatherStationCode = $this->readString($this->columns[self::WEATHER_STATION_CODE][$this->type]);
+		}
+
+		return [$weatherStationName, $weatherStationCode];
+	}
+
+	/**
+	 * High level function to fetch the MCC, MNC, and mobile carrier name.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return array
+	 */
+	private function readMccMncAndMobileCarrierName($pointer)
+	{
+		if ($pointer === false) {
+			$mcc = self::INVALID_IP_ADDRESS;
+			$mnc = self::INVALID_IP_ADDRESS;
+			$mobileCarrierName = self::INVALID_IP_ADDRESS;
+		} elseif ($this->columns[self::MCC][$this->type] === 0) {
+			$mcc = self::FIELD_NOT_SUPPORTED;
+			$mnc = self::FIELD_NOT_SUPPORTED;
+			$mobileCarrierName = self::FIELD_NOT_SUPPORTED;
+		} else {
+			// Read MCC, MNC, and mobile carrier name
+			$mcc = $this->readString($this->columns[self::MCC][$this->type]);
+			$mnc = $this->readString($this->columns[self::MNC][$this->type]);
+			$mobileCarrierName = $this->readString($this->columns[self::MOBILE_CARRIER_NAME][$this->type]);
+		}
+
+		return [$mcc, $mnc, $mobileCarrierName];
+	}
+
+	/**
+	 * High level function to fetch the elevation.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return string
+	 */
+	private function readElevation($pointer)
+	{
+		if ($pointer === false) {
+			return self::INVALID_IP_ADDRESS;
+		}
+
+		if ($this->columns[self::ELEVATION][$this->type] === 0) {
+			return self::FIELD_NOT_SUPPORTED;
+		}
+
+		return $this->readString($this->columns[self::ELEVATION][$this->type]);
+	}
+
+	/**
+	 * High level function to fetch the usage type.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return string
+	 */
+	private function readUsageType($pointer)
+	{
+		if ($pointer === false) {
+			return self::INVALID_IP_ADDRESS;
+		}
+
+		if ($this->columns[self::USAGE_TYPE][$this->type] === 0) {
+			return self::FIELD_NOT_SUPPORTED;
+		}
+
+		return $this->readString($this->columns[self::USAGE_TYPE][$this->type]);
+	}
+
+	/**
+	 * High level function to fetch the address type.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return string
+	 */
+	private function readAddressType($pointer)
+	{
+		if ($pointer === false) {
+			return self::INVALID_IP_ADDRESS;
+		}
+
+		if ($this->columns[self::ADDRESS_TYPE][$this->type] === 0) {
+			return self::FIELD_NOT_SUPPORTED;
+		}
+
+		return $this->readString($this->columns[self::ADDRESS_TYPE][$this->type]);
+	}
+
+	/**
+	 * High level function to fetch the usage type.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return string
+	 */
+	private function readCategory($pointer)
+	{
+		if ($pointer === false) {
+			return self::INVALID_IP_ADDRESS;
+		}
+
+		if ($this->columns[self::CATEGORY][$this->type] === 0) {
+			return self::FIELD_NOT_SUPPORTED;
+		}
+
+		return $this->readString($this->columns[self::CATEGORY][$this->type]);
+	}
+
+	/**
+	 * High level function to fetch the district.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return string
+	 */
+	private function readDistrict($pointer)
+	{
+		if ($pointer === false) {
+			return self::INVALID_IP_ADDRESS;
+		}
+
+		if ($this->columns[self::DISTRICT][$this->type] === 0) {
+			return self::FIELD_NOT_SUPPORTED;
+		}
+
+		return $this->readString($this->columns[self::DISTRICT][$this->type]);
+	}
+
+	/**
+	 * High level function to fetch the ASN.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return string
+	 */
+	private function readAsn($pointer)
+	{
+		if ($pointer === false) {
+			return self::INVALID_IP_ADDRESS;
+		}
+
+		if ($this->columns[self::ASN][$this->type] === 0) {
+			return self::FIELD_NOT_SUPPORTED;
+		}
+
+		return $this->readString($this->columns[self::ASN][$this->type]);
+	}
+
+	/**
+	 * High level function to fetch the AS.
+	 *
+	 * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS
+	 *
+	 * @return string
+	 */
+	private function readAs($pointer)
+	{
+		if ($pointer === false) {
+			return self::INVALID_IP_ADDRESS;
+		}
+
+		if ($this->columns[self::AS][$this->type] === 0) {
+			return self::FIELD_NOT_SUPPORTED;
+		}
+
+		return $this->readString($this->columns[self::AS][$this->type]);
+	}
+
+	/**
+	 * Get the boundaries for an IP address.
+	 *
+	 * @param int $ipVersion IP address version
+	 * @param int $position  Lookup position
+	 * @param int $width     The section width
+	 *
+	 * @return array
+	 */
+	private function getIpBoundary($ipVersion, $position, $width)
+	{
+		// Read 128 bits from the position
+		$section = $this->read($position, 128);
+
+		switch ($ipVersion) {
+			case 4:
+				return [unpack('V', substr($section, 0, 4))[1], unpack('V', substr($section, $width, 4))[1]];
+
+			case 6:
+				return [$this->bcBin2Dec(substr($section, 0, 16)), $this->bcBin2Dec(substr($section, $width, 16))];
+		}
+
+		return [false, false];
+	}
+
+	/**
+	 * Perform a binary search on the given IP number and return a pointer to its record.
+	 *
+	 * @param int   $version  IP version to use for searching
+	 * @param int   $ipNumber IP number to look for
+	 * @param mixed $cidr
+	 *
+	 * @return bool|int
+	 */
+	private function binSearch($version, $ipNumber, $cidr = false)
+	{
+		$base = $this->ipBase[$version];
+		$offset = $this->offset[$version];
+		$width = $this->columnWidth[$version];
+		$high = $this->ipCount[$version];
+		$low = 0;
+
+		$indexBaseStart = $this->indexBaseAddr[$version];
+
+		if ($indexBaseStart > 1) {
+			$indexPos = 0;
+
+			switch ($version) {
+				case 4:
+					$number = (int) ($ipNumber / 65536);
+					$indexPos = $indexBaseStart + ($number << 3);
+
+					break;
+
+				case 6:
+					$number = (int) (bcdiv($ipNumber, bcpow('2', '112')));
+					$indexPos = $indexBaseStart + ($number << 3);
+
+					break;
+			}
+
+			$section = $this->read($indexPos - 1, 8);
+
+			$low = unpack('V', substr($section, 0, 4))[1];
+			$high = unpack('V', substr($section, 4, 4))[1];
+		}
+
+		// Narrow down the search
+		while ($low <= $high) {
+			$mid = (int) ($low + (($high - $low) >> 1));
+			$position = $base + $width * $mid - 1;
+
+			list($ipStart, $ipEnd) = $this->getIpBoundary($version, $position, $width);
+
+			// Determine whether to return, repeat on the lower half, or repeat on the upper half
+			switch ($this->ipBetween($version, $ipNumber, $ipStart, $ipEnd)) {
+				case 0:
+					return ($cidr) ? [$ipStart, $ipEnd] : $base + $offset + $mid * $width;
+
+				case -1:
+					$high = $mid - 1;
+					break;
+
+				case 1:
+					$low = $mid + 1;
+					break;
+			}
+		}
+
+		// Record not found
+		return false;
+	}
+}

+ 356 - 0
app/controller/apps/weather/vendor/IP2Location/src/IpTools.php

@@ -0,0 +1,356 @@
+<?php
+
+namespace IP2Location;
+
+/**
+ * IpTools class.
+ */
+class IpTools
+{
+	public function isIpv4($ip)
+	{
+		return (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) ? true : false;
+	}
+
+	public function isIpv6($ip)
+	{
+		return (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) ? true : false;
+	}
+
+	public function ipv4ToDecimal($ip)
+	{
+		if (!$this->isIpv4($ip)) {
+			return;
+		}
+
+		return sprintf('%u', ip2long($ip));
+	}
+
+	public function ipv6ToDecimal($ipv6)
+	{
+		if (!$this->isIpv6($ipv6)) {
+			return;
+		}
+
+		return (string) gmp_import(inet_pton($ipv6));
+	}
+
+	public function decimalToIpv4($number)
+	{
+		if (!preg_match('/^\d+$/', $number)) {
+			return;
+		}
+
+		if ($number > 4294967295) {
+			return;
+		}
+
+		return long2ip($number);
+	}
+
+	public function decimalToIpv6($number)
+	{
+		if (!preg_match('/^\d+$/', $number)) {
+			return;
+		}
+
+		if ($number <= 4294967295) {
+			return;
+		}
+
+		return inet_ntop(str_pad(gmp_export($number), 16, "\0", STR_PAD_LEFT));
+	}
+
+	public function ipv4ToCidr($ipFrom, $ipTo)
+	{
+		$s = explode('.', $ipFrom);
+
+		$start = '';
+		$dot = '';
+
+		foreach ($s as $val) {
+			$start = sprintf('%s%s%d', $start, $dot, $val);
+			$dot = '.';
+		}
+
+		$end = '';
+		$dot = '';
+
+		$e = explode('.', $ipTo);
+
+		foreach ($e as $val) {
+			$end = sprintf('%s%s%d', $end, $dot, $val);
+			$dot = '.';
+		}
+
+		$start = ip2long($start);
+		$end = ip2long($end);
+		$result = [];
+
+		while ($end >= $start) {
+			$maxSize = $this->maxBlock($start, 32);
+			$x = log($end - $start + 1) / log(2);
+			$maxDiff = floor(32 - floor($x));
+
+			$ip = long2ip($start);
+
+			if ($maxSize < $maxDiff) {
+				$maxSize = $maxDiff;
+			}
+
+			array_push($result, "$ip/$maxSize");
+			$start += pow(2, (32 - $maxSize));
+		}
+
+		return $result;
+	}
+
+	public function ipv6ToCidr($ipFrom, $ipTo)
+	{
+		$ipFromBinary = str_pad($this->ip2Bin($ipFrom), 128, '0', STR_PAD_LEFT);
+		$ipToBinary = str_pad($this->ip2Bin($ipTo), 128, '0', STR_PAD_LEFT);
+
+		if ($ipFromBinary === $ipToBinary) {
+			return [$ipFrom . '/' . 128];
+		}
+
+		if (strcmp($ipFromBinary, $ipToBinary) > 0) {
+			list($ipFromBinary, $ipToBinary) = [$ipToBinary, $ipFromBinary];
+		}
+
+		$networks = [];
+		$networkSize = 0;
+
+		do {
+			if (substr($ipFromBinary, -1, 1) == '1') {
+				$networks[substr($ipFromBinary, $networkSize, 128 - $networkSize) . str_repeat('0', $networkSize)] = 128 - $networkSize;
+
+				$n = strrpos($ipFromBinary, '0');
+				$ipFromBinary = (($n == 0) ? '' : substr($ipFromBinary, 0, $n)) . '1' . str_repeat('0', 128 - $n - 1);
+			}
+
+			if (substr($ipToBinary, -1, 1) == '0') {
+				$networks[substr($ipToBinary, $networkSize, 128 - $networkSize) . str_repeat('0', $networkSize)] = 128 - $networkSize;
+				$n = strrpos($ipToBinary, '1');
+				$ipToBinary = (($n == 0) ? '' : substr($ipToBinary, 0, $n)) . '0' . str_repeat('1', 128 - $n - 1);
+			}
+
+			if (strcmp($ipToBinary, $ipFromBinary) < 0) {
+				continue;
+			}
+
+			$shift = 128 - max(strrpos($ipFromBinary, '0'), strrpos($ipToBinary, '1'));
+			$ipFromBinary = str_repeat('0', $shift) . substr($ipFromBinary, 0, 128 - $shift);
+			$ipToBinary = str_repeat('0', $shift) . substr($ipToBinary, 0, 128 - $shift);
+			$networkSize += $shift;
+			if ($ipFromBinary === $ipToBinary) {
+				$networks[substr($ipFromBinary, $networkSize, 128 - $networkSize) . str_repeat('0', $networkSize)] = 128 - $networkSize;
+				continue;
+			}
+		} while (strcmp($ipFromBinary, $ipToBinary) < 0);
+
+		ksort($networks, SORT_STRING);
+		$result = [];
+
+		foreach ($networks as $ip => $netmask) {
+			$result[] = $this->bin2Ip($ip) . '/' . $netmask;
+		}
+
+		return $result;
+	}
+
+	public function cidrToIpv4($cidr)
+	{
+		if (strpos($cidr, '/') === false) {
+			return;
+		}
+
+		list($ip, $prefix) = explode('/', $cidr);
+
+		$ipStart = long2ip((ip2long($ip)) & ((-1 << (32 - (int) $prefix))));
+
+		$total = 1 << (32 - $prefix);
+
+		$ipStartLong = sprintf('%u', ip2long($ipStart));
+		$ipEndLong = $ipStartLong + $total - 1;
+
+		if ($ipEndLong > 4294967295) {
+			$ipEndLong = 4294967295;
+		}
+
+		$ipLast = long2ip($ipEndLong);
+
+		return [
+			'ip_start' => $ipStart,
+			'ip_end'   => $ipLast,
+		];
+	}
+
+	public function cidrToIpv6($cidr)
+	{
+		if (strpos($cidr, '/') === false) {
+			return;
+		}
+
+		list($ip, $range) = explode('/', $cidr);
+
+		$parts = explode(':', $this->expandIpv6($ip));
+
+		$bitStart = str_repeat('1', $range) . str_repeat('0', 128 - $range);
+		$bitEnd = str_repeat('0', $range) . str_repeat('1', 128 - $range);
+
+		$floors = str_split($bitStart, 16);
+		$ceilings = str_split($bitEnd, 16);
+
+		$start = [];
+		$end = [];
+
+		for ($i = 0; $i < 8; ++$i) {
+			$start[] = dechex(hexdec($parts[$i]) & hexdec(base_convert($floors[$i], 2, 16))) . ':';
+			$end[] = dechex(hexdec($parts[$i]) | hexdec(base_convert($ceilings[$i], 2, 16))) . ':';
+		}
+
+		return [
+			'ip_start' => $this->expandIpv6(substr(implode('', $start), 0, -1)),
+			'ip_end'   => $this->expandIpv6(substr(implode('', $end), 0, -1)),
+		];
+	}
+
+	public function bin2Ip($bin)
+	{
+		if (\strlen($bin) != 128) {
+			return;
+		}
+
+		$pad = 128 - \strlen($bin);
+		for ($i = 1; $i <= $pad; ++$i) {
+			$bin = '0' . $bin;
+		}
+
+		$bits = 0;
+		$ipv6 = '';
+
+		while ($bits <= 7) {
+			$bin_part = substr($bin, ($bits * 16), 16);
+			$ipv6 .= dechex(bindec($bin_part)) . ':';
+			++$bits;
+		}
+
+		return inet_ntop(inet_pton(substr($ipv6, 0, -1)));
+	}
+
+	public function compressIpv6($ipv6)
+	{
+		return inet_ntop(inet_pton($ipv6));
+	}
+
+	public function expandIpv6($ipv6)
+	{
+		$hex = unpack('H*0', inet_pton($ipv6));
+
+		return implode(':', str_split($hex[0], 4));
+	}
+
+	public function getVisitorIp(&$ipData = null)
+	{
+		$ip = $ipRemoteAdd = $ipSucuri = $ipIncap = $ipCf = $ipReal = $ipForwarded = $ipForwardedOri = '::1';
+
+		if (isset($_SERVER['REMOTE_ADDR']) && filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP)) {
+			$ipRemoteAdd = $ip = $_SERVER['REMOTE_ADDR'];
+		}
+
+		// Get real client IP if they are behind Sucuri firewall.
+		if (isset($_SERVER['HTTP_X_SUCURI_CLIENTIP']) && filter_var($_SERVER['HTTP_X_SUCURI_CLIENTIP'], FILTER_VALIDATE_IP)) {
+			$ipSucuri = $ip = $_SERVER['HTTP_X_SUCURI_CLIENTIP'];
+		}
+
+		// Get real client IP if they are behind Incapsula firewall.
+		if (isset($_SERVER['HTTP_INCAP_CLIENT_IP']) && filter_var($_SERVER['HTTP_INCAP_CLIENT_IP'], FILTER_VALIDATE_IP)) {
+			$ipIncap = $ip = $_SERVER['HTTP_INCAP_CLIENT_IP'];
+		}
+
+		// Get real client IP if they are behind CloudFlare protection.
+		if (isset($_SERVER['HTTP_CF_CONNECTING_IP']) && filter_var($_SERVER['HTTP_CF_CONNECTING_IP'], FILTER_VALIDATE_IP)) {
+			$ipCf = $ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
+		}
+
+		if (isset($_SERVER['HTTP_X_REAL_IP']) && filter_var($_SERVER['HTTP_X_REAL_IP'], FILTER_VALIDATE_IP)) {
+			$ipReal = $ip = $_SERVER['HTTP_X_REAL_IP'];
+		}
+
+		// Get real client IP if they are behind proxy server.
+		if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+			$ipForwardedOri = $_SERVER['HTTP_X_FORWARDED_FOR'];
+			$xip = trim(current(explode(',', $ipForwardedOri)));
+			
+			if (filter_var($xip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
+				$ipForwarded = $ip = $xip;
+			}
+		}
+
+		if ((is_array($ipData)) || ($ipData == null)) {
+			if ($ipRemoteAdd != '::1') {
+				$ipData['REMOTE_ADDR'] = $ipRemoteAdd;
+			}
+
+			if ($ipSucuri != '::1') {
+				$ipData['HTTP_X_SUCURI_CLIENTIP'] = $ipSucuri;
+			}
+
+			if ($ipIncap != '::1') {
+				$ipData['HTTP_INCAP_CLIENT_IP'] = $ipIncap;
+			}
+
+			if ($ipCf != '::1') {
+				$ipData['HTTP_CF_CONNECTING_IP'] = $ipCf;
+			}
+
+			if ($ipReal != '::1') {
+				$ipData['HTTP_X_REAL_IP'] = $ipReal;
+			}
+
+			if ($ipForwardedOri != '::1') {
+				$ipData['HTTP_X_FORWARDED_FOR'] = $ipForwardedOri;
+			}
+		}
+
+		return $ip;
+	}
+
+	private function ip2Bin($ip)
+	{
+		if (($n = inet_pton($ip)) === false) {
+			return false;
+		}
+
+		$bits = 15;
+		$binary = '';
+		while ($bits >= 0) {
+			$bin = sprintf('%08b', (\ord($n[$bits])));
+			$binary = $bin . $binary;
+			--$bits;
+		}
+
+		return $binary;
+	}
+
+	private function maxBlock($base, $bit)
+	{
+		while ($bit > 0) {
+			$decimal = hexdec(base_convert((pow(2, 32) - pow(2, (32 - ($bit - 1)))), 10, 16));
+
+			if (($base & $decimal) != $base) {
+				break;
+			}
+
+			--$bit;
+		}
+
+		return $bit;
+	}
+
+	private function expand($ipv6)
+	{
+		return implode(':', str_split(unpack('H*0', inet_pton($ipv6))[0], 4));
+	}
+}

+ 125 - 0
app/controller/apps/weather/vendor/IP2Location/src/Region.php

@@ -0,0 +1,125 @@
+<?php
+
+namespace IP2Location;
+
+/**
+ * Region class.
+ */
+class Region
+{
+	/**
+	 * Unable to locate CSV file.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_FILE_NOT_EXISTS = 10000;
+
+	/**
+	 * Invalid CSV file.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_INVALID_CSV = 10001;
+
+	/**
+	 * Unable to read the CSV file.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_UNABLE_TO_OPEN_CSV = 10002;
+
+	/**
+	 * No record found.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_NO_RECORD = 10003;
+
+	/**
+	 * Fields from CSV.
+	 *
+	 * @var array
+	 */
+	protected $fields = [];
+
+	/**
+	 * Records from CSV.
+	 *
+	 * @var array
+	 */
+	protected $records = [];
+
+	/**
+	 * Constructor.
+	 *
+	 * @param string $csv Path to CSV file
+	 *
+	 * @throws \Exception
+	 */
+	public function __construct($csv)
+	{
+		if (!file_exists($csv)) {
+			throw new \Exception(__CLASS__ . ': The CSV file "' . $csv . '" is not found.', self::EXCEPTION_FILE_NOT_EXISTS);
+		}
+
+		$file = fopen($csv, 'r');
+
+		if (!$file) {
+			throw new \Exception(__CLASS__ . ': Unable to read "' . $csv . '".', self::EXCEPTION_UNABLE_TO_OPEN_CSV);
+		}
+
+		$line = 1;
+
+		while (!feof($file)) {
+			$data = fgetcsv($file);
+
+			if (!$data) {
+				++$line;
+				continue;
+			}
+
+			// Parse the CSV fields
+			if ($line == 1) {
+				if ($data[1] != 'subdivision_name') {
+					throw new \Exception(__CLASS__ . ': Invalid region information CSV file.', self::EXCEPTION_INVALID_CSV);
+				}
+
+				$this->fields = $data;
+			} else {
+				$this->records[$data[0]][] = [
+					'code' => $data[2],
+					'name' => $data[1],
+				];
+			}
+
+			++$line;
+		}
+	}
+
+	/**
+	 * Get region code by country code and region name.
+	 *
+	 * @param string $countryCode The country ISO 3166 country code.
+	 * @param string $regionName  Region name.
+	 *
+	 * @throws \Exception
+	 *
+	 * @return string|null
+	 */
+	public function getRegionCode($countryCode, $regionName)
+	{
+		if (empty($this->records)) {
+			throw new \Exception(__CLASS__ . ': No record available.', self::EXCEPTION_NO_RECORD);
+		}
+
+		if (!isset($this->records[$countryCode])) {
+			return;
+		}
+
+		foreach ($this->records[$countryCode] as $record) {
+			if (strtoupper($regionName) == strtoupper($record['name'])) {
+				return $record['code'];
+			}
+		}
+	}
+}

+ 147 - 0
app/controller/apps/weather/vendor/IP2Location/src/WebService.php

@@ -0,0 +1,147 @@
+<?php
+
+namespace IP2Location;
+
+/**
+ * IP2Location web service class.
+ */
+class WebService
+{
+	/**
+	 * No cURL extension found.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_NO_CURL = 10001;
+
+	/**
+	 * Invalid API key format.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_INVALID_API_KEY = 10002;
+
+	/**
+	 * Web service error.
+	 *
+	 * @var int
+	 */
+	public const EXCEPTION_WEB_SERVICE_ERROR = 10003;
+	
+	private $apiKey;
+	private $package;
+	private $useSsl;
+
+	/**
+	 * Constructor.
+	 *
+	 * @param string $apiKey  API key of your IP2Location web service
+	 * @param string $package Supported IP2Location package from WS1 to WS24
+	 * @param bool   $useSsl  Enable or disabled HTTPS connection. HTTP is faster but less secure.
+	 *
+	 * @throws \Exception
+	 */
+	public function __construct($apiKey, $package = 'WS1', $useSsl = false)
+	{
+		if (!\extension_loaded('curl')) {
+			throw new \Exception(__CLASS__ . ": Please make sure your PHP setup has the 'curl' extension enabled.", self::EXCEPTION_NO_CURL);
+		}
+
+		if (!preg_match('/^[0-9A-Z]{10}$/', $apiKey) && $apiKey != 'demo') {
+			throw new \Exception(__CLASS__ . ': Please provide a valid IP2Location web service API key.', self::EXCEPTION_INVALID_API_KEY);
+		}
+
+		if (!preg_match('/^WS[0-9]+$/', $package)) {
+			$package = 'WS1';
+		}
+
+		$this->apiKey = $apiKey;
+		$this->package = $package;
+		$this->useSsl = $useSsl;
+	}
+
+	/**
+	 * This function will look the given IP address up in IP2Location web service.
+	 *
+	 * @param string $ip       IP address to look up
+	 * @param array  $addOns   Extra fields to return. Please refer to https://www.ip2location.com/web-service/ip2location
+	 * @param string $language the translation for continent, country, region and city name for the addon package
+	 *
+	 * @throws \Exception
+	 *
+	 * @return array|false
+	 */
+	public function lookup($ip, $addOns = [], $language = 'en')
+	{
+		$response = $this->httpRequest('http://api.ip2location.com/v2/?' . http_build_query([
+			'key'     => $this->apiKey,
+			'ip'      => $ip,
+			'package' => $this->package,
+			'addon'   => implode(',', $addOns),
+			'lang'    => $language,
+		]));
+
+		if (($data = json_decode($response, true)) === null) {
+			return false;
+		}
+
+		if ($data['response'] != 'OK') {
+			throw new \Exception(__CLASS__ . ': ' . $data['response'], self::EXCEPTION_WEB_SERVICE_ERROR);
+		}
+
+		return $data;
+	}
+
+	/**
+	 * Get the remaing credit in your IP2Location web service account.
+	 *
+	 * @return int
+	 */
+	public function getCredit()
+	{
+		$response = $this->httpRequest('http://api.ip2location.com/v2/?' . http_build_query([
+			'key'   => $this->apiKey,
+			'check' => true,
+		]));
+
+		if (($data = json_decode($response, true)) === null) {
+			return 0;
+		}
+
+		if (!isset($data['response'])) {
+			return 0;
+		}
+
+		return $data['response'];
+	}
+
+	/**
+	 * Open a remote web address.
+	 *
+	 * @param string $url Website URL
+	 *
+	 * @return bool|string
+	 */
+	private function httpRequest($url)
+	{
+		$ch = curl_init();
+		curl_setopt($ch, CURLOPT_URL, $url);
+		curl_setopt($ch, CURLOPT_FAILONERROR, 1);
+		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+		curl_setopt($ch, CURLOPT_TIMEOUT, 30);
+
+		$response = curl_exec($ch);
+
+		if (!curl_errno($ch)) {
+			curl_close($ch);
+
+			return $response;
+		}
+
+		curl_close($ch);
+
+		return false;
+	}
+}

+ 3 - 3
app/model/CardModel.php

@@ -12,13 +12,13 @@ class CardModel extends Model
 {
 {
     protected $name = "card";
     protected $name = "card";
     protected $pk = "id";
     protected $pk = "id";
-    static array $stopCard = [];
+    static $stopCard = [];
 
 
     public static function cardStatus($name_en = ''): bool
     public static function cardStatus($name_en = ''): bool
     {
     {
         $config = self::$stopCard;
         $config = self::$stopCard;
         if (count($config) == 0) {
         if (count($config) == 0) {
-            $config = self::cache('cardList', 60 * 60)->select()->toArray();
+            $config = self::select()->toArray();
             self::$stopCard = $config;
             self::$stopCard = $config;
         }
         }
         foreach ($config as $item) {
         foreach ($config as $item) {
@@ -35,7 +35,7 @@ class CardModel extends Model
     {
     {
         $config = self::$stopCard;
         $config = self::$stopCard;
         if (count($config) == 0) {
         if (count($config) == 0) {
-            $config = self::cache('cardList', 60 * 60)->select()->toArray();
+            $config = self::select()->toArray();
             self::$stopCard = $config;
             self::$stopCard = $config;
         }
         }
         foreach ($config as $item) {
         foreach ($config as $item) {

+ 1 - 0
app/model/FileModel.php

@@ -23,6 +23,7 @@ class FileModel extends Model
             $info["user_id"] = $user_id;
             $info["user_id"] = $user_id;
             $info['create_time'] = date("Y-m-d H:i:s");
             $info['create_time'] = date("Y-m-d H:i:s");
             $info['size'] = filesize($originPath);
             $info['size'] = filesize($originPath);
+            $info['hash'] = hash_file("md5", $originPath);
             $info["mime_type"] = mime_content_type($originPath);
             $info["mime_type"] = mime_content_type($originPath);
             self::insert($info);
             self::insert($info);
             return $info;
             return $info;

+ 18 - 1
app/model/LinkFolderModel.php

@@ -9,7 +9,24 @@ namespace app\model;
 
 
 use think\Model;
 use think\Model;
 
 
-class LinkFolderModel extends Model{
+class LinkFolderModel extends Model
+{
     protected $pk = 'id';
     protected $pk = 'id';
     protected $name = 'link_folder';
     protected $name = 'link_folder';
+
+    function setGroupIdsAttr($val): string
+    {
+        if (count($val) > 0) {
+            return join(',', $val);
+        }
+        return '0';
+    }
+
+    function getGroupIdsAttr($val): array
+    {
+        if (strlen($val)) {
+            return array_map('intval', explode(',', $val));
+        }
+        return [];
+    }
 }
 }

+ 15 - 0
app/model/LinkStoreModel.php

@@ -21,4 +21,19 @@ class LinkStoreModel extends Model
     {
     {
         return $this->hasOne(UserModel::class, 'id', 'user_id')->field('id,nickname');
         return $this->hasOne(UserModel::class, 'id', 'user_id')->field('id,nickname');
     }
     }
+    function setGroupIdsAttr($val): string
+    {
+        if (count($val) > 0) {
+            return join(',', $val);
+        }
+        return '0';
+    }
+
+    function getGroupIdsAttr($val): array
+    {
+        if (strlen($val)) {
+            return array_map('intval', explode(',', $val));
+        }
+        return [];
+    }
 }
 }

+ 13 - 0
app/model/NoteModel.php

@@ -4,10 +4,23 @@
 namespace app\model;
 namespace app\model;
 
 
 
 
+use DOMDocument;
+use Exception;
 use think\Model;
 use think\Model;
 
 
 class NoteModel extends Model
 class NoteModel extends Model
 {
 {
     protected $name = 'note';
     protected $name = 'note';
     protected $pk = 'id';
     protected $pk = 'id';
+
+    function getTextAttr($value): string
+    {
+        return modifyImageUrls($value, request()->root(true));
+    }
+
+    function setTextAttr($htmlContent)
+    {
+        return removeImagesUrls($htmlContent, request()->root(true));
+    }
+
 }
 }

+ 9 - 0
app/model/PluginsToDoFolderModel.php

@@ -0,0 +1,9 @@
+<?php
+namespace app\model;
+use think\Model;
+
+class PluginsToDoFolderModel extends Model
+{
+    protected $name = 'plugins_todo_folder';
+    protected $pk = 'id';
+}

+ 7 - 0
app/model/PluginsToDoModel.php

@@ -0,0 +1,7 @@
+<?php
+namespace app\model;
+class PluginsToDoModel extends \think\Model
+{
+    protected $name = 'plugins_todo';
+    protected $pk = 'id';
+}

+ 10 - 0
app/model/UserGroupModel.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace app\model;
+
+use think\Model;
+
+class UserGroupModel extends Model
+{
+    protected $name = 'user_group';
+}

+ 1 - 0
app/model/UserModel.php

@@ -38,6 +38,7 @@ class UserModel extends Model
             if ($user) {
             if ($user) {
                 $status = self::where('id', $user['user_id'])->find();
                 $status = self::where('id', $user['user_id'])->find();
                 if ($status && $status['status'] === 0) {
                 if ($status && $status['status'] === 0) {
+                    $user['group_id'] = $status['group_id'];
                     if (time() > ($user['create_time'] + 60 * 60 * 24 * 15)) {//如果创建时间大于15天则删除
                     if (time() > ($user['create_time'] + 60 * 60 * 24 * 15)) {//如果创建时间大于15天则删除
                         $user->delete();
                         $user->delete();
                     } else {
                     } else {

+ 2 - 0
app/service.php

@@ -2,6 +2,8 @@
 
 
 use app\AppService;
 use app\AppService;
 
 
+const un_code = 'YXV0aENvZGU=';
+const un_key = 'RXRhZy1BYzpqc29u';
 // 系统服务定义文件
 // 系统服务定义文件
 // 服务在完成全局初始化之后执行
 // 服务在完成全局初始化之后执行
 return [
 return [

+ 2 - 2
composer.json

@@ -29,7 +29,6 @@
     "ext-openssl": "*",
     "ext-openssl": "*",
     "nette/mail": "^3.1",
     "nette/mail": "^3.1",
     "ext-fileinfo": "*",
     "ext-fileinfo": "*",
-    "paquettg/php-html-parser": "^3.1",
     "topthink/think-filesystem": "^2.0",
     "topthink/think-filesystem": "^2.0",
     "ext-mysqli": "*",
     "ext-mysqli": "*",
     "ext-redis": "*",
     "ext-redis": "*",
@@ -39,7 +38,8 @@
     "ext-dom": "*",
     "ext-dom": "*",
     "ext-mbstring": "*",
     "ext-mbstring": "*",
     "ext-bcmath": "*",
     "ext-bcmath": "*",
-    "ext-gd": "*"
+    "ext-gd": "*",
+    "ext-libxml": "*"
   },
   },
   "require-dev": {
   "require-dev": {
     "symfony/var-dumper": "^4.2",
     "symfony/var-dumper": "^4.2",

+ 25 - 322
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
         "This file is @generated automatically"
     ],
     ],
-    "content-hash": "e87b0606ebfc7c83720051eaf1886bcd",
+    "content-hash": "2b29e33b042d2949a346e8b8beb1987d",
     "packages": [
     "packages": [
         {
         {
             "name": "guzzlehttp/guzzle",
             "name": "guzzlehttp/guzzle",
@@ -462,69 +462,6 @@
             ],
             ],
             "time": "2024-01-28T23:22:08+00:00"
             "time": "2024-01-28T23:22:08+00:00"
         },
         },
-        {
-            "name": "myclabs/php-enum",
-            "version": "1.8.4",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/myclabs/php-enum.git",
-                "reference": "a867478eae49c9f59ece437ae7f9506bfaa27483"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/myclabs/php-enum/zipball/a867478eae49c9f59ece437ae7f9506bfaa27483",
-                "reference": "a867478eae49c9f59ece437ae7f9506bfaa27483",
-                "shasum": ""
-            },
-            "require": {
-                "ext-json": "*",
-                "php": "^7.3 || ^8.0"
-            },
-            "require-dev": {
-                "phpunit/phpunit": "^9.5",
-                "squizlabs/php_codesniffer": "1.*",
-                "vimeo/psalm": "^4.6.2"
-            },
-            "type": "library",
-            "autoload": {
-                "psr-4": {
-                    "MyCLabs\\Enum\\": "src/"
-                },
-                "classmap": [
-                    "stubs/Stringable.php"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "PHP Enum contributors",
-                    "homepage": "https://github.com/myclabs/php-enum/graphs/contributors"
-                }
-            ],
-            "description": "PHP Enum implementation",
-            "homepage": "http://github.com/myclabs/php-enum",
-            "keywords": [
-                "enum"
-            ],
-            "support": {
-                "issues": "https://github.com/myclabs/php-enum/issues",
-                "source": "https://github.com/myclabs/php-enum/tree/1.8.4"
-            },
-            "funding": [
-                {
-                    "url": "https://github.com/mnapoli",
-                    "type": "github"
-                },
-                {
-                    "url": "https://tidelift.com/funding/github/packagist/myclabs/php-enum",
-                    "type": "tidelift"
-                }
-            ],
-            "time": "2022-08-04T09:53:51+00:00"
-        },
         {
         {
             "name": "nette/mail",
             "name": "nette/mail",
             "version": "v3.1.11",
             "version": "v3.1.11",
@@ -685,233 +622,6 @@
             },
             },
             "time": "2023-07-30T15:38:18+00:00"
             "time": "2023-07-30T15:38:18+00:00"
         },
         },
-        {
-            "name": "paquettg/php-html-parser",
-            "version": "3.1.1",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/paquettg/php-html-parser.git",
-                "reference": "4e01a438ad5961cc2d7427eb9798d213c8a12629"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/paquettg/php-html-parser/zipball/4e01a438ad5961cc2d7427eb9798d213c8a12629",
-                "reference": "4e01a438ad5961cc2d7427eb9798d213c8a12629",
-                "shasum": ""
-            },
-            "require": {
-                "ext-curl": "*",
-                "ext-mbstring": "*",
-                "ext-zlib": "*",
-                "guzzlehttp/guzzle": "^7.0",
-                "guzzlehttp/psr7": "^1.6",
-                "myclabs/php-enum": "^1.7",
-                "paquettg/string-encode": "~1.0.0",
-                "php": ">=7.2",
-                "php-http/httplug": "^2.1"
-            },
-            "require-dev": {
-                "friendsofphp/php-cs-fixer": "^2.16",
-                "infection/infection": "^0.13.4",
-                "mockery/mockery": "^1.2",
-                "phan/phan": "^2.4",
-                "phpunit/phpunit": "^7.5.1"
-            },
-            "type": "library",
-            "autoload": {
-                "psr-4": {
-                    "PHPHtmlParser\\": "src/PHPHtmlParser"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Gilles Paquette",
-                    "email": "paquettg@gmail.com",
-                    "homepage": "http://gillespaquette.ca"
-                }
-            ],
-            "description": "An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery.",
-            "homepage": "https://github.com/paquettg/php-html-parser",
-            "keywords": [
-                "dom",
-                "html",
-                "parser"
-            ],
-            "support": {
-                "issues": "https://github.com/paquettg/php-html-parser/issues",
-                "source": "https://github.com/paquettg/php-html-parser/tree/3.1.1"
-            },
-            "funding": [
-                {
-                    "url": "https://tidelift.com/funding/github/packagist/paquettg/php-html-parser",
-                    "type": "tidelift"
-                }
-            ],
-            "time": "2020-11-01T20:34:43+00:00"
-        },
-        {
-            "name": "paquettg/string-encode",
-            "version": "1.0.1",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/paquettg/string-encoder.git",
-                "reference": "a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/paquettg/string-encoder/zipball/a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee",
-                "reference": "a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=7.1"
-            },
-            "require-dev": {
-                "phpunit/phpunit": "^7.5.1"
-            },
-            "type": "library",
-            "autoload": {
-                "psr-0": {
-                    "stringEncode": "src/"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Gilles Paquette",
-                    "email": "paquettg@gmail.com",
-                    "homepage": "http://gillespaquette.ca"
-                }
-            ],
-            "description": "Facilitating the process of altering string encoding in PHP.",
-            "homepage": "https://github.com/paquettg/string-encoder",
-            "keywords": [
-                "charset",
-                "encoding",
-                "string"
-            ],
-            "support": {
-                "issues": "https://github.com/paquettg/string-encoder/issues",
-                "source": "https://github.com/paquettg/string-encoder/tree/1.0.1"
-            },
-            "time": "2018-12-21T02:25:09+00:00"
-        },
-        {
-            "name": "php-http/httplug",
-            "version": "2.4.0",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/php-http/httplug.git",
-                "reference": "625ad742c360c8ac580fcc647a1541d29e257f67"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/php-http/httplug/zipball/625ad742c360c8ac580fcc647a1541d29e257f67",
-                "reference": "625ad742c360c8ac580fcc647a1541d29e257f67",
-                "shasum": ""
-            },
-            "require": {
-                "php": "^7.1 || ^8.0",
-                "php-http/promise": "^1.1",
-                "psr/http-client": "^1.0",
-                "psr/http-message": "^1.0 || ^2.0"
-            },
-            "require-dev": {
-                "friends-of-phpspec/phpspec-code-coverage": "^4.1 || ^5.0 || ^6.0",
-                "phpspec/phpspec": "^5.1 || ^6.0 || ^7.0"
-            },
-            "type": "library",
-            "autoload": {
-                "psr-4": {
-                    "Http\\Client\\": "src/"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Eric GELOEN",
-                    "email": "geloen.eric@gmail.com"
-                },
-                {
-                    "name": "Márk Sági-Kazár",
-                    "email": "mark.sagikazar@gmail.com",
-                    "homepage": "https://sagikazarmark.hu"
-                }
-            ],
-            "description": "HTTPlug, the HTTP client abstraction for PHP",
-            "homepage": "http://httplug.io",
-            "keywords": [
-                "client",
-                "http"
-            ],
-            "support": {
-                "issues": "https://github.com/php-http/httplug/issues",
-                "source": "https://github.com/php-http/httplug/tree/2.4.0"
-            },
-            "time": "2023-04-14T15:10:03+00:00"
-        },
-        {
-            "name": "php-http/promise",
-            "version": "1.3.1",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/php-http/promise.git",
-                "reference": "fc85b1fba37c169a69a07ef0d5a8075770cc1f83"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/php-http/promise/zipball/fc85b1fba37c169a69a07ef0d5a8075770cc1f83",
-                "reference": "fc85b1fba37c169a69a07ef0d5a8075770cc1f83",
-                "shasum": ""
-            },
-            "require": {
-                "php": "^7.1 || ^8.0"
-            },
-            "require-dev": {
-                "friends-of-phpspec/phpspec-code-coverage": "^4.3.2 || ^6.3",
-                "phpspec/phpspec": "^5.1.2 || ^6.2 || ^7.4"
-            },
-            "type": "library",
-            "autoload": {
-                "psr-4": {
-                    "Http\\Promise\\": "src/"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Joel Wurtz",
-                    "email": "joel.wurtz@gmail.com"
-                },
-                {
-                    "name": "Márk Sági-Kazár",
-                    "email": "mark.sagikazar@gmail.com"
-                }
-            ],
-            "description": "Promise used for asynchronous HTTP requests",
-            "homepage": "http://httplug.io",
-            "keywords": [
-                "promise"
-            ],
-            "support": {
-                "issues": "https://github.com/php-http/promise/issues",
-                "source": "https://github.com/php-http/promise/tree/1.3.1"
-            },
-            "time": "2024-03-15T13:55:21+00:00"
-        },
         {
         {
             "name": "psr/container",
             "name": "psr/container",
             "version": "1.1.2",
             "version": "1.1.2",
@@ -1575,20 +1285,20 @@
     "packages-dev": [
     "packages-dev": [
         {
         {
             "name": "symfony/polyfill-mbstring",
             "name": "symfony/polyfill-mbstring",
-            "version": "v1.30.0",
+            "version": "v1.31.0",
             "source": {
             "source": {
                 "type": "git",
                 "type": "git",
                 "url": "https://github.com/symfony/polyfill-mbstring.git",
                 "url": "https://github.com/symfony/polyfill-mbstring.git",
-                "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c"
+                "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341"
             },
             },
             "dist": {
             "dist": {
                 "type": "zip",
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c",
-                "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c",
+                "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341",
+                "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341",
                 "shasum": ""
                 "shasum": ""
             },
             },
             "require": {
             "require": {
-                "php": ">=7.1"
+                "php": ">=7.2"
             },
             },
             "provide": {
             "provide": {
                 "ext-mbstring": "*"
                 "ext-mbstring": "*"
@@ -1635,7 +1345,7 @@
                 "shim"
                 "shim"
             ],
             ],
             "support": {
             "support": {
-                "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0"
+                "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0"
             },
             },
             "funding": [
             "funding": [
                 {
                 {
@@ -1651,40 +1361,32 @@
                     "type": "tidelift"
                     "type": "tidelift"
                 }
                 }
             ],
             ],
-            "time": "2024-06-19T12:30:46+00:00"
+            "time": "2024-09-09T11:45:10+00:00"
         },
         },
         {
         {
             "name": "symfony/polyfill-php72",
             "name": "symfony/polyfill-php72",
-            "version": "v1.30.0",
+            "version": "v1.31.0",
             "source": {
             "source": {
                 "type": "git",
                 "type": "git",
                 "url": "https://github.com/symfony/polyfill-php72.git",
                 "url": "https://github.com/symfony/polyfill-php72.git",
-                "reference": "10112722600777e02d2745716b70c5db4ca70442"
+                "reference": "fa2ae56c44f03bed91a39bfc9822e31e7c5c38ce"
             },
             },
             "dist": {
             "dist": {
                 "type": "zip",
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/10112722600777e02d2745716b70c5db4ca70442",
-                "reference": "10112722600777e02d2745716b70c5db4ca70442",
+                "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/fa2ae56c44f03bed91a39bfc9822e31e7c5c38ce",
+                "reference": "fa2ae56c44f03bed91a39bfc9822e31e7c5c38ce",
                 "shasum": ""
                 "shasum": ""
             },
             },
             "require": {
             "require": {
-                "php": ">=7.1"
+                "php": ">=7.2"
             },
             },
-            "type": "library",
+            "type": "metapackage",
             "extra": {
             "extra": {
                 "thanks": {
                 "thanks": {
                     "name": "symfony/polyfill",
                     "name": "symfony/polyfill",
                     "url": "https://github.com/symfony/polyfill"
                     "url": "https://github.com/symfony/polyfill"
                 }
                 }
             },
             },
-            "autoload": {
-                "files": [
-                    "bootstrap.php"
-                ],
-                "psr-4": {
-                    "Symfony\\Polyfill\\Php72\\": ""
-                }
-            },
             "notification-url": "https://packagist.org/downloads/",
             "notification-url": "https://packagist.org/downloads/",
             "license": [
             "license": [
                 "MIT"
                 "MIT"
@@ -1708,7 +1410,7 @@
                 "shim"
                 "shim"
             ],
             ],
             "support": {
             "support": {
-                "source": "https://github.com/symfony/polyfill-php72/tree/v1.30.0"
+                "source": "https://github.com/symfony/polyfill-php72/tree/v1.31.0"
             },
             },
             "funding": [
             "funding": [
                 {
                 {
@@ -1724,24 +1426,24 @@
                     "type": "tidelift"
                     "type": "tidelift"
                 }
                 }
             ],
             ],
-            "time": "2024-06-19T12:30:46+00:00"
+            "time": "2024-09-09T11:45:10+00:00"
         },
         },
         {
         {
             "name": "symfony/polyfill-php80",
             "name": "symfony/polyfill-php80",
-            "version": "v1.30.0",
+            "version": "v1.31.0",
             "source": {
             "source": {
                 "type": "git",
                 "type": "git",
                 "url": "https://github.com/symfony/polyfill-php80.git",
                 "url": "https://github.com/symfony/polyfill-php80.git",
-                "reference": "77fa7995ac1b21ab60769b7323d600a991a90433"
+                "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8"
             },
             },
             "dist": {
             "dist": {
                 "type": "zip",
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/77fa7995ac1b21ab60769b7323d600a991a90433",
-                "reference": "77fa7995ac1b21ab60769b7323d600a991a90433",
+                "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
+                "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
                 "shasum": ""
                 "shasum": ""
             },
             },
             "require": {
             "require": {
-                "php": ">=7.1"
+                "php": ">=7.2"
             },
             },
             "type": "library",
             "type": "library",
             "extra": {
             "extra": {
@@ -1788,7 +1490,7 @@
                 "shim"
                 "shim"
             ],
             ],
             "support": {
             "support": {
-                "source": "https://github.com/symfony/polyfill-php80/tree/v1.30.0"
+                "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0"
             },
             },
             "funding": [
             "funding": [
                 {
                 {
@@ -1804,7 +1506,7 @@
                     "type": "tidelift"
                     "type": "tidelift"
                 }
                 }
             ],
             ],
-            "time": "2024-05-31T15:07:36+00:00"
+            "time": "2024-09-09T11:45:10+00:00"
         },
         },
         {
         {
             "name": "symfony/var-dumper",
             "name": "symfony/var-dumper",
@@ -1965,7 +1667,8 @@
         "ext-dom": "*",
         "ext-dom": "*",
         "ext-mbstring": "*",
         "ext-mbstring": "*",
         "ext-bcmath": "*",
         "ext-bcmath": "*",
-        "ext-gd": "*"
+        "ext-gd": "*",
+        "ext-libxml": "*"
     },
     },
     "platform-dev": [],
     "platform-dev": [],
     "plugin-api-version": "2.0.0"
     "plugin-api-version": "2.0.0"

+ 1 - 1
config/console.php

@@ -7,6 +7,6 @@ return [
     'commands' => [
     'commands' => [
         'repair' => 'app\command\repair',
         'repair' => 'app\command\repair',
         'repass' => 'app\command\repass',
         'repass' => 'app\command\repass',
-        'test' => 'app\command\test',
+        'upgrade' => 'app\command\upgrade',
     ],
     ],
 ];
 ];

+ 2 - 8
docker-compose.yaml

@@ -8,17 +8,11 @@ services:
     volumes:
     volumes:
       - ./:/app
       - ./:/app
     environment:
     environment:
-      MYSQL_HOST: 127.0.0.1
+      MYSQL_HOST: 172.17.0.1
       MYSQL_USER: root
       MYSQL_USER: root
       MYSQL_PORT: 3306
       MYSQL_PORT: 3306
       MYSQL_PASSWORD: 123456
       MYSQL_PASSWORD: 123456
-      MYSQL_DATABASE: mtaber
+      MYSQL_DATABASE: mtab
       ADMIN_USER: admin
       ADMIN_USER: admin
       ADMIN_PASSWORD: admin
       ADMIN_PASSWORD: admin
     restart: always
     restart: always
-    networks:
-      - my-network
-networks:
-  my-network:
-    driver: baota_net
-

+ 1 - 1
docker/default.conf

@@ -14,7 +14,7 @@ server {
             include fastcgi.conf;
             include fastcgi.conf;
     }
     }
 
 
-    location ~^/ {
+	location ~^/ {
     	if (!-e $request_filename){
     	if (!-e $request_filename){
     		rewrite  ^(.*)$  /index.php?s=$1  last;
     		rewrite  ^(.*)$  /index.php?s=$1  last;
     	}
     	}

+ 4 - 1
docker/install.sh

@@ -1,5 +1,6 @@
 #!/bin/sh
 #!/bin/sh
 
 
+
 apk add php7 php7-pdo_mysql php7-xml php7-xmlrpc php7-openssl php7-posix php7-pcntl php7-sqlite3 php7-pdo_sqlite php7-curl php7-json php7-session php7-phar php7-iconv php7-mbstring php7-fileinfo php7-exif php7-redis php7-gd php7-pecl-imagick-dev php7-pecl-imagick php7-mysqlnd php7-mysqli php7-ctype php7-gmp php7-redis composer unzip  php7-xmlreader php7-xmlwriter php7-dom php7-fpm
 apk add php7 php7-pdo_mysql php7-xml php7-xmlrpc php7-openssl php7-posix php7-pcntl php7-sqlite3 php7-pdo_sqlite php7-curl php7-json php7-session php7-phar php7-iconv php7-mbstring php7-fileinfo php7-exif php7-redis php7-gd php7-pecl-imagick-dev php7-pecl-imagick php7-mysqlnd php7-mysqli php7-ctype php7-gmp php7-redis composer unzip  php7-xmlreader php7-xmlwriter php7-dom php7-fpm
 
 
 apk add php7-simplexml
 apk add php7-simplexml
@@ -45,4 +46,6 @@ fi
 
 
 rm -rf /www/docker/*
 rm -rf /www/docker/*
 rm -r /www/docker
 rm -r /www/docker
-rm /www/Dockerfile
+rm /www/Dockerfile
+
+dos2unix /start.sh

+ 9 - 6
extend/Mail.php

@@ -9,17 +9,20 @@ class Mail
     public static function send($to = "", $text = ""): bool
     public static function send($to = "", $text = ""): bool
     {
     {
         $mail = new Message;
         $mail = new Message;
-        $send_mail = SettingModel::Config('smtp_email');
-        $mail->setFrom(SettingModel::Config('title', '') . " <$send_mail>")
-            ->addTo($to)
-            ->setSubject(SettingModel::Config('title', '') . '动态令牌')
-            ->setHtmlBody($text);
+        $send_mail = SettingModel::Config('smtp_email',false);
         $option = [
         $option = [
             'port' => SettingModel::Config('smtp_port'),
             'port' => SettingModel::Config('smtp_port'),
-            'host' => SettingModel::Config('smtp_host'),
+            'host' => SettingModel::Config('smtp_host',false),
             'username' => SettingModel::Config('smtp_email'),
             'username' => SettingModel::Config('smtp_email'),
             'password' => SettingModel::Config('smtp_password'),
             'password' => SettingModel::Config('smtp_password'),
         ];
         ];
+        if (!$send_mail || !$option['host']) {
+            return abort(0, "管理员没有配置SMTP邮件服务");
+        }
+        $mail->setFrom(SettingModel::Config('title', '') . " <$send_mail>")
+            ->addTo($to)
+            ->setSubject(SettingModel::Config('title', '') . '动态令牌')
+            ->setHtmlBody($text);
         if ((int)$option['port'] === 465) {
         if ((int)$option['port'] === 465) {
             $option['secure'] = 'ssl';
             $option['secure'] = 'ssl';
         }
         }

+ 6 - 6
extend/PluginsInstall.php

@@ -5,12 +5,12 @@ ini_set('memory_limit', '500M');
 
 
 class PluginsInstall
 class PluginsInstall
 {
 {
-    protected string $archiveFile = '';//升级文件地址
-    protected string $extractPath = '';//解压目录地址
-    protected string $root_path = '';//程序根目录
-    public string $download = '';//升级zip文件下载地址
-    protected string $directory = '';//插件目录名称
-    protected string $update_sql = '';//升级sql文件地址
+    protected  $archiveFile = '';//升级文件地址
+    protected  $extractPath = '';//解压目录地址
+    protected  $root_path = '';//程序根目录
+    public  $download = '';//升级zip文件下载地址
+    protected  $directory = '';//插件目录名称
+    protected  $update_sql = '';//升级sql文件地址
 
 
     //构造方法初始化一些数据
     //构造方法初始化一些数据
     function __construct($info)
     function __construct($info)

+ 59 - 8
extend/Upgrade2.php

@@ -1,6 +1,7 @@
 <?php
 <?php
 ini_set('max_execution_time', 0);
 ini_set('max_execution_time', 0);
 ini_set('memory_limit', '500M');
 ini_set('memory_limit', '500M');
+
 class Upgrade2
 class Upgrade2
 {
 {
     protected string $archiveFile = "";//升级文件地址
     protected string $archiveFile = "";//升级文件地址
@@ -9,6 +10,7 @@ class Upgrade2
     public string $update_download_url = "";//升级zip文件下载地址
     public string $update_download_url = "";//升级zip文件下载地址
     public string $update_sql_url = "";//升级sql脚本文件地址
     public string $update_sql_url = "";//升级sql脚本文件地址
     public string $update_script = "";//升级后执行的脚本地址
     public string $update_script = "";//升级后执行的脚本地址
+    protected bool $isLog = false;
 
 
     //构造方法初始化一些数据
     //构造方法初始化一些数据
     function __construct($update_download_url = null, $update_sql_url = null, $update_script = null)
     function __construct($update_download_url = null, $update_sql_url = null, $update_script = null)
@@ -28,41 +30,59 @@ class Upgrade2
     }
     }
 
 
     //运行入口
     //运行入口
-    function run(): bool
+    function run($cli = false): bool
     {
     {
+        if ($cli) {
+            $this->isLog = true;
+        }
         return $this->startUpgrade();
         return $this->startUpgrade();
     }
     }
 
 
+    public function log($msg)
+    {
+        if ($this->isLog) {
+            print_r($msg . "\n");
+        }
+    }
+
     //新的进程启动升级
     //新的进程启动升级
-    private function startUpgrade()
+    private function startUpgrade(): bool
     {
     {
         //如果有程序代码的更新资源则更新程序代码
         //如果有程序代码的更新资源则更新程序代码
         if (strlen($this->update_download_url) > 1) {
         if (strlen($this->update_download_url) > 1) {
             //如果有遗留的解压资源则删除
             //如果有遗留的解压资源则删除
+            $this->log("正在检查是否有旧版本的安装包,并删除。");
             $this->deleteDirectory("{$this->extractPath}mtab");
             $this->deleteDirectory("{$this->extractPath}mtab");
             //如果存在旧的升级包则删除
             //如果存在旧的升级包则删除
             $this->delZip();
             $this->delZip();
             //下载远程更新包
             //下载远程更新包
-            if(!$this->fileDownload()){
+            $this->log("正在下载升级包...");
+            if (!$this->fileDownload()) {
+                $this->log('资源下载失败');
                 abort(0, '资源下载失败');
                 abort(0, '资源下载失败');
             }
             }
             //解压升级包
             //解压升级包
+            $this->log("正在解压升级包...");
             if (!$this->unzip($this->archiveFile, $this->extractPath)) {
             if (!$this->unzip($this->archiveFile, $this->extractPath)) {
                 $this->delZip();
                 $this->delZip();
                 abort(0, '升级资源包解压失败');
                 abort(0, '升级资源包解压失败');
             }
             }
-            $this->deleteDirectory(public_path().'dist/');//删除旧的网站文件
+            $this->log("正在更新程序...");
+            $this->deleteDirectory(public_path() . 'dist/');//删除旧的网站文件
             //拷贝覆盖
             //拷贝覆盖
             $this->copy();
             $this->copy();
             //删除下载的更新包
             //删除下载的更新包
+            $this->log("正在删除升级包...");
             $this->delZip();
             $this->delZip();
             //更新完后的一些操作
             //更新完后的一些操作
         }
         }
         //如果有数据库的更新资源则更新程序代码
         //如果有数据库的更新资源则更新程序代码
         if (strlen($this->update_sql_url) > 1) {
         if (strlen($this->update_sql_url) > 1) {
+            $this->log("正在更新数据库...");
             $this->updateSql();
             $this->updateSql();
         }
         }
         if (file_exists("{$this->root_path}install.sql")) {
         if (file_exists("{$this->root_path}install.sql")) {
+            $this->log("正在更新数据库...");
             $this->updateSql("{$this->root_path}install.sql");
             $this->updateSql("{$this->root_path}install.sql");
         }
         }
         //退出
         //退出
@@ -71,21 +91,52 @@ class Upgrade2
 
 
     private function fileDownload(): bool
     private function fileDownload(): bool
     {
     {
+        $length = 0;
         try {
         try {
             $f = fopen($this->update_download_url, 'r');
             $f = fopen($this->update_download_url, 'r');
             $w = fopen($this->archiveFile, 'wb+');
             $w = fopen($this->archiveFile, 'wb+');
+            $fileSize = $this->getFileSize($this->update_download_url);
             do {
             do {
-                $a = fread($f, 1024);
+                $a = fread($f, 1024 * 64);
+                $length += strlen($a);
                 fwrite($w, $a);
                 fwrite($w, $a);
+                // 计算下载进度
+                $progress = ($fileSize > 0) ? round($length / $fileSize * 100, 2) : 0;
+                // 打印进度条,在一行内更新
+                if ($this->isLog) {
+                    if ($progress <= 100) {
+                        $this->printProgress((int)$progress);
+                    }
+                }
             } while ($a);
             } while ($a);
             fclose($w);
             fclose($w);
             fclose($f);
             fclose($f);
+            $this->log("\n下载完成");
         } catch (ErrorException $e) {
         } catch (ErrorException $e) {
             return false;
             return false;
         }
         }
         return true;
         return true;
     }
     }
 
 
+    private function printProgress(float $progress)
+    {
+        try {
+            $barLength = 50; // 进度条的总长度
+            $completed = round($progress / 100 * $barLength); // 完成的部分
+            $bar = str_repeat('=', $completed) . str_repeat(' ', max($barLength - $completed, 0)); // 拼接进度条
+            echo "\r[" . $bar . "] " . $progress . "%";
+        } catch (Exception $e) {
+
+        }
+    }
+
+    private function getFileSize(string $url): int
+    {
+        // 使用 HEAD 请求获取文件大小
+        $headers = get_headers($url, 1);
+        return isset($headers['Content-Length']) ? (int)$headers['Content-Length'] : 0;
+    }
+
     //删除升级包
     //删除升级包
     function delZip()
     function delZip()
     {
     {
@@ -108,11 +159,11 @@ class Upgrade2
     }
     }
 
 
     //升级的数据库
     //升级的数据库
-    function updateSql($path=null)
+    function updateSql($path = null)
     {
     {
-        if($path){
+        if ($path) {
             $f = fopen($path, 'r');
             $f = fopen($path, 'r');
-        }else{
+        } else {
             $f = fopen($this->update_sql_url, 'r');
             $f = fopen($this->update_sql_url, 'r');
         }
         }
         $sql = "";
         $sql = "";

+ 99 - 0
extend/main.go

@@ -0,0 +1,99 @@
+package main
+
+import (
+	"archive/zip"
+	"flag"
+	"fmt"
+	"io"
+	"os"
+	"path/filepath"
+	"strings"
+)
+
+// Unzip 解压 zip 文件到指定目录
+func Unzip(src, dest string) error {
+	r, err := zip.OpenReader(src)
+	if err != nil {
+		return err
+	}
+	defer func(r *zip.ReadCloser) {
+		err := r.Close()
+		if err != nil {
+			fmt.Println("关闭 zip 文件失败:", err)
+		}
+	}(r)
+
+	for _, f := range r.File {
+		fpath := filepath.Join(dest, f.Name)
+
+		// 检查文件夹层级,防止目录遍历漏洞
+		if !strings.HasPrefix(fpath, filepath.Clean(dest)+string(os.PathSeparator)) {
+			return fmt.Errorf("非法文件路径: %s", fpath)
+		}
+
+		if f.FileInfo().IsDir() {
+			// 创建文件夹
+			if err := os.MkdirAll(fpath, os.ModePerm); err != nil {
+				return err
+			}
+			continue
+		}
+
+		// 创建包含文件的父级目录
+		if err := os.MkdirAll(filepath.Dir(fpath), os.ModePerm); err != nil {
+			return err
+		}
+
+		// 打开目标文件
+		outFile, err := os.OpenFile(fpath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode())
+		if err != nil {
+			return err
+		}
+		defer func(outFile *os.File) {
+			err := outFile.Close()
+			if err != nil {
+				fmt.Println("关闭目标文件失败:", err)
+			}
+		}(outFile)
+
+		// 打开 zip 内的文件
+		rc, err := f.Open()
+		if err != nil {
+			return err
+		}
+		defer func(rc io.ReadCloser) {
+			err := rc.Close()
+			if err != nil {
+				fmt.Println("关闭 zip 文件失败:", err)
+			}
+		}(rc)
+
+		// 将内容复制到目标文件
+		if _, err := io.Copy(outFile, rc); err != nil {
+			return err
+		}
+	}
+	return nil
+}
+
+func main() {
+	// 定义命令行参数
+	src := flag.String("f", "", "源 ZIP 文件路径")
+	dest := flag.String("d", "", "解压到的目标文件夹路径")
+
+	// 解析命令行参数
+	flag.Parse()
+
+	// 检查参数是否提供
+	if *src == "" || *dest == "" {
+		fmt.Println("用法: go run main.go -f <压缩包路径> -d <解压路径>")
+		return
+	}
+
+	err := Unzip(*src, *dest)
+	if err != nil {
+		fmt.Println("解压失败:", err)
+	} else {
+		fmt.Println("解压成功!")
+	}
+}

BIN
extend/unzip


+ 164 - 17
install.sql

@@ -4,7 +4,8 @@ create table if not exists card
 (
 (
     id int auto_increment
     id int auto_increment
         primary key
         primary key
-) character set  utf8mb4 collate utf8mb4_general_ci comment '卡片数据表';
+) character set utf8mb4
+  collate utf8mb4_general_ci comment '卡片数据表';
 
 
 
 
 alter table card
 alter table card
@@ -46,13 +47,20 @@ alter table card
 alter table card
 alter table card
     add dict_option longtext null comment '配置的参数';
     add dict_option longtext null comment '配置的参数';
 
 
+alter table card
+    add constraint card_pk
+        unique (name_en);
+
+create index card_name_en_index
+    on card (name_en);
 
 
 #创建config数据表
 #创建config数据表
 
 
 create table if not exists config
 create table if not exists config
 (
 (
     user_id int null
     user_id int null
-) character set  utf8mb4 collate utf8mb4_general_ci comment '用户配置数据表';
+) character set utf8mb4
+  collate utf8mb4_general_ci comment '用户配置数据表';
 
 
 create index config_user_id_index
 create index config_user_id_index
     on config (user_id);
     on config (user_id);
@@ -66,7 +74,8 @@ create table if not exists file
 (
 (
     id bigint auto_increment
     id bigint auto_increment
         primary key
         primary key
-) character set  utf8mb4 collate utf8mb4_general_ci comment '文件';
+) character set utf8mb4
+  collate utf8mb4_general_ci comment '文件';
 
 
 alter table file
 alter table file
     add path varchar(255) null;
     add path varchar(255) null;
@@ -83,6 +92,8 @@ alter table file
 alter table file
 alter table file
     add mime_type varchar(100) null comment '文件类型';
     add mime_type varchar(100) null comment '文件类型';
 
 
+alter table file
+    add hash varchar(100) null comment '文件哈希';
 
 
 
 
 #创建history数据表
 #创建history数据表
@@ -94,7 +105,8 @@ create table if not exists history
 
 
     constraint history_id_uindex
     constraint history_id_uindex
         unique (id)
         unique (id)
-)  character set  utf8mb4 collate utf8mb4_general_ci comment 'link历史数据';
+) character set utf8mb4
+  collate utf8mb4_general_ci comment 'link历史数据';
 
 
 alter table history
 alter table history
     add user_id int null;
     add user_id int null;
@@ -111,7 +123,8 @@ alter table history
 create table if not exists link
 create table if not exists link
 (
 (
     user_id int null
     user_id int null
-) character set  utf8mb4 collate utf8mb4_general_ci;
+) character set utf8mb4
+  collate utf8mb4_general_ci;
 
 
 create index link_user_id_index
 create index link_user_id_index
     on link (user_id);
     on link (user_id);
@@ -130,7 +143,8 @@ create table if not exists link_folder
 (
 (
     id int auto_increment comment 'id'
     id int auto_increment comment 'id'
         primary key
         primary key
-) character set  utf8mb4 collate utf8mb4_general_ci comment '标签链接分类';
+) character set utf8mb4
+  collate utf8mb4_general_ci comment '标签链接分类';
 
 
 alter table link_folder
 alter table link_folder
     add name varchar(50) null comment '分类名称';
     add name varchar(50) null comment '分类名称';
@@ -138,6 +152,8 @@ alter table link_folder
 alter table link_folder
 alter table link_folder
     add sort int default 0 null;
     add sort int default 0 null;
 
 
+alter table link_folder
+    add group_ids varchar(200) default '0' null comment '可见用户分组';
 
 
 #创建link_store数据表
 #创建link_store数据表
 
 
@@ -147,7 +163,8 @@ create table if not exists linkstore
         primary key,
         primary key,
     constraint linkStore_id_uindex
     constraint linkStore_id_uindex
         unique (id)
         unique (id)
-)  character set  utf8mb4 collate utf8mb4_general_ci;
+) character set utf8mb4
+  collate utf8mb4_general_ci;
 
 
 alter table linkstore
 alter table linkstore
     add name varchar(255) null;
     add name varchar(255) null;
@@ -200,7 +217,8 @@ alter table linkstore
 alter table linkstore
 alter table linkstore
     add status int default 1 null comment '状态 1=展示 0=待审核';
     add status int default 1 null comment '状态 1=展示 0=待审核';
 
 
-
+alter table linkstore
+    add group_ids varchar(200) default '0' null comment '可见用户分组';
 
 
 
 
 #创建note数据表
 #创建note数据表
@@ -211,7 +229,8 @@ create table if not exists note
         primary key,
         primary key,
     constraint note_id_uindex
     constraint note_id_uindex
         unique (id)
         unique (id)
-)  character set  utf8mb4 collate utf8mb4_general_ci;
+) character set utf8mb4
+  collate utf8mb4_general_ci;
 
 
 alter table note
 alter table note
     add user_id bigint null;
     add user_id bigint null;
@@ -240,7 +259,8 @@ create table if not exists search_engine
 (
 (
     id int auto_increment
     id int auto_increment
         primary key
         primary key
-) character set  utf8mb4 collate utf8mb4_general_ci comment '搜索引擎';
+) character set utf8mb4
+  collate utf8mb4_general_ci comment '搜索引擎';
 
 
 alter table search_engine
 alter table search_engine
     add name varchar(50) null comment '名称';
     add name varchar(50) null comment '名称';
@@ -270,7 +290,8 @@ create table if not exists setting
 (
 (
     `keys` varchar(200) not null
     `keys` varchar(200) not null
         primary key
         primary key
-) character set  utf8mb4 collate utf8mb4_general_ci;
+) character set utf8mb4
+  collate utf8mb4_general_ci;
 
 
 alter table setting
 alter table setting
     add value text null;
     add value text null;
@@ -280,7 +301,8 @@ alter table setting
 create table if not exists tabbar
 create table if not exists tabbar
 (
 (
     user_id int null
     user_id int null
-) character set  utf8mb4 collate utf8mb4_general_ci comment '用户页脚信息';
+) character set utf8mb4
+  collate utf8mb4_general_ci comment '用户页脚信息';
 
 
 alter table tabbar
 alter table tabbar
     add tabs longtext null;
     add tabs longtext null;
@@ -296,7 +318,8 @@ create table if not exists token
         primary key,
         primary key,
     constraint token_id_uindex
     constraint token_id_uindex
         unique (id)
         unique (id)
-) character set  utf8mb4 collate utf8mb4_general_ci;
+) character set utf8mb4
+  collate utf8mb4_general_ci;
 
 
 alter table token
 alter table token
     add user_id int null;
     add user_id int null;
@@ -325,7 +348,8 @@ create table if not exists user
         primary key,
         primary key,
     constraint user_id_uindex
     constraint user_id_uindex
         unique (id)
         unique (id)
-) character set  utf8mb4 collate utf8mb4_general_ci;
+) character set utf8mb4
+  collate utf8mb4_general_ci;
 
 
 alter table user
 alter table user
     add avatar varchar(255) null comment '头像';
     add avatar varchar(255) null comment '头像';
@@ -366,6 +390,19 @@ alter table user
 alter table user
 alter table user
     add active date null comment '今日是否活跃';
     add active date null comment '今日是否活跃';
 
 
+alter table user
+    add group_id bigint default 0 null;
+
+alter table user
+    add constraint user_pk
+        unique (mail);
+
+alter table user
+    add constraint user_pk_2
+        unique (qq_open_id);
+
+
+
 #创建user_search_engine表
 #创建user_search_engine表
 
 
 create table if not exists user_search_engine
 create table if not exists user_search_engine
@@ -374,7 +411,8 @@ create table if not exists user_search_engine
         primary key,
         primary key,
     constraint user_search_engine_pk
     constraint user_search_engine_pk
         unique (user_id)
         unique (user_id)
-) character set  utf8mb4 collate utf8mb4_general_ci comment '用户搜索引擎同步表';
+) character set utf8mb4
+  collate utf8mb4_general_ci comment '用户搜索引擎同步表';
 
 
 alter table user_search_engine
 alter table user_search_engine
     add list longtext null;
     add list longtext null;
@@ -386,7 +424,8 @@ create table if not exists wallpaper
 (
 (
     id int auto_increment
     id int auto_increment
         primary key
         primary key
-) character set  utf8mb4 collate utf8mb4_general_ci;
+) character set utf8mb4
+  collate utf8mb4_general_ci;
 
 
 alter table wallpaper
 alter table wallpaper
     add type int null comment '1=folder;0=assets';
     add type int null comment '1=folder;0=assets';
@@ -412,4 +451,112 @@ alter table wallpaper
 alter table wallpaper
 alter table wallpaper
     add sort int default 999 null;
     add sort int default 999 null;
 
 
-##创建结束
+
+create table user_group
+(
+    id bigint auto_increment comment '自增ID',
+    constraint user_group_pk
+        primary key (id)
+)
+    comment '用户分组';
+
+alter table user_group
+    add name varchar(50) not null comment '分组名称';
+
+alter table user_group
+    add create_time datetime null comment '创建时间';
+
+alter table user_group
+    add sort int default 0 null comment '排序';
+
+
+##创建结束
+
+
+##卡片组件安装部分
+
+# 创建待办内容数据表
+
+create table if not exists plugins_todo
+(
+    id int auto_increment
+        primary key
+) comment '待办事项';
+
+
+alter table plugins_todo
+    add status int default 0 null comment '状态1=完成,0=未完成';
+
+alter table plugins_todo
+    add user_id int null;
+
+alter table plugins_todo
+    add create_time datetime null;
+
+alter table plugins_todo
+    add expire_time datetime null;
+
+alter table plugins_todo
+    add todo text(1000) null;
+
+alter table plugins_todo
+    add weight int null comment '重要程度 1-6 颜色划分';
+
+alter table plugins_todo
+    add folder varchar(20) null comment 'today=今天;week=最近七天;其他正常';
+
+create index plugins_todo_user_id_index
+    on plugins_todo (user_id);
+
+# 创建待办文件夹数据表
+
+create table if not exists plugins_todo_folder
+(
+    id int auto_increment,
+    primary key (id)
+) comment 'todo分类';
+
+alter table plugins_todo_folder
+    add column user_id int null comment '用户';
+
+alter table plugins_todo_folder
+    add column name varchar(30) null;
+
+alter table plugins_todo_folder
+    add column create_time datetime null;
+
+create index plugins_todo_folder_user_id_index
+    on plugins_todo_folder (user_id);
+
+
+INSERT INTO card (name, name_en, version, tips, src, url, `window`)
+VALUES ('今天吃什么', 'food', 3, '吃什么是个很麻烦的事情', '/plugins/food/static/ico.png', '/plugins/food/card', '/plugins/food/window')
+ON DUPLICATE KEY UPDATE name = VALUES(name), version = VALUES(version), tips = VALUES(tips), src = VALUES(src), url = VALUES(url), `window` = VALUES(`window`);
+
+INSERT INTO card (name, name_en, version, tips, src, url, `window`)
+VALUES ('天气', 'weather', 13, '获取您所在地的实时天气!', '/plugins/weather/static/ico.png', '/plugins/weather/card', '/plugins/weather/window')
+ON DUPLICATE KEY UPDATE name = VALUES(name), version = VALUES(version), tips = VALUES(tips), src = VALUES(src), url = VALUES(url), `window` = VALUES(`window`);
+
+INSERT INTO card (name, name_en, version, tips, src, url, `window`)
+VALUES ('电子木鱼', 'muyu', 5, '木鱼一敲 烦恼丢掉', '/plugins/muyu/static/ico.png', '/plugins/muyu/card', '/plugins/muyu/window')
+ON DUPLICATE KEY UPDATE name = VALUES(name), version = VALUES(version), tips = VALUES(tips), src = VALUES(src), url = VALUES(url), `window` = VALUES(`window`);
+
+INSERT INTO card (name, name_en, version, tips, src, url, `window`)
+VALUES ('热搜', 'topSearch', 15, '聚合百度,哔站,微博,知乎,头条等热搜!', '/plugins/topSearch/static/ico.png', '/plugins/topSearch/card', '/plugins/topSearch/window')
+ON DUPLICATE KEY UPDATE name = VALUES(name), version = VALUES(version), tips = VALUES(tips), src = VALUES(src), url = VALUES(url), `window` = VALUES(`window`);
+
+INSERT INTO card (name, name_en, version, tips, src, url, `window`)
+VALUES ('记事本', 'noteApp', 15, '快捷记录您的灵感', '/plugins/noteApp/static/ico.png', '/plugins/noteApp/card', '/noteApp')
+ON DUPLICATE KEY UPDATE name = VALUES(name), version = VALUES(version), tips = VALUES(tips), src = VALUES(src), url = VALUES(url), `window` = VALUES(`window`);
+
+INSERT INTO card (name, name_en, version, tips, src, url, `window`)
+VALUES ('每日诗词', 'poetry', 8, '精选每日诗词!', '/plugins/poetry/static/ico.png', '/plugins/poetry/card', '/plugins/poetry/window')
+ON DUPLICATE KEY UPDATE name = VALUES(name), version = VALUES(version), tips = VALUES(tips), src = VALUES(src), url = VALUES(url), `window` = VALUES(`window`);
+
+INSERT INTO card (name, name_en, version, tips, src, url, `window`)
+VALUES ('日历', 'calendar', 1, '日历', '/plugins/calendar/static/ico.png', '/plugins/calendar/card', '/plugins/calendar/window')
+ON DUPLICATE KEY UPDATE name = VALUES(name), version = VALUES(version), tips = VALUES(tips), src = VALUES(src), url = VALUES(url), `window` = VALUES(`window`);
+
+INSERT INTO card (name, name_en, version, tips, src, url, `window`)
+VALUES ('待办事项', 'todo', 8, '快捷添加待办事项', '/plugins/todo/static/ico.png', '/plugins/todo/card', '/plugins/todo/window')
+ON DUPLICATE KEY UPDATE name = VALUES(name), version = VALUES(version), tips = VALUES(tips), src = VALUES(src), url = VALUES(url), `window` = VALUES(`window`);

+ 1 - 1
public/dist/index.html

@@ -1 +1 @@
-<!doctype html><html lang="zh"><head><meta charset="UTF-8"/><link href="{$favicon}" rel="icon"/><meta name="version" content="{$version}"><meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1"><title>{$title}</title>{$customHead|raw}<meta content="{$keywords}" name="keywords"/><meta content="{$description}" name="description"/><script type="module" crossorigin src="/dist/assets/index.1725172370631.js"></script><link rel="stylesheet" href="/dist/assets/index.17251723706314.css"></head><body style="background-color:#fff"><div id="app"></div></body></html>
+<!doctype html><html lang="zh"><head><meta charset="UTF-8"/><link href="{$favicon}" rel="icon"/><meta name="version" content="{$version}"><meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1"><title>{$title}</title>{$customHead|raw}<meta content="{$keywords}" name="keywords"/><meta content="{$description}" name="description"/><script type="module" crossorigin src="/dist/assets/index.e57f2c47.1728219882564.js"></script><link rel="stylesheet" href="/dist/assets/index.7a60d6b7.1728219882564.css"></head><body style="background-color:#fff"><div id="app"></div></body></html>

+ 0 - 2
public/index.php

@@ -1,8 +1,6 @@
 <?php
 <?php
 
 
 namespace think;
 namespace think;
-define('app_version', '2.2.0');
-define('app_version_code', 220);
 require __DIR__ . '/../vendor/autoload.php';
 require __DIR__ . '/../vendor/autoload.php';
 // 执行HTTP应用并响应
 // 执行HTTP应用并响应
 $http = (new App())->http;
 $http = (new App())->http;

+ 2 - 1
public/install.php

@@ -1,4 +1,5 @@
 <?php
 <?php
+set_time_limit(600);//默认十分钟的超时
 function params($key, $default_value = '')
 function params($key, $default_value = '')
 {
 {
     return $_POST[$key] ?? $default_value;
     return $_POST[$key] ?? $default_value;
@@ -346,7 +347,7 @@ EOF;
             使用已存在数据库(不会覆盖数据库,仅安装代码,注意的是数据库的数据表要和最新版本的程序的库一致,否则使用旧版本的数据库表<b
             使用已存在数据库(不会覆盖数据库,仅安装代码,注意的是数据库的数据表要和最新版本的程序的库一致,否则使用旧版本的数据库表<b
                     style="color: red">却</b>安装最新版的代码,否则导致有些服务异常)
                     style="color: red">却</b>安装最新版的代码,否则导致有些服务异常)
         </label>
         </label>
-        <input type='submit' value='安装' style="margin-top: 30px">
+        <input type='submit' value='安装(点击后请耐心等待安装完成)' style="margin-top: 30px">
         <div style='margin-top: 30px;font-size: 14px;line-height: 24px;display: flex;flex-direction: column;align-items: center;text-align: center'>
         <div style='margin-top: 30px;font-size: 14px;line-height: 24px;display: flex;flex-direction: column;align-items: center;text-align: center'>
             <b style="font-size: 18px">温馨提示</b>如果您在安装阶段出现问题或对安装方式(特别是Nas部署用户)不知如何操作,可联系我们为您提供解决方法或辅助您安装,本服务不收费
             <b style="font-size: 18px">温馨提示</b>如果您在安装阶段出现问题或对安装方式(特别是Nas部署用户)不知如何操作,可联系我们为您提供解决方法或辅助您安装,本服务不收费
             <a target='_blank'
             <a target='_blank'

BIN
public/static/defLinkLogo/hkcdata.png


+ 4 - 4
public/static/defaultTab.json

@@ -517,12 +517,12 @@
     },
     },
     {
     {
       "id": "a5b425d1-4c2f-4979-aeaf-68531e052a4e",
       "id": "a5b425d1-4c2f-4979-aeaf-68531e052a4e",
-      "name": "学习时间-综合性学习服务平台",
-      "src": "https://download.mtab.cc/friendLinkLogo/learningtimes.png",
-      "url": "https://learningtimes.cn",
+      "name": "NAS存储",
+      "src": "/static/defLinkLogo/hkcdata.png",
+      "url": "https://www.hkcdata.com",
       "size": "1x1",
       "size": "1x1",
       "type": "icon",
       "type": "icon",
-      "sort": 1,
+      "sort": 0,
       "app": 0,
       "app": 0,
       "bgColor": null,
       "bgColor": null,
       "pageGroup": "",
       "pageGroup": "",

+ 0 - 1
route/app.php

@@ -12,7 +12,6 @@ Route::any("/favicon", "index/favicon");
 Route::get("/plugins/:dir/static/[:file]", "\PluginStaticSystem@index")->pattern(['dir' => '\w+', 'file' => '[\w||\s\-].*']); //插件静态资源路由文件
 Route::get("/plugins/:dir/static/[:file]", "\PluginStaticSystem@index")->pattern(['dir' => '\w+', 'file' => '[\w||\s\-].*']); //插件静态资源路由文件
 Route::any("/manifest.json", "index/manifest")->cache(60 * 10);
 Route::any("/manifest.json", "index/manifest")->cache(60 * 10);
 Route::any("/searchEngine/searchEngine", "searchEngine/searchEngine");
 Route::any("/searchEngine/searchEngine", "searchEngine/searchEngine");
-
 Route::group("/plugins", function () {
 Route::group("/plugins", function () {
     $pluginsDir = root_path() . "plugins/";
     $pluginsDir = root_path() . "plugins/";
     if (is_dir($pluginsDir)) {
     if (is_dir($pluginsDir)) {

+ 1 - 1
vendor/autoload.php

@@ -4,4 +4,4 @@
 
 
 require_once __DIR__ . '/composer/autoload_real.php';
 require_once __DIR__ . '/composer/autoload_real.php';
 
 
-return ComposerAutoloaderInit9940d4d99a4d1020baa0db98e4f44a0e::getLoader();
+return ComposerAutoloaderInitd378e425b3499541fc78e652485974e9::getLoader();

+ 9 - 54
vendor/composer/InstalledVersions.php

@@ -82,15 +82,6 @@ private static $installed = array (
       ),
       ),
       'reference' => 'ce0f4d1e8a6f4eb0ddff33f57c69c50fd09f4301',
       'reference' => 'ce0f4d1e8a6f4eb0ddff33f57c69c50fd09f4301',
     ),
     ),
-    'myclabs/php-enum' => 
-    array (
-      'pretty_version' => '1.8.4',
-      'version' => '1.8.4.0',
-      'aliases' => 
-      array (
-      ),
-      'reference' => 'a867478eae49c9f59ece437ae7f9506bfaa27483',
-    ),
     'nette/mail' => 
     'nette/mail' => 
     array (
     array (
       'pretty_version' => 'v3.1.11',
       'pretty_version' => 'v3.1.11',
@@ -109,42 +100,6 @@ private static $installed = array (
       ),
       ),
       'reference' => 'a4175c62652f2300c8017fb7e640f9ccb11648d2',
       'reference' => 'a4175c62652f2300c8017fb7e640f9ccb11648d2',
     ),
     ),
-    'paquettg/php-html-parser' => 
-    array (
-      'pretty_version' => '3.1.1',
-      'version' => '3.1.1.0',
-      'aliases' => 
-      array (
-      ),
-      'reference' => '4e01a438ad5961cc2d7427eb9798d213c8a12629',
-    ),
-    'paquettg/string-encode' => 
-    array (
-      'pretty_version' => '1.0.1',
-      'version' => '1.0.1.0',
-      'aliases' => 
-      array (
-      ),
-      'reference' => 'a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee',
-    ),
-    'php-http/httplug' => 
-    array (
-      'pretty_version' => '2.4.0',
-      'version' => '2.4.0.0',
-      'aliases' => 
-      array (
-      ),
-      'reference' => '625ad742c360c8ac580fcc647a1541d29e257f67',
-    ),
-    'php-http/promise' => 
-    array (
-      'pretty_version' => '1.3.1',
-      'version' => '1.3.1.0',
-      'aliases' => 
-      array (
-      ),
-      'reference' => 'fc85b1fba37c169a69a07ef0d5a8075770cc1f83',
-    ),
     'psr/container' => 
     'psr/container' => 
     array (
     array (
       'pretty_version' => '1.1.2',
       'pretty_version' => '1.1.2',
@@ -224,30 +179,30 @@ private static $installed = array (
     ),
     ),
     'symfony/polyfill-mbstring' => 
     'symfony/polyfill-mbstring' => 
     array (
     array (
-      'pretty_version' => 'v1.30.0',
-      'version' => '1.30.0.0',
+      'pretty_version' => 'v1.31.0',
+      'version' => '1.31.0.0',
       'aliases' => 
       'aliases' => 
       array (
       array (
       ),
       ),
-      'reference' => 'fd22ab50000ef01661e2a31d850ebaa297f8e03c',
+      'reference' => '85181ba99b2345b0ef10ce42ecac37612d9fd341',
     ),
     ),
     'symfony/polyfill-php72' => 
     'symfony/polyfill-php72' => 
     array (
     array (
-      'pretty_version' => 'v1.30.0',
-      'version' => '1.30.0.0',
+      'pretty_version' => 'v1.31.0',
+      'version' => '1.31.0.0',
       'aliases' => 
       'aliases' => 
       array (
       array (
       ),
       ),
-      'reference' => '10112722600777e02d2745716b70c5db4ca70442',
+      'reference' => 'fa2ae56c44f03bed91a39bfc9822e31e7c5c38ce',
     ),
     ),
     'symfony/polyfill-php80' => 
     'symfony/polyfill-php80' => 
     array (
     array (
-      'pretty_version' => 'v1.30.0',
-      'version' => '1.30.0.0',
+      'pretty_version' => 'v1.31.0',
+      'version' => '1.31.0.0',
       'aliases' => 
       'aliases' => 
       array (
       array (
       ),
       ),
-      'reference' => '77fa7995ac1b21ab60769b7323d600a991a90433',
+      'reference' => '60328e362d4c2c802a54fcbf04f9d3fb892b4cf8',
     ),
     ),
     'symfony/var-dumper' => 
     'symfony/var-dumper' => 
     array (
     array (

+ 2 - 3
vendor/composer/autoload_files.php

@@ -6,14 +6,13 @@ $vendorDir = dirname(dirname(__FILE__));
 $baseDir = dirname($vendorDir);
 $baseDir = dirname($vendorDir);
 
 
 return array(
 return array(
-    '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
     '9b552a3cc426e3287cc811caefa3cf53' => $vendorDir . '/topthink/think-helper/src/helper.php',
     '9b552a3cc426e3287cc811caefa3cf53' => $vendorDir . '/topthink/think-helper/src/helper.php',
+    '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
     'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
     'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
     '35fab96057f1bf5e7aba31a8a6d5fdde' => $vendorDir . '/topthink/think-orm/stubs/load_stubs.php',
     '35fab96057f1bf5e7aba31a8a6d5fdde' => $vendorDir . '/topthink/think-orm/stubs/load_stubs.php',
     '6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
     '6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
-    '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
     '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
     '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
     'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
     'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
-    '25072dd6e2470089de65ae7bf11d3109' => $vendorDir . '/symfony/polyfill-php72/bootstrap.php',
+    '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
     '667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php',
     '667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php',
 );
 );

+ 0 - 1
vendor/composer/autoload_namespaces.php

@@ -6,6 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
 $baseDir = dirname($vendorDir);
 $baseDir = dirname($vendorDir);
 
 
 return array(
 return array(
-    'stringEncode' => array($vendorDir . '/paquettg/string-encode/src'),
     '' => array($baseDir . '/extend'),
     '' => array($baseDir . '/extend'),
 );
 );

+ 1 - 6
vendor/composer/autoload_psr4.php

@@ -8,11 +8,10 @@ $baseDir = dirname($vendorDir);
 return array(
 return array(
     'think\\view\\driver\\' => array($vendorDir . '/topthink/think-view/src'),
     'think\\view\\driver\\' => array($vendorDir . '/topthink/think-view/src'),
     'think\\trace\\' => array($vendorDir . '/topthink/think-trace/src'),
     'think\\trace\\' => array($vendorDir . '/topthink/think-trace/src'),
-    'think\\' => array($vendorDir . '/topthink/think-filesystem/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/framework/src/think'),
+    'think\\' => array($vendorDir . '/topthink/framework/src/think', $vendorDir . '/topthink/think-filesystem/src', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src'),
     'plugins\\' => array($baseDir . '/plugins'),
     'plugins\\' => array($baseDir . '/plugins'),
     'app\\' => array($baseDir . '/app'),
     'app\\' => array($baseDir . '/app'),
     'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'),
     'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'),
-    'Symfony\\Polyfill\\Php72\\' => array($vendorDir . '/symfony/polyfill-php72'),
     'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
     'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
     'Symfony\\Component\\VarDumper\\' => array($vendorDir . '/symfony/var-dumper'),
     'Symfony\\Component\\VarDumper\\' => array($vendorDir . '/symfony/var-dumper'),
     'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
     'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
@@ -20,12 +19,8 @@ return array(
     'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
     'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
     'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
     'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
     'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
     'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
-    'PHPHtmlParser\\' => array($vendorDir . '/paquettg/php-html-parser/src/PHPHtmlParser'),
-    'MyCLabs\\Enum\\' => array($vendorDir . '/myclabs/php-enum/src'),
     'League\\MimeTypeDetection\\' => array($vendorDir . '/league/mime-type-detection/src'),
     'League\\MimeTypeDetection\\' => array($vendorDir . '/league/mime-type-detection/src'),
     'League\\Flysystem\\' => array($vendorDir . '/league/flysystem/src'),
     'League\\Flysystem\\' => array($vendorDir . '/league/flysystem/src'),
-    'Http\\Promise\\' => array($vendorDir . '/php-http/promise/src'),
-    'Http\\Client\\' => array($vendorDir . '/php-http/httplug/src'),
     'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
     'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
     'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
     'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
     'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
     'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),

+ 7 - 7
vendor/composer/autoload_real.php

@@ -2,7 +2,7 @@
 
 
 // autoload_real.php @generated by Composer
 // autoload_real.php @generated by Composer
 
 
-class ComposerAutoloaderInit9940d4d99a4d1020baa0db98e4f44a0e
+class ComposerAutoloaderInitd378e425b3499541fc78e652485974e9
 {
 {
     private static $loader;
     private static $loader;
 
 
@@ -22,15 +22,15 @@ class ComposerAutoloaderInit9940d4d99a4d1020baa0db98e4f44a0e
             return self::$loader;
             return self::$loader;
         }
         }
 
 
-        spl_autoload_register(array('ComposerAutoloaderInit9940d4d99a4d1020baa0db98e4f44a0e', 'loadClassLoader'), true, true);
+        spl_autoload_register(array('ComposerAutoloaderInitd378e425b3499541fc78e652485974e9', 'loadClassLoader'), true, true);
         self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
         self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
-        spl_autoload_unregister(array('ComposerAutoloaderInit9940d4d99a4d1020baa0db98e4f44a0e', 'loadClassLoader'));
+        spl_autoload_unregister(array('ComposerAutoloaderInitd378e425b3499541fc78e652485974e9', 'loadClassLoader'));
 
 
         $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
         $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
         if ($useStaticLoader) {
         if ($useStaticLoader) {
             require __DIR__ . '/autoload_static.php';
             require __DIR__ . '/autoload_static.php';
 
 
-            call_user_func(\Composer\Autoload\ComposerStaticInit9940d4d99a4d1020baa0db98e4f44a0e::getInitializer($loader));
+            call_user_func(\Composer\Autoload\ComposerStaticInitd378e425b3499541fc78e652485974e9::getInitializer($loader));
         } else {
         } else {
             $map = require __DIR__ . '/autoload_namespaces.php';
             $map = require __DIR__ . '/autoload_namespaces.php';
             foreach ($map as $namespace => $path) {
             foreach ($map as $namespace => $path) {
@@ -51,19 +51,19 @@ class ComposerAutoloaderInit9940d4d99a4d1020baa0db98e4f44a0e
         $loader->register(true);
         $loader->register(true);
 
 
         if ($useStaticLoader) {
         if ($useStaticLoader) {
-            $includeFiles = Composer\Autoload\ComposerStaticInit9940d4d99a4d1020baa0db98e4f44a0e::$files;
+            $includeFiles = Composer\Autoload\ComposerStaticInitd378e425b3499541fc78e652485974e9::$files;
         } else {
         } else {
             $includeFiles = require __DIR__ . '/autoload_files.php';
             $includeFiles = require __DIR__ . '/autoload_files.php';
         }
         }
         foreach ($includeFiles as $fileIdentifier => $file) {
         foreach ($includeFiles as $fileIdentifier => $file) {
-            composerRequire9940d4d99a4d1020baa0db98e4f44a0e($fileIdentifier, $file);
+            composerRequired378e425b3499541fc78e652485974e9($fileIdentifier, $file);
         }
         }
 
 
         return $loader;
         return $loader;
     }
     }
 }
 }
 
 
-function composerRequire9940d4d99a4d1020baa0db98e4f44a0e($fileIdentifier, $file)
+function composerRequired378e425b3499541fc78e652485974e9($fileIdentifier, $file)
 {
 {
     if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
     if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
         require $file;
         require $file;

+ 12 - 55
vendor/composer/autoload_static.php

@@ -4,18 +4,17 @@
 
 
 namespace Composer\Autoload;
 namespace Composer\Autoload;
 
 
-class ComposerStaticInit9940d4d99a4d1020baa0db98e4f44a0e
+class ComposerStaticInitd378e425b3499541fc78e652485974e9
 {
 {
     public static $files = array (
     public static $files = array (
-        '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
         '9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php',
         '9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php',
+        '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
         'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
         'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
         '35fab96057f1bf5e7aba31a8a6d5fdde' => __DIR__ . '/..' . '/topthink/think-orm/stubs/load_stubs.php',
         '35fab96057f1bf5e7aba31a8a6d5fdde' => __DIR__ . '/..' . '/topthink/think-orm/stubs/load_stubs.php',
         '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
         '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
-        '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
         '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
         '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
         'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
         'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
-        '25072dd6e2470089de65ae7bf11d3109' => __DIR__ . '/..' . '/symfony/polyfill-php72/bootstrap.php',
+        '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
         '667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php',
         '667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php',
     );
     );
 
 
@@ -37,7 +36,6 @@ class ComposerStaticInit9940d4d99a4d1020baa0db98e4f44a0e
         'S' => 
         'S' => 
         array (
         array (
             'Symfony\\Polyfill\\Php80\\' => 23,
             'Symfony\\Polyfill\\Php80\\' => 23,
-            'Symfony\\Polyfill\\Php72\\' => 23,
             'Symfony\\Polyfill\\Mbstring\\' => 26,
             'Symfony\\Polyfill\\Mbstring\\' => 26,
             'Symfony\\Component\\VarDumper\\' => 28,
             'Symfony\\Component\\VarDumper\\' => 28,
         ),
         ),
@@ -48,22 +46,12 @@ class ComposerStaticInit9940d4d99a4d1020baa0db98e4f44a0e
             'Psr\\Http\\Message\\' => 17,
             'Psr\\Http\\Message\\' => 17,
             'Psr\\Http\\Client\\' => 16,
             'Psr\\Http\\Client\\' => 16,
             'Psr\\Container\\' => 14,
             'Psr\\Container\\' => 14,
-            'PHPHtmlParser\\' => 14,
-        ),
-        'M' => 
-        array (
-            'MyCLabs\\Enum\\' => 13,
         ),
         ),
         'L' => 
         'L' => 
         array (
         array (
             'League\\MimeTypeDetection\\' => 25,
             'League\\MimeTypeDetection\\' => 25,
             'League\\Flysystem\\' => 17,
             'League\\Flysystem\\' => 17,
         ),
         ),
-        'H' => 
-        array (
-            'Http\\Promise\\' => 13,
-            'Http\\Client\\' => 12,
-        ),
         'G' => 
         'G' => 
         array (
         array (
             'GuzzleHttp\\Psr7\\' => 16,
             'GuzzleHttp\\Psr7\\' => 16,
@@ -83,11 +71,11 @@ class ComposerStaticInit9940d4d99a4d1020baa0db98e4f44a0e
         ),
         ),
         'think\\' => 
         'think\\' => 
         array (
         array (
-            0 => __DIR__ . '/..' . '/topthink/think-filesystem/src',
-            1 => __DIR__ . '/..' . '/topthink/think-orm/src',
-            2 => __DIR__ . '/..' . '/topthink/think-template/src',
-            3 => __DIR__ . '/..' . '/topthink/think-helper/src',
-            4 => __DIR__ . '/..' . '/topthink/framework/src/think',
+            0 => __DIR__ . '/..' . '/topthink/framework/src/think',
+            1 => __DIR__ . '/..' . '/topthink/think-filesystem/src',
+            2 => __DIR__ . '/..' . '/topthink/think-helper/src',
+            3 => __DIR__ . '/..' . '/topthink/think-orm/src',
+            4 => __DIR__ . '/..' . '/topthink/think-template/src',
         ),
         ),
         'plugins\\' => 
         'plugins\\' => 
         array (
         array (
@@ -101,10 +89,6 @@ class ComposerStaticInit9940d4d99a4d1020baa0db98e4f44a0e
         array (
         array (
             0 => __DIR__ . '/..' . '/symfony/polyfill-php80',
             0 => __DIR__ . '/..' . '/symfony/polyfill-php80',
         ),
         ),
-        'Symfony\\Polyfill\\Php72\\' => 
-        array (
-            0 => __DIR__ . '/..' . '/symfony/polyfill-php72',
-        ),
         'Symfony\\Polyfill\\Mbstring\\' => 
         'Symfony\\Polyfill\\Mbstring\\' => 
         array (
         array (
             0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
             0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
@@ -133,14 +117,6 @@ class ComposerStaticInit9940d4d99a4d1020baa0db98e4f44a0e
         array (
         array (
             0 => __DIR__ . '/..' . '/psr/container/src',
             0 => __DIR__ . '/..' . '/psr/container/src',
         ),
         ),
-        'PHPHtmlParser\\' => 
-        array (
-            0 => __DIR__ . '/..' . '/paquettg/php-html-parser/src/PHPHtmlParser',
-        ),
-        'MyCLabs\\Enum\\' => 
-        array (
-            0 => __DIR__ . '/..' . '/myclabs/php-enum/src',
-        ),
         'League\\MimeTypeDetection\\' => 
         'League\\MimeTypeDetection\\' => 
         array (
         array (
             0 => __DIR__ . '/..' . '/league/mime-type-detection/src',
             0 => __DIR__ . '/..' . '/league/mime-type-detection/src',
@@ -149,14 +125,6 @@ class ComposerStaticInit9940d4d99a4d1020baa0db98e4f44a0e
         array (
         array (
             0 => __DIR__ . '/..' . '/league/flysystem/src',
             0 => __DIR__ . '/..' . '/league/flysystem/src',
         ),
         ),
-        'Http\\Promise\\' => 
-        array (
-            0 => __DIR__ . '/..' . '/php-http/promise/src',
-        ),
-        'Http\\Client\\' => 
-        array (
-            0 => __DIR__ . '/..' . '/php-http/httplug/src',
-        ),
         'GuzzleHttp\\Psr7\\' => 
         'GuzzleHttp\\Psr7\\' => 
         array (
         array (
             0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
             0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
@@ -171,16 +139,6 @@ class ComposerStaticInit9940d4d99a4d1020baa0db98e4f44a0e
         ),
         ),
     );
     );
 
 
-    public static $prefixesPsr0 = array (
-        's' => 
-        array (
-            'stringEncode' => 
-            array (
-                0 => __DIR__ . '/..' . '/paquettg/string-encode/src',
-            ),
-        ),
-    );
-
     public static $fallbackDirsPsr0 = array (
     public static $fallbackDirsPsr0 = array (
         0 => __DIR__ . '/../..' . '/extend',
         0 => __DIR__ . '/../..' . '/extend',
     );
     );
@@ -255,11 +213,10 @@ class ComposerStaticInit9940d4d99a4d1020baa0db98e4f44a0e
     public static function getInitializer(ClassLoader $loader)
     public static function getInitializer(ClassLoader $loader)
     {
     {
         return \Closure::bind(function () use ($loader) {
         return \Closure::bind(function () use ($loader) {
-            $loader->prefixLengthsPsr4 = ComposerStaticInit9940d4d99a4d1020baa0db98e4f44a0e::$prefixLengthsPsr4;
-            $loader->prefixDirsPsr4 = ComposerStaticInit9940d4d99a4d1020baa0db98e4f44a0e::$prefixDirsPsr4;
-            $loader->prefixesPsr0 = ComposerStaticInit9940d4d99a4d1020baa0db98e4f44a0e::$prefixesPsr0;
-            $loader->fallbackDirsPsr0 = ComposerStaticInit9940d4d99a4d1020baa0db98e4f44a0e::$fallbackDirsPsr0;
-            $loader->classMap = ComposerStaticInit9940d4d99a4d1020baa0db98e4f44a0e::$classMap;
+            $loader->prefixLengthsPsr4 = ComposerStaticInitd378e425b3499541fc78e652485974e9::$prefixLengthsPsr4;
+            $loader->prefixDirsPsr4 = ComposerStaticInitd378e425b3499541fc78e652485974e9::$prefixDirsPsr4;
+            $loader->fallbackDirsPsr0 = ComposerStaticInitd378e425b3499541fc78e652485974e9::$fallbackDirsPsr0;
+            $loader->classMap = ComposerStaticInitd378e425b3499541fc78e652485974e9::$classMap;
 
 
         }, null, ClassLoader::class);
         }, null, ClassLoader::class);
     }
     }

+ 26 - 340
vendor/composer/installed.json

@@ -471,72 +471,6 @@
             ],
             ],
             "install-path": "../league/mime-type-detection"
             "install-path": "../league/mime-type-detection"
         },
         },
-        {
-            "name": "myclabs/php-enum",
-            "version": "1.8.4",
-            "version_normalized": "1.8.4.0",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/myclabs/php-enum.git",
-                "reference": "a867478eae49c9f59ece437ae7f9506bfaa27483"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/myclabs/php-enum/zipball/a867478eae49c9f59ece437ae7f9506bfaa27483",
-                "reference": "a867478eae49c9f59ece437ae7f9506bfaa27483",
-                "shasum": ""
-            },
-            "require": {
-                "ext-json": "*",
-                "php": "^7.3 || ^8.0"
-            },
-            "require-dev": {
-                "phpunit/phpunit": "^9.5",
-                "squizlabs/php_codesniffer": "1.*",
-                "vimeo/psalm": "^4.6.2"
-            },
-            "time": "2022-08-04T09:53:51+00:00",
-            "type": "library",
-            "installation-source": "dist",
-            "autoload": {
-                "psr-4": {
-                    "MyCLabs\\Enum\\": "src/"
-                },
-                "classmap": [
-                    "stubs/Stringable.php"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "PHP Enum contributors",
-                    "homepage": "https://github.com/myclabs/php-enum/graphs/contributors"
-                }
-            ],
-            "description": "PHP Enum implementation",
-            "homepage": "http://github.com/myclabs/php-enum",
-            "keywords": [
-                "enum"
-            ],
-            "support": {
-                "issues": "https://github.com/myclabs/php-enum/issues",
-                "source": "https://github.com/myclabs/php-enum/tree/1.8.4"
-            },
-            "funding": [
-                {
-                    "url": "https://github.com/mnapoli",
-                    "type": "github"
-                },
-                {
-                    "url": "https://tidelift.com/funding/github/packagist/myclabs/php-enum",
-                    "type": "tidelift"
-                }
-            ],
-            "install-path": "../myclabs/php-enum"
-        },
         {
         {
             "name": "nette/mail",
             "name": "nette/mail",
             "version": "v3.1.11",
             "version": "v3.1.11",
@@ -703,245 +637,6 @@
             },
             },
             "install-path": "../nette/utils"
             "install-path": "../nette/utils"
         },
         },
-        {
-            "name": "paquettg/php-html-parser",
-            "version": "3.1.1",
-            "version_normalized": "3.1.1.0",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/paquettg/php-html-parser.git",
-                "reference": "4e01a438ad5961cc2d7427eb9798d213c8a12629"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/paquettg/php-html-parser/zipball/4e01a438ad5961cc2d7427eb9798d213c8a12629",
-                "reference": "4e01a438ad5961cc2d7427eb9798d213c8a12629",
-                "shasum": ""
-            },
-            "require": {
-                "ext-curl": "*",
-                "ext-mbstring": "*",
-                "ext-zlib": "*",
-                "guzzlehttp/guzzle": "^7.0",
-                "guzzlehttp/psr7": "^1.6",
-                "myclabs/php-enum": "^1.7",
-                "paquettg/string-encode": "~1.0.0",
-                "php": ">=7.2",
-                "php-http/httplug": "^2.1"
-            },
-            "require-dev": {
-                "friendsofphp/php-cs-fixer": "^2.16",
-                "infection/infection": "^0.13.4",
-                "mockery/mockery": "^1.2",
-                "phan/phan": "^2.4",
-                "phpunit/phpunit": "^7.5.1"
-            },
-            "time": "2020-11-01T20:34:43+00:00",
-            "type": "library",
-            "installation-source": "dist",
-            "autoload": {
-                "psr-4": {
-                    "PHPHtmlParser\\": "src/PHPHtmlParser"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Gilles Paquette",
-                    "email": "paquettg@gmail.com",
-                    "homepage": "http://gillespaquette.ca"
-                }
-            ],
-            "description": "An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery.",
-            "homepage": "https://github.com/paquettg/php-html-parser",
-            "keywords": [
-                "dom",
-                "html",
-                "parser"
-            ],
-            "support": {
-                "issues": "https://github.com/paquettg/php-html-parser/issues",
-                "source": "https://github.com/paquettg/php-html-parser/tree/3.1.1"
-            },
-            "funding": [
-                {
-                    "url": "https://tidelift.com/funding/github/packagist/paquettg/php-html-parser",
-                    "type": "tidelift"
-                }
-            ],
-            "install-path": "../paquettg/php-html-parser"
-        },
-        {
-            "name": "paquettg/string-encode",
-            "version": "1.0.1",
-            "version_normalized": "1.0.1.0",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/paquettg/string-encoder.git",
-                "reference": "a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/paquettg/string-encoder/zipball/a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee",
-                "reference": "a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=7.1"
-            },
-            "require-dev": {
-                "phpunit/phpunit": "^7.5.1"
-            },
-            "time": "2018-12-21T02:25:09+00:00",
-            "type": "library",
-            "installation-source": "dist",
-            "autoload": {
-                "psr-0": {
-                    "stringEncode": "src/"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Gilles Paquette",
-                    "email": "paquettg@gmail.com",
-                    "homepage": "http://gillespaquette.ca"
-                }
-            ],
-            "description": "Facilitating the process of altering string encoding in PHP.",
-            "homepage": "https://github.com/paquettg/string-encoder",
-            "keywords": [
-                "charset",
-                "encoding",
-                "string"
-            ],
-            "support": {
-                "issues": "https://github.com/paquettg/string-encoder/issues",
-                "source": "https://github.com/paquettg/string-encoder/tree/1.0.1"
-            },
-            "install-path": "../paquettg/string-encode"
-        },
-        {
-            "name": "php-http/httplug",
-            "version": "2.4.0",
-            "version_normalized": "2.4.0.0",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/php-http/httplug.git",
-                "reference": "625ad742c360c8ac580fcc647a1541d29e257f67"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/php-http/httplug/zipball/625ad742c360c8ac580fcc647a1541d29e257f67",
-                "reference": "625ad742c360c8ac580fcc647a1541d29e257f67",
-                "shasum": ""
-            },
-            "require": {
-                "php": "^7.1 || ^8.0",
-                "php-http/promise": "^1.1",
-                "psr/http-client": "^1.0",
-                "psr/http-message": "^1.0 || ^2.0"
-            },
-            "require-dev": {
-                "friends-of-phpspec/phpspec-code-coverage": "^4.1 || ^5.0 || ^6.0",
-                "phpspec/phpspec": "^5.1 || ^6.0 || ^7.0"
-            },
-            "time": "2023-04-14T15:10:03+00:00",
-            "type": "library",
-            "installation-source": "dist",
-            "autoload": {
-                "psr-4": {
-                    "Http\\Client\\": "src/"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Eric GELOEN",
-                    "email": "geloen.eric@gmail.com"
-                },
-                {
-                    "name": "Márk Sági-Kazár",
-                    "email": "mark.sagikazar@gmail.com",
-                    "homepage": "https://sagikazarmark.hu"
-                }
-            ],
-            "description": "HTTPlug, the HTTP client abstraction for PHP",
-            "homepage": "http://httplug.io",
-            "keywords": [
-                "client",
-                "http"
-            ],
-            "support": {
-                "issues": "https://github.com/php-http/httplug/issues",
-                "source": "https://github.com/php-http/httplug/tree/2.4.0"
-            },
-            "install-path": "../php-http/httplug"
-        },
-        {
-            "name": "php-http/promise",
-            "version": "1.3.1",
-            "version_normalized": "1.3.1.0",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/php-http/promise.git",
-                "reference": "fc85b1fba37c169a69a07ef0d5a8075770cc1f83"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/php-http/promise/zipball/fc85b1fba37c169a69a07ef0d5a8075770cc1f83",
-                "reference": "fc85b1fba37c169a69a07ef0d5a8075770cc1f83",
-                "shasum": ""
-            },
-            "require": {
-                "php": "^7.1 || ^8.0"
-            },
-            "require-dev": {
-                "friends-of-phpspec/phpspec-code-coverage": "^4.3.2 || ^6.3",
-                "phpspec/phpspec": "^5.1.2 || ^6.2 || ^7.4"
-            },
-            "time": "2024-03-15T13:55:21+00:00",
-            "type": "library",
-            "installation-source": "dist",
-            "autoload": {
-                "psr-4": {
-                    "Http\\Promise\\": "src/"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Joel Wurtz",
-                    "email": "joel.wurtz@gmail.com"
-                },
-                {
-                    "name": "Márk Sági-Kazár",
-                    "email": "mark.sagikazar@gmail.com"
-                }
-            ],
-            "description": "Promise used for asynchronous HTTP requests",
-            "homepage": "http://httplug.io",
-            "keywords": [
-                "promise"
-            ],
-            "support": {
-                "issues": "https://github.com/php-http/promise/issues",
-                "source": "https://github.com/php-http/promise/tree/1.3.1"
-            },
-            "install-path": "../php-http/promise"
-        },
         {
         {
             "name": "psr/container",
             "name": "psr/container",
             "version": "1.1.2",
             "version": "1.1.2",
@@ -1330,21 +1025,21 @@
         },
         },
         {
         {
             "name": "symfony/polyfill-mbstring",
             "name": "symfony/polyfill-mbstring",
-            "version": "v1.30.0",
-            "version_normalized": "1.30.0.0",
+            "version": "v1.31.0",
+            "version_normalized": "1.31.0.0",
             "source": {
             "source": {
                 "type": "git",
                 "type": "git",
                 "url": "https://github.com/symfony/polyfill-mbstring.git",
                 "url": "https://github.com/symfony/polyfill-mbstring.git",
-                "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c"
+                "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341"
             },
             },
             "dist": {
             "dist": {
                 "type": "zip",
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c",
-                "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c",
+                "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341",
+                "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341",
                 "shasum": ""
                 "shasum": ""
             },
             },
             "require": {
             "require": {
-                "php": ">=7.1"
+                "php": ">=7.2"
             },
             },
             "provide": {
             "provide": {
                 "ext-mbstring": "*"
                 "ext-mbstring": "*"
@@ -1352,7 +1047,7 @@
             "suggest": {
             "suggest": {
                 "ext-mbstring": "For best performance"
                 "ext-mbstring": "For best performance"
             },
             },
-            "time": "2024-06-19T12:30:46+00:00",
+            "time": "2024-09-09T11:45:10+00:00",
             "type": "library",
             "type": "library",
             "extra": {
             "extra": {
                 "thanks": {
                 "thanks": {
@@ -1393,7 +1088,7 @@
                 "shim"
                 "shim"
             ],
             ],
             "support": {
             "support": {
-                "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0"
+                "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0"
             },
             },
             "funding": [
             "funding": [
                 {
                 {
@@ -1413,39 +1108,30 @@
         },
         },
         {
         {
             "name": "symfony/polyfill-php72",
             "name": "symfony/polyfill-php72",
-            "version": "v1.30.0",
-            "version_normalized": "1.30.0.0",
+            "version": "v1.31.0",
+            "version_normalized": "1.31.0.0",
             "source": {
             "source": {
                 "type": "git",
                 "type": "git",
                 "url": "https://github.com/symfony/polyfill-php72.git",
                 "url": "https://github.com/symfony/polyfill-php72.git",
-                "reference": "10112722600777e02d2745716b70c5db4ca70442"
+                "reference": "fa2ae56c44f03bed91a39bfc9822e31e7c5c38ce"
             },
             },
             "dist": {
             "dist": {
                 "type": "zip",
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/10112722600777e02d2745716b70c5db4ca70442",
-                "reference": "10112722600777e02d2745716b70c5db4ca70442",
+                "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/fa2ae56c44f03bed91a39bfc9822e31e7c5c38ce",
+                "reference": "fa2ae56c44f03bed91a39bfc9822e31e7c5c38ce",
                 "shasum": ""
                 "shasum": ""
             },
             },
             "require": {
             "require": {
-                "php": ">=7.1"
+                "php": ">=7.2"
             },
             },
-            "time": "2024-06-19T12:30:46+00:00",
-            "type": "library",
+            "time": "2024-09-09T11:45:10+00:00",
+            "type": "metapackage",
             "extra": {
             "extra": {
                 "thanks": {
                 "thanks": {
                     "name": "symfony/polyfill",
                     "name": "symfony/polyfill",
                     "url": "https://github.com/symfony/polyfill"
                     "url": "https://github.com/symfony/polyfill"
                 }
                 }
             },
             },
-            "installation-source": "dist",
-            "autoload": {
-                "files": [
-                    "bootstrap.php"
-                ],
-                "psr-4": {
-                    "Symfony\\Polyfill\\Php72\\": ""
-                }
-            },
             "notification-url": "https://packagist.org/downloads/",
             "notification-url": "https://packagist.org/downloads/",
             "license": [
             "license": [
                 "MIT"
                 "MIT"
@@ -1469,7 +1155,7 @@
                 "shim"
                 "shim"
             ],
             ],
             "support": {
             "support": {
-                "source": "https://github.com/symfony/polyfill-php72/tree/v1.30.0"
+                "source": "https://github.com/symfony/polyfill-php72/tree/v1.31.0"
             },
             },
             "funding": [
             "funding": [
                 {
                 {
@@ -1485,27 +1171,27 @@
                     "type": "tidelift"
                     "type": "tidelift"
                 }
                 }
             ],
             ],
-            "install-path": "../symfony/polyfill-php72"
+            "install-path": null
         },
         },
         {
         {
             "name": "symfony/polyfill-php80",
             "name": "symfony/polyfill-php80",
-            "version": "v1.30.0",
-            "version_normalized": "1.30.0.0",
+            "version": "v1.31.0",
+            "version_normalized": "1.31.0.0",
             "source": {
             "source": {
                 "type": "git",
                 "type": "git",
                 "url": "https://github.com/symfony/polyfill-php80.git",
                 "url": "https://github.com/symfony/polyfill-php80.git",
-                "reference": "77fa7995ac1b21ab60769b7323d600a991a90433"
+                "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8"
             },
             },
             "dist": {
             "dist": {
                 "type": "zip",
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/77fa7995ac1b21ab60769b7323d600a991a90433",
-                "reference": "77fa7995ac1b21ab60769b7323d600a991a90433",
+                "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
+                "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
                 "shasum": ""
                 "shasum": ""
             },
             },
             "require": {
             "require": {
-                "php": ">=7.1"
+                "php": ">=7.2"
             },
             },
-            "time": "2024-05-31T15:07:36+00:00",
+            "time": "2024-09-09T11:45:10+00:00",
             "type": "library",
             "type": "library",
             "extra": {
             "extra": {
                 "thanks": {
                 "thanks": {
@@ -1552,7 +1238,7 @@
                 "shim"
                 "shim"
             ],
             ],
             "support": {
             "support": {
-                "source": "https://github.com/symfony/polyfill-php80/tree/v1.30.0"
+                "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0"
             },
             },
             "funding": [
             "funding": [
                 {
                 {

+ 9 - 54
vendor/composer/installed.php

@@ -56,15 +56,6 @@
       ),
       ),
       'reference' => 'ce0f4d1e8a6f4eb0ddff33f57c69c50fd09f4301',
       'reference' => 'ce0f4d1e8a6f4eb0ddff33f57c69c50fd09f4301',
     ),
     ),
-    'myclabs/php-enum' => 
-    array (
-      'pretty_version' => '1.8.4',
-      'version' => '1.8.4.0',
-      'aliases' => 
-      array (
-      ),
-      'reference' => 'a867478eae49c9f59ece437ae7f9506bfaa27483',
-    ),
     'nette/mail' => 
     'nette/mail' => 
     array (
     array (
       'pretty_version' => 'v3.1.11',
       'pretty_version' => 'v3.1.11',
@@ -83,42 +74,6 @@
       ),
       ),
       'reference' => 'a4175c62652f2300c8017fb7e640f9ccb11648d2',
       'reference' => 'a4175c62652f2300c8017fb7e640f9ccb11648d2',
     ),
     ),
-    'paquettg/php-html-parser' => 
-    array (
-      'pretty_version' => '3.1.1',
-      'version' => '3.1.1.0',
-      'aliases' => 
-      array (
-      ),
-      'reference' => '4e01a438ad5961cc2d7427eb9798d213c8a12629',
-    ),
-    'paquettg/string-encode' => 
-    array (
-      'pretty_version' => '1.0.1',
-      'version' => '1.0.1.0',
-      'aliases' => 
-      array (
-      ),
-      'reference' => 'a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee',
-    ),
-    'php-http/httplug' => 
-    array (
-      'pretty_version' => '2.4.0',
-      'version' => '2.4.0.0',
-      'aliases' => 
-      array (
-      ),
-      'reference' => '625ad742c360c8ac580fcc647a1541d29e257f67',
-    ),
-    'php-http/promise' => 
-    array (
-      'pretty_version' => '1.3.1',
-      'version' => '1.3.1.0',
-      'aliases' => 
-      array (
-      ),
-      'reference' => 'fc85b1fba37c169a69a07ef0d5a8075770cc1f83',
-    ),
     'psr/container' => 
     'psr/container' => 
     array (
     array (
       'pretty_version' => '1.1.2',
       'pretty_version' => '1.1.2',
@@ -198,30 +153,30 @@
     ),
     ),
     'symfony/polyfill-mbstring' => 
     'symfony/polyfill-mbstring' => 
     array (
     array (
-      'pretty_version' => 'v1.30.0',
-      'version' => '1.30.0.0',
+      'pretty_version' => 'v1.31.0',
+      'version' => '1.31.0.0',
       'aliases' => 
       'aliases' => 
       array (
       array (
       ),
       ),
-      'reference' => 'fd22ab50000ef01661e2a31d850ebaa297f8e03c',
+      'reference' => '85181ba99b2345b0ef10ce42ecac37612d9fd341',
     ),
     ),
     'symfony/polyfill-php72' => 
     'symfony/polyfill-php72' => 
     array (
     array (
-      'pretty_version' => 'v1.30.0',
-      'version' => '1.30.0.0',
+      'pretty_version' => 'v1.31.0',
+      'version' => '1.31.0.0',
       'aliases' => 
       'aliases' => 
       array (
       array (
       ),
       ),
-      'reference' => '10112722600777e02d2745716b70c5db4ca70442',
+      'reference' => 'fa2ae56c44f03bed91a39bfc9822e31e7c5c38ce',
     ),
     ),
     'symfony/polyfill-php80' => 
     'symfony/polyfill-php80' => 
     array (
     array (
-      'pretty_version' => 'v1.30.0',
-      'version' => '1.30.0.0',
+      'pretty_version' => 'v1.31.0',
+      'version' => '1.31.0.0',
       'aliases' => 
       'aliases' => 
       array (
       array (
       ),
       ),
-      'reference' => '77fa7995ac1b21ab60769b7323d600a991a90433',
+      'reference' => '60328e362d4c2c802a54fcbf04f9d3fb892b4cf8',
     ),
     ),
     'symfony/var-dumper' => 
     'symfony/var-dumper' => 
     array (
     array (

+ 2 - 2
vendor/guzzlehttp/psr7/.github/FUNDING.yml

@@ -1,2 +1,2 @@
-github: [Nyholm, GrahamCampbell]
-tidelift: "packagist/guzzlehttp/psr7"
+github: [Nyholm, GrahamCampbell]
+tidelift: "packagist/guzzlehttp/psr7"

+ 14 - 14
vendor/guzzlehttp/psr7/.github/stale.yml

@@ -1,14 +1,14 @@
-daysUntilStale: 120
-daysUntilClose: 14
-exemptLabels:
-  - lifecycle/keep-open
-  - lifecycle/ready-for-merge
-# Label to use when marking an issue as stale
-staleLabel: lifecycle/stale
-# Comment to post when marking an issue as stale. Set to `false` to disable
-markComment: >
-  This issue has been automatically marked as stale because it has not had
-  recent activity. It will be closed after 2 weeks if no further activity occurs. Thank you
-  for your contributions.
-# Comment to post when closing a stale issue. Set to `false` to disable
-closeComment: false
+daysUntilStale: 120
+daysUntilClose: 14
+exemptLabels:
+  - lifecycle/keep-open
+  - lifecycle/ready-for-merge
+# Label to use when marking an issue as stale
+staleLabel: lifecycle/stale
+# Comment to post when marking an issue as stale. Set to `false` to disable
+markComment: >
+  This issue has been automatically marked as stale because it has not had
+  recent activity. It will be closed after 2 weeks if no further activity occurs. Thank you
+  for your contributions.
+# Comment to post when closing a stale issue. Set to `false` to disable
+closeComment: false

+ 30 - 30
vendor/guzzlehttp/psr7/.github/workflows/ci.yml

@@ -1,30 +1,30 @@
-name: CI
-
-on:
-  pull_request:
-
-jobs:
-  build:
-    name: Build
-    runs-on: ubuntu-22.04
-    strategy:
-      max-parallel: 10
-      matrix:
-        php: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
-
-    steps:
-      - name: Set up PHP
-        uses: shivammathur/setup-php@v2
-        with:
-          php-version: ${{ matrix.php }}
-          coverage: 'none'
-          extensions: mbstring
-
-      - name: Checkout code
-        uses: actions/checkout@v3
-
-      - name: Install dependencies
-        run: composer update --no-interaction --no-progress
-
-      - name: Run tests
-        run: make test
+name: CI
+
+on:
+  pull_request:
+
+jobs:
+  build:
+    name: Build
+    runs-on: ubuntu-22.04
+    strategy:
+      max-parallel: 10
+      matrix:
+        php: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
+
+    steps:
+      - name: Set up PHP
+        uses: shivammathur/setup-php@v2
+        with:
+          php-version: ${{ matrix.php }}
+          coverage: 'none'
+          extensions: mbstring
+
+      - name: Checkout code
+        uses: actions/checkout@v3
+
+      - name: Install dependencies
+        run: composer update --no-interaction --no-progress
+
+      - name: Run tests
+        run: make test

+ 36 - 36
vendor/guzzlehttp/psr7/.github/workflows/integration.yml

@@ -1,36 +1,36 @@
-name: Integration
-
-on:
-  pull_request:
-
-jobs:
-  build:
-    name: Test
-    runs-on: ubuntu-22.04
-    strategy:
-      max-parallel: 10
-      matrix:
-        php: ['7.2', '7.3', '7.4', '8.0', '8.1']
-
-    steps:
-      - name: Set up PHP
-        uses: shivammathur/setup-php@v2
-        with:
-          php-version: ${{ matrix.php }}
-          coverage: none
-
-      - name: Checkout code
-        uses: actions/checkout@v3
-
-      - name: Download dependencies
-        uses: ramsey/composer-install@v1
-        with:
-          composer-options: --no-interaction --optimize-autoloader
-
-      - name: Start server
-        run: php -S 127.0.0.1:10002 tests/Integration/server.php &
-
-      - name: Run tests
-        env:
-          TEST_SERVER: 127.0.0.1:10002
-        run: ./vendor/bin/phpunit --testsuite Integration
+name: Integration
+
+on:
+  pull_request:
+
+jobs:
+  build:
+    name: Test
+    runs-on: ubuntu-22.04
+    strategy:
+      max-parallel: 10
+      matrix:
+        php: ['7.2', '7.3', '7.4', '8.0', '8.1']
+
+    steps:
+      - name: Set up PHP
+        uses: shivammathur/setup-php@v2
+        with:
+          php-version: ${{ matrix.php }}
+          coverage: none
+
+      - name: Checkout code
+        uses: actions/checkout@v3
+
+      - name: Download dependencies
+        uses: ramsey/composer-install@v1
+        with:
+          composer-options: --no-interaction --optimize-autoloader
+
+      - name: Start server
+        run: php -S 127.0.0.1:10002 tests/Integration/server.php &
+
+      - name: Run tests
+        env:
+          TEST_SERVER: 127.0.0.1:10002
+        run: ./vendor/bin/phpunit --testsuite Integration

+ 29 - 29
vendor/guzzlehttp/psr7/.github/workflows/static.yml

@@ -1,29 +1,29 @@
-name: Static analysis
-
-on:
-  pull_request:
-
-jobs:
-  php-cs-fixer:
-    name: PHP-CS-Fixer
-    runs-on: ubuntu-22.04
-
-    steps:
-      - name: Checkout code
-        uses: actions/checkout@v3
-
-      - name: Setup PHP
-        uses: shivammathur/setup-php@v2
-        with:
-          php-version: '7.4'
-          coverage: none
-          extensions: mbstring
-
-      - name: Download dependencies
-        run: composer update --no-interaction --no-progress
-
-      - name: Download PHP CS Fixer
-        run: composer require "friendsofphp/php-cs-fixer:2.18.4"
-
-      - name: Execute PHP CS Fixer
-        run: vendor/bin/php-cs-fixer fix --diff-format udiff --dry-run
+name: Static analysis
+
+on:
+  pull_request:
+
+jobs:
+  php-cs-fixer:
+    name: PHP-CS-Fixer
+    runs-on: ubuntu-22.04
+
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v3
+
+      - name: Setup PHP
+        uses: shivammathur/setup-php@v2
+        with:
+          php-version: '7.4'
+          coverage: none
+          extensions: mbstring
+
+      - name: Download dependencies
+        run: composer update --no-interaction --no-progress
+
+      - name: Download PHP CS Fixer
+        run: composer require "friendsofphp/php-cs-fixer:2.18.4"
+
+      - name: Execute PHP CS Fixer
+        run: vendor/bin/php-cs-fixer fix --diff-format udiff --dry-run

+ 56 - 56
vendor/guzzlehttp/psr7/.php_cs.dist

@@ -1,56 +1,56 @@
-<?php
-
-$config = PhpCsFixer\Config::create()
-    ->setRiskyAllowed(true)
-    ->setRules([
-        '@PSR2' => true,
-        'array_syntax' => ['syntax' => 'short'],
-        'concat_space' => ['spacing' => 'one'],
-        'declare_strict_types' => false,
-        'final_static_access' => true,
-        'fully_qualified_strict_types' => true,
-        'header_comment' => false,
-        'is_null' => ['use_yoda_style' => true],
-        'list_syntax' => ['syntax' => 'long'],
-        'lowercase_cast' => true,
-        'magic_method_casing' => true,
-        'modernize_types_casting' => true,
-        'multiline_comment_opening_closing' => true,
-        'no_alias_functions' => true,
-        'no_alternative_syntax' => true,
-        'no_blank_lines_after_phpdoc' => true,
-        'no_empty_comment' => true,
-        'no_empty_phpdoc' => true,
-        'no_empty_statement' => true,
-        'no_extra_blank_lines' => true,
-        'no_leading_import_slash' => true,
-        'no_trailing_comma_in_singleline_array' => true,
-        'no_unset_cast' => true,
-        'no_unused_imports' => true,
-        'no_whitespace_in_blank_line' => true,
-        'ordered_imports' => true,
-        'php_unit_ordered_covers' => true,
-        'php_unit_test_annotation' => ['style' => 'prefix'],
-        'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
-        'phpdoc_align' => ['align' => 'vertical'],
-        'phpdoc_no_useless_inheritdoc' => true,
-        'phpdoc_scalar' => true,
-        'phpdoc_separation' => true,
-        'phpdoc_single_line_var_spacing' => true,
-        'phpdoc_trim' => true,
-        'phpdoc_trim_consecutive_blank_line_separation' => true,
-        'phpdoc_types' => true,
-        'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
-        'phpdoc_var_without_name' => true,
-        'single_trait_insert_per_statement' => true,
-        'standardize_not_equals' => true,
-    ])
-    ->setFinder(
-        PhpCsFixer\Finder::create()
-            ->in(__DIR__.'/src')
-            ->in(__DIR__.'/tests')
-            ->name('*.php')
-    )
-;
-
-return $config;
+<?php
+
+$config = PhpCsFixer\Config::create()
+    ->setRiskyAllowed(true)
+    ->setRules([
+        '@PSR2' => true,
+        'array_syntax' => ['syntax' => 'short'],
+        'concat_space' => ['spacing' => 'one'],
+        'declare_strict_types' => false,
+        'final_static_access' => true,
+        'fully_qualified_strict_types' => true,
+        'header_comment' => false,
+        'is_null' => ['use_yoda_style' => true],
+        'list_syntax' => ['syntax' => 'long'],
+        'lowercase_cast' => true,
+        'magic_method_casing' => true,
+        'modernize_types_casting' => true,
+        'multiline_comment_opening_closing' => true,
+        'no_alias_functions' => true,
+        'no_alternative_syntax' => true,
+        'no_blank_lines_after_phpdoc' => true,
+        'no_empty_comment' => true,
+        'no_empty_phpdoc' => true,
+        'no_empty_statement' => true,
+        'no_extra_blank_lines' => true,
+        'no_leading_import_slash' => true,
+        'no_trailing_comma_in_singleline_array' => true,
+        'no_unset_cast' => true,
+        'no_unused_imports' => true,
+        'no_whitespace_in_blank_line' => true,
+        'ordered_imports' => true,
+        'php_unit_ordered_covers' => true,
+        'php_unit_test_annotation' => ['style' => 'prefix'],
+        'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
+        'phpdoc_align' => ['align' => 'vertical'],
+        'phpdoc_no_useless_inheritdoc' => true,
+        'phpdoc_scalar' => true,
+        'phpdoc_separation' => true,
+        'phpdoc_single_line_var_spacing' => true,
+        'phpdoc_trim' => true,
+        'phpdoc_trim_consecutive_blank_line_separation' => true,
+        'phpdoc_types' => true,
+        'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
+        'phpdoc_var_without_name' => true,
+        'single_trait_insert_per_statement' => true,
+        'standardize_not_equals' => true,
+    ])
+    ->setFinder(
+        PhpCsFixer\Finder::create()
+            ->in(__DIR__.'/src')
+            ->in(__DIR__.'/tests')
+            ->name('*.php')
+    )
+;
+
+return $config;

+ 324 - 324
vendor/guzzlehttp/psr7/CHANGELOG.md

@@ -1,324 +1,324 @@
-# Change Log
-
-
-All notable changes to this project will be documented in this file.
-
-The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
-and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-
-## Unreleased
-
-## 1.9.1 - 2023-04-17
-
-### Fixed
-
-- Fixed header validation issue
-
-## 1.9.0 - 2022-06-20
-
-### Added
-
-- Added `UriComparator::isCrossOrigin` method
-
-## 1.8.5 - 2022-03-20
-
-### Fixed
-
-- Correct header value validation
-
-## 1.8.4 - 2022-03-20
-
-### Fixed
-
-- Validate header values properly
-
-## 1.8.3 - 2021-10-05
-
-### Fixed
-
-- Return `null` in caching stream size if remote size is `null`
-
-## 1.8.2 - 2021-04-26
-
-### Fixed
-
-- Handle possibly unset `url` in `stream_get_meta_data`
-
-## 1.8.1 - 2021-03-21
-
-### Fixed
-
-- Issue parsing IPv6 URLs
-- Issue modifying ServerRequest lost all its attributes
-
-## 1.8.0 - 2021-03-21
-
-### Added
-
-- Locale independent URL parsing
-- Most classes got a `@final` annotation to prepare for 2.0
-
-### Fixed
-
-- Issue when creating stream from `php://input` and curl-ext is not installed
-- Broken `Utils::tryFopen()` on PHP 8
-
-## 1.7.0 - 2020-09-30
-
-### Added
-
-- Replaced functions by static methods
-
-### Fixed
-
-- Converting a non-seekable stream to a string
-- Handle multiple Set-Cookie correctly
-- Ignore array keys in header values when merging
-- Allow multibyte characters to be parsed in `Message:bodySummary()`
-
-### Changed
-
-- Restored partial HHVM 3 support
-
-
-## [1.6.1] - 2019-07-02
-
-### Fixed
-
-- Accept null and bool header values again
-
-
-## [1.6.0] - 2019-06-30
-
-### Added
-
-- Allowed version `^3.0` of `ralouphie/getallheaders` dependency (#244)
-- Added MIME type for WEBP image format (#246)
-- Added more validation of values according to PSR-7 and RFC standards, e.g. status code range (#250, #272)
-
-### Changed
-
-- Tests don't pass with HHVM 4.0, so HHVM support got dropped. Other libraries like composer have done the same. (#262)
-- Accept port number 0 to be valid (#270)
-
-### Fixed
-
-- Fixed subsequent reads from `php://input` in ServerRequest (#247)
-- Fixed readable/writable detection for certain stream modes (#248)
-- Fixed encoding of special characters in the `userInfo` component of an URI (#253)
-
-
-## [1.5.2] - 2018-12-04
-
-### Fixed
-
-- Check body size when getting the message summary
-
-
-## [1.5.1] - 2018-12-04
-
-### Fixed
-
-- Get the summary of a body only if it is readable
-
-
-## [1.5.0] - 2018-12-03
-
-### Added
-
-- Response first-line to response string exception (fixes #145)
-- A test for #129 behavior
-- `get_message_body_summary` function in order to get the message summary
-- `3gp` and `mkv` mime types
-
-### Changed
-
-- Clarify exception message when stream is detached
-
-### Deprecated
-
-- Deprecated parsing folded header lines as per RFC 7230
-
-### Fixed
-
-- Fix `AppendStream::detach` to not close streams
-- `InflateStream` preserves `isSeekable` attribute of the underlying stream
-- `ServerRequest::getUriFromGlobals` to support URLs in query parameters
-
-
-Several other fixes and improvements.
-
-
-## [1.4.2] - 2017-03-20
-
-### Fixed
-
-- Reverted BC break to `Uri::resolve` and `Uri::removeDotSegments` by removing
-  calls to `trigger_error` when deprecated methods are invoked.
-
-
-## [1.4.1] - 2017-02-27
-
-### Added
-
-- Rriggering of silenced deprecation warnings.
-
-### Fixed
-
-- Reverted BC break by reintroducing behavior to automagically fix a URI with a
-  relative path and an authority by adding a leading slash to the path. It's only
-  deprecated now.
-
-
-## [1.4.0] - 2017-02-21
-
-### Added
-
-- Added common URI utility methods based on RFC 3986 (see documentation in the readme):
-  - `Uri::isDefaultPort`
-  - `Uri::isAbsolute`
-  - `Uri::isNetworkPathReference`
-  - `Uri::isAbsolutePathReference`
-  - `Uri::isRelativePathReference`
-  - `Uri::isSameDocumentReference`
-  - `Uri::composeComponents`
-  - `UriNormalizer::normalize`
-  - `UriNormalizer::isEquivalent`
-  - `UriResolver::relativize`
-
-### Changed
-
-- Ensure `ServerRequest::getUriFromGlobals` returns a URI in absolute form.
-- Allow `parse_response` to parse a response without delimiting space and reason.
-- Ensure each URI modification results in a valid URI according to PSR-7 discussions.
-  Invalid modifications will throw an exception instead of returning a wrong URI or
-  doing some magic.
-  - `(new Uri)->withPath('foo')->withHost('example.com')` will throw an exception
-    because the path of a URI with an authority must start with a slash "/" or be empty
-  - `(new Uri())->withScheme('http')` will return `'http://localhost'`
-
-### Deprecated
-
-- `Uri::resolve` in favor of `UriResolver::resolve`
-- `Uri::removeDotSegments` in favor of `UriResolver::removeDotSegments`
-
-### Fixed
-
-- `Stream::read` when length parameter <= 0.
-- `copy_to_stream` reads bytes in chunks instead of `maxLen` into memory.
-- `ServerRequest::getUriFromGlobals` when `Host` header contains port.
-- Compatibility of URIs with `file` scheme and empty host.
-
-
-## [1.3.1] - 2016-06-25
-
-### Fixed
-
-- `Uri::__toString` for network path references, e.g. `//example.org`.
-- Missing lowercase normalization for host.
-- Handling of URI components in case they are `'0'` in a lot of places,
-  e.g. as a user info password.
-- `Uri::withAddedHeader` to correctly merge headers with different case.
-- Trimming of header values in `Uri::withAddedHeader`. Header values may
-  be surrounded by whitespace which should be ignored according to RFC 7230
-  Section 3.2.4. This does not apply to header names.
-- `Uri::withAddedHeader` with an array of header values.
-- `Uri::resolve` when base path has no slash and handling of fragment.
-- Handling of encoding in `Uri::with(out)QueryValue` so one can pass the
-  key/value both in encoded as well as decoded form to those methods. This is
-  consistent with withPath, withQuery etc.
-- `ServerRequest::withoutAttribute` when attribute value is null.
-
-
-## [1.3.0] - 2016-04-13
-
-### Added
-
-- Remaining interfaces needed for full PSR7 compatibility
-  (ServerRequestInterface, UploadedFileInterface, etc.).
-- Support for stream_for from scalars.
-
-### Changed
-
-- Can now extend Uri.
-
-### Fixed
-- A bug in validating request methods by making it more permissive.
-
-
-## [1.2.3] - 2016-02-18
-
-### Fixed
-
-- Support in `GuzzleHttp\Psr7\CachingStream` for seeking forward on remote
-  streams, which can sometimes return fewer bytes than requested with `fread`.
-- Handling of gzipped responses with FNAME headers.
-
-
-## [1.2.2] - 2016-01-22
-
-### Added
-
-- Support for URIs without any authority.
-- Support for HTTP 451 'Unavailable For Legal Reasons.'
-- Support for using '0' as a filename.
-- Support for including non-standard ports in Host headers.
-
-
-## [1.2.1] - 2015-11-02
-
-### Changes
-
-- Now supporting negative offsets when seeking to SEEK_END.
-
-
-## [1.2.0] - 2015-08-15
-
-### Changed
-
-- Body as `"0"` is now properly added to a response.
-- Now allowing forward seeking in CachingStream.
-- Now properly parsing HTTP requests that contain proxy targets in
-  `parse_request`.
-- functions.php is now conditionally required.
-- user-info is no longer dropped when resolving URIs.
-
-
-## [1.1.0] - 2015-06-24
-
-### Changed
-
-- URIs can now be relative.
-- `multipart/form-data` headers are now overridden case-insensitively.
-- URI paths no longer encode the following characters because they are allowed
-  in URIs: "(", ")", "*", "!", "'"
-- A port is no longer added to a URI when the scheme is missing and no port is
-  present.
-
-
-## 1.0.0 - 2015-05-19
-
-Initial release.
-
-Currently unsupported:
-
-- `Psr\Http\Message\ServerRequestInterface`
-- `Psr\Http\Message\UploadedFileInterface`
-
-
-
-[1.6.0]: https://github.com/guzzle/psr7/compare/1.5.2...1.6.0
-[1.5.2]: https://github.com/guzzle/psr7/compare/1.5.1...1.5.2
-[1.5.1]: https://github.com/guzzle/psr7/compare/1.5.0...1.5.1
-[1.5.0]: https://github.com/guzzle/psr7/compare/1.4.2...1.5.0
-[1.4.2]: https://github.com/guzzle/psr7/compare/1.4.1...1.4.2
-[1.4.1]: https://github.com/guzzle/psr7/compare/1.4.0...1.4.1
-[1.4.0]: https://github.com/guzzle/psr7/compare/1.3.1...1.4.0
-[1.3.1]: https://github.com/guzzle/psr7/compare/1.3.0...1.3.1
-[1.3.0]: https://github.com/guzzle/psr7/compare/1.2.3...1.3.0
-[1.2.3]: https://github.com/guzzle/psr7/compare/1.2.2...1.2.3
-[1.2.2]: https://github.com/guzzle/psr7/compare/1.2.1...1.2.2
-[1.2.1]: https://github.com/guzzle/psr7/compare/1.2.0...1.2.1
-[1.2.0]: https://github.com/guzzle/psr7/compare/1.1.0...1.2.0
-[1.1.0]: https://github.com/guzzle/psr7/compare/1.0.0...1.1.0
+# Change Log
+
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+
+## Unreleased
+
+## 1.9.1 - 2023-04-17
+
+### Fixed
+
+- Fixed header validation issue
+
+## 1.9.0 - 2022-06-20
+
+### Added
+
+- Added `UriComparator::isCrossOrigin` method
+
+## 1.8.5 - 2022-03-20
+
+### Fixed
+
+- Correct header value validation
+
+## 1.8.4 - 2022-03-20
+
+### Fixed
+
+- Validate header values properly
+
+## 1.8.3 - 2021-10-05
+
+### Fixed
+
+- Return `null` in caching stream size if remote size is `null`
+
+## 1.8.2 - 2021-04-26
+
+### Fixed
+
+- Handle possibly unset `url` in `stream_get_meta_data`
+
+## 1.8.1 - 2021-03-21
+
+### Fixed
+
+- Issue parsing IPv6 URLs
+- Issue modifying ServerRequest lost all its attributes
+
+## 1.8.0 - 2021-03-21
+
+### Added
+
+- Locale independent URL parsing
+- Most classes got a `@final` annotation to prepare for 2.0
+
+### Fixed
+
+- Issue when creating stream from `php://input` and curl-ext is not installed
+- Broken `Utils::tryFopen()` on PHP 8
+
+## 1.7.0 - 2020-09-30
+
+### Added
+
+- Replaced functions by static methods
+
+### Fixed
+
+- Converting a non-seekable stream to a string
+- Handle multiple Set-Cookie correctly
+- Ignore array keys in header values when merging
+- Allow multibyte characters to be parsed in `Message:bodySummary()`
+
+### Changed
+
+- Restored partial HHVM 3 support
+
+
+## [1.6.1] - 2019-07-02
+
+### Fixed
+
+- Accept null and bool header values again
+
+
+## [1.6.0] - 2019-06-30
+
+### Added
+
+- Allowed version `^3.0` of `ralouphie/getallheaders` dependency (#244)
+- Added MIME type for WEBP image format (#246)
+- Added more validation of values according to PSR-7 and RFC standards, e.g. status code range (#250, #272)
+
+### Changed
+
+- Tests don't pass with HHVM 4.0, so HHVM support got dropped. Other libraries like composer have done the same. (#262)
+- Accept port number 0 to be valid (#270)
+
+### Fixed
+
+- Fixed subsequent reads from `php://input` in ServerRequest (#247)
+- Fixed readable/writable detection for certain stream modes (#248)
+- Fixed encoding of special characters in the `userInfo` component of an URI (#253)
+
+
+## [1.5.2] - 2018-12-04
+
+### Fixed
+
+- Check body size when getting the message summary
+
+
+## [1.5.1] - 2018-12-04
+
+### Fixed
+
+- Get the summary of a body only if it is readable
+
+
+## [1.5.0] - 2018-12-03
+
+### Added
+
+- Response first-line to response string exception (fixes #145)
+- A test for #129 behavior
+- `get_message_body_summary` function in order to get the message summary
+- `3gp` and `mkv` mime types
+
+### Changed
+
+- Clarify exception message when stream is detached
+
+### Deprecated
+
+- Deprecated parsing folded header lines as per RFC 7230
+
+### Fixed
+
+- Fix `AppendStream::detach` to not close streams
+- `InflateStream` preserves `isSeekable` attribute of the underlying stream
+- `ServerRequest::getUriFromGlobals` to support URLs in query parameters
+
+
+Several other fixes and improvements.
+
+
+## [1.4.2] - 2017-03-20
+
+### Fixed
+
+- Reverted BC break to `Uri::resolve` and `Uri::removeDotSegments` by removing
+  calls to `trigger_error` when deprecated methods are invoked.
+
+
+## [1.4.1] - 2017-02-27
+
+### Added
+
+- Rriggering of silenced deprecation warnings.
+
+### Fixed
+
+- Reverted BC break by reintroducing behavior to automagically fix a URI with a
+  relative path and an authority by adding a leading slash to the path. It's only
+  deprecated now.
+
+
+## [1.4.0] - 2017-02-21
+
+### Added
+
+- Added common URI utility methods based on RFC 3986 (see documentation in the readme):
+  - `Uri::isDefaultPort`
+  - `Uri::isAbsolute`
+  - `Uri::isNetworkPathReference`
+  - `Uri::isAbsolutePathReference`
+  - `Uri::isRelativePathReference`
+  - `Uri::isSameDocumentReference`
+  - `Uri::composeComponents`
+  - `UriNormalizer::normalize`
+  - `UriNormalizer::isEquivalent`
+  - `UriResolver::relativize`
+
+### Changed
+
+- Ensure `ServerRequest::getUriFromGlobals` returns a URI in absolute form.
+- Allow `parse_response` to parse a response without delimiting space and reason.
+- Ensure each URI modification results in a valid URI according to PSR-7 discussions.
+  Invalid modifications will throw an exception instead of returning a wrong URI or
+  doing some magic.
+  - `(new Uri)->withPath('foo')->withHost('example.com')` will throw an exception
+    because the path of a URI with an authority must start with a slash "/" or be empty
+  - `(new Uri())->withScheme('http')` will return `'http://localhost'`
+
+### Deprecated
+
+- `Uri::resolve` in favor of `UriResolver::resolve`
+- `Uri::removeDotSegments` in favor of `UriResolver::removeDotSegments`
+
+### Fixed
+
+- `Stream::read` when length parameter <= 0.
+- `copy_to_stream` reads bytes in chunks instead of `maxLen` into memory.
+- `ServerRequest::getUriFromGlobals` when `Host` header contains port.
+- Compatibility of URIs with `file` scheme and empty host.
+
+
+## [1.3.1] - 2016-06-25
+
+### Fixed
+
+- `Uri::__toString` for network path references, e.g. `//example.org`.
+- Missing lowercase normalization for host.
+- Handling of URI components in case they are `'0'` in a lot of places,
+  e.g. as a user info password.
+- `Uri::withAddedHeader` to correctly merge headers with different case.
+- Trimming of header values in `Uri::withAddedHeader`. Header values may
+  be surrounded by whitespace which should be ignored according to RFC 7230
+  Section 3.2.4. This does not apply to header names.
+- `Uri::withAddedHeader` with an array of header values.
+- `Uri::resolve` when base path has no slash and handling of fragment.
+- Handling of encoding in `Uri::with(out)QueryValue` so one can pass the
+  key/value both in encoded as well as decoded form to those methods. This is
+  consistent with withPath, withQuery etc.
+- `ServerRequest::withoutAttribute` when attribute value is null.
+
+
+## [1.3.0] - 2016-04-13
+
+### Added
+
+- Remaining interfaces needed for full PSR7 compatibility
+  (ServerRequestInterface, UploadedFileInterface, etc.).
+- Support for stream_for from scalars.
+
+### Changed
+
+- Can now extend Uri.
+
+### Fixed
+- A bug in validating request methods by making it more permissive.
+
+
+## [1.2.3] - 2016-02-18
+
+### Fixed
+
+- Support in `GuzzleHttp\Psr7\CachingStream` for seeking forward on remote
+  streams, which can sometimes return fewer bytes than requested with `fread`.
+- Handling of gzipped responses with FNAME headers.
+
+
+## [1.2.2] - 2016-01-22
+
+### Added
+
+- Support for URIs without any authority.
+- Support for HTTP 451 'Unavailable For Legal Reasons.'
+- Support for using '0' as a filename.
+- Support for including non-standard ports in Host headers.
+
+
+## [1.2.1] - 2015-11-02
+
+### Changes
+
+- Now supporting negative offsets when seeking to SEEK_END.
+
+
+## [1.2.0] - 2015-08-15
+
+### Changed
+
+- Body as `"0"` is now properly added to a response.
+- Now allowing forward seeking in CachingStream.
+- Now properly parsing HTTP requests that contain proxy targets in
+  `parse_request`.
+- functions.php is now conditionally required.
+- user-info is no longer dropped when resolving URIs.
+
+
+## [1.1.0] - 2015-06-24
+
+### Changed
+
+- URIs can now be relative.
+- `multipart/form-data` headers are now overridden case-insensitively.
+- URI paths no longer encode the following characters because they are allowed
+  in URIs: "(", ")", "*", "!", "'"
+- A port is no longer added to a URI when the scheme is missing and no port is
+  present.
+
+
+## 1.0.0 - 2015-05-19
+
+Initial release.
+
+Currently unsupported:
+
+- `Psr\Http\Message\ServerRequestInterface`
+- `Psr\Http\Message\UploadedFileInterface`
+
+
+
+[1.6.0]: https://github.com/guzzle/psr7/compare/1.5.2...1.6.0
+[1.5.2]: https://github.com/guzzle/psr7/compare/1.5.1...1.5.2
+[1.5.1]: https://github.com/guzzle/psr7/compare/1.5.0...1.5.1
+[1.5.0]: https://github.com/guzzle/psr7/compare/1.4.2...1.5.0
+[1.4.2]: https://github.com/guzzle/psr7/compare/1.4.1...1.4.2
+[1.4.1]: https://github.com/guzzle/psr7/compare/1.4.0...1.4.1
+[1.4.0]: https://github.com/guzzle/psr7/compare/1.3.1...1.4.0
+[1.3.1]: https://github.com/guzzle/psr7/compare/1.3.0...1.3.1
+[1.3.0]: https://github.com/guzzle/psr7/compare/1.2.3...1.3.0
+[1.2.3]: https://github.com/guzzle/psr7/compare/1.2.2...1.2.3
+[1.2.2]: https://github.com/guzzle/psr7/compare/1.2.1...1.2.2
+[1.2.1]: https://github.com/guzzle/psr7/compare/1.2.0...1.2.1
+[1.2.0]: https://github.com/guzzle/psr7/compare/1.1.0...1.2.0
+[1.1.0]: https://github.com/guzzle/psr7/compare/1.0.0...1.1.0

+ 26 - 26
vendor/guzzlehttp/psr7/LICENSE

@@ -1,26 +1,26 @@
-The MIT License (MIT)
-
-Copyright (c) 2015 Michael Dowling <mtdowling@gmail.com>
-Copyright (c) 2015 Márk Sági-Kazár <mark.sagikazar@gmail.com>
-Copyright (c) 2015 Graham Campbell <hello@gjcampbell.co.uk>
-Copyright (c) 2016 Tobias Schultze <webmaster@tubo-world.de>
-Copyright (c) 2016 George Mponos <gmponos@gmail.com>
-Copyright (c) 2018 Tobias Nyholm <tobias.nyholm@gmail.com>
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+The MIT License (MIT)
+
+Copyright (c) 2015 Michael Dowling <mtdowling@gmail.com>
+Copyright (c) 2015 Márk Sági-Kazár <mark.sagikazar@gmail.com>
+Copyright (c) 2015 Graham Campbell <hello@gjcampbell.co.uk>
+Copyright (c) 2016 Tobias Schultze <webmaster@tubo-world.de>
+Copyright (c) 2016 George Mponos <gmponos@gmail.com>
+Copyright (c) 2018 Tobias Nyholm <tobias.nyholm@gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.

+ 844 - 844
vendor/guzzlehttp/psr7/README.md

@@ -1,844 +1,844 @@
-# PSR-7 Message Implementation
-
-This repository contains a full [PSR-7](https://www.php-fig.org/psr/psr-7/)
-message implementation, several stream decorators, and some helpful
-functionality like query string parsing.
-
-
-[![Build Status](https://travis-ci.org/guzzle/psr7.svg?branch=master)](https://travis-ci.org/guzzle/psr7)
-
-
-# Stream implementation
-
-This package comes with a number of stream implementations and stream
-decorators.
-
-
-## AppendStream
-
-`GuzzleHttp\Psr7\AppendStream`
-
-Reads from multiple streams, one after the other.
-
-```php
-use GuzzleHttp\Psr7;
-
-$a = Psr7\Utils::streamFor('abc, ');
-$b = Psr7\Utils::streamFor('123.');
-$composed = new Psr7\AppendStream([$a, $b]);
-
-$composed->addStream(Psr7\Utils::streamFor(' Above all listen to me'));
-
-echo $composed; // abc, 123. Above all listen to me.
-```
-
-
-## BufferStream
-
-`GuzzleHttp\Psr7\BufferStream`
-
-Provides a buffer stream that can be written to fill a buffer, and read
-from to remove bytes from the buffer.
-
-This stream returns a "hwm" metadata value that tells upstream consumers
-what the configured high water mark of the stream is, or the maximum
-preferred size of the buffer.
-
-```php
-use GuzzleHttp\Psr7;
-
-// When more than 1024 bytes are in the buffer, it will begin returning
-// false to writes. This is an indication that writers should slow down.
-$buffer = new Psr7\BufferStream(1024);
-```
-
-
-## CachingStream
-
-The CachingStream is used to allow seeking over previously read bytes on
-non-seekable streams. This can be useful when transferring a non-seekable
-entity body fails due to needing to rewind the stream (for example, resulting
-from a redirect). Data that is read from the remote stream will be buffered in
-a PHP temp stream so that previously read bytes are cached first in memory,
-then on disk.
-
-```php
-use GuzzleHttp\Psr7;
-
-$original = Psr7\Utils::streamFor(fopen('http://www.google.com', 'r'));
-$stream = new Psr7\CachingStream($original);
-
-$stream->read(1024);
-echo $stream->tell();
-// 1024
-
-$stream->seek(0);
-echo $stream->tell();
-// 0
-```
-
-
-## DroppingStream
-
-`GuzzleHttp\Psr7\DroppingStream`
-
-Stream decorator that begins dropping data once the size of the underlying
-stream becomes too full.
-
-```php
-use GuzzleHttp\Psr7;
-
-// Create an empty stream
-$stream = Psr7\Utils::streamFor();
-
-// Start dropping data when the stream has more than 10 bytes
-$dropping = new Psr7\DroppingStream($stream, 10);
-
-$dropping->write('01234567890123456789');
-echo $stream; // 0123456789
-```
-
-
-## FnStream
-
-`GuzzleHttp\Psr7\FnStream`
-
-Compose stream implementations based on a hash of functions.
-
-Allows for easy testing and extension of a provided stream without needing
-to create a concrete class for a simple extension point.
-
-```php
-
-use GuzzleHttp\Psr7;
-
-$stream = Psr7\Utils::streamFor('hi');
-$fnStream = Psr7\FnStream::decorate($stream, [
-    'rewind' => function () use ($stream) {
-        echo 'About to rewind - ';
-        $stream->rewind();
-        echo 'rewound!';
-    }
-]);
-
-$fnStream->rewind();
-// Outputs: About to rewind - rewound!
-```
-
-
-## InflateStream
-
-`GuzzleHttp\Psr7\InflateStream`
-
-Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
-
-This stream decorator skips the first 10 bytes of the given stream to remove
-the gzip header, converts the provided stream to a PHP stream resource,
-then appends the zlib.inflate filter. The stream is then converted back
-to a Guzzle stream resource to be used as a Guzzle stream.
-
-
-## LazyOpenStream
-
-`GuzzleHttp\Psr7\LazyOpenStream`
-
-Lazily reads or writes to a file that is opened only after an IO operation
-take place on the stream.
-
-```php
-use GuzzleHttp\Psr7;
-
-$stream = new Psr7\LazyOpenStream('/path/to/file', 'r');
-// The file has not yet been opened...
-
-echo $stream->read(10);
-// The file is opened and read from only when needed.
-```
-
-
-## LimitStream
-
-`GuzzleHttp\Psr7\LimitStream`
-
-LimitStream can be used to read a subset or slice of an existing stream object.
-This can be useful for breaking a large file into smaller pieces to be sent in
-chunks (e.g. Amazon S3's multipart upload API).
-
-```php
-use GuzzleHttp\Psr7;
-
-$original = Psr7\Utils::streamFor(fopen('/tmp/test.txt', 'r+'));
-echo $original->getSize();
-// >>> 1048576
-
-// Limit the size of the body to 1024 bytes and start reading from byte 2048
-$stream = new Psr7\LimitStream($original, 1024, 2048);
-echo $stream->getSize();
-// >>> 1024
-echo $stream->tell();
-// >>> 0
-```
-
-
-## MultipartStream
-
-`GuzzleHttp\Psr7\MultipartStream`
-
-Stream that when read returns bytes for a streaming multipart or
-multipart/form-data stream.
-
-
-## NoSeekStream
-
-`GuzzleHttp\Psr7\NoSeekStream`
-
-NoSeekStream wraps a stream and does not allow seeking.
-
-```php
-use GuzzleHttp\Psr7;
-
-$original = Psr7\Utils::streamFor('foo');
-$noSeek = new Psr7\NoSeekStream($original);
-
-echo $noSeek->read(3);
-// foo
-var_export($noSeek->isSeekable());
-// false
-$noSeek->seek(0);
-var_export($noSeek->read(3));
-// NULL
-```
-
-
-## PumpStream
-
-`GuzzleHttp\Psr7\PumpStream`
-
-Provides a read only stream that pumps data from a PHP callable.
-
-When invoking the provided callable, the PumpStream will pass the amount of
-data requested to read to the callable. The callable can choose to ignore
-this value and return fewer or more bytes than requested. Any extra data
-returned by the provided callable is buffered internally until drained using
-the read() function of the PumpStream. The provided callable MUST return
-false when there is no more data to read.
-
-
-## Implementing stream decorators
-
-Creating a stream decorator is very easy thanks to the
-`GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that
-implement `Psr\Http\Message\StreamInterface` by proxying to an underlying
-stream. Just `use` the `StreamDecoratorTrait` and implement your custom
-methods.
-
-For example, let's say we wanted to call a specific function each time the last
-byte is read from a stream. This could be implemented by overriding the
-`read()` method.
-
-```php
-use Psr\Http\Message\StreamInterface;
-use GuzzleHttp\Psr7\StreamDecoratorTrait;
-
-class EofCallbackStream implements StreamInterface
-{
-    use StreamDecoratorTrait;
-
-    private $callback;
-
-    public function __construct(StreamInterface $stream, callable $cb)
-    {
-        $this->stream = $stream;
-        $this->callback = $cb;
-    }
-
-    public function read($length)
-    {
-        $result = $this->stream->read($length);
-
-        // Invoke the callback when EOF is hit.
-        if ($this->eof()) {
-            call_user_func($this->callback);
-        }
-
-        return $result;
-    }
-}
-```
-
-This decorator could be added to any existing stream and used like so:
-
-```php
-use GuzzleHttp\Psr7;
-
-$original = Psr7\Utils::streamFor('foo');
-
-$eofStream = new EofCallbackStream($original, function () {
-    echo 'EOF!';
-});
-
-$eofStream->read(2);
-$eofStream->read(1);
-// echoes "EOF!"
-$eofStream->seek(0);
-$eofStream->read(3);
-// echoes "EOF!"
-```
-
-
-## PHP StreamWrapper
-
-You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a
-PSR-7 stream as a PHP stream resource.
-
-Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP
-stream from a PSR-7 stream.
-
-```php
-use GuzzleHttp\Psr7\StreamWrapper;
-
-$stream = GuzzleHttp\Psr7\Utils::streamFor('hello!');
-$resource = StreamWrapper::getResource($stream);
-echo fread($resource, 6); // outputs hello!
-```
-
-
-# Static API
-
-There are various static methods available under the `GuzzleHttp\Psr7` namespace.
-
-
-## `GuzzleHttp\Psr7\Message::toString`
-
-`public static function toString(MessageInterface $message): string`
-
-Returns the string representation of an HTTP message.
-
-```php
-$request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com');
-echo GuzzleHttp\Psr7\Message::toString($request);
-```
-
-
-## `GuzzleHttp\Psr7\Message::bodySummary`
-
-`public static function bodySummary(MessageInterface $message, int $truncateAt = 120): string|null`
-
-Get a short summary of the message body.
-
-Will return `null` if the response is not printable.
-
-
-## `GuzzleHttp\Psr7\Message::rewindBody`
-
-`public static function rewindBody(MessageInterface $message): void`
-
-Attempts to rewind a message body and throws an exception on failure.
-
-The body of the message will only be rewound if a call to `tell()`
-returns a value other than `0`.
-
-
-## `GuzzleHttp\Psr7\Message::parseMessage`
-
-`public static function parseMessage(string $message): array`
-
-Parses an HTTP message into an associative array.
-
-The array contains the "start-line" key containing the start line of
-the message, "headers" key containing an associative array of header
-array values, and a "body" key containing the body of the message.
-
-
-## `GuzzleHttp\Psr7\Message::parseRequestUri`
-
-`public static function parseRequestUri(string $path, array $headers): string`
-
-Constructs a URI for an HTTP request message.
-
-
-## `GuzzleHttp\Psr7\Message::parseRequest`
-
-`public static function parseRequest(string $message): Request`
-
-Parses a request message string into a request object.
-
-
-## `GuzzleHttp\Psr7\Message::parseResponse`
-
-`public static function parseResponse(string $message): Response`
-
-Parses a response message string into a response object.
-
-
-## `GuzzleHttp\Psr7\Header::parse`
-
-`public static function parse(string|array $header): array`
-
-Parse an array of header values containing ";" separated data into an
-array of associative arrays representing the header key value pair data
-of the header. When a parameter does not contain a value, but just
-contains a key, this function will inject a key with a '' string value.
-
-
-## `GuzzleHttp\Psr7\Header::normalize`
-
-`public static function normalize(string|array $header): array`
-
-Converts an array of header values that may contain comma separated
-headers into an array of headers with no comma separated values.
-
-
-## `GuzzleHttp\Psr7\Query::parse`
-
-`public static function parse(string $str, int|bool $urlEncoding = true): array`
-
-Parse a query string into an associative array.
-
-If multiple values are found for the same key, the value of that key
-value pair will become an array. This function does not parse nested
-PHP style arrays into an associative array (e.g., `foo[a]=1&foo[b]=2`
-will be parsed into `['foo[a]' => '1', 'foo[b]' => '2'])`.
-
-
-## `GuzzleHttp\Psr7\Query::build`
-
-`public static function build(array $params, int|false $encoding = PHP_QUERY_RFC3986): string`
-
-Build a query string from an array of key value pairs.
-
-This function can use the return value of `parse()` to build a query
-string. This function does not modify the provided keys when an array is
-encountered (like `http_build_query()` would).
-
-
-## `GuzzleHttp\Psr7\Utils::caselessRemove`
-
-`public static function caselessRemove(iterable<string> $keys, $keys, array $data): array`
-
-Remove the items given by the keys, case insensitively from the data.
-
-
-## `GuzzleHttp\Psr7\Utils::copyToStream`
-
-`public static function copyToStream(StreamInterface $source, StreamInterface $dest, int $maxLen = -1): void`
-
-Copy the contents of a stream into another stream until the given number
-of bytes have been read.
-
-
-## `GuzzleHttp\Psr7\Utils::copyToString`
-
-`public static function copyToString(StreamInterface $stream, int $maxLen = -1): string`
-
-Copy the contents of a stream into a string until the given number of
-bytes have been read.
-
-
-## `GuzzleHttp\Psr7\Utils::hash`
-
-`public static function hash(StreamInterface $stream, string $algo, bool $rawOutput = false): string`
-
-Calculate a hash of a stream.
-
-This method reads the entire stream to calculate a rolling hash, based on
-PHP's `hash_init` functions.
-
-
-## `GuzzleHttp\Psr7\Utils::modifyRequest`
-
-`public static function modifyRequest(RequestInterface $request, array $changes): RequestInterface`
-
-Clone and modify a request with the given changes.
-
-This method is useful for reducing the number of clones needed to mutate
-a message.
-
-- method: (string) Changes the HTTP method.
-- set_headers: (array) Sets the given headers.
-- remove_headers: (array) Remove the given headers.
-- body: (mixed) Sets the given body.
-- uri: (UriInterface) Set the URI.
-- query: (string) Set the query string value of the URI.
-- version: (string) Set the protocol version.
-
-
-## `GuzzleHttp\Psr7\Utils::readLine`
-
-`public static function readLine(StreamInterface $stream, int $maxLength = null): string`
-
-Read a line from the stream up to the maximum allowed buffer length.
-
-
-## `GuzzleHttp\Psr7\Utils::streamFor`
-
-`public static function streamFor(resource|string|null|int|float|bool|StreamInterface|callable|\Iterator $resource = '', array $options = []): StreamInterface`
-
-Create a new stream based on the input type.
-
-Options is an associative array that can contain the following keys:
-
-- metadata: Array of custom metadata.
-- size: Size of the stream.
-
-This method accepts the following `$resource` types:
-
-- `Psr\Http\Message\StreamInterface`: Returns the value as-is.
-- `string`: Creates a stream object that uses the given string as the contents.
-- `resource`: Creates a stream object that wraps the given PHP stream resource.
-- `Iterator`: If the provided value implements `Iterator`, then a read-only
-  stream object will be created that wraps the given iterable. Each time the
-  stream is read from, data from the iterator will fill a buffer and will be
-  continuously called until the buffer is equal to the requested read size.
-  Subsequent read calls will first read from the buffer and then call `next`
-  on the underlying iterator until it is exhausted.
-- `object` with `__toString()`: If the object has the `__toString()` method,
-  the object will be cast to a string and then a stream will be returned that
-  uses the string value.
-- `NULL`: When `null` is passed, an empty stream object is returned.
-- `callable` When a callable is passed, a read-only stream object will be
-  created that invokes the given callable. The callable is invoked with the
-  number of suggested bytes to read. The callable can return any number of
-  bytes, but MUST return `false` when there is no more data to return. The
-  stream object that wraps the callable will invoke the callable until the
-  number of requested bytes are available. Any additional bytes will be
-  buffered and used in subsequent reads.
-
-```php
-$stream = GuzzleHttp\Psr7\Utils::streamFor('foo');
-$stream = GuzzleHttp\Psr7\Utils::streamFor(fopen('/path/to/file', 'r'));
-
-$generator = function ($bytes) {
-    for ($i = 0; $i < $bytes; $i++) {
-        yield ' ';
-    }
-}
-
-$stream = GuzzleHttp\Psr7\Utils::streamFor($generator(100));
-```
-
-
-## `GuzzleHttp\Psr7\Utils::tryFopen`
-
-`public static function tryFopen(string $filename, string $mode): resource`
-
-Safely opens a PHP stream resource using a filename.
-
-When fopen fails, PHP normally raises a warning. This function adds an
-error handler that checks for errors and throws an exception instead.
-
-
-## `GuzzleHttp\Psr7\Utils::uriFor`
-
-`public static function uriFor(string|UriInterface $uri): UriInterface`
-
-Returns a UriInterface for the given value.
-
-This function accepts a string or UriInterface and returns a
-UriInterface for the given value. If the value is already a
-UriInterface, it is returned as-is.
-
-
-## `GuzzleHttp\Psr7\MimeType::fromFilename`
-
-`public static function fromFilename(string $filename): string|null`
-
-Determines the mimetype of a file by looking at its extension.
-
-
-## `GuzzleHttp\Psr7\MimeType::fromExtension`
-
-`public static function fromExtension(string $extension): string|null`
-
-Maps a file extensions to a mimetype.
-
-
-## Upgrading from Function API
-
-The static API was first introduced in 1.7.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API will be removed in 2.0.0. A migration table has been provided here for your convenience:
-
-| Original Function | Replacement Method |
-|----------------|----------------|
-| `str` | `Message::toString` |
-| `uri_for` | `Utils::uriFor` |
-| `stream_for` | `Utils::streamFor` |
-| `parse_header` | `Header::parse` |
-| `normalize_header` | `Header::normalize` |
-| `modify_request` | `Utils::modifyRequest` |
-| `rewind_body` | `Message::rewindBody` |
-| `try_fopen` | `Utils::tryFopen` |
-| `copy_to_string` | `Utils::copyToString` |
-| `copy_to_stream` | `Utils::copyToStream` |
-| `hash` | `Utils::hash` |
-| `readline` | `Utils::readLine` |
-| `parse_request` | `Message::parseRequest` |
-| `parse_response` | `Message::parseResponse` |
-| `parse_query` | `Query::parse` |
-| `build_query` | `Query::build` |
-| `mimetype_from_filename` | `MimeType::fromFilename` |
-| `mimetype_from_extension` | `MimeType::fromExtension` |
-| `_parse_message` | `Message::parseMessage` |
-| `_parse_request_uri` | `Message::parseRequestUri` |
-| `get_message_body_summary` | `Message::bodySummary` |
-| `_caseless_remove` | `Utils::caselessRemove` |
-
-
-# Additional URI Methods
-
-Aside from the standard `Psr\Http\Message\UriInterface` implementation in form of the `GuzzleHttp\Psr7\Uri` class,
-this library also provides additional functionality when working with URIs as static methods.
-
-## URI Types
-
-An instance of `Psr\Http\Message\UriInterface` can either be an absolute URI or a relative reference.
-An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI,
-the base URI. Relative references can be divided into several forms according to
-[RFC 3986 Section 4.2](https://tools.ietf.org/html/rfc3986#section-4.2):
-
-- network-path references, e.g. `//example.com/path`
-- absolute-path references, e.g. `/path`
-- relative-path references, e.g. `subpath`
-
-The following methods can be used to identify the type of the URI.
-
-### `GuzzleHttp\Psr7\Uri::isAbsolute`
-
-`public static function isAbsolute(UriInterface $uri): bool`
-
-Whether the URI is absolute, i.e. it has a scheme.
-
-### `GuzzleHttp\Psr7\Uri::isNetworkPathReference`
-
-`public static function isNetworkPathReference(UriInterface $uri): bool`
-
-Whether the URI is a network-path reference. A relative reference that begins with two slash characters is
-termed an network-path reference.
-
-### `GuzzleHttp\Psr7\Uri::isAbsolutePathReference`
-
-`public static function isAbsolutePathReference(UriInterface $uri): bool`
-
-Whether the URI is a absolute-path reference. A relative reference that begins with a single slash character is
-termed an absolute-path reference.
-
-### `GuzzleHttp\Psr7\Uri::isRelativePathReference`
-
-`public static function isRelativePathReference(UriInterface $uri): bool`
-
-Whether the URI is a relative-path reference. A relative reference that does not begin with a slash character is
-termed a relative-path reference.
-
-### `GuzzleHttp\Psr7\Uri::isSameDocumentReference`
-
-`public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null): bool`
-
-Whether the URI is a same-document reference. A same-document reference refers to a URI that is, aside from its
-fragment component, identical to the base URI. When no base URI is given, only an empty URI reference
-(apart from its fragment) is considered a same-document reference.
-
-## URI Components
-
-Additional methods to work with URI components.
-
-### `GuzzleHttp\Psr7\Uri::isDefaultPort`
-
-`public static function isDefaultPort(UriInterface $uri): bool`
-
-Whether the URI has the default port of the current scheme. `Psr\Http\Message\UriInterface::getPort` may return null
-or the standard port. This method can be used independently of the implementation.
-
-### `GuzzleHttp\Psr7\Uri::composeComponents`
-
-`public static function composeComponents($scheme, $authority, $path, $query, $fragment): string`
-
-Composes a URI reference string from its various components according to
-[RFC 3986 Section 5.3](https://tools.ietf.org/html/rfc3986#section-5.3). Usually this method does not need to be called
-manually but instead is used indirectly via `Psr\Http\Message\UriInterface::__toString`.
-
-### `GuzzleHttp\Psr7\Uri::fromParts`
-
-`public static function fromParts(array $parts): UriInterface`
-
-Creates a URI from a hash of [`parse_url`](https://www.php.net/manual/en/function.parse-url.php) components.
-
-
-### `GuzzleHttp\Psr7\Uri::withQueryValue`
-
-`public static function withQueryValue(UriInterface $uri, $key, $value): UriInterface`
-
-Creates a new URI with a specific query string value. Any existing query string values that exactly match the
-provided key are removed and replaced with the given key value pair. A value of null will set the query string
-key without a value, e.g. "key" instead of "key=value".
-
-### `GuzzleHttp\Psr7\Uri::withQueryValues`
-
-`public static function withQueryValues(UriInterface $uri, array $keyValueArray): UriInterface`
-
-Creates a new URI with multiple query string values. It has the same behavior as `withQueryValue()` but for an
-associative array of key => value.
-
-### `GuzzleHttp\Psr7\Uri::withoutQueryValue`
-
-`public static function withoutQueryValue(UriInterface $uri, $key): UriInterface`
-
-Creates a new URI with a specific query string value removed. Any existing query string values that exactly match the
-provided key are removed.
-
-## Cross-Origin Detection
-
-`GuzzleHttp\Psr7\UriComparator` provides methods to determine if a modified URL should be considered cross-origin.
-
-### `GuzzleHttp\Psr7\UriComparator::isCrossOrigin`
-
-`public static function isCrossOrigin(UriInterface $original, UriInterface $modified): bool`
-
-Determines if a modified URL should be considered cross-origin with respect to an original URL.
-
-## Reference Resolution
-
-`GuzzleHttp\Psr7\UriResolver` provides methods to resolve a URI reference in the context of a base URI according
-to [RFC 3986 Section 5](https://tools.ietf.org/html/rfc3986#section-5). This is for example also what web browsers
-do when resolving a link in a website based on the current request URI.
-
-### `GuzzleHttp\Psr7\UriResolver::resolve`
-
-`public static function resolve(UriInterface $base, UriInterface $rel): UriInterface`
-
-Converts the relative URI into a new URI that is resolved against the base URI.
-
-### `GuzzleHttp\Psr7\UriResolver::removeDotSegments`
-
-`public static function removeDotSegments(string $path): string`
-
-Removes dot segments from a path and returns the new path according to
-[RFC 3986 Section 5.2.4](https://tools.ietf.org/html/rfc3986#section-5.2.4).
-
-### `GuzzleHttp\Psr7\UriResolver::relativize`
-
-`public static function relativize(UriInterface $base, UriInterface $target): UriInterface`
-
-Returns the target URI as a relative reference from the base URI. This method is the counterpart to resolve():
-
-```php
-(string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target))
-```
-
-One use-case is to use the current request URI as base URI and then generate relative links in your documents
-to reduce the document size or offer self-contained downloadable document archives.
-
-```php
-$base = new Uri('http://example.com/a/b/');
-echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c'));  // prints 'c'.
-echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y'));  // prints '../x/y'.
-echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'.
-echo UriResolver::relativize($base, new Uri('http://example.org/a/b/'));   // prints '//example.org/a/b/'.
-```
-
-## Normalization and Comparison
-
-`GuzzleHttp\Psr7\UriNormalizer` provides methods to normalize and compare URIs according to
-[RFC 3986 Section 6](https://tools.ietf.org/html/rfc3986#section-6).
-
-### `GuzzleHttp\Psr7\UriNormalizer::normalize`
-
-`public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS): UriInterface`
-
-Returns a normalized URI. The scheme and host component are already normalized to lowercase per PSR-7 UriInterface.
-This methods adds additional normalizations that can be configured with the `$flags` parameter which is a bitmask
-of normalizations to apply. The following normalizations are available:
-
-- `UriNormalizer::PRESERVING_NORMALIZATIONS`
-
-    Default normalizations which only include the ones that preserve semantics.
-
-- `UriNormalizer::CAPITALIZE_PERCENT_ENCODING`
-
-    All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
-
-    Example: `http://example.org/a%c2%b1b` → `http://example.org/a%C2%B1b`
-
-- `UriNormalizer::DECODE_UNRESERVED_CHARACTERS`
-
-    Decodes percent-encoded octets of unreserved characters. For consistency, percent-encoded octets in the ranges of
-    ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should
-    not be created by URI producers and, when found in a URI, should be decoded to their corresponding unreserved
-    characters by URI normalizers.
-
-    Example: `http://example.org/%7Eusern%61me/` → `http://example.org/~username/`
-
-- `UriNormalizer::CONVERT_EMPTY_PATH`
-
-    Converts the empty path to "/" for http and https URIs.
-
-    Example: `http://example.org` → `http://example.org/`
-
-- `UriNormalizer::REMOVE_DEFAULT_HOST`
-
-    Removes the default host of the given URI scheme from the URI. Only the "file" scheme defines the default host
-    "localhost". All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile` are equivalent according to
-    RFC 3986.
-
-    Example: `file://localhost/myfile` → `file:///myfile`
-
-- `UriNormalizer::REMOVE_DEFAULT_PORT`
-
-    Removes the default port of the given URI scheme from the URI.
-
-    Example: `http://example.org:80/` → `http://example.org/`
-
-- `UriNormalizer::REMOVE_DOT_SEGMENTS`
-
-    Removes unnecessary dot-segments. Dot-segments in relative-path references are not removed as it would
-    change the semantics of the URI reference.
-
-    Example: `http://example.org/../a/b/../c/./d.html` → `http://example.org/a/c/d.html`
-
-- `UriNormalizer::REMOVE_DUPLICATE_SLASHES`
-
-    Paths which include two or more adjacent slashes are converted to one. Webservers usually ignore duplicate slashes
-    and treat those URIs equivalent. But in theory those URIs do not need to be equivalent. So this normalization
-    may change the semantics. Encoded slashes (%2F) are not removed.
-
-    Example: `http://example.org//foo///bar.html` → `http://example.org/foo/bar.html`
-
-- `UriNormalizer::SORT_QUERY_PARAMETERS`
-
-    Sort query parameters with their values in alphabetical order. However, the order of parameters in a URI may be
-    significant (this is not defined by the standard). So this normalization is not safe and may change the semantics
-    of the URI.
-
-    Example: `?lang=en&article=fred` → `?article=fred&lang=en`
-
-### `GuzzleHttp\Psr7\UriNormalizer::isEquivalent`
-
-`public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS): bool`
-
-Whether two URIs can be considered equivalent. Both URIs are normalized automatically before comparison with the given
-`$normalizations` bitmask. The method also accepts relative URI references and returns true when they are equivalent.
-This of course assumes they will be resolved against the same base URI. If this is not the case, determination of
-equivalence or difference of relative references does not mean anything.
-
-
-## Version Guidance
-
-| Version | Status         | PHP Version      |
-|---------|----------------|------------------|
-| 1.x     | Security fixes | >=5.4,<8.1       |
-| 2.x     | Latest         | ^7.2.5 \|\| ^8.0 |
-
-
-## Security
-
-If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see [Security Policy](https://github.com/guzzle/psr7/security/policy) for more information.
-
-
-## License
-
-Guzzle is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information.
-
-
-## For Enterprise
-
-Available as part of the Tidelift Subscription
-
-The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-guzzlehttp-psr7?utm_source=packagist-guzzlehttp-psr7&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
+# PSR-7 Message Implementation
+
+This repository contains a full [PSR-7](https://www.php-fig.org/psr/psr-7/)
+message implementation, several stream decorators, and some helpful
+functionality like query string parsing.
+
+
+[![Build Status](https://travis-ci.org/guzzle/psr7.svg?branch=master)](https://travis-ci.org/guzzle/psr7)
+
+
+# Stream implementation
+
+This package comes with a number of stream implementations and stream
+decorators.
+
+
+## AppendStream
+
+`GuzzleHttp\Psr7\AppendStream`
+
+Reads from multiple streams, one after the other.
+
+```php
+use GuzzleHttp\Psr7;
+
+$a = Psr7\Utils::streamFor('abc, ');
+$b = Psr7\Utils::streamFor('123.');
+$composed = new Psr7\AppendStream([$a, $b]);
+
+$composed->addStream(Psr7\Utils::streamFor(' Above all listen to me'));
+
+echo $composed; // abc, 123. Above all listen to me.
+```
+
+
+## BufferStream
+
+`GuzzleHttp\Psr7\BufferStream`
+
+Provides a buffer stream that can be written to fill a buffer, and read
+from to remove bytes from the buffer.
+
+This stream returns a "hwm" metadata value that tells upstream consumers
+what the configured high water mark of the stream is, or the maximum
+preferred size of the buffer.
+
+```php
+use GuzzleHttp\Psr7;
+
+// When more than 1024 bytes are in the buffer, it will begin returning
+// false to writes. This is an indication that writers should slow down.
+$buffer = new Psr7\BufferStream(1024);
+```
+
+
+## CachingStream
+
+The CachingStream is used to allow seeking over previously read bytes on
+non-seekable streams. This can be useful when transferring a non-seekable
+entity body fails due to needing to rewind the stream (for example, resulting
+from a redirect). Data that is read from the remote stream will be buffered in
+a PHP temp stream so that previously read bytes are cached first in memory,
+then on disk.
+
+```php
+use GuzzleHttp\Psr7;
+
+$original = Psr7\Utils::streamFor(fopen('http://www.google.com', 'r'));
+$stream = new Psr7\CachingStream($original);
+
+$stream->read(1024);
+echo $stream->tell();
+// 1024
+
+$stream->seek(0);
+echo $stream->tell();
+// 0
+```
+
+
+## DroppingStream
+
+`GuzzleHttp\Psr7\DroppingStream`
+
+Stream decorator that begins dropping data once the size of the underlying
+stream becomes too full.
+
+```php
+use GuzzleHttp\Psr7;
+
+// Create an empty stream
+$stream = Psr7\Utils::streamFor();
+
+// Start dropping data when the stream has more than 10 bytes
+$dropping = new Psr7\DroppingStream($stream, 10);
+
+$dropping->write('01234567890123456789');
+echo $stream; // 0123456789
+```
+
+
+## FnStream
+
+`GuzzleHttp\Psr7\FnStream`
+
+Compose stream implementations based on a hash of functions.
+
+Allows for easy testing and extension of a provided stream without needing
+to create a concrete class for a simple extension point.
+
+```php
+
+use GuzzleHttp\Psr7;
+
+$stream = Psr7\Utils::streamFor('hi');
+$fnStream = Psr7\FnStream::decorate($stream, [
+    'rewind' => function () use ($stream) {
+        echo 'About to rewind - ';
+        $stream->rewind();
+        echo 'rewound!';
+    }
+]);
+
+$fnStream->rewind();
+// Outputs: About to rewind - rewound!
+```
+
+
+## InflateStream
+
+`GuzzleHttp\Psr7\InflateStream`
+
+Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
+
+This stream decorator skips the first 10 bytes of the given stream to remove
+the gzip header, converts the provided stream to a PHP stream resource,
+then appends the zlib.inflate filter. The stream is then converted back
+to a Guzzle stream resource to be used as a Guzzle stream.
+
+
+## LazyOpenStream
+
+`GuzzleHttp\Psr7\LazyOpenStream`
+
+Lazily reads or writes to a file that is opened only after an IO operation
+take place on the stream.
+
+```php
+use GuzzleHttp\Psr7;
+
+$stream = new Psr7\LazyOpenStream('/path/to/file', 'r');
+// The file has not yet been opened...
+
+echo $stream->read(10);
+// The file is opened and read from only when needed.
+```
+
+
+## LimitStream
+
+`GuzzleHttp\Psr7\LimitStream`
+
+LimitStream can be used to read a subset or slice of an existing stream object.
+This can be useful for breaking a large file into smaller pieces to be sent in
+chunks (e.g. Amazon S3's multipart upload API).
+
+```php
+use GuzzleHttp\Psr7;
+
+$original = Psr7\Utils::streamFor(fopen('/tmp/test.txt', 'r+'));
+echo $original->getSize();
+// >>> 1048576
+
+// Limit the size of the body to 1024 bytes and start reading from byte 2048
+$stream = new Psr7\LimitStream($original, 1024, 2048);
+echo $stream->getSize();
+// >>> 1024
+echo $stream->tell();
+// >>> 0
+```
+
+
+## MultipartStream
+
+`GuzzleHttp\Psr7\MultipartStream`
+
+Stream that when read returns bytes for a streaming multipart or
+multipart/form-data stream.
+
+
+## NoSeekStream
+
+`GuzzleHttp\Psr7\NoSeekStream`
+
+NoSeekStream wraps a stream and does not allow seeking.
+
+```php
+use GuzzleHttp\Psr7;
+
+$original = Psr7\Utils::streamFor('foo');
+$noSeek = new Psr7\NoSeekStream($original);
+
+echo $noSeek->read(3);
+// foo
+var_export($noSeek->isSeekable());
+// false
+$noSeek->seek(0);
+var_export($noSeek->read(3));
+// NULL
+```
+
+
+## PumpStream
+
+`GuzzleHttp\Psr7\PumpStream`
+
+Provides a read only stream that pumps data from a PHP callable.
+
+When invoking the provided callable, the PumpStream will pass the amount of
+data requested to read to the callable. The callable can choose to ignore
+this value and return fewer or more bytes than requested. Any extra data
+returned by the provided callable is buffered internally until drained using
+the read() function of the PumpStream. The provided callable MUST return
+false when there is no more data to read.
+
+
+## Implementing stream decorators
+
+Creating a stream decorator is very easy thanks to the
+`GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that
+implement `Psr\Http\Message\StreamInterface` by proxying to an underlying
+stream. Just `use` the `StreamDecoratorTrait` and implement your custom
+methods.
+
+For example, let's say we wanted to call a specific function each time the last
+byte is read from a stream. This could be implemented by overriding the
+`read()` method.
+
+```php
+use Psr\Http\Message\StreamInterface;
+use GuzzleHttp\Psr7\StreamDecoratorTrait;
+
+class EofCallbackStream implements StreamInterface
+{
+    use StreamDecoratorTrait;
+
+    private $callback;
+
+    public function __construct(StreamInterface $stream, callable $cb)
+    {
+        $this->stream = $stream;
+        $this->callback = $cb;
+    }
+
+    public function read($length)
+    {
+        $result = $this->stream->read($length);
+
+        // Invoke the callback when EOF is hit.
+        if ($this->eof()) {
+            call_user_func($this->callback);
+        }
+
+        return $result;
+    }
+}
+```
+
+This decorator could be added to any existing stream and used like so:
+
+```php
+use GuzzleHttp\Psr7;
+
+$original = Psr7\Utils::streamFor('foo');
+
+$eofStream = new EofCallbackStream($original, function () {
+    echo 'EOF!';
+});
+
+$eofStream->read(2);
+$eofStream->read(1);
+// echoes "EOF!"
+$eofStream->seek(0);
+$eofStream->read(3);
+// echoes "EOF!"
+```
+
+
+## PHP StreamWrapper
+
+You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a
+PSR-7 stream as a PHP stream resource.
+
+Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP
+stream from a PSR-7 stream.
+
+```php
+use GuzzleHttp\Psr7\StreamWrapper;
+
+$stream = GuzzleHttp\Psr7\Utils::streamFor('hello!');
+$resource = StreamWrapper::getResource($stream);
+echo fread($resource, 6); // outputs hello!
+```
+
+
+# Static API
+
+There are various static methods available under the `GuzzleHttp\Psr7` namespace.
+
+
+## `GuzzleHttp\Psr7\Message::toString`
+
+`public static function toString(MessageInterface $message): string`
+
+Returns the string representation of an HTTP message.
+
+```php
+$request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com');
+echo GuzzleHttp\Psr7\Message::toString($request);
+```
+
+
+## `GuzzleHttp\Psr7\Message::bodySummary`
+
+`public static function bodySummary(MessageInterface $message, int $truncateAt = 120): string|null`
+
+Get a short summary of the message body.
+
+Will return `null` if the response is not printable.
+
+
+## `GuzzleHttp\Psr7\Message::rewindBody`
+
+`public static function rewindBody(MessageInterface $message): void`
+
+Attempts to rewind a message body and throws an exception on failure.
+
+The body of the message will only be rewound if a call to `tell()`
+returns a value other than `0`.
+
+
+## `GuzzleHttp\Psr7\Message::parseMessage`
+
+`public static function parseMessage(string $message): array`
+
+Parses an HTTP message into an associative array.
+
+The array contains the "start-line" key containing the start line of
+the message, "headers" key containing an associative array of header
+array values, and a "body" key containing the body of the message.
+
+
+## `GuzzleHttp\Psr7\Message::parseRequestUri`
+
+`public static function parseRequestUri(string $path, array $headers): string`
+
+Constructs a URI for an HTTP request message.
+
+
+## `GuzzleHttp\Psr7\Message::parseRequest`
+
+`public static function parseRequest(string $message): Request`
+
+Parses a request message string into a request object.
+
+
+## `GuzzleHttp\Psr7\Message::parseResponse`
+
+`public static function parseResponse(string $message): Response`
+
+Parses a response message string into a response object.
+
+
+## `GuzzleHttp\Psr7\Header::parse`
+
+`public static function parse(string|array $header): array`
+
+Parse an array of header values containing ";" separated data into an
+array of associative arrays representing the header key value pair data
+of the header. When a parameter does not contain a value, but just
+contains a key, this function will inject a key with a '' string value.
+
+
+## `GuzzleHttp\Psr7\Header::normalize`
+
+`public static function normalize(string|array $header): array`
+
+Converts an array of header values that may contain comma separated
+headers into an array of headers with no comma separated values.
+
+
+## `GuzzleHttp\Psr7\Query::parse`
+
+`public static function parse(string $str, int|bool $urlEncoding = true): array`
+
+Parse a query string into an associative array.
+
+If multiple values are found for the same key, the value of that key
+value pair will become an array. This function does not parse nested
+PHP style arrays into an associative array (e.g., `foo[a]=1&foo[b]=2`
+will be parsed into `['foo[a]' => '1', 'foo[b]' => '2'])`.
+
+
+## `GuzzleHttp\Psr7\Query::build`
+
+`public static function build(array $params, int|false $encoding = PHP_QUERY_RFC3986): string`
+
+Build a query string from an array of key value pairs.
+
+This function can use the return value of `parse()` to build a query
+string. This function does not modify the provided keys when an array is
+encountered (like `http_build_query()` would).
+
+
+## `GuzzleHttp\Psr7\Utils::caselessRemove`
+
+`public static function caselessRemove(iterable<string> $keys, $keys, array $data): array`
+
+Remove the items given by the keys, case insensitively from the data.
+
+
+## `GuzzleHttp\Psr7\Utils::copyToStream`
+
+`public static function copyToStream(StreamInterface $source, StreamInterface $dest, int $maxLen = -1): void`
+
+Copy the contents of a stream into another stream until the given number
+of bytes have been read.
+
+
+## `GuzzleHttp\Psr7\Utils::copyToString`
+
+`public static function copyToString(StreamInterface $stream, int $maxLen = -1): string`
+
+Copy the contents of a stream into a string until the given number of
+bytes have been read.
+
+
+## `GuzzleHttp\Psr7\Utils::hash`
+
+`public static function hash(StreamInterface $stream, string $algo, bool $rawOutput = false): string`
+
+Calculate a hash of a stream.
+
+This method reads the entire stream to calculate a rolling hash, based on
+PHP's `hash_init` functions.
+
+
+## `GuzzleHttp\Psr7\Utils::modifyRequest`
+
+`public static function modifyRequest(RequestInterface $request, array $changes): RequestInterface`
+
+Clone and modify a request with the given changes.
+
+This method is useful for reducing the number of clones needed to mutate
+a message.
+
+- method: (string) Changes the HTTP method.
+- set_headers: (array) Sets the given headers.
+- remove_headers: (array) Remove the given headers.
+- body: (mixed) Sets the given body.
+- uri: (UriInterface) Set the URI.
+- query: (string) Set the query string value of the URI.
+- version: (string) Set the protocol version.
+
+
+## `GuzzleHttp\Psr7\Utils::readLine`
+
+`public static function readLine(StreamInterface $stream, int $maxLength = null): string`
+
+Read a line from the stream up to the maximum allowed buffer length.
+
+
+## `GuzzleHttp\Psr7\Utils::streamFor`
+
+`public static function streamFor(resource|string|null|int|float|bool|StreamInterface|callable|\Iterator $resource = '', array $options = []): StreamInterface`
+
+Create a new stream based on the input type.
+
+Options is an associative array that can contain the following keys:
+
+- metadata: Array of custom metadata.
+- size: Size of the stream.
+
+This method accepts the following `$resource` types:
+
+- `Psr\Http\Message\StreamInterface`: Returns the value as-is.
+- `string`: Creates a stream object that uses the given string as the contents.
+- `resource`: Creates a stream object that wraps the given PHP stream resource.
+- `Iterator`: If the provided value implements `Iterator`, then a read-only
+  stream object will be created that wraps the given iterable. Each time the
+  stream is read from, data from the iterator will fill a buffer and will be
+  continuously called until the buffer is equal to the requested read size.
+  Subsequent read calls will first read from the buffer and then call `next`
+  on the underlying iterator until it is exhausted.
+- `object` with `__toString()`: If the object has the `__toString()` method,
+  the object will be cast to a string and then a stream will be returned that
+  uses the string value.
+- `NULL`: When `null` is passed, an empty stream object is returned.
+- `callable` When a callable is passed, a read-only stream object will be
+  created that invokes the given callable. The callable is invoked with the
+  number of suggested bytes to read. The callable can return any number of
+  bytes, but MUST return `false` when there is no more data to return. The
+  stream object that wraps the callable will invoke the callable until the
+  number of requested bytes are available. Any additional bytes will be
+  buffered and used in subsequent reads.
+
+```php
+$stream = GuzzleHttp\Psr7\Utils::streamFor('foo');
+$stream = GuzzleHttp\Psr7\Utils::streamFor(fopen('/path/to/file', 'r'));
+
+$generator = function ($bytes) {
+    for ($i = 0; $i < $bytes; $i++) {
+        yield ' ';
+    }
+}
+
+$stream = GuzzleHttp\Psr7\Utils::streamFor($generator(100));
+```
+
+
+## `GuzzleHttp\Psr7\Utils::tryFopen`
+
+`public static function tryFopen(string $filename, string $mode): resource`
+
+Safely opens a PHP stream resource using a filename.
+
+When fopen fails, PHP normally raises a warning. This function adds an
+error handler that checks for errors and throws an exception instead.
+
+
+## `GuzzleHttp\Psr7\Utils::uriFor`
+
+`public static function uriFor(string|UriInterface $uri): UriInterface`
+
+Returns a UriInterface for the given value.
+
+This function accepts a string or UriInterface and returns a
+UriInterface for the given value. If the value is already a
+UriInterface, it is returned as-is.
+
+
+## `GuzzleHttp\Psr7\MimeType::fromFilename`
+
+`public static function fromFilename(string $filename): string|null`
+
+Determines the mimetype of a file by looking at its extension.
+
+
+## `GuzzleHttp\Psr7\MimeType::fromExtension`
+
+`public static function fromExtension(string $extension): string|null`
+
+Maps a file extensions to a mimetype.
+
+
+## Upgrading from Function API
+
+The static API was first introduced in 1.7.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API will be removed in 2.0.0. A migration table has been provided here for your convenience:
+
+| Original Function | Replacement Method |
+|----------------|----------------|
+| `str` | `Message::toString` |
+| `uri_for` | `Utils::uriFor` |
+| `stream_for` | `Utils::streamFor` |
+| `parse_header` | `Header::parse` |
+| `normalize_header` | `Header::normalize` |
+| `modify_request` | `Utils::modifyRequest` |
+| `rewind_body` | `Message::rewindBody` |
+| `try_fopen` | `Utils::tryFopen` |
+| `copy_to_string` | `Utils::copyToString` |
+| `copy_to_stream` | `Utils::copyToStream` |
+| `hash` | `Utils::hash` |
+| `readline` | `Utils::readLine` |
+| `parse_request` | `Message::parseRequest` |
+| `parse_response` | `Message::parseResponse` |
+| `parse_query` | `Query::parse` |
+| `build_query` | `Query::build` |
+| `mimetype_from_filename` | `MimeType::fromFilename` |
+| `mimetype_from_extension` | `MimeType::fromExtension` |
+| `_parse_message` | `Message::parseMessage` |
+| `_parse_request_uri` | `Message::parseRequestUri` |
+| `get_message_body_summary` | `Message::bodySummary` |
+| `_caseless_remove` | `Utils::caselessRemove` |
+
+
+# Additional URI Methods
+
+Aside from the standard `Psr\Http\Message\UriInterface` implementation in form of the `GuzzleHttp\Psr7\Uri` class,
+this library also provides additional functionality when working with URIs as static methods.
+
+## URI Types
+
+An instance of `Psr\Http\Message\UriInterface` can either be an absolute URI or a relative reference.
+An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI,
+the base URI. Relative references can be divided into several forms according to
+[RFC 3986 Section 4.2](https://tools.ietf.org/html/rfc3986#section-4.2):
+
+- network-path references, e.g. `//example.com/path`
+- absolute-path references, e.g. `/path`
+- relative-path references, e.g. `subpath`
+
+The following methods can be used to identify the type of the URI.
+
+### `GuzzleHttp\Psr7\Uri::isAbsolute`
+
+`public static function isAbsolute(UriInterface $uri): bool`
+
+Whether the URI is absolute, i.e. it has a scheme.
+
+### `GuzzleHttp\Psr7\Uri::isNetworkPathReference`
+
+`public static function isNetworkPathReference(UriInterface $uri): bool`
+
+Whether the URI is a network-path reference. A relative reference that begins with two slash characters is
+termed an network-path reference.
+
+### `GuzzleHttp\Psr7\Uri::isAbsolutePathReference`
+
+`public static function isAbsolutePathReference(UriInterface $uri): bool`
+
+Whether the URI is a absolute-path reference. A relative reference that begins with a single slash character is
+termed an absolute-path reference.
+
+### `GuzzleHttp\Psr7\Uri::isRelativePathReference`
+
+`public static function isRelativePathReference(UriInterface $uri): bool`
+
+Whether the URI is a relative-path reference. A relative reference that does not begin with a slash character is
+termed a relative-path reference.
+
+### `GuzzleHttp\Psr7\Uri::isSameDocumentReference`
+
+`public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null): bool`
+
+Whether the URI is a same-document reference. A same-document reference refers to a URI that is, aside from its
+fragment component, identical to the base URI. When no base URI is given, only an empty URI reference
+(apart from its fragment) is considered a same-document reference.
+
+## URI Components
+
+Additional methods to work with URI components.
+
+### `GuzzleHttp\Psr7\Uri::isDefaultPort`
+
+`public static function isDefaultPort(UriInterface $uri): bool`
+
+Whether the URI has the default port of the current scheme. `Psr\Http\Message\UriInterface::getPort` may return null
+or the standard port. This method can be used independently of the implementation.
+
+### `GuzzleHttp\Psr7\Uri::composeComponents`
+
+`public static function composeComponents($scheme, $authority, $path, $query, $fragment): string`
+
+Composes a URI reference string from its various components according to
+[RFC 3986 Section 5.3](https://tools.ietf.org/html/rfc3986#section-5.3). Usually this method does not need to be called
+manually but instead is used indirectly via `Psr\Http\Message\UriInterface::__toString`.
+
+### `GuzzleHttp\Psr7\Uri::fromParts`
+
+`public static function fromParts(array $parts): UriInterface`
+
+Creates a URI from a hash of [`parse_url`](https://www.php.net/manual/en/function.parse-url.php) components.
+
+
+### `GuzzleHttp\Psr7\Uri::withQueryValue`
+
+`public static function withQueryValue(UriInterface $uri, $key, $value): UriInterface`
+
+Creates a new URI with a specific query string value. Any existing query string values that exactly match the
+provided key are removed and replaced with the given key value pair. A value of null will set the query string
+key without a value, e.g. "key" instead of "key=value".
+
+### `GuzzleHttp\Psr7\Uri::withQueryValues`
+
+`public static function withQueryValues(UriInterface $uri, array $keyValueArray): UriInterface`
+
+Creates a new URI with multiple query string values. It has the same behavior as `withQueryValue()` but for an
+associative array of key => value.
+
+### `GuzzleHttp\Psr7\Uri::withoutQueryValue`
+
+`public static function withoutQueryValue(UriInterface $uri, $key): UriInterface`
+
+Creates a new URI with a specific query string value removed. Any existing query string values that exactly match the
+provided key are removed.
+
+## Cross-Origin Detection
+
+`GuzzleHttp\Psr7\UriComparator` provides methods to determine if a modified URL should be considered cross-origin.
+
+### `GuzzleHttp\Psr7\UriComparator::isCrossOrigin`
+
+`public static function isCrossOrigin(UriInterface $original, UriInterface $modified): bool`
+
+Determines if a modified URL should be considered cross-origin with respect to an original URL.
+
+## Reference Resolution
+
+`GuzzleHttp\Psr7\UriResolver` provides methods to resolve a URI reference in the context of a base URI according
+to [RFC 3986 Section 5](https://tools.ietf.org/html/rfc3986#section-5). This is for example also what web browsers
+do when resolving a link in a website based on the current request URI.
+
+### `GuzzleHttp\Psr7\UriResolver::resolve`
+
+`public static function resolve(UriInterface $base, UriInterface $rel): UriInterface`
+
+Converts the relative URI into a new URI that is resolved against the base URI.
+
+### `GuzzleHttp\Psr7\UriResolver::removeDotSegments`
+
+`public static function removeDotSegments(string $path): string`
+
+Removes dot segments from a path and returns the new path according to
+[RFC 3986 Section 5.2.4](https://tools.ietf.org/html/rfc3986#section-5.2.4).
+
+### `GuzzleHttp\Psr7\UriResolver::relativize`
+
+`public static function relativize(UriInterface $base, UriInterface $target): UriInterface`
+
+Returns the target URI as a relative reference from the base URI. This method is the counterpart to resolve():
+
+```php
+(string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target))
+```
+
+One use-case is to use the current request URI as base URI and then generate relative links in your documents
+to reduce the document size or offer self-contained downloadable document archives.
+
+```php
+$base = new Uri('http://example.com/a/b/');
+echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c'));  // prints 'c'.
+echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y'));  // prints '../x/y'.
+echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'.
+echo UriResolver::relativize($base, new Uri('http://example.org/a/b/'));   // prints '//example.org/a/b/'.
+```
+
+## Normalization and Comparison
+
+`GuzzleHttp\Psr7\UriNormalizer` provides methods to normalize and compare URIs according to
+[RFC 3986 Section 6](https://tools.ietf.org/html/rfc3986#section-6).
+
+### `GuzzleHttp\Psr7\UriNormalizer::normalize`
+
+`public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS): UriInterface`
+
+Returns a normalized URI. The scheme and host component are already normalized to lowercase per PSR-7 UriInterface.
+This methods adds additional normalizations that can be configured with the `$flags` parameter which is a bitmask
+of normalizations to apply. The following normalizations are available:
+
+- `UriNormalizer::PRESERVING_NORMALIZATIONS`
+
+    Default normalizations which only include the ones that preserve semantics.
+
+- `UriNormalizer::CAPITALIZE_PERCENT_ENCODING`
+
+    All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
+
+    Example: `http://example.org/a%c2%b1b` → `http://example.org/a%C2%B1b`
+
+- `UriNormalizer::DECODE_UNRESERVED_CHARACTERS`
+
+    Decodes percent-encoded octets of unreserved characters. For consistency, percent-encoded octets in the ranges of
+    ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should
+    not be created by URI producers and, when found in a URI, should be decoded to their corresponding unreserved
+    characters by URI normalizers.
+
+    Example: `http://example.org/%7Eusern%61me/` → `http://example.org/~username/`
+
+- `UriNormalizer::CONVERT_EMPTY_PATH`
+
+    Converts the empty path to "/" for http and https URIs.
+
+    Example: `http://example.org` → `http://example.org/`
+
+- `UriNormalizer::REMOVE_DEFAULT_HOST`
+
+    Removes the default host of the given URI scheme from the URI. Only the "file" scheme defines the default host
+    "localhost". All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile` are equivalent according to
+    RFC 3986.
+
+    Example: `file://localhost/myfile` → `file:///myfile`
+
+- `UriNormalizer::REMOVE_DEFAULT_PORT`
+
+    Removes the default port of the given URI scheme from the URI.
+
+    Example: `http://example.org:80/` → `http://example.org/`
+
+- `UriNormalizer::REMOVE_DOT_SEGMENTS`
+
+    Removes unnecessary dot-segments. Dot-segments in relative-path references are not removed as it would
+    change the semantics of the URI reference.
+
+    Example: `http://example.org/../a/b/../c/./d.html` → `http://example.org/a/c/d.html`
+
+- `UriNormalizer::REMOVE_DUPLICATE_SLASHES`
+
+    Paths which include two or more adjacent slashes are converted to one. Webservers usually ignore duplicate slashes
+    and treat those URIs equivalent. But in theory those URIs do not need to be equivalent. So this normalization
+    may change the semantics. Encoded slashes (%2F) are not removed.
+
+    Example: `http://example.org//foo///bar.html` → `http://example.org/foo/bar.html`
+
+- `UriNormalizer::SORT_QUERY_PARAMETERS`
+
+    Sort query parameters with their values in alphabetical order. However, the order of parameters in a URI may be
+    significant (this is not defined by the standard). So this normalization is not safe and may change the semantics
+    of the URI.
+
+    Example: `?lang=en&article=fred` → `?article=fred&lang=en`
+
+### `GuzzleHttp\Psr7\UriNormalizer::isEquivalent`
+
+`public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS): bool`
+
+Whether two URIs can be considered equivalent. Both URIs are normalized automatically before comparison with the given
+`$normalizations` bitmask. The method also accepts relative URI references and returns true when they are equivalent.
+This of course assumes they will be resolved against the same base URI. If this is not the case, determination of
+equivalence or difference of relative references does not mean anything.
+
+
+## Version Guidance
+
+| Version | Status         | PHP Version      |
+|---------|----------------|------------------|
+| 1.x     | Security fixes | >=5.4,<8.1       |
+| 2.x     | Latest         | ^7.2.5 \|\| ^8.0 |
+
+
+## Security
+
+If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see [Security Policy](https://github.com/guzzle/psr7/security/policy) for more information.
+
+
+## License
+
+Guzzle is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information.
+
+
+## For Enterprise
+
+Available as part of the Tidelift Subscription
+
+The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-guzzlehttp-psr7?utm_source=packagist-guzzlehttp-psr7&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

+ 71 - 71
vendor/guzzlehttp/psr7/composer.json

@@ -1,71 +1,71 @@
-{
-    "name": "guzzlehttp/psr7",
-    "description": "PSR-7 message implementation that also provides common utility methods",
-    "keywords": ["request", "response", "message", "stream", "http", "uri", "url", "psr-7"],
-    "license": "MIT",
-    "authors": [
-        {
-            "name": "Graham Campbell",
-            "email": "hello@gjcampbell.co.uk",
-            "homepage": "https://github.com/GrahamCampbell"
-        },
-        {
-            "name": "Michael Dowling",
-            "email": "mtdowling@gmail.com",
-            "homepage": "https://github.com/mtdowling"
-        },
-        {
-            "name": "George Mponos",
-            "email": "gmponos@gmail.com",
-            "homepage": "https://github.com/gmponos"
-        },
-        {
-            "name": "Tobias Nyholm",
-            "email": "tobias.nyholm@gmail.com",
-            "homepage": "https://github.com/Nyholm"
-        },
-        {
-            "name": "Márk Sági-Kazár",
-            "email": "mark.sagikazar@gmail.com",
-            "homepage": "https://github.com/sagikazarmark"
-        },
-        {
-            "name": "Tobias Schultze",
-            "email": "webmaster@tubo-world.de",
-            "homepage": "https://github.com/Tobion"
-        }
-    ],
-    "require": {
-        "php": ">=5.4.0",
-        "psr/http-message": "~1.0",
-        "ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
-    },
-    "require-dev": {
-        "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10",
-        "ext-zlib": "*"
-    },
-    "provide": {
-        "psr/http-message-implementation": "1.0"
-    },
-    "suggest": {
-        "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
-    },
-    "autoload": {
-        "psr-4": {
-            "GuzzleHttp\\Psr7\\": "src/"
-        },
-        "files": ["src/functions_include.php"]
-    },
-    "autoload-dev": {
-        "psr-4": {
-            "GuzzleHttp\\Tests\\Psr7\\": "tests/"
-        }
-    },
-    "config": {
-        "preferred-install": "dist",
-        "sort-packages": true,
-        "allow-plugins": {
-            "bamarni/composer-bin-plugin": true
-        }
-    }
-}
+{
+    "name": "guzzlehttp/psr7",
+    "description": "PSR-7 message implementation that also provides common utility methods",
+    "keywords": ["request", "response", "message", "stream", "http", "uri", "url", "psr-7"],
+    "license": "MIT",
+    "authors": [
+        {
+            "name": "Graham Campbell",
+            "email": "hello@gjcampbell.co.uk",
+            "homepage": "https://github.com/GrahamCampbell"
+        },
+        {
+            "name": "Michael Dowling",
+            "email": "mtdowling@gmail.com",
+            "homepage": "https://github.com/mtdowling"
+        },
+        {
+            "name": "George Mponos",
+            "email": "gmponos@gmail.com",
+            "homepage": "https://github.com/gmponos"
+        },
+        {
+            "name": "Tobias Nyholm",
+            "email": "tobias.nyholm@gmail.com",
+            "homepage": "https://github.com/Nyholm"
+        },
+        {
+            "name": "Márk Sági-Kazár",
+            "email": "mark.sagikazar@gmail.com",
+            "homepage": "https://github.com/sagikazarmark"
+        },
+        {
+            "name": "Tobias Schultze",
+            "email": "webmaster@tubo-world.de",
+            "homepage": "https://github.com/Tobion"
+        }
+    ],
+    "require": {
+        "php": ">=5.4.0",
+        "psr/http-message": "~1.0",
+        "ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
+    },
+    "require-dev": {
+        "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10",
+        "ext-zlib": "*"
+    },
+    "provide": {
+        "psr/http-message-implementation": "1.0"
+    },
+    "suggest": {
+        "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
+    },
+    "autoload": {
+        "psr-4": {
+            "GuzzleHttp\\Psr7\\": "src/"
+        },
+        "files": ["src/functions_include.php"]
+    },
+    "autoload-dev": {
+        "psr-4": {
+            "GuzzleHttp\\Tests\\Psr7\\": "tests/"
+        }
+    },
+    "config": {
+        "preferred-install": "dist",
+        "sort-packages": true,
+        "allow-plugins": {
+            "bamarni/composer-bin-plugin": true
+        }
+    }
+}

+ 246 - 246
vendor/guzzlehttp/psr7/src/AppendStream.php

@@ -1,246 +1,246 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * Reads from multiple streams, one after the other.
- *
- * This is a read-only stream decorator.
- *
- * @final
- */
-class AppendStream implements StreamInterface
-{
-    /** @var StreamInterface[] Streams being decorated */
-    private $streams = [];
-
-    private $seekable = true;
-    private $current = 0;
-    private $pos = 0;
-
-    /**
-     * @param StreamInterface[] $streams Streams to decorate. Each stream must
-     *                                   be readable.
-     */
-    public function __construct(array $streams = [])
-    {
-        foreach ($streams as $stream) {
-            $this->addStream($stream);
-        }
-    }
-
-    public function __toString()
-    {
-        try {
-            $this->rewind();
-            return $this->getContents();
-        } catch (\Exception $e) {
-            return '';
-        }
-    }
-
-    /**
-     * Add a stream to the AppendStream
-     *
-     * @param StreamInterface $stream Stream to append. Must be readable.
-     *
-     * @throws \InvalidArgumentException if the stream is not readable
-     */
-    public function addStream(StreamInterface $stream)
-    {
-        if (!$stream->isReadable()) {
-            throw new \InvalidArgumentException('Each stream must be readable');
-        }
-
-        // The stream is only seekable if all streams are seekable
-        if (!$stream->isSeekable()) {
-            $this->seekable = false;
-        }
-
-        $this->streams[] = $stream;
-    }
-
-    public function getContents()
-    {
-        return Utils::copyToString($this);
-    }
-
-    /**
-     * Closes each attached stream.
-     *
-     * {@inheritdoc}
-     */
-    public function close()
-    {
-        $this->pos = $this->current = 0;
-        $this->seekable = true;
-
-        foreach ($this->streams as $stream) {
-            $stream->close();
-        }
-
-        $this->streams = [];
-    }
-
-    /**
-     * Detaches each attached stream.
-     *
-     * Returns null as it's not clear which underlying stream resource to return.
-     *
-     * {@inheritdoc}
-     */
-    public function detach()
-    {
-        $this->pos = $this->current = 0;
-        $this->seekable = true;
-
-        foreach ($this->streams as $stream) {
-            $stream->detach();
-        }
-
-        $this->streams = [];
-
-        return null;
-    }
-
-    public function tell()
-    {
-        return $this->pos;
-    }
-
-    /**
-     * Tries to calculate the size by adding the size of each stream.
-     *
-     * If any of the streams do not return a valid number, then the size of the
-     * append stream cannot be determined and null is returned.
-     *
-     * {@inheritdoc}
-     */
-    public function getSize()
-    {
-        $size = 0;
-
-        foreach ($this->streams as $stream) {
-            $s = $stream->getSize();
-            if ($s === null) {
-                return null;
-            }
-            $size += $s;
-        }
-
-        return $size;
-    }
-
-    public function eof()
-    {
-        return !$this->streams ||
-            ($this->current >= count($this->streams) - 1 &&
-             $this->streams[$this->current]->eof());
-    }
-
-    public function rewind()
-    {
-        $this->seek(0);
-    }
-
-    /**
-     * Attempts to seek to the given position. Only supports SEEK_SET.
-     *
-     * {@inheritdoc}
-     */
-    public function seek($offset, $whence = SEEK_SET)
-    {
-        if (!$this->seekable) {
-            throw new \RuntimeException('This AppendStream is not seekable');
-        } elseif ($whence !== SEEK_SET) {
-            throw new \RuntimeException('The AppendStream can only seek with SEEK_SET');
-        }
-
-        $this->pos = $this->current = 0;
-
-        // Rewind each stream
-        foreach ($this->streams as $i => $stream) {
-            try {
-                $stream->rewind();
-            } catch (\Exception $e) {
-                throw new \RuntimeException('Unable to seek stream '
-                    . $i . ' of the AppendStream', 0, $e);
-            }
-        }
-
-        // Seek to the actual position by reading from each stream
-        while ($this->pos < $offset && !$this->eof()) {
-            $result = $this->read(min(8096, $offset - $this->pos));
-            if ($result === '') {
-                break;
-            }
-        }
-    }
-
-    /**
-     * Reads from all of the appended streams until the length is met or EOF.
-     *
-     * {@inheritdoc}
-     */
-    public function read($length)
-    {
-        $buffer = '';
-        $total = count($this->streams) - 1;
-        $remaining = $length;
-        $progressToNext = false;
-
-        while ($remaining > 0) {
-
-            // Progress to the next stream if needed.
-            if ($progressToNext || $this->streams[$this->current]->eof()) {
-                $progressToNext = false;
-                if ($this->current === $total) {
-                    break;
-                }
-                $this->current++;
-            }
-
-            $result = $this->streams[$this->current]->read($remaining);
-
-            // Using a loose comparison here to match on '', false, and null
-            if ($result == null) {
-                $progressToNext = true;
-                continue;
-            }
-
-            $buffer .= $result;
-            $remaining = $length - strlen($buffer);
-        }
-
-        $this->pos += strlen($buffer);
-
-        return $buffer;
-    }
-
-    public function isReadable()
-    {
-        return true;
-    }
-
-    public function isWritable()
-    {
-        return false;
-    }
-
-    public function isSeekable()
-    {
-        return $this->seekable;
-    }
-
-    public function write($string)
-    {
-        throw new \RuntimeException('Cannot write to an AppendStream');
-    }
-
-    public function getMetadata($key = null)
-    {
-        return $key ? null : [];
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Reads from multiple streams, one after the other.
+ *
+ * This is a read-only stream decorator.
+ *
+ * @final
+ */
+class AppendStream implements StreamInterface
+{
+    /** @var StreamInterface[] Streams being decorated */
+    private $streams = [];
+
+    private $seekable = true;
+    private $current = 0;
+    private $pos = 0;
+
+    /**
+     * @param StreamInterface[] $streams Streams to decorate. Each stream must
+     *                                   be readable.
+     */
+    public function __construct(array $streams = [])
+    {
+        foreach ($streams as $stream) {
+            $this->addStream($stream);
+        }
+    }
+
+    public function __toString()
+    {
+        try {
+            $this->rewind();
+            return $this->getContents();
+        } catch (\Exception $e) {
+            return '';
+        }
+    }
+
+    /**
+     * Add a stream to the AppendStream
+     *
+     * @param StreamInterface $stream Stream to append. Must be readable.
+     *
+     * @throws \InvalidArgumentException if the stream is not readable
+     */
+    public function addStream(StreamInterface $stream)
+    {
+        if (!$stream->isReadable()) {
+            throw new \InvalidArgumentException('Each stream must be readable');
+        }
+
+        // The stream is only seekable if all streams are seekable
+        if (!$stream->isSeekable()) {
+            $this->seekable = false;
+        }
+
+        $this->streams[] = $stream;
+    }
+
+    public function getContents()
+    {
+        return Utils::copyToString($this);
+    }
+
+    /**
+     * Closes each attached stream.
+     *
+     * {@inheritdoc}
+     */
+    public function close()
+    {
+        $this->pos = $this->current = 0;
+        $this->seekable = true;
+
+        foreach ($this->streams as $stream) {
+            $stream->close();
+        }
+
+        $this->streams = [];
+    }
+
+    /**
+     * Detaches each attached stream.
+     *
+     * Returns null as it's not clear which underlying stream resource to return.
+     *
+     * {@inheritdoc}
+     */
+    public function detach()
+    {
+        $this->pos = $this->current = 0;
+        $this->seekable = true;
+
+        foreach ($this->streams as $stream) {
+            $stream->detach();
+        }
+
+        $this->streams = [];
+
+        return null;
+    }
+
+    public function tell()
+    {
+        return $this->pos;
+    }
+
+    /**
+     * Tries to calculate the size by adding the size of each stream.
+     *
+     * If any of the streams do not return a valid number, then the size of the
+     * append stream cannot be determined and null is returned.
+     *
+     * {@inheritdoc}
+     */
+    public function getSize()
+    {
+        $size = 0;
+
+        foreach ($this->streams as $stream) {
+            $s = $stream->getSize();
+            if ($s === null) {
+                return null;
+            }
+            $size += $s;
+        }
+
+        return $size;
+    }
+
+    public function eof()
+    {
+        return !$this->streams ||
+            ($this->current >= count($this->streams) - 1 &&
+             $this->streams[$this->current]->eof());
+    }
+
+    public function rewind()
+    {
+        $this->seek(0);
+    }
+
+    /**
+     * Attempts to seek to the given position. Only supports SEEK_SET.
+     *
+     * {@inheritdoc}
+     */
+    public function seek($offset, $whence = SEEK_SET)
+    {
+        if (!$this->seekable) {
+            throw new \RuntimeException('This AppendStream is not seekable');
+        } elseif ($whence !== SEEK_SET) {
+            throw new \RuntimeException('The AppendStream can only seek with SEEK_SET');
+        }
+
+        $this->pos = $this->current = 0;
+
+        // Rewind each stream
+        foreach ($this->streams as $i => $stream) {
+            try {
+                $stream->rewind();
+            } catch (\Exception $e) {
+                throw new \RuntimeException('Unable to seek stream '
+                    . $i . ' of the AppendStream', 0, $e);
+            }
+        }
+
+        // Seek to the actual position by reading from each stream
+        while ($this->pos < $offset && !$this->eof()) {
+            $result = $this->read(min(8096, $offset - $this->pos));
+            if ($result === '') {
+                break;
+            }
+        }
+    }
+
+    /**
+     * Reads from all of the appended streams until the length is met or EOF.
+     *
+     * {@inheritdoc}
+     */
+    public function read($length)
+    {
+        $buffer = '';
+        $total = count($this->streams) - 1;
+        $remaining = $length;
+        $progressToNext = false;
+
+        while ($remaining > 0) {
+
+            // Progress to the next stream if needed.
+            if ($progressToNext || $this->streams[$this->current]->eof()) {
+                $progressToNext = false;
+                if ($this->current === $total) {
+                    break;
+                }
+                $this->current++;
+            }
+
+            $result = $this->streams[$this->current]->read($remaining);
+
+            // Using a loose comparison here to match on '', false, and null
+            if ($result == null) {
+                $progressToNext = true;
+                continue;
+            }
+
+            $buffer .= $result;
+            $remaining = $length - strlen($buffer);
+        }
+
+        $this->pos += strlen($buffer);
+
+        return $buffer;
+    }
+
+    public function isReadable()
+    {
+        return true;
+    }
+
+    public function isWritable()
+    {
+        return false;
+    }
+
+    public function isSeekable()
+    {
+        return $this->seekable;
+    }
+
+    public function write($string)
+    {
+        throw new \RuntimeException('Cannot write to an AppendStream');
+    }
+
+    public function getMetadata($key = null)
+    {
+        return $key ? null : [];
+    }
+}

+ 142 - 142
vendor/guzzlehttp/psr7/src/BufferStream.php

@@ -1,142 +1,142 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * Provides a buffer stream that can be written to to fill a buffer, and read
- * from to remove bytes from the buffer.
- *
- * This stream returns a "hwm" metadata value that tells upstream consumers
- * what the configured high water mark of the stream is, or the maximum
- * preferred size of the buffer.
- *
- * @final
- */
-class BufferStream implements StreamInterface
-{
-    private $hwm;
-    private $buffer = '';
-
-    /**
-     * @param int $hwm High water mark, representing the preferred maximum
-     *                 buffer size. If the size of the buffer exceeds the high
-     *                 water mark, then calls to write will continue to succeed
-     *                 but will return false to inform writers to slow down
-     *                 until the buffer has been drained by reading from it.
-     */
-    public function __construct($hwm = 16384)
-    {
-        $this->hwm = $hwm;
-    }
-
-    public function __toString()
-    {
-        return $this->getContents();
-    }
-
-    public function getContents()
-    {
-        $buffer = $this->buffer;
-        $this->buffer = '';
-
-        return $buffer;
-    }
-
-    public function close()
-    {
-        $this->buffer = '';
-    }
-
-    public function detach()
-    {
-        $this->close();
-
-        return null;
-    }
-
-    public function getSize()
-    {
-        return strlen($this->buffer);
-    }
-
-    public function isReadable()
-    {
-        return true;
-    }
-
-    public function isWritable()
-    {
-        return true;
-    }
-
-    public function isSeekable()
-    {
-        return false;
-    }
-
-    public function rewind()
-    {
-        $this->seek(0);
-    }
-
-    public function seek($offset, $whence = SEEK_SET)
-    {
-        throw new \RuntimeException('Cannot seek a BufferStream');
-    }
-
-    public function eof()
-    {
-        return strlen($this->buffer) === 0;
-    }
-
-    public function tell()
-    {
-        throw new \RuntimeException('Cannot determine the position of a BufferStream');
-    }
-
-    /**
-     * Reads data from the buffer.
-     */
-    public function read($length)
-    {
-        $currentLength = strlen($this->buffer);
-
-        if ($length >= $currentLength) {
-            // No need to slice the buffer because we don't have enough data.
-            $result = $this->buffer;
-            $this->buffer = '';
-        } else {
-            // Slice up the result to provide a subset of the buffer.
-            $result = substr($this->buffer, 0, $length);
-            $this->buffer = substr($this->buffer, $length);
-        }
-
-        return $result;
-    }
-
-    /**
-     * Writes data to the buffer.
-     */
-    public function write($string)
-    {
-        $this->buffer .= $string;
-
-        // TODO: What should happen here?
-        if (strlen($this->buffer) >= $this->hwm) {
-            return false;
-        }
-
-        return strlen($string);
-    }
-
-    public function getMetadata($key = null)
-    {
-        if ($key == 'hwm') {
-            return $this->hwm;
-        }
-
-        return $key ? null : [];
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Provides a buffer stream that can be written to to fill a buffer, and read
+ * from to remove bytes from the buffer.
+ *
+ * This stream returns a "hwm" metadata value that tells upstream consumers
+ * what the configured high water mark of the stream is, or the maximum
+ * preferred size of the buffer.
+ *
+ * @final
+ */
+class BufferStream implements StreamInterface
+{
+    private $hwm;
+    private $buffer = '';
+
+    /**
+     * @param int $hwm High water mark, representing the preferred maximum
+     *                 buffer size. If the size of the buffer exceeds the high
+     *                 water mark, then calls to write will continue to succeed
+     *                 but will return false to inform writers to slow down
+     *                 until the buffer has been drained by reading from it.
+     */
+    public function __construct($hwm = 16384)
+    {
+        $this->hwm = $hwm;
+    }
+
+    public function __toString()
+    {
+        return $this->getContents();
+    }
+
+    public function getContents()
+    {
+        $buffer = $this->buffer;
+        $this->buffer = '';
+
+        return $buffer;
+    }
+
+    public function close()
+    {
+        $this->buffer = '';
+    }
+
+    public function detach()
+    {
+        $this->close();
+
+        return null;
+    }
+
+    public function getSize()
+    {
+        return strlen($this->buffer);
+    }
+
+    public function isReadable()
+    {
+        return true;
+    }
+
+    public function isWritable()
+    {
+        return true;
+    }
+
+    public function isSeekable()
+    {
+        return false;
+    }
+
+    public function rewind()
+    {
+        $this->seek(0);
+    }
+
+    public function seek($offset, $whence = SEEK_SET)
+    {
+        throw new \RuntimeException('Cannot seek a BufferStream');
+    }
+
+    public function eof()
+    {
+        return strlen($this->buffer) === 0;
+    }
+
+    public function tell()
+    {
+        throw new \RuntimeException('Cannot determine the position of a BufferStream');
+    }
+
+    /**
+     * Reads data from the buffer.
+     */
+    public function read($length)
+    {
+        $currentLength = strlen($this->buffer);
+
+        if ($length >= $currentLength) {
+            // No need to slice the buffer because we don't have enough data.
+            $result = $this->buffer;
+            $this->buffer = '';
+        } else {
+            // Slice up the result to provide a subset of the buffer.
+            $result = substr($this->buffer, 0, $length);
+            $this->buffer = substr($this->buffer, $length);
+        }
+
+        return $result;
+    }
+
+    /**
+     * Writes data to the buffer.
+     */
+    public function write($string)
+    {
+        $this->buffer .= $string;
+
+        // TODO: What should happen here?
+        if (strlen($this->buffer) >= $this->hwm) {
+            return false;
+        }
+
+        return strlen($string);
+    }
+
+    public function getMetadata($key = null)
+    {
+        if ($key == 'hwm') {
+            return $this->hwm;
+        }
+
+        return $key ? null : [];
+    }
+}

+ 147 - 147
vendor/guzzlehttp/psr7/src/CachingStream.php

@@ -1,147 +1,147 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * Stream decorator that can cache previously read bytes from a sequentially
- * read stream.
- *
- * @final
- */
-class CachingStream implements StreamInterface
-{
-    use StreamDecoratorTrait;
-
-    /** @var StreamInterface Stream being wrapped */
-    private $remoteStream;
-
-    /** @var int Number of bytes to skip reading due to a write on the buffer */
-    private $skipReadBytes = 0;
-
-    /**
-     * We will treat the buffer object as the body of the stream
-     *
-     * @param StreamInterface $stream Stream to cache. The cursor is assumed to be at the beginning of the stream.
-     * @param StreamInterface $target Optionally specify where data is cached
-     */
-    public function __construct(
-        StreamInterface $stream,
-        StreamInterface $target = null
-    ) {
-        $this->remoteStream = $stream;
-        $this->stream = $target ?: new Stream(Utils::tryFopen('php://temp', 'r+'));
-    }
-
-    public function getSize()
-    {
-        $remoteSize = $this->remoteStream->getSize();
-
-        if (null === $remoteSize) {
-            return null;
-        }
-
-        return max($this->stream->getSize(), $remoteSize);
-    }
-
-    public function rewind()
-    {
-        $this->seek(0);
-    }
-
-    public function seek($offset, $whence = SEEK_SET)
-    {
-        if ($whence == SEEK_SET) {
-            $byte = $offset;
-        } elseif ($whence == SEEK_CUR) {
-            $byte = $offset + $this->tell();
-        } elseif ($whence == SEEK_END) {
-            $size = $this->remoteStream->getSize();
-            if ($size === null) {
-                $size = $this->cacheEntireStream();
-            }
-            $byte = $size + $offset;
-        } else {
-            throw new \InvalidArgumentException('Invalid whence');
-        }
-
-        $diff = $byte - $this->stream->getSize();
-
-        if ($diff > 0) {
-            // Read the remoteStream until we have read in at least the amount
-            // of bytes requested, or we reach the end of the file.
-            while ($diff > 0 && !$this->remoteStream->eof()) {
-                $this->read($diff);
-                $diff = $byte - $this->stream->getSize();
-            }
-        } else {
-            // We can just do a normal seek since we've already seen this byte.
-            $this->stream->seek($byte);
-        }
-    }
-
-    public function read($length)
-    {
-        // Perform a regular read on any previously read data from the buffer
-        $data = $this->stream->read($length);
-        $remaining = $length - strlen($data);
-
-        // More data was requested so read from the remote stream
-        if ($remaining) {
-            // If data was written to the buffer in a position that would have
-            // been filled from the remote stream, then we must skip bytes on
-            // the remote stream to emulate overwriting bytes from that
-            // position. This mimics the behavior of other PHP stream wrappers.
-            $remoteData = $this->remoteStream->read(
-                $remaining + $this->skipReadBytes
-            );
-
-            if ($this->skipReadBytes) {
-                $len = strlen($remoteData);
-                $remoteData = substr($remoteData, $this->skipReadBytes);
-                $this->skipReadBytes = max(0, $this->skipReadBytes - $len);
-            }
-
-            $data .= $remoteData;
-            $this->stream->write($remoteData);
-        }
-
-        return $data;
-    }
-
-    public function write($string)
-    {
-        // When appending to the end of the currently read stream, you'll want
-        // to skip bytes from being read from the remote stream to emulate
-        // other stream wrappers. Basically replacing bytes of data of a fixed
-        // length.
-        $overflow = (strlen($string) + $this->tell()) - $this->remoteStream->tell();
-        if ($overflow > 0) {
-            $this->skipReadBytes += $overflow;
-        }
-
-        return $this->stream->write($string);
-    }
-
-    public function eof()
-    {
-        return $this->stream->eof() && $this->remoteStream->eof();
-    }
-
-    /**
-     * Close both the remote stream and buffer stream
-     */
-    public function close()
-    {
-        $this->remoteStream->close() && $this->stream->close();
-    }
-
-    private function cacheEntireStream()
-    {
-        $target = new FnStream(['write' => 'strlen']);
-        Utils::copyToStream($this, $target);
-
-        return $this->tell();
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Stream decorator that can cache previously read bytes from a sequentially
+ * read stream.
+ *
+ * @final
+ */
+class CachingStream implements StreamInterface
+{
+    use StreamDecoratorTrait;
+
+    /** @var StreamInterface Stream being wrapped */
+    private $remoteStream;
+
+    /** @var int Number of bytes to skip reading due to a write on the buffer */
+    private $skipReadBytes = 0;
+
+    /**
+     * We will treat the buffer object as the body of the stream
+     *
+     * @param StreamInterface $stream Stream to cache. The cursor is assumed to be at the beginning of the stream.
+     * @param StreamInterface $target Optionally specify where data is cached
+     */
+    public function __construct(
+        StreamInterface $stream,
+        StreamInterface $target = null
+    ) {
+        $this->remoteStream = $stream;
+        $this->stream = $target ?: new Stream(Utils::tryFopen('php://temp', 'r+'));
+    }
+
+    public function getSize()
+    {
+        $remoteSize = $this->remoteStream->getSize();
+
+        if (null === $remoteSize) {
+            return null;
+        }
+
+        return max($this->stream->getSize(), $remoteSize);
+    }
+
+    public function rewind()
+    {
+        $this->seek(0);
+    }
+
+    public function seek($offset, $whence = SEEK_SET)
+    {
+        if ($whence == SEEK_SET) {
+            $byte = $offset;
+        } elseif ($whence == SEEK_CUR) {
+            $byte = $offset + $this->tell();
+        } elseif ($whence == SEEK_END) {
+            $size = $this->remoteStream->getSize();
+            if ($size === null) {
+                $size = $this->cacheEntireStream();
+            }
+            $byte = $size + $offset;
+        } else {
+            throw new \InvalidArgumentException('Invalid whence');
+        }
+
+        $diff = $byte - $this->stream->getSize();
+
+        if ($diff > 0) {
+            // Read the remoteStream until we have read in at least the amount
+            // of bytes requested, or we reach the end of the file.
+            while ($diff > 0 && !$this->remoteStream->eof()) {
+                $this->read($diff);
+                $diff = $byte - $this->stream->getSize();
+            }
+        } else {
+            // We can just do a normal seek since we've already seen this byte.
+            $this->stream->seek($byte);
+        }
+    }
+
+    public function read($length)
+    {
+        // Perform a regular read on any previously read data from the buffer
+        $data = $this->stream->read($length);
+        $remaining = $length - strlen($data);
+
+        // More data was requested so read from the remote stream
+        if ($remaining) {
+            // If data was written to the buffer in a position that would have
+            // been filled from the remote stream, then we must skip bytes on
+            // the remote stream to emulate overwriting bytes from that
+            // position. This mimics the behavior of other PHP stream wrappers.
+            $remoteData = $this->remoteStream->read(
+                $remaining + $this->skipReadBytes
+            );
+
+            if ($this->skipReadBytes) {
+                $len = strlen($remoteData);
+                $remoteData = substr($remoteData, $this->skipReadBytes);
+                $this->skipReadBytes = max(0, $this->skipReadBytes - $len);
+            }
+
+            $data .= $remoteData;
+            $this->stream->write($remoteData);
+        }
+
+        return $data;
+    }
+
+    public function write($string)
+    {
+        // When appending to the end of the currently read stream, you'll want
+        // to skip bytes from being read from the remote stream to emulate
+        // other stream wrappers. Basically replacing bytes of data of a fixed
+        // length.
+        $overflow = (strlen($string) + $this->tell()) - $this->remoteStream->tell();
+        if ($overflow > 0) {
+            $this->skipReadBytes += $overflow;
+        }
+
+        return $this->stream->write($string);
+    }
+
+    public function eof()
+    {
+        return $this->stream->eof() && $this->remoteStream->eof();
+    }
+
+    /**
+     * Close both the remote stream and buffer stream
+     */
+    public function close()
+    {
+        $this->remoteStream->close() && $this->stream->close();
+    }
+
+    private function cacheEntireStream()
+    {
+        $target = new FnStream(['write' => 'strlen']);
+        Utils::copyToStream($this, $target);
+
+        return $this->tell();
+    }
+}

+ 45 - 45
vendor/guzzlehttp/psr7/src/DroppingStream.php

@@ -1,45 +1,45 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * Stream decorator that begins dropping data once the size of the underlying
- * stream becomes too full.
- *
- * @final
- */
-class DroppingStream implements StreamInterface
-{
-    use StreamDecoratorTrait;
-
-    private $maxLength;
-
-    /**
-     * @param StreamInterface $stream    Underlying stream to decorate.
-     * @param int             $maxLength Maximum size before dropping data.
-     */
-    public function __construct(StreamInterface $stream, $maxLength)
-    {
-        $this->stream = $stream;
-        $this->maxLength = $maxLength;
-    }
-
-    public function write($string)
-    {
-        $diff = $this->maxLength - $this->stream->getSize();
-
-        // Begin returning 0 when the underlying stream is too large.
-        if ($diff <= 0) {
-            return 0;
-        }
-
-        // Write the stream or a subset of the stream if needed.
-        if (strlen($string) < $diff) {
-            return $this->stream->write($string);
-        }
-
-        return $this->stream->write(substr($string, 0, $diff));
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Stream decorator that begins dropping data once the size of the underlying
+ * stream becomes too full.
+ *
+ * @final
+ */
+class DroppingStream implements StreamInterface
+{
+    use StreamDecoratorTrait;
+
+    private $maxLength;
+
+    /**
+     * @param StreamInterface $stream    Underlying stream to decorate.
+     * @param int             $maxLength Maximum size before dropping data.
+     */
+    public function __construct(StreamInterface $stream, $maxLength)
+    {
+        $this->stream = $stream;
+        $this->maxLength = $maxLength;
+    }
+
+    public function write($string)
+    {
+        $diff = $this->maxLength - $this->stream->getSize();
+
+        // Begin returning 0 when the underlying stream is too large.
+        if ($diff <= 0) {
+            return 0;
+        }
+
+        // Write the stream or a subset of the stream if needed.
+        if (strlen($string) < $diff) {
+            return $this->stream->write($string);
+        }
+
+        return $this->stream->write(substr($string, 0, $diff));
+    }
+}

+ 163 - 163
vendor/guzzlehttp/psr7/src/FnStream.php

@@ -1,163 +1,163 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * Compose stream implementations based on a hash of functions.
- *
- * Allows for easy testing and extension of a provided stream without needing
- * to create a concrete class for a simple extension point.
- *
- * @final
- */
-class FnStream implements StreamInterface
-{
-    /** @var array */
-    private $methods;
-
-    /** @var array Methods that must be implemented in the given array */
-    private static $slots = ['__toString', 'close', 'detach', 'rewind',
-        'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write',
-        'isReadable', 'read', 'getContents', 'getMetadata'];
-
-    /**
-     * @param array $methods Hash of method name to a callable.
-     */
-    public function __construct(array $methods)
-    {
-        $this->methods = $methods;
-
-        // Create the functions on the class
-        foreach ($methods as $name => $fn) {
-            $this->{'_fn_' . $name} = $fn;
-        }
-    }
-
-    /**
-     * Lazily determine which methods are not implemented.
-     *
-     * @throws \BadMethodCallException
-     */
-    public function __get($name)
-    {
-        throw new \BadMethodCallException(str_replace('_fn_', '', $name)
-            . '() is not implemented in the FnStream');
-    }
-
-    /**
-     * The close method is called on the underlying stream only if possible.
-     */
-    public function __destruct()
-    {
-        if (isset($this->_fn_close)) {
-            call_user_func($this->_fn_close);
-        }
-    }
-
-    /**
-     * An unserialize would allow the __destruct to run when the unserialized value goes out of scope.
-     *
-     * @throws \LogicException
-     */
-    public function __wakeup()
-    {
-        throw new \LogicException('FnStream should never be unserialized');
-    }
-
-    /**
-     * Adds custom functionality to an underlying stream by intercepting
-     * specific method calls.
-     *
-     * @param StreamInterface $stream  Stream to decorate
-     * @param array           $methods Hash of method name to a closure
-     *
-     * @return FnStream
-     */
-    public static function decorate(StreamInterface $stream, array $methods)
-    {
-        // If any of the required methods were not provided, then simply
-        // proxy to the decorated stream.
-        foreach (array_diff(self::$slots, array_keys($methods)) as $diff) {
-            $methods[$diff] = [$stream, $diff];
-        }
-
-        return new self($methods);
-    }
-
-    public function __toString()
-    {
-        return call_user_func($this->_fn___toString);
-    }
-
-    public function close()
-    {
-        return call_user_func($this->_fn_close);
-    }
-
-    public function detach()
-    {
-        return call_user_func($this->_fn_detach);
-    }
-
-    public function getSize()
-    {
-        return call_user_func($this->_fn_getSize);
-    }
-
-    public function tell()
-    {
-        return call_user_func($this->_fn_tell);
-    }
-
-    public function eof()
-    {
-        return call_user_func($this->_fn_eof);
-    }
-
-    public function isSeekable()
-    {
-        return call_user_func($this->_fn_isSeekable);
-    }
-
-    public function rewind()
-    {
-        call_user_func($this->_fn_rewind);
-    }
-
-    public function seek($offset, $whence = SEEK_SET)
-    {
-        call_user_func($this->_fn_seek, $offset, $whence);
-    }
-
-    public function isWritable()
-    {
-        return call_user_func($this->_fn_isWritable);
-    }
-
-    public function write($string)
-    {
-        return call_user_func($this->_fn_write, $string);
-    }
-
-    public function isReadable()
-    {
-        return call_user_func($this->_fn_isReadable);
-    }
-
-    public function read($length)
-    {
-        return call_user_func($this->_fn_read, $length);
-    }
-
-    public function getContents()
-    {
-        return call_user_func($this->_fn_getContents);
-    }
-
-    public function getMetadata($key = null)
-    {
-        return call_user_func($this->_fn_getMetadata, $key);
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Compose stream implementations based on a hash of functions.
+ *
+ * Allows for easy testing and extension of a provided stream without needing
+ * to create a concrete class for a simple extension point.
+ *
+ * @final
+ */
+class FnStream implements StreamInterface
+{
+    /** @var array */
+    private $methods;
+
+    /** @var array Methods that must be implemented in the given array */
+    private static $slots = ['__toString', 'close', 'detach', 'rewind',
+        'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write',
+        'isReadable', 'read', 'getContents', 'getMetadata'];
+
+    /**
+     * @param array $methods Hash of method name to a callable.
+     */
+    public function __construct(array $methods)
+    {
+        $this->methods = $methods;
+
+        // Create the functions on the class
+        foreach ($methods as $name => $fn) {
+            $this->{'_fn_' . $name} = $fn;
+        }
+    }
+
+    /**
+     * Lazily determine which methods are not implemented.
+     *
+     * @throws \BadMethodCallException
+     */
+    public function __get($name)
+    {
+        throw new \BadMethodCallException(str_replace('_fn_', '', $name)
+            . '() is not implemented in the FnStream');
+    }
+
+    /**
+     * The close method is called on the underlying stream only if possible.
+     */
+    public function __destruct()
+    {
+        if (isset($this->_fn_close)) {
+            call_user_func($this->_fn_close);
+        }
+    }
+
+    /**
+     * An unserialize would allow the __destruct to run when the unserialized value goes out of scope.
+     *
+     * @throws \LogicException
+     */
+    public function __wakeup()
+    {
+        throw new \LogicException('FnStream should never be unserialized');
+    }
+
+    /**
+     * Adds custom functionality to an underlying stream by intercepting
+     * specific method calls.
+     *
+     * @param StreamInterface $stream  Stream to decorate
+     * @param array           $methods Hash of method name to a closure
+     *
+     * @return FnStream
+     */
+    public static function decorate(StreamInterface $stream, array $methods)
+    {
+        // If any of the required methods were not provided, then simply
+        // proxy to the decorated stream.
+        foreach (array_diff(self::$slots, array_keys($methods)) as $diff) {
+            $methods[$diff] = [$stream, $diff];
+        }
+
+        return new self($methods);
+    }
+
+    public function __toString()
+    {
+        return call_user_func($this->_fn___toString);
+    }
+
+    public function close()
+    {
+        return call_user_func($this->_fn_close);
+    }
+
+    public function detach()
+    {
+        return call_user_func($this->_fn_detach);
+    }
+
+    public function getSize()
+    {
+        return call_user_func($this->_fn_getSize);
+    }
+
+    public function tell()
+    {
+        return call_user_func($this->_fn_tell);
+    }
+
+    public function eof()
+    {
+        return call_user_func($this->_fn_eof);
+    }
+
+    public function isSeekable()
+    {
+        return call_user_func($this->_fn_isSeekable);
+    }
+
+    public function rewind()
+    {
+        call_user_func($this->_fn_rewind);
+    }
+
+    public function seek($offset, $whence = SEEK_SET)
+    {
+        call_user_func($this->_fn_seek, $offset, $whence);
+    }
+
+    public function isWritable()
+    {
+        return call_user_func($this->_fn_isWritable);
+    }
+
+    public function write($string)
+    {
+        return call_user_func($this->_fn_write, $string);
+    }
+
+    public function isReadable()
+    {
+        return call_user_func($this->_fn_isReadable);
+    }
+
+    public function read($length)
+    {
+        return call_user_func($this->_fn_read, $length);
+    }
+
+    public function getContents()
+    {
+        return call_user_func($this->_fn_getContents);
+    }
+
+    public function getMetadata($key = null)
+    {
+        return call_user_func($this->_fn_getMetadata, $key);
+    }
+}

+ 71 - 71
vendor/guzzlehttp/psr7/src/Header.php

@@ -1,71 +1,71 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-final class Header
-{
-    /**
-     * Parse an array of header values containing ";" separated data into an
-     * array of associative arrays representing the header key value pair data
-     * of the header. When a parameter does not contain a value, but just
-     * contains a key, this function will inject a key with a '' string value.
-     *
-     * @param string|array $header Header to parse into components.
-     *
-     * @return array Returns the parsed header values.
-     */
-    public static function parse($header)
-    {
-        static $trimmed = "\"'  \n\t\r";
-        $params = $matches = [];
-
-        foreach (self::normalize($header) as $val) {
-            $part = [];
-            foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) {
-                if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
-                    $m = $matches[0];
-                    if (isset($m[1])) {
-                        $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed);
-                    } else {
-                        $part[] = trim($m[0], $trimmed);
-                    }
-                }
-            }
-            if ($part) {
-                $params[] = $part;
-            }
-        }
-
-        return $params;
-    }
-
-    /**
-     * Converts an array of header values that may contain comma separated
-     * headers into an array of headers with no comma separated values.
-     *
-     * @param string|array $header Header to normalize.
-     *
-     * @return array Returns the normalized header field values.
-     */
-    public static function normalize($header)
-    {
-        if (!is_array($header)) {
-            return array_map('trim', explode(',', $header));
-        }
-
-        $result = [];
-        foreach ($header as $value) {
-            foreach ((array) $value as $v) {
-                if (strpos($v, ',') === false) {
-                    $result[] = $v;
-                    continue;
-                }
-                foreach (preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $v) as $vv) {
-                    $result[] = trim($vv);
-                }
-            }
-        }
-
-        return $result;
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+final class Header
+{
+    /**
+     * Parse an array of header values containing ";" separated data into an
+     * array of associative arrays representing the header key value pair data
+     * of the header. When a parameter does not contain a value, but just
+     * contains a key, this function will inject a key with a '' string value.
+     *
+     * @param string|array $header Header to parse into components.
+     *
+     * @return array Returns the parsed header values.
+     */
+    public static function parse($header)
+    {
+        static $trimmed = "\"'  \n\t\r";
+        $params = $matches = [];
+
+        foreach (self::normalize($header) as $val) {
+            $part = [];
+            foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) {
+                if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
+                    $m = $matches[0];
+                    if (isset($m[1])) {
+                        $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed);
+                    } else {
+                        $part[] = trim($m[0], $trimmed);
+                    }
+                }
+            }
+            if ($part) {
+                $params[] = $part;
+            }
+        }
+
+        return $params;
+    }
+
+    /**
+     * Converts an array of header values that may contain comma separated
+     * headers into an array of headers with no comma separated values.
+     *
+     * @param string|array $header Header to normalize.
+     *
+     * @return array Returns the normalized header field values.
+     */
+    public static function normalize($header)
+    {
+        if (!is_array($header)) {
+            return array_map('trim', explode(',', $header));
+        }
+
+        $result = [];
+        foreach ($header as $value) {
+            foreach ((array) $value as $v) {
+                if (strpos($v, ',') === false) {
+                    $result[] = $v;
+                    continue;
+                }
+                foreach (preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $v) as $vv) {
+                    $result[] = trim($vv);
+                }
+            }
+        }
+
+        return $result;
+    }
+}

+ 56 - 56
vendor/guzzlehttp/psr7/src/InflateStream.php

@@ -1,56 +1,56 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
- *
- * This stream decorator skips the first 10 bytes of the given stream to remove
- * the gzip header, converts the provided stream to a PHP stream resource,
- * then appends the zlib.inflate filter. The stream is then converted back
- * to a Guzzle stream resource to be used as a Guzzle stream.
- *
- * @link http://tools.ietf.org/html/rfc1952
- * @link http://php.net/manual/en/filters.compression.php
- *
- * @final
- */
-class InflateStream implements StreamInterface
-{
-    use StreamDecoratorTrait;
-
-    public function __construct(StreamInterface $stream)
-    {
-        // read the first 10 bytes, ie. gzip header
-        $header = $stream->read(10);
-        $filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header);
-        // Skip the header, that is 10 + length of filename + 1 (nil) bytes
-        $stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength);
-        $resource = StreamWrapper::getResource($stream);
-        stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
-        $this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource));
-    }
-
-    /**
-     * @param StreamInterface $stream
-     * @param $header
-     *
-     * @return int
-     */
-    private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header)
-    {
-        $filename_header_length = 0;
-
-        if (substr(bin2hex($header), 6, 2) === '08') {
-            // we have a filename, read until nil
-            $filename_header_length = 1;
-            while ($stream->read(1) !== chr(0)) {
-                $filename_header_length++;
-            }
-        }
-
-        return $filename_header_length;
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
+ *
+ * This stream decorator skips the first 10 bytes of the given stream to remove
+ * the gzip header, converts the provided stream to a PHP stream resource,
+ * then appends the zlib.inflate filter. The stream is then converted back
+ * to a Guzzle stream resource to be used as a Guzzle stream.
+ *
+ * @link http://tools.ietf.org/html/rfc1952
+ * @link http://php.net/manual/en/filters.compression.php
+ *
+ * @final
+ */
+class InflateStream implements StreamInterface
+{
+    use StreamDecoratorTrait;
+
+    public function __construct(StreamInterface $stream)
+    {
+        // read the first 10 bytes, ie. gzip header
+        $header = $stream->read(10);
+        $filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header);
+        // Skip the header, that is 10 + length of filename + 1 (nil) bytes
+        $stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength);
+        $resource = StreamWrapper::getResource($stream);
+        stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
+        $this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource));
+    }
+
+    /**
+     * @param StreamInterface $stream
+     * @param $header
+     *
+     * @return int
+     */
+    private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header)
+    {
+        $filename_header_length = 0;
+
+        if (substr(bin2hex($header), 6, 2) === '08') {
+            // we have a filename, read until nil
+            $filename_header_length = 1;
+            while ($stream->read(1) !== chr(0)) {
+                $filename_header_length++;
+            }
+        }
+
+        return $filename_header_length;
+    }
+}

+ 42 - 42
vendor/guzzlehttp/psr7/src/LazyOpenStream.php

@@ -1,42 +1,42 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * Lazily reads or writes to a file that is opened only after an IO operation
- * take place on the stream.
- *
- * @final
- */
-class LazyOpenStream implements StreamInterface
-{
-    use StreamDecoratorTrait;
-
-    /** @var string File to open */
-    private $filename;
-
-    /** @var string */
-    private $mode;
-
-    /**
-     * @param string $filename File to lazily open
-     * @param string $mode     fopen mode to use when opening the stream
-     */
-    public function __construct($filename, $mode)
-    {
-        $this->filename = $filename;
-        $this->mode = $mode;
-    }
-
-    /**
-     * Creates the underlying stream lazily when required.
-     *
-     * @return StreamInterface
-     */
-    protected function createStream()
-    {
-        return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode));
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Lazily reads or writes to a file that is opened only after an IO operation
+ * take place on the stream.
+ *
+ * @final
+ */
+class LazyOpenStream implements StreamInterface
+{
+    use StreamDecoratorTrait;
+
+    /** @var string File to open */
+    private $filename;
+
+    /** @var string */
+    private $mode;
+
+    /**
+     * @param string $filename File to lazily open
+     * @param string $mode     fopen mode to use when opening the stream
+     */
+    public function __construct($filename, $mode)
+    {
+        $this->filename = $filename;
+        $this->mode = $mode;
+    }
+
+    /**
+     * Creates the underlying stream lazily when required.
+     *
+     * @return StreamInterface
+     */
+    protected function createStream()
+    {
+        return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode));
+    }
+}

+ 157 - 157
vendor/guzzlehttp/psr7/src/LimitStream.php

@@ -1,157 +1,157 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * Decorator used to return only a subset of a stream.
- *
- * @final
- */
-class LimitStream implements StreamInterface
-{
-    use StreamDecoratorTrait;
-
-    /** @var int Offset to start reading from */
-    private $offset;
-
-    /** @var int Limit the number of bytes that can be read */
-    private $limit;
-
-    /**
-     * @param StreamInterface $stream Stream to wrap
-     * @param int             $limit  Total number of bytes to allow to be read
-     *                                from the stream. Pass -1 for no limit.
-     * @param int             $offset Position to seek to before reading (only
-     *                                works on seekable streams).
-     */
-    public function __construct(
-        StreamInterface $stream,
-        $limit = -1,
-        $offset = 0
-    ) {
-        $this->stream = $stream;
-        $this->setLimit($limit);
-        $this->setOffset($offset);
-    }
-
-    public function eof()
-    {
-        // Always return true if the underlying stream is EOF
-        if ($this->stream->eof()) {
-            return true;
-        }
-
-        // No limit and the underlying stream is not at EOF
-        if ($this->limit == -1) {
-            return false;
-        }
-
-        return $this->stream->tell() >= $this->offset + $this->limit;
-    }
-
-    /**
-     * Returns the size of the limited subset of data
-     * {@inheritdoc}
-     */
-    public function getSize()
-    {
-        if (null === ($length = $this->stream->getSize())) {
-            return null;
-        } elseif ($this->limit == -1) {
-            return $length - $this->offset;
-        } else {
-            return min($this->limit, $length - $this->offset);
-        }
-    }
-
-    /**
-     * Allow for a bounded seek on the read limited stream
-     * {@inheritdoc}
-     */
-    public function seek($offset, $whence = SEEK_SET)
-    {
-        if ($whence !== SEEK_SET || $offset < 0) {
-            throw new \RuntimeException(sprintf(
-                'Cannot seek to offset %s with whence %s',
-                $offset,
-                $whence
-            ));
-        }
-
-        $offset += $this->offset;
-
-        if ($this->limit !== -1) {
-            if ($offset > $this->offset + $this->limit) {
-                $offset = $this->offset + $this->limit;
-            }
-        }
-
-        $this->stream->seek($offset);
-    }
-
-    /**
-     * Give a relative tell()
-     * {@inheritdoc}
-     */
-    public function tell()
-    {
-        return $this->stream->tell() - $this->offset;
-    }
-
-    /**
-     * Set the offset to start limiting from
-     *
-     * @param int $offset Offset to seek to and begin byte limiting from
-     *
-     * @throws \RuntimeException if the stream cannot be seeked.
-     */
-    public function setOffset($offset)
-    {
-        $current = $this->stream->tell();
-
-        if ($current !== $offset) {
-            // If the stream cannot seek to the offset position, then read to it
-            if ($this->stream->isSeekable()) {
-                $this->stream->seek($offset);
-            } elseif ($current > $offset) {
-                throw new \RuntimeException("Could not seek to stream offset $offset");
-            } else {
-                $this->stream->read($offset - $current);
-            }
-        }
-
-        $this->offset = $offset;
-    }
-
-    /**
-     * Set the limit of bytes that the decorator allows to be read from the
-     * stream.
-     *
-     * @param int $limit Number of bytes to allow to be read from the stream.
-     *                   Use -1 for no limit.
-     */
-    public function setLimit($limit)
-    {
-        $this->limit = $limit;
-    }
-
-    public function read($length)
-    {
-        if ($this->limit == -1) {
-            return $this->stream->read($length);
-        }
-
-        // Check if the current position is less than the total allowed
-        // bytes + original offset
-        $remaining = ($this->offset + $this->limit) - $this->stream->tell();
-        if ($remaining > 0) {
-            // Only return the amount of requested data, ensuring that the byte
-            // limit is not exceeded
-            return $this->stream->read(min($remaining, $length));
-        }
-
-        return '';
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Decorator used to return only a subset of a stream.
+ *
+ * @final
+ */
+class LimitStream implements StreamInterface
+{
+    use StreamDecoratorTrait;
+
+    /** @var int Offset to start reading from */
+    private $offset;
+
+    /** @var int Limit the number of bytes that can be read */
+    private $limit;
+
+    /**
+     * @param StreamInterface $stream Stream to wrap
+     * @param int             $limit  Total number of bytes to allow to be read
+     *                                from the stream. Pass -1 for no limit.
+     * @param int             $offset Position to seek to before reading (only
+     *                                works on seekable streams).
+     */
+    public function __construct(
+        StreamInterface $stream,
+        $limit = -1,
+        $offset = 0
+    ) {
+        $this->stream = $stream;
+        $this->setLimit($limit);
+        $this->setOffset($offset);
+    }
+
+    public function eof()
+    {
+        // Always return true if the underlying stream is EOF
+        if ($this->stream->eof()) {
+            return true;
+        }
+
+        // No limit and the underlying stream is not at EOF
+        if ($this->limit == -1) {
+            return false;
+        }
+
+        return $this->stream->tell() >= $this->offset + $this->limit;
+    }
+
+    /**
+     * Returns the size of the limited subset of data
+     * {@inheritdoc}
+     */
+    public function getSize()
+    {
+        if (null === ($length = $this->stream->getSize())) {
+            return null;
+        } elseif ($this->limit == -1) {
+            return $length - $this->offset;
+        } else {
+            return min($this->limit, $length - $this->offset);
+        }
+    }
+
+    /**
+     * Allow for a bounded seek on the read limited stream
+     * {@inheritdoc}
+     */
+    public function seek($offset, $whence = SEEK_SET)
+    {
+        if ($whence !== SEEK_SET || $offset < 0) {
+            throw new \RuntimeException(sprintf(
+                'Cannot seek to offset %s with whence %s',
+                $offset,
+                $whence
+            ));
+        }
+
+        $offset += $this->offset;
+
+        if ($this->limit !== -1) {
+            if ($offset > $this->offset + $this->limit) {
+                $offset = $this->offset + $this->limit;
+            }
+        }
+
+        $this->stream->seek($offset);
+    }
+
+    /**
+     * Give a relative tell()
+     * {@inheritdoc}
+     */
+    public function tell()
+    {
+        return $this->stream->tell() - $this->offset;
+    }
+
+    /**
+     * Set the offset to start limiting from
+     *
+     * @param int $offset Offset to seek to and begin byte limiting from
+     *
+     * @throws \RuntimeException if the stream cannot be seeked.
+     */
+    public function setOffset($offset)
+    {
+        $current = $this->stream->tell();
+
+        if ($current !== $offset) {
+            // If the stream cannot seek to the offset position, then read to it
+            if ($this->stream->isSeekable()) {
+                $this->stream->seek($offset);
+            } elseif ($current > $offset) {
+                throw new \RuntimeException("Could not seek to stream offset $offset");
+            } else {
+                $this->stream->read($offset - $current);
+            }
+        }
+
+        $this->offset = $offset;
+    }
+
+    /**
+     * Set the limit of bytes that the decorator allows to be read from the
+     * stream.
+     *
+     * @param int $limit Number of bytes to allow to be read from the stream.
+     *                   Use -1 for no limit.
+     */
+    public function setLimit($limit)
+    {
+        $this->limit = $limit;
+    }
+
+    public function read($length)
+    {
+        if ($this->limit == -1) {
+            return $this->stream->read($length);
+        }
+
+        // Check if the current position is less than the total allowed
+        // bytes + original offset
+        $remaining = ($this->offset + $this->limit) - $this->stream->tell();
+        if ($remaining > 0) {
+            // Only return the amount of requested data, ensuring that the byte
+            // limit is not exceeded
+            return $this->stream->read(min($remaining, $length));
+        }
+
+        return '';
+    }
+}

+ 252 - 252
vendor/guzzlehttp/psr7/src/Message.php

@@ -1,252 +1,252 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\MessageInterface;
-use Psr\Http\Message\RequestInterface;
-use Psr\Http\Message\ResponseInterface;
-
-final class Message
-{
-    /**
-     * Returns the string representation of an HTTP message.
-     *
-     * @param MessageInterface $message Message to convert to a string.
-     *
-     * @return string
-     */
-    public static function toString(MessageInterface $message)
-    {
-        if ($message instanceof RequestInterface) {
-            $msg = trim($message->getMethod() . ' '
-                    . $message->getRequestTarget())
-                . ' HTTP/' . $message->getProtocolVersion();
-            if (!$message->hasHeader('host')) {
-                $msg .= "\r\nHost: " . $message->getUri()->getHost();
-            }
-        } elseif ($message instanceof ResponseInterface) {
-            $msg = 'HTTP/' . $message->getProtocolVersion() . ' '
-                . $message->getStatusCode() . ' '
-                . $message->getReasonPhrase();
-        } else {
-            throw new \InvalidArgumentException('Unknown message type');
-        }
-
-        foreach ($message->getHeaders() as $name => $values) {
-            if (strtolower($name) === 'set-cookie') {
-                foreach ($values as $value) {
-                    $msg .= "\r\n{$name}: " . $value;
-                }
-            } else {
-                $msg .= "\r\n{$name}: " . implode(', ', $values);
-            }
-        }
-
-        return "{$msg}\r\n\r\n" . $message->getBody();
-    }
-
-    /**
-     * Get a short summary of the message body.
-     *
-     * Will return `null` if the response is not printable.
-     *
-     * @param MessageInterface $message    The message to get the body summary
-     * @param int              $truncateAt The maximum allowed size of the summary
-     *
-     * @return string|null
-     */
-    public static function bodySummary(MessageInterface $message, $truncateAt = 120)
-    {
-        $body = $message->getBody();
-
-        if (!$body->isSeekable() || !$body->isReadable()) {
-            return null;
-        }
-
-        $size = $body->getSize();
-
-        if ($size === 0) {
-            return null;
-        }
-
-        $summary = $body->read($truncateAt);
-        $body->rewind();
-
-        if ($size > $truncateAt) {
-            $summary .= ' (truncated...)';
-        }
-
-        // Matches any printable character, including unicode characters:
-        // letters, marks, numbers, punctuation, spacing, and separators.
-        if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary)) {
-            return null;
-        }
-
-        return $summary;
-    }
-
-    /**
-     * Attempts to rewind a message body and throws an exception on failure.
-     *
-     * The body of the message will only be rewound if a call to `tell()`
-     * returns a value other than `0`.
-     *
-     * @param MessageInterface $message Message to rewind
-     *
-     * @throws \RuntimeException
-     */
-    public static function rewindBody(MessageInterface $message)
-    {
-        $body = $message->getBody();
-
-        if ($body->tell()) {
-            $body->rewind();
-        }
-    }
-
-    /**
-     * Parses an HTTP message into an associative array.
-     *
-     * The array contains the "start-line" key containing the start line of
-     * the message, "headers" key containing an associative array of header
-     * array values, and a "body" key containing the body of the message.
-     *
-     * @param string $message HTTP request or response to parse.
-     *
-     * @return array
-     */
-    public static function parseMessage($message)
-    {
-        if (!$message) {
-            throw new \InvalidArgumentException('Invalid message');
-        }
-
-        $message = ltrim($message, "\r\n");
-
-        $messageParts = preg_split("/\r?\n\r?\n/", $message, 2);
-
-        if ($messageParts === false || count($messageParts) !== 2) {
-            throw new \InvalidArgumentException('Invalid message: Missing header delimiter');
-        }
-
-        list($rawHeaders, $body) = $messageParts;
-        $rawHeaders .= "\r\n"; // Put back the delimiter we split previously
-        $headerParts = preg_split("/\r?\n/", $rawHeaders, 2);
-
-        if ($headerParts === false || count($headerParts) !== 2) {
-            throw new \InvalidArgumentException('Invalid message: Missing status line');
-        }
-
-        list($startLine, $rawHeaders) = $headerParts;
-
-        if (preg_match("/(?:^HTTP\/|^[A-Z]+ \S+ HTTP\/)(\d+(?:\.\d+)?)/i", $startLine, $matches) && $matches[1] === '1.0') {
-            // Header folding is deprecated for HTTP/1.1, but allowed in HTTP/1.0
-            $rawHeaders = preg_replace(Rfc7230::HEADER_FOLD_REGEX, ' ', $rawHeaders);
-        }
-
-        /** @var array[] $headerLines */
-        $count = preg_match_all(Rfc7230::HEADER_REGEX, $rawHeaders, $headerLines, PREG_SET_ORDER);
-
-        // If these aren't the same, then one line didn't match and there's an invalid header.
-        if ($count !== substr_count($rawHeaders, "\n")) {
-            // Folding is deprecated, see https://tools.ietf.org/html/rfc7230#section-3.2.4
-            if (preg_match(Rfc7230::HEADER_FOLD_REGEX, $rawHeaders)) {
-                throw new \InvalidArgumentException('Invalid header syntax: Obsolete line folding');
-            }
-
-            throw new \InvalidArgumentException('Invalid header syntax');
-        }
-
-        $headers = [];
-
-        foreach ($headerLines as $headerLine) {
-            $headers[$headerLine[1]][] = $headerLine[2];
-        }
-
-        return [
-            'start-line' => $startLine,
-            'headers' => $headers,
-            'body' => $body,
-        ];
-    }
-
-    /**
-     * Constructs a URI for an HTTP request message.
-     *
-     * @param string $path    Path from the start-line
-     * @param array  $headers Array of headers (each value an array).
-     *
-     * @return string
-     */
-    public static function parseRequestUri($path, array $headers)
-    {
-        $hostKey = array_filter(array_keys($headers), function ($k) {
-            return strtolower($k) === 'host';
-        });
-
-        // If no host is found, then a full URI cannot be constructed.
-        if (!$hostKey) {
-            return $path;
-        }
-
-        $host = $headers[reset($hostKey)][0];
-        $scheme = substr($host, -4) === ':443' ? 'https' : 'http';
-
-        return $scheme . '://' . $host . '/' . ltrim($path, '/');
-    }
-
-    /**
-     * Parses a request message string into a request object.
-     *
-     * @param string $message Request message string.
-     *
-     * @return Request
-     */
-    public static function parseRequest($message)
-    {
-        $data = self::parseMessage($message);
-        $matches = [];
-        if (!preg_match('/^[\S]+\s+([a-zA-Z]+:\/\/|\/).*/', $data['start-line'], $matches)) {
-            throw new \InvalidArgumentException('Invalid request string');
-        }
-        $parts = explode(' ', $data['start-line'], 3);
-        $version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1';
-
-        $request = new Request(
-            $parts[0],
-            $matches[1] === '/' ? self::parseRequestUri($parts[1], $data['headers']) : $parts[1],
-            $data['headers'],
-            $data['body'],
-            $version
-        );
-
-        return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]);
-    }
-
-    /**
-     * Parses a response message string into a response object.
-     *
-     * @param string $message Response message string.
-     *
-     * @return Response
-     */
-    public static function parseResponse($message)
-    {
-        $data = self::parseMessage($message);
-        // According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space
-        // between status-code and reason-phrase is required. But browsers accept
-        // responses without space and reason as well.
-        if (!preg_match('/^HTTP\/.* [0-9]{3}( .*|$)/', $data['start-line'])) {
-            throw new \InvalidArgumentException('Invalid response string: ' . $data['start-line']);
-        }
-        $parts = explode(' ', $data['start-line'], 3);
-
-        return new Response(
-            (int) $parts[1],
-            $data['headers'],
-            $data['body'],
-            explode('/', $parts[0])[1],
-            isset($parts[2]) ? $parts[2] : null
-        );
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\MessageInterface;
+use Psr\Http\Message\RequestInterface;
+use Psr\Http\Message\ResponseInterface;
+
+final class Message
+{
+    /**
+     * Returns the string representation of an HTTP message.
+     *
+     * @param MessageInterface $message Message to convert to a string.
+     *
+     * @return string
+     */
+    public static function toString(MessageInterface $message)
+    {
+        if ($message instanceof RequestInterface) {
+            $msg = trim($message->getMethod() . ' '
+                    . $message->getRequestTarget())
+                . ' HTTP/' . $message->getProtocolVersion();
+            if (!$message->hasHeader('host')) {
+                $msg .= "\r\nHost: " . $message->getUri()->getHost();
+            }
+        } elseif ($message instanceof ResponseInterface) {
+            $msg = 'HTTP/' . $message->getProtocolVersion() . ' '
+                . $message->getStatusCode() . ' '
+                . $message->getReasonPhrase();
+        } else {
+            throw new \InvalidArgumentException('Unknown message type');
+        }
+
+        foreach ($message->getHeaders() as $name => $values) {
+            if (strtolower($name) === 'set-cookie') {
+                foreach ($values as $value) {
+                    $msg .= "\r\n{$name}: " . $value;
+                }
+            } else {
+                $msg .= "\r\n{$name}: " . implode(', ', $values);
+            }
+        }
+
+        return "{$msg}\r\n\r\n" . $message->getBody();
+    }
+
+    /**
+     * Get a short summary of the message body.
+     *
+     * Will return `null` if the response is not printable.
+     *
+     * @param MessageInterface $message    The message to get the body summary
+     * @param int              $truncateAt The maximum allowed size of the summary
+     *
+     * @return string|null
+     */
+    public static function bodySummary(MessageInterface $message, $truncateAt = 120)
+    {
+        $body = $message->getBody();
+
+        if (!$body->isSeekable() || !$body->isReadable()) {
+            return null;
+        }
+
+        $size = $body->getSize();
+
+        if ($size === 0) {
+            return null;
+        }
+
+        $summary = $body->read($truncateAt);
+        $body->rewind();
+
+        if ($size > $truncateAt) {
+            $summary .= ' (truncated...)';
+        }
+
+        // Matches any printable character, including unicode characters:
+        // letters, marks, numbers, punctuation, spacing, and separators.
+        if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary)) {
+            return null;
+        }
+
+        return $summary;
+    }
+
+    /**
+     * Attempts to rewind a message body and throws an exception on failure.
+     *
+     * The body of the message will only be rewound if a call to `tell()`
+     * returns a value other than `0`.
+     *
+     * @param MessageInterface $message Message to rewind
+     *
+     * @throws \RuntimeException
+     */
+    public static function rewindBody(MessageInterface $message)
+    {
+        $body = $message->getBody();
+
+        if ($body->tell()) {
+            $body->rewind();
+        }
+    }
+
+    /**
+     * Parses an HTTP message into an associative array.
+     *
+     * The array contains the "start-line" key containing the start line of
+     * the message, "headers" key containing an associative array of header
+     * array values, and a "body" key containing the body of the message.
+     *
+     * @param string $message HTTP request or response to parse.
+     *
+     * @return array
+     */
+    public static function parseMessage($message)
+    {
+        if (!$message) {
+            throw new \InvalidArgumentException('Invalid message');
+        }
+
+        $message = ltrim($message, "\r\n");
+
+        $messageParts = preg_split("/\r?\n\r?\n/", $message, 2);
+
+        if ($messageParts === false || count($messageParts) !== 2) {
+            throw new \InvalidArgumentException('Invalid message: Missing header delimiter');
+        }
+
+        list($rawHeaders, $body) = $messageParts;
+        $rawHeaders .= "\r\n"; // Put back the delimiter we split previously
+        $headerParts = preg_split("/\r?\n/", $rawHeaders, 2);
+
+        if ($headerParts === false || count($headerParts) !== 2) {
+            throw new \InvalidArgumentException('Invalid message: Missing status line');
+        }
+
+        list($startLine, $rawHeaders) = $headerParts;
+
+        if (preg_match("/(?:^HTTP\/|^[A-Z]+ \S+ HTTP\/)(\d+(?:\.\d+)?)/i", $startLine, $matches) && $matches[1] === '1.0') {
+            // Header folding is deprecated for HTTP/1.1, but allowed in HTTP/1.0
+            $rawHeaders = preg_replace(Rfc7230::HEADER_FOLD_REGEX, ' ', $rawHeaders);
+        }
+
+        /** @var array[] $headerLines */
+        $count = preg_match_all(Rfc7230::HEADER_REGEX, $rawHeaders, $headerLines, PREG_SET_ORDER);
+
+        // If these aren't the same, then one line didn't match and there's an invalid header.
+        if ($count !== substr_count($rawHeaders, "\n")) {
+            // Folding is deprecated, see https://tools.ietf.org/html/rfc7230#section-3.2.4
+            if (preg_match(Rfc7230::HEADER_FOLD_REGEX, $rawHeaders)) {
+                throw new \InvalidArgumentException('Invalid header syntax: Obsolete line folding');
+            }
+
+            throw new \InvalidArgumentException('Invalid header syntax');
+        }
+
+        $headers = [];
+
+        foreach ($headerLines as $headerLine) {
+            $headers[$headerLine[1]][] = $headerLine[2];
+        }
+
+        return [
+            'start-line' => $startLine,
+            'headers' => $headers,
+            'body' => $body,
+        ];
+    }
+
+    /**
+     * Constructs a URI for an HTTP request message.
+     *
+     * @param string $path    Path from the start-line
+     * @param array  $headers Array of headers (each value an array).
+     *
+     * @return string
+     */
+    public static function parseRequestUri($path, array $headers)
+    {
+        $hostKey = array_filter(array_keys($headers), function ($k) {
+            return strtolower($k) === 'host';
+        });
+
+        // If no host is found, then a full URI cannot be constructed.
+        if (!$hostKey) {
+            return $path;
+        }
+
+        $host = $headers[reset($hostKey)][0];
+        $scheme = substr($host, -4) === ':443' ? 'https' : 'http';
+
+        return $scheme . '://' . $host . '/' . ltrim($path, '/');
+    }
+
+    /**
+     * Parses a request message string into a request object.
+     *
+     * @param string $message Request message string.
+     *
+     * @return Request
+     */
+    public static function parseRequest($message)
+    {
+        $data = self::parseMessage($message);
+        $matches = [];
+        if (!preg_match('/^[\S]+\s+([a-zA-Z]+:\/\/|\/).*/', $data['start-line'], $matches)) {
+            throw new \InvalidArgumentException('Invalid request string');
+        }
+        $parts = explode(' ', $data['start-line'], 3);
+        $version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1';
+
+        $request = new Request(
+            $parts[0],
+            $matches[1] === '/' ? self::parseRequestUri($parts[1], $data['headers']) : $parts[1],
+            $data['headers'],
+            $data['body'],
+            $version
+        );
+
+        return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]);
+    }
+
+    /**
+     * Parses a response message string into a response object.
+     *
+     * @param string $message Response message string.
+     *
+     * @return Response
+     */
+    public static function parseResponse($message)
+    {
+        $data = self::parseMessage($message);
+        // According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space
+        // between status-code and reason-phrase is required. But browsers accept
+        // responses without space and reason as well.
+        if (!preg_match('/^HTTP\/.* [0-9]{3}( .*|$)/', $data['start-line'])) {
+            throw new \InvalidArgumentException('Invalid response string: ' . $data['start-line']);
+        }
+        $parts = explode(' ', $data['start-line'], 3);
+
+        return new Response(
+            (int) $parts[1],
+            $data['headers'],
+            $data['body'],
+            explode('/', $parts[0])[1],
+            isset($parts[2]) ? $parts[2] : null
+        );
+    }
+}

+ 269 - 269
vendor/guzzlehttp/psr7/src/MessageTrait.php

@@ -1,269 +1,269 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * Trait implementing functionality common to requests and responses.
- */
-trait MessageTrait
-{
-    /** @var array Map of all registered headers, as original name => array of values */
-    private $headers = [];
-
-    /** @var array Map of lowercase header name => original name at registration */
-    private $headerNames  = [];
-
-    /** @var string */
-    private $protocol = '1.1';
-
-    /** @var StreamInterface|null */
-    private $stream;
-
-    public function getProtocolVersion()
-    {
-        return $this->protocol;
-    }
-
-    public function withProtocolVersion($version)
-    {
-        if ($this->protocol === $version) {
-            return $this;
-        }
-
-        $new = clone $this;
-        $new->protocol = $version;
-        return $new;
-    }
-
-    public function getHeaders()
-    {
-        return $this->headers;
-    }
-
-    public function hasHeader($header)
-    {
-        return isset($this->headerNames[strtolower($header)]);
-    }
-
-    public function getHeader($header)
-    {
-        $header = strtolower($header);
-
-        if (!isset($this->headerNames[$header])) {
-            return [];
-        }
-
-        $header = $this->headerNames[$header];
-
-        return $this->headers[$header];
-    }
-
-    public function getHeaderLine($header)
-    {
-        return implode(', ', $this->getHeader($header));
-    }
-
-    public function withHeader($header, $value)
-    {
-        $this->assertHeader($header);
-        $value = $this->normalizeHeaderValue($value);
-        $normalized = strtolower($header);
-
-        $new = clone $this;
-        if (isset($new->headerNames[$normalized])) {
-            unset($new->headers[$new->headerNames[$normalized]]);
-        }
-        $new->headerNames[$normalized] = $header;
-        $new->headers[$header] = $value;
-
-        return $new;
-    }
-
-    public function withAddedHeader($header, $value)
-    {
-        $this->assertHeader($header);
-        $value = $this->normalizeHeaderValue($value);
-        $normalized = strtolower($header);
-
-        $new = clone $this;
-        if (isset($new->headerNames[$normalized])) {
-            $header = $this->headerNames[$normalized];
-            $new->headers[$header] = array_merge($this->headers[$header], $value);
-        } else {
-            $new->headerNames[$normalized] = $header;
-            $new->headers[$header] = $value;
-        }
-
-        return $new;
-    }
-
-    public function withoutHeader($header)
-    {
-        $normalized = strtolower($header);
-
-        if (!isset($this->headerNames[$normalized])) {
-            return $this;
-        }
-
-        $header = $this->headerNames[$normalized];
-
-        $new = clone $this;
-        unset($new->headers[$header], $new->headerNames[$normalized]);
-
-        return $new;
-    }
-
-    public function getBody()
-    {
-        if (!$this->stream) {
-            $this->stream = Utils::streamFor('');
-        }
-
-        return $this->stream;
-    }
-
-    public function withBody(StreamInterface $body)
-    {
-        if ($body === $this->stream) {
-            return $this;
-        }
-
-        $new = clone $this;
-        $new->stream = $body;
-        return $new;
-    }
-
-    private function setHeaders(array $headers)
-    {
-        $this->headerNames = $this->headers = [];
-        foreach ($headers as $header => $value) {
-            if (is_int($header)) {
-                // Numeric array keys are converted to int by PHP but having a header name '123' is not forbidden by the spec
-                // and also allowed in withHeader(). So we need to cast it to string again for the following assertion to pass.
-                $header = (string) $header;
-            }
-            $this->assertHeader($header);
-            $value = $this->normalizeHeaderValue($value);
-            $normalized = strtolower($header);
-            if (isset($this->headerNames[$normalized])) {
-                $header = $this->headerNames[$normalized];
-                $this->headers[$header] = array_merge($this->headers[$header], $value);
-            } else {
-                $this->headerNames[$normalized] = $header;
-                $this->headers[$header] = $value;
-            }
-        }
-    }
-
-    /**
-     * @param mixed $value
-     *
-     * @return string[]
-     */
-    private function normalizeHeaderValue($value)
-    {
-        if (!is_array($value)) {
-            return $this->trimAndValidateHeaderValues([$value]);
-        }
-
-        if (count($value) === 0) {
-            throw new \InvalidArgumentException('Header value can not be an empty array.');
-        }
-
-        return $this->trimAndValidateHeaderValues($value);
-    }
-
-    /**
-     * Trims whitespace from the header values.
-     *
-     * Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field.
-     *
-     * header-field = field-name ":" OWS field-value OWS
-     * OWS          = *( SP / HTAB )
-     *
-     * @param mixed[] $values Header values
-     *
-     * @return string[] Trimmed header values
-     *
-     * @see https://tools.ietf.org/html/rfc7230#section-3.2.4
-     */
-    private function trimAndValidateHeaderValues(array $values)
-    {
-        return array_map(function ($value) {
-            if (!is_scalar($value) && null !== $value) {
-                throw new \InvalidArgumentException(sprintf(
-                    'Header value must be scalar or null but %s provided.',
-                    is_object($value) ? get_class($value) : gettype($value)
-                ));
-            }
-
-            $trimmed = trim((string) $value, " \t");
-            $this->assertValue($trimmed);
-
-            return $trimmed;
-        }, array_values($values));
-    }
-
-    /**
-     * @see https://tools.ietf.org/html/rfc7230#section-3.2
-     *
-     * @param mixed $header
-     *
-     * @return void
-     */
-    private function assertHeader($header)
-    {
-        if (!is_string($header)) {
-            throw new \InvalidArgumentException(sprintf(
-                'Header name must be a string but %s provided.',
-                is_object($header) ? get_class($header) : gettype($header)
-            ));
-        }
-
-        if ($header === '') {
-            throw new \InvalidArgumentException('Header name can not be empty.');
-        }
-
-        if (! preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/D', $header)) {
-            throw new \InvalidArgumentException(
-                sprintf('"%s" is not valid header name.', $header)
-            );
-        }
-    }
-
-    /**
-     * @param string $value
-     *
-     * @return void
-     *
-     * @see https://tools.ietf.org/html/rfc7230#section-3.2
-     *
-     * field-value    = *( field-content / obs-fold )
-     * field-content  = field-vchar [ 1*( SP / HTAB ) field-vchar ]
-     * field-vchar    = VCHAR / obs-text
-     * VCHAR          = %x21-7E
-     * obs-text       = %x80-FF
-     * obs-fold       = CRLF 1*( SP / HTAB )
-     */
-    private function assertValue($value)
-    {
-        // The regular expression intentionally does not support the obs-fold production, because as
-        // per RFC 7230#3.2.4:
-        //
-        // A sender MUST NOT generate a message that includes
-        // line folding (i.e., that has any field-value that contains a match to
-        // the obs-fold rule) unless the message is intended for packaging
-        // within the message/http media type.
-        //
-        // Clients must not send a request with line folding and a server sending folded headers is
-        // likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting
-        // folding is not likely to break any legitimate use case.
-        if (! preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/D', $value)) {
-            throw new \InvalidArgumentException(
-                sprintf('"%s" is not valid header value.', $value)
-            );
-        }
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Trait implementing functionality common to requests and responses.
+ */
+trait MessageTrait
+{
+    /** @var array Map of all registered headers, as original name => array of values */
+    private $headers = [];
+
+    /** @var array Map of lowercase header name => original name at registration */
+    private $headerNames  = [];
+
+    /** @var string */
+    private $protocol = '1.1';
+
+    /** @var StreamInterface|null */
+    private $stream;
+
+    public function getProtocolVersion()
+    {
+        return $this->protocol;
+    }
+
+    public function withProtocolVersion($version)
+    {
+        if ($this->protocol === $version) {
+            return $this;
+        }
+
+        $new = clone $this;
+        $new->protocol = $version;
+        return $new;
+    }
+
+    public function getHeaders()
+    {
+        return $this->headers;
+    }
+
+    public function hasHeader($header)
+    {
+        return isset($this->headerNames[strtolower($header)]);
+    }
+
+    public function getHeader($header)
+    {
+        $header = strtolower($header);
+
+        if (!isset($this->headerNames[$header])) {
+            return [];
+        }
+
+        $header = $this->headerNames[$header];
+
+        return $this->headers[$header];
+    }
+
+    public function getHeaderLine($header)
+    {
+        return implode(', ', $this->getHeader($header));
+    }
+
+    public function withHeader($header, $value)
+    {
+        $this->assertHeader($header);
+        $value = $this->normalizeHeaderValue($value);
+        $normalized = strtolower($header);
+
+        $new = clone $this;
+        if (isset($new->headerNames[$normalized])) {
+            unset($new->headers[$new->headerNames[$normalized]]);
+        }
+        $new->headerNames[$normalized] = $header;
+        $new->headers[$header] = $value;
+
+        return $new;
+    }
+
+    public function withAddedHeader($header, $value)
+    {
+        $this->assertHeader($header);
+        $value = $this->normalizeHeaderValue($value);
+        $normalized = strtolower($header);
+
+        $new = clone $this;
+        if (isset($new->headerNames[$normalized])) {
+            $header = $this->headerNames[$normalized];
+            $new->headers[$header] = array_merge($this->headers[$header], $value);
+        } else {
+            $new->headerNames[$normalized] = $header;
+            $new->headers[$header] = $value;
+        }
+
+        return $new;
+    }
+
+    public function withoutHeader($header)
+    {
+        $normalized = strtolower($header);
+
+        if (!isset($this->headerNames[$normalized])) {
+            return $this;
+        }
+
+        $header = $this->headerNames[$normalized];
+
+        $new = clone $this;
+        unset($new->headers[$header], $new->headerNames[$normalized]);
+
+        return $new;
+    }
+
+    public function getBody()
+    {
+        if (!$this->stream) {
+            $this->stream = Utils::streamFor('');
+        }
+
+        return $this->stream;
+    }
+
+    public function withBody(StreamInterface $body)
+    {
+        if ($body === $this->stream) {
+            return $this;
+        }
+
+        $new = clone $this;
+        $new->stream = $body;
+        return $new;
+    }
+
+    private function setHeaders(array $headers)
+    {
+        $this->headerNames = $this->headers = [];
+        foreach ($headers as $header => $value) {
+            if (is_int($header)) {
+                // Numeric array keys are converted to int by PHP but having a header name '123' is not forbidden by the spec
+                // and also allowed in withHeader(). So we need to cast it to string again for the following assertion to pass.
+                $header = (string) $header;
+            }
+            $this->assertHeader($header);
+            $value = $this->normalizeHeaderValue($value);
+            $normalized = strtolower($header);
+            if (isset($this->headerNames[$normalized])) {
+                $header = $this->headerNames[$normalized];
+                $this->headers[$header] = array_merge($this->headers[$header], $value);
+            } else {
+                $this->headerNames[$normalized] = $header;
+                $this->headers[$header] = $value;
+            }
+        }
+    }
+
+    /**
+     * @param mixed $value
+     *
+     * @return string[]
+     */
+    private function normalizeHeaderValue($value)
+    {
+        if (!is_array($value)) {
+            return $this->trimAndValidateHeaderValues([$value]);
+        }
+
+        if (count($value) === 0) {
+            throw new \InvalidArgumentException('Header value can not be an empty array.');
+        }
+
+        return $this->trimAndValidateHeaderValues($value);
+    }
+
+    /**
+     * Trims whitespace from the header values.
+     *
+     * Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field.
+     *
+     * header-field = field-name ":" OWS field-value OWS
+     * OWS          = *( SP / HTAB )
+     *
+     * @param mixed[] $values Header values
+     *
+     * @return string[] Trimmed header values
+     *
+     * @see https://tools.ietf.org/html/rfc7230#section-3.2.4
+     */
+    private function trimAndValidateHeaderValues(array $values)
+    {
+        return array_map(function ($value) {
+            if (!is_scalar($value) && null !== $value) {
+                throw new \InvalidArgumentException(sprintf(
+                    'Header value must be scalar or null but %s provided.',
+                    is_object($value) ? get_class($value) : gettype($value)
+                ));
+            }
+
+            $trimmed = trim((string) $value, " \t");
+            $this->assertValue($trimmed);
+
+            return $trimmed;
+        }, array_values($values));
+    }
+
+    /**
+     * @see https://tools.ietf.org/html/rfc7230#section-3.2
+     *
+     * @param mixed $header
+     *
+     * @return void
+     */
+    private function assertHeader($header)
+    {
+        if (!is_string($header)) {
+            throw new \InvalidArgumentException(sprintf(
+                'Header name must be a string but %s provided.',
+                is_object($header) ? get_class($header) : gettype($header)
+            ));
+        }
+
+        if ($header === '') {
+            throw new \InvalidArgumentException('Header name can not be empty.');
+        }
+
+        if (! preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/D', $header)) {
+            throw new \InvalidArgumentException(
+                sprintf('"%s" is not valid header name.', $header)
+            );
+        }
+    }
+
+    /**
+     * @param string $value
+     *
+     * @return void
+     *
+     * @see https://tools.ietf.org/html/rfc7230#section-3.2
+     *
+     * field-value    = *( field-content / obs-fold )
+     * field-content  = field-vchar [ 1*( SP / HTAB ) field-vchar ]
+     * field-vchar    = VCHAR / obs-text
+     * VCHAR          = %x21-7E
+     * obs-text       = %x80-FF
+     * obs-fold       = CRLF 1*( SP / HTAB )
+     */
+    private function assertValue($value)
+    {
+        // The regular expression intentionally does not support the obs-fold production, because as
+        // per RFC 7230#3.2.4:
+        //
+        // A sender MUST NOT generate a message that includes
+        // line folding (i.e., that has any field-value that contains a match to
+        // the obs-fold rule) unless the message is intended for packaging
+        // within the message/http media type.
+        //
+        // Clients must not send a request with line folding and a server sending folded headers is
+        // likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting
+        // folding is not likely to break any legitimate use case.
+        if (! preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/D', $value)) {
+            throw new \InvalidArgumentException(
+                sprintf('"%s" is not valid header value.', $value)
+            );
+        }
+    }
+}

+ 140 - 140
vendor/guzzlehttp/psr7/src/MimeType.php

@@ -1,140 +1,140 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-final class MimeType
-{
-    /**
-     * Determines the mimetype of a file by looking at its extension.
-     *
-     * @param string $filename
-     *
-     * @return string|null
-     */
-    public static function fromFilename($filename)
-    {
-        return self::fromExtension(pathinfo($filename, PATHINFO_EXTENSION));
-    }
-
-    /**
-     * Maps a file extensions to a mimetype.
-     *
-     * @param string $extension string The file extension.
-     *
-     * @return string|null
-     *
-     * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types
-     */
-    public static function fromExtension($extension)
-    {
-        static $mimetypes = [
-            '3gp' => 'video/3gpp',
-            '7z' => 'application/x-7z-compressed',
-            'aac' => 'audio/x-aac',
-            'ai' => 'application/postscript',
-            'aif' => 'audio/x-aiff',
-            'asc' => 'text/plain',
-            'asf' => 'video/x-ms-asf',
-            'atom' => 'application/atom+xml',
-            'avi' => 'video/x-msvideo',
-            'bmp' => 'image/bmp',
-            'bz2' => 'application/x-bzip2',
-            'cer' => 'application/pkix-cert',
-            'crl' => 'application/pkix-crl',
-            'crt' => 'application/x-x509-ca-cert',
-            'css' => 'text/css',
-            'csv' => 'text/csv',
-            'cu' => 'application/cu-seeme',
-            'deb' => 'application/x-debian-package',
-            'doc' => 'application/msword',
-            'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
-            'dvi' => 'application/x-dvi',
-            'eot' => 'application/vnd.ms-fontobject',
-            'eps' => 'application/postscript',
-            'epub' => 'application/epub+zip',
-            'etx' => 'text/x-setext',
-            'flac' => 'audio/flac',
-            'flv' => 'video/x-flv',
-            'gif' => 'image/gif',
-            'gz' => 'application/gzip',
-            'htm' => 'text/html',
-            'html' => 'text/html',
-            'ico' => 'image/x-icon',
-            'ics' => 'text/calendar',
-            'ini' => 'text/plain',
-            'iso' => 'application/x-iso9660-image',
-            'jar' => 'application/java-archive',
-            'jpe' => 'image/jpeg',
-            'jpeg' => 'image/jpeg',
-            'jpg' => 'image/jpeg',
-            'js' => 'text/javascript',
-            'json' => 'application/json',
-            'latex' => 'application/x-latex',
-            'log' => 'text/plain',
-            'm4a' => 'audio/mp4',
-            'm4v' => 'video/mp4',
-            'mid' => 'audio/midi',
-            'midi' => 'audio/midi',
-            'mov' => 'video/quicktime',
-            'mkv' => 'video/x-matroska',
-            'mp3' => 'audio/mpeg',
-            'mp4' => 'video/mp4',
-            'mp4a' => 'audio/mp4',
-            'mp4v' => 'video/mp4',
-            'mpe' => 'video/mpeg',
-            'mpeg' => 'video/mpeg',
-            'mpg' => 'video/mpeg',
-            'mpg4' => 'video/mp4',
-            'oga' => 'audio/ogg',
-            'ogg' => 'audio/ogg',
-            'ogv' => 'video/ogg',
-            'ogx' => 'application/ogg',
-            'pbm' => 'image/x-portable-bitmap',
-            'pdf' => 'application/pdf',
-            'pgm' => 'image/x-portable-graymap',
-            'png' => 'image/png',
-            'pnm' => 'image/x-portable-anymap',
-            'ppm' => 'image/x-portable-pixmap',
-            'ppt' => 'application/vnd.ms-powerpoint',
-            'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
-            'ps' => 'application/postscript',
-            'qt' => 'video/quicktime',
-            'rar' => 'application/x-rar-compressed',
-            'ras' => 'image/x-cmu-raster',
-            'rss' => 'application/rss+xml',
-            'rtf' => 'application/rtf',
-            'sgm' => 'text/sgml',
-            'sgml' => 'text/sgml',
-            'svg' => 'image/svg+xml',
-            'swf' => 'application/x-shockwave-flash',
-            'tar' => 'application/x-tar',
-            'tif' => 'image/tiff',
-            'tiff' => 'image/tiff',
-            'torrent' => 'application/x-bittorrent',
-            'ttf' => 'application/x-font-ttf',
-            'txt' => 'text/plain',
-            'wav' => 'audio/x-wav',
-            'webm' => 'video/webm',
-            'webp' => 'image/webp',
-            'wma' => 'audio/x-ms-wma',
-            'wmv' => 'video/x-ms-wmv',
-            'woff' => 'application/x-font-woff',
-            'wsdl' => 'application/wsdl+xml',
-            'xbm' => 'image/x-xbitmap',
-            'xls' => 'application/vnd.ms-excel',
-            'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
-            'xml' => 'application/xml',
-            'xpm' => 'image/x-xpixmap',
-            'xwd' => 'image/x-xwindowdump',
-            'yaml' => 'text/yaml',
-            'yml' => 'text/yaml',
-            'zip' => 'application/zip',
-        ];
-
-        $extension = strtolower($extension);
-
-        return isset($mimetypes[$extension])
-            ? $mimetypes[$extension]
-            : null;
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+final class MimeType
+{
+    /**
+     * Determines the mimetype of a file by looking at its extension.
+     *
+     * @param string $filename
+     *
+     * @return string|null
+     */
+    public static function fromFilename($filename)
+    {
+        return self::fromExtension(pathinfo($filename, PATHINFO_EXTENSION));
+    }
+
+    /**
+     * Maps a file extensions to a mimetype.
+     *
+     * @param string $extension string The file extension.
+     *
+     * @return string|null
+     *
+     * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types
+     */
+    public static function fromExtension($extension)
+    {
+        static $mimetypes = [
+            '3gp' => 'video/3gpp',
+            '7z' => 'application/x-7z-compressed',
+            'aac' => 'audio/x-aac',
+            'ai' => 'application/postscript',
+            'aif' => 'audio/x-aiff',
+            'asc' => 'text/plain',
+            'asf' => 'video/x-ms-asf',
+            'atom' => 'application/atom+xml',
+            'avi' => 'video/x-msvideo',
+            'bmp' => 'image/bmp',
+            'bz2' => 'application/x-bzip2',
+            'cer' => 'application/pkix-cert',
+            'crl' => 'application/pkix-crl',
+            'crt' => 'application/x-x509-ca-cert',
+            'css' => 'text/css',
+            'csv' => 'text/csv',
+            'cu' => 'application/cu-seeme',
+            'deb' => 'application/x-debian-package',
+            'doc' => 'application/msword',
+            'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+            'dvi' => 'application/x-dvi',
+            'eot' => 'application/vnd.ms-fontobject',
+            'eps' => 'application/postscript',
+            'epub' => 'application/epub+zip',
+            'etx' => 'text/x-setext',
+            'flac' => 'audio/flac',
+            'flv' => 'video/x-flv',
+            'gif' => 'image/gif',
+            'gz' => 'application/gzip',
+            'htm' => 'text/html',
+            'html' => 'text/html',
+            'ico' => 'image/x-icon',
+            'ics' => 'text/calendar',
+            'ini' => 'text/plain',
+            'iso' => 'application/x-iso9660-image',
+            'jar' => 'application/java-archive',
+            'jpe' => 'image/jpeg',
+            'jpeg' => 'image/jpeg',
+            'jpg' => 'image/jpeg',
+            'js' => 'text/javascript',
+            'json' => 'application/json',
+            'latex' => 'application/x-latex',
+            'log' => 'text/plain',
+            'm4a' => 'audio/mp4',
+            'm4v' => 'video/mp4',
+            'mid' => 'audio/midi',
+            'midi' => 'audio/midi',
+            'mov' => 'video/quicktime',
+            'mkv' => 'video/x-matroska',
+            'mp3' => 'audio/mpeg',
+            'mp4' => 'video/mp4',
+            'mp4a' => 'audio/mp4',
+            'mp4v' => 'video/mp4',
+            'mpe' => 'video/mpeg',
+            'mpeg' => 'video/mpeg',
+            'mpg' => 'video/mpeg',
+            'mpg4' => 'video/mp4',
+            'oga' => 'audio/ogg',
+            'ogg' => 'audio/ogg',
+            'ogv' => 'video/ogg',
+            'ogx' => 'application/ogg',
+            'pbm' => 'image/x-portable-bitmap',
+            'pdf' => 'application/pdf',
+            'pgm' => 'image/x-portable-graymap',
+            'png' => 'image/png',
+            'pnm' => 'image/x-portable-anymap',
+            'ppm' => 'image/x-portable-pixmap',
+            'ppt' => 'application/vnd.ms-powerpoint',
+            'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
+            'ps' => 'application/postscript',
+            'qt' => 'video/quicktime',
+            'rar' => 'application/x-rar-compressed',
+            'ras' => 'image/x-cmu-raster',
+            'rss' => 'application/rss+xml',
+            'rtf' => 'application/rtf',
+            'sgm' => 'text/sgml',
+            'sgml' => 'text/sgml',
+            'svg' => 'image/svg+xml',
+            'swf' => 'application/x-shockwave-flash',
+            'tar' => 'application/x-tar',
+            'tif' => 'image/tiff',
+            'tiff' => 'image/tiff',
+            'torrent' => 'application/x-bittorrent',
+            'ttf' => 'application/x-font-ttf',
+            'txt' => 'text/plain',
+            'wav' => 'audio/x-wav',
+            'webm' => 'video/webm',
+            'webp' => 'image/webp',
+            'wma' => 'audio/x-ms-wma',
+            'wmv' => 'video/x-ms-wmv',
+            'woff' => 'application/x-font-woff',
+            'wsdl' => 'application/wsdl+xml',
+            'xbm' => 'image/x-xbitmap',
+            'xls' => 'application/vnd.ms-excel',
+            'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+            'xml' => 'application/xml',
+            'xpm' => 'image/x-xpixmap',
+            'xwd' => 'image/x-xwindowdump',
+            'yaml' => 'text/yaml',
+            'yml' => 'text/yaml',
+            'zip' => 'application/zip',
+        ];
+
+        $extension = strtolower($extension);
+
+        return isset($mimetypes[$extension])
+            ? $mimetypes[$extension]
+            : null;
+    }
+}

+ 158 - 158
vendor/guzzlehttp/psr7/src/MultipartStream.php

@@ -1,158 +1,158 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * Stream that when read returns bytes for a streaming multipart or
- * multipart/form-data stream.
- *
- * @final
- */
-class MultipartStream implements StreamInterface
-{
-    use StreamDecoratorTrait;
-
-    private $boundary;
-
-    /**
-     * @param array  $elements Array of associative arrays, each containing a
-     *                         required "name" key mapping to the form field,
-     *                         name, a required "contents" key mapping to a
-     *                         StreamInterface/resource/string, an optional
-     *                         "headers" associative array of custom headers,
-     *                         and an optional "filename" key mapping to a
-     *                         string to send as the filename in the part.
-     * @param string $boundary You can optionally provide a specific boundary
-     *
-     * @throws \InvalidArgumentException
-     */
-    public function __construct(array $elements = [], $boundary = null)
-    {
-        $this->boundary = $boundary ?: sha1(uniqid('', true));
-        $this->stream = $this->createStream($elements);
-    }
-
-    /**
-     * Get the boundary
-     *
-     * @return string
-     */
-    public function getBoundary()
-    {
-        return $this->boundary;
-    }
-
-    public function isWritable()
-    {
-        return false;
-    }
-
-    /**
-     * Get the headers needed before transferring the content of a POST file
-     */
-    private function getHeaders(array $headers)
-    {
-        $str = '';
-        foreach ($headers as $key => $value) {
-            $str .= "{$key}: {$value}\r\n";
-        }
-
-        return "--{$this->boundary}\r\n" . trim($str) . "\r\n\r\n";
-    }
-
-    /**
-     * Create the aggregate stream that will be used to upload the POST data
-     */
-    protected function createStream(array $elements)
-    {
-        $stream = new AppendStream();
-
-        foreach ($elements as $element) {
-            $this->addElement($stream, $element);
-        }
-
-        // Add the trailing boundary with CRLF
-        $stream->addStream(Utils::streamFor("--{$this->boundary}--\r\n"));
-
-        return $stream;
-    }
-
-    private function addElement(AppendStream $stream, array $element)
-    {
-        foreach (['contents', 'name'] as $key) {
-            if (!array_key_exists($key, $element)) {
-                throw new \InvalidArgumentException("A '{$key}' key is required");
-            }
-        }
-
-        $element['contents'] = Utils::streamFor($element['contents']);
-
-        if (empty($element['filename'])) {
-            $uri = $element['contents']->getMetadata('uri');
-            if (substr($uri, 0, 6) !== 'php://') {
-                $element['filename'] = $uri;
-            }
-        }
-
-        list($body, $headers) = $this->createElement(
-            $element['name'],
-            $element['contents'],
-            isset($element['filename']) ? $element['filename'] : null,
-            isset($element['headers']) ? $element['headers'] : []
-        );
-
-        $stream->addStream(Utils::streamFor($this->getHeaders($headers)));
-        $stream->addStream($body);
-        $stream->addStream(Utils::streamFor("\r\n"));
-    }
-
-    /**
-     * @return array
-     */
-    private function createElement($name, StreamInterface $stream, $filename, array $headers)
-    {
-        // Set a default content-disposition header if one was no provided
-        $disposition = $this->getHeader($headers, 'content-disposition');
-        if (!$disposition) {
-            $headers['Content-Disposition'] = ($filename === '0' || $filename)
-                ? sprintf(
-                    'form-data; name="%s"; filename="%s"',
-                    $name,
-                    basename($filename)
-                )
-                : "form-data; name=\"{$name}\"";
-        }
-
-        // Set a default content-length header if one was no provided
-        $length = $this->getHeader($headers, 'content-length');
-        if (!$length) {
-            if ($length = $stream->getSize()) {
-                $headers['Content-Length'] = (string) $length;
-            }
-        }
-
-        // Set a default Content-Type if one was not supplied
-        $type = $this->getHeader($headers, 'content-type');
-        if (!$type && ($filename === '0' || $filename)) {
-            if ($type = MimeType::fromFilename($filename)) {
-                $headers['Content-Type'] = $type;
-            }
-        }
-
-        return [$stream, $headers];
-    }
-
-    private function getHeader(array $headers, $key)
-    {
-        $lowercaseHeader = strtolower($key);
-        foreach ($headers as $k => $v) {
-            if (strtolower($k) === $lowercaseHeader) {
-                return $v;
-            }
-        }
-
-        return null;
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Stream that when read returns bytes for a streaming multipart or
+ * multipart/form-data stream.
+ *
+ * @final
+ */
+class MultipartStream implements StreamInterface
+{
+    use StreamDecoratorTrait;
+
+    private $boundary;
+
+    /**
+     * @param array  $elements Array of associative arrays, each containing a
+     *                         required "name" key mapping to the form field,
+     *                         name, a required "contents" key mapping to a
+     *                         StreamInterface/resource/string, an optional
+     *                         "headers" associative array of custom headers,
+     *                         and an optional "filename" key mapping to a
+     *                         string to send as the filename in the part.
+     * @param string $boundary You can optionally provide a specific boundary
+     *
+     * @throws \InvalidArgumentException
+     */
+    public function __construct(array $elements = [], $boundary = null)
+    {
+        $this->boundary = $boundary ?: sha1(uniqid('', true));
+        $this->stream = $this->createStream($elements);
+    }
+
+    /**
+     * Get the boundary
+     *
+     * @return string
+     */
+    public function getBoundary()
+    {
+        return $this->boundary;
+    }
+
+    public function isWritable()
+    {
+        return false;
+    }
+
+    /**
+     * Get the headers needed before transferring the content of a POST file
+     */
+    private function getHeaders(array $headers)
+    {
+        $str = '';
+        foreach ($headers as $key => $value) {
+            $str .= "{$key}: {$value}\r\n";
+        }
+
+        return "--{$this->boundary}\r\n" . trim($str) . "\r\n\r\n";
+    }
+
+    /**
+     * Create the aggregate stream that will be used to upload the POST data
+     */
+    protected function createStream(array $elements)
+    {
+        $stream = new AppendStream();
+
+        foreach ($elements as $element) {
+            $this->addElement($stream, $element);
+        }
+
+        // Add the trailing boundary with CRLF
+        $stream->addStream(Utils::streamFor("--{$this->boundary}--\r\n"));
+
+        return $stream;
+    }
+
+    private function addElement(AppendStream $stream, array $element)
+    {
+        foreach (['contents', 'name'] as $key) {
+            if (!array_key_exists($key, $element)) {
+                throw new \InvalidArgumentException("A '{$key}' key is required");
+            }
+        }
+
+        $element['contents'] = Utils::streamFor($element['contents']);
+
+        if (empty($element['filename'])) {
+            $uri = $element['contents']->getMetadata('uri');
+            if (substr($uri, 0, 6) !== 'php://') {
+                $element['filename'] = $uri;
+            }
+        }
+
+        list($body, $headers) = $this->createElement(
+            $element['name'],
+            $element['contents'],
+            isset($element['filename']) ? $element['filename'] : null,
+            isset($element['headers']) ? $element['headers'] : []
+        );
+
+        $stream->addStream(Utils::streamFor($this->getHeaders($headers)));
+        $stream->addStream($body);
+        $stream->addStream(Utils::streamFor("\r\n"));
+    }
+
+    /**
+     * @return array
+     */
+    private function createElement($name, StreamInterface $stream, $filename, array $headers)
+    {
+        // Set a default content-disposition header if one was no provided
+        $disposition = $this->getHeader($headers, 'content-disposition');
+        if (!$disposition) {
+            $headers['Content-Disposition'] = ($filename === '0' || $filename)
+                ? sprintf(
+                    'form-data; name="%s"; filename="%s"',
+                    $name,
+                    basename($filename)
+                )
+                : "form-data; name=\"{$name}\"";
+        }
+
+        // Set a default content-length header if one was no provided
+        $length = $this->getHeader($headers, 'content-length');
+        if (!$length) {
+            if ($length = $stream->getSize()) {
+                $headers['Content-Length'] = (string) $length;
+            }
+        }
+
+        // Set a default Content-Type if one was not supplied
+        $type = $this->getHeader($headers, 'content-type');
+        if (!$type && ($filename === '0' || $filename)) {
+            if ($type = MimeType::fromFilename($filename)) {
+                $headers['Content-Type'] = $type;
+            }
+        }
+
+        return [$stream, $headers];
+    }
+
+    private function getHeader(array $headers, $key)
+    {
+        $lowercaseHeader = strtolower($key);
+        foreach ($headers as $k => $v) {
+            if (strtolower($k) === $lowercaseHeader) {
+                return $v;
+            }
+        }
+
+        return null;
+    }
+}

+ 25 - 25
vendor/guzzlehttp/psr7/src/NoSeekStream.php

@@ -1,25 +1,25 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * Stream decorator that prevents a stream from being seeked.
- *
- * @final
- */
-class NoSeekStream implements StreamInterface
-{
-    use StreamDecoratorTrait;
-
-    public function seek($offset, $whence = SEEK_SET)
-    {
-        throw new \RuntimeException('Cannot seek a NoSeekStream');
-    }
-
-    public function isSeekable()
-    {
-        return false;
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Stream decorator that prevents a stream from being seeked.
+ *
+ * @final
+ */
+class NoSeekStream implements StreamInterface
+{
+    use StreamDecoratorTrait;
+
+    public function seek($offset, $whence = SEEK_SET)
+    {
+        throw new \RuntimeException('Cannot seek a NoSeekStream');
+    }
+
+    public function isSeekable()
+    {
+        return false;
+    }
+}

+ 170 - 170
vendor/guzzlehttp/psr7/src/PumpStream.php

@@ -1,170 +1,170 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * Provides a read only stream that pumps data from a PHP callable.
- *
- * When invoking the provided callable, the PumpStream will pass the amount of
- * data requested to read to the callable. The callable can choose to ignore
- * this value and return fewer or more bytes than requested. Any extra data
- * returned by the provided callable is buffered internally until drained using
- * the read() function of the PumpStream. The provided callable MUST return
- * false when there is no more data to read.
- *
- * @final
- */
-class PumpStream implements StreamInterface
-{
-    /** @var callable */
-    private $source;
-
-    /** @var int */
-    private $size;
-
-    /** @var int */
-    private $tellPos = 0;
-
-    /** @var array */
-    private $metadata;
-
-    /** @var BufferStream */
-    private $buffer;
-
-    /**
-     * @param callable $source  Source of the stream data. The callable MAY
-     *                          accept an integer argument used to control the
-     *                          amount of data to return. The callable MUST
-     *                          return a string when called, or false on error
-     *                          or EOF.
-     * @param array    $options Stream options:
-     *                          - metadata: Hash of metadata to use with stream.
-     *                          - size: Size of the stream, if known.
-     */
-    public function __construct(callable $source, array $options = [])
-    {
-        $this->source = $source;
-        $this->size = isset($options['size']) ? $options['size'] : null;
-        $this->metadata = isset($options['metadata']) ? $options['metadata'] : [];
-        $this->buffer = new BufferStream();
-    }
-
-    public function __toString()
-    {
-        try {
-            return Utils::copyToString($this);
-        } catch (\Exception $e) {
-            return '';
-        }
-    }
-
-    public function close()
-    {
-        $this->detach();
-    }
-
-    public function detach()
-    {
-        $this->tellPos = false;
-        $this->source = null;
-
-        return null;
-    }
-
-    public function getSize()
-    {
-        return $this->size;
-    }
-
-    public function tell()
-    {
-        return $this->tellPos;
-    }
-
-    public function eof()
-    {
-        return !$this->source;
-    }
-
-    public function isSeekable()
-    {
-        return false;
-    }
-
-    public function rewind()
-    {
-        $this->seek(0);
-    }
-
-    public function seek($offset, $whence = SEEK_SET)
-    {
-        throw new \RuntimeException('Cannot seek a PumpStream');
-    }
-
-    public function isWritable()
-    {
-        return false;
-    }
-
-    public function write($string)
-    {
-        throw new \RuntimeException('Cannot write to a PumpStream');
-    }
-
-    public function isReadable()
-    {
-        return true;
-    }
-
-    public function read($length)
-    {
-        $data = $this->buffer->read($length);
-        $readLen = strlen($data);
-        $this->tellPos += $readLen;
-        $remaining = $length - $readLen;
-
-        if ($remaining) {
-            $this->pump($remaining);
-            $data .= $this->buffer->read($remaining);
-            $this->tellPos += strlen($data) - $readLen;
-        }
-
-        return $data;
-    }
-
-    public function getContents()
-    {
-        $result = '';
-        while (!$this->eof()) {
-            $result .= $this->read(1000000);
-        }
-
-        return $result;
-    }
-
-    public function getMetadata($key = null)
-    {
-        if (!$key) {
-            return $this->metadata;
-        }
-
-        return isset($this->metadata[$key]) ? $this->metadata[$key] : null;
-    }
-
-    private function pump($length)
-    {
-        if ($this->source) {
-            do {
-                $data = call_user_func($this->source, $length);
-                if ($data === false || $data === null) {
-                    $this->source = null;
-                    return;
-                }
-                $this->buffer->write($data);
-                $length -= strlen($data);
-            } while ($length > 0);
-        }
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Provides a read only stream that pumps data from a PHP callable.
+ *
+ * When invoking the provided callable, the PumpStream will pass the amount of
+ * data requested to read to the callable. The callable can choose to ignore
+ * this value and return fewer or more bytes than requested. Any extra data
+ * returned by the provided callable is buffered internally until drained using
+ * the read() function of the PumpStream. The provided callable MUST return
+ * false when there is no more data to read.
+ *
+ * @final
+ */
+class PumpStream implements StreamInterface
+{
+    /** @var callable */
+    private $source;
+
+    /** @var int */
+    private $size;
+
+    /** @var int */
+    private $tellPos = 0;
+
+    /** @var array */
+    private $metadata;
+
+    /** @var BufferStream */
+    private $buffer;
+
+    /**
+     * @param callable $source  Source of the stream data. The callable MAY
+     *                          accept an integer argument used to control the
+     *                          amount of data to return. The callable MUST
+     *                          return a string when called, or false on error
+     *                          or EOF.
+     * @param array    $options Stream options:
+     *                          - metadata: Hash of metadata to use with stream.
+     *                          - size: Size of the stream, if known.
+     */
+    public function __construct(callable $source, array $options = [])
+    {
+        $this->source = $source;
+        $this->size = isset($options['size']) ? $options['size'] : null;
+        $this->metadata = isset($options['metadata']) ? $options['metadata'] : [];
+        $this->buffer = new BufferStream();
+    }
+
+    public function __toString()
+    {
+        try {
+            return Utils::copyToString($this);
+        } catch (\Exception $e) {
+            return '';
+        }
+    }
+
+    public function close()
+    {
+        $this->detach();
+    }
+
+    public function detach()
+    {
+        $this->tellPos = false;
+        $this->source = null;
+
+        return null;
+    }
+
+    public function getSize()
+    {
+        return $this->size;
+    }
+
+    public function tell()
+    {
+        return $this->tellPos;
+    }
+
+    public function eof()
+    {
+        return !$this->source;
+    }
+
+    public function isSeekable()
+    {
+        return false;
+    }
+
+    public function rewind()
+    {
+        $this->seek(0);
+    }
+
+    public function seek($offset, $whence = SEEK_SET)
+    {
+        throw new \RuntimeException('Cannot seek a PumpStream');
+    }
+
+    public function isWritable()
+    {
+        return false;
+    }
+
+    public function write($string)
+    {
+        throw new \RuntimeException('Cannot write to a PumpStream');
+    }
+
+    public function isReadable()
+    {
+        return true;
+    }
+
+    public function read($length)
+    {
+        $data = $this->buffer->read($length);
+        $readLen = strlen($data);
+        $this->tellPos += $readLen;
+        $remaining = $length - $readLen;
+
+        if ($remaining) {
+            $this->pump($remaining);
+            $data .= $this->buffer->read($remaining);
+            $this->tellPos += strlen($data) - $readLen;
+        }
+
+        return $data;
+    }
+
+    public function getContents()
+    {
+        $result = '';
+        while (!$this->eof()) {
+            $result .= $this->read(1000000);
+        }
+
+        return $result;
+    }
+
+    public function getMetadata($key = null)
+    {
+        if (!$key) {
+            return $this->metadata;
+        }
+
+        return isset($this->metadata[$key]) ? $this->metadata[$key] : null;
+    }
+
+    private function pump($length)
+    {
+        if ($this->source) {
+            do {
+                $data = call_user_func($this->source, $length);
+                if ($data === false || $data === null) {
+                    $this->source = null;
+                    return;
+                }
+                $this->buffer->write($data);
+                $length -= strlen($data);
+            } while ($length > 0);
+        }
+    }
+}

+ 113 - 113
vendor/guzzlehttp/psr7/src/Query.php

@@ -1,113 +1,113 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-final class Query
-{
-    /**
-     * Parse a query string into an associative array.
-     *
-     * If multiple values are found for the same key, the value of that key
-     * value pair will become an array. This function does not parse nested
-     * PHP style arrays into an associative array (e.g., `foo[a]=1&foo[b]=2`
-     * will be parsed into `['foo[a]' => '1', 'foo[b]' => '2'])`.
-     *
-     * @param string   $str         Query string to parse
-     * @param int|bool $urlEncoding How the query string is encoded
-     *
-     * @return array
-     */
-    public static function parse($str, $urlEncoding = true)
-    {
-        $result = [];
-
-        if ($str === '') {
-            return $result;
-        }
-
-        if ($urlEncoding === true) {
-            $decoder = function ($value) {
-                return rawurldecode(str_replace('+', ' ', $value));
-            };
-        } elseif ($urlEncoding === PHP_QUERY_RFC3986) {
-            $decoder = 'rawurldecode';
-        } elseif ($urlEncoding === PHP_QUERY_RFC1738) {
-            $decoder = 'urldecode';
-        } else {
-            $decoder = function ($str) {
-                return $str;
-            };
-        }
-
-        foreach (explode('&', $str) as $kvp) {
-            $parts = explode('=', $kvp, 2);
-            $key = $decoder($parts[0]);
-            $value = isset($parts[1]) ? $decoder($parts[1]) : null;
-            if (!isset($result[$key])) {
-                $result[$key] = $value;
-            } else {
-                if (!is_array($result[$key])) {
-                    $result[$key] = [$result[$key]];
-                }
-                $result[$key][] = $value;
-            }
-        }
-
-        return $result;
-    }
-
-    /**
-     * Build a query string from an array of key value pairs.
-     *
-     * This function can use the return value of `parse()` to build a query
-     * string. This function does not modify the provided keys when an array is
-     * encountered (like `http_build_query()` would).
-     *
-     * @param array     $params   Query string parameters.
-     * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986
-     *                            to encode using RFC3986, or PHP_QUERY_RFC1738
-     *                            to encode using RFC1738.
-     *
-     * @return string
-     */
-    public static function build(array $params, $encoding = PHP_QUERY_RFC3986)
-    {
-        if (!$params) {
-            return '';
-        }
-
-        if ($encoding === false) {
-            $encoder = function ($str) {
-                return $str;
-            };
-        } elseif ($encoding === PHP_QUERY_RFC3986) {
-            $encoder = 'rawurlencode';
-        } elseif ($encoding === PHP_QUERY_RFC1738) {
-            $encoder = 'urlencode';
-        } else {
-            throw new \InvalidArgumentException('Invalid type');
-        }
-
-        $qs = '';
-        foreach ($params as $k => $v) {
-            $k = $encoder($k);
-            if (!is_array($v)) {
-                $qs .= $k;
-                if ($v !== null) {
-                    $qs .= '=' . $encoder($v);
-                }
-                $qs .= '&';
-            } else {
-                foreach ($v as $vv) {
-                    $qs .= $k;
-                    if ($vv !== null) {
-                        $qs .= '=' . $encoder($vv);
-                    }
-                    $qs .= '&';
-                }
-            }
-        }
-
-        return $qs ? (string) substr($qs, 0, -1) : '';
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+final class Query
+{
+    /**
+     * Parse a query string into an associative array.
+     *
+     * If multiple values are found for the same key, the value of that key
+     * value pair will become an array. This function does not parse nested
+     * PHP style arrays into an associative array (e.g., `foo[a]=1&foo[b]=2`
+     * will be parsed into `['foo[a]' => '1', 'foo[b]' => '2'])`.
+     *
+     * @param string   $str         Query string to parse
+     * @param int|bool $urlEncoding How the query string is encoded
+     *
+     * @return array
+     */
+    public static function parse($str, $urlEncoding = true)
+    {
+        $result = [];
+
+        if ($str === '') {
+            return $result;
+        }
+
+        if ($urlEncoding === true) {
+            $decoder = function ($value) {
+                return rawurldecode(str_replace('+', ' ', $value));
+            };
+        } elseif ($urlEncoding === PHP_QUERY_RFC3986) {
+            $decoder = 'rawurldecode';
+        } elseif ($urlEncoding === PHP_QUERY_RFC1738) {
+            $decoder = 'urldecode';
+        } else {
+            $decoder = function ($str) {
+                return $str;
+            };
+        }
+
+        foreach (explode('&', $str) as $kvp) {
+            $parts = explode('=', $kvp, 2);
+            $key = $decoder($parts[0]);
+            $value = isset($parts[1]) ? $decoder($parts[1]) : null;
+            if (!isset($result[$key])) {
+                $result[$key] = $value;
+            } else {
+                if (!is_array($result[$key])) {
+                    $result[$key] = [$result[$key]];
+                }
+                $result[$key][] = $value;
+            }
+        }
+
+        return $result;
+    }
+
+    /**
+     * Build a query string from an array of key value pairs.
+     *
+     * This function can use the return value of `parse()` to build a query
+     * string. This function does not modify the provided keys when an array is
+     * encountered (like `http_build_query()` would).
+     *
+     * @param array     $params   Query string parameters.
+     * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986
+     *                            to encode using RFC3986, or PHP_QUERY_RFC1738
+     *                            to encode using RFC1738.
+     *
+     * @return string
+     */
+    public static function build(array $params, $encoding = PHP_QUERY_RFC3986)
+    {
+        if (!$params) {
+            return '';
+        }
+
+        if ($encoding === false) {
+            $encoder = function ($str) {
+                return $str;
+            };
+        } elseif ($encoding === PHP_QUERY_RFC3986) {
+            $encoder = 'rawurlencode';
+        } elseif ($encoding === PHP_QUERY_RFC1738) {
+            $encoder = 'urlencode';
+        } else {
+            throw new \InvalidArgumentException('Invalid type');
+        }
+
+        $qs = '';
+        foreach ($params as $k => $v) {
+            $k = $encoder($k);
+            if (!is_array($v)) {
+                $qs .= $k;
+                if ($v !== null) {
+                    $qs .= '=' . $encoder($v);
+                }
+                $qs .= '&';
+            } else {
+                foreach ($v as $vv) {
+                    $qs .= $k;
+                    if ($vv !== null) {
+                        $qs .= '=' . $encoder($vv);
+                    }
+                    $qs .= '&';
+                }
+            }
+        }
+
+        return $qs ? (string) substr($qs, 0, -1) : '';
+    }
+}

+ 152 - 152
vendor/guzzlehttp/psr7/src/Request.php

@@ -1,152 +1,152 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use InvalidArgumentException;
-use Psr\Http\Message\RequestInterface;
-use Psr\Http\Message\StreamInterface;
-use Psr\Http\Message\UriInterface;
-
-/**
- * PSR-7 request implementation.
- */
-class Request implements RequestInterface
-{
-    use MessageTrait;
-
-    /** @var string */
-    private $method;
-
-    /** @var string|null */
-    private $requestTarget;
-
-    /** @var UriInterface */
-    private $uri;
-
-    /**
-     * @param string                               $method  HTTP method
-     * @param string|UriInterface                  $uri     URI
-     * @param array                                $headers Request headers
-     * @param string|resource|StreamInterface|null $body    Request body
-     * @param string                               $version Protocol version
-     */
-    public function __construct(
-        $method,
-        $uri,
-        array $headers = [],
-        $body = null,
-        $version = '1.1'
-    ) {
-        $this->assertMethod($method);
-        if (!($uri instanceof UriInterface)) {
-            $uri = new Uri($uri);
-        }
-
-        $this->method = strtoupper($method);
-        $this->uri = $uri;
-        $this->setHeaders($headers);
-        $this->protocol = $version;
-
-        if (!isset($this->headerNames['host'])) {
-            $this->updateHostFromUri();
-        }
-
-        if ($body !== '' && $body !== null) {
-            $this->stream = Utils::streamFor($body);
-        }
-    }
-
-    public function getRequestTarget()
-    {
-        if ($this->requestTarget !== null) {
-            return $this->requestTarget;
-        }
-
-        $target = $this->uri->getPath();
-        if ($target == '') {
-            $target = '/';
-        }
-        if ($this->uri->getQuery() != '') {
-            $target .= '?' . $this->uri->getQuery();
-        }
-
-        return $target;
-    }
-
-    public function withRequestTarget($requestTarget)
-    {
-        if (preg_match('#\s#', $requestTarget)) {
-            throw new InvalidArgumentException(
-                'Invalid request target provided; cannot contain whitespace'
-            );
-        }
-
-        $new = clone $this;
-        $new->requestTarget = $requestTarget;
-        return $new;
-    }
-
-    public function getMethod()
-    {
-        return $this->method;
-    }
-
-    public function withMethod($method)
-    {
-        $this->assertMethod($method);
-        $new = clone $this;
-        $new->method = strtoupper($method);
-        return $new;
-    }
-
-    public function getUri()
-    {
-        return $this->uri;
-    }
-
-    public function withUri(UriInterface $uri, $preserveHost = false)
-    {
-        if ($uri === $this->uri) {
-            return $this;
-        }
-
-        $new = clone $this;
-        $new->uri = $uri;
-
-        if (!$preserveHost || !isset($this->headerNames['host'])) {
-            $new->updateHostFromUri();
-        }
-
-        return $new;
-    }
-
-    private function updateHostFromUri()
-    {
-        $host = $this->uri->getHost();
-
-        if ($host == '') {
-            return;
-        }
-
-        if (($port = $this->uri->getPort()) !== null) {
-            $host .= ':' . $port;
-        }
-
-        if (isset($this->headerNames['host'])) {
-            $header = $this->headerNames['host'];
-        } else {
-            $header = 'Host';
-            $this->headerNames['host'] = 'Host';
-        }
-        // Ensure Host is the first header.
-        // See: http://tools.ietf.org/html/rfc7230#section-5.4
-        $this->headers = [$header => [$host]] + $this->headers;
-    }
-
-    private function assertMethod($method)
-    {
-        if (!is_string($method) || $method === '') {
-            throw new \InvalidArgumentException('Method must be a non-empty string.');
-        }
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use InvalidArgumentException;
+use Psr\Http\Message\RequestInterface;
+use Psr\Http\Message\StreamInterface;
+use Psr\Http\Message\UriInterface;
+
+/**
+ * PSR-7 request implementation.
+ */
+class Request implements RequestInterface
+{
+    use MessageTrait;
+
+    /** @var string */
+    private $method;
+
+    /** @var string|null */
+    private $requestTarget;
+
+    /** @var UriInterface */
+    private $uri;
+
+    /**
+     * @param string                               $method  HTTP method
+     * @param string|UriInterface                  $uri     URI
+     * @param array                                $headers Request headers
+     * @param string|resource|StreamInterface|null $body    Request body
+     * @param string                               $version Protocol version
+     */
+    public function __construct(
+        $method,
+        $uri,
+        array $headers = [],
+        $body = null,
+        $version = '1.1'
+    ) {
+        $this->assertMethod($method);
+        if (!($uri instanceof UriInterface)) {
+            $uri = new Uri($uri);
+        }
+
+        $this->method = strtoupper($method);
+        $this->uri = $uri;
+        $this->setHeaders($headers);
+        $this->protocol = $version;
+
+        if (!isset($this->headerNames['host'])) {
+            $this->updateHostFromUri();
+        }
+
+        if ($body !== '' && $body !== null) {
+            $this->stream = Utils::streamFor($body);
+        }
+    }
+
+    public function getRequestTarget()
+    {
+        if ($this->requestTarget !== null) {
+            return $this->requestTarget;
+        }
+
+        $target = $this->uri->getPath();
+        if ($target == '') {
+            $target = '/';
+        }
+        if ($this->uri->getQuery() != '') {
+            $target .= '?' . $this->uri->getQuery();
+        }
+
+        return $target;
+    }
+
+    public function withRequestTarget($requestTarget)
+    {
+        if (preg_match('#\s#', $requestTarget)) {
+            throw new InvalidArgumentException(
+                'Invalid request target provided; cannot contain whitespace'
+            );
+        }
+
+        $new = clone $this;
+        $new->requestTarget = $requestTarget;
+        return $new;
+    }
+
+    public function getMethod()
+    {
+        return $this->method;
+    }
+
+    public function withMethod($method)
+    {
+        $this->assertMethod($method);
+        $new = clone $this;
+        $new->method = strtoupper($method);
+        return $new;
+    }
+
+    public function getUri()
+    {
+        return $this->uri;
+    }
+
+    public function withUri(UriInterface $uri, $preserveHost = false)
+    {
+        if ($uri === $this->uri) {
+            return $this;
+        }
+
+        $new = clone $this;
+        $new->uri = $uri;
+
+        if (!$preserveHost || !isset($this->headerNames['host'])) {
+            $new->updateHostFromUri();
+        }
+
+        return $new;
+    }
+
+    private function updateHostFromUri()
+    {
+        $host = $this->uri->getHost();
+
+        if ($host == '') {
+            return;
+        }
+
+        if (($port = $this->uri->getPort()) !== null) {
+            $host .= ':' . $port;
+        }
+
+        if (isset($this->headerNames['host'])) {
+            $header = $this->headerNames['host'];
+        } else {
+            $header = 'Host';
+            $this->headerNames['host'] = 'Host';
+        }
+        // Ensure Host is the first header.
+        // See: http://tools.ietf.org/html/rfc7230#section-5.4
+        $this->headers = [$header => [$host]] + $this->headers;
+    }
+
+    private function assertMethod($method)
+    {
+        if (!is_string($method) || $method === '') {
+            throw new \InvalidArgumentException('Method must be a non-empty string.');
+        }
+    }
+}

+ 155 - 155
vendor/guzzlehttp/psr7/src/Response.php

@@ -1,155 +1,155 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\ResponseInterface;
-use Psr\Http\Message\StreamInterface;
-
-/**
- * PSR-7 response implementation.
- */
-class Response implements ResponseInterface
-{
-    use MessageTrait;
-
-    /** @var array Map of standard HTTP status code/reason phrases */
-    private static $phrases = [
-        100 => 'Continue',
-        101 => 'Switching Protocols',
-        102 => 'Processing',
-        200 => 'OK',
-        201 => 'Created',
-        202 => 'Accepted',
-        203 => 'Non-Authoritative Information',
-        204 => 'No Content',
-        205 => 'Reset Content',
-        206 => 'Partial Content',
-        207 => 'Multi-status',
-        208 => 'Already Reported',
-        300 => 'Multiple Choices',
-        301 => 'Moved Permanently',
-        302 => 'Found',
-        303 => 'See Other',
-        304 => 'Not Modified',
-        305 => 'Use Proxy',
-        306 => 'Switch Proxy',
-        307 => 'Temporary Redirect',
-        400 => 'Bad Request',
-        401 => 'Unauthorized',
-        402 => 'Payment Required',
-        403 => 'Forbidden',
-        404 => 'Not Found',
-        405 => 'Method Not Allowed',
-        406 => 'Not Acceptable',
-        407 => 'Proxy Authentication Required',
-        408 => 'Request Time-out',
-        409 => 'Conflict',
-        410 => 'Gone',
-        411 => 'Length Required',
-        412 => 'Precondition Failed',
-        413 => 'Request Entity Too Large',
-        414 => 'Request-URI Too Large',
-        415 => 'Unsupported Media Type',
-        416 => 'Requested range not satisfiable',
-        417 => 'Expectation Failed',
-        418 => 'I\'m a teapot',
-        422 => 'Unprocessable Entity',
-        423 => 'Locked',
-        424 => 'Failed Dependency',
-        425 => 'Unordered Collection',
-        426 => 'Upgrade Required',
-        428 => 'Precondition Required',
-        429 => 'Too Many Requests',
-        431 => 'Request Header Fields Too Large',
-        451 => 'Unavailable For Legal Reasons',
-        500 => 'Internal Server Error',
-        501 => 'Not Implemented',
-        502 => 'Bad Gateway',
-        503 => 'Service Unavailable',
-        504 => 'Gateway Time-out',
-        505 => 'HTTP Version not supported',
-        506 => 'Variant Also Negotiates',
-        507 => 'Insufficient Storage',
-        508 => 'Loop Detected',
-        511 => 'Network Authentication Required',
-    ];
-
-    /** @var string */
-    private $reasonPhrase = '';
-
-    /** @var int */
-    private $statusCode = 200;
-
-    /**
-     * @param int                                  $status  Status code
-     * @param array                                $headers Response headers
-     * @param string|resource|StreamInterface|null $body    Response body
-     * @param string                               $version Protocol version
-     * @param string|null                          $reason  Reason phrase (when empty a default will be used based on the status code)
-     */
-    public function __construct(
-        $status = 200,
-        array $headers = [],
-        $body = null,
-        $version = '1.1',
-        $reason = null
-    ) {
-        $this->assertStatusCodeIsInteger($status);
-        $status = (int) $status;
-        $this->assertStatusCodeRange($status);
-
-        $this->statusCode = $status;
-
-        if ($body !== '' && $body !== null) {
-            $this->stream = Utils::streamFor($body);
-        }
-
-        $this->setHeaders($headers);
-        if ($reason == '' && isset(self::$phrases[$this->statusCode])) {
-            $this->reasonPhrase = self::$phrases[$this->statusCode];
-        } else {
-            $this->reasonPhrase = (string) $reason;
-        }
-
-        $this->protocol = $version;
-    }
-
-    public function getStatusCode()
-    {
-        return $this->statusCode;
-    }
-
-    public function getReasonPhrase()
-    {
-        return $this->reasonPhrase;
-    }
-
-    public function withStatus($code, $reasonPhrase = '')
-    {
-        $this->assertStatusCodeIsInteger($code);
-        $code = (int) $code;
-        $this->assertStatusCodeRange($code);
-
-        $new = clone $this;
-        $new->statusCode = $code;
-        if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) {
-            $reasonPhrase = self::$phrases[$new->statusCode];
-        }
-        $new->reasonPhrase = (string) $reasonPhrase;
-        return $new;
-    }
-
-    private function assertStatusCodeIsInteger($statusCode)
-    {
-        if (filter_var($statusCode, FILTER_VALIDATE_INT) === false) {
-            throw new \InvalidArgumentException('Status code must be an integer value.');
-        }
-    }
-
-    private function assertStatusCodeRange($statusCode)
-    {
-        if ($statusCode < 100 || $statusCode >= 600) {
-            throw new \InvalidArgumentException('Status code must be an integer value between 1xx and 5xx.');
-        }
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * PSR-7 response implementation.
+ */
+class Response implements ResponseInterface
+{
+    use MessageTrait;
+
+    /** @var array Map of standard HTTP status code/reason phrases */
+    private static $phrases = [
+        100 => 'Continue',
+        101 => 'Switching Protocols',
+        102 => 'Processing',
+        200 => 'OK',
+        201 => 'Created',
+        202 => 'Accepted',
+        203 => 'Non-Authoritative Information',
+        204 => 'No Content',
+        205 => 'Reset Content',
+        206 => 'Partial Content',
+        207 => 'Multi-status',
+        208 => 'Already Reported',
+        300 => 'Multiple Choices',
+        301 => 'Moved Permanently',
+        302 => 'Found',
+        303 => 'See Other',
+        304 => 'Not Modified',
+        305 => 'Use Proxy',
+        306 => 'Switch Proxy',
+        307 => 'Temporary Redirect',
+        400 => 'Bad Request',
+        401 => 'Unauthorized',
+        402 => 'Payment Required',
+        403 => 'Forbidden',
+        404 => 'Not Found',
+        405 => 'Method Not Allowed',
+        406 => 'Not Acceptable',
+        407 => 'Proxy Authentication Required',
+        408 => 'Request Time-out',
+        409 => 'Conflict',
+        410 => 'Gone',
+        411 => 'Length Required',
+        412 => 'Precondition Failed',
+        413 => 'Request Entity Too Large',
+        414 => 'Request-URI Too Large',
+        415 => 'Unsupported Media Type',
+        416 => 'Requested range not satisfiable',
+        417 => 'Expectation Failed',
+        418 => 'I\'m a teapot',
+        422 => 'Unprocessable Entity',
+        423 => 'Locked',
+        424 => 'Failed Dependency',
+        425 => 'Unordered Collection',
+        426 => 'Upgrade Required',
+        428 => 'Precondition Required',
+        429 => 'Too Many Requests',
+        431 => 'Request Header Fields Too Large',
+        451 => 'Unavailable For Legal Reasons',
+        500 => 'Internal Server Error',
+        501 => 'Not Implemented',
+        502 => 'Bad Gateway',
+        503 => 'Service Unavailable',
+        504 => 'Gateway Time-out',
+        505 => 'HTTP Version not supported',
+        506 => 'Variant Also Negotiates',
+        507 => 'Insufficient Storage',
+        508 => 'Loop Detected',
+        511 => 'Network Authentication Required',
+    ];
+
+    /** @var string */
+    private $reasonPhrase = '';
+
+    /** @var int */
+    private $statusCode = 200;
+
+    /**
+     * @param int                                  $status  Status code
+     * @param array                                $headers Response headers
+     * @param string|resource|StreamInterface|null $body    Response body
+     * @param string                               $version Protocol version
+     * @param string|null                          $reason  Reason phrase (when empty a default will be used based on the status code)
+     */
+    public function __construct(
+        $status = 200,
+        array $headers = [],
+        $body = null,
+        $version = '1.1',
+        $reason = null
+    ) {
+        $this->assertStatusCodeIsInteger($status);
+        $status = (int) $status;
+        $this->assertStatusCodeRange($status);
+
+        $this->statusCode = $status;
+
+        if ($body !== '' && $body !== null) {
+            $this->stream = Utils::streamFor($body);
+        }
+
+        $this->setHeaders($headers);
+        if ($reason == '' && isset(self::$phrases[$this->statusCode])) {
+            $this->reasonPhrase = self::$phrases[$this->statusCode];
+        } else {
+            $this->reasonPhrase = (string) $reason;
+        }
+
+        $this->protocol = $version;
+    }
+
+    public function getStatusCode()
+    {
+        return $this->statusCode;
+    }
+
+    public function getReasonPhrase()
+    {
+        return $this->reasonPhrase;
+    }
+
+    public function withStatus($code, $reasonPhrase = '')
+    {
+        $this->assertStatusCodeIsInteger($code);
+        $code = (int) $code;
+        $this->assertStatusCodeRange($code);
+
+        $new = clone $this;
+        $new->statusCode = $code;
+        if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) {
+            $reasonPhrase = self::$phrases[$new->statusCode];
+        }
+        $new->reasonPhrase = (string) $reasonPhrase;
+        return $new;
+    }
+
+    private function assertStatusCodeIsInteger($statusCode)
+    {
+        if (filter_var($statusCode, FILTER_VALIDATE_INT) === false) {
+            throw new \InvalidArgumentException('Status code must be an integer value.');
+        }
+    }
+
+    private function assertStatusCodeRange($statusCode)
+    {
+        if ($statusCode < 100 || $statusCode >= 600) {
+            throw new \InvalidArgumentException('Status code must be an integer value between 1xx and 5xx.');
+        }
+    }
+}

+ 19 - 19
vendor/guzzlehttp/psr7/src/Rfc7230.php

@@ -1,19 +1,19 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-final class Rfc7230
-{
-    /**
-     * Header related regular expressions (copied from amphp/http package)
-     * (Note: once we require PHP 7.x we could just depend on the upstream package)
-     *
-     * Note: header delimiter (\r\n) is modified to \r?\n to accept line feed only delimiters for BC reasons.
-     *
-     * @link    https://github.com/amphp/http/blob/v1.0.1/src/Rfc7230.php#L12-L15
-     *
-     * @license https://github.com/amphp/http/blob/v1.0.1/LICENSE
-     */
-    const HEADER_REGEX = "(^([^()<>@,;:\\\"/[\]?={}\x01-\x20\x7F]++):[ \t]*+((?:[ \t]*+[\x21-\x7E\x80-\xFF]++)*+)[ \t]*+\r?\n)m";
-    const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)";
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+final class Rfc7230
+{
+    /**
+     * Header related regular expressions (copied from amphp/http package)
+     * (Note: once we require PHP 7.x we could just depend on the upstream package)
+     *
+     * Note: header delimiter (\r\n) is modified to \r?\n to accept line feed only delimiters for BC reasons.
+     *
+     * @link    https://github.com/amphp/http/blob/v1.0.1/src/Rfc7230.php#L12-L15
+     *
+     * @license https://github.com/amphp/http/blob/v1.0.1/LICENSE
+     */
+    const HEADER_REGEX = "(^([^()<>@,;:\\\"/[\]?={}\x01-\x20\x7F]++):[ \t]*+((?:[ \t]*+[\x21-\x7E\x80-\xFF]++)*+)[ \t]*+\r?\n)m";
+    const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)";
+}

+ 379 - 379
vendor/guzzlehttp/psr7/src/ServerRequest.php

@@ -1,379 +1,379 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use InvalidArgumentException;
-use Psr\Http\Message\ServerRequestInterface;
-use Psr\Http\Message\StreamInterface;
-use Psr\Http\Message\UploadedFileInterface;
-use Psr\Http\Message\UriInterface;
-
-/**
- * Server-side HTTP request
- *
- * Extends the Request definition to add methods for accessing incoming data,
- * specifically server parameters, cookies, matched path parameters, query
- * string arguments, body parameters, and upload file information.
- *
- * "Attributes" are discovered via decomposing the request (and usually
- * specifically the URI path), and typically will be injected by the application.
- *
- * Requests are considered immutable; all methods that might change state are
- * implemented such that they retain the internal state of the current
- * message and return a new instance that contains the changed state.
- */
-class ServerRequest extends Request implements ServerRequestInterface
-{
-    /**
-     * @var array
-     */
-    private $attributes = [];
-
-    /**
-     * @var array
-     */
-    private $cookieParams = [];
-
-    /**
-     * @var array|object|null
-     */
-    private $parsedBody;
-
-    /**
-     * @var array
-     */
-    private $queryParams = [];
-
-    /**
-     * @var array
-     */
-    private $serverParams;
-
-    /**
-     * @var array
-     */
-    private $uploadedFiles = [];
-
-    /**
-     * @param string                               $method       HTTP method
-     * @param string|UriInterface                  $uri          URI
-     * @param array                                $headers      Request headers
-     * @param string|resource|StreamInterface|null $body         Request body
-     * @param string                               $version      Protocol version
-     * @param array                                $serverParams Typically the $_SERVER superglobal
-     */
-    public function __construct(
-        $method,
-        $uri,
-        array $headers = [],
-        $body = null,
-        $version = '1.1',
-        array $serverParams = []
-    ) {
-        $this->serverParams = $serverParams;
-
-        parent::__construct($method, $uri, $headers, $body, $version);
-    }
-
-    /**
-     * Return an UploadedFile instance array.
-     *
-     * @param array $files A array which respect $_FILES structure
-     *
-     * @return array
-     *
-     * @throws InvalidArgumentException for unrecognized values
-     */
-    public static function normalizeFiles(array $files)
-    {
-        $normalized = [];
-
-        foreach ($files as $key => $value) {
-            if ($value instanceof UploadedFileInterface) {
-                $normalized[$key] = $value;
-            } elseif (is_array($value) && isset($value['tmp_name'])) {
-                $normalized[$key] = self::createUploadedFileFromSpec($value);
-            } elseif (is_array($value)) {
-                $normalized[$key] = self::normalizeFiles($value);
-                continue;
-            } else {
-                throw new InvalidArgumentException('Invalid value in files specification');
-            }
-        }
-
-        return $normalized;
-    }
-
-    /**
-     * Create and return an UploadedFile instance from a $_FILES specification.
-     *
-     * If the specification represents an array of values, this method will
-     * delegate to normalizeNestedFileSpec() and return that return value.
-     *
-     * @param array $value $_FILES struct
-     *
-     * @return array|UploadedFileInterface
-     */
-    private static function createUploadedFileFromSpec(array $value)
-    {
-        if (is_array($value['tmp_name'])) {
-            return self::normalizeNestedFileSpec($value);
-        }
-
-        return new UploadedFile(
-            $value['tmp_name'],
-            (int) $value['size'],
-            (int) $value['error'],
-            $value['name'],
-            $value['type']
-        );
-    }
-
-    /**
-     * Normalize an array of file specifications.
-     *
-     * Loops through all nested files and returns a normalized array of
-     * UploadedFileInterface instances.
-     *
-     * @param array $files
-     *
-     * @return UploadedFileInterface[]
-     */
-    private static function normalizeNestedFileSpec(array $files = [])
-    {
-        $normalizedFiles = [];
-
-        foreach (array_keys($files['tmp_name']) as $key) {
-            $spec = [
-                'tmp_name' => $files['tmp_name'][$key],
-                'size'     => $files['size'][$key],
-                'error'    => $files['error'][$key],
-                'name'     => $files['name'][$key],
-                'type'     => $files['type'][$key],
-            ];
-            $normalizedFiles[$key] = self::createUploadedFileFromSpec($spec);
-        }
-
-        return $normalizedFiles;
-    }
-
-    /**
-     * Return a ServerRequest populated with superglobals:
-     * $_GET
-     * $_POST
-     * $_COOKIE
-     * $_FILES
-     * $_SERVER
-     *
-     * @return ServerRequestInterface
-     */
-    public static function fromGlobals()
-    {
-        $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
-        $headers = getallheaders();
-        $uri = self::getUriFromGlobals();
-        $body = new CachingStream(new LazyOpenStream('php://input', 'r+'));
-        $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1';
-
-        $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER);
-
-        return $serverRequest
-            ->withCookieParams($_COOKIE)
-            ->withQueryParams($_GET)
-            ->withParsedBody($_POST)
-            ->withUploadedFiles(self::normalizeFiles($_FILES));
-    }
-
-    private static function extractHostAndPortFromAuthority($authority)
-    {
-        $uri = 'http://' . $authority;
-        $parts = parse_url($uri);
-        if (false === $parts) {
-            return [null, null];
-        }
-
-        $host = isset($parts['host']) ? $parts['host'] : null;
-        $port = isset($parts['port']) ? $parts['port'] : null;
-
-        return [$host, $port];
-    }
-
-    /**
-     * Get a Uri populated with values from $_SERVER.
-     *
-     * @return UriInterface
-     */
-    public static function getUriFromGlobals()
-    {
-        $uri = new Uri('');
-
-        $uri = $uri->withScheme(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http');
-
-        $hasPort = false;
-        if (isset($_SERVER['HTTP_HOST'])) {
-            list($host, $port) = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']);
-            if ($host !== null) {
-                $uri = $uri->withHost($host);
-            }
-
-            if ($port !== null) {
-                $hasPort = true;
-                $uri = $uri->withPort($port);
-            }
-        } elseif (isset($_SERVER['SERVER_NAME'])) {
-            $uri = $uri->withHost($_SERVER['SERVER_NAME']);
-        } elseif (isset($_SERVER['SERVER_ADDR'])) {
-            $uri = $uri->withHost($_SERVER['SERVER_ADDR']);
-        }
-
-        if (!$hasPort && isset($_SERVER['SERVER_PORT'])) {
-            $uri = $uri->withPort($_SERVER['SERVER_PORT']);
-        }
-
-        $hasQuery = false;
-        if (isset($_SERVER['REQUEST_URI'])) {
-            $requestUriParts = explode('?', $_SERVER['REQUEST_URI'], 2);
-            $uri = $uri->withPath($requestUriParts[0]);
-            if (isset($requestUriParts[1])) {
-                $hasQuery = true;
-                $uri = $uri->withQuery($requestUriParts[1]);
-            }
-        }
-
-        if (!$hasQuery && isset($_SERVER['QUERY_STRING'])) {
-            $uri = $uri->withQuery($_SERVER['QUERY_STRING']);
-        }
-
-        return $uri;
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function getServerParams()
-    {
-        return $this->serverParams;
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function getUploadedFiles()
-    {
-        return $this->uploadedFiles;
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function withUploadedFiles(array $uploadedFiles)
-    {
-        $new = clone $this;
-        $new->uploadedFiles = $uploadedFiles;
-
-        return $new;
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function getCookieParams()
-    {
-        return $this->cookieParams;
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function withCookieParams(array $cookies)
-    {
-        $new = clone $this;
-        $new->cookieParams = $cookies;
-
-        return $new;
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function getQueryParams()
-    {
-        return $this->queryParams;
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function withQueryParams(array $query)
-    {
-        $new = clone $this;
-        $new->queryParams = $query;
-
-        return $new;
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function getParsedBody()
-    {
-        return $this->parsedBody;
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function withParsedBody($data)
-    {
-        $new = clone $this;
-        $new->parsedBody = $data;
-
-        return $new;
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function getAttributes()
-    {
-        return $this->attributes;
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function getAttribute($attribute, $default = null)
-    {
-        if (false === array_key_exists($attribute, $this->attributes)) {
-            return $default;
-        }
-
-        return $this->attributes[$attribute];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function withAttribute($attribute, $value)
-    {
-        $new = clone $this;
-        $new->attributes[$attribute] = $value;
-
-        return $new;
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function withoutAttribute($attribute)
-    {
-        if (false === array_key_exists($attribute, $this->attributes)) {
-            return $this;
-        }
-
-        $new = clone $this;
-        unset($new->attributes[$attribute]);
-
-        return $new;
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use InvalidArgumentException;
+use Psr\Http\Message\ServerRequestInterface;
+use Psr\Http\Message\StreamInterface;
+use Psr\Http\Message\UploadedFileInterface;
+use Psr\Http\Message\UriInterface;
+
+/**
+ * Server-side HTTP request
+ *
+ * Extends the Request definition to add methods for accessing incoming data,
+ * specifically server parameters, cookies, matched path parameters, query
+ * string arguments, body parameters, and upload file information.
+ *
+ * "Attributes" are discovered via decomposing the request (and usually
+ * specifically the URI path), and typically will be injected by the application.
+ *
+ * Requests are considered immutable; all methods that might change state are
+ * implemented such that they retain the internal state of the current
+ * message and return a new instance that contains the changed state.
+ */
+class ServerRequest extends Request implements ServerRequestInterface
+{
+    /**
+     * @var array
+     */
+    private $attributes = [];
+
+    /**
+     * @var array
+     */
+    private $cookieParams = [];
+
+    /**
+     * @var array|object|null
+     */
+    private $parsedBody;
+
+    /**
+     * @var array
+     */
+    private $queryParams = [];
+
+    /**
+     * @var array
+     */
+    private $serverParams;
+
+    /**
+     * @var array
+     */
+    private $uploadedFiles = [];
+
+    /**
+     * @param string                               $method       HTTP method
+     * @param string|UriInterface                  $uri          URI
+     * @param array                                $headers      Request headers
+     * @param string|resource|StreamInterface|null $body         Request body
+     * @param string                               $version      Protocol version
+     * @param array                                $serverParams Typically the $_SERVER superglobal
+     */
+    public function __construct(
+        $method,
+        $uri,
+        array $headers = [],
+        $body = null,
+        $version = '1.1',
+        array $serverParams = []
+    ) {
+        $this->serverParams = $serverParams;
+
+        parent::__construct($method, $uri, $headers, $body, $version);
+    }
+
+    /**
+     * Return an UploadedFile instance array.
+     *
+     * @param array $files A array which respect $_FILES structure
+     *
+     * @return array
+     *
+     * @throws InvalidArgumentException for unrecognized values
+     */
+    public static function normalizeFiles(array $files)
+    {
+        $normalized = [];
+
+        foreach ($files as $key => $value) {
+            if ($value instanceof UploadedFileInterface) {
+                $normalized[$key] = $value;
+            } elseif (is_array($value) && isset($value['tmp_name'])) {
+                $normalized[$key] = self::createUploadedFileFromSpec($value);
+            } elseif (is_array($value)) {
+                $normalized[$key] = self::normalizeFiles($value);
+                continue;
+            } else {
+                throw new InvalidArgumentException('Invalid value in files specification');
+            }
+        }
+
+        return $normalized;
+    }
+
+    /**
+     * Create and return an UploadedFile instance from a $_FILES specification.
+     *
+     * If the specification represents an array of values, this method will
+     * delegate to normalizeNestedFileSpec() and return that return value.
+     *
+     * @param array $value $_FILES struct
+     *
+     * @return array|UploadedFileInterface
+     */
+    private static function createUploadedFileFromSpec(array $value)
+    {
+        if (is_array($value['tmp_name'])) {
+            return self::normalizeNestedFileSpec($value);
+        }
+
+        return new UploadedFile(
+            $value['tmp_name'],
+            (int) $value['size'],
+            (int) $value['error'],
+            $value['name'],
+            $value['type']
+        );
+    }
+
+    /**
+     * Normalize an array of file specifications.
+     *
+     * Loops through all nested files and returns a normalized array of
+     * UploadedFileInterface instances.
+     *
+     * @param array $files
+     *
+     * @return UploadedFileInterface[]
+     */
+    private static function normalizeNestedFileSpec(array $files = [])
+    {
+        $normalizedFiles = [];
+
+        foreach (array_keys($files['tmp_name']) as $key) {
+            $spec = [
+                'tmp_name' => $files['tmp_name'][$key],
+                'size'     => $files['size'][$key],
+                'error'    => $files['error'][$key],
+                'name'     => $files['name'][$key],
+                'type'     => $files['type'][$key],
+            ];
+            $normalizedFiles[$key] = self::createUploadedFileFromSpec($spec);
+        }
+
+        return $normalizedFiles;
+    }
+
+    /**
+     * Return a ServerRequest populated with superglobals:
+     * $_GET
+     * $_POST
+     * $_COOKIE
+     * $_FILES
+     * $_SERVER
+     *
+     * @return ServerRequestInterface
+     */
+    public static function fromGlobals()
+    {
+        $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
+        $headers = getallheaders();
+        $uri = self::getUriFromGlobals();
+        $body = new CachingStream(new LazyOpenStream('php://input', 'r+'));
+        $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1';
+
+        $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER);
+
+        return $serverRequest
+            ->withCookieParams($_COOKIE)
+            ->withQueryParams($_GET)
+            ->withParsedBody($_POST)
+            ->withUploadedFiles(self::normalizeFiles($_FILES));
+    }
+
+    private static function extractHostAndPortFromAuthority($authority)
+    {
+        $uri = 'http://' . $authority;
+        $parts = parse_url($uri);
+        if (false === $parts) {
+            return [null, null];
+        }
+
+        $host = isset($parts['host']) ? $parts['host'] : null;
+        $port = isset($parts['port']) ? $parts['port'] : null;
+
+        return [$host, $port];
+    }
+
+    /**
+     * Get a Uri populated with values from $_SERVER.
+     *
+     * @return UriInterface
+     */
+    public static function getUriFromGlobals()
+    {
+        $uri = new Uri('');
+
+        $uri = $uri->withScheme(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http');
+
+        $hasPort = false;
+        if (isset($_SERVER['HTTP_HOST'])) {
+            list($host, $port) = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']);
+            if ($host !== null) {
+                $uri = $uri->withHost($host);
+            }
+
+            if ($port !== null) {
+                $hasPort = true;
+                $uri = $uri->withPort($port);
+            }
+        } elseif (isset($_SERVER['SERVER_NAME'])) {
+            $uri = $uri->withHost($_SERVER['SERVER_NAME']);
+        } elseif (isset($_SERVER['SERVER_ADDR'])) {
+            $uri = $uri->withHost($_SERVER['SERVER_ADDR']);
+        }
+
+        if (!$hasPort && isset($_SERVER['SERVER_PORT'])) {
+            $uri = $uri->withPort($_SERVER['SERVER_PORT']);
+        }
+
+        $hasQuery = false;
+        if (isset($_SERVER['REQUEST_URI'])) {
+            $requestUriParts = explode('?', $_SERVER['REQUEST_URI'], 2);
+            $uri = $uri->withPath($requestUriParts[0]);
+            if (isset($requestUriParts[1])) {
+                $hasQuery = true;
+                $uri = $uri->withQuery($requestUriParts[1]);
+            }
+        }
+
+        if (!$hasQuery && isset($_SERVER['QUERY_STRING'])) {
+            $uri = $uri->withQuery($_SERVER['QUERY_STRING']);
+        }
+
+        return $uri;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getServerParams()
+    {
+        return $this->serverParams;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getUploadedFiles()
+    {
+        return $this->uploadedFiles;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function withUploadedFiles(array $uploadedFiles)
+    {
+        $new = clone $this;
+        $new->uploadedFiles = $uploadedFiles;
+
+        return $new;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getCookieParams()
+    {
+        return $this->cookieParams;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function withCookieParams(array $cookies)
+    {
+        $new = clone $this;
+        $new->cookieParams = $cookies;
+
+        return $new;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getQueryParams()
+    {
+        return $this->queryParams;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function withQueryParams(array $query)
+    {
+        $new = clone $this;
+        $new->queryParams = $query;
+
+        return $new;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getParsedBody()
+    {
+        return $this->parsedBody;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function withParsedBody($data)
+    {
+        $new = clone $this;
+        $new->parsedBody = $data;
+
+        return $new;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getAttributes()
+    {
+        return $this->attributes;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getAttribute($attribute, $default = null)
+    {
+        if (false === array_key_exists($attribute, $this->attributes)) {
+            return $default;
+        }
+
+        return $this->attributes[$attribute];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function withAttribute($attribute, $value)
+    {
+        $new = clone $this;
+        $new->attributes[$attribute] = $value;
+
+        return $new;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function withoutAttribute($attribute)
+    {
+        if (false === array_key_exists($attribute, $this->attributes)) {
+            return $this;
+        }
+
+        $new = clone $this;
+        unset($new->attributes[$attribute]);
+
+        return $new;
+    }
+}

+ 270 - 270
vendor/guzzlehttp/psr7/src/Stream.php

@@ -1,270 +1,270 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * PHP stream implementation.
- *
- * @var $stream
- */
-class Stream implements StreamInterface
-{
-    /**
-     * Resource modes.
-     *
-     * @var string
-     *
-     * @see http://php.net/manual/function.fopen.php
-     * @see http://php.net/manual/en/function.gzopen.php
-     */
-    const READABLE_MODES = '/r|a\+|ab\+|w\+|wb\+|x\+|xb\+|c\+|cb\+/';
-    const WRITABLE_MODES = '/a|w|r\+|rb\+|rw|x|c/';
-
-    private $stream;
-    private $size;
-    private $seekable;
-    private $readable;
-    private $writable;
-    private $uri;
-    private $customMetadata;
-
-    /**
-     * This constructor accepts an associative array of options.
-     *
-     * - size: (int) If a read stream would otherwise have an indeterminate
-     *   size, but the size is known due to foreknowledge, then you can
-     *   provide that size, in bytes.
-     * - metadata: (array) Any additional metadata to return when the metadata
-     *   of the stream is accessed.
-     *
-     * @param resource $stream  Stream resource to wrap.
-     * @param array    $options Associative array of options.
-     *
-     * @throws \InvalidArgumentException if the stream is not a stream resource
-     */
-    public function __construct($stream, $options = [])
-    {
-        if (!is_resource($stream)) {
-            throw new \InvalidArgumentException('Stream must be a resource');
-        }
-
-        if (isset($options['size'])) {
-            $this->size = $options['size'];
-        }
-
-        $this->customMetadata = isset($options['metadata'])
-            ? $options['metadata']
-            : [];
-
-        $this->stream = $stream;
-        $meta = stream_get_meta_data($this->stream);
-        $this->seekable = $meta['seekable'];
-        $this->readable = (bool)preg_match(self::READABLE_MODES, $meta['mode']);
-        $this->writable = (bool)preg_match(self::WRITABLE_MODES, $meta['mode']);
-        $this->uri = $this->getMetadata('uri');
-    }
-
-    /**
-     * Closes the stream when the destructed
-     */
-    public function __destruct()
-    {
-        $this->close();
-    }
-
-    public function __toString()
-    {
-        try {
-            if ($this->isSeekable()) {
-                $this->seek(0);
-            }
-            return $this->getContents();
-        } catch (\Exception $e) {
-            return '';
-        }
-    }
-
-    public function getContents()
-    {
-        if (!isset($this->stream)) {
-            throw new \RuntimeException('Stream is detached');
-        }
-
-        $contents = stream_get_contents($this->stream);
-
-        if ($contents === false) {
-            throw new \RuntimeException('Unable to read stream contents');
-        }
-
-        return $contents;
-    }
-
-    public function close()
-    {
-        if (isset($this->stream)) {
-            if (is_resource($this->stream)) {
-                fclose($this->stream);
-            }
-            $this->detach();
-        }
-    }
-
-    public function detach()
-    {
-        if (!isset($this->stream)) {
-            return null;
-        }
-
-        $result = $this->stream;
-        unset($this->stream);
-        $this->size = $this->uri = null;
-        $this->readable = $this->writable = $this->seekable = false;
-
-        return $result;
-    }
-
-    public function getSize()
-    {
-        if ($this->size !== null) {
-            return $this->size;
-        }
-
-        if (!isset($this->stream)) {
-            return null;
-        }
-
-        // Clear the stat cache if the stream has a URI
-        if ($this->uri) {
-            clearstatcache(true, $this->uri);
-        }
-
-        $stats = fstat($this->stream);
-        if (isset($stats['size'])) {
-            $this->size = $stats['size'];
-            return $this->size;
-        }
-
-        return null;
-    }
-
-    public function isReadable()
-    {
-        return $this->readable;
-    }
-
-    public function isWritable()
-    {
-        return $this->writable;
-    }
-
-    public function isSeekable()
-    {
-        return $this->seekable;
-    }
-
-    public function eof()
-    {
-        if (!isset($this->stream)) {
-            throw new \RuntimeException('Stream is detached');
-        }
-
-        return feof($this->stream);
-    }
-
-    public function tell()
-    {
-        if (!isset($this->stream)) {
-            throw new \RuntimeException('Stream is detached');
-        }
-
-        $result = ftell($this->stream);
-
-        if ($result === false) {
-            throw new \RuntimeException('Unable to determine stream position');
-        }
-
-        return $result;
-    }
-
-    public function rewind()
-    {
-        $this->seek(0);
-    }
-
-    public function seek($offset, $whence = SEEK_SET)
-    {
-        $whence = (int) $whence;
-
-        if (!isset($this->stream)) {
-            throw new \RuntimeException('Stream is detached');
-        }
-        if (!$this->seekable) {
-            throw new \RuntimeException('Stream is not seekable');
-        }
-        if (fseek($this->stream, $offset, $whence) === -1) {
-            throw new \RuntimeException('Unable to seek to stream position '
-                . $offset . ' with whence ' . var_export($whence, true));
-        }
-    }
-
-    public function read($length)
-    {
-        if (!isset($this->stream)) {
-            throw new \RuntimeException('Stream is detached');
-        }
-        if (!$this->readable) {
-            throw new \RuntimeException('Cannot read from non-readable stream');
-        }
-        if ($length < 0) {
-            throw new \RuntimeException('Length parameter cannot be negative');
-        }
-
-        if (0 === $length) {
-            return '';
-        }
-
-        $string = fread($this->stream, $length);
-        if (false === $string) {
-            throw new \RuntimeException('Unable to read from stream');
-        }
-
-        return $string;
-    }
-
-    public function write($string)
-    {
-        if (!isset($this->stream)) {
-            throw new \RuntimeException('Stream is detached');
-        }
-        if (!$this->writable) {
-            throw new \RuntimeException('Cannot write to a non-writable stream');
-        }
-
-        // We can't know the size after writing anything
-        $this->size = null;
-        $result = fwrite($this->stream, $string);
-
-        if ($result === false) {
-            throw new \RuntimeException('Unable to write to stream');
-        }
-
-        return $result;
-    }
-
-    public function getMetadata($key = null)
-    {
-        if (!isset($this->stream)) {
-            return $key ? null : [];
-        } elseif (!$key) {
-            return $this->customMetadata + stream_get_meta_data($this->stream);
-        } elseif (isset($this->customMetadata[$key])) {
-            return $this->customMetadata[$key];
-        }
-
-        $meta = stream_get_meta_data($this->stream);
-
-        return isset($meta[$key]) ? $meta[$key] : null;
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * PHP stream implementation.
+ *
+ * @var $stream
+ */
+class Stream implements StreamInterface
+{
+    /**
+     * Resource modes.
+     *
+     * @var string
+     *
+     * @see http://php.net/manual/function.fopen.php
+     * @see http://php.net/manual/en/function.gzopen.php
+     */
+    const READABLE_MODES = '/r|a\+|ab\+|w\+|wb\+|x\+|xb\+|c\+|cb\+/';
+    const WRITABLE_MODES = '/a|w|r\+|rb\+|rw|x|c/';
+
+    private $stream;
+    private $size;
+    private $seekable;
+    private $readable;
+    private $writable;
+    private $uri;
+    private $customMetadata;
+
+    /**
+     * This constructor accepts an associative array of options.
+     *
+     * - size: (int) If a read stream would otherwise have an indeterminate
+     *   size, but the size is known due to foreknowledge, then you can
+     *   provide that size, in bytes.
+     * - metadata: (array) Any additional metadata to return when the metadata
+     *   of the stream is accessed.
+     *
+     * @param resource $stream  Stream resource to wrap.
+     * @param array    $options Associative array of options.
+     *
+     * @throws \InvalidArgumentException if the stream is not a stream resource
+     */
+    public function __construct($stream, $options = [])
+    {
+        if (!is_resource($stream)) {
+            throw new \InvalidArgumentException('Stream must be a resource');
+        }
+
+        if (isset($options['size'])) {
+            $this->size = $options['size'];
+        }
+
+        $this->customMetadata = isset($options['metadata'])
+            ? $options['metadata']
+            : [];
+
+        $this->stream = $stream;
+        $meta = stream_get_meta_data($this->stream);
+        $this->seekable = $meta['seekable'];
+        $this->readable = (bool)preg_match(self::READABLE_MODES, $meta['mode']);
+        $this->writable = (bool)preg_match(self::WRITABLE_MODES, $meta['mode']);
+        $this->uri = $this->getMetadata('uri');
+    }
+
+    /**
+     * Closes the stream when the destructed
+     */
+    public function __destruct()
+    {
+        $this->close();
+    }
+
+    public function __toString()
+    {
+        try {
+            if ($this->isSeekable()) {
+                $this->seek(0);
+            }
+            return $this->getContents();
+        } catch (\Exception $e) {
+            return '';
+        }
+    }
+
+    public function getContents()
+    {
+        if (!isset($this->stream)) {
+            throw new \RuntimeException('Stream is detached');
+        }
+
+        $contents = stream_get_contents($this->stream);
+
+        if ($contents === false) {
+            throw new \RuntimeException('Unable to read stream contents');
+        }
+
+        return $contents;
+    }
+
+    public function close()
+    {
+        if (isset($this->stream)) {
+            if (is_resource($this->stream)) {
+                fclose($this->stream);
+            }
+            $this->detach();
+        }
+    }
+
+    public function detach()
+    {
+        if (!isset($this->stream)) {
+            return null;
+        }
+
+        $result = $this->stream;
+        unset($this->stream);
+        $this->size = $this->uri = null;
+        $this->readable = $this->writable = $this->seekable = false;
+
+        return $result;
+    }
+
+    public function getSize()
+    {
+        if ($this->size !== null) {
+            return $this->size;
+        }
+
+        if (!isset($this->stream)) {
+            return null;
+        }
+
+        // Clear the stat cache if the stream has a URI
+        if ($this->uri) {
+            clearstatcache(true, $this->uri);
+        }
+
+        $stats = fstat($this->stream);
+        if (isset($stats['size'])) {
+            $this->size = $stats['size'];
+            return $this->size;
+        }
+
+        return null;
+    }
+
+    public function isReadable()
+    {
+        return $this->readable;
+    }
+
+    public function isWritable()
+    {
+        return $this->writable;
+    }
+
+    public function isSeekable()
+    {
+        return $this->seekable;
+    }
+
+    public function eof()
+    {
+        if (!isset($this->stream)) {
+            throw new \RuntimeException('Stream is detached');
+        }
+
+        return feof($this->stream);
+    }
+
+    public function tell()
+    {
+        if (!isset($this->stream)) {
+            throw new \RuntimeException('Stream is detached');
+        }
+
+        $result = ftell($this->stream);
+
+        if ($result === false) {
+            throw new \RuntimeException('Unable to determine stream position');
+        }
+
+        return $result;
+    }
+
+    public function rewind()
+    {
+        $this->seek(0);
+    }
+
+    public function seek($offset, $whence = SEEK_SET)
+    {
+        $whence = (int) $whence;
+
+        if (!isset($this->stream)) {
+            throw new \RuntimeException('Stream is detached');
+        }
+        if (!$this->seekable) {
+            throw new \RuntimeException('Stream is not seekable');
+        }
+        if (fseek($this->stream, $offset, $whence) === -1) {
+            throw new \RuntimeException('Unable to seek to stream position '
+                . $offset . ' with whence ' . var_export($whence, true));
+        }
+    }
+
+    public function read($length)
+    {
+        if (!isset($this->stream)) {
+            throw new \RuntimeException('Stream is detached');
+        }
+        if (!$this->readable) {
+            throw new \RuntimeException('Cannot read from non-readable stream');
+        }
+        if ($length < 0) {
+            throw new \RuntimeException('Length parameter cannot be negative');
+        }
+
+        if (0 === $length) {
+            return '';
+        }
+
+        $string = fread($this->stream, $length);
+        if (false === $string) {
+            throw new \RuntimeException('Unable to read from stream');
+        }
+
+        return $string;
+    }
+
+    public function write($string)
+    {
+        if (!isset($this->stream)) {
+            throw new \RuntimeException('Stream is detached');
+        }
+        if (!$this->writable) {
+            throw new \RuntimeException('Cannot write to a non-writable stream');
+        }
+
+        // We can't know the size after writing anything
+        $this->size = null;
+        $result = fwrite($this->stream, $string);
+
+        if ($result === false) {
+            throw new \RuntimeException('Unable to write to stream');
+        }
+
+        return $result;
+    }
+
+    public function getMetadata($key = null)
+    {
+        if (!isset($this->stream)) {
+            return $key ? null : [];
+        } elseif (!$key) {
+            return $this->customMetadata + stream_get_meta_data($this->stream);
+        } elseif (isset($this->customMetadata[$key])) {
+            return $this->customMetadata[$key];
+        }
+
+        $meta = stream_get_meta_data($this->stream);
+
+        return isset($meta[$key]) ? $meta[$key] : null;
+    }
+}

+ 152 - 152
vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php

@@ -1,152 +1,152 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * Stream decorator trait
- *
- * @property StreamInterface stream
- */
-trait StreamDecoratorTrait
-{
-    /**
-     * @param StreamInterface $stream Stream to decorate
-     */
-    public function __construct(StreamInterface $stream)
-    {
-        $this->stream = $stream;
-    }
-
-    /**
-     * Magic method used to create a new stream if streams are not added in
-     * the constructor of a decorator (e.g., LazyOpenStream).
-     *
-     * @param string $name Name of the property (allows "stream" only).
-     *
-     * @return StreamInterface
-     */
-    public function __get($name)
-    {
-        if ($name == 'stream') {
-            $this->stream = $this->createStream();
-            return $this->stream;
-        }
-
-        throw new \UnexpectedValueException("$name not found on class");
-    }
-
-    public function __toString()
-    {
-        try {
-            if ($this->isSeekable()) {
-                $this->seek(0);
-            }
-            return $this->getContents();
-        } catch (\Exception $e) {
-            // Really, PHP? https://bugs.php.net/bug.php?id=53648
-            trigger_error('StreamDecorator::__toString exception: '
-                . (string) $e, E_USER_ERROR);
-            return '';
-        }
-    }
-
-    public function getContents()
-    {
-        return Utils::copyToString($this);
-    }
-
-    /**
-     * Allow decorators to implement custom methods
-     *
-     * @param string $method Missing method name
-     * @param array  $args   Method arguments
-     *
-     * @return mixed
-     */
-    public function __call($method, array $args)
-    {
-        $result = call_user_func_array([$this->stream, $method], $args);
-
-        // Always return the wrapped object if the result is a return $this
-        return $result === $this->stream ? $this : $result;
-    }
-
-    public function close()
-    {
-        $this->stream->close();
-    }
-
-    public function getMetadata($key = null)
-    {
-        return $this->stream->getMetadata($key);
-    }
-
-    public function detach()
-    {
-        return $this->stream->detach();
-    }
-
-    public function getSize()
-    {
-        return $this->stream->getSize();
-    }
-
-    public function eof()
-    {
-        return $this->stream->eof();
-    }
-
-    public function tell()
-    {
-        return $this->stream->tell();
-    }
-
-    public function isReadable()
-    {
-        return $this->stream->isReadable();
-    }
-
-    public function isWritable()
-    {
-        return $this->stream->isWritable();
-    }
-
-    public function isSeekable()
-    {
-        return $this->stream->isSeekable();
-    }
-
-    public function rewind()
-    {
-        $this->seek(0);
-    }
-
-    public function seek($offset, $whence = SEEK_SET)
-    {
-        $this->stream->seek($offset, $whence);
-    }
-
-    public function read($length)
-    {
-        return $this->stream->read($length);
-    }
-
-    public function write($string)
-    {
-        return $this->stream->write($string);
-    }
-
-    /**
-     * Implement in subclasses to dynamically create streams when requested.
-     *
-     * @return StreamInterface
-     *
-     * @throws \BadMethodCallException
-     */
-    protected function createStream()
-    {
-        throw new \BadMethodCallException('Not implemented');
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Stream decorator trait
+ *
+ * @property StreamInterface stream
+ */
+trait StreamDecoratorTrait
+{
+    /**
+     * @param StreamInterface $stream Stream to decorate
+     */
+    public function __construct(StreamInterface $stream)
+    {
+        $this->stream = $stream;
+    }
+
+    /**
+     * Magic method used to create a new stream if streams are not added in
+     * the constructor of a decorator (e.g., LazyOpenStream).
+     *
+     * @param string $name Name of the property (allows "stream" only).
+     *
+     * @return StreamInterface
+     */
+    public function __get($name)
+    {
+        if ($name == 'stream') {
+            $this->stream = $this->createStream();
+            return $this->stream;
+        }
+
+        throw new \UnexpectedValueException("$name not found on class");
+    }
+
+    public function __toString()
+    {
+        try {
+            if ($this->isSeekable()) {
+                $this->seek(0);
+            }
+            return $this->getContents();
+        } catch (\Exception $e) {
+            // Really, PHP? https://bugs.php.net/bug.php?id=53648
+            trigger_error('StreamDecorator::__toString exception: '
+                . (string) $e, E_USER_ERROR);
+            return '';
+        }
+    }
+
+    public function getContents()
+    {
+        return Utils::copyToString($this);
+    }
+
+    /**
+     * Allow decorators to implement custom methods
+     *
+     * @param string $method Missing method name
+     * @param array  $args   Method arguments
+     *
+     * @return mixed
+     */
+    public function __call($method, array $args)
+    {
+        $result = call_user_func_array([$this->stream, $method], $args);
+
+        // Always return the wrapped object if the result is a return $this
+        return $result === $this->stream ? $this : $result;
+    }
+
+    public function close()
+    {
+        $this->stream->close();
+    }
+
+    public function getMetadata($key = null)
+    {
+        return $this->stream->getMetadata($key);
+    }
+
+    public function detach()
+    {
+        return $this->stream->detach();
+    }
+
+    public function getSize()
+    {
+        return $this->stream->getSize();
+    }
+
+    public function eof()
+    {
+        return $this->stream->eof();
+    }
+
+    public function tell()
+    {
+        return $this->stream->tell();
+    }
+
+    public function isReadable()
+    {
+        return $this->stream->isReadable();
+    }
+
+    public function isWritable()
+    {
+        return $this->stream->isWritable();
+    }
+
+    public function isSeekable()
+    {
+        return $this->stream->isSeekable();
+    }
+
+    public function rewind()
+    {
+        $this->seek(0);
+    }
+
+    public function seek($offset, $whence = SEEK_SET)
+    {
+        $this->stream->seek($offset, $whence);
+    }
+
+    public function read($length)
+    {
+        return $this->stream->read($length);
+    }
+
+    public function write($string)
+    {
+        return $this->stream->write($string);
+    }
+
+    /**
+     * Implement in subclasses to dynamically create streams when requested.
+     *
+     * @return StreamInterface
+     *
+     * @throws \BadMethodCallException
+     */
+    protected function createStream()
+    {
+        throw new \BadMethodCallException('Not implemented');
+    }
+}

+ 165 - 165
vendor/guzzlehttp/psr7/src/StreamWrapper.php

@@ -1,165 +1,165 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * Converts Guzzle streams into PHP stream resources.
- *
- * @final
- */
-class StreamWrapper
-{
-    /** @var resource */
-    public $context;
-
-    /** @var StreamInterface */
-    private $stream;
-
-    /** @var string r, r+, or w */
-    private $mode;
-
-    /**
-     * Returns a resource representing the stream.
-     *
-     * @param StreamInterface $stream The stream to get a resource for
-     *
-     * @return resource
-     *
-     * @throws \InvalidArgumentException if stream is not readable or writable
-     */
-    public static function getResource(StreamInterface $stream)
-    {
-        self::register();
-
-        if ($stream->isReadable()) {
-            $mode = $stream->isWritable() ? 'r+' : 'r';
-        } elseif ($stream->isWritable()) {
-            $mode = 'w';
-        } else {
-            throw new \InvalidArgumentException('The stream must be readable, '
-                . 'writable, or both.');
-        }
-
-        return fopen('guzzle://stream', $mode, null, self::createStreamContext($stream));
-    }
-
-    /**
-     * Creates a stream context that can be used to open a stream as a php stream resource.
-     *
-     * @param StreamInterface $stream
-     *
-     * @return resource
-     */
-    public static function createStreamContext(StreamInterface $stream)
-    {
-        return stream_context_create([
-            'guzzle' => ['stream' => $stream]
-        ]);
-    }
-
-    /**
-     * Registers the stream wrapper if needed
-     */
-    public static function register()
-    {
-        if (!in_array('guzzle', stream_get_wrappers())) {
-            stream_wrapper_register('guzzle', __CLASS__);
-        }
-    }
-
-    public function stream_open($path, $mode, $options, &$opened_path)
-    {
-        $options = stream_context_get_options($this->context);
-
-        if (!isset($options['guzzle']['stream'])) {
-            return false;
-        }
-
-        $this->mode = $mode;
-        $this->stream = $options['guzzle']['stream'];
-
-        return true;
-    }
-
-    public function stream_read($count)
-    {
-        return $this->stream->read($count);
-    }
-
-    public function stream_write($data)
-    {
-        return (int) $this->stream->write($data);
-    }
-
-    public function stream_tell()
-    {
-        return $this->stream->tell();
-    }
-
-    public function stream_eof()
-    {
-        return $this->stream->eof();
-    }
-
-    public function stream_seek($offset, $whence)
-    {
-        $this->stream->seek($offset, $whence);
-
-        return true;
-    }
-
-    public function stream_cast($cast_as)
-    {
-        $stream = clone($this->stream);
-
-        return $stream->detach();
-    }
-
-    public function stream_stat()
-    {
-        static $modeMap = [
-            'r'  => 33060,
-            'rb' => 33060,
-            'r+' => 33206,
-            'w'  => 33188,
-            'wb' => 33188
-        ];
-
-        return [
-            'dev'     => 0,
-            'ino'     => 0,
-            'mode'    => $modeMap[$this->mode],
-            'nlink'   => 0,
-            'uid'     => 0,
-            'gid'     => 0,
-            'rdev'    => 0,
-            'size'    => $this->stream->getSize() ?: 0,
-            'atime'   => 0,
-            'mtime'   => 0,
-            'ctime'   => 0,
-            'blksize' => 0,
-            'blocks'  => 0
-        ];
-    }
-
-    public function url_stat($path, $flags)
-    {
-        return [
-            'dev'     => 0,
-            'ino'     => 0,
-            'mode'    => 0,
-            'nlink'   => 0,
-            'uid'     => 0,
-            'gid'     => 0,
-            'rdev'    => 0,
-            'size'    => 0,
-            'atime'   => 0,
-            'mtime'   => 0,
-            'ctime'   => 0,
-            'blksize' => 0,
-            'blocks'  => 0
-        ];
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Converts Guzzle streams into PHP stream resources.
+ *
+ * @final
+ */
+class StreamWrapper
+{
+    /** @var resource */
+    public $context;
+
+    /** @var StreamInterface */
+    private $stream;
+
+    /** @var string r, r+, or w */
+    private $mode;
+
+    /**
+     * Returns a resource representing the stream.
+     *
+     * @param StreamInterface $stream The stream to get a resource for
+     *
+     * @return resource
+     *
+     * @throws \InvalidArgumentException if stream is not readable or writable
+     */
+    public static function getResource(StreamInterface $stream)
+    {
+        self::register();
+
+        if ($stream->isReadable()) {
+            $mode = $stream->isWritable() ? 'r+' : 'r';
+        } elseif ($stream->isWritable()) {
+            $mode = 'w';
+        } else {
+            throw new \InvalidArgumentException('The stream must be readable, '
+                . 'writable, or both.');
+        }
+
+        return fopen('guzzle://stream', $mode, null, self::createStreamContext($stream));
+    }
+
+    /**
+     * Creates a stream context that can be used to open a stream as a php stream resource.
+     *
+     * @param StreamInterface $stream
+     *
+     * @return resource
+     */
+    public static function createStreamContext(StreamInterface $stream)
+    {
+        return stream_context_create([
+            'guzzle' => ['stream' => $stream]
+        ]);
+    }
+
+    /**
+     * Registers the stream wrapper if needed
+     */
+    public static function register()
+    {
+        if (!in_array('guzzle', stream_get_wrappers())) {
+            stream_wrapper_register('guzzle', __CLASS__);
+        }
+    }
+
+    public function stream_open($path, $mode, $options, &$opened_path)
+    {
+        $options = stream_context_get_options($this->context);
+
+        if (!isset($options['guzzle']['stream'])) {
+            return false;
+        }
+
+        $this->mode = $mode;
+        $this->stream = $options['guzzle']['stream'];
+
+        return true;
+    }
+
+    public function stream_read($count)
+    {
+        return $this->stream->read($count);
+    }
+
+    public function stream_write($data)
+    {
+        return (int) $this->stream->write($data);
+    }
+
+    public function stream_tell()
+    {
+        return $this->stream->tell();
+    }
+
+    public function stream_eof()
+    {
+        return $this->stream->eof();
+    }
+
+    public function stream_seek($offset, $whence)
+    {
+        $this->stream->seek($offset, $whence);
+
+        return true;
+    }
+
+    public function stream_cast($cast_as)
+    {
+        $stream = clone($this->stream);
+
+        return $stream->detach();
+    }
+
+    public function stream_stat()
+    {
+        static $modeMap = [
+            'r'  => 33060,
+            'rb' => 33060,
+            'r+' => 33206,
+            'w'  => 33188,
+            'wb' => 33188
+        ];
+
+        return [
+            'dev'     => 0,
+            'ino'     => 0,
+            'mode'    => $modeMap[$this->mode],
+            'nlink'   => 0,
+            'uid'     => 0,
+            'gid'     => 0,
+            'rdev'    => 0,
+            'size'    => $this->stream->getSize() ?: 0,
+            'atime'   => 0,
+            'mtime'   => 0,
+            'ctime'   => 0,
+            'blksize' => 0,
+            'blocks'  => 0
+        ];
+    }
+
+    public function url_stat($path, $flags)
+    {
+        return [
+            'dev'     => 0,
+            'ino'     => 0,
+            'mode'    => 0,
+            'nlink'   => 0,
+            'uid'     => 0,
+            'gid'     => 0,
+            'rdev'    => 0,
+            'size'    => 0,
+            'atime'   => 0,
+            'mtime'   => 0,
+            'ctime'   => 0,
+            'blksize' => 0,
+            'blocks'  => 0
+        ];
+    }
+}

+ 328 - 328
vendor/guzzlehttp/psr7/src/UploadedFile.php

@@ -1,328 +1,328 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use InvalidArgumentException;
-use Psr\Http\Message\StreamInterface;
-use Psr\Http\Message\UploadedFileInterface;
-use RuntimeException;
-
-class UploadedFile implements UploadedFileInterface
-{
-    /**
-     * @var int[]
-     */
-    private static $errors = [
-        UPLOAD_ERR_OK,
-        UPLOAD_ERR_INI_SIZE,
-        UPLOAD_ERR_FORM_SIZE,
-        UPLOAD_ERR_PARTIAL,
-        UPLOAD_ERR_NO_FILE,
-        UPLOAD_ERR_NO_TMP_DIR,
-        UPLOAD_ERR_CANT_WRITE,
-        UPLOAD_ERR_EXTENSION,
-    ];
-
-    /**
-     * @var string
-     */
-    private $clientFilename;
-
-    /**
-     * @var string
-     */
-    private $clientMediaType;
-
-    /**
-     * @var int
-     */
-    private $error;
-
-    /**
-     * @var string|null
-     */
-    private $file;
-
-    /**
-     * @var bool
-     */
-    private $moved = false;
-
-    /**
-     * @var int
-     */
-    private $size;
-
-    /**
-     * @var StreamInterface|null
-     */
-    private $stream;
-
-    /**
-     * @param StreamInterface|string|resource $streamOrFile
-     * @param int                             $size
-     * @param int                             $errorStatus
-     * @param string|null                     $clientFilename
-     * @param string|null                     $clientMediaType
-     */
-    public function __construct(
-        $streamOrFile,
-        $size,
-        $errorStatus,
-        $clientFilename = null,
-        $clientMediaType = null
-    ) {
-        $this->setError($errorStatus);
-        $this->setSize($size);
-        $this->setClientFilename($clientFilename);
-        $this->setClientMediaType($clientMediaType);
-
-        if ($this->isOk()) {
-            $this->setStreamOrFile($streamOrFile);
-        }
-    }
-
-    /**
-     * Depending on the value set file or stream variable
-     *
-     * @param mixed $streamOrFile
-     *
-     * @throws InvalidArgumentException
-     */
-    private function setStreamOrFile($streamOrFile)
-    {
-        if (is_string($streamOrFile)) {
-            $this->file = $streamOrFile;
-        } elseif (is_resource($streamOrFile)) {
-            $this->stream = new Stream($streamOrFile);
-        } elseif ($streamOrFile instanceof StreamInterface) {
-            $this->stream = $streamOrFile;
-        } else {
-            throw new InvalidArgumentException(
-                'Invalid stream or file provided for UploadedFile'
-            );
-        }
-    }
-
-    /**
-     * @param int $error
-     *
-     * @throws InvalidArgumentException
-     */
-    private function setError($error)
-    {
-        if (false === is_int($error)) {
-            throw new InvalidArgumentException(
-                'Upload file error status must be an integer'
-            );
-        }
-
-        if (false === in_array($error, UploadedFile::$errors)) {
-            throw new InvalidArgumentException(
-                'Invalid error status for UploadedFile'
-            );
-        }
-
-        $this->error = $error;
-    }
-
-    /**
-     * @param int $size
-     *
-     * @throws InvalidArgumentException
-     */
-    private function setSize($size)
-    {
-        if (false === is_int($size)) {
-            throw new InvalidArgumentException(
-                'Upload file size must be an integer'
-            );
-        }
-
-        $this->size = $size;
-    }
-
-    /**
-     * @param mixed $param
-     *
-     * @return bool
-     */
-    private function isStringOrNull($param)
-    {
-        return in_array(gettype($param), ['string', 'NULL']);
-    }
-
-    /**
-     * @param mixed $param
-     *
-     * @return bool
-     */
-    private function isStringNotEmpty($param)
-    {
-        return is_string($param) && false === empty($param);
-    }
-
-    /**
-     * @param string|null $clientFilename
-     *
-     * @throws InvalidArgumentException
-     */
-    private function setClientFilename($clientFilename)
-    {
-        if (false === $this->isStringOrNull($clientFilename)) {
-            throw new InvalidArgumentException(
-                'Upload file client filename must be a string or null'
-            );
-        }
-
-        $this->clientFilename = $clientFilename;
-    }
-
-    /**
-     * @param string|null $clientMediaType
-     *
-     * @throws InvalidArgumentException
-     */
-    private function setClientMediaType($clientMediaType)
-    {
-        if (false === $this->isStringOrNull($clientMediaType)) {
-            throw new InvalidArgumentException(
-                'Upload file client media type must be a string or null'
-            );
-        }
-
-        $this->clientMediaType = $clientMediaType;
-    }
-
-    /**
-     * Return true if there is no upload error
-     *
-     * @return bool
-     */
-    private function isOk()
-    {
-        return $this->error === UPLOAD_ERR_OK;
-    }
-
-    /**
-     * @return bool
-     */
-    public function isMoved()
-    {
-        return $this->moved;
-    }
-
-    /**
-     * @throws RuntimeException if is moved or not ok
-     */
-    private function validateActive()
-    {
-        if (false === $this->isOk()) {
-            throw new RuntimeException('Cannot retrieve stream due to upload error');
-        }
-
-        if ($this->isMoved()) {
-            throw new RuntimeException('Cannot retrieve stream after it has already been moved');
-        }
-    }
-
-    /**
-     * {@inheritdoc}
-     *
-     * @throws RuntimeException if the upload was not successful.
-     */
-    public function getStream()
-    {
-        $this->validateActive();
-
-        if ($this->stream instanceof StreamInterface) {
-            return $this->stream;
-        }
-
-        return new LazyOpenStream($this->file, 'r+');
-    }
-
-    /**
-     * {@inheritdoc}
-     *
-     * @see http://php.net/is_uploaded_file
-     * @see http://php.net/move_uploaded_file
-     *
-     * @param string $targetPath Path to which to move the uploaded file.
-     *
-     * @throws RuntimeException         if the upload was not successful.
-     * @throws InvalidArgumentException if the $path specified is invalid.
-     * @throws RuntimeException         on any error during the move operation, or on
-     *                                  the second or subsequent call to the method.
-     */
-    public function moveTo($targetPath)
-    {
-        $this->validateActive();
-
-        if (false === $this->isStringNotEmpty($targetPath)) {
-            throw new InvalidArgumentException(
-                'Invalid path provided for move operation; must be a non-empty string'
-            );
-        }
-
-        if ($this->file) {
-            $this->moved = php_sapi_name() == 'cli'
-                ? rename($this->file, $targetPath)
-                : move_uploaded_file($this->file, $targetPath);
-        } else {
-            Utils::copyToStream(
-                $this->getStream(),
-                new LazyOpenStream($targetPath, 'w')
-            );
-
-            $this->moved = true;
-        }
-
-        if (false === $this->moved) {
-            throw new RuntimeException(
-                sprintf('Uploaded file could not be moved to %s', $targetPath)
-            );
-        }
-    }
-
-    /**
-     * {@inheritdoc}
-     *
-     * @return int|null The file size in bytes or null if unknown.
-     */
-    public function getSize()
-    {
-        return $this->size;
-    }
-
-    /**
-     * {@inheritdoc}
-     *
-     * @see http://php.net/manual/en/features.file-upload.errors.php
-     *
-     * @return int One of PHP's UPLOAD_ERR_XXX constants.
-     */
-    public function getError()
-    {
-        return $this->error;
-    }
-
-    /**
-     * {@inheritdoc}
-     *
-     * @return string|null The filename sent by the client or null if none
-     *                     was provided.
-     */
-    public function getClientFilename()
-    {
-        return $this->clientFilename;
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function getClientMediaType()
-    {
-        return $this->clientMediaType;
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use InvalidArgumentException;
+use Psr\Http\Message\StreamInterface;
+use Psr\Http\Message\UploadedFileInterface;
+use RuntimeException;
+
+class UploadedFile implements UploadedFileInterface
+{
+    /**
+     * @var int[]
+     */
+    private static $errors = [
+        UPLOAD_ERR_OK,
+        UPLOAD_ERR_INI_SIZE,
+        UPLOAD_ERR_FORM_SIZE,
+        UPLOAD_ERR_PARTIAL,
+        UPLOAD_ERR_NO_FILE,
+        UPLOAD_ERR_NO_TMP_DIR,
+        UPLOAD_ERR_CANT_WRITE,
+        UPLOAD_ERR_EXTENSION,
+    ];
+
+    /**
+     * @var string
+     */
+    private $clientFilename;
+
+    /**
+     * @var string
+     */
+    private $clientMediaType;
+
+    /**
+     * @var int
+     */
+    private $error;
+
+    /**
+     * @var string|null
+     */
+    private $file;
+
+    /**
+     * @var bool
+     */
+    private $moved = false;
+
+    /**
+     * @var int
+     */
+    private $size;
+
+    /**
+     * @var StreamInterface|null
+     */
+    private $stream;
+
+    /**
+     * @param StreamInterface|string|resource $streamOrFile
+     * @param int                             $size
+     * @param int                             $errorStatus
+     * @param string|null                     $clientFilename
+     * @param string|null                     $clientMediaType
+     */
+    public function __construct(
+        $streamOrFile,
+        $size,
+        $errorStatus,
+        $clientFilename = null,
+        $clientMediaType = null
+    ) {
+        $this->setError($errorStatus);
+        $this->setSize($size);
+        $this->setClientFilename($clientFilename);
+        $this->setClientMediaType($clientMediaType);
+
+        if ($this->isOk()) {
+            $this->setStreamOrFile($streamOrFile);
+        }
+    }
+
+    /**
+     * Depending on the value set file or stream variable
+     *
+     * @param mixed $streamOrFile
+     *
+     * @throws InvalidArgumentException
+     */
+    private function setStreamOrFile($streamOrFile)
+    {
+        if (is_string($streamOrFile)) {
+            $this->file = $streamOrFile;
+        } elseif (is_resource($streamOrFile)) {
+            $this->stream = new Stream($streamOrFile);
+        } elseif ($streamOrFile instanceof StreamInterface) {
+            $this->stream = $streamOrFile;
+        } else {
+            throw new InvalidArgumentException(
+                'Invalid stream or file provided for UploadedFile'
+            );
+        }
+    }
+
+    /**
+     * @param int $error
+     *
+     * @throws InvalidArgumentException
+     */
+    private function setError($error)
+    {
+        if (false === is_int($error)) {
+            throw new InvalidArgumentException(
+                'Upload file error status must be an integer'
+            );
+        }
+
+        if (false === in_array($error, UploadedFile::$errors)) {
+            throw new InvalidArgumentException(
+                'Invalid error status for UploadedFile'
+            );
+        }
+
+        $this->error = $error;
+    }
+
+    /**
+     * @param int $size
+     *
+     * @throws InvalidArgumentException
+     */
+    private function setSize($size)
+    {
+        if (false === is_int($size)) {
+            throw new InvalidArgumentException(
+                'Upload file size must be an integer'
+            );
+        }
+
+        $this->size = $size;
+    }
+
+    /**
+     * @param mixed $param
+     *
+     * @return bool
+     */
+    private function isStringOrNull($param)
+    {
+        return in_array(gettype($param), ['string', 'NULL']);
+    }
+
+    /**
+     * @param mixed $param
+     *
+     * @return bool
+     */
+    private function isStringNotEmpty($param)
+    {
+        return is_string($param) && false === empty($param);
+    }
+
+    /**
+     * @param string|null $clientFilename
+     *
+     * @throws InvalidArgumentException
+     */
+    private function setClientFilename($clientFilename)
+    {
+        if (false === $this->isStringOrNull($clientFilename)) {
+            throw new InvalidArgumentException(
+                'Upload file client filename must be a string or null'
+            );
+        }
+
+        $this->clientFilename = $clientFilename;
+    }
+
+    /**
+     * @param string|null $clientMediaType
+     *
+     * @throws InvalidArgumentException
+     */
+    private function setClientMediaType($clientMediaType)
+    {
+        if (false === $this->isStringOrNull($clientMediaType)) {
+            throw new InvalidArgumentException(
+                'Upload file client media type must be a string or null'
+            );
+        }
+
+        $this->clientMediaType = $clientMediaType;
+    }
+
+    /**
+     * Return true if there is no upload error
+     *
+     * @return bool
+     */
+    private function isOk()
+    {
+        return $this->error === UPLOAD_ERR_OK;
+    }
+
+    /**
+     * @return bool
+     */
+    public function isMoved()
+    {
+        return $this->moved;
+    }
+
+    /**
+     * @throws RuntimeException if is moved or not ok
+     */
+    private function validateActive()
+    {
+        if (false === $this->isOk()) {
+            throw new RuntimeException('Cannot retrieve stream due to upload error');
+        }
+
+        if ($this->isMoved()) {
+            throw new RuntimeException('Cannot retrieve stream after it has already been moved');
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     *
+     * @throws RuntimeException if the upload was not successful.
+     */
+    public function getStream()
+    {
+        $this->validateActive();
+
+        if ($this->stream instanceof StreamInterface) {
+            return $this->stream;
+        }
+
+        return new LazyOpenStream($this->file, 'r+');
+    }
+
+    /**
+     * {@inheritdoc}
+     *
+     * @see http://php.net/is_uploaded_file
+     * @see http://php.net/move_uploaded_file
+     *
+     * @param string $targetPath Path to which to move the uploaded file.
+     *
+     * @throws RuntimeException         if the upload was not successful.
+     * @throws InvalidArgumentException if the $path specified is invalid.
+     * @throws RuntimeException         on any error during the move operation, or on
+     *                                  the second or subsequent call to the method.
+     */
+    public function moveTo($targetPath)
+    {
+        $this->validateActive();
+
+        if (false === $this->isStringNotEmpty($targetPath)) {
+            throw new InvalidArgumentException(
+                'Invalid path provided for move operation; must be a non-empty string'
+            );
+        }
+
+        if ($this->file) {
+            $this->moved = php_sapi_name() == 'cli'
+                ? rename($this->file, $targetPath)
+                : move_uploaded_file($this->file, $targetPath);
+        } else {
+            Utils::copyToStream(
+                $this->getStream(),
+                new LazyOpenStream($targetPath, 'w')
+            );
+
+            $this->moved = true;
+        }
+
+        if (false === $this->moved) {
+            throw new RuntimeException(
+                sprintf('Uploaded file could not be moved to %s', $targetPath)
+            );
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     *
+     * @return int|null The file size in bytes or null if unknown.
+     */
+    public function getSize()
+    {
+        return $this->size;
+    }
+
+    /**
+     * {@inheritdoc}
+     *
+     * @see http://php.net/manual/en/features.file-upload.errors.php
+     *
+     * @return int One of PHP's UPLOAD_ERR_XXX constants.
+     */
+    public function getError()
+    {
+        return $this->error;
+    }
+
+    /**
+     * {@inheritdoc}
+     *
+     * @return string|null The filename sent by the client or null if none
+     *                     was provided.
+     */
+    public function getClientFilename()
+    {
+        return $this->clientFilename;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getClientMediaType()
+    {
+        return $this->clientMediaType;
+    }
+}

+ 810 - 810
vendor/guzzlehttp/psr7/src/Uri.php

@@ -1,810 +1,810 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\UriInterface;
-
-/**
- * PSR-7 URI implementation.
- *
- * @author Michael Dowling
- * @author Tobias Schultze
- * @author Matthew Weier O'Phinney
- */
-class Uri implements UriInterface
-{
-    /**
-     * Absolute http and https URIs require a host per RFC 7230 Section 2.7
-     * but in generic URIs the host can be empty. So for http(s) URIs
-     * we apply this default host when no host is given yet to form a
-     * valid URI.
-     */
-    const HTTP_DEFAULT_HOST = 'localhost';
-
-    private static $defaultPorts = [
-        'http'  => 80,
-        'https' => 443,
-        'ftp' => 21,
-        'gopher' => 70,
-        'nntp' => 119,
-        'news' => 119,
-        'telnet' => 23,
-        'tn3270' => 23,
-        'imap' => 143,
-        'pop' => 110,
-        'ldap' => 389,
-    ];
-
-    private static $charUnreserved = 'a-zA-Z0-9_\-\.~';
-    private static $charSubDelims = '!\$&\'\(\)\*\+,;=';
-    private static $replaceQuery = ['=' => '%3D', '&' => '%26'];
-
-    /** @var string Uri scheme. */
-    private $scheme = '';
-
-    /** @var string Uri user info. */
-    private $userInfo = '';
-
-    /** @var string Uri host. */
-    private $host = '';
-
-    /** @var int|null Uri port. */
-    private $port;
-
-    /** @var string Uri path. */
-    private $path = '';
-
-    /** @var string Uri query string. */
-    private $query = '';
-
-    /** @var string Uri fragment. */
-    private $fragment = '';
-
-    /**
-     * @param string $uri URI to parse
-     */
-    public function __construct($uri = '')
-    {
-        // weak type check to also accept null until we can add scalar type hints
-        if ($uri != '') {
-            $parts = self::parse($uri);
-            if ($parts === false) {
-                throw new \InvalidArgumentException("Unable to parse URI: $uri");
-            }
-            $this->applyParts($parts);
-        }
-    }
-
-    /**
-     * UTF-8 aware \parse_url() replacement.
-     *
-     * The internal function produces broken output for non ASCII domain names
-     * (IDN) when used with locales other than "C".
-     *
-     * On the other hand, cURL understands IDN correctly only when UTF-8 locale
-     * is configured ("C.UTF-8", "en_US.UTF-8", etc.).
-     *
-     * @see https://bugs.php.net/bug.php?id=52923
-     * @see https://www.php.net/manual/en/function.parse-url.php#114817
-     * @see https://curl.haxx.se/libcurl/c/CURLOPT_URL.html#ENCODING
-     *
-     * @param string $url
-     *
-     * @return array|false
-     */
-    private static function parse($url)
-    {
-        // If IPv6
-        $prefix = '';
-        if (preg_match('%^(.*://\[[0-9:a-f]+\])(.*?)$%', $url, $matches)) {
-            $prefix = $matches[1];
-            $url = $matches[2];
-        }
-
-        $encodedUrl = preg_replace_callback(
-            '%[^:/@?&=#]+%usD',
-            static function ($matches) {
-                return urlencode($matches[0]);
-            },
-            $url
-        );
-
-        $result = parse_url($prefix . $encodedUrl);
-
-        if ($result === false) {
-            return false;
-        }
-
-        return array_map('urldecode', $result);
-    }
-
-    public function __toString()
-    {
-        return self::composeComponents(
-            $this->scheme,
-            $this->getAuthority(),
-            $this->path,
-            $this->query,
-            $this->fragment
-        );
-    }
-
-    /**
-     * Composes a URI reference string from its various components.
-     *
-     * Usually this method does not need to be called manually but instead is used indirectly via
-     * `Psr\Http\Message\UriInterface::__toString`.
-     *
-     * PSR-7 UriInterface treats an empty component the same as a missing component as
-     * getQuery(), getFragment() etc. always return a string. This explains the slight
-     * difference to RFC 3986 Section 5.3.
-     *
-     * Another adjustment is that the authority separator is added even when the authority is missing/empty
-     * for the "file" scheme. This is because PHP stream functions like `file_get_contents` only work with
-     * `file:///myfile` but not with `file:/myfile` although they are equivalent according to RFC 3986. But
-     * `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to
-     * that format).
-     *
-     * @param string $scheme
-     * @param string $authority
-     * @param string $path
-     * @param string $query
-     * @param string $fragment
-     *
-     * @return string
-     *
-     * @link https://tools.ietf.org/html/rfc3986#section-5.3
-     */
-    public static function composeComponents($scheme, $authority, $path, $query, $fragment)
-    {
-        $uri = '';
-
-        // weak type checks to also accept null until we can add scalar type hints
-        if ($scheme != '') {
-            $uri .= $scheme . ':';
-        }
-
-        if ($authority != ''|| $scheme === 'file') {
-            $uri .= '//' . $authority;
-        }
-
-        $uri .= $path;
-
-        if ($query != '') {
-            $uri .= '?' . $query;
-        }
-
-        if ($fragment != '') {
-            $uri .= '#' . $fragment;
-        }
-
-        return $uri;
-    }
-
-    /**
-     * Whether the URI has the default port of the current scheme.
-     *
-     * `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used
-     * independently of the implementation.
-     *
-     * @param UriInterface $uri
-     *
-     * @return bool
-     */
-    public static function isDefaultPort(UriInterface $uri)
-    {
-        return $uri->getPort() === null
-            || (isset(self::$defaultPorts[$uri->getScheme()]) && $uri->getPort() === self::$defaultPorts[$uri->getScheme()]);
-    }
-
-    /**
-     * Whether the URI is absolute, i.e. it has a scheme.
-     *
-     * An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true
-     * if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative
-     * to another URI, the base URI. Relative references can be divided into several forms:
-     * - network-path references, e.g. '//example.com/path'
-     * - absolute-path references, e.g. '/path'
-     * - relative-path references, e.g. 'subpath'
-     *
-     * @param UriInterface $uri
-     *
-     * @return bool
-     *
-     * @see Uri::isNetworkPathReference
-     * @see Uri::isAbsolutePathReference
-     * @see Uri::isRelativePathReference
-     * @link https://tools.ietf.org/html/rfc3986#section-4
-     */
-    public static function isAbsolute(UriInterface $uri)
-    {
-        return $uri->getScheme() !== '';
-    }
-
-    /**
-     * Whether the URI is a network-path reference.
-     *
-     * A relative reference that begins with two slash characters is termed an network-path reference.
-     *
-     * @param UriInterface $uri
-     *
-     * @return bool
-     *
-     * @link https://tools.ietf.org/html/rfc3986#section-4.2
-     */
-    public static function isNetworkPathReference(UriInterface $uri)
-    {
-        return $uri->getScheme() === '' && $uri->getAuthority() !== '';
-    }
-
-    /**
-     * Whether the URI is a absolute-path reference.
-     *
-     * A relative reference that begins with a single slash character is termed an absolute-path reference.
-     *
-     * @param UriInterface $uri
-     *
-     * @return bool
-     *
-     * @link https://tools.ietf.org/html/rfc3986#section-4.2
-     */
-    public static function isAbsolutePathReference(UriInterface $uri)
-    {
-        return $uri->getScheme() === ''
-            && $uri->getAuthority() === ''
-            && isset($uri->getPath()[0])
-            && $uri->getPath()[0] === '/';
-    }
-
-    /**
-     * Whether the URI is a relative-path reference.
-     *
-     * A relative reference that does not begin with a slash character is termed a relative-path reference.
-     *
-     * @param UriInterface $uri
-     *
-     * @return bool
-     *
-     * @link https://tools.ietf.org/html/rfc3986#section-4.2
-     */
-    public static function isRelativePathReference(UriInterface $uri)
-    {
-        return $uri->getScheme() === ''
-            && $uri->getAuthority() === ''
-            && (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/');
-    }
-
-    /**
-     * Whether the URI is a same-document reference.
-     *
-     * A same-document reference refers to a URI that is, aside from its fragment
-     * component, identical to the base URI. When no base URI is given, only an empty
-     * URI reference (apart from its fragment) is considered a same-document reference.
-     *
-     * @param UriInterface      $uri  The URI to check
-     * @param UriInterface|null $base An optional base URI to compare against
-     *
-     * @return bool
-     *
-     * @link https://tools.ietf.org/html/rfc3986#section-4.4
-     */
-    public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null)
-    {
-        if ($base !== null) {
-            $uri = UriResolver::resolve($base, $uri);
-
-            return ($uri->getScheme() === $base->getScheme())
-                && ($uri->getAuthority() === $base->getAuthority())
-                && ($uri->getPath() === $base->getPath())
-                && ($uri->getQuery() === $base->getQuery());
-        }
-
-        return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === '';
-    }
-
-    /**
-     * Removes dot segments from a path and returns the new path.
-     *
-     * @param string $path
-     *
-     * @return string
-     *
-     * @deprecated since version 1.4. Use UriResolver::removeDotSegments instead.
-     * @see UriResolver::removeDotSegments
-     */
-    public static function removeDotSegments($path)
-    {
-        return UriResolver::removeDotSegments($path);
-    }
-
-    /**
-     * Converts the relative URI into a new URI that is resolved against the base URI.
-     *
-     * @param UriInterface        $base Base URI
-     * @param string|UriInterface $rel  Relative URI
-     *
-     * @return UriInterface
-     *
-     * @deprecated since version 1.4. Use UriResolver::resolve instead.
-     * @see UriResolver::resolve
-     */
-    public static function resolve(UriInterface $base, $rel)
-    {
-        if (!($rel instanceof UriInterface)) {
-            $rel = new self($rel);
-        }
-
-        return UriResolver::resolve($base, $rel);
-    }
-
-    /**
-     * Creates a new URI with a specific query string value removed.
-     *
-     * Any existing query string values that exactly match the provided key are
-     * removed.
-     *
-     * @param UriInterface $uri URI to use as a base.
-     * @param string       $key Query string key to remove.
-     *
-     * @return UriInterface
-     */
-    public static function withoutQueryValue(UriInterface $uri, $key)
-    {
-        $result = self::getFilteredQueryString($uri, [$key]);
-
-        return $uri->withQuery(implode('&', $result));
-    }
-
-    /**
-     * Creates a new URI with a specific query string value.
-     *
-     * Any existing query string values that exactly match the provided key are
-     * removed and replaced with the given key value pair.
-     *
-     * A value of null will set the query string key without a value, e.g. "key"
-     * instead of "key=value".
-     *
-     * @param UriInterface $uri   URI to use as a base.
-     * @param string       $key   Key to set.
-     * @param string|null  $value Value to set
-     *
-     * @return UriInterface
-     */
-    public static function withQueryValue(UriInterface $uri, $key, $value)
-    {
-        $result = self::getFilteredQueryString($uri, [$key]);
-
-        $result[] = self::generateQueryString($key, $value);
-
-        return $uri->withQuery(implode('&', $result));
-    }
-
-    /**
-     * Creates a new URI with multiple specific query string values.
-     *
-     * It has the same behavior as withQueryValue() but for an associative array of key => value.
-     *
-     * @param UriInterface $uri           URI to use as a base.
-     * @param array        $keyValueArray Associative array of key and values
-     *
-     * @return UriInterface
-     */
-    public static function withQueryValues(UriInterface $uri, array $keyValueArray)
-    {
-        $result = self::getFilteredQueryString($uri, array_keys($keyValueArray));
-
-        foreach ($keyValueArray as $key => $value) {
-            $result[] = self::generateQueryString($key, $value);
-        }
-
-        return $uri->withQuery(implode('&', $result));
-    }
-
-    /**
-     * Creates a URI from a hash of `parse_url` components.
-     *
-     * @param array $parts
-     *
-     * @return UriInterface
-     *
-     * @link http://php.net/manual/en/function.parse-url.php
-     *
-     * @throws \InvalidArgumentException If the components do not form a valid URI.
-     */
-    public static function fromParts(array $parts)
-    {
-        $uri = new self();
-        $uri->applyParts($parts);
-        $uri->validateState();
-
-        return $uri;
-    }
-
-    public function getScheme()
-    {
-        return $this->scheme;
-    }
-
-    public function getAuthority()
-    {
-        $authority = $this->host;
-        if ($this->userInfo !== '') {
-            $authority = $this->userInfo . '@' . $authority;
-        }
-
-        if ($this->port !== null) {
-            $authority .= ':' . $this->port;
-        }
-
-        return $authority;
-    }
-
-    public function getUserInfo()
-    {
-        return $this->userInfo;
-    }
-
-    public function getHost()
-    {
-        return $this->host;
-    }
-
-    public function getPort()
-    {
-        return $this->port;
-    }
-
-    public function getPath()
-    {
-        return $this->path;
-    }
-
-    public function getQuery()
-    {
-        return $this->query;
-    }
-
-    public function getFragment()
-    {
-        return $this->fragment;
-    }
-
-    public function withScheme($scheme)
-    {
-        $scheme = $this->filterScheme($scheme);
-
-        if ($this->scheme === $scheme) {
-            return $this;
-        }
-
-        $new = clone $this;
-        $new->scheme = $scheme;
-        $new->removeDefaultPort();
-        $new->validateState();
-
-        return $new;
-    }
-
-    public function withUserInfo($user, $password = null)
-    {
-        $info = $this->filterUserInfoComponent($user);
-        if ($password !== null) {
-            $info .= ':' . $this->filterUserInfoComponent($password);
-        }
-
-        if ($this->userInfo === $info) {
-            return $this;
-        }
-
-        $new = clone $this;
-        $new->userInfo = $info;
-        $new->validateState();
-
-        return $new;
-    }
-
-    public function withHost($host)
-    {
-        $host = $this->filterHost($host);
-
-        if ($this->host === $host) {
-            return $this;
-        }
-
-        $new = clone $this;
-        $new->host = $host;
-        $new->validateState();
-
-        return $new;
-    }
-
-    public function withPort($port)
-    {
-        $port = $this->filterPort($port);
-
-        if ($this->port === $port) {
-            return $this;
-        }
-
-        $new = clone $this;
-        $new->port = $port;
-        $new->removeDefaultPort();
-        $new->validateState();
-
-        return $new;
-    }
-
-    public function withPath($path)
-    {
-        $path = $this->filterPath($path);
-
-        if ($this->path === $path) {
-            return $this;
-        }
-
-        $new = clone $this;
-        $new->path = $path;
-        $new->validateState();
-
-        return $new;
-    }
-
-    public function withQuery($query)
-    {
-        $query = $this->filterQueryAndFragment($query);
-
-        if ($this->query === $query) {
-            return $this;
-        }
-
-        $new = clone $this;
-        $new->query = $query;
-
-        return $new;
-    }
-
-    public function withFragment($fragment)
-    {
-        $fragment = $this->filterQueryAndFragment($fragment);
-
-        if ($this->fragment === $fragment) {
-            return $this;
-        }
-
-        $new = clone $this;
-        $new->fragment = $fragment;
-
-        return $new;
-    }
-
-    /**
-     * Apply parse_url parts to a URI.
-     *
-     * @param array $parts Array of parse_url parts to apply.
-     */
-    private function applyParts(array $parts)
-    {
-        $this->scheme = isset($parts['scheme'])
-            ? $this->filterScheme($parts['scheme'])
-            : '';
-        $this->userInfo = isset($parts['user'])
-            ? $this->filterUserInfoComponent($parts['user'])
-            : '';
-        $this->host = isset($parts['host'])
-            ? $this->filterHost($parts['host'])
-            : '';
-        $this->port = isset($parts['port'])
-            ? $this->filterPort($parts['port'])
-            : null;
-        $this->path = isset($parts['path'])
-            ? $this->filterPath($parts['path'])
-            : '';
-        $this->query = isset($parts['query'])
-            ? $this->filterQueryAndFragment($parts['query'])
-            : '';
-        $this->fragment = isset($parts['fragment'])
-            ? $this->filterQueryAndFragment($parts['fragment'])
-            : '';
-        if (isset($parts['pass'])) {
-            $this->userInfo .= ':' . $this->filterUserInfoComponent($parts['pass']);
-        }
-
-        $this->removeDefaultPort();
-    }
-
-    /**
-     * @param string $scheme
-     *
-     * @return string
-     *
-     * @throws \InvalidArgumentException If the scheme is invalid.
-     */
-    private function filterScheme($scheme)
-    {
-        if (!is_string($scheme)) {
-            throw new \InvalidArgumentException('Scheme must be a string');
-        }
-
-        return \strtr($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
-    }
-
-    /**
-     * @param string $component
-     *
-     * @return string
-     *
-     * @throws \InvalidArgumentException If the user info is invalid.
-     */
-    private function filterUserInfoComponent($component)
-    {
-        if (!is_string($component)) {
-            throw new \InvalidArgumentException('User info must be a string');
-        }
-
-        return preg_replace_callback(
-            '/(?:[^%' . self::$charUnreserved . self::$charSubDelims . ']+|%(?![A-Fa-f0-9]{2}))/',
-            [$this, 'rawurlencodeMatchZero'],
-            $component
-        );
-    }
-
-    /**
-     * @param string $host
-     *
-     * @return string
-     *
-     * @throws \InvalidArgumentException If the host is invalid.
-     */
-    private function filterHost($host)
-    {
-        if (!is_string($host)) {
-            throw new \InvalidArgumentException('Host must be a string');
-        }
-
-        return \strtr($host, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
-    }
-
-    /**
-     * @param int|null $port
-     *
-     * @return int|null
-     *
-     * @throws \InvalidArgumentException If the port is invalid.
-     */
-    private function filterPort($port)
-    {
-        if ($port === null) {
-            return null;
-        }
-
-        $port = (int) $port;
-        if (0 > $port || 0xffff < $port) {
-            throw new \InvalidArgumentException(
-                sprintf('Invalid port: %d. Must be between 0 and 65535', $port)
-            );
-        }
-
-        return $port;
-    }
-
-    /**
-     * @param UriInterface $uri
-     * @param array        $keys
-     *
-     * @return array
-     */
-    private static function getFilteredQueryString(UriInterface $uri, array $keys)
-    {
-        $current = $uri->getQuery();
-
-        if ($current === '') {
-            return [];
-        }
-
-        $decodedKeys = array_map('rawurldecode', $keys);
-
-        return array_filter(explode('&', $current), function ($part) use ($decodedKeys) {
-            return !in_array(rawurldecode(explode('=', $part)[0]), $decodedKeys, true);
-        });
-    }
-
-    /**
-     * @param string      $key
-     * @param string|null $value
-     *
-     * @return string
-     */
-    private static function generateQueryString($key, $value)
-    {
-        // Query string separators ("=", "&") within the key or value need to be encoded
-        // (while preventing double-encoding) before setting the query string. All other
-        // chars that need percent-encoding will be encoded by withQuery().
-        $queryString = strtr($key, self::$replaceQuery);
-
-        if ($value !== null) {
-            $queryString .= '=' . strtr($value, self::$replaceQuery);
-        }
-
-        return $queryString;
-    }
-
-    private function removeDefaultPort()
-    {
-        if ($this->port !== null && self::isDefaultPort($this)) {
-            $this->port = null;
-        }
-    }
-
-    /**
-     * Filters the path of a URI
-     *
-     * @param string $path
-     *
-     * @return string
-     *
-     * @throws \InvalidArgumentException If the path is invalid.
-     */
-    private function filterPath($path)
-    {
-        if (!is_string($path)) {
-            throw new \InvalidArgumentException('Path must be a string');
-        }
-
-        return preg_replace_callback(
-            '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
-            [$this, 'rawurlencodeMatchZero'],
-            $path
-        );
-    }
-
-    /**
-     * Filters the query string or fragment of a URI.
-     *
-     * @param string $str
-     *
-     * @return string
-     *
-     * @throws \InvalidArgumentException If the query or fragment is invalid.
-     */
-    private function filterQueryAndFragment($str)
-    {
-        if (!is_string($str)) {
-            throw new \InvalidArgumentException('Query and fragment must be a string');
-        }
-
-        return preg_replace_callback(
-            '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/',
-            [$this, 'rawurlencodeMatchZero'],
-            $str
-        );
-    }
-
-    private function rawurlencodeMatchZero(array $match)
-    {
-        return rawurlencode($match[0]);
-    }
-
-    private function validateState()
-    {
-        if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) {
-            $this->host = self::HTTP_DEFAULT_HOST;
-        }
-
-        if ($this->getAuthority() === '') {
-            if (0 === strpos($this->path, '//')) {
-                throw new \InvalidArgumentException('The path of a URI without an authority must not start with two slashes "//"');
-            }
-            if ($this->scheme === '' && false !== strpos(explode('/', $this->path, 2)[0], ':')) {
-                throw new \InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon');
-            }
-        } elseif (isset($this->path[0]) && $this->path[0] !== '/') {
-            @trigger_error(
-                'The path of a URI with an authority must start with a slash "/" or be empty. Automagically fixing the URI ' .
-                'by adding a leading slash to the path is deprecated since version 1.4 and will throw an exception instead.',
-                E_USER_DEPRECATED
-            );
-            $this->path = '/' . $this->path;
-            //throw new \InvalidArgumentException('The path of a URI with an authority must start with a slash "/" or be empty');
-        }
-    }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\UriInterface;
+
+/**
+ * PSR-7 URI implementation.
+ *
+ * @author Michael Dowling
+ * @author Tobias Schultze
+ * @author Matthew Weier O'Phinney
+ */
+class Uri implements UriInterface
+{
+    /**
+     * Absolute http and https URIs require a host per RFC 7230 Section 2.7
+     * but in generic URIs the host can be empty. So for http(s) URIs
+     * we apply this default host when no host is given yet to form a
+     * valid URI.
+     */
+    const HTTP_DEFAULT_HOST = 'localhost';
+
+    private static $defaultPorts = [
+        'http'  => 80,
+        'https' => 443,
+        'ftp' => 21,
+        'gopher' => 70,
+        'nntp' => 119,
+        'news' => 119,
+        'telnet' => 23,
+        'tn3270' => 23,
+        'imap' => 143,
+        'pop' => 110,
+        'ldap' => 389,
+    ];
+
+    private static $charUnreserved = 'a-zA-Z0-9_\-\.~';
+    private static $charSubDelims = '!\$&\'\(\)\*\+,;=';
+    private static $replaceQuery = ['=' => '%3D', '&' => '%26'];
+
+    /** @var string Uri scheme. */
+    private $scheme = '';
+
+    /** @var string Uri user info. */
+    private $userInfo = '';
+
+    /** @var string Uri host. */
+    private $host = '';
+
+    /** @var int|null Uri port. */
+    private $port;
+
+    /** @var string Uri path. */
+    private $path = '';
+
+    /** @var string Uri query string. */
+    private $query = '';
+
+    /** @var string Uri fragment. */
+    private $fragment = '';
+
+    /**
+     * @param string $uri URI to parse
+     */
+    public function __construct($uri = '')
+    {
+        // weak type check to also accept null until we can add scalar type hints
+        if ($uri != '') {
+            $parts = self::parse($uri);
+            if ($parts === false) {
+                throw new \InvalidArgumentException("Unable to parse URI: $uri");
+            }
+            $this->applyParts($parts);
+        }
+    }
+
+    /**
+     * UTF-8 aware \parse_url() replacement.
+     *
+     * The internal function produces broken output for non ASCII domain names
+     * (IDN) when used with locales other than "C".
+     *
+     * On the other hand, cURL understands IDN correctly only when UTF-8 locale
+     * is configured ("C.UTF-8", "en_US.UTF-8", etc.).
+     *
+     * @see https://bugs.php.net/bug.php?id=52923
+     * @see https://www.php.net/manual/en/function.parse-url.php#114817
+     * @see https://curl.haxx.se/libcurl/c/CURLOPT_URL.html#ENCODING
+     *
+     * @param string $url
+     *
+     * @return array|false
+     */
+    private static function parse($url)
+    {
+        // If IPv6
+        $prefix = '';
+        if (preg_match('%^(.*://\[[0-9:a-f]+\])(.*?)$%', $url, $matches)) {
+            $prefix = $matches[1];
+            $url = $matches[2];
+        }
+
+        $encodedUrl = preg_replace_callback(
+            '%[^:/@?&=#]+%usD',
+            static function ($matches) {
+                return urlencode($matches[0]);
+            },
+            $url
+        );
+
+        $result = parse_url($prefix . $encodedUrl);
+
+        if ($result === false) {
+            return false;
+        }
+
+        return array_map('urldecode', $result);
+    }
+
+    public function __toString()
+    {
+        return self::composeComponents(
+            $this->scheme,
+            $this->getAuthority(),
+            $this->path,
+            $this->query,
+            $this->fragment
+        );
+    }
+
+    /**
+     * Composes a URI reference string from its various components.
+     *
+     * Usually this method does not need to be called manually but instead is used indirectly via
+     * `Psr\Http\Message\UriInterface::__toString`.
+     *
+     * PSR-7 UriInterface treats an empty component the same as a missing component as
+     * getQuery(), getFragment() etc. always return a string. This explains the slight
+     * difference to RFC 3986 Section 5.3.
+     *
+     * Another adjustment is that the authority separator is added even when the authority is missing/empty
+     * for the "file" scheme. This is because PHP stream functions like `file_get_contents` only work with
+     * `file:///myfile` but not with `file:/myfile` although they are equivalent according to RFC 3986. But
+     * `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to
+     * that format).
+     *
+     * @param string $scheme
+     * @param string $authority
+     * @param string $path
+     * @param string $query
+     * @param string $fragment
+     *
+     * @return string
+     *
+     * @link https://tools.ietf.org/html/rfc3986#section-5.3
+     */
+    public static function composeComponents($scheme, $authority, $path, $query, $fragment)
+    {
+        $uri = '';
+
+        // weak type checks to also accept null until we can add scalar type hints
+        if ($scheme != '') {
+            $uri .= $scheme . ':';
+        }
+
+        if ($authority != ''|| $scheme === 'file') {
+            $uri .= '//' . $authority;
+        }
+
+        $uri .= $path;
+
+        if ($query != '') {
+            $uri .= '?' . $query;
+        }
+
+        if ($fragment != '') {
+            $uri .= '#' . $fragment;
+        }
+
+        return $uri;
+    }
+
+    /**
+     * Whether the URI has the default port of the current scheme.
+     *
+     * `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used
+     * independently of the implementation.
+     *
+     * @param UriInterface $uri
+     *
+     * @return bool
+     */
+    public static function isDefaultPort(UriInterface $uri)
+    {
+        return $uri->getPort() === null
+            || (isset(self::$defaultPorts[$uri->getScheme()]) && $uri->getPort() === self::$defaultPorts[$uri->getScheme()]);
+    }
+
+    /**
+     * Whether the URI is absolute, i.e. it has a scheme.
+     *
+     * An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true
+     * if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative
+     * to another URI, the base URI. Relative references can be divided into several forms:
+     * - network-path references, e.g. '//example.com/path'
+     * - absolute-path references, e.g. '/path'
+     * - relative-path references, e.g. 'subpath'
+     *
+     * @param UriInterface $uri
+     *
+     * @return bool
+     *
+     * @see Uri::isNetworkPathReference
+     * @see Uri::isAbsolutePathReference
+     * @see Uri::isRelativePathReference
+     * @link https://tools.ietf.org/html/rfc3986#section-4
+     */
+    public static function isAbsolute(UriInterface $uri)
+    {
+        return $uri->getScheme() !== '';
+    }
+
+    /**
+     * Whether the URI is a network-path reference.
+     *
+     * A relative reference that begins with two slash characters is termed an network-path reference.
+     *
+     * @param UriInterface $uri
+     *
+     * @return bool
+     *
+     * @link https://tools.ietf.org/html/rfc3986#section-4.2
+     */
+    public static function isNetworkPathReference(UriInterface $uri)
+    {
+        return $uri->getScheme() === '' && $uri->getAuthority() !== '';
+    }
+
+    /**
+     * Whether the URI is a absolute-path reference.
+     *
+     * A relative reference that begins with a single slash character is termed an absolute-path reference.
+     *
+     * @param UriInterface $uri
+     *
+     * @return bool
+     *
+     * @link https://tools.ietf.org/html/rfc3986#section-4.2
+     */
+    public static function isAbsolutePathReference(UriInterface $uri)
+    {
+        return $uri->getScheme() === ''
+            && $uri->getAuthority() === ''
+            && isset($uri->getPath()[0])
+            && $uri->getPath()[0] === '/';
+    }
+
+    /**
+     * Whether the URI is a relative-path reference.
+     *
+     * A relative reference that does not begin with a slash character is termed a relative-path reference.
+     *
+     * @param UriInterface $uri
+     *
+     * @return bool
+     *
+     * @link https://tools.ietf.org/html/rfc3986#section-4.2
+     */
+    public static function isRelativePathReference(UriInterface $uri)
+    {
+        return $uri->getScheme() === ''
+            && $uri->getAuthority() === ''
+            && (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/');
+    }
+
+    /**
+     * Whether the URI is a same-document reference.
+     *
+     * A same-document reference refers to a URI that is, aside from its fragment
+     * component, identical to the base URI. When no base URI is given, only an empty
+     * URI reference (apart from its fragment) is considered a same-document reference.
+     *
+     * @param UriInterface      $uri  The URI to check
+     * @param UriInterface|null $base An optional base URI to compare against
+     *
+     * @return bool
+     *
+     * @link https://tools.ietf.org/html/rfc3986#section-4.4
+     */
+    public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null)
+    {
+        if ($base !== null) {
+            $uri = UriResolver::resolve($base, $uri);
+
+            return ($uri->getScheme() === $base->getScheme())
+                && ($uri->getAuthority() === $base->getAuthority())
+                && ($uri->getPath() === $base->getPath())
+                && ($uri->getQuery() === $base->getQuery());
+        }
+
+        return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === '';
+    }
+
+    /**
+     * Removes dot segments from a path and returns the new path.
+     *
+     * @param string $path
+     *
+     * @return string
+     *
+     * @deprecated since version 1.4. Use UriResolver::removeDotSegments instead.
+     * @see UriResolver::removeDotSegments
+     */
+    public static function removeDotSegments($path)
+    {
+        return UriResolver::removeDotSegments($path);
+    }
+
+    /**
+     * Converts the relative URI into a new URI that is resolved against the base URI.
+     *
+     * @param UriInterface        $base Base URI
+     * @param string|UriInterface $rel  Relative URI
+     *
+     * @return UriInterface
+     *
+     * @deprecated since version 1.4. Use UriResolver::resolve instead.
+     * @see UriResolver::resolve
+     */
+    public static function resolve(UriInterface $base, $rel)
+    {
+        if (!($rel instanceof UriInterface)) {
+            $rel = new self($rel);
+        }
+
+        return UriResolver::resolve($base, $rel);
+    }
+
+    /**
+     * Creates a new URI with a specific query string value removed.
+     *
+     * Any existing query string values that exactly match the provided key are
+     * removed.
+     *
+     * @param UriInterface $uri URI to use as a base.
+     * @param string       $key Query string key to remove.
+     *
+     * @return UriInterface
+     */
+    public static function withoutQueryValue(UriInterface $uri, $key)
+    {
+        $result = self::getFilteredQueryString($uri, [$key]);
+
+        return $uri->withQuery(implode('&', $result));
+    }
+
+    /**
+     * Creates a new URI with a specific query string value.
+     *
+     * Any existing query string values that exactly match the provided key are
+     * removed and replaced with the given key value pair.
+     *
+     * A value of null will set the query string key without a value, e.g. "key"
+     * instead of "key=value".
+     *
+     * @param UriInterface $uri   URI to use as a base.
+     * @param string       $key   Key to set.
+     * @param string|null  $value Value to set
+     *
+     * @return UriInterface
+     */
+    public static function withQueryValue(UriInterface $uri, $key, $value)
+    {
+        $result = self::getFilteredQueryString($uri, [$key]);
+
+        $result[] = self::generateQueryString($key, $value);
+
+        return $uri->withQuery(implode('&', $result));
+    }
+
+    /**
+     * Creates a new URI with multiple specific query string values.
+     *
+     * It has the same behavior as withQueryValue() but for an associative array of key => value.
+     *
+     * @param UriInterface $uri           URI to use as a base.
+     * @param array        $keyValueArray Associative array of key and values
+     *
+     * @return UriInterface
+     */
+    public static function withQueryValues(UriInterface $uri, array $keyValueArray)
+    {
+        $result = self::getFilteredQueryString($uri, array_keys($keyValueArray));
+
+        foreach ($keyValueArray as $key => $value) {
+            $result[] = self::generateQueryString($key, $value);
+        }
+
+        return $uri->withQuery(implode('&', $result));
+    }
+
+    /**
+     * Creates a URI from a hash of `parse_url` components.
+     *
+     * @param array $parts
+     *
+     * @return UriInterface
+     *
+     * @link http://php.net/manual/en/function.parse-url.php
+     *
+     * @throws \InvalidArgumentException If the components do not form a valid URI.
+     */
+    public static function fromParts(array $parts)
+    {
+        $uri = new self();
+        $uri->applyParts($parts);
+        $uri->validateState();
+
+        return $uri;
+    }
+
+    public function getScheme()
+    {
+        return $this->scheme;
+    }
+
+    public function getAuthority()
+    {
+        $authority = $this->host;
+        if ($this->userInfo !== '') {
+            $authority = $this->userInfo . '@' . $authority;
+        }
+
+        if ($this->port !== null) {
+            $authority .= ':' . $this->port;
+        }
+
+        return $authority;
+    }
+
+    public function getUserInfo()
+    {
+        return $this->userInfo;
+    }
+
+    public function getHost()
+    {
+        return $this->host;
+    }
+
+    public function getPort()
+    {
+        return $this->port;
+    }
+
+    public function getPath()
+    {
+        return $this->path;
+    }
+
+    public function getQuery()
+    {
+        return $this->query;
+    }
+
+    public function getFragment()
+    {
+        return $this->fragment;
+    }
+
+    public function withScheme($scheme)
+    {
+        $scheme = $this->filterScheme($scheme);
+
+        if ($this->scheme === $scheme) {
+            return $this;
+        }
+
+        $new = clone $this;
+        $new->scheme = $scheme;
+        $new->removeDefaultPort();
+        $new->validateState();
+
+        return $new;
+    }
+
+    public function withUserInfo($user, $password = null)
+    {
+        $info = $this->filterUserInfoComponent($user);
+        if ($password !== null) {
+            $info .= ':' . $this->filterUserInfoComponent($password);
+        }
+
+        if ($this->userInfo === $info) {
+            return $this;
+        }
+
+        $new = clone $this;
+        $new->userInfo = $info;
+        $new->validateState();
+
+        return $new;
+    }
+
+    public function withHost($host)
+    {
+        $host = $this->filterHost($host);
+
+        if ($this->host === $host) {
+            return $this;
+        }
+
+        $new = clone $this;
+        $new->host = $host;
+        $new->validateState();
+
+        return $new;
+    }
+
+    public function withPort($port)
+    {
+        $port = $this->filterPort($port);
+
+        if ($this->port === $port) {
+            return $this;
+        }
+
+        $new = clone $this;
+        $new->port = $port;
+        $new->removeDefaultPort();
+        $new->validateState();
+
+        return $new;
+    }
+
+    public function withPath($path)
+    {
+        $path = $this->filterPath($path);
+
+        if ($this->path === $path) {
+            return $this;
+        }
+
+        $new = clone $this;
+        $new->path = $path;
+        $new->validateState();
+
+        return $new;
+    }
+
+    public function withQuery($query)
+    {
+        $query = $this->filterQueryAndFragment($query);
+
+        if ($this->query === $query) {
+            return $this;
+        }
+
+        $new = clone $this;
+        $new->query = $query;
+
+        return $new;
+    }
+
+    public function withFragment($fragment)
+    {
+        $fragment = $this->filterQueryAndFragment($fragment);
+
+        if ($this->fragment === $fragment) {
+            return $this;
+        }
+
+        $new = clone $this;
+        $new->fragment = $fragment;
+
+        return $new;
+    }
+
+    /**
+     * Apply parse_url parts to a URI.
+     *
+     * @param array $parts Array of parse_url parts to apply.
+     */
+    private function applyParts(array $parts)
+    {
+        $this->scheme = isset($parts['scheme'])
+            ? $this->filterScheme($parts['scheme'])
+            : '';
+        $this->userInfo = isset($parts['user'])
+            ? $this->filterUserInfoComponent($parts['user'])
+            : '';
+        $this->host = isset($parts['host'])
+            ? $this->filterHost($parts['host'])
+            : '';
+        $this->port = isset($parts['port'])
+            ? $this->filterPort($parts['port'])
+            : null;
+        $this->path = isset($parts['path'])
+            ? $this->filterPath($parts['path'])
+            : '';
+        $this->query = isset($parts['query'])
+            ? $this->filterQueryAndFragment($parts['query'])
+            : '';
+        $this->fragment = isset($parts['fragment'])
+            ? $this->filterQueryAndFragment($parts['fragment'])
+            : '';
+        if (isset($parts['pass'])) {
+            $this->userInfo .= ':' . $this->filterUserInfoComponent($parts['pass']);
+        }
+
+        $this->removeDefaultPort();
+    }
+
+    /**
+     * @param string $scheme
+     *
+     * @return string
+     *
+     * @throws \InvalidArgumentException If the scheme is invalid.
+     */
+    private function filterScheme($scheme)
+    {
+        if (!is_string($scheme)) {
+            throw new \InvalidArgumentException('Scheme must be a string');
+        }
+
+        return \strtr($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
+    }
+
+    /**
+     * @param string $component
+     *
+     * @return string
+     *
+     * @throws \InvalidArgumentException If the user info is invalid.
+     */
+    private function filterUserInfoComponent($component)
+    {
+        if (!is_string($component)) {
+            throw new \InvalidArgumentException('User info must be a string');
+        }
+
+        return preg_replace_callback(
+            '/(?:[^%' . self::$charUnreserved . self::$charSubDelims . ']+|%(?![A-Fa-f0-9]{2}))/',
+            [$this, 'rawurlencodeMatchZero'],
+            $component
+        );
+    }
+
+    /**
+     * @param string $host
+     *
+     * @return string
+     *
+     * @throws \InvalidArgumentException If the host is invalid.
+     */
+    private function filterHost($host)
+    {
+        if (!is_string($host)) {
+            throw new \InvalidArgumentException('Host must be a string');
+        }
+
+        return \strtr($host, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
+    }
+
+    /**
+     * @param int|null $port
+     *
+     * @return int|null
+     *
+     * @throws \InvalidArgumentException If the port is invalid.
+     */
+    private function filterPort($port)
+    {
+        if ($port === null) {
+            return null;
+        }
+
+        $port = (int) $port;
+        if (0 > $port || 0xffff < $port) {
+            throw new \InvalidArgumentException(
+                sprintf('Invalid port: %d. Must be between 0 and 65535', $port)
+            );
+        }
+
+        return $port;
+    }
+
+    /**
+     * @param UriInterface $uri
+     * @param array        $keys
+     *
+     * @return array
+     */
+    private static function getFilteredQueryString(UriInterface $uri, array $keys)
+    {
+        $current = $uri->getQuery();
+
+        if ($current === '') {
+            return [];
+        }
+
+        $decodedKeys = array_map('rawurldecode', $keys);
+
+        return array_filter(explode('&', $current), function ($part) use ($decodedKeys) {
+            return !in_array(rawurldecode(explode('=', $part)[0]), $decodedKeys, true);
+        });
+    }
+
+    /**
+     * @param string      $key
+     * @param string|null $value
+     *
+     * @return string
+     */
+    private static function generateQueryString($key, $value)
+    {
+        // Query string separators ("=", "&") within the key or value need to be encoded
+        // (while preventing double-encoding) before setting the query string. All other
+        // chars that need percent-encoding will be encoded by withQuery().
+        $queryString = strtr($key, self::$replaceQuery);
+
+        if ($value !== null) {
+            $queryString .= '=' . strtr($value, self::$replaceQuery);
+        }
+
+        return $queryString;
+    }
+
+    private function removeDefaultPort()
+    {
+        if ($this->port !== null && self::isDefaultPort($this)) {
+            $this->port = null;
+        }
+    }
+
+    /**
+     * Filters the path of a URI
+     *
+     * @param string $path
+     *
+     * @return string
+     *
+     * @throws \InvalidArgumentException If the path is invalid.
+     */
+    private function filterPath($path)
+    {
+        if (!is_string($path)) {
+            throw new \InvalidArgumentException('Path must be a string');
+        }
+
+        return preg_replace_callback(
+            '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
+            [$this, 'rawurlencodeMatchZero'],
+            $path
+        );
+    }
+
+    /**
+     * Filters the query string or fragment of a URI.
+     *
+     * @param string $str
+     *
+     * @return string
+     *
+     * @throws \InvalidArgumentException If the query or fragment is invalid.
+     */
+    private function filterQueryAndFragment($str)
+    {
+        if (!is_string($str)) {
+            throw new \InvalidArgumentException('Query and fragment must be a string');
+        }
+
+        return preg_replace_callback(
+            '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/',
+            [$this, 'rawurlencodeMatchZero'],
+            $str
+        );
+    }
+
+    private function rawurlencodeMatchZero(array $match)
+    {
+        return rawurlencode($match[0]);
+    }
+
+    private function validateState()
+    {
+        if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) {
+            $this->host = self::HTTP_DEFAULT_HOST;
+        }
+
+        if ($this->getAuthority() === '') {
+            if (0 === strpos($this->path, '//')) {
+                throw new \InvalidArgumentException('The path of a URI without an authority must not start with two slashes "//"');
+            }
+            if ($this->scheme === '' && false !== strpos(explode('/', $this->path, 2)[0], ':')) {
+                throw new \InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon');
+            }
+        } elseif (isset($this->path[0]) && $this->path[0] !== '/') {
+            @trigger_error(
+                'The path of a URI with an authority must start with a slash "/" or be empty. Automagically fixing the URI ' .
+                'by adding a leading slash to the path is deprecated since version 1.4 and will throw an exception instead.',
+                E_USER_DEPRECATED
+            );
+            $this->path = '/' . $this->path;
+            //throw new \InvalidArgumentException('The path of a URI with an authority must start with a slash "/" or be empty');
+        }
+    }
+}

Some files were not shown because too many files changed in this diff