From 58b5956a156e0020043d8ba23f5eab779bc7b60a Mon Sep 17 00:00:00 2001 From: WispX <1591788658@qq.com> Date: Wed, 8 Jan 2020 11:24:11 +0800 Subject: [PATCH] =?UTF-8?q?:package:=20=E6=9B=B4=E6=96=B0=E6=8B=93?= =?UTF-8?q?=E5=B1=95=E5=8C=85=E5=8F=8A=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.lock | 201 ++--- thinkphp/composer.json | 2 +- thinkphp/library/think/App.php | 2 +- thinkphp/library/think/Model.php | 15 +- thinkphp/library/think/Request.php | 7 +- thinkphp/library/think/Url.php | 14 +- thinkphp/library/think/Validate.php | 6 +- thinkphp/library/think/cache/driver/File.php | 6 +- .../library/think/cache/driver/Memcached.php | 6 +- thinkphp/library/think/db/Builder.php | 3 +- thinkphp/library/think/db/Query.php | 32 +- thinkphp/library/think/db/builder/Mysql.php | 2 +- .../think/model/relation/BelongsTo.php | 7 +- .../think/model/relation/BelongsToMany.php | 9 +- .../library/think/model/relation/HasMany.php | 9 +- .../think/model/relation/HasManyThrough.php | 21 +- .../library/think/model/relation/HasOne.php | 7 +- .../think/model/relation/MorphMany.php | 9 +- .../library/think/model/relation/MorphOne.php | 5 +- .../library/think/model/relation/MorphTo.php | 1 + .../library/think/model/relation/OneToOne.php | 5 +- thinkphp/library/think/route/dispatch/Url.php | 2 +- .../library/think/session/driver/Redis.php | 2 +- vendor/aliyuncs/oss-sdk-php/CHANGELOG.md | 77 +- .../aliyuncs/oss-sdk-php/samples/Bucket.php | 55 +- .../oss-sdk-php/samples/BucketCors.php | 28 +- .../oss-sdk-php/samples/BucketLifecycle.php | 28 +- .../oss-sdk-php/samples/BucketLogging.php | 30 +- .../oss-sdk-php/samples/BucketReferer.php | 30 +- .../oss-sdk-php/samples/BucketWebsite.php | 26 +- .../aliyuncs/oss-sdk-php/samples/Callback.php | 24 +- .../aliyuncs/oss-sdk-php/samples/Common.php | 10 +- .../aliyuncs/oss-sdk-php/samples/Config.php | 12 +- vendor/aliyuncs/oss-sdk-php/samples/Image.php | 22 +- .../oss-sdk-php/samples/LiveChannel.php | 40 +- .../oss-sdk-php/samples/MultipartUpload.php | 38 +- .../aliyuncs/oss-sdk-php/samples/Object.php | 137 ++-- .../aliyuncs/oss-sdk-php/samples/RunAll.php | 2 +- .../oss-sdk-php/samples/Signature.php | 31 +- .../oss-sdk-php/src/OSS/Core/MimeTypes.php | 7 +- .../oss-sdk-php/src/OSS/Core/OssException.php | 4 +- .../oss-sdk-php/src/OSS/Core/OssUtil.php | 108 ++- .../oss-sdk-php/src/OSS/Http/RequestCore.php | 35 +- .../oss-sdk-php/src/OSS/Http/ResponseCore.php | 10 +- .../oss-sdk-php/src/OSS/Model/BucketInfo.php | 14 +- .../src/OSS/Model/BucketListInfo.php | 6 +- .../oss-sdk-php/src/OSS/Model/CorsConfig.php | 10 +- .../oss-sdk-php/src/OSS/Model/CorsRule.php | 18 +- .../src/OSS/Model/LifecycleAction.php | 2 +- .../src/OSS/Model/LifecycleConfig.php | 10 +- .../src/OSS/Model/LifecycleRule.php | 20 +- .../src/OSS/Model/LiveChannelListInfo.php | 2 +- .../src/OSS/Model/LoggingConfig.php | 2 +- .../oss-sdk-php/src/OSS/Model/ObjectInfo.php | 8 +- .../src/OSS/Model/ObjectListInfo.php | 6 +- .../oss-sdk-php/src/OSS/Model/PrefixInfo.php | 8 +- .../src/OSS/Model/RefererConfig.php | 2 +- .../src/OSS/Model/StorageCapacityConfig.php | 2 +- .../oss-sdk-php/src/OSS/Model/UploadInfo.php | 2 +- .../src/OSS/Model/WebsiteConfig.php | 2 +- .../oss-sdk-php/src/OSS/Model/XmlConfig.php | 4 +- .../oss-sdk-php/src/OSS/OssClient.php | 669 +++++++-------- .../oss-sdk-php/src/OSS/Result/AclResult.php | 3 +- .../src/OSS/Result/AppendResult.php | 2 +- .../src/OSS/Result/ExistResult.php | 7 +- .../src/OSS/Result/GetCorsResult.php | 3 +- .../src/OSS/Result/GetLifecycleResult.php | 8 +- .../src/OSS/Result/GetLocationResult.php | 4 +- .../src/OSS/Result/GetLoggingResult.php | 6 +- .../src/OSS/Result/GetRefererResult.php | 6 +- .../OSS/Result/GetStorageCapacityResult.php | 4 +- .../src/OSS/Result/GetWebsiteResult.php | 6 +- .../src/OSS/Result/HeaderResult.php | 2 +- .../Result/InitiateMultipartUploadResult.php | 2 +- .../OSS/Result/ListMultipartUploadResult.php | 2 +- .../src/OSS/Result/ListObjectsResult.php | 2 +- .../src/OSS/Result/ListPartsResult.php | 2 +- .../oss-sdk-php/src/OSS/Result/Result.php | 26 +- .../tests/OSS/Tests/CallbackTest.php | 37 +- .../oss-sdk-php/tests/OSS/Tests/Common.php | 18 +- .../tests/OSS/Tests/OssClientBucketTest.php | 4 +- .../tests/OSS/Tests/OssClientObjectTest.php | 80 +- .../tests/OSS/Tests/OssUtilTest.php | 26 + .../tests/OSS/Tests/SymlinkTest.php | 2 +- vendor/composer/installed.json | 211 ++--- vendor/guzzlehttp/guzzle/.php_cs | 4 +- vendor/guzzlehttp/guzzle/CHANGELOG.md | 18 + vendor/guzzlehttp/guzzle/README.md | 2 +- vendor/guzzlehttp/guzzle/composer.json | 5 +- vendor/guzzlehttp/guzzle/phpstan.neon.dist | 9 - vendor/guzzlehttp/guzzle/src/Client.php | 99 ++- .../guzzlehttp/guzzle/src/ClientInterface.php | 7 +- .../guzzle/src/Cookie/CookieJar.php | 6 +- .../guzzle/src/Cookie/CookieJarInterface.php | 6 +- .../guzzle/src/Exception/RequestException.php | 35 +- .../guzzle/src/Handler/CurlFactory.php | 15 +- .../guzzle/src/Handler/CurlMultiHandler.php | 18 +- .../guzzle/src/Handler/MockHandler.php | 7 +- .../guzzle/src/Handler/StreamHandler.php | 2 +- vendor/guzzlehttp/guzzle/src/HandlerStack.php | 6 +- .../guzzle/src/MessageFormatter.php | 5 + vendor/guzzlehttp/guzzle/src/Pool.php | 13 +- .../guzzle/src/PrepareBodyMiddleware.php | 5 + .../guzzle/src/RedirectMiddleware.php | 26 +- .../guzzlehttp/guzzle/src/RequestOptions.php | 8 + .../guzzlehttp/guzzle/src/RetryMiddleware.php | 17 +- .../guzzlehttp/guzzle/src/TransferStats.php | 12 +- vendor/guzzlehttp/guzzle/src/functions.php | 50 +- vendor/phpmailer/phpmailer/README.md | 4 +- vendor/phpmailer/phpmailer/VERSION | 2 +- vendor/phpmailer/phpmailer/composer.json | 6 +- .../phpmailer/language/phpmailer.lang-nl.php | 2 + vendor/phpmailer/phpmailer/src/OAuth.php | 2 +- vendor/phpmailer/phpmailer/src/PHPMailer.php | 763 ++++++++++-------- vendor/phpmailer/phpmailer/src/POP3.php | 4 +- vendor/phpmailer/phpmailer/src/SMTP.php | 87 +- 116 files changed, 1929 insertions(+), 1693 deletions(-) delete mode 100644 vendor/guzzlehttp/guzzle/phpstan.neon.dist diff --git a/composer.lock b/composer.lock index 98e18132..2f92de9f 100644 --- a/composer.lock +++ b/composer.lock @@ -8,23 +8,17 @@ "packages": [ { "name": "aliyuncs/oss-sdk-php", - "version": "v2.3.0", + "version": "v2.3.1", "source": { "type": "git", "url": "https://github.com/aliyun/aliyun-oss-php-sdk.git", - "reference": "e69f57916678458642ac9d2fd341ae78a56996c8" + "reference": "053d7ba9e798e4c09b9c5c1edab153d25ea9643a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/e69f57916678458642ac9d2fd341ae78a56996c8", - "reference": "e69f57916678458642ac9d2fd341ae78a56996c8", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://github-api-proxy.cnpkg.org/repos/aliyun/aliyun-oss-php-sdk/zipball/053d7ba9e798e4c09b9c5c1edab153d25ea9643a", + "reference": "053d7ba9e798e4c09b9c5c1edab153d25ea9643a", + "shasum": "" }, "require": { "php": ">=5.3" @@ -39,7 +33,7 @@ "OSS\\": "src/OSS" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "https://repo.packagist.org/downloads/", "license": [ "MIT" ], @@ -51,7 +45,7 @@ ], "description": "Aliyun OSS SDK for PHP", "homepage": "http://www.aliyun.com/product/oss/", - "time": "2018-01-08T06:59:35+00:00" + "time": "2019-11-15T11:05:42+00:00" }, { "name": "guzzle/guzzle", @@ -65,13 +59,7 @@ "type": "zip", "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9", "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "ext-curl": "*", @@ -157,23 +145,17 @@ }, { "name": "guzzlehttp/guzzle", - "version": "6.4.1", + "version": "6.5.2", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "0895c932405407fd3a7368b6910c09a24d26db11" + "reference": "43ece0e75098b7ecd8d13918293029e555a50f82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/0895c932405407fd3a7368b6910c09a24d26db11", - "reference": "0895c932405407fd3a7368b6910c09a24d26db11", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://github-api-proxy.cnpkg.org/repos/guzzle/guzzle/zipball/43ece0e75098b7ecd8d13918293029e555a50f82", + "reference": "43ece0e75098b7ecd8d13918293029e555a50f82", + "shasum": "" }, "require": { "ext-json": "*", @@ -187,12 +169,13 @@ "psr/log": "^1.1" }, "suggest": { + "ext-intl": "Required for Internationalized Domain Name (IDN) support", "psr/log": "Required for using the Log middleware" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "6.3-dev" + "dev-master": "6.5-dev" } }, "autoload": { @@ -203,7 +186,7 @@ "src/functions_include.php" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "https://repo.packagist.org/downloads/", "license": [ "MIT" ], @@ -225,7 +208,7 @@ "rest", "web service" ], - "time": "2019-10-23T15:58:00+00:00" + "time": "2019-12-23T11:57:10+00:00" }, { "name": "guzzlehttp/promises", @@ -239,13 +222,7 @@ "type": "zip", "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "php": ">=5.5.0" @@ -296,13 +273,7 @@ "type": "zip", "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", "reference": "239400de7a173fe9901b9ac7c06497751f00727a", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "php": ">=5.4.0", @@ -373,13 +344,7 @@ "type": "zip", "url": "https://api.github.com/repos/Nicolab/php-ftp-client/zipball/8c66e1104da1b638f5d7a9e24624a5525b459a0c", "reference": "8c66e1104da1b638f5d7a9e24624a5525b459a0c", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "ext-ftp": "*", @@ -418,23 +383,17 @@ }, { "name": "phpmailer/phpmailer", - "version": "v6.1.1", + "version": "v6.1.4", "source": { "type": "git", "url": "https://github.com/PHPMailer/PHPMailer.git", - "reference": "26bd96350b0b2fcbf0ef4e6f0f9cf3528302a9d8" + "reference": "c5e61d0729507049cec9673aa1a679f9adefd683" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/26bd96350b0b2fcbf0ef4e6f0f9cf3528302a9d8", - "reference": "26bd96350b0b2fcbf0ef4e6f0f9cf3528302a9d8", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://github-api-proxy.cnpkg.org/repos/PHPMailer/PHPMailer/zipball/c5e61d0729507049cec9673aa1a679f9adefd683", + "reference": "c5e61d0729507049cec9673aa1a679f9adefd683", + "shasum": "" }, "require": { "ext-ctype": "*", @@ -442,13 +401,9 @@ "php": ">=5.5.0" }, "require-dev": { - "doctrine/annotations": "1.2.*", + "doctrine/annotations": "^1.2", "friendsofphp/php-cs-fixer": "^2.2", - "phpdocumentor/phpdocumentor": "2.*", - "phpunit/phpunit": "^4.8 || ^5.7", - "zendframework/zend-eventmanager": "3.0.*", - "zendframework/zend-i18n": "2.7.3", - "zendframework/zend-serializer": "2.7.*" + "phpunit/phpunit": "^4.8 || ^5.7" }, "suggest": { "ext-mbstring": "Needed to send email in multibyte encoding charset", @@ -464,7 +419,7 @@ "PHPMailer\\PHPMailer\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "https://repo.packagist.org/downloads/", "license": [ "LGPL-2.1-only" ], @@ -486,7 +441,7 @@ } ], "description": "PHPMailer is a full-featured email creation and transfer class for PHP", - "time": "2019-09-27T21:33:43+00:00" + "time": "2019-12-10T11:17:38+00:00" }, { "name": "psr/http-message", @@ -500,13 +455,7 @@ "type": "zip", "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "php": ">=5.3.0" @@ -556,13 +505,7 @@ "type": "zip", "url": "https://api.github.com/repos/tencentyun/cos-php-sdk-v5/zipball/1b32aa422f6dffe4ea411e5095e4b0da9135551b", "reference": "1b32aa422f6dffe4ea411e5095e4b0da9135551b", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "guzzle/guzzle": "~3.7", @@ -608,13 +551,7 @@ "type": "zip", "url": "https://api.github.com/repos/qiniu/php-sdk/zipball/d89987163f560ebf9dfa5bb25de9bd9b1a3b2bd8", "reference": "d89987163f560ebf9dfa5bb25de9bd9b1a3b2bd8", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "php": ">=5.3.3" @@ -665,13 +602,7 @@ "type": "zip", "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", "reference": "120b605dfeb996808c31b6477290a714d356e822", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "php": ">=5.6" @@ -701,7 +632,7 @@ }, { "name": "symfony/event-dispatcher", - "version": "v2.8.50", + "version": "v2.8.52", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -709,15 +640,9 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a77e974a5fecb4398833b0709210e3d5e334ffb0", + "url": "https://github-api-proxy.cnpkg.org/repos/symfony/event-dispatcher/zipball/a77e974a5fecb4398833b0709210e3d5e334ffb0", "reference": "a77e974a5fecb4398833b0709210e3d5e334ffb0", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "php": ">=5.3.9" @@ -747,7 +672,7 @@ "/Tests/" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "https://repo.packagist.org/downloads/", "license": [ "MIT" ], @@ -767,23 +692,17 @@ }, { "name": "topthink/framework", - "version": "v5.1.38.1", + "version": "v5.1.39", "source": { "type": "git", "url": "https://github.com/top-think/framework.git", - "reference": "12d15c29d5d6a972fc8bfc8db005d64d4786028c" + "reference": "5762858f3d58faafb3a39427f8788884b2927007" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/framework/zipball/12d15c29d5d6a972fc8bfc8db005d64d4786028c", - "reference": "12d15c29d5d6a972fc8bfc8db005d64d4786028c", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://github-api-proxy.cnpkg.org/repos/top-think/framework/zipball/5762858f3d58faafb3a39427f8788884b2927007", + "reference": "5762858f3d58faafb3a39427f8788884b2927007", + "shasum": "" }, "require": { "php": ">=5.6.0", @@ -799,7 +718,7 @@ "squizlabs/php_codesniffer": "2.*" }, "type": "think-framework", - "notification-url": "https://packagist.org/downloads/", + "notification-url": "https://repo.packagist.org/downloads/", "license": [ "Apache-2.0" ], @@ -820,7 +739,7 @@ "orm", "thinkphp" ], - "time": "2019-08-12T00:58:30+00:00" + "time": "2019-11-17T23:22:02+00:00" }, { "name": "topthink/think-captcha", @@ -834,13 +753,7 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-captcha/zipball/54c8a51552f99ff9ea89ea9c272383a8f738ceee", "reference": "54c8a51552f99ff9ea89ea9c272383a8f738ceee", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "topthink/framework": "5.1.*" @@ -879,13 +792,7 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-image/zipball/8586cf47f117481c6d415b20f7dedf62e79d5512", "reference": "8586cf47f117481c6d415b20f7dedf62e79d5512", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "ext-gd": "*" @@ -925,13 +832,7 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-installer/zipball/f5400a12c60e513911aef41fe443fa6920952675", "reference": "f5400a12c60e513911aef41fe443fa6920952675", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "composer-plugin-api": "^1.0" @@ -972,13 +873,7 @@ "type": "zip", "url": "https://api.github.com/repos/upyun/php-sdk/zipball/b4819fd941e3f19a886f8b3c5f8bffcb8279185f", "reference": "b4819fd941e3f19a886f8b3c5f8bffcb8279185f", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "ext-curl": "*", diff --git a/thinkphp/composer.json b/thinkphp/composer.json index cc4fca91..33477b1d 100644 --- a/thinkphp/composer.json +++ b/thinkphp/composer.json @@ -26,7 +26,7 @@ "require-dev": { "phpunit/phpunit": "^5.0|^6.0", "johnkary/phpunit-speedtrap": "^1.0", - "mikey179/vfsStream": "~1.6", + "mikey179/vfsstream": "~1.6", "phploc/phploc": "2.*", "sebastian/phpcpd": "2.*", "squizlabs/php_codesniffer": "2.*", diff --git a/thinkphp/library/think/App.php b/thinkphp/library/think/App.php index 7766555e..5cd55a8b 100644 --- a/thinkphp/library/think/App.php +++ b/thinkphp/library/think/App.php @@ -20,7 +20,7 @@ use think\route\Dispatch; */ class App extends Container { - const VERSION = '5.1.38 LTS'; + const VERSION = '5.1.39 LTS'; /** * 当前模块路径 diff --git a/thinkphp/library/think/Model.php b/thinkphp/library/think/Model.php index 65e543d9..93be3dc0 100644 --- a/thinkphp/library/think/Model.php +++ b/thinkphp/library/think/Model.php @@ -780,12 +780,19 @@ abstract class Model implements \JsonSerializable, \ArrayAccess // 删除条件 $pk = $this->getPk(); + $where = []; if (is_string($pk) && isset($this->data[$pk])) { $where[] = [$pk, '=', $this->data[$pk]]; - } elseif (!empty($this->updateWhere)) { - $where = $this->updateWhere; - } else { - $where = null; + } elseif (is_array($pk)) { + foreach ($pk as $field) { + if (isset($this->data[$field])) { + $where[] = [$field, '=', $this->data[$field]]; + } + } + } + + if (empty($where)) { + $where = empty($this->updateWhere) ? null : $this->updateWhere; } return $where; diff --git a/thinkphp/library/think/Request.php b/thinkphp/library/think/Request.php index e0488e77..92a401d7 100644 --- a/thinkphp/library/think/Request.php +++ b/thinkphp/library/think/Request.php @@ -1044,7 +1044,7 @@ class Request protected function getInputData($content) { - if ($this->isJson()) { + if (false !== strpos($this->contentType(), 'json')) { return (array) json_decode($content, true); } elseif (strpos($content, '=')) { parse_str($content, $data); @@ -1643,10 +1643,7 @@ class Request */ public function isJson() { - $contentType = $this->contentType(); - $acceptType = $this->type(); - - return false !== strpos($contentType, 'json') || false !== strpos($acceptType, 'json'); + return false !== strpos($this->type(), 'json'); } /** diff --git a/thinkphp/library/think/Url.php b/thinkphp/library/think/Url.php index cccabc22..acd510aa 100644 --- a/thinkphp/library/think/Url.php +++ b/thinkphp/library/think/Url.php @@ -349,6 +349,7 @@ class Url // 匹配路由地址 public function getRuleUrl($rule, &$vars = [], $allowDomain = '') { + $port = $this->app['request']->port(); foreach ($rule as $item) { list($url, $pattern, $domain, $suffix, $method) = $item; @@ -356,8 +357,8 @@ class Url continue; } - if (!in_array($this->app['request']->port(), [80, 443])) { - $domain .= ':' . $this->app['request']->port(); + if ($port && !in_array($port, [80, 443])) { + $domain .= ':' . $port; } if (empty($pattern)) { @@ -365,11 +366,12 @@ class Url } $type = $this->config['url_common_param']; + $keys = []; foreach ($pattern as $key => $val) { if (isset($vars[$key])) { - $url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key, '<' . $key . '>'], $type ? $vars[$key] : urlencode($vars[$key]), $url); - unset($vars[$key]); + $url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key, '<' . $key . '>'], $type ? $vars[$key] : urlencode($vars[$key]), $url); + $keys[] = $key; $url = str_replace(['/?', '-?'], ['/', '-'], $url); $result = [rtrim($url, '?/-'), $domain, $suffix]; } elseif (2 == $val) { @@ -377,10 +379,14 @@ class Url $url = str_replace(['/?', '-?'], ['/', '-'], $url); $result = [rtrim($url, '?/-'), $domain, $suffix]; } else { + $result = null; + $keys = []; break; } } + $vars = array_diff_key($vars, array_flip($keys)); + if (isset($result)) { return $result; } diff --git a/thinkphp/library/think/Validate.php b/thinkphp/library/think/Validate.php index d4f6d236..f58d7a88 100644 --- a/thinkphp/library/think/Validate.php +++ b/thinkphp/library/think/Validate.php @@ -570,7 +570,7 @@ class Validate $result = str_replace(':attribute', $title, $result); if (strpos($result, ':rule') && is_scalar($rule)) { - $msg = str_replace(':rule', (string) $rule, $result); + $result = str_replace(':rule', (string) $rule, $result); } } @@ -934,8 +934,8 @@ class Validate if (isset($rule[2])) { $imageType = strtolower($rule[2]); - if ('jpeg' == $imageType) { - $imageType = 'jpg'; + if ('jpg' == $imageType) { + $imageType = 'jpeg'; } if (image_type_to_extension($type, false) != $imageType) { diff --git a/thinkphp/library/think/cache/driver/File.php b/thinkphp/library/think/cache/driver/File.php index 93d321f2..60be08db 100644 --- a/thinkphp/library/think/cache/driver/File.php +++ b/thinkphp/library/think/cache/driver/File.php @@ -278,11 +278,13 @@ class File extends Driver if (is_dir($path)) { $matches = glob($path . DIRECTORY_SEPARATOR . '*.php'); if (is_array($matches)) { - array_map('unlink', $matches); + array_map(function ($v) { + $this->unlink($v); + }, $matches); } rmdir($path); } else { - unlink($path); + $this->unlink($path); } } diff --git a/thinkphp/library/think/cache/driver/Memcached.php b/thinkphp/library/think/cache/driver/Memcached.php index 6af60d19..4533e78a 100644 --- a/thinkphp/library/think/cache/driver/Memcached.php +++ b/thinkphp/library/think/cache/driver/Memcached.php @@ -67,7 +67,7 @@ class Memcached extends Driver } $this->handler->addServers($servers); - + $this->handler->setOption(\Memcached::OPT_COMPRESSION, false); if ('' != $this->options['username']) { $this->handler->setOption(\Memcached::OPT_BINARY_PROTOCOL, true); $this->handler->setSaslAuthData($this->options['username'], $this->options['password']); @@ -232,7 +232,7 @@ class Memcached extends Driver $this->handler->delete($tagName); } - if (!$this->handler->has($tagName)) { + if (!$this->has($tagName)) { $this->handler->set($tagName, ''); } @@ -255,7 +255,7 @@ class Memcached extends Driver if ($this->tag) { $tagName = $this->getTagKey($this->tag); - if ($this->handler->has($tagName)) { + if ($this->has($tagName)) { $this->handler->append($tagName, ',' . $name); } else { $this->handler->set($tagName, $name); diff --git a/thinkphp/library/think/db/Builder.php b/thinkphp/library/think/db/Builder.php index 09df1a07..a0faada8 100644 --- a/thinkphp/library/think/db/Builder.php +++ b/thinkphp/library/think/db/Builder.php @@ -313,9 +313,10 @@ abstract class Builder // 使用闭包查询 $newQuery = $query->newQuery()->setConnection($this->connection); $value($newQuery); - $whereClause = $this->buildWhere($query, $newQuery->getOptions('where')); + $whereClause = $this->buildWhere($newQuery, $newQuery->getOptions('where')); if (!empty($whereClause)) { + $query->bind($newQuery->getBind(false)); $str[] = ' ' . $logic . ' ( ' . $whereClause . ' )'; } } elseif (is_array($field)) { diff --git a/thinkphp/library/think/db/Query.php b/thinkphp/library/think/db/Query.php index 4d632909..0c3df899 100644 --- a/thinkphp/library/think/db/Query.php +++ b/thinkphp/library/think/db/Query.php @@ -133,7 +133,27 @@ class Query */ public function newQuery() { - return new static($this->connection); + $query = new static($this->connection); + + if ($this->model) { + $query->model($this->model); + } + + if (isset($this->options['table'])) { + $query->table($this->options['table']); + } else { + $query->name($this->name); + } + + if (isset($this->options['json'])) { + $query->json($this->options['json'], $this->options['json_assoc']); + } + + if (isset($this->options['field_type'])) { + $query->setJsonFieldType($this->options['field_type']); + } + + return $query; } /** @@ -562,12 +582,12 @@ class Query default: if (function_exists($type)) { // 支持指定函数哈希 - $seq = (ord(substr($type($value), 0, 1)) % $rule['num']) + 1; - } else { - // 按照字段的首字母的值分表 - $seq = (ord($value{0}) % $rule['num']) + 1; + $value = $type($value); } + + $seq = (ord(substr($value, 0, 1)) % $rule['num']) + 1; } + return $this->getTable() . '_' . $seq; } // 当设置的分表字段不在查询条件或者数据中 @@ -2470,7 +2490,7 @@ class Query if (is_array($value)) { $this->bind = array_merge($this->bind, $value); } else { - $name = $name ?: 'ThinkBind_' . (count($this->bind) + 1) . '_'; + $name = $name ?: 'ThinkBind_' . (count($this->bind) + 1) . '_' . mt_rand() . '_'; $this->bind[$name] = [$value, $type]; return $name; diff --git a/thinkphp/library/think/db/builder/Mysql.php b/thinkphp/library/think/db/builder/Mysql.php index c715aa34..af364dff 100644 --- a/thinkphp/library/think/db/builder/Mysql.php +++ b/thinkphp/library/think/db/builder/Mysql.php @@ -62,7 +62,7 @@ class Mysql extends Builder $bind = $this->connection->getFieldsBind($options['table']); foreach ($dataSet as $k => $data) { - $data = $this->parseData($query, $data, $allowFields, $bind, '_' . $k); + $data = $this->parseData($query, $data, $allowFields, $bind); $values[] = '( ' . implode(',', array_values($data)) . ' )'; diff --git a/thinkphp/library/think/model/relation/BelongsTo.php b/thinkphp/library/think/model/relation/BelongsTo.php index 1dea3b3b..056c7d76 100644 --- a/thinkphp/library/think/model/relation/BelongsTo.php +++ b/thinkphp/library/think/model/relation/BelongsTo.php @@ -11,6 +11,7 @@ namespace think\model\relation; +use Closure; use think\Loader; use think\Model; @@ -49,7 +50,7 @@ class BelongsTo extends OneToOne */ public function getRelation($subRelation = '', $closure = null) { - if ($closure) { + if ($closure instanceof Closure) { $closure($this->query); } @@ -79,7 +80,7 @@ class BelongsTo extends OneToOne */ public function getRelationCountQuery($closure, $aggregate = 'count', $field = '*', &$aggregateAlias = '') { - if ($closure) { + if ($closure instanceof Closure) { $return = $closure($this->query); if ($return && is_string($return)) { @@ -111,7 +112,7 @@ class BelongsTo extends OneToOne return 0; } - if ($closure) { + if ($closure instanceof Closure) { $return = $closure($this->query); if ($return && is_string($return)) { diff --git a/thinkphp/library/think/model/relation/BelongsToMany.php b/thinkphp/library/think/model/relation/BelongsToMany.php index 54df68b0..2d64f683 100644 --- a/thinkphp/library/think/model/relation/BelongsToMany.php +++ b/thinkphp/library/think/model/relation/BelongsToMany.php @@ -11,6 +11,7 @@ namespace think\model\relation; +use Closure; use think\Collection; use think\db\Query; use think\Exception; @@ -166,7 +167,7 @@ class BelongsToMany extends Relation */ public function getRelation($subRelation = '', $closure = null) { - if ($closure) { + if ($closure instanceof Closure) { $closure($this->query); } @@ -377,7 +378,7 @@ class BelongsToMany extends Relation $pk = $result->$pk; - if ($closure) { + if ($closure instanceof Closure) { $return = $closure($this->query); if ($return && is_string($return)) { @@ -401,7 +402,7 @@ class BelongsToMany extends Relation */ public function getRelationCountQuery($closure, $aggregate = 'count', $field = '*', &$aggregateAlias = '') { - if ($closure) { + if ($closure instanceof Closure) { $return = $closure($this->query); if ($return && is_string($return)) { @@ -428,7 +429,7 @@ class BelongsToMany extends Relation protected function eagerlyManyToMany($where, $relation, $subRelation = '', $closure = null) { // 预载入关联查询 支持嵌套预载入 - if ($closure) { + if ($closure instanceof Closure) { $closure($this->query); } diff --git a/thinkphp/library/think/model/relation/HasMany.php b/thinkphp/library/think/model/relation/HasMany.php index 728ca181..e4df5c4b 100644 --- a/thinkphp/library/think/model/relation/HasMany.php +++ b/thinkphp/library/think/model/relation/HasMany.php @@ -11,6 +11,7 @@ namespace think\model\relation; +use Closure; use think\db\Query; use think\Loader; use think\Model; @@ -48,7 +49,7 @@ class HasMany extends Relation */ public function getRelation($subRelation = '', $closure = null) { - if ($closure) { + if ($closure instanceof Closure) { $closure($this->query); } @@ -163,7 +164,7 @@ class HasMany extends Relation return 0; } - if ($closure) { + if ($closure instanceof Closure) { $return = $closure($this->query); if ($return && is_string($return)) { $name = $return; @@ -186,7 +187,7 @@ class HasMany extends Relation */ public function getRelationCountQuery($closure, $aggregate = 'count', $field = '*', &$aggregateAlias = '') { - if ($closure) { + if ($closure instanceof Closure) { $return = $closure($this->query); if ($return && is_string($return)) { @@ -216,7 +217,7 @@ class HasMany extends Relation $this->query->removeWhereField($this->foreignKey); // 预载入关联查询 支持嵌套预载入 - if ($closure) { + if ($closure instanceof Closure) { $closure($this->query); } diff --git a/thinkphp/library/think/model/relation/HasManyThrough.php b/thinkphp/library/think/model/relation/HasManyThrough.php index c048eb91..6e39f2ad 100644 --- a/thinkphp/library/think/model/relation/HasManyThrough.php +++ b/thinkphp/library/think/model/relation/HasManyThrough.php @@ -11,6 +11,7 @@ namespace think\model\relation; +use Closure; use think\db\Query; use think\Loader; use think\Model; @@ -60,7 +61,7 @@ class HasManyThrough extends Relation */ public function getRelation($subRelation = '', $closure = null) { - if ($closure) { + if ($closure instanceof Closure) { $closure($this->query); } @@ -143,11 +144,11 @@ class HasManyThrough extends Relation * @access protected * @param array $resultSet 数据集 * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 + * @param mixed $subRelation 子关联名 * @param Closure $closure 闭包 * @return void */ - public function eagerlyResultSet(array &$resultSet, $relation, array $subRelation = [], $closure = null) + public function eagerlyResultSet(array &$resultSet, $relation, $subRelation = '', $closure = null) { $localKey = $this->localKey; $foreignKey = $this->foreignKey; @@ -192,11 +193,11 @@ class HasManyThrough extends Relation * @access protected * @param Model $result 数据对象 * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 + * @param mixed $subRelation 子关联名 * @param Closure $closure 闭包 * @return void */ - public function eagerlyResult($result, $relation, array $subRelation = [], $closure = null) + public function eagerlyResult($result, $relation, $subRelation = '', $closure = null) { $localKey = $this->localKey; $foreignKey = $this->foreignKey; @@ -226,17 +227,17 @@ class HasManyThrough extends Relation * @param array $where 关联预查询条件 * @param string $key 关联键名 * @param string $relation 关联名 - * @param array $subRelation 子关联 + * @param mixed $subRelation 子关联 * @param Closure $closure * @return array */ - protected function eagerlyWhere(array $where, $key, $relation, array $subRelation = [], $closure = null) + protected function eagerlyWhere(array $where, $key, $relation, $subRelation = '', $closure = null) { // 预载入关联查询 支持嵌套预载入 $throughList = $this->through->where($where)->select(); $keys = $throughList->column($this->throughPk, $this->throughPk); - if ($closure) { + if ($closure instanceof Closure) { $closure($this->query); } @@ -271,7 +272,7 @@ class HasManyThrough extends Relation return 0; } - if ($closure) { + if ($closure instanceof Closure) { $return = $closure($this->query); if ($return && is_string($return)) { $name = $return; @@ -307,7 +308,7 @@ class HasManyThrough extends Relation */ public function getRelationCountQuery($closure = null, $aggregate = 'count', $field = '*', &$name = null) { - if ($closure) { + if ($closure instanceof Closure) { $return = $closure($this->query); if ($return && is_string($return)) { $name = $return; diff --git a/thinkphp/library/think/model/relation/HasOne.php b/thinkphp/library/think/model/relation/HasOne.php index 7d582a14..e036bba4 100644 --- a/thinkphp/library/think/model/relation/HasOne.php +++ b/thinkphp/library/think/model/relation/HasOne.php @@ -11,6 +11,7 @@ namespace think\model\relation; +use Closure; use think\db\Query; use think\Loader; use think\Model; @@ -50,7 +51,7 @@ class HasOne extends OneToOne { $localKey = $this->localKey; - if ($closure) { + if ($closure instanceof Closure) { $closure($this->query); } @@ -79,7 +80,7 @@ class HasOne extends OneToOne */ public function getRelationCountQuery($closure, $aggregate = 'count', $field = '*', &$aggregateAlias = '') { - if ($closure) { + if ($closure instanceof Closure) { $return = $closure($this->query); if ($return && is_string($return)) { @@ -111,7 +112,7 @@ class HasOne extends OneToOne return 0; } - if ($closure) { + if ($closure instanceof Closure) { $return = $closure($this->query); if ($return && is_string($return)) { $name = $return; diff --git a/thinkphp/library/think/model/relation/MorphMany.php b/thinkphp/library/think/model/relation/MorphMany.php index a1f54889..d2af66e9 100644 --- a/thinkphp/library/think/model/relation/MorphMany.php +++ b/thinkphp/library/think/model/relation/MorphMany.php @@ -11,6 +11,7 @@ namespace think\model\relation; +use Closure; use think\db\Query; use think\Exception; use think\Loader; @@ -53,7 +54,7 @@ class MorphMany extends Relation */ public function getRelation($subRelation = '', $closure = null) { - if ($closure) { + if ($closure instanceof Closure) { $closure($this->query); } @@ -197,7 +198,7 @@ class MorphMany extends Relation return 0; } - if ($closure) { + if ($closure instanceof Closure) { $return = $closure($this->query); if ($return && is_string($return)) { @@ -224,7 +225,7 @@ class MorphMany extends Relation */ public function getRelationCountQuery($closure, $aggregate = 'count', $field = '*', &$aggregateAlias = '') { - if ($closure) { + if ($closure instanceof Closure) { $return = $closure($this->query); if ($return && is_string($return)) { @@ -253,7 +254,7 @@ class MorphMany extends Relation // 预载入关联查询 支持嵌套预载入 $this->query->removeOption('where'); - if ($closure) { + if ($closure instanceof Closure) { $closure($this->query); } diff --git a/thinkphp/library/think/model/relation/MorphOne.php b/thinkphp/library/think/model/relation/MorphOne.php index 775b2dfd..6bc205c5 100644 --- a/thinkphp/library/think/model/relation/MorphOne.php +++ b/thinkphp/library/think/model/relation/MorphOne.php @@ -11,6 +11,7 @@ namespace think\model\relation; +use Closure; use think\db\Query; use think\Exception; use think\Loader; @@ -53,7 +54,7 @@ class MorphOne extends Relation */ public function getRelation($subRelation = '', $closure = null) { - if ($closure) { + if ($closure instanceof Closure) { $closure($this->query); } @@ -186,7 +187,7 @@ class MorphOne extends Relation protected function eagerlyMorphToOne($where, $relation, $subRelation = '', $closure = null) { // 预载入关联查询 支持嵌套预载入 - if ($closure) { + if ($closure instanceof Closure) { $closure($this->query); } diff --git a/thinkphp/library/think/model/relation/MorphTo.php b/thinkphp/library/think/model/relation/MorphTo.php index 6da6a025..17771ce8 100644 --- a/thinkphp/library/think/model/relation/MorphTo.php +++ b/thinkphp/library/think/model/relation/MorphTo.php @@ -11,6 +11,7 @@ namespace think\model\relation; +use Closure; use think\Exception; use think\Loader; use think\Model; diff --git a/thinkphp/library/think/model/relation/OneToOne.php b/thinkphp/library/think/model/relation/OneToOne.php index 59fce77f..a0333c86 100644 --- a/thinkphp/library/think/model/relation/OneToOne.php +++ b/thinkphp/library/think/model/relation/OneToOne.php @@ -11,6 +11,7 @@ namespace think\model\relation; +use Closure; use think\db\Query; use think\Exception; use think\Loader; @@ -87,7 +88,7 @@ abstract class OneToOne extends Relation $joinOn = $name . '.' . $this->localKey . '=' . $joinAlias . '.' . $this->foreignKey; } - if ($closure) { + if ($closure instanceof Closure) { // 执行闭包查询 $closure($query); // 使用withField指定获取关联的字段,如 @@ -311,7 +312,7 @@ abstract class OneToOne extends Relation protected function eagerlyWhere($where, $key, $relation, $subRelation = '', $closure = null) { // 预载入关联查询 支持嵌套预载入 - if ($closure) { + if ($closure instanceof Closure) { $closure($this->query); if ($field = $this->query->getOptions('with_field')) { diff --git a/thinkphp/library/think/route/dispatch/Url.php b/thinkphp/library/think/route/dispatch/Url.php index 00dc8cca..acc524e3 100644 --- a/thinkphp/library/think/route/dispatch/Url.php +++ b/thinkphp/library/think/route/dispatch/Url.php @@ -60,7 +60,7 @@ class Url extends Dispatch $controller = !empty($path) ? array_shift($path) : null; } - if ($controller && !preg_match('/^[A-Za-z][\w|\.]*$/', $controller)) { + if ($controller && !preg_match('/^[A-Za-z0-9][\w|\.]*$/', $controller)) { throw new HttpException(404, 'controller not exists:' . $controller); } diff --git a/thinkphp/library/think/session/driver/Redis.php b/thinkphp/library/think/session/driver/Redis.php index 646700bd..5a0e7bc7 100644 --- a/thinkphp/library/think/session/driver/Redis.php +++ b/thinkphp/library/think/session/driver/Redis.php @@ -124,7 +124,7 @@ class Redis implements SessionHandlerInterface */ public function destroy($sessID) { - return $this->handler->delete($this->config['session_name'] . $sessID) > 0; + return $this->handler->del($this->config['session_name'] . $sessID) > 0; } /** diff --git a/vendor/aliyuncs/oss-sdk-php/CHANGELOG.md b/vendor/aliyuncs/oss-sdk-php/CHANGELOG.md index 042a72a0..d349d907 100644 --- a/vendor/aliyuncs/oss-sdk-php/CHANGELOG.md +++ b/vendor/aliyuncs/oss-sdk-php/CHANGELOG.md @@ -1,39 +1,44 @@ # ChangeLog - Aliyun OSS SDK for PHP +## v2.3.1 / 2019-011-15 + +* translate chinese comments into english +* Added: endpoint validity check + ## v2.3.0 / 2018-01-05 -* 修复:putObject支持创建空文件 -* 修复:createBucket支持IA/Archive -* 增加:支持restoreObject -* 增加:支持Symlink功能 -* 增加:支持getBucketLocation -* 增加:支持getBucketMeta -* 增加:支持代理服务器Proxy +* Fixed: putObject support creating empty files +* Fixed: createBucket support IA/Archive +* Added: support restoreObject +* Added: support the Symlink feature +* Added: support getBucketLocation +* Added: support getBucketMeta +* Added: support proxy server Proxy ## v2.2.4 / 2017-04-25 -* fix getObject to local file bug +* Fixed getObject to local file bug ## v2.2.3 / 2017-04-14 -* fix md5 check +* Fixed md5 check ## v2.2.2 / 2017-01-18 -* 解决在php7上运行连接数和内存bug +* Resolve to run the connection number and memory bug on php7 ## v2.2.1 / 2016-12-01 -* 禁止http curl自动填充Accept-Encoding +* No HTTP curl is allowed to automatically populate accept-encoding ## v2.2.0 / 2016-11-22 -* 修复PutObject/CompleteMultipartUpload的返回值问题(#26) +* Fixed PutObject/CompleteMultipartUpload return values(#26) ## v2.1.0 / 2016-11-12 -* 增加[RTMP](https://help.aliyun.com/document_detail/44297.html)接口 -* 增加支持[图片服务](https://help.aliyun.com/document_detail/44686.html) +* Added[RTMP](https://help.aliyun.com/document_detail/44297.html)interface +* Add support[image service](https://help.aliyun.com/document_detail/44686.html) ## v2.0.7 / 2016-06-17 @@ -46,47 +51,47 @@ ## v2.0.5 -* 增加Add/Delete/Get BucketCname接口 +* Added Add/Delete/Get BucketCname interface ## v2.0.4 -* 增加Put/Get Object Acl接口 +* Added Put/Get Object Acl interface ## v2.0.3 -* 修复Util中的常量定义在低于5.6的PHP版本中报错的问题 +* Fixing the constants in Util is defined in a PHP version that is less than 5.6. ## v2.0.2 -* 修复multipart上传时无法指定Content-Type的问题 +* The problem of content-type cannot be specified when restoring multipart uploads ## v2.0.1 -* 增加对ListObjects/ListMultipartUploads时特殊字符的处理 -* 提供接口获取OssException中的详细信息 +* Increase the ListObjects/ListMultipartUploads special characters +* Provides the interface to get the details of the OssException ## 2015.11.25 -* **大版本升级,不再兼容以前接口,新版本对易用性做了很大的改进,建议用户迁移到新版本。** +* **Large version upgrade, no longer compatible with previous interface, new version has made great improvements to ease of use, suggesting that users migrate to a new version.** -## 修改内容 +## Modify the content -* 不再支持PHP 5.2版本 +* PHP 5.2 is no longer supported -### 新增内容 +### Add the cotent -* 引入命名空间 -* 接口命名修正,采用驼峰式命名 -* 接口入参修改,把常用参数从Options参数中提出来 -* 接口返回结果修改,对返回结果进行处理,用户可以直接得到容易处理的数据结构  -* OssClient的构造函数变更 -* 支持CNAME和IP格式的Endpoint地址 -* 重新整理sample文件组织结构,使用function组织功能点 -* 增加设置连接超时,请求超时的接口 -* 去掉Object Group相关的已经过时的接口 -* OssException中的message改为英文 +* Introduce namespace +* Interface naming and modification, using hump naming +* The interface is modified, and the common parameters are extracted from the Options parameter. +* The interface returns the result modification, processing the return result, and the user can directly get the data structure easily processed  +* OssClient's constructor changes +* The Endpoint address that support CNAME and IP formats +* Rearrange the sample file organization structure and use function to organize the function points +* Add an interface that sets the connection timeout and requests timeout +* Remove the outdated interface associated with the Object Group +* The message in the OssException is changed to English -### 问题修复 +### Repair problem -* object名称校验不完备 +* The object name is not complete diff --git a/vendor/aliyuncs/oss-sdk-php/samples/Bucket.php b/vendor/aliyuncs/oss-sdk-php/samples/Bucket.php index bd16e655..7dc50b89 100644 --- a/vendor/aliyuncs/oss-sdk-php/samples/Bucket.php +++ b/vendor/aliyuncs/oss-sdk-php/samples/Bucket.php @@ -8,28 +8,28 @@ $ossClient = Common::getOssClient(); if (is_null($ossClient)) exit(1); $bucket = Common::getBucketName(); -//******************************* 简单使用 **************************************************************** +//******************************* Simple Usage**************************************************************** -//创建bucket +// Create a bucket $ossClient->createBucket($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); Common::println("bucket $bucket created"); -// 判断Bucket是否存在 +// Check whether a bucket exists $doesExist = $ossClient->doesBucketExist($bucket); Common::println("bucket $bucket exist? " . ($doesExist ? "yes" : "no")); -// 获取Bucket列表 +// Get the bucket list $bucketListInfo = $ossClient->listBuckets(); -// 设置bucket的ACL +// Set bucket ACL $ossClient->putBucketAcl($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); Common::println("bucket $bucket acl put"); -// 获取bucket的ACL +// Get bucket ACL $acl = $ossClient->getBucketAcl($bucket); Common::println("bucket $bucket acl get: " . $acl); -//******************************* 完整用法参考下面函数 **************************************************** +//******************************* For complete usage, see the following functions **************************************************** createBucket($ossClient, $bucket); doesBucketExist($ossClient, $bucket); @@ -39,13 +39,13 @@ getBucketAcl($ossClient, $bucket); listBuckets($ossClient); /** - * 创建一个存储空间 - * acl 指的是bucket的访问控制权限,有三种,私有读写,公共读私有写,公共读写。 - * 私有读写就是只有bucket的拥有者或授权用户才有权限操作 - * 三种权限分别对应 (OssClient::OSS_ACL_TYPE_PRIVATE,OssClient::OSS_ACL_TYPE_PUBLIC_READ, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE) + * Create a new bucket + * acl indicates the access permission of a bucket, including: private, public-read-only/private-read-write, and public read-write. + * Private indicates that only the bucket owner or authorized users can access the data.. + * The three permissions are separately defined by (OssClient::OSS_ACL_TYPE_PRIVATE,OssClient::OSS_ACL_TYPE_PUBLIC_READ, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE) * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 要创建的存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create * @return null */ function createBucket($ossClient, $bucket) @@ -61,10 +61,10 @@ function createBucket($ossClient, $bucket) } /** - * 判断Bucket是否存在 + * Check whether a bucket exists. * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name */ function doesBucketExist($ossClient, $bucket) { @@ -83,10 +83,11 @@ function doesBucketExist($ossClient, $bucket) } /** - * 删除bucket,如果bucket不为空则bucket无法删除成功, 不为空表示bucket既没有object,也没有未完成的multipart上传时的parts + * Delete a bucket. If the bucket is not empty, the deletion fails. + * A bucket which is not empty indicates that it does not contain any objects or parts that are not completely uploaded during multipart upload * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 待删除的存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to delete * @return null */ function deleteBucket($ossClient, $bucket) @@ -102,10 +103,10 @@ function deleteBucket($ossClient, $bucket) } /** - * 设置bucket的acl配置 + * Set bucket ACL * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function putBucketAcl($ossClient, $bucket) @@ -123,10 +124,10 @@ function putBucketAcl($ossClient, $bucket) /** - * 获取bucket的acl配置 + * Get bucket ACL * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function getBucketAcl($ossClient, $bucket) @@ -144,9 +145,9 @@ function getBucketAcl($ossClient, $bucket) /** - * 列出用户所有的Bucket + * List all buckets * - * @param OssClient $ossClient OssClient实例 + * @param OssClient $ossClient OssClient instance * @return null */ function listBuckets($ossClient) diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketCors.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketCors.php index cc5c0b9c..dfa42d32 100644 --- a/vendor/aliyuncs/oss-sdk-php/samples/BucketCors.php +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketCors.php @@ -11,9 +11,9 @@ if (is_null($ossClient)) exit(1); $bucket = Common::getBucketName(); -//******************************* 简单使用 **************************************************************** +//******************************* Simple usage**************************************************************** -// 设置cors配置 +// Set cors configuration $corsConfig = new CorsConfig(); $rule = new CorsRule(); $rule->addAllowedHeader("x-oss-header"); @@ -24,15 +24,15 @@ $corsConfig->addRule($rule); $ossClient->putBucketCors($bucket, $corsConfig); Common::println("bucket $bucket corsConfig created:" . $corsConfig->serializeToXml()); -// 获取cors配置 +// Get cors configuration $corsConfig = $ossClient->getBucketCors($bucket); Common::println("bucket $bucket corsConfig fetched:" . $corsConfig->serializeToXml()); -// 删除cors配置 +// Delete cors configuration $ossClient->deleteBucketCors($bucket); Common::println("bucket $bucket corsConfig deleted"); -//******************************* 完整用法参考下面函数 ***************************************************** +//******************************* For complete usage, see the following functions ***************************************************** putBucketCors($ossClient, $bucket); getBucketCors($ossClient, $bucket); @@ -40,10 +40,10 @@ deleteBucketCors($ossClient, $bucket); getBucketCors($ossClient, $bucket); /** - * 设置bucket的cors配置 + * Set bucket cores * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function putBucketCors($ossClient, $bucket) @@ -67,10 +67,10 @@ function putBucketCors($ossClient, $bucket) } /** - * 获取并打印bucket的cors配置 + * Get and print the cors configuration of a bucket * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function getBucketCors($ossClient, $bucket) @@ -88,10 +88,10 @@ function getBucketCors($ossClient, $bucket) } /** - * 删除bucket的所有的cors配置 + * Delete all cors configuraiton of a bucket * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function deleteBucketCors($ossClient, $bucket) diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketLifecycle.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketLifecycle.php index ec0c37f8..04d2edd6 100644 --- a/vendor/aliyuncs/oss-sdk-php/samples/BucketLifecycle.php +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketLifecycle.php @@ -11,9 +11,9 @@ $bucket = Common::getBucketName(); $ossClient = Common::getOssClient(); if (is_null($ossClient)) exit(1); -//******************************* 简单使用 ******************************************************* +//******************************* Simple Usage ******************************************************* -//设置lifecycle规则 +// Set lifecycle configuration $lifecycleConfig = new LifecycleConfig(); $actions = array(); $actions[] = new LifecycleAction("Expiration", "Days", 3); @@ -22,16 +22,16 @@ $lifecycleConfig->addRule($lifecycleRule); $ossClient->putBucketLifecycle($bucket, $lifecycleConfig); Common::println("bucket $bucket lifecycleConfig created:" . $lifecycleConfig->serializeToXml()); -//获取lifecycle规则 +// Get lifecycle configuration $lifecycleConfig = $ossClient->getBucketLifecycle($bucket); Common::println("bucket $bucket lifecycleConfig fetched:" . $lifecycleConfig->serializeToXml()); -//删除bucket的lifecycle配置 +// Delete bucket lifecycle configuration $ossClient->deleteBucketLifecycle($bucket); Common::println("bucket $bucket lifecycleConfig deleted"); -//***************************** 完整用法参考下面函数 *********************************************** +//***************************** For complete usage, see the following functions *********************************************** putBucketLifecycle($ossClient, $bucket); getBucketLifecycle($ossClient, $bucket); @@ -39,10 +39,10 @@ deleteBucketLifecycle($ossClient, $bucket); getBucketLifecycle($ossClient, $bucket); /** - * 设置bucket的生命周期配置 + * Set bucket lifecycle configuration * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function putBucketLifecycle($ossClient, $bucket) @@ -67,10 +67,10 @@ function putBucketLifecycle($ossClient, $bucket) } /** - * 获取bucket的生命周期配置 + * Get bucket lifecycle configuration * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function getBucketLifecycle($ossClient, $bucket) @@ -88,10 +88,10 @@ function getBucketLifecycle($ossClient, $bucket) } /** - * 删除bucket的生命周期配置 + * Delete bucket lifecycle configuration * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function deleteBucketLifecycle($ossClient, $bucket) diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketLogging.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketLogging.php index 406e1d47..eef71f22 100644 --- a/vendor/aliyuncs/oss-sdk-php/samples/BucketLogging.php +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketLogging.php @@ -8,21 +8,21 @@ $bucket = Common::getBucketName(); $ossClient = Common::getOssClient(); if (is_null($ossClient)) exit(1); -//*******************************简单使用*************************************************************** +//*******************************Simple Usage *************************************************************** -// 设置Bucket访问日志记录规则, 访问日志文件的存放位置是同bucket下的access.log前缀的文件 +// Set bucket access logging rules. Access logs are stored under the same bucket with a 'access.log' prefix. $ossClient->putBucketLogging($bucket, $bucket, "access.log", array()); Common::println("bucket $bucket lifecycleConfig created"); -// 获取Bucket访问日志记录规则 +// Get bucket access logging rules $loggingConfig = $ossClient->getBucketLogging($bucket, array()); Common::println("bucket $bucket lifecycleConfig fetched:" . $loggingConfig->serializeToXml()); -// 删除Bucket访问日志记录规则 +// Delete bucket access logging rules $loggingConfig = $ossClient->getBucketLogging($bucket, array()); Common::println("bucket $bucket lifecycleConfig deleted"); -//******************************* 完整用法参考下面函数 **************************************************** +//******************************* For complete usage, see the following functions **************************************************** putBucketLogging($ossClient, $bucket); getBucketLogging($ossClient, $bucket); @@ -30,16 +30,16 @@ deleteBucketLogging($ossClient, $bucket); getBucketLogging($ossClient, $bucket); /** - * 设置bucket的Logging配置 + * Set bucket logging configuration * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function putBucketLogging($ossClient, $bucket) { $option = array(); - //访问日志存放在本bucket下 + // Access logs are stored in the same bucket. $targetBucket = $bucket; $targetPrefix = "access.log"; @@ -54,10 +54,10 @@ function putBucketLogging($ossClient, $bucket) } /** - * 获取bucket的Logging配置 + * Get bucket logging configuration * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function getBucketLogging($ossClient, $bucket) @@ -76,10 +76,10 @@ function getBucketLogging($ossClient, $bucket) } /** - * 删除bucket的Logging配置 + * Delete bucket logging configuration * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function deleteBucketLogging($ossClient, $bucket) diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketReferer.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketReferer.php index 3828df69..628f7846 100644 --- a/vendor/aliyuncs/oss-sdk-php/samples/BucketReferer.php +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketReferer.php @@ -9,26 +9,26 @@ $bucket = Common::getBucketName(); $ossClient = Common::getOssClient(); if (is_null($ossClient)) exit(1); -//******************************* 简单使用 **************************************************************** +//******************************* Simple Usage **************************************************************** -//设置referer白名单 +// Set referer whitelist $refererConfig = new RefererConfig(); $refererConfig->setAllowEmptyReferer(true); $refererConfig->addReferer("www.aliiyun.com"); $refererConfig->addReferer("www.aliiyuncs.com"); $ossClient->putBucketReferer($bucket, $refererConfig); Common::println("bucket $bucket refererConfig created:" . $refererConfig->serializeToXml()); -//获取Referer白名单 +// Get referer whitelist $refererConfig = $ossClient->getBucketReferer($bucket); Common::println("bucket $bucket refererConfig fetched:" . $refererConfig->serializeToXml()); -//删除referer白名单 +// Delete referrer whitelist $refererConfig = new RefererConfig(); $ossClient->putBucketReferer($bucket, $refererConfig); Common::println("bucket $bucket refererConfig deleted"); -//******************************* 完整用法参考下面函数 **************************************************** +//******************************* For complete usage, see the following functions **************************************************** putBucketReferer($ossClient, $bucket); getBucketReferer($ossClient, $bucket); @@ -36,10 +36,10 @@ deleteBucketReferer($ossClient, $bucket); getBucketReferer($ossClient, $bucket); /** - * 设置bucket的防盗链配置 + * Set bucket referer configuration * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function putBucketReferer($ossClient, $bucket) @@ -59,10 +59,10 @@ function putBucketReferer($ossClient, $bucket) } /** - * 获取bucket的防盗链配置 + * Get bucket referer configuration * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function getBucketReferer($ossClient, $bucket) @@ -80,11 +80,11 @@ function getBucketReferer($ossClient, $bucket) } /** - * 删除bucket的防盗链配置 - * Referer白名单不能直接清空,只能通过重新设置来覆盖之前的规则。 + * Delete bucket referer configuration + * Referer whitelist cannot be directly deleted. So use a empty one to overwrite it. * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function deleteBucketReferer($ossClient, $bucket) diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketWebsite.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketWebsite.php index 54706f83..6c387e68 100644 --- a/vendor/aliyuncs/oss-sdk-php/samples/BucketWebsite.php +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketWebsite.php @@ -9,22 +9,22 @@ $bucket = Common::getBucketName(); $ossClient = Common::getOssClient(); if (is_null($ossClient)) exit(1); -//*******************************简单使用*************************************************************** +//******************************* Simple Usage *************************************************************** -// 设置Bucket的静态网站托管模式 +// Set bucket static website configuration $websiteConfig = new WebsiteConfig("index.html", "error.html"); $ossClient->putBucketWebsite($bucket, $websiteConfig); Common::println("bucket $bucket websiteConfig created:" . $websiteConfig->serializeToXml()); -// 查看Bucket的静态网站托管状态 +// Get bucket static website configuration $websiteConfig = $ossClient->getBucketWebsite($bucket); Common::println("bucket $bucket websiteConfig fetched:" . $websiteConfig->serializeToXml()); -// 删除Bucket的静态网站托管模式 +// Delete bucket static website configuration $ossClient->deleteBucketWebsite($bucket); Common::println("bucket $bucket websiteConfig deleted"); -//******************************* 完整用法参考下面函数 **************************************************** +//******************************* For complete usage, see the following functions **************************************************** putBucketWebsite($ossClient, $bucket); getBucketWebsite($ossClient, $bucket); @@ -32,10 +32,10 @@ deleteBucketWebsite($ossClient, $bucket); getBucketWebsite($ossClient, $bucket); /** - * 设置bucket的静态网站托管模式配置 + * Sets bucket static website configuration * * @param $ossClient OssClient - * @param $bucket string 存储空间名称 + * @param $bucket string bucket name * @return null */ function putBucketWebsite($ossClient, $bucket) @@ -52,10 +52,10 @@ function putBucketWebsite($ossClient, $bucket) } /** - * 获取bucket的静态网站托管状态 + * Get bucket static website configuration * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function getBucketWebsite($ossClient, $bucket) @@ -73,10 +73,10 @@ function getBucketWebsite($ossClient, $bucket) } /** - * 删除bucket的静态网站托管模式配置 + * Delete bucket static website configuration * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function deleteBucketWebsite($ossClient, $bucket) diff --git a/vendor/aliyuncs/oss-sdk-php/samples/Callback.php b/vendor/aliyuncs/oss-sdk-php/samples/Callback.php index 8612a1c5..4b7bc41c 100644 --- a/vendor/aliyuncs/oss-sdk-php/samples/Callback.php +++ b/vendor/aliyuncs/oss-sdk-php/samples/Callback.php @@ -7,14 +7,14 @@ $bucket = Common::getBucketName(); $ossClient = Common::getOssClient(); if (is_null($ossClient)) exit(1); -//*******************************简单使用*************************************************************** +//******************************* Simple Usage *************************************************************** -/** putObject 使用callback上传内容到oss文件 - * callbackurl参数指定请求回调的服务器url - * callbackbodytype参数可为application/json或application/x-www-form-urlencoded, 可选参数,默认为application/x-www-form-urlencoded - * OSS_CALLBACK_VAR参数可以不设置 +/** putObject Upload content to an OSS file using callback. + * The callbackurl specifies the server url for the request callback. + * The callbackbodytype can be application/json or application/x-www-form-urlencoded,the optional parameters,the default for the application/x - WWW - form - urlencoded + * Users can choose not to set OSS_BACK_VAR */ -$url = +$url = '{ "callbackUrl":"callback.oss-demo.com:23450", "callbackHost":"oss-cn-hangzhou.aliyuncs.com", @@ -35,17 +35,17 @@ Common::println($result['body']); Common::println($result['info']['http_code']); /** - * completeMultipartUpload 使用callback上传内容到oss文件 - * callbackurl参数指定请求回调的服务器url - * callbackbodytype参数可为application/json或application/x-www-form-urlencoded, 可选参数,默认为application/x-www-form-urlencoded - * OSS_CALLBACK_VAR参数可以不设置 - */ + * completeMultipartUpload Upload content to an OSS file using callback. + * callbackurl specifies the server url for the request callback + * The callbackbodytype can be application/json or application/x-www-form-urlencoded,the optional parameters,the default for the application/x - WWW - form - urlencoded + * Users can choose not to set OSS_BACK_VAR. + */ $object = "multipart-callback-test.txt"; $copiedObject = "multipart-callback-test.txt.copied"; $ossClient->putObject($bucket, $copiedObject, file_get_contents(__FILE__)); /** - * step 1. 初始化一个分块上传事件, 也就是初始化上传Multipart, 获取upload id + * step 1. Initialize a block upload event, that is, a multipart upload process to get an upload id */ $upload_id = $ossClient->initiateMultipartUpload($bucket, $object); diff --git a/vendor/aliyuncs/oss-sdk-php/samples/Common.php b/vendor/aliyuncs/oss-sdk-php/samples/Common.php index f419d178..49bd4931 100644 --- a/vendor/aliyuncs/oss-sdk-php/samples/Common.php +++ b/vendor/aliyuncs/oss-sdk-php/samples/Common.php @@ -14,7 +14,7 @@ use OSS\Core\OssException; /** * Class Common * - * 示例程序【Samples/*.php】 的Common类,用于获取OssClient实例和其他公用方法 + * The Common class for 【Samples/*.php】 used to obtain OssClient instance and other common functions */ class Common { @@ -24,9 +24,9 @@ class Common const bucket = Config::OSS_TEST_BUCKET; /** - * 根据Config配置,得到一个OssClient实例 + * Get an OSSClient instance according to config. * - * @return OssClient 一个OssClient实例 + * @return OssClient An OssClient instance */ public static function getOssClient() { @@ -46,7 +46,7 @@ class Common } /** - * 工具方法,创建一个存储空间,如果发生异常直接exit + * A tool function which creates a bucket and exists the process if there are exceptions */ public static function createBucket() { @@ -81,4 +81,4 @@ class Common } } -Common::createBucket(); +# Common::createBucket(); diff --git a/vendor/aliyuncs/oss-sdk-php/samples/Config.php b/vendor/aliyuncs/oss-sdk-php/samples/Config.php index 35c0dc7c..fc3a1673 100644 --- a/vendor/aliyuncs/oss-sdk-php/samples/Config.php +++ b/vendor/aliyuncs/oss-sdk-php/samples/Config.php @@ -3,13 +3,13 @@ /** * Class Config * - * 执行Sample示例所需要的配置,用户在这里配置好Endpoint,AccessId, AccessKey和Sample示例操作的 - * bucket后,便可以直接运行RunAll.php, 运行所有的samples + * Make configurations required by the sample. + * Users can run RunAll.php which runs all the samples after configuring Endpoint, AccessId, and AccessKey. */ final class Config { - const OSS_ACCESS_ID = ''; - const OSS_ACCESS_KEY = ''; - const OSS_ENDPOINT = ''; - const OSS_TEST_BUCKET = ''; + const OSS_ACCESS_ID = 'update me'; + const OSS_ACCESS_KEY = 'update me'; + const OSS_ENDPOINT = 'update me'; + const OSS_TEST_BUCKET = 'update me'; } diff --git a/vendor/aliyuncs/oss-sdk-php/samples/Image.php b/vendor/aliyuncs/oss-sdk-php/samples/Image.php index 53ec0475..6e51d06d 100644 --- a/vendor/aliyuncs/oss-sdk-php/samples/Image.php +++ b/vendor/aliyuncs/oss-sdk-php/samples/Image.php @@ -9,54 +9,54 @@ $ossClient = Common::getOssClient(); $download_file = "download.jpg"; if (is_null($ossClient)) exit(1); -//*******************************简单使用*************************************************************** +//******************************* Simple Usage *************************************************************** -// 先把本地的example.jpg上传到指定$bucket, 命名为$object +// Upload example.jpg to the specified bucket and rename it to $object. $ossClient->uploadFile($bucketName, $object, "example.jpg"); -// 图片缩放 +// Image resize $options = array( OssClient::OSS_FILE_DOWNLOAD => $download_file, OssClient::OSS_PROCESS => "image/resize,m_fixed,h_100,w_100", ); $ossClient->getObject($bucketName, $object, $options); printImage("imageResize",$download_file); -// 图片裁剪 +// Image crop $options = array( OssClient::OSS_FILE_DOWNLOAD => $download_file, OssClient::OSS_PROCESS => "image/crop,w_100,h_100,x_100,y_100,r_1", ); $ossClient->getObject($bucketName, $object, $options); printImage("iamgeCrop", $download_file); -// 图片旋转 +// Image rotate $options = array( OssClient::OSS_FILE_DOWNLOAD => $download_file, OssClient::OSS_PROCESS => "image/rotate,90", ); $ossClient->getObject($bucketName, $object, $options); printImage("imageRotate", $download_file); -// 图片锐化 +// Image sharpen $options = array( OssClient::OSS_FILE_DOWNLOAD => $download_file, OssClient::OSS_PROCESS => "image/sharpen,100", ); $ossClient->getObject($bucketName, $object, $options); printImage("imageSharpen", $download_file); -// 图片水印 +// Add watermark into a image $options = array( OssClient::OSS_FILE_DOWNLOAD => $download_file, OssClient::OSS_PROCESS => "image/watermark,text_SGVsbG8g5Zu-54mH5pyN5YqhIQ", ); $ossClient->getObject($bucketName, $object, $options); printImage("imageWatermark", $download_file); -// 图片格式转换 +// Image format convertion $options = array( OssClient::OSS_FILE_DOWNLOAD => $download_file, OssClient::OSS_PROCESS => "image/format,png", ); $ossClient->getObject($bucketName, $object, $options); printImage("imageFormat", $download_file); -// 获取图片信息 +// Get image information $options = array( OssClient::OSS_FILE_DOWNLOAD => $download_file, OssClient::OSS_PROCESS => "image/info", ); @@ -65,7 +65,7 @@ printImage("imageInfo", $download_file); /** - * 生成一个带签名的可用于浏览器直接打开的url, URL的有效期是3600秒 + * Generate a signed url which could be used in browser to access the object. The expiration time is 1 hour. */ $timeout = 3600; $options = array( @@ -74,7 +74,7 @@ $options = array( $signedUrl = $ossClient->signUrl($bucketName, $object, $timeout, "GET", $options); Common::println("rtmp url: \n" . $signedUrl); -//最后删除上传的$object +// Finally delete the $object uploaded. $ossClient->deleteObject($bucketName, $object); function printImage($func, $imageFile) diff --git a/vendor/aliyuncs/oss-sdk-php/samples/LiveChannel.php b/vendor/aliyuncs/oss-sdk-php/samples/LiveChannel.php index 2f7d3a8b..67bb5415 100644 --- a/vendor/aliyuncs/oss-sdk-php/samples/LiveChannel.php +++ b/vendor/aliyuncs/oss-sdk-php/samples/LiveChannel.php @@ -8,11 +8,14 @@ $bucket = Common::getBucketName(); $ossClient = Common::getOssClient(); if (is_null($ossClient)) exit(1); -//******************************* 简单使用 ******************************************************* +//******************************* Simple Usage ******************************************************* /** - 创建一个直播频道 - 频道的名称是test_rtmp_live。直播生成的m3u8文件叫做test.m3u8,该索引文件包含3片ts文件,每片ts文件的时长为5秒(这只是一个建议值,具体的时长取决于关键帧)。 + * Create a Live Channel + * The live channel's name is test_rtmp_live. + * The play url file is named as test.m3u8, which includes 3 ts files. + * The time period of each file is 5 seconds.(It is recommneded value only for demo purpose, the actual period depends on the key frame.) + * */ $config = new LiveChannelConfig(array( 'description' => 'live channel test', @@ -29,9 +32,9 @@ Common::println("bucket $bucket liveChannel created:\n" . "playurls: ". $info->getPlayUrls()[0] . "\n"); /** - 对创建好的频道,可以使用listBucketLiveChannels来进行列举已达到管理的目的。 - prefix可以按照前缀过滤list出来的频道。 - max_keys表示迭代器内部一次list出来的频道的最大数量,这个值最大不能超过1000,不填写的话默认为100。 + * You can use listBucketLiveChannels to list and manage all existing live channels. + * Prefix can be used to filter listed live channels by prefix. + * Max_keys indicates the maximum numbers of live channels that can be listed in an iterator at one time. Its value is 1000 in maximum and 100 by default. */ $list = $ossClient->listBucketLiveChannels($bucket); Common::println("bucket $bucket listLiveChannel:\n" . @@ -50,7 +53,9 @@ foreach($list->getChannelList() as $list) "list live channel getNextMarker: ". $list->getLastModified() . "\n"); } /** - 创建直播频道之后拿到推流用的play_url(rtmp推流的url,如果Bucket不是公共读写权限那么还需要带上签名,见下文示例)和推流用的publish_url(推流产生的m3u8文件的url) + * Obtain the play_url (url used for rtmp stream pushing. + * If the the bucket is not globally readable and writable, + * the url must be signed as shown in the following.) and pulish_url (the url included in the m3u8 file generated in stream pushing) used to push streams. */ $play_url = $ossClient->signRtmpUrl($bucket, "test_rtmp_live", 3600, array('params' => array('playlistName' => 'playlist.m3u8'))); Common::println("bucket $bucket rtmp url: \n" . $play_url); @@ -58,12 +63,13 @@ $play_url = $ossClient->signRtmpUrl($bucket, "test_rtmp_live", 3600); Common::println("bucket $bucket rtmp url: \n" . $play_url); /** - 创建好直播频道,如果想把这个频道禁用掉(断掉正在推的流或者不再允许向一个地址推流),应该使用putLiveChannelStatus接口,将频道的status改成“Disabled”,如果要将一个禁用状态的频道启用,那么也是调用这个接口,将status改成“Enabled” + * If you want to disable a created live channel (disable the pushing streaming or do not allow stream pushing to an IP address), call putLiveChannelStatus to change the channel status to "Disabled". + * If you want to enable a disabled live channel, call PutLiveChannelStatus to chanage the channel status to "Enabled". */ $resp = $ossClient->putLiveChannelStatus($bucket, "test_rtmp_live", "enabled"); /** - 创建好直播频道之后调用getLiveChannelInfo可以得到频道相关的信息 + * You can callLiveChannelInfo to get the information about a live channel. */ $info = $ossClient->getLiveChannelInfo($bucket, 'test_rtmp_live'); Common::println("bucket $bucket LiveChannelInfo:\n" . @@ -75,7 +81,7 @@ Common::println("bucket $bucket LiveChannelInfo:\n" . "live channel info playListName: ". $info->getPlayListName() . "\n"); /** - 如果想查看一个频道历史推流记录,可以调用getLiveChannelHistory。目前最多可以看到10次推流的记录 + * Gets the historical pushing streaming records by calling getLiveChannelHistory. Now the max records to return is 10. */ $history = $ossClient->getLiveChannelHistory($bucket, "test_rtmp_live"); if (count($history->getLiveRecordList()) != 0) @@ -90,9 +96,9 @@ if (count($history->getLiveRecordList()) != 0) } /** - 对于正在推流的频道调用get_live_channel_stat可以获得流的状态信息。 - 如果频道正在推流,那么stat_result中的所有字段都有意义。 - 如果频道闲置或者处于“Disabled”状态,那么status为“Idle”或“Disabled”,其他字段无意义。 + * Get the live channel's status by calling getLiveChannelStatus. + * If the live channel is receiving the pushing stream, all attributes in stat_result are valid. + * If the live channel is idle or disabled, then the status is idle or Disabled and other attributes have no meaning. */ $status = $ossClient->getLiveChannelStatus($bucket, "test_rtmp_live"); Common::println("bucket $bucket listLiveChannel:\n" . @@ -108,9 +114,9 @@ Common::println("bucket $bucket listLiveChannel:\n" . "live channel status AdioCodec: ". $status->getAudioCodec() . "\n"); /** - * 如果希望利用直播推流产生的ts文件生成一个点播列表,可以使用postVodPlaylist方法。 - * 指定起始时间为当前时间减去60秒,结束时间为当前时间,这意味着将生成一个长度为60秒的点播视频。 - * 播放列表指定为“vod_playlist.m3u8”,也就是说这个接口调用成功之后会在OSS上生成一个名叫“vod_playlist.m3u8”的播放列表文件。 + * If you want to generate a play url from the ts files generated from pushing streaming, call postVodPlayList. + * Specify the start time to 60 seconds before the current time and the end time to the current time, which means that a video of 60 seconds is generated. + * The playlist file is specified to “vod_playlist.m3u8”, which means that a palylist file named vod_playlist.m3u8 is created after the interface is called. */ $current_time = time(); $ossClient->postVodPlaylist($bucket, @@ -120,6 +126,6 @@ $ossClient->postVodPlaylist($bucket, ); /** - * 如果一个直播频道已经不打算再使用了,那么可以调用delete_live_channel来删除频道。 + * Call delete_live_channel to delete a live channel if it will no longer be in used. */ $ossClient->deleteBucketLiveChannel($bucket, "test_rtmp_live"); diff --git a/vendor/aliyuncs/oss-sdk-php/samples/MultipartUpload.php b/vendor/aliyuncs/oss-sdk-php/samples/MultipartUpload.php index e8d69a3e..21756b7c 100644 --- a/vendor/aliyuncs/oss-sdk-php/samples/MultipartUpload.php +++ b/vendor/aliyuncs/oss-sdk-php/samples/MultipartUpload.php @@ -9,27 +9,27 @@ $bucket = Common::getBucketName(); $ossClient = Common::getOssClient(); if (is_null($ossClient)) exit(1); -//*******************************简单使用*************************************************************** +//******************************* Simple usage *************************************************************** /** - * 查看完整用法中的 "putObjectByRawApis"函数,查看使用基础的分片上传api进行文件上传,用户可以基于这个自行实现断点续传等功能 + * See the putObjectByRawAPis usage in complete example to check out basic multipart upload APIs which can be used as resumable upload. */ -// 使用分片上传接口上传文件, 接口会根据文件大小决定是使用普通上传还是分片上传 +// Upload a file using the multipart upload interface, which determines to use simple upload or multipart upload based on the file size. $ossClient->multiuploadFile($bucket, "file.php", __FILE__, array()); Common::println("local file " . __FILE__ . " is uploaded to the bucket $bucket, file.php"); -// 上传本地目录到bucket内的targetdir子目录中 +// Upload local directory's data into target dir $ossClient->uploadDir($bucket, "targetdir", __DIR__); Common::println("local dir " . __DIR__ . " is uploaded to the bucket $bucket, targetdir/"); -// 列出当前未完成的分片上传 +// List the incomplete multipart uploads $listMultipartUploadInfo = $ossClient->listMultipartUploads($bucket, array()); -//******************************* 完整用法参考下面函数 **************************************************** +//******************************* For complete usage, see the following functions **************************************************** multiuploadFile($ossClient, $bucket); putObjectByRawApis($ossClient, $bucket); @@ -37,10 +37,10 @@ uploadDir($ossClient, $bucket); listMultipartUploads($ossClient, $bucket); /** - * 通过multipart上传文件 + * Upload files using multipart upload * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function multiuploadFile($ossClient, $bucket) @@ -60,17 +60,17 @@ function multiuploadFile($ossClient, $bucket) } /** - * 使用基本的api分阶段进行分片上传 + * Use basic multipart upload for file upload. * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @throws OssException */ function putObjectByRawApis($ossClient, $bucket) { $object = "test/multipart-test.txt"; /** - * step 1. 初始化一个分块上传事件, 也就是初始化上传Multipart, 获取upload id + * step 1. Initialize a block upload event, that is, a multipart upload process to get an upload id */ try { $uploadId = $ossClient->initiateMultipartUpload($bucket, $object); @@ -81,7 +81,7 @@ function putObjectByRawApis($ossClient, $bucket) } print(__FUNCTION__ . ": initiateMultipartUpload OK" . "\n"); /* - * step 2. 上传分片 + * step 2. Upload parts */ $partSize = 10 * 1024 * 1024; $uploadFile = __FILE__; @@ -104,7 +104,7 @@ function putObjectByRawApis($ossClient, $bucket) $contentMd5 = OssUtil::getMd5SumForFile($uploadFile, $fromPos, $toPos); $upOptions[$ossClient::OSS_CONTENT_MD5] = $contentMd5; } - //2. 将每一分片上传到OSS + //2. Upload each part to OSS try { $responseUploadPart[] = $ossClient->uploadPart($bucket, $object, $uploadId, $upOptions); } catch (OssException $e) { @@ -122,7 +122,7 @@ function putObjectByRawApis($ossClient, $bucket) ); } /** - * step 3. 完成上传 + * step 3. Complete the upload */ try { $ossClient->completeMultipartUpload($bucket, $object, $uploadId, $uploadParts); @@ -135,10 +135,10 @@ function putObjectByRawApis($ossClient, $bucket) } /** - * 按照目录上传文件 + * Upload by directories * * @param OssClient $ossClient OssClient - * @param string $bucket 存储空间名称 + * @param string $bucket bucket name * */ function uploadDir($ossClient, $bucket) @@ -156,7 +156,7 @@ function uploadDir($ossClient, $bucket) } /** - * 获取当前未完成的分片上传列表 + * Get ongoing multipart uploads * * @param $ossClient OssClient * @param $bucket string diff --git a/vendor/aliyuncs/oss-sdk-php/samples/Object.php b/vendor/aliyuncs/oss-sdk-php/samples/Object.php index 3bf024b0..ae6eb839 100644 --- a/vendor/aliyuncs/oss-sdk-php/samples/Object.php +++ b/vendor/aliyuncs/oss-sdk-php/samples/Object.php @@ -7,9 +7,9 @@ use OSS\Core\OssException; $bucket = Common::getBucketName(); $ossClient = Common::getOssClient(); if (is_null($ossClient)) exit(1); -//*******************************简单使用*************************************************************** +//******************************* Simple usage *************************************************************** -// 简单上传变量的内容到oss文件 +// Upload the in-memory string (hi, oss) to an OSS file $result = $ossClient->putObject($bucket, "b.file", "hi, oss"); Common::println("b.file is created"); Common::println($result['x-oss-request-id']); @@ -17,7 +17,7 @@ Common::println($result['etag']); Common::println($result['content-md5']); Common::println($result['body']); -// 上传本地文件 +// Uploads a local file to an OSS file $result = $ossClient->uploadFile($bucket, "c.file", __FILE__); Common::println("c.file is created"); Common::println("b.file is created"); @@ -26,21 +26,21 @@ Common::println($result['etag']); Common::println($result['content-md5']); Common::println($result['body']); -// 下载object到本地变量 +// Download an oss object as an in-memory variable $content = $ossClient->getObject($bucket, "b.file"); Common::println("b.file is fetched, the content is: " . $content); -// 给object添加symlink +// Add a symlink to an object $content = $ossClient->putSymlink($bucket, "test-symlink", "b.file"); Common::println("test-symlink is created"); Common::println($result['x-oss-request-id']); Common::println($result['etag']); -// 获取symlink +// Get a symlink $content = $ossClient->getSymlink($bucket, "test-symlink"); Common::println("test-symlink refer to : " . $content[OssClient::OSS_SYMLINK_TARGET]); -// 下载object到本地文件 +// Download an object to a local file. $options = array( OssClient::OSS_FILE_DOWNLOAD => "./c.file.localcopy", ); @@ -48,26 +48,26 @@ $ossClient->getObject($bucket, "c.file", $options); Common::println("b.file is fetched to the local file: c.file.localcopy"); Common::println("b.file is created"); -// 拷贝object +// Copy an object $result = $ossClient->copyObject($bucket, "c.file", $bucket, "c.file.copy"); Common::println("lastModifiedTime: " . $result[0]); Common::println("ETag: " . $result[1]); -// 判断object是否存在 +// Check whether an object exists $doesExist = $ossClient->doesObjectExist($bucket, "c.file.copy"); Common::println("file c.file.copy exist? " . ($doesExist ? "yes" : "no")); -// 删除object +// Delete an object $result = $ossClient->deleteObject($bucket, "c.file.copy"); Common::println("c.file.copy is deleted"); Common::println("b.file is created"); Common::println($result['x-oss-request-id']); -// 判断object是否存在 +// Check whether an object exists $doesExist = $ossClient->doesObjectExist($bucket, "c.file.copy"); Common::println("file c.file.copy exist? " . ($doesExist ? "yes" : "no")); -// 批量删除object +// Delete multiple objects in batch $result = $ossClient->deleteObjects($bucket, array("b.file", "c.file")); foreach($result as $object) Common::println($object); @@ -75,7 +75,7 @@ foreach($result as $object) sleep(2); unlink("c.file.localcopy"); -//******************************* 完整用法参考下面函数 **************************************************** +//******************************* For complete usage, see the following functions **************************************************** listObjects($ossClient, $bucket); listAllObjects($ossClient, $bucket); @@ -93,10 +93,10 @@ doesObjectExist($ossClient, $bucket); getSymlink($ossClient, $bucket); putSymlink($ossClient, $bucket); /** - * 创建虚拟目录 + * Create a 'virtual' folder * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function createObjectDir($ossClient, $bucket) @@ -112,12 +112,12 @@ function createObjectDir($ossClient, $bucket) } /** - * 把本地变量的内容到文件 + * Upload in-memory data to oss * - * 简单上传,上传指定变量的内存值作为object的内容 + * Simple upload---upload specified in-memory data to an OSS object * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function putObject($ossClient, $bucket) @@ -137,10 +137,10 @@ function putObject($ossClient, $bucket) /** - * 上传指定的本地文件内容 + * Uploads a local file to OSS * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function uploadFile($ossClient, $bucket) @@ -160,11 +160,12 @@ function uploadFile($ossClient, $bucket) } /** - * 列出Bucket内所有目录和文件, 注意如果符合条件的文件数目超过设置的max-keys, 用户需要使用返回的nextMarker作为入参,通过 - * 循环调用ListObjects得到所有的文件,具体操作见下面的 listAllObjects 示例 + * Lists all files and folders in the bucket. + * Note if there's more items than the max-keys specified, the caller needs to use the nextMarker returned as the value for the next call's maker paramter. + * Loop through all the items returned from ListObjects. * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function listObjects($ossClient, $bucket) @@ -187,8 +188,8 @@ function listObjects($ossClient, $bucket) return; } print(__FUNCTION__ . ": OK" . "\n"); - $objectList = $listObjectInfo->getObjectList(); // 文件列表 - $prefixList = $listObjectInfo->getPrefixList(); // 目录列表 + $objectList = $listObjectInfo->getObjectList(); // object list + $prefixList = $listObjectInfo->getPrefixList(); // directory list if (!empty($objectList)) { print("objectList:\n"); foreach ($objectList as $objectInfo) { @@ -204,15 +205,15 @@ function listObjects($ossClient, $bucket) } /** - * 列出Bucket内所有目录和文件, 根据返回的nextMarker循环得到所有Objects + * Lists all folders and files under the bucket. Use nextMarker repeatedly to get all objects. * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function listAllObjects($ossClient, $bucket) { - //构造dir下的文件和虚拟目录 + // Create dir/obj 'folder' and put some files into it. for ($i = 0; $i < 100; $i += 1) { $ossClient->putObject($bucket, "dir/obj" . strval($i), "hi"); $ossClient->createObjectDir($bucket, "dir/obj" . strval($i)); @@ -238,7 +239,7 @@ function listAllObjects($ossClient, $bucket) printf($e->getMessage() . "\n"); return; } - // 得到nextMarker,从上一次listObjects读到的最后一个文件的下一个文件开始继续获取文件列表 + // Get the nextMarker, and it would be used as the next call's marker parameter to resume from the last call $nextMarker = $listObjectInfo->getNextMarker(); $listObject = $listObjectInfo->getObjectList(); $listPrefix = $listObjectInfo->getPrefixList(); @@ -251,10 +252,10 @@ function listAllObjects($ossClient, $bucket) } /** - * 获取object的内容 + * Get the content of an object. * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function getObject($ossClient, $bucket) @@ -277,10 +278,10 @@ function getObject($ossClient, $bucket) } /** - * put symlink + * Put symlink * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient The Instance of OssClient + * @param string $bucket bucket name * @return null */ function putSymlink($ossClient, $bucket) @@ -305,10 +306,10 @@ function putSymlink($ossClient, $bucket) } /** - * 获取symlink + * Get symlink * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function getSymlink($ossClient, $bucket) @@ -333,13 +334,13 @@ function getSymlink($ossClient, $bucket) } /** - * get_object_to_local_file + * Get_object_to_local_file * - * 获取object - * 将object下载到指定的文件 + * Get object + * Download object to a specified file. * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function getObjectToLocalFile($ossClient, $bucket) @@ -369,11 +370,11 @@ function getObjectToLocalFile($ossClient, $bucket) } /** - * 拷贝object - * 当目的object和源object完全相同时,表示修改object的meta信息 + * Copy object + * When the source object is same as the target one, copy operation will just update the metadata. * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function copyObject($ossClient, $bucket) @@ -395,11 +396,11 @@ function copyObject($ossClient, $bucket) } /** - * 修改Object Meta - * 利用copyObject接口的特性:当目的object和源object完全相同时,表示修改object的meta信息 + * Update Object Meta + * it leverages the feature of copyObject: when the source object is just the target object, the metadata could be updated via copy * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function modifyMetaForObject($ossClient, $bucket) @@ -425,10 +426,10 @@ function modifyMetaForObject($ossClient, $bucket) } /** - * 获取object meta, 也就是getObjectMeta接口 + * Get object meta, that is, getObjectMeta * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function getObjectMeta($ossClient, $bucket) @@ -452,10 +453,10 @@ function getObjectMeta($ossClient, $bucket) } /** - * 删除object + * Delete an object * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function deleteObject($ossClient, $bucket) @@ -473,10 +474,10 @@ function deleteObject($ossClient, $bucket) /** - * 批量删除object + * Delete multiple objects in batch * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function deleteObjects($ossClient, $bucket) @@ -495,10 +496,10 @@ function deleteObjects($ossClient, $bucket) } /** - * 判断object是否存在 + * Check whether an object exists * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null */ function doesObjectExist($ossClient, $bucket) diff --git a/vendor/aliyuncs/oss-sdk-php/samples/RunAll.php b/vendor/aliyuncs/oss-sdk-php/samples/RunAll.php index a4d6d9b9..0cd7ec16 100644 --- a/vendor/aliyuncs/oss-sdk-php/samples/RunAll.php +++ b/vendor/aliyuncs/oss-sdk-php/samples/RunAll.php @@ -9,5 +9,5 @@ require_once __DIR__ . '/BucketReferer.php'; require_once __DIR__ . '/BucketLogging.php'; require_once __DIR__ . '/BucketWebsite.php'; require_once __DIR__ . '/Signature.php'; -require_once __DIR__ . '/Object.php'; +require_once __DIR__ . '/Object1.php'; require_once __DIR__ . '/MultipartUpload.php'; \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/samples/Signature.php b/vendor/aliyuncs/oss-sdk-php/samples/Signature.php index 5ef2b7dd..eef59812 100644 --- a/vendor/aliyuncs/oss-sdk-php/samples/Signature.php +++ b/vendor/aliyuncs/oss-sdk-php/samples/Signature.php @@ -10,33 +10,33 @@ $bucket = Common::getBucketName(); $ossClient = Common::getOssClient(); if (is_null($ossClient)) exit(1); -//******************************* 简单使用 *************************************************************** +//******************************* Simple Usage *************************************************************** $ossClient->uploadFile($bucket, "a.file", __FILE__); -// 生成GetObject的签名url,用户可以使用这个url直接在浏览器下载 +// Generate a signed url for getting an object. The URL can be used in browser directly to download the file. $signedUrl = $ossClient->signUrl($bucket, "a.file", 3600); Common::println($signedUrl); -// 生成用于putObject的签名URL,用户可以直接用put方法使用这个url上传文件到 "a.file" +// Generate the signed url for putting an object. User can use put method with this url to upload a file to "a.file". $signedUrl = $ossClient->signUrl($bucket, "a.file", "3600", "PUT"); Common::println($signedUrl); -// 生成从本地文件上传PutObject的签名url, 用户可以直接使用这个url把本地文件上传到 "a.file" +// Generate the signed url for putting an object from local file. The url can be used directly to upload the file to "a.file". $signedUrl = $ossClient->signUrl($bucket, "a.file", 3600, "PUT", array('Content-Type' => 'txt')); Common::println($signedUrl); -//******************************* 完整用法参考下面函数 **************************************************** +//******************************* For complete usage, see the following functions **************************************************** getSignedUrlForPuttingObject($ossClient, $bucket); getSignedUrlForPuttingObjectFromFile($ossClient, $bucket); getSignedUrlForGettingObject($ossClient, $bucket); /** - * 生成GetObject的签名url,主要用于私有权限下的读访问控制 + * Generate the signed url for getObject() to control read accesses under private privilege * - * @param $ossClient OssClient OssClient实例 - * @param $bucket string 存储空间名称 + * @param $ossClient OssClient OssClient instance + * @param $bucket string bucket name * @return null */ function getSignedUrlForGettingObject($ossClient, $bucket) @@ -52,7 +52,7 @@ function getSignedUrlForGettingObject($ossClient, $bucket) } print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n"); /** - * 可以类似的代码来访问签名的URL,也可以输入到浏览器中去访问 + * Use similar code to access the object by url, or use browser to access the object. */ $request = new RequestCore($signedUrl); $request->set_method('GET'); @@ -67,10 +67,10 @@ function getSignedUrlForGettingObject($ossClient, $bucket) } /** - * 生成PutObject的签名url,主要用于私有权限下的写访问控制 + * Generate the signed url for PutObject to control write accesses under private privilege. * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @return null * @throws OssException */ @@ -105,11 +105,10 @@ function getSignedUrlForPuttingObject($ossClient, $bucket) } /** - * 生成PutObject的签名url,主要用于私有权限下的写访问控制, 用户可以利用生成的signedUrl - * 从文件上传文件 + * Generate the signed url for PutObject's signed url. User could use the signed url to upload file directly. * - * @param OssClient $ossClient OssClient实例 - * @param string $bucket 存储空间名称 + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name * @throws OssException */ function getSignedUrlForPuttingObjectFromFile($ossClient, $bucket) diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php index e9b88ffa..17685c31 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php @@ -5,16 +5,17 @@ namespace OSS\Core; /** * Class MimeTypes * - * 在上传文件的时候,根据文件的缺省名,得到其对应的Content-type + * The map of a file's extention name to its corresponding Content-Type value in the file upload request. + * If the file extention name is not predefined in this class, getMimetype() returns null. * * @package OSS\Core */ class MimeTypes { /** - * 根据文件名,获取http协议header中的content-type应该填写的数据 + * Get the content-type value of http header from the file's extension name. * - * @param string $name 缺省名 + * @param string $name Default file extension name. * @return string content-type */ public static function getMimetype($name) diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php index b0e9e8b0..2320c9e8 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php @@ -5,8 +5,8 @@ namespace OSS\Core; /** * Class OssException * - * OssClient在使用的时候,所抛出的异常,用户在使用OssClient的时候,要Try住相关代码, - * try的Exception应该是OssException,其中会得到相关异常原因 + * This is the class that OSSClient is expected to thrown, which the caller needs to handle properly. + * It has the OSS specific errors which is useful for troubleshooting. * * @package OSS\Core */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php index 6e5d4133..541d2c34 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php @@ -5,7 +5,7 @@ namespace OSS\Core; /** * Class OssUtil * - * Oss工具类,主要供OssClient使用,用户也可以使用本类进行返回结果的格式化 + * Oss Util class for OssClient. The caller could use it for formating the result from OssClient. * * @package OSS */ @@ -20,10 +20,10 @@ class OssUtil const OSS_MIN_PART_SIZE = 102400; // 100KB /** - * 生成query params + * Generate query params * - * @param array $options 关联数组 - * @return string 返回诸如 key1=value1&key2=value2 + * @param array $options: a key-value pair array. + * @return string: the key-value list in the format such as key1=value1&key2=value2 */ public static function toQueryString($options = array()) { @@ -38,7 +38,7 @@ class OssUtil } /** - * 转义字符替换 + * Html encoding '<', '>', '&', '\', '"' in subject parameter. * * @param string $subject * @return string @@ -51,7 +51,7 @@ class OssUtil } /** - * 检查是否是中文编码 + * Check whether the string includes any chinese character * * @param $str * @return int @@ -62,10 +62,10 @@ class OssUtil } /** - * 检测是否GB2312编码 + * Checks if the string is encoded by GB2312. * * @param string $str - * @return boolean false UTF-8编码 TRUE GB2312编码 + * @return boolean false UTF-8 encoding TRUE GB2312 encoding */ public static function isGb2312($str) { @@ -87,7 +87,7 @@ class OssUtil } /** - * 检测是否GBK编码 + * Checks if the string is encoded by GBK * * @param string $str * @param boolean $gbk @@ -114,13 +114,13 @@ class OssUtil } /** - * 检验bucket名称是否合法 - * bucket的命名规范: - * 1. 只能包括小写字母,数字 - * 2. 必须以小写字母或者数字开头 - * 3. 长度必须在3-63字节之间 + * Checks if the bucket name is valid + * bucket naming rules + * 1. Can only include lowercase letters, numbers, or dashes + * 2. Must start and end with lowercase letters or numbers + * 3. Must be within a length from 3 to 63 bytes. * - * @param string $bucket Bucket名称 + * @param string $bucket Bucket name * @return boolean */ public static function validateBucket($bucket) @@ -133,11 +133,11 @@ class OssUtil } /** - * 检验object名称是否合法 - * object命名规范: - * 1. 规则长度必须在1-1023字节之间 - * 2. 使用UTF-8编码 - * 3. 不能以 "/" "\\"开头 + * Checks if object name is valid + * object naming rules: + * 1. Must be within a length from 1 to 1023 bytes + * 2. Cannot start with '/' or '\\'. + * 3. Must be encoded in UTF-8. * * @param string $object Object名称 * @return boolean @@ -155,7 +155,7 @@ class OssUtil /** - * 判断字符串$str是不是以$findMe开始 + * Checks if $str starts with $findMe * * @param string $str * @param string $findMe @@ -170,8 +170,9 @@ class OssUtil } } + /** - * 生成createBucketXmlBody接口的xml消息 + * Generate the xml message of createBucketXmlBody. * * @param string $storageClass * @return string @@ -184,7 +185,7 @@ class OssUtil } /** - * 检验$options + * validate $options * * @param array $options * @throws OssException @@ -199,7 +200,7 @@ class OssUtil } /** - * 检查上传文件的内容是否合法 + * check whether the Content is valid. * * @param $content string * @throws OssException @@ -212,7 +213,7 @@ class OssUtil } /** - * 校验BUCKET/OBJECT/OBJECT GROUP是否为空 + * Check if BUCKET/OBJECT/OBJECT GROUP is empty. * * @param string $name * @param string $errMsg @@ -227,7 +228,7 @@ class OssUtil } /** - * 仅供测试使用的接口,请勿使用 + * This is a method for test only. DO NOT USE. * * @param $filename * @param $size @@ -268,7 +269,7 @@ BBB; } /** - * 得到文件的md5编码 + * Get MD5 of the file. * * @param $filename * @param $from_pos @@ -318,7 +319,7 @@ BBB; } /** - * 检测是否windows系统,因为windows系统默认编码为GBK + * Check if the OS is Windows. The default encoding in Windows is GBK. * * @return bool */ @@ -328,7 +329,9 @@ BBB; } /** - * 主要是由于windows系统编码是gbk,遇到中文时候,如果不进行转换处理会出现找不到文件的问题 + * Encodes the file path from GBK to UTF-8. + * The default encoding in Windows is GBK. + * And if the file path is in Chinese, the file would not be found without the transcoding to UTF-8. * * @param $file_path * @return string @@ -342,9 +345,9 @@ BBB; } /** - * 判断用户输入的endpoint是否是 xxx.xxx.xxx.xxx:port 或者 xxx.xxx.xxx.xxx的ip格式 + * Check if the endpoint is in the IPv4 format, such as xxx.xxx.xxx.xxx:port or xxx.xxx.xxx.xxx. * - * @param string $endpoint 需要做判断的endpoint + * @param string $endpoint The endpoint to check. * @return boolean */ public static function isIPFormat($endpoint) @@ -360,7 +363,44 @@ BBB; } /** - * 生成DeleteMultiObjects接口的xml消息 + * Get the host:port from endpoint. + * + * @param string $endpoint the endpoint. + * @return boolean + */ + public static function getHostPortFromEndpoint($endpoint) + { + $str = $endpoint; + $pos = strpos($str, "://"); + if ($pos !== false) { + $str = substr($str, $pos+3); + } + + $pos = strpos($str, '#'); + if ($pos !== false) { + $str = substr($str, 0, $pos); + } + + $pos = strpos($str, '?'); + if ($pos !== false) { + $str = substr($str, 0, $pos); + } + + $pos = strpos($str, '/'); + if ($pos !== false) { + $str = substr($str, 0, $pos); + } + + $pos = strpos($str, '@'); + if ($pos !== false) { + $str = substr($str, $pos+1); + } + + return $str; + } + + /** + * Generate the xml message of DeleteMultiObjects. * * @param string[] $objects * @param bool $quiet @@ -379,7 +419,7 @@ BBB; } /** - * 生成CompleteMultipartUpload接口的xml消息 + * Generate the xml message of CompleteMultipartUpload. * * @param array[] $listParts * @return string @@ -396,7 +436,7 @@ BBB; } /** - * 读取目录 + * Read the directory, return a associative array in which the MD5 is the named key and the is the value. * * @param string $dir * @param string $exclude diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore.php index 06d0f878..e1d221e2 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore.php @@ -3,7 +3,7 @@ namespace OSS\Http; /** - * Handles all HTTP requests using cURL and manages the responses. + * Handle all HTTP requests using cURL and manages the responses. * * @version 2011.06.07 * @copyright 2006-2011 Ryan Parman @@ -75,7 +75,7 @@ class RequestCore public $method; /** - * Stores the proxy settings to use for the request. + * Store the proxy settings to use for the request. */ public $proxy = null; @@ -170,14 +170,14 @@ class RequestCore public $registered_streaming_write_callback = null; /** - * 请求超时时间, 默认是5184000秒,6天 + * The request timeout time, which is 5,184,000 seconds,that is, 6 days by default * * @var int */ public $timeout = 5184000; /** - * 连接超时时间,默认是10秒 + * The connection timeout time, which is 10 seconds by default * * @var int */ @@ -216,7 +216,7 @@ class RequestCore // CONSTRUCTOR/DESTRUCTOR /** - * Constructs a new instance of this class. + * Construct a new instance of this class. * * @param string $url (Optional) The URL to request or service endpoint to query. * @param string $proxy (Optional) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port` @@ -249,7 +249,7 @@ class RequestCore } /** - * Destructs the instance. Closes opened file handles. + * Destruct the instance. Closes opened file handles. * * @return $this A reference to the current instance. */ @@ -271,7 +271,7 @@ class RequestCore // REQUEST METHODS /** - * Sets the credentials to use for authentication. + * Set the credentials to use for authentication. * * @param string $user (Required) The username to authenticate with. * @param string $pass (Required) The password to authenticate with. @@ -285,7 +285,7 @@ class RequestCore } /** - * Adds a custom HTTP header to the cURL request. + * Add a custom HTTP header to the cURL request. * * @param string $key (Required) The custom HTTP header to set. * @param mixed $value (Required) The value to assign to the custom HTTP header. @@ -298,7 +298,7 @@ class RequestCore } /** - * Removes an HTTP header from the cURL request. + * Remove an HTTP header from the cURL request. * * @param string $key (Required) The custom HTTP header to set. * @return $this A reference to the current instance. @@ -324,7 +324,7 @@ class RequestCore } /** - * Sets a custom useragent string for the class. + * Set a custom useragent string for the class. * * @param string $ua (Required) The useragent string to use. * @return $this A reference to the current instance. @@ -373,7 +373,7 @@ class RequestCore } /** - * Sets the length in bytes to read from the stream while streaming up. + * Set the length in bytes to read from the stream while streaming up. * * @param integer $size (Required) The length in bytes to read from the stream. * @return $this A reference to the current instance. @@ -386,7 +386,7 @@ class RequestCore } /** - * Sets the resource to read from while streaming up. Reads the stream from its current position until + * Set the resource to read from while streaming up. Reads the stream from its current position until * EOF or `$size` bytes have been read. If `$size` is not given it will be determined by and * . * @@ -414,7 +414,7 @@ class RequestCore } /** - * Sets the file to read from while streaming up. + * Set the file to read from while streaming up. * * @param string $location (Required) The readable location to read from. * @return $this A reference to the current instance. @@ -428,7 +428,7 @@ class RequestCore } /** - * Sets the resource to write to while streaming down. + * Set the resource to write to while streaming down. * * @param resource $resource (Required) The writeable resource to write to. * @return $this A reference to the current instance. @@ -441,7 +441,7 @@ class RequestCore } /** - * Sets the file to write to while streaming down. + * Set the file to write to while streaming down. * * @param string $location (Required) The writeable location to write to. * @return $this A reference to the current instance. @@ -631,7 +631,7 @@ class RequestCore } /** - * Prepares and adds the details of the cURL request. This can be passed along to a + * Prepare and adds the details of the cURL request. This can be passed along to a * function. * * @return resource The handle for the cURL object. @@ -685,7 +685,6 @@ class RequestCore // Enable a proxy connection if requested. if ($this->proxy) { - $host = $this->proxy['host']; $host .= ($this->proxy['port']) ? ':' . $this->proxy['port'] : ''; curl_setopt($curl_handle, CURLOPT_PROXY, $host); @@ -830,7 +829,7 @@ class RequestCore } /** - * Sends the request, calling necessary utility functions to update built-in properties. + * Send the request, calling necessary utility functions to update built-in properties. * * @param boolean $parse (Optional) Whether to parse the response with ResponseCore or not. * @return string The resulting unparsed data from the request. diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/ResponseCore.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/ResponseCore.php index 106d181c..90935615 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/ResponseCore.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/ResponseCore.php @@ -8,25 +8,25 @@ namespace OSS\Http; class ResponseCore { /** - * Stores the HTTP header information. + * Store the HTTP header information. */ public $header; /** - * Stores the SimpleXML response. + * Store the SimpleXML response. */ public $body; /** - * Stores the HTTP response code. + * Store the HTTP response code. */ public $status; /** - * Constructs a new instance of this class. + * Construct a new instance of this class. * * @param array $header (Required) Associative array of HTTP headers (typically returned by ). - * @param string $body (Required) XML-formatted response from AWS. + * @param string $body (Required) XML-formatted response from OSS. * @param integer $status (Optional) HTTP response status code from the request. * @return Mixed Contains an `header` property (HTTP headers as an associative array), a or `body` property, and an `status` code. */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php index 9b89674f..09e7deaf 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php @@ -4,7 +4,7 @@ namespace OSS\Model; /** - * Bucket信息,ListBuckets接口返回数据 + * Bucket information class. This is the type of element in BucketListInfo's * * Class BucketInfo * @package OSS\Model @@ -26,7 +26,7 @@ class BucketInfo } /** - * 得到bucket所在的region + * Get bucket location * * @return string */ @@ -36,7 +36,7 @@ class BucketInfo } /** - * 得到bucket的名称 + * Get bucket name * * @return string */ @@ -46,7 +46,7 @@ class BucketInfo } /** - * 得到bucket的创建时间 + * Get bucket creation time. * * @return string */ @@ -56,20 +56,20 @@ class BucketInfo } /** - * bucket所在的region + * bucket region * * @var string */ private $location; /** - * bucket的名称 + * bucket name * * @var string */ private $name; /** - * bucket的创建事件 + * bucket creation time * * @var string */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php index 910717f9..ce03a0d7 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php @@ -5,7 +5,7 @@ namespace OSS\Model; /** * Class BucketListInfo * - * ListBuckets接口返回的数据类型 + * It's the type of return value of ListBuckets. * * @package OSS\Model */ @@ -21,7 +21,7 @@ class BucketListInfo } /** - * 得到BucketInfo列表 + * Get the BucketInfo list * * @return BucketInfo[] */ @@ -31,7 +31,7 @@ class BucketListInfo } /** - * BucketInfo信息列表 + * BucketInfo list * * @var array */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php index c44c10a1..62a0d710 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php @@ -22,7 +22,7 @@ class CorsConfig implements XmlConfig } /** - * 得到CorsRule列表 + * Get CorsRule list * * @return CorsRule[] */ @@ -33,7 +33,7 @@ class CorsConfig implements XmlConfig /** - * 添加一条CorsRule + * Add a new CorsRule * * @param CorsRule $rule * @throws OssException @@ -47,7 +47,7 @@ class CorsConfig implements XmlConfig } /** - * 从xml数据中解析出CorsConfig + * Parse CorsConfig from the xml. * * @param string $strXml * @throws OssException @@ -78,7 +78,7 @@ class CorsConfig implements XmlConfig } /** - * 生成xml字符串 + * Serialize the object into xml string. * * @return string */ @@ -105,7 +105,7 @@ class CorsConfig implements XmlConfig const OSS_MAX_RULES = 10; /** - * orsRule列表 + * CorsRule list * * @var CorsRule[] */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php index 2cbe1c17..08353a0c 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php @@ -13,7 +13,7 @@ use OSS\Core\OssException; class CorsRule { /** - * Rule中增加一条allowedOrigin + * Add an allowedOrigin rule * * @param string $allowedOrigin */ @@ -25,7 +25,7 @@ class CorsRule } /** - * Rule中增加一条allowedMethod + * Add an allowedMethod rule * * @param string $allowedMethod */ @@ -37,7 +37,7 @@ class CorsRule } /** - * Rule中增加一条allowedHeader + * Add an allowedHeader rule * * @param string $allowedHeader */ @@ -49,7 +49,7 @@ class CorsRule } /** - * Rule中增加一条exposeHeader + * Add an exposeHeader rule * * @param string $exposeHeader */ @@ -77,7 +77,7 @@ class CorsRule } /** - * 得到AllowedHeaders列表 + * Get the AllowedHeaders list * * @return string[] */ @@ -87,7 +87,7 @@ class CorsRule } /** - * 得到AllowedOrigins列表 + * Get the AllowedOrigins list * * @return string[] */ @@ -97,7 +97,7 @@ class CorsRule } /** - * 得到AllowedMethods列表 + * Get the AllowedMethods list * * @return string[] */ @@ -107,7 +107,7 @@ class CorsRule } /** - * 得到ExposeHeaders列表 + * Get the ExposeHeaders list * * @return string[] */ @@ -117,7 +117,7 @@ class CorsRule } /** - * 根据提供的xmlRule, 把this按照一定的规则插入到$xmlRule中 + * Serialize all the rules into the xml represented by parameter $xmlRule * * @param \SimpleXMLElement $xmlRule * @throws OssException diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php index 5abd825d..a0e21269 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php @@ -71,7 +71,7 @@ class LifecycleAction } /** - * appendToXml 把actions插入到xml中 + * Use appendToXml to insert actions into xml. * * @param \SimpleXMLElement $xmlRule */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php index fc4f5755..f2d2dc33 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php @@ -13,7 +13,7 @@ use OSS\Core\OssException; class LifecycleConfig implements XmlConfig { /** - * 从xml数据中解析出LifecycleConfig + * Parse the xml into this object. * * @param string $strXml * @throws OssException @@ -48,7 +48,7 @@ class LifecycleConfig implements XmlConfig /** - * 生成xml字符串 + * Serialize the object to xml * * @return string */ @@ -65,7 +65,7 @@ class LifecycleConfig implements XmlConfig /** * - * 添加LifecycleRule + * Add a LifecycleRule * * @param LifecycleRule $lifecycleRule * @throws OssException @@ -79,7 +79,7 @@ class LifecycleConfig implements XmlConfig } /** - * 将配置转换成字符串,便于用户查看 + * Serialize the object into xml string. * * @return string */ @@ -89,7 +89,7 @@ class LifecycleConfig implements XmlConfig } /** - * 得到所有的生命周期规则 + * Get all lifecycle rules. * * @return LifecycleRule[] */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php index ec615b9a..73c6cc35 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php @@ -12,7 +12,7 @@ namespace OSS\Model; class LifecycleRule { /** - * 得到规则ID + * Get Id * * @return string */ @@ -22,7 +22,7 @@ class LifecycleRule } /** - * @param string $id 规则ID + * @param string $id Rule Id */ public function setId($id) { @@ -30,7 +30,7 @@ class LifecycleRule } /** - * 得到文件前缀 + * Get a file prefix * * @return string */ @@ -40,9 +40,9 @@ class LifecycleRule } /** - * 设置文件前缀 + * Set a file prefix * - * @param string $prefix 文件前缀 + * @param string $prefix The file prefix */ public function setPrefix($prefix) { @@ -50,7 +50,7 @@ class LifecycleRule } /** - * Lifecycle规则的状态 + * Get Lifecycle status * * @return string */ @@ -60,7 +60,7 @@ class LifecycleRule } /** - * 设置Lifecycle规则状态 + * Set Lifecycle status * * @param string $status */ @@ -90,9 +90,9 @@ class LifecycleRule /** * LifecycleRule constructor. * - * @param string $id 规则ID - * @param string $prefix 文件前缀 - * @param string $status 规则状态,可选[self::LIFECYCLE_STATUS_ENABLED, self::LIFECYCLE_STATUS_DISABLED] + * @param string $id rule Id + * @param string $prefix File prefix + * @param string $status Rule status, which has the following valid values: [self::LIFECYCLE_STATUS_ENABLED, self::LIFECYCLE_STATUS_DISABLED] * @param LifecycleAction[] $actions */ public function __construct($id, $prefix, $status, $actions) diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelListInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelListInfo.php index bb5093aa..f4ee02f6 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelListInfo.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelListInfo.php @@ -5,7 +5,7 @@ namespace OSS\Model; /** * Class LiveChannelListInfo * - * ListBucketLiveChannels接口返回数据 + * The data returned by ListBucketLiveChannels * * @package OSS\Model * @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/GetBucket.html diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php index 978421a2..ed9fb1db 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php @@ -42,7 +42,7 @@ class LoggingConfig implements XmlConfig } /** - * 序列化成xml字符串 + * Serialize to xml string * */ public function serializeToXml() diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php index 2ae6c99b..891f8625 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php @@ -6,11 +6,11 @@ namespace OSS\Model; * * Class ObjectInfo * - * listObjects接口中返回的Object列表中的类 + * The element type of ObjectListInfo, which is the return value type of listObjects * - * listObjects接口返回数据中包含两个Array - * 一个是拿到的Object列表【可以理解成对应文件系统中的文件列表】 - * 一个是拿到的Prefix列表【可以理解成对应文件系统中的目录列表】 + * The return value of listObjects includes two arrays + * One is the returned ObjectListInfo, which is similar to a file list in a file system. + * The other is the returned prefix list, which is similar to a folder list in a file system. * * @package OSS\Model */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php index dbe7c7a7..81c5d27b 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php @@ -5,7 +5,7 @@ namespace OSS\Model; /** * Class ObjectListInfo * - * ListObjects接口返回数据 + * The class of return value of ListObjects * * @package OSS\Model * @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/GetBucket.html @@ -87,7 +87,7 @@ class ObjectListInfo } /** - * 返回ListObjects接口返回数据中的ObjectInfo列表 + * Get the ObjectInfo list. * * @return ObjectInfo[] */ @@ -97,7 +97,7 @@ class ObjectListInfo } /** - * 返回ListObjects接口返回数据中的PrefixInfo列表 + * Get the PrefixInfo list * * @return PrefixInfo[] */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php index e61eac44..27920b9f 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php @@ -5,10 +5,10 @@ namespace OSS\Model; /** * Class PrefixInfo * - * listObjects接口中返回的Prefix列表中的类 - * listObjects接口返回数据中包含两个Array: - * 一个是拿到的Object列表【可以理解成对应文件系统中的文件列表】 - * 一个是拿到的Prefix列表【可以理解成对应文件系统中的目录列表】 + * ListObjects return Prefix list of classes + * The returned data contains two arrays + * One is to get the list of objects【Can be understood as the corresponding file system file list】 + * One is to get Prefix list【Can be understood as the corresponding file system directory list】 * * @package OSS\Model * @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/GetBucket.html diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php index 1d7d975c..08301439 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php @@ -29,7 +29,7 @@ class RefererConfig implements XmlConfig /** - * 把RefererConfig序列化成xml + * serialize the RefererConfig object into xml string * * @return string */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/StorageCapacityConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/StorageCapacityConfig.php index 05e6332c..024b5c95 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/StorageCapacityConfig.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/StorageCapacityConfig.php @@ -29,7 +29,7 @@ class StorageCapacityConfig implements XmlConfig } /** - * 把StorageCapacityConfig序列化成xml + * Serialize StorageCapacityConfig into xml * * @return string */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php index 8eaa3639..49aa414e 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php @@ -5,7 +5,7 @@ namespace OSS\Model; /** * Class UploadInfo * - * ListMultipartUpload接口得到的UploadInfo + * The return value of ListMultipartUpload * * @package OSS\Model */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php index 8ea08a03..e298eb46 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php @@ -40,7 +40,7 @@ class WebsiteConfig implements XmlConfig } /** - * 把WebsiteConfig序列化成xml + * Serialize the WebsiteConfig object into xml string. * * @return string * @throws OssException diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php index d353a222..8c0a0db1 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php @@ -10,7 +10,7 @@ interface XmlConfig { /** - * 接口定义,实现此接口的类都需要实现从xml数据解析的函数 + * Interface method: Parse the object from the xml. * * @param string $strXml * @return null @@ -18,7 +18,7 @@ interface XmlConfig public function parseFromXml($strXml); /** - * 接口定义,实现此接口的类,都需要实现把子类序列化成xml字符串的接口 + * Interface method: Serialize the object into xml. * * @return string */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/OssClient.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/OssClient.php index 1c090d3d..daae42c7 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/OssClient.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/OssClient.php @@ -17,11 +17,12 @@ use OSS\Result\AclResult; use OSS\Result\BodyResult; use OSS\Result\GetCorsResult; use OSS\Result\GetLifecycleResult; +use OSS\Result\GetLocationResult; use OSS\Result\GetLoggingResult; use OSS\Result\GetRefererResult; +use OSS\Result\GetStorageCapacityResult; use OSS\Result\GetWebsiteResult; use OSS\Result\GetCnameResult; -use OSS\Result\GetLocationResult; use OSS\Result\HeaderResult; use OSS\Result\InitiateMultipartUploadResult; use OSS\Result\ListBucketsResult; @@ -39,9 +40,9 @@ use OSS\Result\GetLiveChannelHistoryResult; use OSS\Result\GetLiveChannelInfoResult; use OSS\Result\GetLiveChannelStatusResult; use OSS\Result\ListLiveChannelResult; -use OSS\Result\GetStorageCapacityResult; use OSS\Result\AppendResult; use OSS\Model\ObjectListInfo; +use OSS\Result\SymlinkResult; use OSS\Result\UploadPartResult; use OSS\Model\BucketListInfo; use OSS\Model\LifecycleConfig; @@ -49,35 +50,33 @@ use OSS\Model\RefererConfig; use OSS\Model\WebsiteConfig; use OSS\Core\OssUtil; use OSS\Model\ListPartsInfo; -use OSS\Result\SymlinkResult; /** * Class OssClient * - * Object Storage Service(OSS) 的客户端类,封装了用户通过OSS API对OSS服务的各种操作, - * 用户通过OssClient实例可以进行Bucket,Object,MultipartUpload, ACL等操作,具体 - * 的接口规则可以参考官方OSS API文档 + * Object Storage Service(OSS)'s client class, which wraps all OSS APIs user could call to talk to OSS. + * Users could do operations on bucket, object, including MultipartUpload or setting ACL via an OSSClient instance. + * For more details, please check out the OSS API document:https://www.alibabacloud.com/help/doc-detail/31947.htm */ class OssClient { /** - * 构造函数 + * Constructor * - * 构造函数有几种情况: - * 1. 一般的时候初始化使用 $ossClient = new OssClient($id, $key, $endpoint) - * 2. 如果使用CNAME的,比如使用的是www.testoss.com,在控制台上做了CNAME的绑定, - * 初始化使用 $ossClient = new OssClient($id, $key, $endpoint, true) - * 3. 如果使用了阿里云SecurityTokenService(STS),获得了AccessKeyID, AccessKeySecret, Token - * 初始化使用 $ossClient = new OssClient($id, $key, $endpoint, false, $token) - * 4. 如果用户使用的endpoint是ip - * 初始化使用 $ossClient = new OssClient($id, $key, “1.2.3.4:8900”) + * There're a few different ways to create an OssClient object: + * 1. Most common one from access Id, access Key and the endpoint: $ossClient = new OssClient($id, $key, $endpoint) + * 2. If the endpoint is the CName (such as www.testoss.com, make sure it's CName binded in the OSS console), + * uses $ossClient = new OssClient($id, $key, $endpoint, true) + * 3. If using Alicloud's security token service (STS), then the AccessKeyId, AccessKeySecret and STS token are all got from STS. + * Use this: $ossClient = new OssClient($id, $key, $endpoint, false, $token) + * 4. If the endpoint is in IP format, you could use this: $ossClient = new OssClient($id, $key, “1.2.3.4:8900”) * - * @param string $accessKeyId 从OSS获得的AccessKeyId - * @param string $accessKeySecret 从OSS获得的AccessKeySecret - * @param string $endpoint 您选定的OSS数据中心访问域名,例如oss-cn-hangzhou.aliyuncs.com - * @param boolean $isCName 是否对Bucket做了域名绑定,并且Endpoint参数填写的是自己的域名 - * @param string $securityToken - * @param string $requestProxy 添加代理支持 + * @param string $accessKeyId The AccessKeyId from OSS or STS + * @param string $accessKeySecret The AccessKeySecret from OSS or STS + * @param string $endpoint The domain name of the datacenter,For example: oss-cn-hangzhou.aliyuncs.com + * @param boolean $isCName If this is the CName and binded in the bucket. + * @param string $securityToken from STS. + * @param string $requestProxy * @throws OssException */ public function __construct($accessKeyId, $accessKeySecret, $endpoint, $isCName = false, $securityToken = NULL, $requestProxy = NULL) @@ -100,12 +99,11 @@ class OssClient $this->accessKeySecret = $accessKeySecret; $this->securityToken = $securityToken; $this->requestProxy = $requestProxy; - self::checkEnv(); } /** - * 列举用户所有的Bucket[GetService], Endpoint类型为cname不能进行此操作 + * Lists the Bucket [GetService]. Not applicable if the endpoint is CName (because CName must be binded to a specific bucket). * * @param array $options * @throws OssException @@ -126,7 +124,7 @@ class OssClient } /** - * 创建bucket,默认创建的bucket的ACL是OssClient::OSS_ACL_TYPE_PRIVATE + * Creates bucket,The ACL of the bucket created by default is OssClient::OSS_ACL_TYPE_PRIVATE * * @param string $bucket * @param string $acl @@ -152,9 +150,9 @@ class OssClient } /** - * 删除bucket - * 如果Bucket不为空(Bucket中有Object,或者有分块上传的碎片),则Bucket无法删除, - * 必须删除Bucket中的所有Object以及碎片后,Bucket才能成功删除。 + * Deletes bucket + * The deletion will not succeed if the bucket is not empty (either has objects or parts) + * To delete a bucket, all its objects and parts must be deleted first. * * @param string $bucket * @param array $options @@ -172,7 +170,7 @@ class OssClient } /** - * 判断bucket是否存在 + * Checks if a bucket exists * * @param string $bucket * @return bool @@ -189,9 +187,9 @@ class OssClient $result = new ExistResult($response); return $result->getData(); } - + /** - * 获取bucket所属的数据中心位置信息 + * Get the data center location information for the bucket * * @param string $bucket * @param array $options @@ -209,27 +207,27 @@ class OssClient $result = new GetLocationResult($response); return $result->getData(); } - + /** - * 获取Bucket的Meta信息 + * Get the Meta information for the Bucket * * @param string $bucket - * @param array $options 具体参考SDK文档 + * @param array $options Refer to the SDK documentation * @return array */ public function getBucketMeta($bucket, $options = NULL) { - $this->precheckCommon($bucket, NULL, $options, false); - $options[self::OSS_BUCKET] = $bucket; - $options[self::OSS_METHOD] = self::OSS_HTTP_HEAD; - $options[self::OSS_OBJECT] = '/'; - $response = $this->auth($options); - $result = new HeaderResult($response); - return $result->getData(); + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_HEAD; + $options[self::OSS_OBJECT] = '/'; + $response = $this->auth($options); + $result = new HeaderResult($response); + return $result->getData(); } /** - * 获取bucket的ACL配置情况 + * Gets the bucket ACL * * @param string $bucket * @param array $options @@ -249,11 +247,11 @@ class OssClient } /** - * 设置bucket的ACL配置情况 + * Sets the bucket ACL * - * @param string $bucket bucket名称 - * @param string $acl 读写权限,可选值 ['private', 'public-read', 'public-read-write'] - * @param array $options 可以为空 + * @param string $bucket bucket name + * @param string $acl access permissions, valid values are ['private', 'public-read', 'public-read-write'] + * @param array $options by default is empty * @throws OssException * @return null */ @@ -271,7 +269,7 @@ class OssClient } /** - * 获取object的ACL属性 + * Gets object ACL * * @param string $bucket * @param string $object @@ -292,11 +290,11 @@ class OssClient } /** - * 设置object的ACL属性 + * Sets the object ACL * - * @param string $bucket bucket名称 - * @param string $object object名称 - * @param string $acl 读写权限,可选值 ['default', 'private', 'public-read', 'public-read-write'] + * @param string $bucket bucket name + * @param string $object object name + * @param string $acl access permissions, valid values are ['default', 'private', 'public-read', 'public-read-write'] * @throws OssException * @return null */ @@ -314,10 +312,10 @@ class OssClient } /** - * 获取Bucket的访问日志配置情况 + * Gets the bucket logging config * - * @param string $bucket bucket名称 - * @param array $options 可以为空 + * @param string $bucket bucket name + * @param array $options by default is empty * @throws OssException * @return LoggingConfig */ @@ -334,12 +332,12 @@ class OssClient } /** - * 开启Bucket访问日志记录功能,只有Bucket的所有者才能更改 + * Sets the bycket logging config. Only owner can call this API. * - * @param string $bucket bucket名称 - * @param string $targetBucket 日志文件存放的bucket - * @param string $targetPrefix 日志的文件前缀 - * @param array $options 可以为空 + * @param string $bucket bucket name + * @param string $targetBucket The logging file's bucket + * @param string $targetPrefix The logging file's prefix + * @param array $options By default is empty. * @throws OssException * @return null */ @@ -361,10 +359,10 @@ class OssClient } /** - * 关闭bucket访问日志记录功能 + * Deletes the bucket logging config * - * @param string $bucket bucket名称 - * @param array $options 可以为空 + * @param string $bucket bucket name + * @param array $options * @throws OssException * @return null */ @@ -381,11 +379,11 @@ class OssClient } /** - * 将bucket设置成静态网站托管模式 + * Sets the website config in bucket---that is could make the bucket as a static website once the CName is binded. * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param WebsiteConfig $websiteConfig - * @param array $options 可以为空 + * @param array $options * @throws OssException * @return null */ @@ -404,9 +402,9 @@ class OssClient } /** - * 获取bucket的静态网站托管状态 + * Gets the website config in the bucket * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param array $options * @throws OssException * @return WebsiteConfig @@ -424,9 +422,9 @@ class OssClient } /** - * 关闭bucket的静态网站托管模式 + * Deletes the website config in the bucket * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param array $options * @throws OssException * @return null @@ -444,10 +442,10 @@ class OssClient } /** - * 在指定的bucket上设定一个跨域资源共享(CORS)的规则,如果原规则存在则覆盖原规则 + * Sets the cross-origin-resource-sharing (CORS) rule. It would overwrite the originl one. * - * @param string $bucket bucket名称 - * @param CorsConfig $corsConfig 跨域资源共享配置,具体规则参见SDK文档 + * @param string $bucket bucket name + * @param CorsConfig $corsConfig CORS config. Check out the details from OSS API document * @param array $options array * @throws OssException * @return null @@ -467,10 +465,10 @@ class OssClient } /** - * 获取Bucket的CORS配置情况 + * Gets the bucket CORS config * - * @param string $bucket bucket名称 - * @param array $options 可以为空 + * @param string $bucket bucket name + * @param array $options * @throws OssException * @return CorsConfig */ @@ -487,9 +485,9 @@ class OssClient } /** - * 关闭指定Bucket对应的CORS功能并清空所有规则 + * Deletes the bucket's CORS config and disable the CORS on the bucket. * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param array $options * @throws OssException * @return null @@ -507,9 +505,9 @@ class OssClient } /** - * 为指定Bucket增加CNAME绑定 + * Bind a CName for the bucket * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param string $cname * @param array $options * @throws OssException @@ -534,9 +532,9 @@ class OssClient } /** - * 获取指定Bucket已绑定的CNAME列表 + * Gets the binded CName list of the bucket * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param array $options * @throws OssException * @return CnameConfig @@ -554,9 +552,9 @@ class OssClient } /** - * 解除指定Bucket的CNAME绑定 + * Remove a CName binding from the bucket * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param CnameConfig $cnameConfig * @param array $options * @throws OssException @@ -581,9 +579,9 @@ class OssClient } /** - * 为指定Bucket创建LiveChannel + * Creates a Live Channel under a bucket * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param string channelName $channelName * @param LiveChannelConfig $channelConfig * @param array $options @@ -610,11 +608,11 @@ class OssClient } /** - * 设置LiveChannel的status + * Sets the LiveChannel status * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param string channelName $channelName - * @param string channelStatus $channelStatus 为enabled或disabled + * @param string channelStatus $channelStatus enabled or disabled * @param array $options * @throws OssException * @return null @@ -634,9 +632,9 @@ class OssClient } /** - * 获取LiveChannel信息 + * Gets the LiveChannel information by the channel name * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param string channelName $channelName * @param array $options * @throws OssException @@ -656,9 +654,9 @@ class OssClient } /** - * 获取LiveChannel状态信息 + * Gets the status of LiveChannel * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param string channelName $channelName * @param array $options * @throws OssException @@ -679,9 +677,9 @@ class OssClient } /** - *获取LiveChannel推流记录 + * Gets the LiveChannel pushing streaming record * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param string channelName $channelName * @param array $options * @throws OssException @@ -702,9 +700,9 @@ class OssClient } /** - *获取指定Bucket下的live channel列表 + *Gets the live channel list under a bucket. * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param array $options * @throws OssException * @return LiveChannelListInfo @@ -730,12 +728,12 @@ class OssClient } /** - * 为指定LiveChannel生成播放列表 + * Creates a play list file for the LiveChannel * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param string channelName $channelName - * @param string $playlistName 指定生成的点播播放列表的名称,必须以“.m3u8”结尾 - * @param array $setTime startTime和EndTime以unix时间戳格式给定,跨度不能超过一天 + * @param string $playlistName The playlist name, must end with ".m3u8". + * @param array $setTime startTime and EndTime in unix time. No more than 1 day. * @throws OssException * @return null */ @@ -755,9 +753,9 @@ class OssClient } /** - * 删除指定Bucket的LiveChannel + * Deletes the Bucket LiveChannel * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param string channelName $channelName * @param array $options * @throws OssException @@ -777,14 +775,14 @@ class OssClient } /** - * 生成带签名的推流地址 + * Generates the signed pushing streaming url * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param string channelName $channelName - * @param int timeout 设置超时时间,单位为秒 + * @param int timeout timeout value in seconds * @param array $options * @throws OssException - * @return 推流地址 + * @return The signed pushing streaming url */ public function signRtmpUrl($bucket, $channelName, $timeout = 60, $options = NULL) { @@ -813,16 +811,16 @@ class OssClient } /** - * 检验跨域资源请求, 发送跨域请求之前会发送一个preflight请求(OPTIONS)并带上特定的来源域, - * HTTP方法和header信息等给OSS以决定是否发送真正的请求。 OSS可以通过putBucketCors接口 - * 来开启Bucket的CORS支持,开启CORS功能之后,OSS在收到浏览器preflight请求时会根据设定的 - * 规则评估是否允许本次请求 + * Precheck the CORS request. Before sending a CORS request, a preflight request (OPTIONS) is sent with the specific origin. + * HTTP METHOD and headers information are sent to OSS as well for evaluating if the CORS request is allowed. + * + * Note: OSS could enable the CORS on the bucket by calling putBucketCors. Once CORS is enabled, the OSS could evaluate accordingto the preflight request. * - * @param string $bucket bucket名称 - * @param string $object object名称 - * @param string $origin 请求来源域 - * @param string $request_method 表明实际请求中会使用的HTTP方法 - * @param string $request_headers 表明实际请求中会使用的除了简单头部之外的headers + * @param string $bucket bucket name + * @param string $object object name + * @param string $origin the origin of the request + * @param string $request_method The actual HTTP method which will be used in CORS request + * @param string $request_headers The actual HTTP headers which will be used in CORS request * @param array $options * @return array * @throws OssException @@ -845,10 +843,10 @@ class OssClient } /** - * 设置Bucket的Lifecycle配置 + * Sets the bucket's lifecycle config * - * @param string $bucket bucket名称 - * @param LifecycleConfig $lifecycleConfig Lifecycle配置类 + * @param string $bucket bucket name + * @param LifecycleConfig $lifecycleConfig LifecycleConfig instance * @param array $options * @throws OssException * @return null @@ -868,9 +866,9 @@ class OssClient } /** - * 获取Bucket的Lifecycle配置情况 + * Gets bucket's lifecycle config * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param array $options * @throws OssException * @return LifecycleConfig @@ -888,9 +886,9 @@ class OssClient } /** - * 删除指定Bucket的生命周期配置 + * Deletes the bucket's lifecycle config * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param array $options * @throws OssException * @return null @@ -908,10 +906,10 @@ class OssClient } /** - * 设置一个bucket的referer访问白名单和是否允许referer字段为空的请求访问 - * Bucket Referer防盗链具体见OSS防盗链 + * Sets a bucket's referer, which has a whitelist of referrer and specifies if empty referer is allowed. + * Checks out API document for more details about "Bucket Referer" * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param RefererConfig $refererConfig * @param array $options * @return ResponseCore @@ -932,10 +930,10 @@ class OssClient } /** - * 获取Bucket的Referer配置情况 - * Bucket Referer防盗链具体见OSS防盗链 + * Gets the bucket's Referer + * Checks out API document for more details about "Bucket Referer" * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param array $options * @throws OssException * @return RefererConfig @@ -951,12 +949,13 @@ class OssClient $result = new GetRefererResult($response); return $result->getData(); } - + + /** - * 设置bucket的容量大小,单位GB - * 当bucket的容量大于设置的容量时,禁止继续写入 + * Set the size of the bucket,the unit is GB + * When the capacity of the bucket is bigger than the set, it's forbidden to continue writing * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param int $storageCapacity * @param array $options * @return ResponseCore @@ -976,11 +975,11 @@ class OssClient $result = new PutSetDeleteResult($response); return $result->getData(); } - + /** - * 获取bucket的容量大小,单位GB + * Get the capacity of the bucket, the unit is GB * - * @param string $bucket bucket名称 + * @param string $bucket bucket name * @param array $options * @throws OssException * @return int @@ -997,19 +996,19 @@ class OssClient return $result->getData(); } + /** - * 获取bucket下的object列表 + * Lists the bucket's object list (in ObjectListInfo) * * @param string $bucket - * @param array $options - * 其中options中的参数如下 + * @param array $options are defined below: * $options = array( - * 'max-keys' => max-keys用于限定此次返回object的最大数,如果不设定,默认为100,max-keys取值不能大于1000。 - * 'prefix' => 限定返回的object key必须以prefix作为前缀。注意使用prefix查询时,返回的key中仍会包含prefix。 - * 'delimiter' => 是一个用于对Object名字进行分组的字符。所有名字包含指定的前缀且第一次出现delimiter字符之间的object作为一组元素 - * 'marker' => 用户设定结果从marker之后按字母排序的第一个开始返回。 + * 'max-keys' => specifies max object count to return. By default is 100 and max value could be 1000. + * 'prefix' => specifies the key prefix the returned objects must have. Note that the returned keys still contain the prefix. + * 'delimiter' => The delimiter of object name for grouping object. When it's specified, listObjects will differeniate the object and folder. And it will return subfolder's objects. + * 'marker' => The key of returned object must be greater than the 'marker'. *) - * 其中 prefix,marker用来实现分页显示效果,参数的长度必须小于256字节。 + * Prefix and marker are for filtering and paging. Their length must be less than 256 bytes * @throws OssException * @return ObjectListInfo */ @@ -1037,12 +1036,12 @@ class OssClient } /** - * 创建虚拟目录 (本函数会在object名称后增加'/', 所以创建目录的object名称不需要'/'结尾,否则,目录名称会变成'//') + * Creates a virtual 'folder' in OSS. The name should not end with '/' because the method will append the name with a '/' anyway. * - * 暂不开放此接口 + * Internal use only. * - * @param string $bucket bucket名称 - * @param string $object object名称 + * @param string $bucket bucket name + * @param string $object object name * @param array $options * @return null */ @@ -1059,11 +1058,11 @@ class OssClient } /** - * 上传内存中的内容 + * Uploads the $content object to OSS. * - * @param string $bucket bucket名称 - * @param string $object objcet名称 - * @param string $content 上传的内容 + * @param string $bucket bucket name + * @param string $object objcet name + * @param string $content The content object * @param array $options * @return null */ @@ -1102,11 +1101,12 @@ class OssClient return $result->getData(); } + /** - * 创建symlink - * @param string $bucket bucket名称 - * @param string $symlink symlink名称 - * @param string $targetObject 目标object名称 + * creates symlink + * @param string $bucket bucket name + * @param string $symlink symlink name + * @param string $targetObject targetObject name * @param array $options * @return null */ @@ -1126,9 +1126,9 @@ class OssClient } /** - * 获取symlink - *@param string $bucket bucket名称 - * @param string $symlink symlink名称 + * gets symlink + *@param string $bucket bucket name + * @param string $symlink symlink name * @return null */ public function getSymlink($bucket, $symlink) @@ -1146,11 +1146,11 @@ class OssClient } /** - * 上传本地文件 + * Uploads a local file * - * @param string $bucket bucket名称 - * @param string $object object名称 - * @param string $file 本地文件路径 + * @param string $bucket bucket name + * @param string $object object name + * @param string $file local file path * @param array $options * @return null * @throws OssException @@ -1183,11 +1183,11 @@ class OssClient } /** - * 追加上传内存中的内容 - * - * @param string $bucket bucket名称 - * @param string $object objcet名称 - * @param string $content 本次追加上传的内容 + * Append the object with the content at the specified position. + * The specified position is typically the lengh of the current file. + * @param string $bucket bucket name + * @param string $object objcet name + * @param string $content content to append * @param array $options * @return int next append position * @throws OssException @@ -1224,11 +1224,11 @@ class OssClient } /** - * 追加上传本地文件 + * Append the object with a local file * - * @param string $bucket bucket名称 - * @param string $object object名称 - * @param string $file 追加上传的本地文件路径 + * @param string $bucket bucket name + * @param string $object object name + * @param string $file The local file path to append with * @param array $options * @return int next append position * @throws OssException @@ -1266,12 +1266,12 @@ class OssClient } /** - * 拷贝一个在OSS上已经存在的object成另外一个object + * Copy from an existing OSS object to another OSS object. If the target object exists already, it will be overwritten. * - * @param string $fromBucket 源bucket名称 - * @param string $fromObject 源object名称 - * @param string $toBucket 目标bucket名称 - * @param string $toObject 目标object名称 + * @param string $fromBucket Source bucket name + * @param string $fromObject Source object name + * @param string $toBucket Target bucket name + * @param string $toObject Target object name * @param array $options * @return null * @throws OssException @@ -1294,11 +1294,11 @@ class OssClient } /** - * 获取Object的Meta信息 + * Gets Object metadata * - * @param string $bucket bucket名称 - * @param string $object object名称 - * @param string $options 具体参考SDK文档 + * @param string $bucket bucket name + * @param string $object object name + * @param string $options Checks out the SDK document for the detail * @return array */ public function getObjectMeta($bucket, $object, $options = NULL) @@ -1313,10 +1313,10 @@ class OssClient } /** - * 删除某个Object + * Deletes a object * - * @param string $bucket bucket名称 - * @param string $object object名称 + * @param string $bucket bucket name + * @param string $object object name * @param array $options * @return null */ @@ -1332,10 +1332,10 @@ class OssClient } /** - * 删除同一个Bucket中的多个Object + * Deletes multiple objects in a bucket * - * @param string $bucket bucket名称 - * @param array $objects object列表 + * @param string $bucket bucket name + * @param array $objects object list * @param array $options * @return ResponseCore * @throws null @@ -1367,11 +1367,11 @@ class OssClient } /** - * 获得Object内容 + * Gets Object content * - * @param string $bucket bucket名称 - * @param string $object object名称 - * @param array $options 该参数中必须设置ALIOSS::OSS_FILE_DOWNLOAD,ALIOSS::OSS_RANGE可选,可以根据实际情况设置;如果不设置,默认会下载全部内容 + * @param string $bucket bucket name + * @param string $object object name + * @param array $options It must contain ALIOSS::OSS_FILE_DOWNLOAD. And ALIOSS::OSS_RANGE is optional and empty means to download the whole file. * @return string */ public function getObject($bucket, $object, $options = NULL) @@ -1399,13 +1399,13 @@ class OssClient } /** - * 检测Object是否存在 - * 通过获取Object的Meta信息来判断Object是否存在, 用户需要自行解析ResponseCore判断object是否存在 + * Checks if the object exists + * It's implemented by getObjectMeta(). * - * @param string $bucket bucket名称 - * @param string $object object名称 + * @param string $bucket bucket name + * @param string $object object name * @param array $options - * @return bool + * @return bool True:object exists; False:object does not exist */ public function doesObjectExist($bucket, $object, $options = NULL) { @@ -1419,11 +1419,11 @@ class OssClient } /** - * 针对Archive类型的Object读取 - * 需要使用Restore操作让服务端执行解冻任务 + * Object reading for Archive type + * Use Restore to enable the server to perform the thawing task * - * @param string $bucket bucket名称 - * @param string $object object名称 + * @param string $bucket bucket name + * @param string $object object name * @return null * @throws OssException */ @@ -1440,8 +1440,9 @@ class OssClient } /** - * 获取分片大小,根据用户提供的part_size,重新计算一个更合理的partsize - * + * Gets the part size according to the preferred part size. + * If the specified part size is too small or too big, it will return a min part or max part size instead. + * Otherwise returns the specified part size. * @param int $partSize * @return int */ @@ -1457,12 +1458,12 @@ class OssClient } /** - * 计算文件可以分成多少个part,以及每个part的长度以及起始位置 - * 方法必须在 中调用 + * Computes the parts count, size and start position according to the file size and the part size. + * It must be only called by upload_Part(). * - * @param integer $file_size 文件大小 - * @param integer $partSize part大小,默认5M - * @return array An array 包含 key-value 键值对. Key 为 `seekTo` 和 `length`. + * @param integer $file_size File size + * @param integer $partSize part大小,part size. Default is 5MB + * @return array An array contains key-value pairs--the key is `seekTo`and value is `length`. */ public function generateMultiuploadParts($file_size, $partSize = 5242880) { @@ -1482,13 +1483,13 @@ class OssClient } /** - * 初始化multi-part upload + * Initialize a multi-part upload * - * @param string $bucket Bucket名称 - * @param string $object Object名称 - * @param array $options Key-Value数组 + * @param string $bucket bucket name + * @param string $object object name + * @param array $options Key-Value array * @throws OssException - * @return string 返回uploadid + * @return string returns uploadid */ public function initiateMultipartUpload($bucket, $object, $options = NULL) { @@ -1511,12 +1512,12 @@ class OssClient } /** - * 分片上传的块上传接口 + * Upload a part in a multiparts upload. * - * @param string $bucket Bucket名称 - * @param string $object Object名称 + * @param string $bucket bucket name + * @param string $object object name * @param string $uploadId - * @param array $options Key-Value数组 + * @param array $options Key-Value array * @return string eTag * @throws OssException */ @@ -1540,12 +1541,12 @@ class OssClient } /** - * 获取已成功上传的part + * Gets the uploaded parts. * - * @param string $bucket Bucket名称 - * @param string $object Object名称 + * @param string $bucket bucket name + * @param string $object object name * @param string $uploadId uploadId - * @param array $options Key-Value数组 + * @param array $options Key-Value array * @return ListPartsInfo * @throws OssException */ @@ -1569,12 +1570,12 @@ class OssClient } /** - * 中止进行一半的分片上传操作 + * Abort a multiparts upload * - * @param string $bucket Bucket名称 - * @param string $object Object名称 + * @param string $bucket bucket name + * @param string $object object name * @param string $uploadId uploadId - * @param array $options Key-Value数组 + * @param array $options Key-Value name * @return null * @throws OssException */ @@ -1591,13 +1592,13 @@ class OssClient } /** - * 在将所有数据Part都上传完成后,调用此接口完成本次分块上传 + * Completes a multiparts upload, after all parts are uploaded. * - * @param string $bucket Bucket名称 - * @param string $object Object名称 + * @param string $bucket bucket name + * @param string $object object name * @param string $uploadId uploadId * @param array $listParts array( array("PartNumber"=> int, "ETag"=>string)) - * @param array $options Key-Value数组 + * @param array $options Key-Value array * @throws OssException * @return null */ @@ -1623,11 +1624,10 @@ class OssClient } /** - * 罗列出所有执行中的Multipart Upload事件,即已经被初始化的Multipart Upload但是未被 - * Complete或者Abort的Multipart Upload事件 + * Lists all ongoing multipart upload events, which means all initialized but not completed or aborted multipart uploads. * * @param string $bucket bucket - * @param array $options 关联数组 + * @param array $options key-value array--expected keys are 'delimiter', 'key-marker', 'max-uploads', 'prefix', 'upload-id-marker' * @throws OssException * @return ListMultipartUploadInfo */ @@ -1657,15 +1657,15 @@ class OssClient } /** - * 从一个已存在的Object中拷贝数据来上传一个Part + * Copy an existing file as a part * - * @param string $fromBucket 源bucket名称 - * @param string $fromObject 源object名称 - * @param string $toBucket 目标bucket名称 - * @param string $toObject 目标object名称 - * @param int $partNumber 分块上传的块id - * @param string $uploadId 初始化multipart upload返回的uploadid - * @param array $options Key-Value数组 + * @param string $fromBucket source bucket name + * @param string $fromObject source object name + * @param string $toBucket target bucket name + * @param string $toObject target object name + * @param int $partNumber Part number + * @param string $uploadId Upload Id + * @param array $options Key-Value array---it should have 'start' or 'end' key to specify the range of the source object to copy. If it's not specifed, the whole object is copied. * @return null * @throws OssException */ @@ -1674,7 +1674,7 @@ class OssClient $this->precheckCommon($fromBucket, $fromObject, $options); $this->precheckCommon($toBucket, $toObject, $options); - //如果没有设置$options['isFullCopy'],则需要强制判断copy的起止位置 + //If $options['isFullCopy'] is not set, copy from the beginning $start_range = "0"; if (isset($options['start'])) { $start_range = $options['start']; @@ -1701,12 +1701,12 @@ class OssClient } /** - * multipart上传统一封装,从初始化到完成multipart,以及出错后中止动作 + * A higher level API for uploading a file with multipart upload. It consists of initialization, parts upload and completion. * - * @param string $bucket bucket名称 - * @param string $object object名称 - * @param string $file 需要上传的本地文件的路径 - * @param array $options Key-Value数组 + * @param string $bucket bucket name + * @param string $object object name + * @param string $file The local file to upload + * @param array $options Key-Value array * @return null * @throws OssException */ @@ -1739,7 +1739,7 @@ class OssClient if ($upload_position === false || !isset($upload_file_size) || $upload_file_size === false || $upload_file_size < 0) { throw new OssException('The size of `fileUpload` cannot be determined in ' . __FUNCTION__ . '().'); } - // 处理partSize + // Computes the part size and assign it to options. if (isset($options[self::OSS_PART_SIZE])) { $options[self::OSS_PART_SIZE] = $this->computePartSize($options[self::OSS_PART_SIZE]); } else { @@ -1747,20 +1747,20 @@ class OssClient } $is_check_md5 = $this->isCheckMD5($options); - // 如果上传的文件小于partSize,则直接使用普通方式上传 + // if the file size is less than part size, use simple file upload. if ($upload_file_size < $options[self::OSS_PART_SIZE] && !isset($options[self::OSS_UPLOAD_ID])) { return $this->uploadFile($bucket, $object, $uploadFile, $options); } - // 初始化multipart + // Using multipart upload, initialize if no OSS_UPLOAD_ID is specified in options. if (isset($options[self::OSS_UPLOAD_ID])) { $uploadId = $options[self::OSS_UPLOAD_ID]; } else { - // 初始化 + // initialize $uploadId = $this->initiateMultipartUpload($bucket, $object, $options); } - // 获取的分片 + // generates the parts information and upload them one by one $pieces = $this->generateMultiuploadParts($upload_file_size, (integer)$options[self::OSS_PART_SIZE]); $response_upload_part = array(); foreach ($pieces as $i => $piece) { @@ -1791,15 +1791,15 @@ class OssClient } /** - * 上传本地目录内的文件或者目录到指定bucket的指定prefix的object中 + * Uploads the local directory to the specified bucket into specified folder (prefix) * - * @param string $bucket bucket名称 - * @param string $prefix 需要上传到的object的key前缀,可以理解成bucket中的子目录,结尾不能是'/',接口中会补充'/' - * @param string $localDirectory 需要上传的本地目录 - * @param string $exclude 需要排除的目录 - * @param bool $recursive 是否递归的上传localDirectory下的子目录内容 + * @param string $bucket bucket name + * @param string $prefix The object key prefix. Typically it's folder name. The name should not end with '/' as the API appends it automatically. + * @param string $localDirectory The local directory to upload + * @param string $exclude To excluded directories + * @param bool $recursive Recursive flag. True: Recursively upload all datas under the local directory; False: only upload first layer's files. * @param bool $checkMd5 - * @return array 返回两个列表 array("succeededList" => array("object"), "failedList" => array("object"=>"errorMessage")) + * @return array Returns two list: array("succeededList" => array("object"), "failedList" => array("object"=>"errorMessage")) * @throws OssException */ public function uploadDir($bucket, $prefix, $localDirectory, $exclude = '.|..|.svn|.git', $recursive = false, $checkMd5 = true) @@ -1810,7 +1810,7 @@ class OssClient if (empty($localDirectory)) throw new OssException("parameter error, localDirectory is empty"); $directory = $localDirectory; $directory = OssUtil::encodePath($directory); - //判断是否目录 + //If it's not the local directory, throw OSSException. if (!is_dir($directory)) { throw new OssException('parameter error: ' . $directory . ' is not a directory, please check it'); } @@ -1840,14 +1840,14 @@ class OssClient } /** - * 支持生成get和put签名, 用户可以生成一个具有一定有效期的 - * 签名过的url + * Sign URL with specified expiration time in seconds (timeout) and HTTP method. + * The signed URL could be used to access the object directly. * * @param string $bucket * @param string $object - * @param int $timeout + * @param int $timeout expiration time in seconds. * @param string $method - * @param array $options Key-Value数组 + * @param array $options Key-Value array * @return string * @throws OssException */ @@ -1872,7 +1872,7 @@ class OssClient } /** - * 检测options参数 + * validates options. Create a empty array if it's NULL. * * @param array $options * @throws OssException @@ -1886,7 +1886,7 @@ class OssClient } /** - * 校验bucket参数 + * Validates bucket parameter * * @param string $bucket * @param string $errMsg @@ -1898,7 +1898,7 @@ class OssClient } /** - * 校验object参数 + * validates object parameter * * @param string $object * @throws OssException @@ -1918,21 +1918,21 @@ class OssClient { if (is_string($storage)) { switch ($storage) { - case self::OSS_STORAGE_ARCHIVE: - return; - case self::OSS_STORAGE_IA: - return; - case self::OSS_STORAGE_STANDARD: - return; - default: - break; + case self::OSS_STORAGE_ARCHIVE: + return; + case self::OSS_STORAGE_IA: + return; + case self::OSS_STORAGE_STANDARD: + return; + default: + break; } } throw new OssException('storage name is invalid'); } /** - * 校验bucket,options参数 + * Validates bucket,options parameters and optionally validate object parameter. * * @param string $bucket * @param string $object @@ -1949,7 +1949,7 @@ class OssClient } /** - * 参数校验 + * checks parameters * * @param array $options * @param string $param @@ -1964,7 +1964,7 @@ class OssClient } /** - * 检测md5 + * Checks md5 * * @param array $options * @return bool|null @@ -1975,7 +1975,7 @@ class OssClient } /** - * 获取value + * Gets value of the specified key from the options * * @param array $options * @param string $key @@ -2006,7 +2006,7 @@ class OssClient } /** - * 获取mimetype类型 + * Gets mimetype * * @param string $object * @return string @@ -2029,7 +2029,7 @@ class OssClient } /** - * 验证并且执行请求,按照OSS Api协议,执行操作 + * Validates and executes the request according to OSS API protocol. * * @param array $options * @return ResponseCore @@ -2039,24 +2039,24 @@ class OssClient private function auth($options) { OssUtil::validateOptions($options); - //验证bucket,list_bucket时不需要验证 + //Validates bucket, not required for list_bucket $this->authPrecheckBucket($options); - //验证object + //Validates object $this->authPrecheckObject($options); - //Object名称的编码必须是utf8 + //object name encoding must be UTF-8 $this->authPrecheckObjectEncoding($options); - //验证ACL + //Validates ACL $this->authPrecheckAcl($options); - // 获得当次请求使用的协议头,是https还是http + // Should https or http be used? $scheme = $this->useSSL ? 'https://' : 'http://'; - // 获得当次请求使用的hostname,如果是公共域名或者专有域名,bucket拼在前面构成三级域名 + // gets the host name. If the host name is public domain or private domain, form a third level domain by prefixing the bucket name on the domain name. $hostname = $this->generateHostname($options[self::OSS_BUCKET]); $string_to_sign = ''; $headers = $this->generateHeaders($options, $hostname); $signable_query_string_params = $this->generateSignableQueryStringParam($options); $signable_query_string = OssUtil::toQueryString($signable_query_string_params); $resource_uri = $this->generateResourceUri($options); - //生成请求URL + //Generates the URL (add query parameters) $conjunction = '?'; $non_signable_resource = ''; if (isset($options[self::OSS_SUB_RESOURCE])) { @@ -2073,7 +2073,7 @@ class OssClient } $this->requestUrl = $scheme . $hostname . $resource_uri . $signable_query_string . $non_signable_resource; - //创建请求 + //Creates the request $request = new RequestCore($this->requestUrl, $this->requestProxy); $request->set_useragent($this->generateUserAgent()); // Streaming uploads @@ -2157,11 +2157,11 @@ class OssClient $string_to_sign .= strtolower($header_key) . ':' . $header_value . "\n"; } } - // 生成 signable_resource + // Generates the signable_resource $signable_resource = $this->generateSignableResource($options); $string_to_sign .= rawurldecode($signable_resource) . urldecode($signable_query_string); - //对?后面的要签名的string字母序排序 + // Sort the strings to be signed. $string_to_sign_ordered = $this->stringToSignSorted($string_to_sign); $signature = base64_encode(hash_hmac('sha1', $string_to_sign_ordered, $this->accessKeySecret, true)); @@ -2196,7 +2196,7 @@ class OssClient //retry if OSS Internal Error if ((integer)$request->get_response_code() === 500) { if ($this->redirects <= $this->maxRetries) { - //设置休眠 + //Sets the sleep time betwen each retry. $delay = (integer)(pow(4, $this->redirects) * 100000); usleep($delay); $this->redirects++; @@ -2209,7 +2209,7 @@ class OssClient } /** - * 设置最大尝试次数 + * Sets the max retry count * * @param int $maxRetries * @return void @@ -2220,7 +2220,7 @@ class OssClient } /** - * 获取最大尝试次数 + * Gets the max retry count * * @return int */ @@ -2230,7 +2230,7 @@ class OssClient } /** - * 打开sts enable标志,使用户构造函数中传入的$sts生效 + * Enaable/disable STS in the URL. This is to determine the $sts value passed from constructor take effect or not. * * @param boolean $enable */ @@ -2256,7 +2256,7 @@ class OssClient } /** - * 检查bucket名称格式是否正确,如果非法抛出异常 + * Validates bucket name--throw OssException if it's invalid * * @param $options * @throws OssException @@ -2270,7 +2270,7 @@ class OssClient /** * - * 检查object名称格式是否正确,如果非法抛出异常 + * Validates the object name--throw OssException if it's invalid. * * @param $options * @throws OssException @@ -2287,9 +2287,9 @@ class OssClient } /** - * 检查object的编码,如果是gbk或者gb2312则尝试将其转化为utf8编码 + * Checks the object's encoding. Convert it to UTF8 if it's in GBK or GB2312 * - * @param mixed $options 参数 + * @param mixed $options parameter */ private function authPrecheckObjectEncoding(&$options) { @@ -2310,7 +2310,7 @@ class OssClient } /** - * 检查ACL是否是预定义中三种之一,如果不是抛出异常 + * Checks if the ACL is one of the 3 predefined one. Throw OSSException if not. * * @param $options * @throws OssException @@ -2325,11 +2325,11 @@ class OssClient } /** - * 获得档次请求使用的域名 - * bucket在前的三级域名,或者二级域名,如果是cname或者ip的话,则是二级域名 + * Gets the host name for the current request. + * It could be either a third level domain (prefixed by bucket name) or second level domain if it's CName or IP * * @param $bucket - * @return string 剥掉协议头的域名 + * @return string The host name without the protocol scheem (e.g. https://) */ private function generateHostname($bucket) { @@ -2338,17 +2338,17 @@ class OssClient } elseif ($this->hostType === self::OSS_HOST_TYPE_CNAME) { $hostname = $this->hostname; } else { - // 专有域或者官网endpoint + // Private domain or public domain $hostname = ($bucket == '') ? $this->hostname : ($bucket . '.') . $this->hostname; } return $hostname; } /** - * 获得当次请求的资源定位字段 + * Gets the resource Uri in the current request * * @param $options - * @return string 资源定位字段 + * @return string return the resource uri. */ private function generateResourceUri($options) { @@ -2375,7 +2375,7 @@ class OssClient } /** - * 生成signalbe_query_string_param, array类型 + * Generates the signalbe query string parameters in array type * * @param array $options * @return array @@ -2416,7 +2416,7 @@ class OssClient } /** - * 生成用于签名resource段 + * Generates the resource uri for signing * * @param mixed $options * @return string @@ -2427,7 +2427,7 @@ class OssClient $signableResource .= '/'; if (isset($options[self::OSS_BUCKET]) && '' !== $options[self::OSS_BUCKET]) { $signableResource .= $options[self::OSS_BUCKET]; - // 如果操作没有Object操作的话,这里最后是否有斜线有个trick,ip的域名下,不需要加'/', 否则需要加'/' + // if there's no object in options, adding a '/' if the host type is not IP.\ if ($options[self::OSS_OBJECT] == '/') { if ($this->hostType !== self::OSS_HOST_TYPE_IP) { $signableResource .= "/"; @@ -2445,14 +2445,14 @@ class OssClient } /** - * 生成query_string + * generates query string * * @param mixed $options * @return string */ private function generateQueryString($options) { - //请求参数 + //query parameters $queryStringParams = array(); if (isset($options[self::OSS_QUERY_STRING])) { $queryStringParams = array_merge($queryStringParams, $options[self::OSS_QUERY_STRING]); @@ -2482,7 +2482,7 @@ class OssClient } /** - * 初始化headers + * Initialize headers * * @param mixed $options * @param string $hostname hostname @@ -2500,11 +2500,11 @@ class OssClient $headers[self::OSS_CONTENT_MD5] = $options[self::OSS_CONTENT_MD5]; } - //添加stsSecurityToken + //Add stsSecurityToken if ((!is_null($this->securityToken)) && (!$this->enableStsInUrl)) { $headers[self::OSS_SECURITY_TOKEN] = $this->securityToken; } - //合并HTTP headers + //Merge HTTP headers if (isset($options[self::OSS_HEADERS])) { $headers = array_merge($headers, $options[self::OSS_HEADERS]); } @@ -2512,7 +2512,7 @@ class OssClient } /** - * 生成请求用的UserAgent + * Generates UserAgent * * @return string */ @@ -2522,13 +2522,12 @@ class OssClient } /** - * 检查endpoint的种类 - * 如有有协议头,剥去协议头 - * 并且根据参数 is_cname 和endpoint本身,判定域名类型,是ip,cname,还是专有域或者官网域名 + * Checks endpoint type and returns the endpoint without the protocol schema. + * Figures out the domain's type (ip, cname or private/public domain). * * @param string $endpoint * @param boolean $isCName - * @return string 剥掉协议头的域名 + * @return string The domain name without the protocol schema. */ private function checkEndpoint($endpoint, $isCName) { @@ -2542,6 +2541,8 @@ class OssClient $ret_endpoint = $endpoint; } + $ret_endpoint = OssUtil::getHostPortFromEndpoint($ret_endpoint); + if ($isCName) { $this->hostType = self::OSS_HOST_TYPE_CNAME; } elseif (OssUtil::isIPFormat($ret_endpoint)) { @@ -2553,14 +2554,14 @@ class OssClient } /** - * 用来检查sdk所以来的扩展是否打开 - * + * Check if all dependent extensions are installed correctly. + * For now only "curl" is needed. * @throws OssException */ public static function checkEnv() { if (function_exists('get_loaded_extensions')) { - //检测curl扩展 + //Test curl extension $enabled_extension = array("curl"); $extensions = get_loaded_extensions(); if ($extensions) { @@ -2578,7 +2579,7 @@ class OssClient } /** - //* 设置http库的请求超时时间,单位秒 + * Sets the http's timeout (in seconds) * * @param int $timeout */ @@ -2588,7 +2589,7 @@ class OssClient } /** - * 设置http库的连接超时时间,单位秒 + * Sets the http's connection timeout (in seconds) * * @param int $connectTimeout */ @@ -2597,11 +2598,11 @@ class OssClient $this->connectTimeout = $connectTimeout; } - // 生命周期相关常量 + // Constants for Life cycle const OSS_LIFECYCLE_EXPIRATION = "Expiration"; const OSS_LIFECYCLE_TIMING_DAYS = "Days"; const OSS_LIFECYCLE_TIMING_DATE = "Date"; - //OSS 内部常量 + //OSS Internal constants const OSS_BUCKET = 'bucket'; const OSS_OBJECT = 'object'; const OSS_HEADERS = OssUtil::OSS_HEADERS; @@ -2670,18 +2671,18 @@ class OssClient const OSS_STORAGE_IA = 'IA'; const OSS_STORAGE_ARCHIVE = 'Archive'; - //私有URL变量 + //private URLs const OSS_URL_ACCESS_KEY_ID = 'OSSAccessKeyId'; const OSS_URL_EXPIRES = 'Expires'; const OSS_URL_SIGNATURE = 'Signature'; - //HTTP方法 + //HTTP METHOD const OSS_HTTP_GET = 'GET'; const OSS_HTTP_PUT = 'PUT'; const OSS_HTTP_HEAD = 'HEAD'; const OSS_HTTP_POST = 'POST'; const OSS_HTTP_DELETE = 'DELETE'; const OSS_HTTP_OPTIONS = 'OPTIONS'; - //其他常量 + //Others const OSS_ACL = 'x-oss-acl'; const OSS_OBJECT_ACL = 'x-oss-object-acl'; const OSS_OBJECT_GROUP = 'x-oss-file-group'; @@ -2692,7 +2693,7 @@ class OssClient const OSS_PROCESS = "x-oss-process"; const OSS_CALLBACK = "x-oss-callback"; const OSS_CALLBACK_VAR = "x-oss-callback-var"; - //支持STS SecurityToken + //Constants for STS SecurityToken const OSS_SECURITY_TOKEN = "x-oss-security-token"; const OSS_ACL_TYPE_PRIVATE = 'private'; const OSS_ACL_TYPE_PUBLIC_READ = 'public-read'; @@ -2700,39 +2701,39 @@ class OssClient const OSS_ENCODING_TYPE = "encoding-type"; const OSS_ENCODING_TYPE_URL = "url"; - // 域名类型 + // Domain Types const OSS_HOST_TYPE_NORMAL = "normal";//http://bucket.oss-cn-hangzhou.aliyuncs.com/object const OSS_HOST_TYPE_IP = "ip"; //http://1.1.1.1/bucket/object const OSS_HOST_TYPE_SPECIAL = 'special'; //http://bucket.guizhou.gov/object const OSS_HOST_TYPE_CNAME = "cname"; //http://mydomain.com/object - //OSS ACL数组 + //OSS ACL array static $OSS_ACL_TYPES = array( self::OSS_ACL_TYPE_PRIVATE, self::OSS_ACL_TYPE_PUBLIC_READ, self::OSS_ACL_TYPE_PUBLIC_READ_WRITE ); - // OssClient版本信息 + // OssClient version information const OSS_NAME = "aliyun-sdk-php"; - const OSS_VERSION = "2.3.0"; - const OSS_BUILD = "20180105"; + const OSS_VERSION = "2.3.1"; + const OSS_BUILD = "20191115"; const OSS_AUTHOR = ""; const OSS_OPTIONS_ORIGIN = 'Origin'; const OSS_OPTIONS_REQUEST_METHOD = 'Access-Control-Request-Method'; const OSS_OPTIONS_REQUEST_HEADERS = 'Access-Control-Request-Headers'; - //是否使用ssl + //use ssl flag private $useSSL = false; private $maxRetries = 3; private $redirects = 0; - // 用户提供的域名类型,有四种 OSS_HOST_TYPE_NORMAL, OSS_HOST_TYPE_IP, OSS_HOST_TYPE_SPECIAL, OSS_HOST_TYPE_CNAME + // user's domain type. It could be one of the four: OSS_HOST_TYPE_NORMAL, OSS_HOST_TYPE_IP, OSS_HOST_TYPE_SPECIAL, OSS_HOST_TYPE_CNAME private $hostType = self::OSS_HOST_TYPE_NORMAL; private $requestUrl; + private $requestProxy = null; private $accessKeyId; private $accessKeySecret; private $hostname; private $securityToken; - private $requestProxy = null; private $enableStsInUrl = false; private $timeout = 0; private $connectTimeout = 0; diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php index 6da08604..7061ff09 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php @@ -5,8 +5,7 @@ namespace OSS\Result; use OSS\Core\OssException; /** - * Class AclResult getBucketAcl接口返回结果类,封装了 - * 返回的xml数据的解析 + * The type of the return value of getBucketAcl, it wraps the data parsed from xml. * * @package OSS\Result */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AppendResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AppendResult.php index 433c03eb..d898d585 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AppendResult.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AppendResult.php @@ -11,7 +11,7 @@ use OSS\Core\OssException; class AppendResult extends Result { /** - * 结果中part的next-append-position + * Get the value of next-append-position from append's response headers * * @return int * @throws OssException diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php index f7aa287c..e9522d4f 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php @@ -3,8 +3,7 @@ namespace OSS\Result; /** - * Class ExistResult 检查bucket和object是否存在的返回结果, - * 根据返回response的http status判断 + * Class ExistResult checks if bucket or object exists, according to the http status in response headers. * @package OSS\Result */ class ExistResult extends Result @@ -18,8 +17,8 @@ class ExistResult extends Result } /** - * 根据返回http状态码判断,[200-299]即认为是OK, 判断是否存在的接口,404也认为是一种 - * 有效响应 + * Check if the response status is OK according to the http status code. + * [200-299]: OK; [404]: Not found. It means the object or bucket is not found--it's a valid response too. * * @return bool */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php index a51afe2a..8fb10ea3 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php @@ -18,8 +18,7 @@ class GetCorsResult extends Result } /** - * 根据返回http状态码判断,[200-299]即认为是OK, 获取bucket相关配置的接口,404也认为是一种 - * 有效响应 + * Check if the response is OK, according to the http status. [200-299]:OK, the Cors config could be got; [404]: not found--no Cors config. * * @return bool */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php index 6b440c35..e0a9595f 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php @@ -12,7 +12,7 @@ use OSS\Model\LifecycleConfig; class GetLifecycleResult extends Result { /** - * 解析Lifestyle数据 + * Parse the LifecycleConfig object from the response * * @return LifecycleConfig */ @@ -25,8 +25,8 @@ class GetLifecycleResult extends Result } /** - * 根据返回http状态码判断,[200-299]即认为是OK, 获取bucket相关配置的接口,404也认为是一种 - * 有效响应 + * Check if the response is OK according to the http status. + * [200-299]: OK, and the LifecycleConfig could be got; [404] The Life cycle config is not found. * * @return bool */ @@ -38,4 +38,4 @@ class GetLifecycleResult extends Result } return false; } -} \ No newline at end of file +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLocationResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLocationResult.php index 71c4c96e..a0c51295 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLocationResult.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLocationResult.php @@ -4,8 +4,8 @@ namespace OSS\Result; use OSS\Core\OssException; /** - * Class GetLocationResult getBucketLocation接口返回结果类,封装了 - * 返回的xml数据的解析 + * Class GetLocationResult getBucketLocation interface returns the result class, encapsulated + * The returned xml data is parsed * * @package OSS\Result */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLoggingResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLoggingResult.php index 72fc3aeb..eab8c645 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLoggingResult.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLoggingResult.php @@ -12,7 +12,7 @@ use OSS\Model\LoggingConfig; class GetLoggingResult extends Result { /** - * 解析LoggingConfig数据 + * Parse LoggingConfig data * * @return LoggingConfig */ @@ -25,8 +25,8 @@ class GetLoggingResult extends Result } /** - * 根据返回http状态码判断,[200-299]即认为是OK, 获取bucket相关配置的接口,404也认为是一种 - * 有效响应 + * Judged according to the return HTTP status code, [200-299] that is OK, get the bucket configuration interface, + * 404 is also considered a valid response * * @return bool */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetRefererResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetRefererResult.php index aee50d3a..a8a649eb 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetRefererResult.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetRefererResult.php @@ -12,7 +12,7 @@ use OSS\Model\RefererConfig; class GetRefererResult extends Result { /** - * 解析RefererConfig数据 + * Parse RefererConfig data * * @return RefererConfig */ @@ -25,8 +25,8 @@ class GetRefererResult extends Result } /** - * 根据返回http状态码判断,[200-299]即认为是OK, 获取bucket相关配置的接口,404也认为是一种 - * 有效响应 + * Judged according to the return HTTP status code, [200-299] that is OK, get the bucket configuration interface, + * 404 is also considered a valid response * * @return bool */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetStorageCapacityResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetStorageCapacityResult.php index 84e49160..2f4127b1 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetStorageCapacityResult.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetStorageCapacityResult.php @@ -5,8 +5,8 @@ namespace OSS\Result; use OSS\Core\OssException; /** - * Class AclResult getBucketAcl接口返回结果类,封装了 - * 返回的xml数据的解析 + * Class AclResult GetBucketAcl interface returns the result class, encapsulated + * The returned xml data is parsed * * @package OSS\Result */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php index 3099172c..64d54fac 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php @@ -11,7 +11,7 @@ use OSS\Model\WebsiteConfig; class GetWebsiteResult extends Result { /** - * 解析WebsiteConfig数据 + * Parse WebsiteConfig data * * @return WebsiteConfig */ @@ -24,8 +24,8 @@ class GetWebsiteResult extends Result } /** - * 根据返回http状态码判断,[200-299]即认为是OK, 获取bucket相关配置的接口,404也认为是一种 - * 有效响应 + * Judged according to the return HTTP status code, [200-299] that is OK, get the bucket configuration interface, + * 404 is also considered a valid response * * @return bool */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php index c9aae561..1ca4d1a2 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php @@ -11,7 +11,7 @@ namespace OSS\Result; class HeaderResult extends Result { /** - * 把返回的ResponseCore中的header作为返回数据 + * The returned ResponseCore header is used as the return data * * @return array */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php index af985f27..53a15da8 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php @@ -12,7 +12,7 @@ use OSS\Core\OssException; class InitiateMultipartUploadResult extends Result { /** - * 结果中获取uploadId并返回 + * Get uploadId in result and return * * @throws OssException * @return string diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php index bcb20bf5..3220c861 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php @@ -14,7 +14,7 @@ use OSS\Model\UploadInfo; class ListMultipartUploadResult extends Result { /** - * 解析从ListMultipartUpload接口的返回数据 + * Parse the return data from the ListMultipartUpload interface * * @return ListMultipartUploadInfo */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php index fcf493d2..f44c66a0 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php @@ -14,7 +14,7 @@ use OSS\Model\PrefixInfo; class ListObjectsResult extends Result { /** - * 解析ListObjects接口返回的xml数据 + * Parse the xml data returned by the ListObjects interface * * return ObjectListInfo */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php index fd8a1b86..092d94e0 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php @@ -13,7 +13,7 @@ use OSS\Model\PartInfo; class ListPartsResult extends Result { /** - * 解析ListParts接口返回的xml数据 + * Parse the xml data returned by the ListParts interface * * @return ListPartsInfo */ diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/Result.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/Result.php index 491256f0..e5d83d37 100644 --- a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/Result.php +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/Result.php @@ -7,8 +7,8 @@ use OSS\Http\ResponseCore; /** - * Class Result, 操作结果类的基类,不同的请求在处理返回数据的时候有不同的逻辑, - * 具体的解析逻辑推迟到子类实现 + * Class Result, The result class of The operation of the base class, different requests in dealing with the return of data have different logic, + * The specific parsing logic postponed to subclass implementation * * @package OSS\Model */ @@ -29,7 +29,7 @@ abstract class Result } /** - * 获取requestId + * Get requestId * * @return string */ @@ -46,7 +46,7 @@ abstract class Result } /** - * 得到返回数据,不同的请求返回数据格式不同 + * Get the returned data, different request returns the data format is different * * $return mixed */ @@ -56,14 +56,14 @@ abstract class Result } /** - * 由子类实现,不同的请求返回数据有不同的解析逻辑,由子类实现 + * Subclass implementation, different requests return data has different analytical logic, implemented by subclasses * * @return mixed */ abstract protected function parseDataFromResponse(); /** - * 操作是否成功 + * Whether the operation is successful * * @return mixed */ @@ -99,7 +99,7 @@ abstract class Result } /** - * 尝试从body中获取错误Message + * Try to get the error message from body * * @param $body * @return string @@ -117,7 +117,7 @@ abstract class Result } /** - * 尝试从body中获取错误Code + * Try to get the error Code from body * * @param $body * @return string @@ -135,7 +135,7 @@ abstract class Result } /** - * 根据返回http状态码判断,[200-299]即认为是OK + * Judging from the return http status code, [200-299] that is OK * * @return bool */ @@ -149,7 +149,7 @@ abstract class Result } /** - * 返回原始的返回数据 + * Return the original return data * * @return ResponseCore */ @@ -159,15 +159,15 @@ abstract class Result } /** - * 标示请求是否成功 + * Indicate whether the request is successful */ protected $isOk = false; /** - * 由子类解析过的数据 + * Data parsed by subclasses */ protected $parsedData = null; /** - * 存放auth函数返回的原始Response + * Store the original Response returned by the auth function * * @var ResponseCore */ diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CallbackTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CallbackTest.php index a0db0037..337ea243 100644 --- a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CallbackTest.php +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CallbackTest.php @@ -17,7 +17,7 @@ class CallbackTest extends TestOssClientBase $this->ossClient->putObject($this->bucket, $copiedObject, file_get_contents(__FILE__)); /** - * step 1. 初始化一个分块上传事件, 也就是初始化上传Multipart, 获取upload id + * step 1. Initialize a block upload event, which is initialized to upload Multipart, get the upload id */ try { $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); @@ -44,11 +44,10 @@ class CallbackTest extends TestOssClientBase /** * step 3. */ - $json = '{ - "callbackUrl":"oss-demo.aliyuncs.com:23450", - "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackUrl":"'.Common::getCallbackUrl().'",'. + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", "callbackBody":"{\"mimeType\":${mimeType},\"size\":${size},\"x:var1\":${x:var1},\"x:var2\":${x:var2}}", "callbackBodyType":"application/json" }'; @@ -78,7 +77,7 @@ class CallbackTest extends TestOssClientBase $this->ossClient->putObject($this->bucket, $copiedObject, file_get_contents(__FILE__)); /** - * step 1. 初始化一个分块上传事件, 也就是初始化上传Multipart, 获取upload id + * step 1. Initialize a block upload event, which is initialized to upload Multipart, get the upload id */ try { $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); @@ -139,8 +138,8 @@ class CallbackTest extends TestOssClientBase { $json = '{ - "callbackUrl":"oss-demo.aliyuncs.com:23450", - "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackUrl":"'.Common::getCallbackUrl().'",'. + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", "callbackBody":"{\"mimeType\":${mimeType},\"size\":${size}}", "callbackBodyType":"application/json" }'; @@ -151,8 +150,8 @@ class CallbackTest extends TestOssClientBase { $url = '{ - "callbackUrl":"oss-demo.aliyuncs.com:23450", - "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackUrl":"'.Common::getCallbackUrl().'",'. + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", "callbackBody":"bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&imageInfo.height=${imageInfo.height}&imageInfo.width=${imageInfo.width}&imageInfo.format=${imageInfo.format}", "callbackBodyType":"application/x-www-form-urlencoded" }'; @@ -163,8 +162,8 @@ class CallbackTest extends TestOssClientBase { $url = '{ - "callbackUrl":"oss-demo.aliyuncs.com:23450", - "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackUrl":"'.Common::getCallbackUrl().'",'. + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", "callbackBody":"bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&imageInfo.height=${imageInfo.height}&imageInfo.width=${imageInfo.width}&imageInfo.format=${imageInfo.format}" }'; $options = array(OssClient::OSS_CALLBACK => $url); @@ -174,8 +173,8 @@ class CallbackTest extends TestOssClientBase { $json = '{ - "callbackUrl":"oss-demo.aliyuncs.com:23450", - "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackUrl":"'.Common::getCallbackUrl().'",'. + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", "callbackBody":"{\" 春水碧于天,画船听雨眠。\":\"垆边人似月,皓腕凝霜雪。\"}", "callbackBodyType":"application/json" }'; @@ -186,8 +185,8 @@ class CallbackTest extends TestOssClientBase { $url = '{ - "callbackUrl":"oss-demo.aliyuncs.com:23450", - "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackUrl":"'.Common::getCallbackUrl().'",'. + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", "callbackBody":"春水碧于天,画船听雨眠。垆边人似月,皓腕凝霜雪", "callbackBodyType":"application/x-www-form-urlencoded" }'; @@ -198,8 +197,8 @@ class CallbackTest extends TestOssClientBase { $json = '{ - "callbackUrl":"oss-demo.aliyuncs.com:23450", - "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackUrl":"'.Common::getCallbackUrl().'",'. + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", "callbackBody":"{\"mimeType\":${mimeType},\"size\":${size},\"x:var1\":${x:var1},\"x:var2\":${x:var2}}", "callbackBodyType":"application/json" }'; @@ -218,8 +217,8 @@ class CallbackTest extends TestOssClientBase { $url = '{ - "callbackUrl":"oss-demo.aliyuncs.com:23450", - "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackUrl":"'.Common::getCallbackUrl().'",'. + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", "callbackBody":"bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&imageInfo.height=${imageInfo.height}&imageInfo.width=${imageInfo.width}&imageInfo.format=${imageInfo.format}&my_var1=${x:var1}&my_var2=${x:var2}", "callbackBodyType":"application/x-www-form-urlencoded" }'; diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/Common.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/Common.php index 9d7190cc..15289448 100644 --- a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/Common.php +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/Common.php @@ -10,14 +10,14 @@ use OSS\Core\OssException; /** * Class Common * - * 示例程序【Samples/*.php】 的Common类,用于获取OssClient实例和其他公用方法 + * Sample program [Samples / *. Php] Common class, used to obtain OssClient instance and other public methods */ class Common { /** - * 根据Config配置,得到一个OssClient实例 + * According to the Config configuration, get an OssClient instance * - * @return OssClient 一个OssClient实例 + * @return OssClient An OssClient instance */ public static function getOssClient() { @@ -39,8 +39,18 @@ class Common return getenv('OSS_BUCKET'); } + public static function getRegion() + { + return getenv('OSS_REGION'); + } + + public static function getCallbackUrl() + { + return getenv('OSS_CALLBACK_URL'); + } + /** - * 工具方法,创建一个bucket + * Tool method, create a bucket */ public static function createBucket() { diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTest.php index f207ca1a..d0a2a225 100644 --- a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTest.php +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTest.php @@ -51,11 +51,11 @@ class OssClientBucketTest extends TestOssClientBase $this->assertTrue($this->ossClient->doesBucketExist($this->bucket)); $this->assertFalse($this->ossClient->doesBucketExist($this->bucket . '-notexist')); - $this->assertEquals($this->ossClient->getBucketLocation($this->bucket), 'oss-us-west-1'); + $this->assertEquals($this->ossClient->getBucketLocation($this->bucket), Common::getRegion()); $res = $this->ossClient->getBucketMeta($this->bucket); $this->assertEquals('200', $res['info']['http_code']); - $this->assertEquals('oss-us-west-1', $res['x-oss-bucket-region']); + $this->assertEquals(Common::getRegion(), $res['x-oss-bucket-region']); } public function testCreateBucketWithStorageType() diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTest.php index 34e3ded7..2f1201bb 100644 --- a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTest.php +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTest.php @@ -78,7 +78,7 @@ class OssClientObjectTest extends TestOssClientBase public function testObject() { /** - * 上传本地变量到bucket + * Upload the local variable to bucket */ $object = "oss-php-sdk-test/upload-test-object-name.txt"; $content = file_get_contents(__FILE__); @@ -129,7 +129,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * getObject到本地变量,检查是否match + * GetObject to the local variable and check for match */ try { $content = $this->ossClient->getObject($this->bucket, $object); @@ -139,7 +139,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * getObject的前五个字节 + * GetObject first five bytes */ try { $options = array(OssClient::OSS_RANGE => '0-4'); @@ -151,7 +151,7 @@ class OssClientObjectTest extends TestOssClientBase /** - * 上传本地文件到object + * Upload the local file to object */ try { $this->ossClient->uploadFile($this->bucket, $object, __FILE__); @@ -160,7 +160,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 下载文件到本地变量,检查是否match + * Download the file to the local variable and check for match. */ try { $content = $this->ossClient->getObject($this->bucket, $object); @@ -170,7 +170,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 下载文件到本地文件 + * Download the file to the local file */ $localfile = "upload-test-object-name.txt"; $options = array( @@ -188,7 +188,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 下载文件到本地文件 no such key + * Download the file to the local file. no such key */ $localfile = "upload-test-object-name-no-such-key.txt"; $options = array( @@ -208,7 +208,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 下载文件到内容 no such key + * Download the file to the content. no such key */ try { $result = $this->ossClient->getObject($this->bucket, $object . "no-such-key"); @@ -222,7 +222,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 复制object + * Copy object */ $to_bucket = $this->bucket; $to_object = $object . '.copy'; @@ -239,7 +239,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 检查复制的是否相同 + * Check if the replication is the same */ try { $content = $this->ossClient->getObject($this->bucket, $to_object); @@ -249,7 +249,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 列出bucket内的文件列表 + * List the files in your bucket. */ $prefix = ''; $delimiter = '/'; @@ -276,7 +276,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 设置文件的meta信息 + * Set the meta information for the file */ $from_bucket = $this->bucket; $from_object = "oss-php-sdk-test/upload-test-object-name.txt"; @@ -295,7 +295,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 获取文件的meta信息 + * Get the meta information for the file */ $object = "oss-php-sdk-test/upload-test-object-name.txt"; try { @@ -306,7 +306,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 删除单个文件 + * Delete single file */ $object = "oss-php-sdk-test/upload-test-object-name.txt"; @@ -319,7 +319,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 删除多个个文件 + * Delete multiple files */ $object1 = "oss-php-sdk-test/upload-test-object-name.txt"; $object2 = "oss-php-sdk-test/upload-test-object-name.txt.copy"; @@ -345,7 +345,7 @@ class OssClientObjectTest extends TestOssClientBase $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); /** - * 追加上传字符串 + * Append the upload string */ try { $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[0], 0); @@ -359,7 +359,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 检查内容的是否相同 + * Check if the content is the same */ try { $content = $this->ossClient->getObject($this->bucket, $object); @@ -370,7 +370,7 @@ class OssClientObjectTest extends TestOssClientBase /** - * 删除测试object + * Delete test object */ try { $this->ossClient->deleteObject($this->bucket, $object); @@ -379,7 +379,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 追加上传本地文件 + * Append the upload of local files */ try { $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, 0); @@ -391,7 +391,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 检查复制的是否相同 + * Check if the replication is the same */ try { $content = $this->ossClient->getObject($this->bucket, $object); @@ -401,7 +401,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 删除测试object + * Delete test object */ try { $this->ossClient->deleteObject($this->bucket, $object); @@ -418,7 +418,7 @@ class OssClientObjectTest extends TestOssClientBase ); /** - * 带option的追加上传 + * Append upload with option */ try { $position = $this->ossClient->appendObject($this->bucket, $object, "Hello OSS, ", 0, $options); @@ -428,7 +428,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 获取文件的meta信息 + * Get the meta information for the file */ try { $objectMeta = $this->ossClient->getObjectMeta($this->bucket, $object); @@ -438,7 +438,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 删除测试object + * Delete test object */ try { $this->ossClient->deleteObject($this->bucket, $object); @@ -465,7 +465,7 @@ class OssClientObjectTest extends TestOssClientBase $options = array(OssClient::OSS_CHECK_MD5 => true); /** - * 上传数据开启MD5 + * Upload data to start MD5 */ try { $this->ossClient->putObject($this->bucket, $object, $content, $options); @@ -474,7 +474,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 检查复制的是否相同 + * Check if the replication is the same */ try { $content = $this->ossClient->getObject($this->bucket, $object); @@ -484,7 +484,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 上传文件开启MD5 + * Upload file to start MD5 */ try { $this->ossClient->uploadFile($this->bucket, $object, __FILE__, $options); @@ -493,7 +493,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 检查复制的是否相同 + * Check if the replication is the same */ try { $content = $this->ossClient->getObject($this->bucket, $object); @@ -503,7 +503,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 删除测试object + * Delete test object */ try { $this->ossClient->deleteObject($this->bucket, $object); @@ -516,7 +516,7 @@ class OssClientObjectTest extends TestOssClientBase $options = array(OssClient::OSS_CHECK_MD5 => true); /** - * 追加上传字符串 + * Append the upload string */ try { $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[0], 0, $options); @@ -530,7 +530,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 检查内容的是否相同 + * Check if the content is the same */ try { $content = $this->ossClient->getObject($this->bucket, $object); @@ -540,7 +540,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 删除测试object + * Delete test object */ try { $this->ossClient->deleteObject($this->bucket, $object); @@ -549,7 +549,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 追加上传本地文件 + * Append upload of local files */ try { $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, 0, $options); @@ -561,7 +561,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 检查复制的是否相同 + * Check if the replication is the same */ try { $content = $this->ossClient->getObject($this->bucket, $object); @@ -571,7 +571,7 @@ class OssClientObjectTest extends TestOssClientBase } /** - * 删除测试object + * delete test object */ try { $this->ossClient->deleteObject($this->bucket, $object); @@ -580,6 +580,16 @@ class OssClientObjectTest extends TestOssClientBase } } + public function testWithInvalidBucketName() + { + try { + $this->ossClient->createBucket("abcefc/", "test-key"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('"abcefc/"bucket name is invalid', $e->getMessage()); + } + } + public function setUp() { parent::setUp(); diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssUtilTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssUtilTest.php index adf64571..c5652496 100644 --- a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssUtilTest.php +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssUtilTest.php @@ -222,4 +222,30 @@ BBBB; return str_replace("\n", "", str_replace("\r", "", $xml)); } + public function testGetHostPortFromEndpoint() + { + $str = OssUtil::getHostPortFromEndpoint('http://username:password@hostname:80/path?arg=value#anchor'); + $this->assertEquals('hostname:80', $str); + + $str = OssUtil::getHostPortFromEndpoint('hostname:80'); + $this->assertEquals('hostname:80', $str); + + $str = OssUtil::getHostPortFromEndpoint('www.hostname.com'); + $this->assertEquals('www.hostname.com', $str); + + $str = OssUtil::getHostPortFromEndpoint('http://www.hostname.com'); + $this->assertEquals('www.hostname.com', $str); + + $str = OssUtil::getHostPortFromEndpoint('https://www.hostname.com'); + $this->assertEquals('www.hostname.com', $str); + + $str = OssUtil::getHostPortFromEndpoint('192.168.1.10:8080'); + $this->assertEquals('192.168.1.10:8080', $str); + + $str = OssUtil::getHostPortFromEndpoint('http:///path?arg=value#anchor'); + $this->assertEquals('', $str); + + $str = OssUtil::getHostPortFromEndpoint('file://username:password@hostname:80/path?arg=value#anchor'); + $this->assertEquals('hostname:80', $str); + } } diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SymlinkTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SymlinkTest.php index d257c948..4a39dfa9 100644 --- a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SymlinkTest.php +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SymlinkTest.php @@ -53,7 +53,7 @@ class SymlinkTest extends TestOssClientBase $this->ossClient->getObject($bucket, $symlink); $this->assertTrue(false); }catch (OssException $e){ - $this->assertEquals('The symlink target object does not exist', $e->getErrorMessage()); + $this->assertEquals('The specified key does not exist.', $e->getErrorMessage()); } } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index fc39cdcb..bc251f26 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1,24 +1,18 @@ [ { "name": "aliyuncs/oss-sdk-php", - "version": "v2.3.0", - "version_normalized": "2.3.0.0", + "version": "v2.3.1", + "version_normalized": "2.3.1.0", "source": { "type": "git", "url": "https://github.com/aliyun/aliyun-oss-php-sdk.git", - "reference": "e69f57916678458642ac9d2fd341ae78a56996c8" + "reference": "053d7ba9e798e4c09b9c5c1edab153d25ea9643a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/e69f57916678458642ac9d2fd341ae78a56996c8", - "reference": "e69f57916678458642ac9d2fd341ae78a56996c8", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://github-api-proxy.cnpkg.org/repos/aliyun/aliyun-oss-php-sdk/zipball/053d7ba9e798e4c09b9c5c1edab153d25ea9643a", + "reference": "053d7ba9e798e4c09b9c5c1edab153d25ea9643a", + "shasum": "" }, "require": { "php": ">=5.3" @@ -27,7 +21,7 @@ "phpunit/phpunit": "~4.0", "satooshi/php-coveralls": "~1.0" }, - "time": "2018-01-08T06:59:35+00:00", + "time": "2019-11-15T11:05:42+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -35,7 +29,7 @@ "OSS\\": "src/OSS" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "https://repo.packagist.org/downloads/", "license": [ "MIT" ], @@ -61,13 +55,7 @@ "type": "zip", "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9", "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "ext-curl": "*", @@ -154,24 +142,18 @@ }, { "name": "guzzlehttp/guzzle", - "version": "6.4.1", - "version_normalized": "6.4.1.0", + "version": "6.5.2", + "version_normalized": "6.5.2.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "0895c932405407fd3a7368b6910c09a24d26db11" + "reference": "43ece0e75098b7ecd8d13918293029e555a50f82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/0895c932405407fd3a7368b6910c09a24d26db11", - "reference": "0895c932405407fd3a7368b6910c09a24d26db11", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://github-api-proxy.cnpkg.org/repos/guzzle/guzzle/zipball/43ece0e75098b7ecd8d13918293029e555a50f82", + "reference": "43ece0e75098b7ecd8d13918293029e555a50f82", + "shasum": "" }, "require": { "ext-json": "*", @@ -185,13 +167,14 @@ "psr/log": "^1.1" }, "suggest": { + "ext-intl": "Required for Internationalized Domain Name (IDN) support", "psr/log": "Required for using the Log middleware" }, - "time": "2019-10-23T15:58:00+00:00", + "time": "2019-12-23T11:57:10+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "6.3-dev" + "dev-master": "6.5-dev" } }, "installation-source": "dist", @@ -203,7 +186,7 @@ "src/functions_include.php" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "https://repo.packagist.org/downloads/", "license": [ "MIT" ], @@ -239,13 +222,7 @@ "type": "zip", "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "php": ">=5.5.0" @@ -298,13 +275,7 @@ "type": "zip", "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", "reference": "239400de7a173fe9901b9ac7c06497751f00727a", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "php": ">=5.4.0", @@ -377,13 +348,7 @@ "type": "zip", "url": "https://api.github.com/repos/Nicolab/php-ftp-client/zipball/8c66e1104da1b638f5d7a9e24624a5525b459a0c", "reference": "8c66e1104da1b638f5d7a9e24624a5525b459a0c", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "ext-ftp": "*", @@ -423,24 +388,18 @@ }, { "name": "phpmailer/phpmailer", - "version": "v6.1.1", - "version_normalized": "6.1.1.0", + "version": "v6.1.4", + "version_normalized": "6.1.4.0", "source": { "type": "git", "url": "https://github.com/PHPMailer/PHPMailer.git", - "reference": "26bd96350b0b2fcbf0ef4e6f0f9cf3528302a9d8" + "reference": "c5e61d0729507049cec9673aa1a679f9adefd683" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/26bd96350b0b2fcbf0ef4e6f0f9cf3528302a9d8", - "reference": "26bd96350b0b2fcbf0ef4e6f0f9cf3528302a9d8", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://github-api-proxy.cnpkg.org/repos/PHPMailer/PHPMailer/zipball/c5e61d0729507049cec9673aa1a679f9adefd683", + "reference": "c5e61d0729507049cec9673aa1a679f9adefd683", + "shasum": "" }, "require": { "ext-ctype": "*", @@ -448,13 +407,9 @@ "php": ">=5.5.0" }, "require-dev": { - "doctrine/annotations": "1.2.*", + "doctrine/annotations": "^1.2", "friendsofphp/php-cs-fixer": "^2.2", - "phpdocumentor/phpdocumentor": "2.*", - "phpunit/phpunit": "^4.8 || ^5.7", - "zendframework/zend-eventmanager": "3.0.*", - "zendframework/zend-i18n": "2.7.3", - "zendframework/zend-serializer": "2.7.*" + "phpunit/phpunit": "^4.8 || ^5.7" }, "suggest": { "ext-mbstring": "Needed to send email in multibyte encoding charset", @@ -464,7 +419,7 @@ "stevenmaguire/oauth2-microsoft": "Needed for Microsoft XOAUTH2 authentication", "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)" }, - "time": "2019-09-27T21:33:43+00:00", + "time": "2019-12-10T11:17:38+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -472,7 +427,7 @@ "PHPMailer\\PHPMailer\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "https://repo.packagist.org/downloads/", "license": [ "LGPL-2.1-only" ], @@ -508,13 +463,7 @@ "type": "zip", "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "php": ">=5.3.0" @@ -566,13 +515,7 @@ "type": "zip", "url": "https://api.github.com/repos/tencentyun/cos-php-sdk-v5/zipball/1b32aa422f6dffe4ea411e5095e4b0da9135551b", "reference": "1b32aa422f6dffe4ea411e5095e4b0da9135551b", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "guzzle/guzzle": "~3.7", @@ -620,13 +563,7 @@ "type": "zip", "url": "https://api.github.com/repos/qiniu/php-sdk/zipball/d89987163f560ebf9dfa5bb25de9bd9b1a3b2bd8", "reference": "d89987163f560ebf9dfa5bb25de9bd9b1a3b2bd8", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "php": ">=5.3.3" @@ -679,13 +616,7 @@ "type": "zip", "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", "reference": "120b605dfeb996808c31b6477290a714d356e822", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "php": ">=5.6" @@ -716,8 +647,8 @@ }, { "name": "symfony/event-dispatcher", - "version": "v2.8.50", - "version_normalized": "2.8.50.0", + "version": "v2.8.52", + "version_normalized": "2.8.52.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -725,15 +656,9 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a77e974a5fecb4398833b0709210e3d5e334ffb0", + "url": "https://github-api-proxy.cnpkg.org/repos/symfony/event-dispatcher/zipball/a77e974a5fecb4398833b0709210e3d5e334ffb0", "reference": "a77e974a5fecb4398833b0709210e3d5e334ffb0", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "php": ">=5.3.9" @@ -765,7 +690,7 @@ "/Tests/" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "https://repo.packagist.org/downloads/", "license": [ "MIT" ], @@ -784,24 +709,18 @@ }, { "name": "topthink/framework", - "version": "v5.1.38.1", - "version_normalized": "5.1.38.1", + "version": "v5.1.39", + "version_normalized": "5.1.39.0", "source": { "type": "git", "url": "https://github.com/top-think/framework.git", - "reference": "12d15c29d5d6a972fc8bfc8db005d64d4786028c" + "reference": "5762858f3d58faafb3a39427f8788884b2927007" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/framework/zipball/12d15c29d5d6a972fc8bfc8db005d64d4786028c", - "reference": "12d15c29d5d6a972fc8bfc8db005d64d4786028c", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://github-api-proxy.cnpkg.org/repos/top-think/framework/zipball/5762858f3d58faafb3a39427f8788884b2927007", + "reference": "5762858f3d58faafb3a39427f8788884b2927007", + "shasum": "" }, "require": { "php": ">=5.6.0", @@ -816,10 +735,10 @@ "sebastian/phpcpd": "2.*", "squizlabs/php_codesniffer": "2.*" }, - "time": "2019-08-12T00:58:30+00:00", + "time": "2019-11-17T23:22:02+00:00", "type": "think-framework", "installation-source": "dist", - "notification-url": "https://packagist.org/downloads/", + "notification-url": "https://repo.packagist.org/downloads/", "license": [ "Apache-2.0" ], @@ -854,13 +773,7 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-captcha/zipball/54c8a51552f99ff9ea89ea9c272383a8f738ceee", "reference": "54c8a51552f99ff9ea89ea9c272383a8f738ceee", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "topthink/framework": "5.1.*" @@ -901,13 +814,7 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-image/zipball/8586cf47f117481c6d415b20f7dedf62e79d5512", "reference": "8586cf47f117481c6d415b20f7dedf62e79d5512", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "ext-gd": "*" @@ -949,13 +856,7 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-installer/zipball/f5400a12c60e513911aef41fe443fa6920952675", "reference": "f5400a12c60e513911aef41fe443fa6920952675", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "composer-plugin-api": "^1.0" @@ -998,13 +899,7 @@ "type": "zip", "url": "https://api.github.com/repos/upyun/php-sdk/zipball/b4819fd941e3f19a886f8b3c5f8bffcb8279185f", "reference": "b4819fd941e3f19a886f8b3c5f8bffcb8279185f", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "ext-curl": "*", diff --git a/vendor/guzzlehttp/guzzle/.php_cs b/vendor/guzzlehttp/guzzle/.php_cs index a8ace8aa..2dd5036c 100644 --- a/vendor/guzzlehttp/guzzle/.php_cs +++ b/vendor/guzzlehttp/guzzle/.php_cs @@ -7,13 +7,15 @@ $config = PhpCsFixer\Config::create() 'array_syntax' => ['syntax' => 'short'], 'declare_strict_types' => false, 'concat_space' => ['spacing'=>'one'], - // 'ordered_imports' => true, + 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], + 'ordered_imports' => true, // 'phpdoc_align' => ['align'=>'vertical'], // 'native_function_invocation' => true, ]) ->setFinder( PhpCsFixer\Finder::create() ->in(__DIR__.'/src') + ->in(__DIR__.'/tests') ->name('*.php') ) ; diff --git a/vendor/guzzlehttp/guzzle/CHANGELOG.md b/vendor/guzzlehttp/guzzle/CHANGELOG.md index 65557498..a2b61e71 100644 --- a/vendor/guzzlehttp/guzzle/CHANGELOG.md +++ b/vendor/guzzlehttp/guzzle/CHANGELOG.md @@ -1,5 +1,23 @@ # Change Log +## 6.5.2 - 2019-12-23 + +* idn_to_ascii() fix for old PHP versions [#2489](https://github.com/guzzle/guzzle/pull/2489) + +## 6.5.1 - 2019-12-21 + +* Better defaults for PHP installations with old ICU lib [#2454](https://github.com/guzzle/guzzle/pull/2454) +* IDN support for redirects [#2424](https://github.com/guzzle/guzzle/pull/2424) + +## 6.5.0 - 2019-12-07 + +* Improvement: Added support for reset internal queue in MockHandler. [#2143](https://github.com/guzzle/guzzle/pull/2143) +* Improvement: Added support to pass arbitrary options to `curl_multi_init`. [#2287](https://github.com/guzzle/guzzle/pull/2287) +* Fix: Gracefully handle passing `null` to the `header` option. [#2132](https://github.com/guzzle/guzzle/pull/2132) +* Fix: `RetryMiddleware` did not do exponential delay between retires due unit mismatch. [#2132](https://github.com/guzzle/guzzle/pull/2132) +* Fix: Prevent undefined offset when using array for ssl_key options. [#2348](https://github.com/guzzle/guzzle/pull/2348) +* Deprecated `ClientInterface::VERSION` + ## 6.4.1 - 2019-10-23 * No `guzzle.phar` was created in 6.4.0 due expired API token. This release will fix that diff --git a/vendor/guzzlehttp/guzzle/README.md b/vendor/guzzlehttp/guzzle/README.md index a5ef18ae..5fdb6c5f 100644 --- a/vendor/guzzlehttp/guzzle/README.md +++ b/vendor/guzzlehttp/guzzle/README.md @@ -78,7 +78,7 @@ composer update |---------|------------|---------------------|--------------|---------------------|---------------------|-------|-------------| | 3.x | EOL | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | >= 5.3.3 | | 4.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v4][guzzle-4-repo] | N/A | No | >= 5.4 | -| 5.x | Maintained | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >= 5.4 | +| 5.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >= 5.4 | | 6.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >= 5.5 | [guzzle-3-repo]: https://github.com/guzzle/guzzle3 diff --git a/vendor/guzzlehttp/guzzle/composer.json b/vendor/guzzlehttp/guzzle/composer.json index c5532575..bbf0ff20 100644 --- a/vendor/guzzlehttp/guzzle/composer.json +++ b/vendor/guzzlehttp/guzzle/composer.json @@ -32,14 +32,15 @@ "psr/log": "^1.1" }, "suggest": { - "psr/log": "Required for using the Log middleware" + "psr/log": "Required for using the Log middleware", + "ext-intl": "Required for Internationalized Domain Name (IDN) support" }, "config": { "sort-packages": true }, "extra": { "branch-alias": { - "dev-master": "6.3-dev" + "dev-master": "6.5-dev" } }, "autoload": { diff --git a/vendor/guzzlehttp/guzzle/phpstan.neon.dist b/vendor/guzzlehttp/guzzle/phpstan.neon.dist deleted file mode 100644 index 4ef4192d..00000000 --- a/vendor/guzzlehttp/guzzle/phpstan.neon.dist +++ /dev/null @@ -1,9 +0,0 @@ -parameters: - level: 1 - paths: - - src - - ignoreErrors: - - - message: '#Function uri_template not found#' - path: %currentWorkingDirectory%/src/functions.php diff --git a/vendor/guzzlehttp/guzzle/src/Client.php b/vendor/guzzlehttp/guzzle/src/Client.php index 0f43c71f..f2bf2044 100644 --- a/vendor/guzzlehttp/guzzle/src/Client.php +++ b/vendor/guzzlehttp/guzzle/src/Client.php @@ -2,11 +2,12 @@ namespace GuzzleHttp; use GuzzleHttp\Cookie\CookieJar; +use GuzzleHttp\Exception\InvalidArgumentException; use GuzzleHttp\Promise; use GuzzleHttp\Psr7; -use Psr\Http\Message\UriInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\UriInterface; /** * @method ResponseInterface get(string|UriInterface $uri, array $options = []) @@ -75,6 +76,12 @@ class Client implements ClientInterface $this->configureDefaults($config); } + /** + * @param string $method + * @param array $args + * + * @return Promise\PromiseInterface + */ public function __call($method, $args) { if (count($args) < 1) { @@ -89,6 +96,14 @@ class Client implements ClientInterface : $this->request($method, $uri, $opts); } + /** + * Asynchronously send an HTTP request. + * + * @param array $options Request options to apply to the given + * request and to the transfer. See \GuzzleHttp\RequestOptions. + * + * @return Promise\PromiseInterface + */ public function sendAsync(RequestInterface $request, array $options = []) { // Merge the base URI into the request URI if needed. @@ -100,12 +115,35 @@ class Client implements ClientInterface ); } + /** + * Send an HTTP request. + * + * @param array $options Request options to apply to the given + * request and to the transfer. See \GuzzleHttp\RequestOptions. + * + * @return ResponseInterface + * @throws GuzzleException + */ public function send(RequestInterface $request, array $options = []) { $options[RequestOptions::SYNCHRONOUS] = true; return $this->sendAsync($request, $options)->wait(); } + /** + * Create and send an asynchronous HTTP request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. Use an array to provide a URL + * template and additional variables to use in the URL template expansion. + * + * @param string $method HTTP method + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. See \GuzzleHttp\RequestOptions. + * + * @return Promise\PromiseInterface + */ public function requestAsync($method, $uri = '', array $options = []) { $options = $this->prepareDefaults($options); @@ -125,12 +163,37 @@ class Client implements ClientInterface return $this->transfer($request, $options); } + /** + * Create and send an HTTP request. + * + * Use an absolute path to override the base path of the client, or a + * relative path to append to the base path of the client. The URL can + * contain the query string as well. + * + * @param string $method HTTP method. + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. See \GuzzleHttp\RequestOptions. + * + * @return ResponseInterface + * @throws GuzzleException + */ public function request($method, $uri = '', array $options = []) { $options[RequestOptions::SYNCHRONOUS] = true; return $this->requestAsync($method, $uri, $options)->wait(); } + /** + * Get a client configuration option. + * + * These options include default request options of the client, a "handler" + * (if utilized by the concrete client), and a "base_uri" if utilized by + * the concrete client. + * + * @param string|null $option The config option to retrieve. + * + * @return mixed + */ public function getConfig($option = null) { return $option === null @@ -138,6 +201,11 @@ class Client implements ClientInterface : (isset($this->config[$option]) ? $this->config[$option] : null); } + /** + * @param string|null $uri + * + * @return UriInterface + */ private function buildUri($uri, array $config) { // for BC we accept null which would otherwise fail in uri_for @@ -147,6 +215,11 @@ class Client implements ClientInterface $uri = Psr7\UriResolver::resolve(Psr7\uri_for($config['base_uri']), $uri); } + if (isset($config['idn_conversion']) && ($config['idn_conversion'] !== false)) { + $idnOptions = ($config['idn_conversion'] === true) ? IDNA_DEFAULT : $config['idn_conversion']; + $uri = _idn_uri_convert($uri, $idnOptions); + } + return $uri->getScheme() === '' && $uri->getHost() !== '' ? $uri->withScheme('http') : $uri; } @@ -154,6 +227,7 @@ class Client implements ClientInterface * Configures the default options for a client. * * @param array $config + * @return void */ private function configureDefaults(array $config) { @@ -165,12 +239,22 @@ class Client implements ClientInterface 'cookies' => false ]; + // idn_to_ascii() is a part of ext-intl and might be not available + $defaults['idn_conversion'] = function_exists('idn_to_ascii') + // Old ICU versions don't have this constant, so we are basically stuck (see https://github.com/guzzle/guzzle/pull/2424 + // and https://github.com/guzzle/guzzle/issues/2448 for details) + && ( + defined('INTL_IDNA_VARIANT_UTS46') + || + PHP_VERSION_ID < 70200 + ); + // Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set. // We can only trust the HTTP_PROXY environment variable in a CLI // process due to the fact that PHP has no reliable mechanism to // get environment variables that start with "HTTP_". - if (php_sapi_name() == 'cli' && getenv('HTTP_PROXY')) { + if (php_sapi_name() === 'cli' && getenv('HTTP_PROXY')) { $defaults['proxy']['http'] = getenv('HTTP_PROXY'); } @@ -225,7 +309,7 @@ class Client implements ClientInterface if (array_key_exists('headers', $options)) { // Allows default headers to be unset. if ($options['headers'] === null) { - $defaults['_conditional'] = null; + $defaults['_conditional'] = []; unset($options['headers']); } elseif (!is_array($options['headers'])) { throw new \InvalidArgumentException('headers must be an array'); @@ -251,8 +335,7 @@ class Client implements ClientInterface * The URI of the request is not modified and the request options are used * as-is without merging in default options. * - * @param RequestInterface $request - * @param array $options + * @param array $options See \GuzzleHttp\RequestOptions. * * @return Promise\PromiseInterface */ @@ -271,6 +354,7 @@ class Client implements ClientInterface } $request = $this->applyOptions($request, $options); + /** @var HandlerStack $handler */ $handler = $options['handler']; try { @@ -411,6 +495,11 @@ class Client implements ClientInterface return $request; } + /** + * Throw Exception with pre-set message. + * @return void + * @throws InvalidArgumentException Invalid body. + */ private function invalidBody() { throw new \InvalidArgumentException('Passing in the "body" request ' diff --git a/vendor/guzzlehttp/guzzle/src/ClientInterface.php b/vendor/guzzlehttp/guzzle/src/ClientInterface.php index 5b370851..0c8d42a1 100644 --- a/vendor/guzzlehttp/guzzle/src/ClientInterface.php +++ b/vendor/guzzlehttp/guzzle/src/ClientInterface.php @@ -1,8 +1,8 @@ cookies as $cookie) { @@ -103,6 +103,8 @@ class CookieJar implements CookieJarInterface return $cookie; } } + + return null; } public function toArray() diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php b/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php index 2cf298a8..6ee11885 100644 --- a/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php +++ b/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php @@ -58,9 +58,9 @@ interface CookieJarInterface extends \Countable, \IteratorAggregate * arguments, then the cookie with the specified name, path and domain is * removed. * - * @param string $domain Clears cookies matching a domain - * @param string $path Clears cookies matching a domain and path - * @param string $name Clears cookies matching a domain, path, and name + * @param string|null $domain Clears cookies matching a domain + * @param string|null $path Clears cookies matching a domain and path + * @param string|null $name Clears cookies matching a domain, path, and name * * @return CookieJarInterface */ diff --git a/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php b/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php index f38ca864..12dd081e 100644 --- a/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php +++ b/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php @@ -1,9 +1,9 @@ getBody(); - - if (!$body->isSeekable() || !$body->isReadable()) { - return null; - } - - $size = $body->getSize(); - - if ($size === 0) { - return null; - } - - $summary = $body->read(120); - $body->rewind(); - - if ($size > 120) { - $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]/', $summary)) { - return null; - } - - return $summary; + return \GuzzleHttp\Psr7\get_message_body_summary($response); } /** - * Obfuscates URI if there is an username and a password present + * Obfuscates URI if there is a username and a password present * * @param UriInterface $uri * * @return UriInterface */ - private static function obfuscateUri($uri) + private static function obfuscateUri(UriInterface $uri) { $userInfo = $uri->getUserInfo(); diff --git a/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php b/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php index e349bb4c..4a28a96e 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php @@ -1,8 +1,8 @@ selectTimeout = 1; } + + $this->options = isset($options['options']) ? $options['options'] : []; } public function __get($name) { if ($name === '_mh') { - return $this->_mh = curl_multi_init(); + $this->_mh = curl_multi_init(); + + foreach ($this->options as $option => $value) { + // A warning is raised in case of a wrong option. + curl_multi_setopt($this->_mh, $option, $value); + } + + // Further calls to _mh will return the value directly, without entering the + // __get() method at all. + return $this->_mh; } throw new \BadMethodCallException(); diff --git a/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php b/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php index d5c449c1..5b312bc0 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php @@ -66,7 +66,7 @@ class MockHandler implements \Countable throw new \OutOfBoundsException('Mock queue is empty'); } - if (isset($options['delay'])) { + if (isset($options['delay']) && is_numeric($options['delay'])) { usleep($options['delay'] * 1000); } @@ -175,6 +175,11 @@ class MockHandler implements \Countable return count($this->queue); } + public function reset() + { + $this->queue = []; + } + private function invokeStats( RequestInterface $request, array $options, diff --git a/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php b/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php index 0dedd7da..a8eba378 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php @@ -1,8 +1,8 @@ each = new EachPromise($requests(), $config); } + /** + * Get promise + * + * @return PromiseInterface + */ public function promise() { return $this->each->promise(); @@ -106,6 +112,11 @@ class Pool implements PromisorInterface return $res; } + /** + * Execute callback(s) + * + * @return void + */ private static function cmpCallback(array &$options, $name, array &$results) { if (!isset($options[$name])) { diff --git a/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php b/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php index 2eb95f9b..568a1e90 100644 --- a/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php +++ b/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php @@ -66,6 +66,11 @@ class PrepareBodyMiddleware return $fn(Psr7\modify_request($request, $modify), $options); } + /** + * Add expect header + * + * @return void + */ private function addExpectHeader( RequestInterface $request, array $options, diff --git a/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php b/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php index bff4e4e8..2f301261 100644 --- a/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php +++ b/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php @@ -13,7 +13,7 @@ use Psr\Http\Message\UriInterface; * Request redirect middleware. * * Apply this middleware like other middleware using - * {@see GuzzleHttp\Middleware::redirect()}. + * {@see \GuzzleHttp\Middleware::redirect()}. */ class RedirectMiddleware { @@ -76,7 +76,7 @@ class RedirectMiddleware /** * @param RequestInterface $request * @param array $options - * @param ResponseInterface|PromiseInterface $response + * @param ResponseInterface $response * * @return ResponseInterface|PromiseInterface */ @@ -118,6 +118,11 @@ class RedirectMiddleware return $promise; } + /** + * Enable tracking on promise. + * + * @return PromiseInterface + */ private function withTracking(PromiseInterface $promise, $uri, $statusCode) { return $promise->then( @@ -135,6 +140,13 @@ class RedirectMiddleware ); } + /** + * Check for too many redirects + * + * @return void + * + * @throws TooManyRedirectsException Too many redirects. + */ private function guardMax(RequestInterface $request, array &$options) { $current = isset($options['__redirect_count']) @@ -172,13 +184,19 @@ class RedirectMiddleware // would do. $statusCode = $response->getStatusCode(); if ($statusCode == 303 || - ($statusCode <= 302 && $request->getBody() && !$options['allow_redirects']['strict']) + ($statusCode <= 302 && !$options['allow_redirects']['strict']) ) { $modify['method'] = 'GET'; $modify['body'] = ''; } - $modify['uri'] = $this->redirectUri($request, $response, $protocols); + $uri = $this->redirectUri($request, $response, $protocols); + if (isset($options['idn_conversion']) && ($options['idn_conversion'] !== false)) { + $idnOptions = ($options['idn_conversion'] === true) ? IDNA_DEFAULT : $options['idn_conversion']; + $uri = _idn_uri_convert($uri, $idnOptions); + } + + $modify['uri'] = $uri; Psr7\rewind_body($request); // Add the Referer header if it is told to do so and only diff --git a/vendor/guzzlehttp/guzzle/src/RequestOptions.php b/vendor/guzzlehttp/guzzle/src/RequestOptions.php index 5c0fd19d..355f658f 100644 --- a/vendor/guzzlehttp/guzzle/src/RequestOptions.php +++ b/vendor/guzzlehttp/guzzle/src/RequestOptions.php @@ -132,6 +132,14 @@ final class RequestOptions */ const HTTP_ERRORS = 'http_errors'; + /** + * idn: (bool|int, default=true) A combination of IDNA_* constants for + * idn_to_ascii() PHP's function (see "options" parameter). Set to false to + * disable IDN support completely, or to true to use the default + * configuration (IDNA_DEFAULT constant). + */ + const IDN_CONVERSION = 'idn_conversion'; + /** * json: (mixed) Adds JSON data to a request. The provided value is JSON * encoded and a Content-Type header of application/json will be added to diff --git a/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php b/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php index 7d40ecaf..5acc8c5c 100644 --- a/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php +++ b/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php @@ -47,11 +47,11 @@ class RetryMiddleware * * @param int $retries * - * @return int + * @return int milliseconds. */ public static function exponentialDelay($retries) { - return (int) pow(2, $retries - 1); + return (int) pow(2, $retries - 1) * 1000; } /** @@ -74,6 +74,11 @@ class RetryMiddleware ); } + /** + * Execute fulfilled closure + * + * @return mixed + */ private function onFulfilled(RequestInterface $req, array $options) { return function ($value) use ($req, $options) { @@ -90,6 +95,11 @@ class RetryMiddleware }; } + /** + * Execute rejected closure + * + * @return callable + */ private function onRejected(RequestInterface $req, array $options) { return function ($reason) use ($req, $options) { @@ -106,6 +116,9 @@ class RetryMiddleware }; } + /** + * @return self + */ private function doRetry(RequestInterface $request, array $options, ResponseInterface $response = null) { $options['delay'] = call_user_func($this->delay, ++$options['retries'], $response); diff --git a/vendor/guzzlehttp/guzzle/src/TransferStats.php b/vendor/guzzlehttp/guzzle/src/TransferStats.php index 23a22a33..87fb3c00 100644 --- a/vendor/guzzlehttp/guzzle/src/TransferStats.php +++ b/vendor/guzzlehttp/guzzle/src/TransferStats.php @@ -18,11 +18,11 @@ final class TransferStats private $handlerErrorData; /** - * @param RequestInterface $request Request that was sent. - * @param ResponseInterface $response Response received (if any) - * @param float|null $transferTime Total handler transfer time. - * @param mixed $handlerErrorData Handler error data. - * @param array $handlerStats Handler specific stats. + * @param RequestInterface $request Request that was sent. + * @param ResponseInterface|null $response Response received (if any) + * @param float|null $transferTime Total handler transfer time. + * @param mixed $handlerErrorData Handler error data. + * @param array $handlerStats Handler specific stats. */ public function __construct( RequestInterface $request, @@ -93,7 +93,7 @@ final class TransferStats /** * Get the estimated time the request was being transferred by the handler. * - * @return float Time in seconds. + * @return float|null Time in seconds. */ public function getTransferTime() { diff --git a/vendor/guzzlehttp/guzzle/src/functions.php b/vendor/guzzlehttp/guzzle/src/functions.php index 51d736d8..5e806f63 100644 --- a/vendor/guzzlehttp/guzzle/src/functions.php +++ b/vendor/guzzlehttp/guzzle/src/functions.php @@ -1,10 +1,12 @@ getHost()) { + $idnaVariant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : 0; + $asciiHost = $idnaVariant === 0 + ? idn_to_ascii($uri->getHost(), $options) + : idn_to_ascii($uri->getHost(), $options, $idnaVariant, $info); + if ($asciiHost === false) { + $errorBitSet = isset($info['errors']) ? $info['errors'] : 0; + + $errorConstants = array_filter(array_keys(get_defined_constants()), function ($name) { + return substr($name, 0, 11) === 'IDNA_ERROR_'; + }); + + $errors = []; + foreach ($errorConstants as $errorConstant) { + if ($errorBitSet & constant($errorConstant)) { + $errors[] = $errorConstant; + } + } + + $errorMessage = 'IDN conversion failed'; + if ($errors) { + $errorMessage .= ' (errors: ' . implode(', ', $errors) . ')'; + } + + throw new InvalidArgumentException($errorMessage); + } else { + if ($uri->getHost() !== $asciiHost) { + // Replace URI only if the ASCII version is different + $uri = $uri->withHost($asciiHost); + } + } + } + + return $uri; +} diff --git a/vendor/phpmailer/phpmailer/README.md b/vendor/phpmailer/phpmailer/README.md index a000c930..d8a0f4e3 100644 --- a/vendor/phpmailer/phpmailer/README.md +++ b/vendor/phpmailer/phpmailer/README.md @@ -6,11 +6,11 @@ Build status: [![Build Status](https://travis-ci.org/PHPMailer/PHPMailer.svg)](h [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/badges/quality-score.png?s=3758e21d279becdf847a557a56a3ed16dfec9d5d)](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/) [![Code Coverage](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/badges/coverage.png?s=3fe6ca5fe8cd2cdf96285756e42932f7ca256962)](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/) -[![Latest Stable Version](https://poser.pugx.org/phpmailer/phpmailer/v/stable.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![Total Downloads](https://poser.pugx.org/phpmailer/phpmailer/downloads)](https://packagist.org/packages/phpmailer/phpmailer) [![Latest Unstable Version](https://poser.pugx.org/phpmailer/phpmailer/v/unstable.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![License](https://poser.pugx.org/phpmailer/phpmailer/license.svg)](https://packagist.org/packages/phpmailer/phpmailer) +[![Latest Stable Version](https://poser.pugx.org/phpmailer/phpmailer/v/stable.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![Total Downloads](https://poser.pugx.org/phpmailer/phpmailer/downloads)](https://packagist.org/packages/phpmailer/phpmailer) [![Latest Unstable Version](https://poser.pugx.org/phpmailer/phpmailer/v/unstable.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![License](https://poser.pugx.org/phpmailer/phpmailer/license.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![API Docs](https://github.com/phpmailer/phpmailer/workflows/Docs/badge.svg)](http://phpmailer.github.io/PHPMailer/) ## Class Features - Probably the world's most popular code for sending email from PHP! -- Used by many open-source projects: WordPress, Drupal, 1CRM, SugarCRM, Yii, Joomla!, and many more +- Used by many open-source projects: WordPress, Drupal, 1CRM, SugarCRM, Yii, Joomla! and many more - Integrated SMTP support - send without a local mail server - Send emails with multiple To, CC, BCC and Reply-to addresses - Multipart/alternative emails for mail clients that do not read HTML email diff --git a/vendor/phpmailer/phpmailer/VERSION b/vendor/phpmailer/phpmailer/VERSION index 132c6def..1879c1be 100644 --- a/vendor/phpmailer/phpmailer/VERSION +++ b/vendor/phpmailer/phpmailer/VERSION @@ -1 +1 @@ -6.1.1 \ No newline at end of file +6.1.4 \ No newline at end of file diff --git a/vendor/phpmailer/phpmailer/composer.json b/vendor/phpmailer/phpmailer/composer.json index d1b14171..fd0695c8 100644 --- a/vendor/phpmailer/phpmailer/composer.json +++ b/vendor/phpmailer/phpmailer/composer.json @@ -26,12 +26,8 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.2", - "phpdocumentor/phpdocumentor": "2.*", "phpunit/phpunit": "^4.8 || ^5.7", - "zendframework/zend-serializer": "2.7.*", - "doctrine/annotations": "1.2.*", - "zendframework/zend-eventmanager": "3.0.*", - "zendframework/zend-i18n": "2.7.3" + "doctrine/annotations": "^1.2" }, "suggest": { "psr/log": "For optional PSR-3 debug logging", diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-nl.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-nl.php index 2fb01b2d..f4d0e7cd 100644 --- a/vendor/phpmailer/phpmailer/language/phpmailer.lang-nl.php +++ b/vendor/phpmailer/phpmailer/language/phpmailer.lang-nl.php @@ -16,6 +16,8 @@ $PHPMAILER_LANG['file_open'] = 'Bestandsfout: kon bestand niet openen $PHPMAILER_LANG['from_failed'] = 'Het volgende afzendersadres is mislukt: '; $PHPMAILER_LANG['instantiate'] = 'Kon mailfunctie niet initialiseren.'; $PHPMAILER_LANG['invalid_address'] = 'Ongeldig adres: '; +$PHPMAILER_LANG['invalid_hostentry'] = 'Ongeldige hostentry: '; +$PHPMAILER_LANG['invalid_host'] = 'Ongeldige host: '; $PHPMAILER_LANG['mailer_not_supported'] = ' mailer wordt niet ondersteund.'; $PHPMAILER_LANG['provide_address'] = 'Er moet minstens één ontvanger worden opgegeven.'; $PHPMAILER_LANG['recipients_failed'] = 'SMTP-fout: de volgende ontvangers zijn mislukt: '; diff --git a/vendor/phpmailer/phpmailer/src/OAuth.php b/vendor/phpmailer/phpmailer/src/OAuth.php index 0bce7e34..0271963c 100644 --- a/vendor/phpmailer/phpmailer/src/OAuth.php +++ b/vendor/phpmailer/phpmailer/src/OAuth.php @@ -123,7 +123,7 @@ class OAuth public function getOauth64() { // Get a new token if it's not available or has expired - if (null === $this->oauthToken or $this->oauthToken->hasExpired()) { + if (null === $this->oauthToken || $this->oauthToken->hasExpired()) { $this->oauthToken = $this->getToken(); } diff --git a/vendor/phpmailer/phpmailer/src/PHPMailer.php b/vendor/phpmailer/phpmailer/src/PHPMailer.php index 4897b5e2..127f2b79 100644 --- a/vendor/phpmailer/phpmailer/src/PHPMailer.php +++ b/vendor/phpmailer/phpmailer/src/PHPMailer.php @@ -745,7 +745,7 @@ class PHPMailer * * @var string */ - const VERSION = '6.1.1'; + const VERSION = '6.1.4'; /** * Error severity: message only, continue processing. @@ -848,7 +848,7 @@ class PHPMailer $subject = $this->encodeHeader($this->secureHeader($subject)); } //Calling mail() with null params breaks - if (!$this->UseSendmailOptions or null === $params) { + if (!$this->UseSendmailOptions || null === $params) { $result = @mail($to, $subject, $body, $header); } else { $result = @mail($to, $subject, $body, $header, $params); @@ -878,7 +878,7 @@ class PHPMailer return; } //Avoid clash with built-in function names - if (!in_array($this->Debugoutput, ['error_log', 'html', 'echo']) and is_callable($this->Debugoutput)) { + if (is_callable($this->Debugoutput) && !in_array($this->Debugoutput, ['error_log', 'html', 'echo'])) { call_user_func($this->Debugoutput, $str, $this->SMTPDebug); return; @@ -899,12 +899,12 @@ class PHPMailer case 'echo': default: //Normalize line breaks - $str = preg_replace('/\r\n|\r/ms', "\n", $str); + $str = preg_replace('/\r\n|\r/m', "\n", $str); echo gmdate('Y-m-d H:i:s'), "\t", //Trim trailing space trim( - //Indent for readability, except for trailing break + //Indent for readability, except for trailing break str_replace( "\n", "\n \t ", @@ -1072,19 +1072,17 @@ class PHPMailer } $params = [$kind, $address, $name]; // Enqueue addresses with IDN until we know the PHPMailer::$CharSet. - if ($this->has8bitChars(substr($address, ++$pos)) and static::idnSupported()) { - if ('Reply-To' != $kind) { + if (static::idnSupported() && $this->has8bitChars(substr($address, ++$pos))) { + if ('Reply-To' !== $kind) { if (!array_key_exists($address, $this->RecipientsQueue)) { $this->RecipientsQueue[$address] = $params; return true; } - } else { - if (!array_key_exists($address, $this->ReplyToQueue)) { - $this->ReplyToQueue[$address] = $params; + } elseif (!array_key_exists($address, $this->ReplyToQueue)) { + $this->ReplyToQueue[$address] = $params; - return true; - } + return true; } return false; @@ -1137,19 +1135,17 @@ class PHPMailer return false; } - if ('Reply-To' != $kind) { + if ('Reply-To' !== $kind) { if (!array_key_exists(strtolower($address), $this->all_recipients)) { $this->{$kind}[] = [$address, $name]; $this->all_recipients[strtolower($address)] = true; return true; } - } else { - if (!array_key_exists(strtolower($address), $this->ReplyTo)) { - $this->ReplyTo[strtolower($address)] = [$address, $name]; + } elseif (!array_key_exists(strtolower($address), $this->ReplyTo)) { + $this->ReplyTo[strtolower($address)] = [$address, $name]; - return true; - } + return true; } return false; @@ -1171,17 +1167,17 @@ class PHPMailer public static function parseAddresses($addrstr, $useimap = true) { $addresses = []; - if ($useimap and function_exists('imap_rfc822_parse_adrlist')) { + if ($useimap && function_exists('imap_rfc822_parse_adrlist')) { //Use this built-in parser if it's available $list = imap_rfc822_parse_adrlist($addrstr, ''); foreach ($list as $address) { - if ('.SYNTAX-ERROR.' != $address->host) { - if (static::validateAddress($address->mailbox . '@' . $address->host)) { - $addresses[] = [ - 'name' => (property_exists($address, 'personal') ? $address->personal : ''), - 'address' => $address->mailbox . '@' . $address->host, - ]; - } + if (('.SYNTAX-ERROR.' !== $address->host) && static::validateAddress( + $address->mailbox . '@' . $address->host + )) { + $addresses[] = [ + 'name' => (property_exists($address, 'personal') ? $address->personal : ''), + 'address' => $address->mailbox . '@' . $address->host, + ]; } } } else { @@ -1231,9 +1227,9 @@ class PHPMailer $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim // Don't validate now addresses with IDN. Will be done in send(). $pos = strrpos($address, '@'); - if (false === $pos - or (!$this->has8bitChars(substr($address, ++$pos)) or !static::idnSupported()) - and !static::validateAddress($address) + if ((false === $pos) + || ((!$this->has8bitChars(substr($address, ++$pos)) || !static::idnSupported()) + && !static::validateAddress($address)) ) { $error_message = sprintf( '%s (From): %s', @@ -1250,10 +1246,8 @@ class PHPMailer } $this->From = $address; $this->FromName = $name; - if ($auto) { - if (empty($this->Sender)) { - $this->Sender = $address; - } + if ($auto && empty($this->Sender)) { + $this->Sender = $address; } return true; @@ -1302,10 +1296,10 @@ class PHPMailer $patternselect = static::$validator; } if (is_callable($patternselect)) { - return call_user_func($patternselect, $address); + return $patternselect($address); } //Reject line breaks in addresses; it's valid RFC5322, but not RFC5321 - if (strpos($address, "\n") !== false or strpos($address, "\r") !== false) { + if (strpos($address, "\n") !== false || strpos($address, "\r") !== false) { return false; } switch ($patternselect) { @@ -1352,7 +1346,7 @@ class PHPMailer ); case 'php': default: - return (bool) filter_var($address, FILTER_VALIDATE_EMAIL); + return filter_var($address, FILTER_VALIDATE_EMAIL) !== false; } } @@ -1364,7 +1358,7 @@ class PHPMailer */ public static function idnSupported() { - return function_exists('idn_to_ascii') and function_exists('mb_convert_encoding'); + return function_exists('idn_to_ascii') && function_exists('mb_convert_encoding'); } /** @@ -1385,17 +1379,23 @@ class PHPMailer { // Verify we have required functions, CharSet, and at-sign. $pos = strrpos($address, '@'); - if (static::idnSupported() and - !empty($this->CharSet) and - false !== $pos + if (!empty($this->CharSet) && + false !== $pos && + static::idnSupported() ) { $domain = substr($address, ++$pos); // Verify CharSet string is a valid one, and domain properly encoded in this CharSet. - if ($this->has8bitChars($domain) and @mb_check_encoding($domain, $this->CharSet)) { + if ($this->has8bitChars($domain) && @mb_check_encoding($domain, $this->CharSet)) { $domain = mb_convert_encoding($domain, 'UTF-8', $this->CharSet); //Ignore IDE complaints about this line - method signature changed in PHP 5.4 $errorcode = 0; - $punycode = idn_to_ascii($domain, $errorcode, INTL_IDNA_VARIANT_UTS46); + if (defined('INTL_IDNA_VARIANT_UTS46')) { + $punycode = idn_to_ascii($domain, $errorcode, INTL_IDNA_VARIANT_UTS46); + } elseif (defined('INTL_IDNA_VARIANT_2003')) { + $punycode = idn_to_ascii($domain, $errorcode, INTL_IDNA_VARIANT_2003); + } else { + $punycode = idn_to_ascii($domain, $errorcode); + } if (false !== $punycode) { return substr($address, 0, $pos) . $punycode; } @@ -1441,8 +1441,8 @@ class PHPMailer */ public function preSend() { - if ('smtp' == $this->Mailer - or ('mail' == $this->Mailer and stripos(PHP_OS, 'WIN') === 0) + if ('smtp' === $this->Mailer + || ('mail' === $this->Mailer && stripos(PHP_OS, 'WIN') === 0) ) { //SMTP mandates RFC-compliant line endings //and it's also used with mail() on Windows @@ -1452,13 +1452,11 @@ class PHPMailer static::setLE(PHP_EOL); } //Check for buggy PHP versions that add a header with an incorrect line break - if (ini_get('mail.add_x_header') == 1 - and 'mail' == $this->Mailer - and stripos(PHP_OS, 'WIN') === 0 - and ((version_compare(PHP_VERSION, '7.0.0', '>=') - and version_compare(PHP_VERSION, '7.0.17', '<')) - or (version_compare(PHP_VERSION, '7.1.0', '>=') - and version_compare(PHP_VERSION, '7.1.3', '<'))) + if ('mail' === $this->Mailer + && ((PHP_VERSION_ID >= 70000 && PHP_VERSION_ID < 70017) + || (PHP_VERSION_ID >= 70100 && PHP_VERSION_ID < 70103)) + && ini_get('mail.add_x_header') === '1' + && stripos(PHP_OS, 'WIN') === 0 ) { trigger_error( 'Your version of PHP is affected by a bug that may result in corrupted messages.' . @@ -1512,7 +1510,7 @@ class PHPMailer $this->setMessageType(); // Refuse to send an empty message unless we are specifically allowing it - if (!$this->AllowEmpty and empty($this->Body)) { + if (!$this->AllowEmpty && empty($this->Body)) { throw new Exception($this->lang('empty_message'), self::STOP_CRITICAL); } @@ -1528,7 +1526,7 @@ class PHPMailer // To capture the complete message when using mail(), create // an extra header list which createHeader() doesn't fold in - if ('mail' == $this->Mailer) { + if ('mail' === $this->Mailer) { if (count($this->to) > 0) { $this->mailHeader .= $this->addrAppend('To', $this->to); } else { @@ -1542,11 +1540,11 @@ class PHPMailer // Sign with DKIM if enabled if (!empty($this->DKIM_domain) - and !empty($this->DKIM_selector) - and (!empty($this->DKIM_private_string) - or (!empty($this->DKIM_private) - and static::isPermittedPath($this->DKIM_private) - and file_exists($this->DKIM_private) + && !empty($this->DKIM_selector) + && (!empty($this->DKIM_private_string) + || (!empty($this->DKIM_private) + && static::isPermittedPath($this->DKIM_private) + && file_exists($this->DKIM_private) ) ) ) { @@ -1622,19 +1620,19 @@ class PHPMailer */ protected function sendmailSend($header, $body) { + $header = rtrim($header, "\r\n ") . static::$LE . static::$LE; + // CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped. - if (!empty($this->Sender) and self::isShellSafe($this->Sender)) { - if ('qmail' == $this->Mailer) { + if (!empty($this->Sender) && self::isShellSafe($this->Sender)) { + if ('qmail' === $this->Mailer) { $sendmailFmt = '%s -f%s'; } else { $sendmailFmt = '%s -oi -f%s -t'; } + } elseif ('qmail' === $this->Mailer) { + $sendmailFmt = '%s'; } else { - if ('qmail' == $this->Mailer) { - $sendmailFmt = '%s'; - } else { - $sendmailFmt = '%s -oi -t'; - } + $sendmailFmt = '%s -oi -t'; } $sendmail = sprintf($sendmailFmt, escapeshellcmd($this->Sendmail), $this->Sender); @@ -1650,7 +1648,7 @@ class PHPMailer fwrite($mail, $body); $result = pclose($mail); $this->doCallback( - ($result == 0), + ($result === 0), [$toAddr], $this->cc, $this->bcc, @@ -1672,7 +1670,7 @@ class PHPMailer fwrite($mail, $body); $result = pclose($mail); $this->doCallback( - ($result == 0), + ($result === 0), $this->to, $this->cc, $this->bcc, @@ -1703,7 +1701,7 @@ class PHPMailer { // Future-proof if (escapeshellcmd($string) !== $string - or !in_array(escapeshellarg($string), ["'$string'", "\"$string\""]) + || !in_array(escapeshellarg($string), ["'$string'", "\"$string\""]) ) { return false; } @@ -1752,6 +1750,8 @@ class PHPMailer */ protected function mailSend($header, $body) { + $header = rtrim($header, "\r\n ") . static::$LE . static::$LE; + $toArr = []; foreach ($this->to as $toaddr) { $toArr[] = $this->addrFormat($toaddr); @@ -1760,24 +1760,22 @@ class PHPMailer $params = null; //This sets the SMTP envelope sender which gets turned into a return-path header by the receiver - if (!empty($this->Sender) and static::validateAddress($this->Sender)) { - //A space after `-f` is optional, but there is a long history of its presence - //causing problems, so we don't use one - //Exim docs: http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html - //Sendmail docs: http://www.sendmail.org/~ca/email/man/sendmail.html - //Qmail docs: http://www.qmail.org/man/man8/qmail-inject.html - //Example problem: https://www.drupal.org/node/1057954 - // CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped. - if (self::isShellSafe($this->Sender)) { - $params = sprintf('-f%s', $this->Sender); - } + //A space after `-f` is optional, but there is a long history of its presence + //causing problems, so we don't use one + //Exim docs: http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html + //Sendmail docs: http://www.sendmail.org/~ca/email/man/sendmail.html + //Qmail docs: http://www.qmail.org/man/man8/qmail-inject.html + //Example problem: https://www.drupal.org/node/1057954 + // CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped. + if (!empty($this->Sender) && static::validateAddress($this->Sender) && self::isShellSafe($this->Sender)) { + $params = sprintf('-f%s', $this->Sender); } - if (!empty($this->Sender) and static::validateAddress($this->Sender)) { + if (!empty($this->Sender) && static::validateAddress($this->Sender)) { $old_from = ini_get('sendmail_from'); ini_set('sendmail_from', $this->Sender); } $result = false; - if ($this->SingleTo and count($toArr) > 1) { + if ($this->SingleTo && count($toArr) > 1) { foreach ($toArr as $toAddr) { $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params); $this->doCallback($result, [$toAddr], $this->cc, $this->bcc, $this->Subject, $body, $this->From, []); @@ -1815,8 +1813,6 @@ class PHPMailer /** * Provide an instance to use for SMTP operations. * - * @param SMTP $smtp - * * @return SMTP */ public function setSMTPInstance(SMTP $smtp) @@ -1843,12 +1839,13 @@ class PHPMailer */ protected function smtpSend($header, $body) { + $header = rtrim($header, "\r\n ") . static::$LE . static::$LE; $bad_rcpt = []; if (!$this->smtpConnect($this->SMTPOptions)) { throw new Exception($this->lang('smtp_connect_failed'), self::STOP_CRITICAL); } //Sender already validated in preSend() - if ('' == $this->Sender) { + if ('' === $this->Sender) { $smtp_from = $this->From; } else { $smtp_from = $this->Sender; @@ -1875,7 +1872,7 @@ class PHPMailer } // Only send the DATA command if we have viable recipients - if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) { + if ((count($this->all_recipients) > count($bad_rcpt)) && !$this->smtp->data($header . $body)) { throw new Exception($this->lang('data_not_accepted'), self::STOP_CRITICAL); } @@ -1907,10 +1904,7 @@ class PHPMailer foreach ($bad_rcpt as $bad) { $errstr .= $bad['to'] . ': ' . $bad['error']; } - throw new Exception( - $this->lang('recipients_failed') . $errstr, - self::STOP_CONTINUE - ); + throw new Exception($this->lang('recipients_failed') . $errstr, self::STOP_CONTINUE); } return true; @@ -1954,50 +1948,49 @@ class PHPMailer foreach ($hosts as $hostentry) { $hostinfo = []; if (!preg_match( - '/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*|\[[a-fA-F0-9:]+\]):?([0-9]*)$/', + '/^(?:(ssl|tls):\/\/)?(.+?)(?::(\d+))?$/', trim($hostentry), $hostinfo )) { - static::edebug($this->lang('connect_host') . ' ' . $hostentry); + $this->edebug($this->lang('invalid_hostentry') . ' ' . trim($hostentry)); // Not a valid host entry continue; } - // $hostinfo[2]: optional ssl or tls prefix - // $hostinfo[3]: the hostname - // $hostinfo[4]: optional port number + // $hostinfo[1]: optional ssl or tls prefix + // $hostinfo[2]: the hostname + // $hostinfo[3]: optional port number // The host string prefix can temporarily override the current setting for SMTPSecure // If it's not specified, the default value is used //Check the host name is a valid name or IP address before trying to use it - if (!static::isValidHost($hostinfo[3])) { - static::edebug($this->lang('connect_host') . ' ' . $hostentry); + if (!static::isValidHost($hostinfo[2])) { + $this->edebug($this->lang('invalid_host') . ' ' . $hostinfo[2]); continue; } $prefix = ''; $secure = $this->SMTPSecure; - $tls = (static::ENCRYPTION_STARTTLS == $this->SMTPSecure); - if ('ssl' == $hostinfo[2] or ('' == $hostinfo[2] and static::ENCRYPTION_SMTPS == $this->SMTPSecure)) { + $tls = (static::ENCRYPTION_STARTTLS === $this->SMTPSecure); + if ('ssl' === $hostinfo[1] || ('' === $hostinfo[1] && static::ENCRYPTION_SMTPS === $this->SMTPSecure)) { $prefix = 'ssl://'; $tls = false; // Can't have SSL and TLS at the same time $secure = static::ENCRYPTION_SMTPS; - } elseif ('tls' == $hostinfo[2]) { + } elseif ('tls' === $hostinfo[1]) { $tls = true; // tls doesn't use a prefix $secure = static::ENCRYPTION_STARTTLS; } //Do we need the OpenSSL extension? $sslext = defined('OPENSSL_ALGO_SHA256'); - if (static::ENCRYPTION_STARTTLS === $secure or static::ENCRYPTION_SMTPS === $secure) { + if (static::ENCRYPTION_STARTTLS === $secure || static::ENCRYPTION_SMTPS === $secure) { //Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled if (!$sslext) { throw new Exception($this->lang('extension_missing') . 'openssl', self::STOP_CRITICAL); } } - $host = $hostinfo[3]; + $host = $hostinfo[2]; $port = $this->Port; - $tport = (int) $hostinfo[4]; - if ($tport > 0 and $tport < 65536) { - $port = $tport; + if (array_key_exists(3, $hostinfo) && is_numeric($hostinfo[3]) && $hostinfo[3] > 0 && $hostinfo[3] < 65536) { + $port = (int) $hostinfo[3]; } if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) { try { @@ -2012,7 +2005,7 @@ class PHPMailer // * we have openssl extension // * we are not already using SSL // * the server offers STARTTLS - if ($this->SMTPAutoTLS and $sslext and 'ssl' != $secure and $this->smtp->getServerExt('STARTTLS')) { + if ($this->SMTPAutoTLS && $sslext && 'ssl' !== $secure && $this->smtp->getServerExt('STARTTLS')) { $tls = true; } if ($tls) { @@ -2022,16 +2015,13 @@ class PHPMailer // We must resend EHLO after TLS negotiation $this->smtp->hello($hello); } - if ($this->SMTPAuth) { - if (!$this->smtp->authenticate( - $this->Username, - $this->Password, - $this->AuthType, - $this->oauth - ) - ) { - throw new Exception($this->lang('authenticate')); - } + if ($this->SMTPAuth && !$this->smtp->authenticate( + $this->Username, + $this->Password, + $this->AuthType, + $this->oauth + )) { + throw new Exception($this->lang('authenticate')); } return true; @@ -2046,7 +2036,7 @@ class PHPMailer // If we get here, all connection attempts have failed, so close connection hard $this->smtp->close(); // As we've caught all exceptions, just report whatever the last one was - if ($this->exceptions and null !== $lastexception) { + if ($this->exceptions && null !== $lastexception) { throw $lastexception; } @@ -2058,11 +2048,9 @@ class PHPMailer */ public function smtpClose() { - if (null !== $this->smtp) { - if ($this->smtp->connected()) { - $this->smtp->quit(); - $this->smtp->close(); - } + if ((null !== $this->smtp) && $this->smtp->connected()) { + $this->smtp->quit(); + $this->smtp->close(); } } @@ -2106,6 +2094,8 @@ class PHPMailer 'from_failed' => 'The following From address failed: ', 'instantiate' => 'Could not instantiate mail function.', 'invalid_address' => 'Invalid address: ', + 'invalid_hostentry' => 'Invalid hostentry: ', + 'invalid_host' => 'Invalid host: ', 'mailer_not_supported' => ' mailer is not supported.', 'provide_address' => 'You must provide at least one recipient email address.', 'recipients_failed' => 'SMTP Error: The following recipients failed: ', @@ -2126,7 +2116,7 @@ class PHPMailer $foundlang = true; $lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php'; // There is no English translation file - if ('en' != $langcode) { + if ('en' !== $langcode) { // Make sure language file path is readable if (!static::isPermittedPath($lang_file) || !file_exists($lang_file)) { $foundlang = false; @@ -2186,9 +2176,8 @@ class PHPMailer return $this->secureHeader($addr[0]); } - return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . ' <' . $this->secureHeader( - $addr[0] - ) . '>'; + return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . + ' <' . $this->secureHeader($addr[0]) . '>'; } /** @@ -2218,7 +2207,7 @@ class PHPMailer $message = static::normalizeBreaks($message); //Remove a trailing line break - if (substr($message, -$lelen) == static::$LE) { + if (substr($message, -$lelen) === static::$LE) { $message = substr($message, 0, -$lelen); } @@ -2231,16 +2220,16 @@ class PHPMailer $buf = ''; $firstword = true; foreach ($words as $word) { - if ($qp_mode and (strlen($word) > $length)) { + if ($qp_mode && (strlen($word) > $length)) { $space_left = $length - strlen($buf) - $crlflen; if (!$firstword) { if ($space_left > 20) { $len = $space_left; if ($is_utf8) { $len = $this->utf8CharBoundary($word, $len); - } elseif ('=' == substr($word, $len - 1, 1)) { + } elseif ('=' === substr($word, $len - 1, 1)) { --$len; - } elseif ('=' == substr($word, $len - 2, 1)) { + } elseif ('=' === substr($word, $len - 2, 1)) { $len -= 2; } $part = substr($word, 0, $len); @@ -2252,22 +2241,22 @@ class PHPMailer } $buf = ''; } - while (strlen($word) > 0) { + while ($word !== '') { if ($length <= 0) { break; } $len = $length; if ($is_utf8) { $len = $this->utf8CharBoundary($word, $len); - } elseif ('=' == substr($word, $len - 1, 1)) { + } elseif ('=' === substr($word, $len - 1, 1)) { --$len; - } elseif ('=' == substr($word, $len - 2, 1)) { + } elseif ('=' === substr($word, $len - 2, 1)) { $len -= 2; } $part = substr($word, 0, $len); - $word = substr($word, $len); + $word = (string) substr($word, $len); - if (strlen($word) > 0) { + if ($word !== '') { $message .= $part . sprintf('=%s', static::$LE); } else { $buf = $part; @@ -2280,7 +2269,7 @@ class PHPMailer } $buf .= $word; - if (strlen($buf) > $length and '' != $buf_o) { + if ('' !== $buf_o && strlen($buf) > $length) { $message .= $buf_o . $soft_break; $buf = $word; } @@ -2375,23 +2364,21 @@ class PHPMailer { $result = ''; - $result .= $this->headerLine('Date', '' == $this->MessageDate ? self::rfcDate() : $this->MessageDate); + $result .= $this->headerLine('Date', '' === $this->MessageDate ? self::rfcDate() : $this->MessageDate); // To be created automatically by mail() if ($this->SingleTo) { - if ('mail' != $this->Mailer) { + if ('mail' !== $this->Mailer) { foreach ($this->to as $toaddr) { $this->SingleToArray[] = $this->addrFormat($toaddr); } } - } else { - if (count($this->to) > 0) { - if ('mail' != $this->Mailer) { - $result .= $this->addrAppend('To', $this->to); - } - } elseif (count($this->cc) == 0) { - $result .= $this->headerLine('To', 'undisclosed-recipients:;'); + } elseif (count($this->to) > 0) { + if ('mail' !== $this->Mailer) { + $result .= $this->addrAppend('To', $this->to); } + } elseif (count($this->cc) === 0) { + $result .= $this->headerLine('To', 'undisclosed-recipients:;'); } $result .= $this->addrAppend('From', [[trim($this->From), $this->FromName]]); @@ -2403,9 +2390,9 @@ class PHPMailer // sendmail and mail() extract Bcc from the header before sending if (( - 'sendmail' == $this->Mailer or 'qmail' == $this->Mailer or 'mail' == $this->Mailer + 'sendmail' === $this->Mailer || 'qmail' === $this->Mailer || 'mail' === $this->Mailer ) - and count($this->bcc) > 0 + && count($this->bcc) > 0 ) { $result .= $this->addrAppend('Bcc', $this->bcc); } @@ -2415,13 +2402,13 @@ class PHPMailer } // mail() sets the subject itself - if ('mail' != $this->Mailer) { + if ('mail' !== $this->Mailer) { $result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject))); } // Only allow a custom message ID if it conforms to RFC 5322 section 3.6.4 // https://tools.ietf.org/html/rfc5322#section-3.6.4 - if ('' != $this->MessageID and preg_match('/^<.*@.*>$/', $this->MessageID)) { + if ('' !== $this->MessageID && preg_match('/^<.*@.*>$/', $this->MessageID)) { $this->lastMessageID = $this->MessageID; } else { $this->lastMessageID = sprintf('<%s@%s>', $this->uniqueid, $this->serverHostname()); @@ -2442,7 +2429,7 @@ class PHPMailer } } - if ('' != $this->ConfirmReadingTo) { + if ('' !== $this->ConfirmReadingTo) { $result .= $this->headerLine('Disposition-Notification-To', '<' . $this->ConfirmReadingTo . '>'); } @@ -2494,10 +2481,10 @@ class PHPMailer break; } // RFC1341 part 5 says 7bit is assumed if not specified - if (static::ENCODING_7BIT != $this->Encoding) { + if (static::ENCODING_7BIT !== $this->Encoding) { // RFC 2045 section 6.4 says multipart MIME parts may only use 7bit, 8bit or binary CTE if ($ismultipart) { - if (static::ENCODING_8BIT == $this->Encoding) { + if (static::ENCODING_8BIT === $this->Encoding) { $result .= $this->headerLine('Content-Transfer-Encoding', static::ENCODING_8BIT); } // The only remaining alternatives are quoted-printable and base64, which are both 7bit compatible @@ -2506,8 +2493,8 @@ class PHPMailer } } - if ('mail' != $this->Mailer) { - $result .= static::$LE; + if ('mail' !== $this->Mailer) { +// $result .= static::$LE; } return $result; @@ -2535,11 +2522,19 @@ class PHPMailer protected function generateId() { $len = 32; //32 bytes = 256 bits + $bytes = ''; if (function_exists('random_bytes')) { - $bytes = random_bytes($len); + try { + $bytes = random_bytes($len); + } catch (\Exception $e) { + //Do nothing + } } elseif (function_exists('openssl_random_pseudo_bytes')) { + /** @noinspection CryptographicallySecureRandomnessInspection */ $bytes = openssl_random_pseudo_bytes($len); - } else { + } + if ($bytes === '') { + //We failed to produce a proper random string, so make do. //Use a hash to force the length to the same as the other methods $bytes = hash('sha256', uniqid((string) mt_rand(), true), true); } @@ -2574,28 +2569,28 @@ class PHPMailer $bodyEncoding = $this->Encoding; $bodyCharSet = $this->CharSet; //Can we do a 7-bit downgrade? - if (static::ENCODING_8BIT == $bodyEncoding and !$this->has8bitChars($this->Body)) { + if (static::ENCODING_8BIT === $bodyEncoding && !$this->has8bitChars($this->Body)) { $bodyEncoding = static::ENCODING_7BIT; //All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit $bodyCharSet = static::CHARSET_ASCII; } //If lines are too long, and we're not already using an encoding that will shorten them, //change to quoted-printable transfer encoding for the body part only - if (static::ENCODING_BASE64 != $this->Encoding and static::hasLineLongerThanMax($this->Body)) { + if (static::ENCODING_BASE64 !== $this->Encoding && static::hasLineLongerThanMax($this->Body)) { $bodyEncoding = static::ENCODING_QUOTED_PRINTABLE; } $altBodyEncoding = $this->Encoding; $altBodyCharSet = $this->CharSet; //Can we do a 7-bit downgrade? - if (static::ENCODING_8BIT == $altBodyEncoding and !$this->has8bitChars($this->AltBody)) { + if (static::ENCODING_8BIT === $altBodyEncoding && !$this->has8bitChars($this->AltBody)) { $altBodyEncoding = static::ENCODING_7BIT; //All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit $altBodyCharSet = static::CHARSET_ASCII; } //If lines are too long, and we're not already using an encoding that will shorten them, //change to quoted-printable transfer encoding for the alt body part only - if (static::ENCODING_BASE64 != $altBodyEncoding and static::hasLineLongerThanMax($this->AltBody)) { + if (static::ENCODING_BASE64 !== $altBodyEncoding && static::hasLineLongerThanMax($this->AltBody)) { $altBodyEncoding = static::ENCODING_QUOTED_PRINTABLE; } //Use this as a preamble in all multipart message types @@ -2631,10 +2626,20 @@ class PHPMailer break; case 'alt': $body .= $mimepre; - $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding); + $body .= $this->getBoundary( + $this->boundary[1], + $altBodyCharSet, + static::CONTENT_TYPE_PLAINTEXT, + $altBodyEncoding + ); $body .= $this->encodeString($this->AltBody, $altBodyEncoding); $body .= static::$LE; - $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding); + $body .= $this->getBoundary( + $this->boundary[1], + $bodyCharSet, + static::CONTENT_TYPE_TEXT_HTML, + $bodyEncoding + ); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; if (!empty($this->Ical)) { @@ -2645,7 +2650,12 @@ class PHPMailer break; } } - $body .= $this->getBoundary($this->boundary[1], '', static::CONTENT_TYPE_TEXT_CALENDAR . '; method=' . $method, ''); + $body .= $this->getBoundary( + $this->boundary[1], + '', + static::CONTENT_TYPE_TEXT_CALENDAR . '; method=' . $method, + '' + ); $body .= $this->encodeString($this->Ical, $this->Encoding); $body .= static::$LE; } @@ -2653,7 +2663,12 @@ class PHPMailer break; case 'alt_inline': $body .= $mimepre; - $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding); + $body .= $this->getBoundary( + $this->boundary[1], + $altBodyCharSet, + static::CONTENT_TYPE_PLAINTEXT, + $altBodyEncoding + ); $body .= $this->encodeString($this->AltBody, $altBodyEncoding); $body .= static::$LE; $body .= $this->textLine('--' . $this->boundary[1]); @@ -2661,7 +2676,12 @@ class PHPMailer $body .= $this->textLine(' boundary="' . $this->boundary[2] . '";'); $body .= $this->textLine(' type="' . static::CONTENT_TYPE_TEXT_HTML . '"'); $body .= static::$LE; - $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding); + $body .= $this->getBoundary( + $this->boundary[2], + $bodyCharSet, + static::CONTENT_TYPE_TEXT_HTML, + $bodyEncoding + ); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; $body .= $this->attachAll('inline', $this->boundary[2]); @@ -2674,10 +2694,20 @@ class PHPMailer $body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . ';'); $body .= $this->textLine(' boundary="' . $this->boundary[2] . '"'); $body .= static::$LE; - $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding); + $body .= $this->getBoundary( + $this->boundary[2], + $altBodyCharSet, + static::CONTENT_TYPE_PLAINTEXT, + $altBodyEncoding + ); $body .= $this->encodeString($this->AltBody, $altBodyEncoding); $body .= static::$LE; - $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding); + $body .= $this->getBoundary( + $this->boundary[2], + $bodyCharSet, + static::CONTENT_TYPE_TEXT_HTML, + $bodyEncoding + ); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; if (!empty($this->Ical)) { @@ -2688,7 +2718,12 @@ class PHPMailer break; } } - $body .= $this->getBoundary($this->boundary[2], '', static::CONTENT_TYPE_TEXT_CALENDAR . '; method=' . $method, ''); + $body .= $this->getBoundary( + $this->boundary[2], + '', + static::CONTENT_TYPE_TEXT_CALENDAR . '; method=' . $method, + '' + ); $body .= $this->encodeString($this->Ical, $this->Encoding); } $body .= $this->endBoundary($this->boundary[2]); @@ -2701,7 +2736,12 @@ class PHPMailer $body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . ';'); $body .= $this->textLine(' boundary="' . $this->boundary[2] . '"'); $body .= static::$LE; - $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding); + $body .= $this->getBoundary( + $this->boundary[2], + $altBodyCharSet, + static::CONTENT_TYPE_PLAINTEXT, + $altBodyEncoding + ); $body .= $this->encodeString($this->AltBody, $altBodyEncoding); $body .= static::$LE; $body .= $this->textLine('--' . $this->boundary[2]); @@ -2709,7 +2749,12 @@ class PHPMailer $body .= $this->textLine(' boundary="' . $this->boundary[3] . '";'); $body .= $this->textLine(' type="' . static::CONTENT_TYPE_TEXT_HTML . '"'); $body .= static::$LE; - $body .= $this->getBoundary($this->boundary[3], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding); + $body .= $this->getBoundary( + $this->boundary[3], + $bodyCharSet, + static::CONTENT_TYPE_TEXT_HTML, + $bodyEncoding + ); $body .= $this->encodeString($this->Body, $bodyEncoding); $body .= static::$LE; $body .= $this->attachAll('inline', $this->boundary[3]); @@ -2798,20 +2843,20 @@ class PHPMailer protected function getBoundary($boundary, $charSet, $contentType, $encoding) { $result = ''; - if ('' == $charSet) { + if ('' === $charSet) { $charSet = $this->CharSet; } - if ('' == $contentType) { + if ('' === $contentType) { $contentType = $this->ContentType; } - if ('' == $encoding) { + if ('' === $encoding) { $encoding = $this->Encoding; } $result .= $this->textLine('--' . $boundary); $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet); $result .= static::$LE; // RFC1341 part 5 says 7bit is assumed if not specified - if (static::ENCODING_7BIT != $encoding) { + if (static::ENCODING_7BIT !== $encoding) { $result .= $this->headerLine('Content-Transfer-Encoding', $encoding); } $result .= static::$LE; @@ -2848,7 +2893,7 @@ class PHPMailer $type[] = 'attach'; } $this->message_type = implode('_', $type); - if ('' == $this->message_type) { + if ('' === $this->message_type) { //The 'plain' message_type refers to the message having a single body element, not that it is plain-text $this->message_type = 'plain'; } @@ -2909,12 +2954,12 @@ class PHPMailer } // If a MIME type is not specified, try to work it out from the file name - if ('' == $type) { + if ('' === $type) { $type = static::filenameToType($path); } - $filename = static::mb_pathinfo($path, PATHINFO_BASENAME); - if ('' == $name) { + $filename = (string) static::mb_pathinfo($path, PATHINFO_BASENAME); + if ('' === $name) { $name = $filename; } @@ -2962,6 +3007,8 @@ class PHPMailer * @param string $disposition_type * @param string $boundary * + * @throws Exception + * * @return string */ protected function attachAll($disposition_type, $boundary) @@ -2974,7 +3021,7 @@ class PHPMailer // Add all attachments foreach ($this->attachment as $attachment) { // Check if it is a valid disposition_filter - if ($attachment[6] == $disposition_type) { + if ($attachment[6] === $disposition_type) { // Check for string attachment $string = ''; $path = ''; @@ -2986,7 +3033,7 @@ class PHPMailer } $inclhash = hash('sha256', serialize($attachment)); - if (in_array($inclhash, $incl)) { + if (in_array($inclhash, $incl, true)) { continue; } $incl[] = $inclhash; @@ -2995,7 +3042,7 @@ class PHPMailer $type = $attachment[4]; $disposition = $attachment[6]; $cid = $attachment[7]; - if ('inline' == $disposition and array_key_exists($cid, $cidUniq)) { + if ('inline' === $disposition && array_key_exists($cid, $cidUniq)) { continue; } $cidUniq[$cid] = true; @@ -3017,16 +3064,13 @@ class PHPMailer ); } // RFC1341 part 5 says 7bit is assumed if not specified - if (static::ENCODING_7BIT != $encoding) { + if (static::ENCODING_7BIT !== $encoding) { $mime[] = sprintf('Content-Transfer-Encoding: %s%s', $encoding, static::$LE); } - if (!empty($cid)) { - $mime[] = sprintf( - 'Content-ID: <%s>%s', - $this->encodeHeader($this->secureHeader($cid)), - static::$LE - ); + //Only set Content-IDs on inline attachments + if ((string) $cid !== '' && $disposition === 'inline') { + $mime[] = 'Content-ID: <' . $this->encodeHeader($this->secureHeader($cid)) . '>' . static::$LE; } // If a filename contains any of these chars, it should be quoted, @@ -3035,28 +3079,26 @@ class PHPMailer // Allow for bypassing the Content-Disposition header totally if (!empty($disposition)) { $encoded_name = $this->encodeHeader($this->secureHeader($name)); - if (preg_match('/[ \(\)<>@,;:\\"\/\[\]\?=]/', $encoded_name)) { + if (preg_match('/[ ()<>@,;:"\/\[\]?=]/', $encoded_name)) { $mime[] = sprintf( 'Content-Disposition: %s; filename="%s"%s', $disposition, $encoded_name, static::$LE . static::$LE ); + } elseif (!empty($encoded_name)) { + $mime[] = sprintf( + 'Content-Disposition: %s; filename=%s%s', + $disposition, + $encoded_name, + static::$LE . static::$LE + ); } else { - if (!empty($encoded_name)) { - $mime[] = sprintf( - 'Content-Disposition: %s; filename=%s%s', - $disposition, - $encoded_name, - static::$LE . static::$LE - ); - } else { - $mime[] = sprintf( - 'Content-Disposition: %s%s', - $disposition, - static::$LE . static::$LE - ); - } + $mime[] = sprintf( + 'Content-Disposition: %s%s', + $disposition, + static::$LE . static::$LE + ); } } else { $mime[] = static::$LE; @@ -3087,8 +3129,6 @@ class PHPMailer * @param string $path The full path to the file * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' * - * @throws Exception - * * @return string */ protected function encodeFile($path, $encoding = self::ENCODING_BASE64) @@ -3137,7 +3177,7 @@ class PHPMailer case static::ENCODING_8BIT: $encoded = static::normalizeBreaks($str); // Make sure it ends with a line break - if (substr($encoded, -(strlen(static::$LE))) != static::$LE) { + if (substr($encoded, -(strlen(static::$LE))) !== static::$LE) { $encoded .= static::$LE; } break; @@ -3176,7 +3216,7 @@ class PHPMailer if (!preg_match('/[\200-\377]/', $str)) { // Can't use addslashes as we don't know the value of magic_quotes_sybase $encoded = addcslashes($str, "\0..\37\177\\\""); - if (($str == $encoded) and !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { + if (($str === $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { return $encoded; } @@ -3203,10 +3243,10 @@ class PHPMailer // Q/B encoding adds 8 chars and the charset ("` =??[QB]??=`"). $overhead = 8 + strlen($charset); - if ('mail' == $this->Mailer) { + if ('mail' === $this->Mailer) { $maxlen = static::MAIL_MAX_LINE_LENGTH - $overhead; } else { - $maxlen = static::STD_LINE_LENGTH - $overhead; + $maxlen = static::MAX_LINE_LENGTH - $overhead; } // Select the encoding that produces the shortest output and/or prevents corruption. @@ -3308,6 +3348,7 @@ class PHPMailer // Base64 has a 4:3 ratio $avgLength = floor($length * $ratio * .75); + $offset = 0; for ($i = 0; $i < $mb_length; $i += $offset) { $lookBack = 0; do { @@ -3368,7 +3409,6 @@ class PHPMailer default: // RFC 2047 section 5.1 // Replace every high ascii, control, =, ? and _ characters - /** @noinspection SuspiciousAssignmentsInspection */ $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern; break; } @@ -3376,7 +3416,7 @@ class PHPMailer if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) { // If the string contains an '=', make sure it's the first thing we replace // so as to avoid double-encoding - $eqkey = array_search('=', $matches[0]); + $eqkey = array_search('=', $matches[0], true); if (false !== $eqkey) { unset($matches[0][$eqkey]); array_unshift($matches[0], '='); @@ -3414,7 +3454,7 @@ class PHPMailer ) { try { // If a MIME type is not specified, try to work it out from the file name - if ('' == $type) { + if ('' === $type) { $type = static::filenameToType($filename); } @@ -3481,7 +3521,7 @@ class PHPMailer } // If a MIME type is not specified, try to work it out from the file name - if ('' == $type) { + if ('' === $type) { $type = static::filenameToType($path); } @@ -3489,8 +3529,8 @@ class PHPMailer throw new Exception($this->lang('encoding') . $encoding); } - $filename = static::mb_pathinfo($path, PATHINFO_BASENAME); - if ('' == $name) { + $filename = (string) static::mb_pathinfo($path, PATHINFO_BASENAME); + if ('' === $name) { $name = $filename; } @@ -3547,7 +3587,7 @@ class PHPMailer ) { try { // If a MIME type is not specified, try to work it out from the name - if ('' == $type and !empty($name)) { + if ('' === $type && !empty($name)) { $type = static::filenameToType($name); } @@ -3582,7 +3622,7 @@ class PHPMailer /** * Validate encodings. * - * @param $encoding + * @param string $encoding * * @return bool */ @@ -3611,7 +3651,7 @@ class PHPMailer protected function cidExists($cid) { foreach ($this->attachment as $attachment) { - if ('inline' == $attachment[6] and $cid == $attachment[7]) { + if ('inline' === $attachment[6] && $cid === $attachment[7]) { return true; } } @@ -3627,7 +3667,7 @@ class PHPMailer public function inlineImageExists() { foreach ($this->attachment as $attachment) { - if ('inline' == $attachment[6]) { + if ('inline' === $attachment[6]) { return true; } } @@ -3643,7 +3683,7 @@ class PHPMailer public function attachmentExists() { foreach ($this->attachment as $attachment) { - if ('attachment' == $attachment[6]) { + if ('attachment' === $attachment[6]) { return true; } } @@ -3670,8 +3710,8 @@ class PHPMailer { $this->RecipientsQueue = array_filter( $this->RecipientsQueue, - function ($params) use ($kind) { - return $params[0] != $kind; + static function ($params) use ($kind) { + return $params[0] !== $kind; } ); } @@ -3757,7 +3797,7 @@ class PHPMailer protected function setError($msg) { ++$this->error_count; - if ('smtp' == $this->Mailer and null !== $this->smtp) { + if ('smtp' === $this->Mailer && null !== $this->smtp) { $lasterror = $this->smtp->getError(); if (!empty($lasterror['error'])) { $msg .= $this->lang('smtp_error') . $lasterror['error']; @@ -3800,9 +3840,9 @@ class PHPMailer $result = ''; if (!empty($this->Hostname)) { $result = $this->Hostname; - } elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER)) { + } elseif (isset($_SERVER) && array_key_exists('SERVER_NAME', $_SERVER)) { $result = $_SERVER['SERVER_NAME']; - } elseif (function_exists('gethostname') and gethostname() !== false) { + } elseif (function_exists('gethostname') && gethostname() !== false) { $result = gethostname(); } elseif (php_uname('n') !== false) { $result = php_uname('n'); @@ -3826,22 +3866,23 @@ class PHPMailer { //Simple syntax limits if (empty($host) - or !is_string($host) - or strlen($host) > 256 + || !is_string($host) + || strlen($host) > 256 + || !preg_match('/^([a-zA-Z\d.-]*|\[[a-fA-F\d:]+])$/', $host) ) { return false; } //Looks like a bracketed IPv6 address - if (trim($host, '[]') != $host) { - return (bool) filter_var(trim($host, '[]'), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6); + if (strlen($host) > 2 && substr($host, 0, 1) === '[' && substr($host, -1, 1) === ']') { + return filter_var(substr($host, 1, -1), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false; } //If removing all the dots results in a numeric string, it must be an IPv4 address. //Need to check this first because otherwise things like `999.0.0.0` are considered valid host names if (is_numeric(str_replace('.', '', $host))) { //Is it a valid IPv4 address? - return (bool) filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); + return filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false; } - if (filter_var('http://' . $host, FILTER_VALIDATE_URL)) { + if (filter_var('http://' . $host, FILTER_VALIDATE_URL) !== false) { //Is it a syntactically valid hostname? return true; } @@ -3859,11 +3900,11 @@ class PHPMailer protected function lang($key) { if (count($this->language) < 1) { - $this->setLanguage('en'); // set the default language + $this->setLanguage(); // set the default language } if (array_key_exists($key, $this->language)) { - if ('smtp_connect_failed' == $key) { + if ('smtp_connect_failed' === $key) { //Include a link to troubleshooting docs on SMTP connection failure //this is by far the biggest cause of support questions //but it's usually not PHPMailer's fault. @@ -3929,15 +3970,17 @@ class PHPMailer * @param string $message HTML message string * @param string $basedir Absolute path to a base directory to prepend to relative paths to images * @param bool|callable $advanced Whether to use the internal HTML to text converter - * or your own custom converter @see PHPMailer::html2text() + * or your own custom converter @return string $message The transformed message Body * - * @return string $message The transformed message Body + * @throws Exception + * + * @see PHPMailer::html2text() */ public function msgHTML($message, $basedir = '', $advanced = false) { - preg_match_all('/(src|background)=["\'](.*)["\']/Ui', $message, $images); + preg_match_all('/(? 1 && '/' != substr($basedir, -1)) { + if (strlen($basedir) > 1 && '/' !== substr($basedir, -1)) { // Ensure $basedir has a trailing / $basedir .= '/'; } @@ -3945,20 +3988,26 @@ class PHPMailer // Convert data URIs into embedded images //e.g. "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" if (preg_match('#^data:(image/(?:jpe?g|gif|png));?(base64)?,(.+)#', $url, $match)) { - if (count($match) == 4 and static::ENCODING_BASE64 == $match[2]) { + if (count($match) === 4 && static::ENCODING_BASE64 === $match[2]) { $data = base64_decode($match[3]); - } elseif ('' == $match[2]) { + } elseif ('' === $match[2]) { $data = rawurldecode($match[3]); } else { //Not recognised so leave it alone continue; } - //Hash the decoded data, not the URL so that the same data-URI image used in multiple places + //Hash the decoded data, not the URL, so that the same data-URI image used in multiple places //will only be embedded once, even if it used a different encoding - $cid = hash('sha256', $data) . '@phpmailer.0'; // RFC2392 S 2 + $cid = substr(hash('sha256', $data), 0, 32) . '@phpmailer.0'; // RFC2392 S 2 if (!$this->cidExists($cid)) { - $this->addStringEmbeddedImage($data, $cid, 'embed' . $imgindex, static::ENCODING_BASE64, $match[1]); + $this->addStringEmbeddedImage( + $data, + $cid, + 'embed' . $imgindex, + static::ENCODING_BASE64, + $match[1] + ); } $message = str_replace( $images[0][$imgindex], @@ -3970,22 +4019,23 @@ class PHPMailer if (// Only process relative URLs if a basedir is provided (i.e. no absolute local paths) !empty($basedir) // Ignore URLs containing parent dir traversal (..) - and (strpos($url, '..') === false) + && (strpos($url, '..') === false) // Do not change urls that are already inline images - and 0 !== strpos($url, 'cid:') + && 0 !== strpos($url, 'cid:') // Do not change absolute URLs, including anonymous protocol - and !preg_match('#^[a-z][a-z0-9+.-]*:?//#i', $url) + && !preg_match('#^[a-z][a-z0-9+.-]*:?//#i', $url) ) { $filename = static::mb_pathinfo($url, PATHINFO_BASENAME); $directory = dirname($url); - if ('.' == $directory) { + if ('.' === $directory) { $directory = ''; } - $cid = hash('sha256', $url) . '@phpmailer.0'; // RFC2392 S 2 - if (strlen($basedir) > 1 and '/' != substr($basedir, -1)) { + // RFC2392 S 2 + $cid = substr(hash('sha256', $url), 0, 32) . '@phpmailer.0'; + if (strlen($basedir) > 1 && '/' !== substr($basedir, -1)) { $basedir .= '/'; } - if (strlen($directory) > 1 and '/' != substr($directory, -1)) { + if (strlen($directory) > 1 && '/' !== substr($directory, -1)) { $directory .= '/'; } if ($this->addEmbeddedImage( @@ -4005,7 +4055,7 @@ class PHPMailer } } } - $this->isHTML(true); + $this->isHTML(); // Convert all message body line breaks to LE, makes quoted-printable encoding work much better $this->Body = static::normalizeBreaks($message); $this->AltBody = static::normalizeBreaks($this->html2text($message, $advanced)); @@ -4043,7 +4093,7 @@ class PHPMailer public function html2text($html, $advanced = false) { if (is_callable($advanced)) { - return call_user_func($advanced, $html); + return $advanced($html); } return html_entity_decode( @@ -4363,7 +4413,7 @@ class PHPMailer $len = strlen($txt); for ($i = 0; $i < $len; ++$i) { $ord = ord($txt[$i]); - if (((0x21 <= $ord) and ($ord <= 0x3A)) or $ord == 0x3C or ((0x3E <= $ord) and ($ord <= 0x7E))) { + if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord === 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) { $line .= $txt[$i]; } else { $line .= '=' . sprintf('%02X', $ord); @@ -4394,7 +4444,7 @@ class PHPMailer $privKeyStr = !empty($this->DKIM_private_string) ? $this->DKIM_private_string : file_get_contents($this->DKIM_private); - if ('' != $this->DKIM_passphrase) { + if ('' !== $this->DKIM_passphrase) { $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase); } else { $privKey = openssl_pkey_get_private($privKeyStr); @@ -4426,9 +4476,7 @@ class PHPMailer //@see https://tools.ietf.org/html/rfc5322#section-2.2 //That means this may break if you do something daft like put vertical tabs in your headers. //Unfold header lines - $signHeader = preg_replace('/\r\n[ \t]+/m', '', $signHeader); - //Collapse internal whitespace to a single space -// $signHeader = preg_replace('/[ \t]+/', ' ', $signHeader); + $signHeader = preg_replace('/\r\n[ \t]+/', ' ', $signHeader); //Break headers out into an array $lines = explode("\r\n", $signHeader); foreach ($lines as $key => $line) { @@ -4483,109 +4531,144 @@ class PHPMailer * @param string $subject Subject * @param string $body Body * + * @throws Exception + * * @return string */ public function DKIM_Add($headers_line, $subject, $body) { $DKIMsignatureType = 'rsa-sha256'; // Signature & hash algorithms - $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body + $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization methods of header & body $DKIMquery = 'dns/txt'; // Query method - $DKIMtime = time(); // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone) - $subject_header = "Subject: $subject"; - $headers = explode(static::$LE, $headers_line); - $from_header = ''; - $to_header = ''; - $date_header = ''; - $current = ''; - $copiedHeaderFields = ''; - $foundExtraHeaders = []; - $extraHeaderKeys = ''; - $extraHeaderValues = ''; - $extraCopyHeaderFields = ''; - foreach ($headers as $header) { - if (strpos($header, 'From:') === 0) { - $from_header = $header; - $current = 'from_header'; - } elseif (strpos($header, 'To:') === 0) { - $to_header = $header; - $current = 'to_header'; - } elseif (strpos($header, 'Date:') === 0) { - $date_header = $header; - $current = 'date_header'; - } elseif (!empty($this->DKIM_extraHeaders)) { - foreach ($this->DKIM_extraHeaders as $extraHeader) { - if (strpos($header, $extraHeader . ':') === 0) { - $headerValue = $header; - foreach ($this->CustomHeader as $customHeader) { - if ($customHeader[0] === $extraHeader) { - $headerValue = trim($customHeader[0]) . - ': ' . - $this->encodeHeader(trim($customHeader[1])); - break; - } + $DKIMtime = time(); + //Always sign these headers without being asked + $autoSignHeaders = [ + 'From', + 'To', + 'CC', + 'Date', + 'Subject', + 'Reply-To', + 'Message-ID', + 'Content-Type', + 'Mime-Version', + 'X-Mailer', + ]; + if (stripos($headers_line, 'Subject') === false) { + $headers_line .= 'Subject: ' . $subject . static::$LE; + } + $headerLines = explode(static::$LE, $headers_line); + $currentHeaderLabel = ''; + $currentHeaderValue = ''; + $parsedHeaders = []; + $headerLineIndex = 0; + $headerLineCount = count($headerLines); + foreach ($headerLines as $headerLine) { + $matches = []; + if (preg_match('/^([^ \t]*?)(?::[ \t]*)(.*)$/', $headerLine, $matches)) { + if ($currentHeaderLabel !== '') { + //We were previously in another header; This is the start of a new header, so save the previous one + $parsedHeaders[] = ['label' => $currentHeaderLabel, 'value' => $currentHeaderValue]; + } + $currentHeaderLabel = $matches[1]; + $currentHeaderValue = $matches[2]; + } elseif (preg_match('/^[ \t]+(.*)$/', $headerLine, $matches)) { + //This is a folded continuation of the current header, so unfold it + $currentHeaderValue .= ' ' . $matches[1]; + } + ++$headerLineIndex; + if ($headerLineIndex >= $headerLineCount) { + //This was the last line, so finish off this header + $parsedHeaders[] = ['label' => $currentHeaderLabel, 'value' => $currentHeaderValue]; + } + } + $copiedHeaders = []; + $headersToSignKeys = []; + $headersToSign = []; + foreach ($parsedHeaders as $header) { + //Is this header one that must be included in the DKIM signature? + if (in_array($header['label'], $autoSignHeaders, true)) { + $headersToSignKeys[] = $header['label']; + $headersToSign[] = $header['label'] . ': ' . $header['value']; + if ($this->DKIM_copyHeaderFields) { + $copiedHeaders[] = $header['label'] . ':' . //Note no space after this, as per RFC + str_replace('|', '=7C', $this->DKIM_QP($header['value'])); + } + continue; + } + //Is this an extra custom header we've been asked to sign? + if (in_array($header['label'], $this->DKIM_extraHeaders, true)) { + //Find its value in custom headers + foreach ($this->CustomHeader as $customHeader) { + if ($customHeader[0] === $header['label']) { + $headersToSignKeys[] = $header['label']; + $headersToSign[] = $header['label'] . ': ' . $header['value']; + if ($this->DKIM_copyHeaderFields) { + $copiedHeaders[] = $header['label'] . ':' . //Note no space after this, as per RFC + str_replace('|', '=7C', $this->DKIM_QP($header['value'])); } - $foundExtraHeaders[$extraHeader] = $headerValue; - $current = ''; - break; + //Skip straight to the next header + continue 2; } } - } else { - if (!empty($$current) and strpos($header, ' =?') === 0) { - $$current .= $header; - } else { - $current = ''; + } + } + $copiedHeaderFields = ''; + if ($this->DKIM_copyHeaderFields && count($copiedHeaders) > 0) { + //Assemble a DKIM 'z' tag + $copiedHeaderFields = ' z='; + $first = true; + foreach ($copiedHeaders as $copiedHeader) { + if (!$first) { + $copiedHeaderFields .= static::$LE . ' |'; } + //Fold long values + if (strlen($copiedHeader) > self::STD_LINE_LENGTH - 3) { + $copiedHeaderFields .= substr( + chunk_split($copiedHeader, self::STD_LINE_LENGTH - 3, static::$LE . ' '), + 0, + -strlen(static::$LE . ' ') + ); + } else { + $copiedHeaderFields .= $copiedHeader; + } + $first = false; } + $copiedHeaderFields .= ';' . static::$LE; } - foreach ($foundExtraHeaders as $key => $value) { - $extraHeaderKeys .= ':' . $key; - $extraHeaderValues .= $value . "\r\n"; - if ($this->DKIM_copyHeaderFields) { - $extraCopyHeaderFields .= ' |' . str_replace('|', '=7C', $this->DKIM_QP($value)) . ";\r\n"; - } - } - if ($this->DKIM_copyHeaderFields) { - $from = str_replace('|', '=7C', $this->DKIM_QP($from_header)); - $to = str_replace('|', '=7C', $this->DKIM_QP($to_header)); - $date = str_replace('|', '=7C', $this->DKIM_QP($date_header)); - $subject = str_replace('|', '=7C', $this->DKIM_QP($subject_header)); - $copiedHeaderFields = " z=$from\r\n" . - " |$to\r\n" . - " |$date\r\n" . - " |$subject;\r\n" . - $extraCopyHeaderFields; - } + $headerKeys = ' h=' . implode(':', $headersToSignKeys) . ';' . static::$LE; + $headerValues = implode(static::$LE, $headersToSign); $body = $this->DKIM_BodyC($body); $DKIMlen = strlen($body); // Length of body $DKIMb64 = base64_encode(pack('H*', hash('sha256', $body))); // Base64 of packed binary SHA-256 hash of body - if ('' == $this->DKIM_identity) { - $ident = ''; - } else { - $ident = ' i=' . $this->DKIM_identity . ';'; + $ident = ''; + if ('' !== $this->DKIM_identity) { + $ident = ' i=' . $this->DKIM_identity . ';' . static::$LE; } - $dkimhdrs = 'DKIM-Signature: v=1; a=' . - $DKIMsignatureType . '; q=' . - $DKIMquery . '; l=' . - $DKIMlen . '; s=' . - $this->DKIM_selector . - ";\r\n" . - ' t=' . $DKIMtime . '; c=' . $DKIMcanonicalization . ";\r\n" . - ' h=From:To:Date:Subject' . $extraHeaderKeys . ";\r\n" . - ' d=' . $this->DKIM_domain . ';' . $ident . "\r\n" . + //The DKIM-Signature header is included in the signature *except for* the value of the `b` tag + //which is appended after calculating the signature + //https://tools.ietf.org/html/rfc6376#section-3.5 + $dkimSignatureHeader = 'DKIM-Signature: v=1;' . + ' d=' . $this->DKIM_domain . ';' . + ' s=' . $this->DKIM_selector . ';' . static::$LE . + ' a=' . $DKIMsignatureType . ';' . + ' q=' . $DKIMquery . ';' . + ' l=' . $DKIMlen . ';' . + ' t=' . $DKIMtime . ';' . + ' c=' . $DKIMcanonicalization . ';' . static::$LE . + $headerKeys . + $ident . $copiedHeaderFields . - ' bh=' . $DKIMb64 . ";\r\n" . + ' bh=' . $DKIMb64 . ';' . static::$LE . ' b='; - $toSign = $this->DKIM_HeaderC( - $from_header . "\r\n" . - $to_header . "\r\n" . - $date_header . "\r\n" . - $subject_header . "\r\n" . - $extraHeaderValues . - $dkimhdrs + //Canonicalize the set of headers + $canonicalizedHeaders = $this->DKIM_HeaderC( + $headerValues . static::$LE . $dkimSignatureHeader ); - $signed = $this->DKIM_Sign($toSign); + $signature = $this->DKIM_Sign($canonicalizedHeaders); + $signature = trim(chunk_split($signature, self::STD_LINE_LENGTH - 3, static::$LE . ' ')); - return static::normalizeBreaks($dkimhdrs . $signed) . static::$LE; + return static::normalizeBreaks($dkimSignatureHeader . $signature) . static::$LE; } /** @@ -4670,7 +4753,7 @@ class PHPMailer */ protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from, $extra) { - if (!empty($this->action_function) and is_callable($this->action_function)) { + if (!empty($this->action_function) && is_callable($this->action_function)) { call_user_func($this->action_function, $isSent, $to, $cc, $bcc, $subject, $body, $from, $extra); } } @@ -4687,8 +4770,6 @@ class PHPMailer /** * Set an OAuth instance. - * - * @param OAuth $oauth */ public function setOAuth(OAuth $oauth) { diff --git a/vendor/phpmailer/phpmailer/src/POP3.php b/vendor/phpmailer/phpmailer/src/POP3.php index e6ad6310..50d5f0c2 100644 --- a/vendor/phpmailer/phpmailer/src/POP3.php +++ b/vendor/phpmailer/phpmailer/src/POP3.php @@ -45,7 +45,7 @@ class POP3 * * @var string */ - const VERSION = '6.1.1'; + const VERSION = '6.1.4'; /** * Default POP3 port number. @@ -364,7 +364,7 @@ class POP3 */ protected function checkResponse($string) { - if (substr($string, 0, 3) !== '+OK') { + if (strpos($string, '+OK') !== 0) { $this->setError("Server reported an error: $string"); return false; diff --git a/vendor/phpmailer/phpmailer/src/SMTP.php b/vendor/phpmailer/phpmailer/src/SMTP.php index 77df57ce..c693f4d4 100644 --- a/vendor/phpmailer/phpmailer/src/SMTP.php +++ b/vendor/phpmailer/phpmailer/src/SMTP.php @@ -34,7 +34,7 @@ class SMTP * * @var string */ - const VERSION = '6.1.1'; + const VERSION = '6.1.4'; /** * SMTP line break constant. @@ -51,12 +51,25 @@ class SMTP const DEFAULT_PORT = 25; /** - * The maximum line length allowed by RFC 2822 section 2.1.1. + * The maximum line length allowed by RFC 5321 section 4.5.3.1.6, + * *excluding* a trailing CRLF break. + * + * @see https://tools.ietf.org/html/rfc5321#section-4.5.3.1.6 * * @var int */ const MAX_LINE_LENGTH = 998; + /** + * The maximum line length allowed for replies in RFC 5321 section 4.5.3.1.5, + * *including* a trailing CRLF line break. + * + * @see https://tools.ietf.org/html/rfc5321#section-4.5.3.1.5 + * + * @var int + */ + const MAX_REPLY_LENGTH = 512; + /** * Debug level for no output. * @@ -207,7 +220,7 @@ class SMTP * * @var string|null */ - protected $helo_rply = null; + protected $helo_rply; /** * The set of SMTP extensions sent in reply to EHLO command. @@ -219,7 +232,7 @@ class SMTP * * @var array|null */ - protected $server_caps = null; + protected $server_caps; /** * The most recent reply received from the server. @@ -249,7 +262,7 @@ class SMTP return; } //Avoid clash with built-in function names - if (!in_array($this->Debugoutput, ['error_log', 'html', 'echo']) and is_callable($this->Debugoutput)) { + if (is_callable($this->Debugoutput) && !in_array($this->Debugoutput, ['error_log', 'html', 'echo'])) { call_user_func($this->Debugoutput, $str, $level); return; @@ -270,12 +283,12 @@ class SMTP case 'echo': default: //Normalize line breaks - $str = preg_replace('/\r\n|\r/ms', "\n", $str); + $str = preg_replace('/\r\n|\r/m', "\n", $str); echo gmdate('Y-m-d H:i:s'), "\t", //Trim trailing space trim( - //Indent for readability, except for trailing break + //Indent for readability, except for trailing break str_replace( "\n", "\n \t ", @@ -358,7 +371,7 @@ class SMTP 'Failed to connect to server', '', (string) $errno, - (string) $errstr + $errstr ); $this->edebug( 'SMTP ERROR: ' . $this->error['error'] @@ -371,10 +384,10 @@ class SMTP $this->edebug('Connection: opened', self::DEBUG_CONNECTION); // SMTP server can take longer to respond, give longer timeout for first read // Windows does not have support for this timeout function - if (substr(PHP_OS, 0, 3) != 'WIN') { - $max = ini_get('max_execution_time'); + if (strpos(PHP_OS, 'WIN') !== 0) { + $max = (int) ini_get('max_execution_time'); // Don't bother if unlimited - if (0 != $max and $timeout > $max) { + if (0 !== $max && $timeout > $max) { @set_time_limit($timeout); } stream_set_timeout($this->smtp_conn, $timeout, 0); @@ -454,14 +467,14 @@ class SMTP return false; } - $this->edebug('Auth method requested: ' . ($authtype ? $authtype : 'UNSPECIFIED'), self::DEBUG_LOWLEVEL); + $this->edebug('Auth method requested: ' . ($authtype ?: 'UNSPECIFIED'), self::DEBUG_LOWLEVEL); $this->edebug( 'Auth methods available on the server: ' . implode(',', $this->server_caps['AUTH']), self::DEBUG_LOWLEVEL ); //If we have requested a specific auth type, check the server supports it before trying others - if (null !== $authtype and !in_array($authtype, $this->server_caps['AUTH'])) { + if (null !== $authtype && !in_array($authtype, $this->server_caps['AUTH'], true)) { $this->edebug('Requested auth method not available: ' . $authtype, self::DEBUG_LOWLEVEL); $authtype = null; } @@ -470,7 +483,7 @@ class SMTP //If no auth mechanism is specified, attempt to use these, in this order //Try CRAM-MD5 first as it's more secure than the others foreach (['CRAM-MD5', 'LOGIN', 'PLAIN', 'XOAUTH2'] as $method) { - if (in_array($method, $this->server_caps['AUTH'])) { + if (in_array($method, $this->server_caps['AUTH'], true)) { $authtype = $method; break; } @@ -480,10 +493,10 @@ class SMTP return false; } - self::edebug('Auth method selected: ' . $authtype, self::DEBUG_LOWLEVEL); + $this->edebug('Auth method selected: ' . $authtype, self::DEBUG_LOWLEVEL); } - if (!in_array($authtype, $this->server_caps['AUTH'])) { + if (!in_array($authtype, $this->server_caps['AUTH'], true)) { $this->setError("The requested authentication method \"$authtype\" is not supported by the server"); return false; @@ -673,13 +686,13 @@ class SMTP $field = substr($lines[0], 0, strpos($lines[0], ':')); $in_headers = false; - if (!empty($field) and strpos($field, ' ') === false) { + if (!empty($field) && strpos($field, ' ') === false) { $in_headers = true; } foreach ($lines as $line) { $lines_out = []; - if ($in_headers and $line == '') { + if ($in_headers && $line === '') { $in_headers = false; } //Break this line up into several smaller lines if it's too long @@ -710,7 +723,7 @@ class SMTP //Send the lines to the server foreach ($lines_out as $line_out) { //RFC2821 section 4.5.2 - if (!empty($line_out) and $line_out[0] == '.') { + if (!empty($line_out) && $line_out[0] === '.') { $line_out = '.' . $line_out; } $this->client_send($line_out . static::LE, 'DATA'); @@ -720,7 +733,7 @@ class SMTP //Message data has been sent, complete the command //Increase timelimit for end of DATA command $savetimelimit = $this->Timelimit; - $this->Timelimit = $this->Timelimit * 2; + $this->Timelimit *= 2; $result = $this->sendCommand('DATA END', '.', 250); $this->recordLastTransactionID(); //Restore timelimit @@ -848,7 +861,7 @@ class SMTP { $noerror = $this->sendCommand('QUIT', 'QUIT', 221); $err = $this->error; //Save any error - if ($noerror or $close_on_error) { + if ($noerror || $close_on_error) { $this->close(); $this->error = $err; //Restore any error from the quit command } @@ -925,7 +938,7 @@ class SMTP return false; } //Reject line breaks in all commands - if (strpos($commandstring, "\n") !== false or strpos($commandstring, "\r") !== false) { + if ((strpos($commandstring, "\n") !== false) || (strpos($commandstring, "\r") !== false)) { $this->setError("Command '$command' contained line breaks"); return false; @@ -935,8 +948,8 @@ class SMTP $this->last_reply = $this->get_lines(); // Fetch SMTP code and possible error code explanation $matches = []; - if (preg_match('/^([0-9]{3})[ -](?:([0-9]\\.[0-9]\\.[0-9]{1,2}) )?/', $this->last_reply, $matches)) { - $code = $matches[1]; + if (preg_match('/^([\d]{3})[ -](?:([\d]\\.[\d]\\.[\d]{1,2}) )?/', $this->last_reply, $matches)) { + $code = (int) $matches[1]; $code_ex = (count($matches) > 2 ? $matches[2] : null); // Cut off error code from each response line $detail = preg_replace( @@ -947,14 +960,14 @@ class SMTP ); } else { // Fall back to simple parsing if regex fails - $code = substr($this->last_reply, 0, 3); + $code = (int) substr($this->last_reply, 0, 3); $code_ex = null; $detail = substr($this->last_reply, 4); } $this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER); - if (!in_array($code, (array) $expect)) { + if (!in_array($code, (array) $expect, true)) { $this->setError( "$command command failed", $detail, @@ -1045,9 +1058,9 @@ class SMTP { //If SMTP transcripts are left enabled, or debug output is posted online //it can leak credentials, so hide credentials in all but lowest level - if (self::DEBUG_LOWLEVEL > $this->do_debug and + if (self::DEBUG_LOWLEVEL > $this->do_debug && in_array($command, ['User & Password', 'Username', 'Password'], true)) { - $this->edebug('CLIENT -> SERVER: