📦 Updating compiled files or packages.

This commit is contained in:
wisp-x
2019-10-31 09:08:29 +08:00
parent 64faf21fdc
commit d4879dc6f1
83 changed files with 1042 additions and 1921 deletions
+2 -2
View File
@@ -3,7 +3,7 @@
{block name="title"}登录 - {$config.site_name}{/block}
{block name="css"}
<link href="/static/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
{/block}
{block name="main"}
@@ -42,5 +42,5 @@
{/block}
{block name="js"}
<script src="/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="/static/bootstrap/4.3.1/js/bootstrap.min.js"></script>
{/block}
+2 -2
View File
@@ -3,7 +3,7 @@
{block name="title"}注册 - {$config.site_name}{/block}
{block name="css"}
<link href="/static/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
{/block}
{block name="main"}
@@ -67,5 +67,5 @@
{/block}
{block name="js"}
<script src="/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="/static/bootstrap/4.3.1/js/bootstrap.min.js"></script>
{/block}
Generated
+46 -45
View File
@@ -157,16 +157,16 @@
},
{
"name": "guzzlehttp/guzzle",
"version": "6.3.3",
"version": "6.4.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba"
"reference": "0895c932405407fd3a7368b6910c09a24d26db11"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba",
"reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/0895c932405407fd3a7368b6910c09a24d26db11",
"reference": "0895c932405407fd3a7368b6910c09a24d26db11",
"shasum": "",
"mirrors": [
{
@@ -176,14 +176,15 @@
]
},
"require": {
"ext-json": "*",
"guzzlehttp/promises": "^1.0",
"guzzlehttp/psr7": "^1.4",
"guzzlehttp/psr7": "^1.6.1",
"php": ">=5.5"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
"psr/log": "^1.0"
"psr/log": "^1.1"
},
"suggest": {
"psr/log": "Required for using the Log middleware"
@@ -195,12 +196,12 @@
}
},
"autoload": {
"files": [
"src/functions_include.php"
],
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -224,7 +225,7 @@
"rest",
"web service"
],
"time": "2018-04-22T15:46:56+00:00"
"time": "2019-10-23T15:58:00+00:00"
},
{
"name": "guzzlehttp/promises",
@@ -362,16 +363,16 @@
},
{
"name": "phpmailer/phpmailer",
"version": "v6.0.7",
"version": "v6.1.1",
"source": {
"type": "git",
"url": "https://github.com/PHPMailer/PHPMailer.git",
"reference": "0c41a36d4508d470e376498c1c0c527aa36a2d59"
"reference": "26bd96350b0b2fcbf0ef4e6f0f9cf3528302a9d8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/0c41a36d4508d470e376498c1c0c527aa36a2d59",
"reference": "0c41a36d4508d470e376498c1c0c527aa36a2d59",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/26bd96350b0b2fcbf0ef4e6f0f9cf3528302a9d8",
"reference": "26bd96350b0b2fcbf0ef4e6f0f9cf3528302a9d8",
"shasum": "",
"mirrors": [
{
@@ -410,17 +411,17 @@
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1"
"LGPL-2.1-only"
],
"authors": [
{
"name": "Jim Jagielski",
"email": "jimjag@gmail.com"
},
{
"name": "Marcus Bointon",
"email": "phpmailer@synchromedia.co.uk"
},
{
"name": "Jim Jagielski",
"email": "jimjag@gmail.com"
},
{
"name": "Andy Prevost",
"email": "codeworxtech@users.sourceforge.net"
@@ -430,7 +431,7 @@
}
],
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
"time": "2019-02-01T15:04:28+00:00"
"time": "2019-09-27T21:33:43+00:00"
},
{
"name": "psr/http-message",
@@ -490,16 +491,16 @@
},
{
"name": "qcloud/cos-sdk-v5",
"version": "v1.3.3",
"version": "v1.3.4",
"source": {
"type": "git",
"url": "https://github.com/tencentyun/cos-php-sdk-v5.git",
"reference": "cd1b9cefa04521eaf125a82eb53552d9a87aae4d"
"reference": "1b32aa422f6dffe4ea411e5095e4b0da9135551b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tencentyun/cos-php-sdk-v5/zipball/cd1b9cefa04521eaf125a82eb53552d9a87aae4d",
"reference": "cd1b9cefa04521eaf125a82eb53552d9a87aae4d",
"url": "https://api.github.com/repos/tencentyun/cos-php-sdk-v5/zipball/1b32aa422f6dffe4ea411e5095e4b0da9135551b",
"reference": "1b32aa422f6dffe4ea411e5095e4b0da9135551b",
"shasum": "",
"mirrors": [
{
@@ -538,20 +539,20 @@
"php",
"qcloud"
],
"time": "2019-08-07T10:15:47+00:00"
"time": "2019-09-02T12:08:44+00:00"
},
{
"name": "qiniu/php-sdk",
"version": "v7.2.9",
"version": "v7.2.10",
"source": {
"type": "git",
"url": "https://github.com/qiniu/php-sdk.git",
"reference": "afe7d8715d8a688b1d8d8cdf031240d2363dad90"
"reference": "d89987163f560ebf9dfa5bb25de9bd9b1a3b2bd8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/qiniu/php-sdk/zipball/afe7d8715d8a688b1d8d8cdf031240d2363dad90",
"reference": "afe7d8715d8a688b1d8d8cdf031240d2363dad90",
"url": "https://api.github.com/repos/qiniu/php-sdk/zipball/d89987163f560ebf9dfa5bb25de9bd9b1a3b2bd8",
"reference": "d89987163f560ebf9dfa5bb25de9bd9b1a3b2bd8",
"shasum": "",
"mirrors": [
{
@@ -595,7 +596,7 @@
"sdk",
"storage"
],
"time": "2019-07-09T07:55:07+00:00"
"time": "2019-10-28T10:23:23+00:00"
},
{
"name": "ralouphie/getallheaders",
@@ -711,16 +712,16 @@
},
{
"name": "topthink/framework",
"version": "v5.1.38",
"version": "v5.1.38.1",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
"reference": "b538d2615794bfd05455b6f8232a359d09f5a8df"
"reference": "12d15c29d5d6a972fc8bfc8db005d64d4786028c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/b538d2615794bfd05455b6f8232a359d09f5a8df",
"reference": "b538d2615794bfd05455b6f8232a359d09f5a8df",
"url": "https://api.github.com/repos/top-think/framework/zipball/12d15c29d5d6a972fc8bfc8db005d64d4786028c",
"reference": "12d15c29d5d6a972fc8bfc8db005d64d4786028c",
"shasum": "",
"mirrors": [
{
@@ -764,7 +765,7 @@
"orm",
"thinkphp"
],
"time": "2019-08-09T07:12:36+00:00"
"time": "2019-08-12T00:58:30+00:00"
},
{
"name": "topthink/think-captcha",
@@ -906,16 +907,16 @@
},
{
"name": "upyun/sdk",
"version": "3.3.0",
"version": "3.4.0",
"source": {
"type": "git",
"url": "https://github.com/upyun/php-sdk.git",
"reference": "1a2dd5ae31047956c733aef0f764f3a527d30628"
"reference": "b4819fd941e3f19a886f8b3c5f8bffcb8279185f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/upyun/php-sdk/zipball/1a2dd5ae31047956c733aef0f764f3a527d30628",
"reference": "1a2dd5ae31047956c733aef0f764f3a527d30628",
"url": "https://api.github.com/repos/upyun/php-sdk/zipball/b4819fd941e3f19a886f8b3c5f8bffcb8279185f",
"reference": "b4819fd941e3f19a886f8b3c5f8bffcb8279185f",
"shasum": "",
"mirrors": [
{
@@ -945,10 +946,6 @@
"MIT"
],
"authors": [
{
"name": "totoleo",
"email": "totoleo@163.com"
},
{
"name": "lfeng",
"email": "bonevv@gmail.com"
@@ -957,6 +954,10 @@
"name": "lvtongda",
"email": "riyao.lyu@gmail.com"
},
{
"name": "totoleo",
"email": "totoleo@163.com"
},
{
"name": "sabakugaara",
"email": "senellise@gmail.com"
@@ -968,7 +969,7 @@
"sdk",
"upyun"
],
"time": "2017-11-12T09:17:42+00:00"
"time": "2019-04-29T09:27:51+00:00"
}
],
"packages-dev": [],
+7 -1
View File
@@ -686,7 +686,13 @@ if (!function_exists('widget')) {
*/
function widget($name, $data = [])
{
return app()->action($name, $data, 'widget');
$result = app()->action($name, $data, 'widget');
if (is_object($result)) {
$result = $result->getContent();
}
return $result;
}
}
+1 -1
View File
@@ -353,7 +353,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
$result = isset($data[$field]) ? $data[$field] : null;
}
switch ($operator) {
switch (strtolower($operator)) {
case '===':
return $result === $value;
case '!==':
+4 -1
View File
@@ -160,7 +160,10 @@ class View
*/
public function filter($filter)
{
$this->filter = $filter;
if ($filter) {
$this->filter = $filter;
}
return $this;
}
View File
+52 -51
View File
@@ -154,17 +154,17 @@
},
{
"name": "guzzlehttp/guzzle",
"version": "6.3.3",
"version_normalized": "6.3.3.0",
"version": "6.4.1",
"version_normalized": "6.4.1.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba"
"reference": "0895c932405407fd3a7368b6910c09a24d26db11"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba",
"reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/0895c932405407fd3a7368b6910c09a24d26db11",
"reference": "0895c932405407fd3a7368b6910c09a24d26db11",
"shasum": "",
"mirrors": [
{
@@ -174,19 +174,20 @@
]
},
"require": {
"ext-json": "*",
"guzzlehttp/promises": "^1.0",
"guzzlehttp/psr7": "^1.4",
"guzzlehttp/psr7": "^1.6.1",
"php": ">=5.5"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
"psr/log": "^1.0"
"psr/log": "^1.1"
},
"suggest": {
"psr/log": "Required for using the Log middleware"
},
"time": "2018-04-22T15:46:56+00:00",
"time": "2019-10-23T15:58:00+00:00",
"type": "library",
"extra": {
"branch-alias": {
@@ -195,12 +196,12 @@
},
"installation-source": "dist",
"autoload": {
"files": [
"src/functions_include.php"
],
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@@ -365,17 +366,17 @@
},
{
"name": "phpmailer/phpmailer",
"version": "v6.0.7",
"version_normalized": "6.0.7.0",
"version": "v6.1.1",
"version_normalized": "6.1.1.0",
"source": {
"type": "git",
"url": "https://github.com/PHPMailer/PHPMailer.git",
"reference": "0c41a36d4508d470e376498c1c0c527aa36a2d59"
"reference": "26bd96350b0b2fcbf0ef4e6f0f9cf3528302a9d8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/0c41a36d4508d470e376498c1c0c527aa36a2d59",
"reference": "0c41a36d4508d470e376498c1c0c527aa36a2d59",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/26bd96350b0b2fcbf0ef4e6f0f9cf3528302a9d8",
"reference": "26bd96350b0b2fcbf0ef4e6f0f9cf3528302a9d8",
"shasum": "",
"mirrors": [
{
@@ -406,7 +407,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-02-01T15:04:28+00:00",
"time": "2019-09-27T21:33:43+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -416,17 +417,17 @@
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1"
"LGPL-2.1-only"
],
"authors": [
{
"name": "Jim Jagielski",
"email": "jimjag@gmail.com"
},
{
"name": "Marcus Bointon",
"email": "phpmailer@synchromedia.co.uk"
},
{
"name": "Jim Jagielski",
"email": "jimjag@gmail.com"
},
{
"name": "Andy Prevost",
"email": "codeworxtech@users.sourceforge.net"
@@ -497,17 +498,17 @@
},
{
"name": "qcloud/cos-sdk-v5",
"version": "v1.3.3",
"version_normalized": "1.3.3.0",
"version": "v1.3.4",
"version_normalized": "1.3.4.0",
"source": {
"type": "git",
"url": "https://github.com/tencentyun/cos-php-sdk-v5.git",
"reference": "cd1b9cefa04521eaf125a82eb53552d9a87aae4d"
"reference": "1b32aa422f6dffe4ea411e5095e4b0da9135551b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tencentyun/cos-php-sdk-v5/zipball/cd1b9cefa04521eaf125a82eb53552d9a87aae4d",
"reference": "cd1b9cefa04521eaf125a82eb53552d9a87aae4d",
"url": "https://api.github.com/repos/tencentyun/cos-php-sdk-v5/zipball/1b32aa422f6dffe4ea411e5095e4b0da9135551b",
"reference": "1b32aa422f6dffe4ea411e5095e4b0da9135551b",
"shasum": "",
"mirrors": [
{
@@ -520,7 +521,7 @@
"guzzle/guzzle": "~3.7",
"php": ">=5.3.0"
},
"time": "2019-08-07T10:15:47+00:00",
"time": "2019-09-02T12:08:44+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -551,17 +552,17 @@
},
{
"name": "qiniu/php-sdk",
"version": "v7.2.9",
"version_normalized": "7.2.9.0",
"version": "v7.2.10",
"version_normalized": "7.2.10.0",
"source": {
"type": "git",
"url": "https://github.com/qiniu/php-sdk.git",
"reference": "afe7d8715d8a688b1d8d8cdf031240d2363dad90"
"reference": "d89987163f560ebf9dfa5bb25de9bd9b1a3b2bd8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/qiniu/php-sdk/zipball/afe7d8715d8a688b1d8d8cdf031240d2363dad90",
"reference": "afe7d8715d8a688b1d8d8cdf031240d2363dad90",
"url": "https://api.github.com/repos/qiniu/php-sdk/zipball/d89987163f560ebf9dfa5bb25de9bd9b1a3b2bd8",
"reference": "d89987163f560ebf9dfa5bb25de9bd9b1a3b2bd8",
"shasum": "",
"mirrors": [
{
@@ -577,7 +578,7 @@
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.3"
},
"time": "2019-07-09T07:55:07+00:00",
"time": "2019-10-28T10:23:23+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -726,17 +727,17 @@
},
{
"name": "topthink/framework",
"version": "v5.1.38",
"version_normalized": "5.1.38.0",
"version": "v5.1.38.1",
"version_normalized": "5.1.38.1",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
"reference": "b538d2615794bfd05455b6f8232a359d09f5a8df"
"reference": "12d15c29d5d6a972fc8bfc8db005d64d4786028c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/b538d2615794bfd05455b6f8232a359d09f5a8df",
"reference": "b538d2615794bfd05455b6f8232a359d09f5a8df",
"url": "https://api.github.com/repos/top-think/framework/zipball/12d15c29d5d6a972fc8bfc8db005d64d4786028c",
"reference": "12d15c29d5d6a972fc8bfc8db005d64d4786028c",
"shasum": "",
"mirrors": [
{
@@ -758,7 +759,7 @@
"sebastian/phpcpd": "2.*",
"squizlabs/php_codesniffer": "2.*"
},
"time": "2019-08-09T07:12:36+00:00",
"time": "2019-08-12T00:58:30+00:00",
"type": "think-framework",
"installation-source": "dist",
"notification-url": "https://packagist.org/downloads/",
@@ -929,17 +930,17 @@
},
{
"name": "upyun/sdk",
"version": "3.3.0",
"version_normalized": "3.3.0.0",
"version": "3.4.0",
"version_normalized": "3.4.0.0",
"source": {
"type": "git",
"url": "https://github.com/upyun/php-sdk.git",
"reference": "1a2dd5ae31047956c733aef0f764f3a527d30628"
"reference": "b4819fd941e3f19a886f8b3c5f8bffcb8279185f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/upyun/php-sdk/zipball/1a2dd5ae31047956c733aef0f764f3a527d30628",
"reference": "1a2dd5ae31047956c733aef0f764f3a527d30628",
"url": "https://api.github.com/repos/upyun/php-sdk/zipball/b4819fd941e3f19a886f8b3c5f8bffcb8279185f",
"reference": "b4819fd941e3f19a886f8b3c5f8bffcb8279185f",
"shasum": "",
"mirrors": [
{
@@ -958,7 +959,7 @@
"phpdocumentor/phpdocumentor": "^2.9",
"phpunit/phpunit": "~4.0"
},
"time": "2017-11-12T09:17:42+00:00",
"time": "2019-04-29T09:27:51+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -971,10 +972,6 @@
"MIT"
],
"authors": [
{
"name": "totoleo",
"email": "totoleo@163.com"
},
{
"name": "lfeng",
"email": "bonevv@gmail.com"
@@ -983,6 +980,10 @@
"name": "lvtongda",
"email": "riyao.lyu@gmail.com"
},
{
"name": "totoleo",
"email": "totoleo@163.com"
},
{
"name": "sabakugaara",
"email": "senellise@gmail.com"
+21
View File
@@ -0,0 +1,21 @@
<?php
$config = PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'declare_strict_types' => false,
'concat_space' => ['spacing'=>'one'],
// 'ordered_imports' => true,
// 'phpdoc_align' => ['align'=>'vertical'],
// 'native_function_invocation' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->name('*.php')
)
;
return $config;
+17
View File
@@ -1,5 +1,22 @@
# Change Log
## 6.4.1 - 2019-10-23
* No `guzzle.phar` was created in 6.4.0 due expired API token. This release will fix that
* Added `parent::__construct()` to `FileCookieJar` and `SessionCookieJar`
## 6.4.0 - 2019-10-23
* Improvement: Improved error messages when using curl < 7.21.2 [#2108](https://github.com/guzzle/guzzle/pull/2108)
* Fix: Test if response is readable before returning a summary in `RequestException::getResponseBodySummary()` [#2081](https://github.com/guzzle/guzzle/pull/2081)
* Fix: Add support for GUZZLE_CURL_SELECT_TIMEOUT environment variable [#2161](https://github.com/guzzle/guzzle/pull/2161)
* Improvement: Added `GuzzleHttp\Exception\InvalidArgumentException` [#2163](https://github.com/guzzle/guzzle/pull/2163)
* Improvement: Added `GuzzleHttp\_current_time()` to use `hrtime()` if that function exists. [#2242](https://github.com/guzzle/guzzle/pull/2242)
* Improvement: Added curl's `appconnect_time` in `TransferStats` [#2284](https://github.com/guzzle/guzzle/pull/2284)
* Improvement: Make GuzzleException extend Throwable wherever it's available [#2273](https://github.com/guzzle/guzzle/pull/2273)
* Fix: Prevent concurrent writes to file when saving `CookieJar` [#2335](https://github.com/guzzle/guzzle/pull/2335)
* Improvement: Update `MockHandler` so we can test transfer time [#2362](https://github.com/guzzle/guzzle/pull/2362)
## 6.3.3 - 2018-04-22
* Fix: Default headers when decode_content is specified
+18
View File
@@ -0,0 +1,18 @@
FROM composer:latest as setup
RUN mkdir /guzzle
WORKDIR /guzzle
RUN set -xe \
&& composer init --name=guzzlehttp/test --description="Simple project for testing Guzzle scripts" --author="Márk Sági-Kazár <mark.sagikazar@gmail.com>" --no-interaction \
&& composer require guzzlehttp/guzzle
FROM php:7.3
RUN mkdir /guzzle
WORKDIR /guzzle
COPY --from=setup /guzzle /guzzle
+10 -11
View File
@@ -21,19 +21,18 @@ trivial to integrate with web services.
```php
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle');
echo $res->getStatusCode();
// 200
echo $res->getHeaderLine('content-type');
// 'application/json; charset=utf8'
echo $res->getBody();
// '{"id": 1420053, "name": "guzzle", ...}'
$response = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle');
// Send an asynchronous request.
echo $response->getStatusCode(); # 200
echo $response->getHeaderLine('content-type'); # 'application/json; charset=utf8'
echo $response->getBody(); # '{"id": 1420053, "name": "guzzle", ...}'
# Send an asynchronous request.
$request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org');
$promise = $client->sendAsync($request)->then(function ($response) {
echo 'I completed! ' . $response->getBody();
});
$promise->wait();
```
@@ -57,7 +56,7 @@ curl -sS https://getcomposer.org/installer | php
Next, run the Composer command to install the latest stable version of Guzzle:
```bash
php composer.phar require guzzlehttp/guzzle
composer require guzzlehttp/guzzle
```
After installing, you need to require Composer's autoloader:
@@ -69,7 +68,7 @@ require 'vendor/autoload.php';
You can then later update Guzzle using composer:
```bash
composer.phar update
composer update
```
@@ -86,6 +85,6 @@ composer.phar update
[guzzle-4-repo]: https://github.com/guzzle/guzzle/tree/4.x
[guzzle-5-repo]: https://github.com/guzzle/guzzle/tree/5.3
[guzzle-6-repo]: https://github.com/guzzle/guzzle
[guzzle-3-docs]: http://guzzle3.readthedocs.org/en/latest/
[guzzle-3-docs]: http://guzzle3.readthedocs.org
[guzzle-5-docs]: http://guzzle.readthedocs.org/en/5.3/
[guzzle-6-docs]: http://guzzle.readthedocs.org/en/latest/
+29 -15
View File
@@ -2,7 +2,15 @@
"name": "guzzlehttp/guzzle",
"type": "library",
"description": "Guzzle is a PHP HTTP client library",
"keywords": ["framework", "http", "rest", "web service", "curl", "client", "HTTP client"],
"keywords": [
"framework",
"http",
"rest",
"web service",
"curl",
"client",
"HTTP client"
],
"homepage": "http://guzzlephp.org/",
"license": "MIT",
"authors": [
@@ -14,31 +22,37 @@
],
"require": {
"php": ">=5.5",
"guzzlehttp/psr7": "^1.4",
"guzzlehttp/promises": "^1.0"
"ext-json": "*",
"guzzlehttp/promises": "^1.0",
"guzzlehttp/psr7": "^1.6.1"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
"psr/log": "^1.0"
},
"autoload": {
"files": ["src/functions_include.php"],
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"GuzzleHttp\\Tests\\": "tests/"
}
"psr/log": "^1.1"
},
"suggest": {
"psr/log": "Required for using the Log middleware"
},
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-master": "6.3-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"autoload-dev": {
"psr-4": {
"GuzzleHttp\\Tests\\": "tests/"
}
}
}
+9
View File
@@ -0,0 +1,9 @@
parameters:
level: 1
paths:
- src
ignoreErrors:
-
message: '#Function uri_template not found#'
path: %currentWorkingDirectory%/src/functions.php
+1 -1
View File
@@ -210,7 +210,7 @@ class Client implements ClientInterface
*
* @return array
*/
private function prepareDefaults($options)
private function prepareDefaults(array $options)
{
$defaults = $this->config;
+1 -1
View File
@@ -12,7 +12,7 @@ use Psr\Http\Message\UriInterface;
*/
interface ClientInterface
{
const VERSION = '6.3.3';
const VERSION = '6.4.1';
/**
* Send an HTTP request.
+1 -1
View File
@@ -120,7 +120,7 @@ class CookieJar implements CookieJarInterface
} elseif (!$path) {
$this->cookies = array_filter(
$this->cookies,
function (SetCookie $cookie) use ($path, $domain) {
function (SetCookie $cookie) use ($domain) {
return !$cookie->matchesDomain($domain);
}
);
+2 -1
View File
@@ -23,6 +23,7 @@ class FileCookieJar extends CookieJar
*/
public function __construct($cookieFile, $storeSessionCookies = false)
{
parent::__construct();
$this->filename = $cookieFile;
$this->storeSessionCookies = $storeSessionCookies;
@@ -56,7 +57,7 @@ class FileCookieJar extends CookieJar
}
$jsonStr = \GuzzleHttp\json_encode($json);
if (false === file_put_contents($filename, $jsonStr)) {
if (false === file_put_contents($filename, $jsonStr, LOCK_EX)) {
throw new \RuntimeException("Unable to save file {$filename}");
}
}
@@ -22,6 +22,7 @@ class SessionCookieJar extends CookieJar
*/
public function __construct($sessionKey, $storeSessionCookies = false)
{
parent::__construct();
$this->sessionKey = $sessionKey;
$this->storeSessionCookies = $storeSessionCookies;
$this->load();
+2 -2
View File
@@ -227,7 +227,7 @@ class SetCookie
/**
* Get whether or not this is a secure cookie
*
* @return null|bool
* @return bool|null
*/
public function getSecure()
{
@@ -247,7 +247,7 @@ class SetCookie
/**
* Get whether or not this is a session cookie
*
* @return null|bool
* @return bool|null
*/
public function getDiscard()
{
+3 -1
View File
@@ -4,4 +4,6 @@ namespace GuzzleHttp\Exception;
/**
* Exception when a client error is encountered (4xx codes)
*/
class ClientException extends BadResponseException {}
class ClientException extends BadResponseException
{
}
+20 -10
View File
@@ -1,13 +1,23 @@
<?php
namespace GuzzleHttp\Exception;
/**
* @method string getMessage()
* @method \Throwable|null getPrevious()
* @method mixed getCode()
* @method string getFile()
* @method int getLine()
* @method array getTrace()
* @method string getTraceAsString()
*/
interface GuzzleException {}
use Throwable;
if (interface_exists(Throwable::class)) {
interface GuzzleException extends Throwable
{
}
} else {
/**
* @method string getMessage()
* @method \Throwable|null getPrevious()
* @method mixed getCode()
* @method string getFile()
* @method int getLine()
* @method array getTrace()
* @method string getTraceAsString()
*/
interface GuzzleException
{
}
}
@@ -0,0 +1,7 @@
<?php
namespace GuzzleHttp\Exception;
final class InvalidArgumentException extends \InvalidArgumentException implements GuzzleException
{
}
@@ -126,7 +126,7 @@ class RequestException extends TransferException
{
$body = $response->getBody();
if (!$body->isSeekable()) {
if (!$body->isSeekable() || !$body->isReadable()) {
return null;
}
+3 -1
View File
@@ -4,4 +4,6 @@ namespace GuzzleHttp\Exception;
/**
* Exception when a server error is encountered (5xx codes)
*/
class ServerException extends BadResponseException {}
class ServerException extends BadResponseException
{
}
@@ -1,4 +1,6 @@
<?php
namespace GuzzleHttp\Exception;
class TooManyRedirectsException extends RequestException {}
class TooManyRedirectsException extends RequestException
{
}
@@ -1,4 +1,6 @@
<?php
namespace GuzzleHttp\Exception;
class TransferException extends \RuntimeException implements GuzzleException {}
class TransferException extends \RuntimeException implements GuzzleException
{
}
+22 -7
View File
@@ -14,6 +14,9 @@ use Psr\Http\Message\RequestInterface;
*/
class CurlFactory implements CurlFactoryInterface
{
const CURL_VERSION_STR = 'curl_version';
const LOW_CURL_VERSION_NUMBER = '7.21.2';
/** @var array */
private $handles = [];
@@ -117,6 +120,7 @@ class CurlFactory implements CurlFactoryInterface
private static function invokeStats(EasyHandle $easy)
{
$curlStats = curl_getinfo($easy->handle);
$curlStats['appconnect_time'] = curl_getinfo($easy->handle, CURLINFO_APPCONNECT_TIME);
$stats = new TransferStats(
$easy->request,
$easy->response,
@@ -136,7 +140,9 @@ class CurlFactory implements CurlFactoryInterface
$ctx = [
'errno' => $easy->errno,
'error' => curl_error($easy->handle),
'appconnect_time' => curl_getinfo($easy->handle, CURLINFO_APPCONNECT_TIME),
] + curl_getinfo($easy->handle);
$ctx[self::CURL_VERSION_STR] = curl_version()['version'];
$factory->release($easy);
// Retry when nothing is present or when curl failed to rewind.
@@ -172,13 +178,22 @@ class CurlFactory implements CurlFactoryInterface
)
);
}
$message = sprintf(
'cURL error %s: %s (%s)',
$ctx['errno'],
$ctx['error'],
'see http://curl.haxx.se/libcurl/c/libcurl-errors.html'
);
if (version_compare($ctx[self::CURL_VERSION_STR], self::LOW_CURL_VERSION_NUMBER)) {
$message = sprintf(
'cURL error %s: %s (%s)',
$ctx['errno'],
$ctx['error'],
'see https://curl.haxx.se/libcurl/c/libcurl-errors.html'
);
} else {
$message = sprintf(
'cURL error %s: %s (%s) for %s',
$ctx['errno'],
$ctx['error'],
'see https://curl.haxx.se/libcurl/c/libcurl-errors.html',
$easy->request->getUri()
);
}
// Create a connection exception if it was a specific error code.
$error = isset($connectionErrors[$easy->errno])
+11 -5
View File
@@ -37,8 +37,14 @@ class CurlMultiHandler
{
$this->factory = isset($options['handle_factory'])
? $options['handle_factory'] : new CurlFactory(50);
$this->selectTimeout = isset($options['select_timeout'])
? $options['select_timeout'] : 1;
if (isset($options['select_timeout'])) {
$this->selectTimeout = $options['select_timeout'];
} elseif ($selectTimeout = getenv('GUZZLE_CURL_SELECT_TIMEOUT')) {
$this->selectTimeout = $selectTimeout;
} else {
$this->selectTimeout = 1;
}
}
public function __get($name)
@@ -82,7 +88,7 @@ class CurlMultiHandler
{
// Add any delayed handles if needed.
if ($this->delays) {
$currentTime = microtime(true);
$currentTime = \GuzzleHttp\_current_time();
foreach ($this->delays as $id => $delay) {
if ($currentTime >= $delay) {
unset($this->delays[$id]);
@@ -134,7 +140,7 @@ class CurlMultiHandler
if (empty($easy->options['delay'])) {
curl_multi_add_handle($this->_mh, $easy->handle);
} else {
$this->delays[$id] = microtime(true) + ($easy->options['delay'] / 1000);
$this->delays[$id] = \GuzzleHttp\_current_time() + ($easy->options['delay'] / 1000);
}
}
@@ -186,7 +192,7 @@ class CurlMultiHandler
private function timeToNext()
{
$currentTime = microtime(true);
$currentTime = \GuzzleHttp\_current_time();
$nextTime = PHP_INT_MAX;
foreach ($this->delays as $time) {
if ($time < $nextTime) {
+2 -1
View File
@@ -182,7 +182,8 @@ class MockHandler implements \Countable
$reason = null
) {
if (isset($options['on_stats'])) {
$stats = new TransferStats($request, $response, 0, $reason);
$transferTime = isset($options['transfer_time']) ? $options['transfer_time'] : 0;
$stats = new TransferStats($request, $response, $transferTime, $reason);
call_user_func($options['on_stats'], $stats);
}
}
+17 -5
View File
@@ -33,7 +33,7 @@ class StreamHandler
usleep($options['delay'] * 1000);
}
$startTime = isset($options['on_stats']) ? microtime(true) : null;
$startTime = isset($options['on_stats']) ? \GuzzleHttp\_current_time() : null;
try {
// Does not support the expect header.
@@ -42,7 +42,7 @@ class StreamHandler
// Append a content-length header if body size is zero to match
// cURL's behavior.
if (0 === $request->getBody()->getSize()) {
$request = $request->withHeader('Content-Length', 0);
$request = $request->withHeader('Content-Length', '0');
}
return $this->createResponse(
@@ -82,7 +82,7 @@ class StreamHandler
$stats = new TransferStats(
$request,
$response,
microtime(true) - $startTime,
\GuzzleHttp\_current_time() - $startTime,
$error,
[]
);
@@ -343,13 +343,25 @@ class StreamHandler
if ('v4' === $options['force_ip_resolve']) {
$records = dns_get_record($uri->getHost(), DNS_A);
if (!isset($records[0]['ip'])) {
throw new ConnectException(sprintf("Could not resolve IPv4 address for host '%s'", $uri->getHost()), $request);
throw new ConnectException(
sprintf(
"Could not resolve IPv4 address for host '%s'",
$uri->getHost()
),
$request
);
}
$uri = $uri->withHost($records[0]['ip']);
} elseif ('v6' === $options['force_ip_resolve']) {
$records = dns_get_record($uri->getHost(), DNS_AAAA);
if (!isset($records[0]['ipv6'])) {
throw new ConnectException(sprintf("Could not resolve IPv6 address for host '%s'", $uri->getHost()), $request);
throw new ConnectException(
sprintf(
"Could not resolve IPv6 address for host '%s'",
$uri->getHost()
),
$request
);
}
$uri = $uri->withHost('[' . $records[0]['ipv6'] . ']');
}
+4 -4
View File
@@ -206,7 +206,7 @@ class HandlerStack
}
/**
* @param $name
* @param string $name
* @return int
*/
private function findByName($name)
@@ -223,10 +223,10 @@ class HandlerStack
/**
* Splices a function into the middleware list at a specific position.
*
* @param $findName
* @param $withName
* @param string $findName
* @param string $withName
* @param callable $middleware
* @param $before
* @param bool $before
*/
private function splice($findName, $withName, callable $middleware, $before)
{
+3 -4
View File
@@ -7,7 +7,6 @@ use GuzzleHttp\Promise\RejectedPromise;
use GuzzleHttp\Psr7;
use Psr\Http\Message\ResponseInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
/**
* Functions used to create and wrap handlers with handler middleware.
@@ -39,7 +38,7 @@ final class Middleware
$cookieJar->extractCookies($request, $response);
return $response;
}
);
);
};
};
}
@@ -58,7 +57,7 @@ final class Middleware
return $handler($request, $options);
}
return $handler($request, $options)->then(
function (ResponseInterface $response) use ($request, $handler) {
function (ResponseInterface $response) use ($request) {
$code = $response->getStatusCode();
if ($code < 400) {
return $response;
@@ -183,7 +182,7 @@ final class Middleware
*
* @return callable Returns a function that accepts the next handler.
*/
public static function log(LoggerInterface $logger, MessageFormatter $formatter, $logLevel = LogLevel::INFO)
public static function log(LoggerInterface $logger, MessageFormatter $formatter, $logLevel = 'info' /* \Psr\Log\LogLevel::INFO */)
{
return function (callable $handler) use ($logger, $formatter, $logLevel) {
return function ($request, array $options) use ($handler, $logger, $formatter, $logLevel) {
+1 -1
View File
@@ -6,7 +6,7 @@ use Psr\Http\Message\RequestInterface;
use GuzzleHttp\Promise\EachPromise;
/**
* Sends and iterator of requests concurrently using a capped pool size.
* Sends an iterator of requests concurrently using a capped pool size.
*
* The pool will read from an iterator until it is cancelled or until the
* iterator is consumed. When a request is yielded, the request is sent after
+1 -1
View File
@@ -186,7 +186,7 @@ class RedirectMiddleware
if ($options['allow_redirects']['referer']
&& $modify['uri']->getScheme() === $request->getUri()->getScheme()
) {
$uri = $request->getUri()->withUserInfo('', '');
$uri = $request->getUri()->withUserInfo('');
$modify['set_headers']['Referer'] = (string) $uri;
} else {
$modify['remove_headers'][] = 'Referer';
+1 -1
View File
@@ -22,7 +22,7 @@ final class RequestOptions
* - strict: (bool, default=false) Set to true to use strict redirects
* meaning redirect POST requests with POST requests vs. doing what most
* browsers do which is redirect POST requests with GET requests
* - referer: (bool, default=true) Set to false to disable the Referer
* - referer: (bool, default=false) Set to true to enable the Referer
* header.
* - protocols: (array, default=['http', 'https']) Allowed redirect
* protocols.
+4 -1
View File
@@ -19,6 +19,9 @@ class RetryMiddleware
/** @var callable */
private $decider;
/** @var callable */
private $delay;
/**
* @param callable $decider Function that accepts the number of retries,
* a request, [response], and [exception] and
@@ -42,7 +45,7 @@ class RetryMiddleware
/**
* Default exponential backoff delay function.
*
* @param $retries
* @param int $retries
*
* @return int
*/
+1 -1
View File
@@ -20,7 +20,7 @@ final class TransferStats
/**
* @param RequestInterface $request Request that was sent.
* @param ResponseInterface $response Response received (if any)
* @param null $transferTime Total handler transfer time.
* @param float|null $transferTime Total handler transfer time.
* @param mixed $handlerErrorData Handler error data.
* @param array $handlerStats Handler specific stats.
*/
+18 -5
View File
@@ -196,7 +196,8 @@ function default_ca_bundle()
}
}
throw new \RuntimeException(<<< EOT
throw new \RuntimeException(
<<< EOT
No system CA bundle could be found in any of the the common system locations.
PHP versions earlier than 5.6 are not properly configured to use the system's
CA bundle by default. In order to verify peer certificates, you will need to
@@ -294,14 +295,14 @@ function is_host_in_noproxy($host, array $noProxyArray)
* @param int $options Bitmask of JSON decode options.
*
* @return mixed
* @throws \InvalidArgumentException if the JSON cannot be decoded.
* @throws Exception\InvalidArgumentException if the JSON cannot be decoded.
* @link http://www.php.net/manual/en/function.json-decode.php
*/
function json_decode($json, $assoc = false, $depth = 512, $options = 0)
{
$data = \json_decode($json, $assoc, $depth, $options);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException(
throw new Exception\InvalidArgumentException(
'json_decode error: ' . json_last_error_msg()
);
}
@@ -317,17 +318,29 @@ function json_decode($json, $assoc = false, $depth = 512, $options = 0)
* @param int $depth Set the maximum depth. Must be greater than zero.
*
* @return string
* @throws \InvalidArgumentException if the JSON cannot be encoded.
* @throws Exception\InvalidArgumentException if the JSON cannot be encoded.
* @link http://www.php.net/manual/en/function.json-encode.php
*/
function json_encode($value, $options = 0, $depth = 512)
{
$json = \json_encode($value, $options, $depth);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException(
throw new Exception\InvalidArgumentException(
'json_encode error: ' . json_last_error_msg()
);
}
return $json;
}
/**
* Wrapper for the hrtime() or microtime() functions
* (depending on the PHP version, one of the two is used)
*
* @return float|mixed UNIX timestamp
* @internal
*/
function _current_time()
{
return function_exists('hrtime') ? hrtime(true) / 1e9 : microtime(true);
}
+29 -26
View File
@@ -10,13 +10,13 @@ Build status: [![Build Status](https://travis-ci.org/PHPMailer/PHPMailer.svg)](h
## 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
- Add attachments, including inline
- Support for UTF-8 content and 8bit, base64, binary, and quoted-printable encodings
- SMTP authentication with LOGIN, PLAIN, CRAM-MD5 and XOAUTH2 mechanisms over SSL and SMTP+STARTTLS transports
- SMTP authentication with LOGIN, PLAIN, CRAM-MD5, and XOAUTH2 mechanisms over SSL and SMTP+STARTTLS transports
- Validates email addresses automatically
- Protect against header injection attacks
- Error messages in over 50 languages!
@@ -26,12 +26,12 @@ Build status: [![Build Status](https://travis-ci.org/PHPMailer/PHPMailer.svg)](h
- Much more!
## Why you might need it
Many PHP developers utilize email in their code. The only PHP function that supports this is the `mail()` function. However, it does not provide any assistance for making use of popular features such as HTML-based emails and attachments.
Many PHP developers need to send email from their code. The only PHP function that supports this is [`mail()`](https://www.php.net/manual/en/function.mail.php). However, it does not provide any assistance for making use of popular features such as encryption, authentication, HTML messages, and attachments.
Formatting email correctly is surprisingly difficult. There are myriad overlapping RFCs, requiring tight adherence to horribly complicated formatting and encoding rules - the vast majority of code that you'll find online that uses the `mail()` function directly is just plain wrong!
*Please* don't be tempted to do it yourself - if you don't use PHPMailer, there are many other excellent libraries that you should look at before rolling your own - try [SwiftMailer](https://swiftmailer.symfony.com/), [Zend/Mail](https://zendframework.github.io/zend-mail/), [eZcomponents](https://github.com/zetacomponents/Mail) etc.
Formatting email correctly is surprisingly difficult. There are myriad overlapping RFCs, requiring tight adherence to horribly complicated formatting and encoding rules the vast majority of code that you'll find online that uses the `mail()` function directly is just plain wrong!
*Please* don't be tempted to do it yourself if you don't use PHPMailer, there are many other excellent libraries that you should look at before rolling your own. Try [SwiftMailer](https://swiftmailer.symfony.com/), [Zend/Mail](https://zendframework.github.io/zend-mail/), [ZetaComponents](https://github.com/zetacomponents/Mail) etc.
The PHP `mail()` function usually sends via a local mail server, typically fronted by a `sendmail` binary on Linux, BSD and OS X platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP implementation allows email sending on Windows platforms without a local mail server.
The PHP `mail()` function usually sends via a local mail server, typically fronted by a `sendmail` binary on Linux, BSD, and macOS platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP implementation allows email sending on Windows platforms without a local mail server.
## License
This software is distributed under the [LGPL 2.1](http://www.gnu.org/licenses/lgpl-2.1.html) license, along with the [GPL Cooperation Commitment](https://gplcc.github.io/gplcc/). Please read LICENSE for information on the software availability and distribution.
@@ -40,7 +40,7 @@ This software is distributed under the [LGPL 2.1](http://www.gnu.org/licenses/lg
PHPMailer is available on [Packagist](https://packagist.org/packages/phpmailer/phpmailer) (using semantic versioning), and installation via [Composer](https://getcomposer.org) is the recommended way to install PHPMailer. Just add this line to your `composer.json` file:
```json
"phpmailer/phpmailer": "~6.0"
"phpmailer/phpmailer": "~6.1"
```
or run
@@ -70,15 +70,13 @@ If you're not using the `SMTP` class explicitly (you're probably not), you don't
If you don't speak git or just want a tarball, click the 'zip' button on the right of the project page in GitHub, though note that docs and examples are not included in the tarball.
## Legacy versions
PHPMailer 5.2 (which is compatible with PHP 5.0 - 7.0) is no longer being supported for feature updates, and will only be receiving security updates from now on. You will find the latest version of 5.2 in the [5.2-stable branch](https://github.com/PHPMailer/PHPMailer/tree/5.2-stable), and future versions of 5.2 will be tagged with 5.2.x version numbers, so existing Composer configs should remain working. If you're using PHP 5.5 or later, we recommend you make the necessary changes to switch to the 6.0 release.
PHPMailer 5.2 (which is compatible with PHP 5.0 - 7.0) is no longer being supported, even for security updates. You will find the latest version of 5.2 in the [5.2-stable branch](https://github.com/PHPMailer/PHPMailer/tree/5.2-stable). If you're using PHP 5.5 or later (which you should be), switch to the 6.x releases.
The 5.2 branch will not receive security updates after December 31st 2018.
## Upgrading from 5.2
### Upgrading from 5.2
The biggest changes are that source files are now in the `src/` folder, and PHPMailer now declares the namespace `PHPMailer\PHPMailer`. This has several important effects [read the upgrade guide](https://github.com/PHPMailer/PHPMailer/tree/master/UPGRADING.md) for more details.
### Minimal installation
While installing the entire package manually or with Composer is simple, convenient and reliable, you may want to include only vital files in your project. At the very least you will need [src/PHPMailer.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/PHPMailer.php). If you're using SMTP, you'll need [src/SMTP.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/SMTP.php), and if you're using POP-before SMTP, you'll need [src/POP3.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/POP3.php). You can skip the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder if you're not showing errors to users and can make do with English-only errors. If you're using XOAUTH2 you will need [src/OAuth.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/OAuth.php) as well as the Composer dependencies for the services you wish to authenticate with. Really, it's much easier to use Composer!
While installing the entire package manually or with Composer is simple, convenient, and reliable, you may want to include only vital files in your project. At the very least you will need [src/PHPMailer.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/PHPMailer.php). If you're using SMTP, you'll need [src/SMTP.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/SMTP.php), and if you're using POP-before SMTP, you'll need [src/POP3.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/POP3.php). You can skip the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder if you're not showing errors to users and can make do with English-only errors. If you're using XOAUTH2 you will need [src/OAuth.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/OAuth.php) as well as the Composer dependencies for the services you wish to authenticate with. Really, it's much easier to use Composer!
## A Simple Example
@@ -87,22 +85,25 @@ While installing the entire package manually or with Composer is simple, conveni
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
//Load Composer's autoloader
// Load Composer's autoloader
require 'vendor/autoload.php';
$mail = new PHPMailer(true); // Passing `true` enables exceptions
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user@example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->SMTPDebug = SMTP::DEBUG_SERVER; // Enable verbose debug output
$mail->isSMTP(); // Send using SMTP
$mail->Host = 'smtp1.example.com'; // Set the SMTP server to send through
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user@example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('from@example.com', 'Mailer');
@@ -112,11 +113,11 @@ try {
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
//Attachments
// Attachments
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
//Content
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
@@ -125,16 +126,18 @@ try {
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
```
You'll find plenty more to play with in the [examples](https://github.com/PHPMailer/PHPMailer/tree/master/examples) folder.
If you are re-using the instance (e.g. when sending to a mailing list), you may need to clear the recipient list to avoid sending duplicate messages. See [the mailing list example](https://github.com/PHPMailer/PHPMailer/blob/master/examples/mailing_list.phps) for further guidance.
That's it. You should now be ready to use PHPMailer!
## Localization
PHPMailer defaults to English, but in the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder you'll find numerous (48 at the time of writing!) translations for PHPMailer error messages that you may encounter. Their filenames contain [ISO 639-1](http://en.wikipedia.org/wiki/ISO_639-1) language code for the translations, for example `fr` for French. To specify a language, you need to tell PHPMailer which one to use, like this:
PHPMailer defaults to English, but in the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder you'll find many translations for PHPMailer error messages that you may encounter. Their filenames contain [ISO 639-1](http://en.wikipedia.org/wiki/ISO_639-1) language code for the translations, for example `fr` for French. To specify a language, you need to tell PHPMailer which one to use, like this:
```php
// To load the French version
+1 -1
View File
@@ -1 +1 @@
6.0.7
6.1.1
+1 -1
View File
@@ -51,5 +51,5 @@
"PHPMailer\\Test\\": "test/"
}
},
"license": "LGPL-2.1"
"license": "LGPL-2.1-only"
}
@@ -0,0 +1,25 @@
<?php
/**
* Afrikaans PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer
*/
$PHPMAILER_LANG['authenticate'] = 'SMTP-fout: kon nie geverifieer word nie.';
$PHPMAILER_LANG['connect_host'] = 'SMTP-fout: kon nie aan SMTP-verbind nie.';
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP-fout: data nie aanvaar nie.';
$PHPMAILER_LANG['empty_message'] = 'Boodskapliggaam leeg.';
$PHPMAILER_LANG['encoding'] = 'Onbekende kodering: ';
$PHPMAILER_LANG['execute'] = 'Kon nie uitvoer nie: ';
$PHPMAILER_LANG['file_access'] = 'Kon nie lêer oopmaak nie: ';
$PHPMAILER_LANG['file_open'] = 'Lêerfout: Kon nie lêer oopmaak nie: ';
$PHPMAILER_LANG['from_failed'] = 'Die volgende Van adres misluk: ';
$PHPMAILER_LANG['instantiate'] = 'Kon nie posfunksie instansieer nie.';
$PHPMAILER_LANG['invalid_address'] = 'Ongeldige adres: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer word nie ondersteun nie.';
$PHPMAILER_LANG['provide_address'] = 'U moet ten minste een ontvanger e-pos adres verskaf.';
$PHPMAILER_LANG['recipients_failed'] = 'SMTP-fout: Die volgende ontvangers het misluk: ';
$PHPMAILER_LANG['signing'] = 'Ondertekening Fout: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP-verbinding () misluk.';
$PHPMAILER_LANG['smtp_error'] = 'SMTP-bediener fout: ';
$PHPMAILER_LANG['variable_set'] = 'Kan nie veranderlike instel of herstel nie: ';
$PHPMAILER_LANG['extension_missing'] = 'Uitbreiding ontbreek: ';
+1 -1
View File
@@ -24,4 +24,4 @@ $PHPMAILER_LANG['signing'] = 'خطا در امضا: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'خطا در اتصال به SMTP.';
$PHPMAILER_LANG['smtp_error'] = 'خطا در SMTP Server: ';
$PHPMAILER_LANG['variable_set'] = 'امکان ارسال یا ارسال مجدد متغیر‌ها وجود ندارد: ';
//$PHPMAILER_LANG['extension_missing'] = 'Extension missing: ';
$PHPMAILER_LANG['extension_missing'] = 'افزونه موجود نیست: ';
@@ -26,4 +26,4 @@ $PHPMAILER_LANG['signing'] = 'Erro de Assinatura: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() falhou.';
$PHPMAILER_LANG['smtp_error'] = 'Erro de servidor SMTP: ';
$PHPMAILER_LANG['variable_set'] = 'Não foi possível definir ou redefinir a variável: ';
$PHPMAILER_LANG['extension_missing'] = 'Extensão ausente: ';
$PHPMAILER_LANG['extension_missing'] = 'Extensão não existe: ';
+8 -8
View File
@@ -7,21 +7,21 @@
*/
$PHPMAILER_LANG['authenticate'] = 'Ошибка SMTP: ошибка авторизации.';
$PHPMAILER_LANG['connect_host'] = 'Ошибка SMTP: не удается подключиться к серверу SMTP.';
$PHPMAILER_LANG['connect_host'] = 'Ошибка SMTP: не удается подключиться к SMTP-серверу.';
$PHPMAILER_LANG['data_not_accepted'] = 'Ошибка SMTP: данные не приняты.';
$PHPMAILER_LANG['encoding'] = 'Неизвестный вид кодировки: ';
$PHPMAILER_LANG['encoding'] = 'Неизвестная кодировка: ';
$PHPMAILER_LANG['execute'] = 'Невозможно выполнить команду: ';
$PHPMAILER_LANG['file_access'] = 'Нет доступа к файлу: ';
$PHPMAILER_LANG['file_open'] = 'Файловая ошибка: не удается открыть файл: ';
$PHPMAILER_LANG['file_open'] = 'Файловая ошибка: не удаётся открыть файл: ';
$PHPMAILER_LANG['from_failed'] = 'Неверный адрес отправителя: ';
$PHPMAILER_LANG['instantiate'] = 'Невозможно запустить функцию mail.';
$PHPMAILER_LANG['provide_address'] = 'Пожалуйста, введите хотя бы один адрес e-mail получателя.';
$PHPMAILER_LANG['instantiate'] = 'Невозможно запустить функцию mail().';
$PHPMAILER_LANG['provide_address'] = 'Пожалуйста, введите хотя бы один email-адрес получателя.';
$PHPMAILER_LANG['mailer_not_supported'] = ' — почтовый сервер не поддерживается.';
$PHPMAILER_LANG['recipients_failed'] = 'Ошибка SMTP: отправка по следующим адресам получателей не удалась: ';
$PHPMAILER_LANG['recipients_failed'] = 'Ошибка SMTP: не удалась отправка таким адресатам: ';
$PHPMAILER_LANG['empty_message'] = 'Пустое сообщение';
$PHPMAILER_LANG['invalid_address'] = 'Не отослано, неправильный формат email адреса: ';
$PHPMAILER_LANG['invalid_address'] = 'Не отправлено из-за неправильного формата email-адреса: ';
$PHPMAILER_LANG['signing'] = 'Ошибка подписи: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'Ошибка соединения с SMTP-сервером';
$PHPMAILER_LANG['smtp_error'] = 'Ошибка SMTP-сервера: ';
$PHPMAILER_LANG['variable_set'] = 'Невозможно установить или переустановить переменную: ';
$PHPMAILER_LANG['variable_set'] = 'Невозможно установить или сбросить переменную: ';
$PHPMAILER_LANG['extension_missing'] = 'Расширение отсутствует: ';
+11 -11
View File
@@ -7,21 +7,21 @@
*/
$PHPMAILER_LANG['authenticate'] = 'Помилка SMTP: помилка авторизації.';
$PHPMAILER_LANG['connect_host'] = 'Помилка SMTP: не вдається під\'єднатися до серверу SMTP.';
$PHPMAILER_LANG['data_not_accepted'] = 'Помилка SMTP: дані не прийняті.';
$PHPMAILER_LANG['encoding'] = 'Невідомий тип кодування: ';
$PHPMAILER_LANG['connect_host'] = 'Помилка SMTP: не вдається під\'єднатися до SMTP-серверу.';
$PHPMAILER_LANG['data_not_accepted'] = 'Помилка SMTP: дані не прийнято.';
$PHPMAILER_LANG['encoding'] = 'Невідоме кодування: ';
$PHPMAILER_LANG['execute'] = 'Неможливо виконати команду: ';
$PHPMAILER_LANG['file_access'] = 'Немає доступу до файлу: ';
$PHPMAILER_LANG['file_open'] = 'Помилка файлової системи: не вдається відкрити файл: ';
$PHPMAILER_LANG['from_failed'] = 'Невірна адреса відправника: ';
$PHPMAILER_LANG['instantiate'] = 'Неможливо запустити функцію mail.';
$PHPMAILER_LANG['provide_address'] = 'Будь-ласка, введіть хоча б одну адресу e-mail отримувача.';
$PHPMAILER_LANG['instantiate'] = 'Неможливо запустити функцію mail().';
$PHPMAILER_LANG['provide_address'] = 'Будь-ласка, введіть хоча б одну email-адресу отримувача.';
$PHPMAILER_LANG['mailer_not_supported'] = ' - поштовий сервер не підтримується.';
$PHPMAILER_LANG['recipients_failed'] = 'Помилка SMTP: відправлення наступним отримувачам не вдалося: ';
$PHPMAILER_LANG['empty_message'] = 'Пусте тіло повідомлення';
$PHPMAILER_LANG['invalid_address'] = 'Не відправлено, невірний формат адреси e-mail: ';
$PHPMAILER_LANG['recipients_failed'] = 'Помилка SMTP: не вдалося відправлення для таких отримувачів: ';
$PHPMAILER_LANG['empty_message'] = 'Пусте повідомлення';
$PHPMAILER_LANG['invalid_address'] = 'Не відправлено через невірний формат email-адреси: ';
$PHPMAILER_LANG['signing'] = 'Помилка підпису: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'Помилка з\'єднання із SMTP-сервером';
$PHPMAILER_LANG['smtp_connect_failed'] = 'Помилка з\'єднання з SMTP-сервером';
$PHPMAILER_LANG['smtp_error'] = 'Помилка SMTP-сервера: ';
$PHPMAILER_LANG['variable_set'] = 'Неможливо встановити або перевстановити змінну: ';
$PHPMAILER_LANG['extension_missing'] = 'Не знайдено розширення: ';
$PHPMAILER_LANG['variable_set'] = 'Неможливо встановити або скинути змінну: ';
$PHPMAILER_LANG['extension_missing'] = 'Розширення відсутнє: ';
+1 -1
View File
@@ -23,7 +23,7 @@ namespace PHPMailer\PHPMailer;
/**
* PHPMailer exception handler.
*
* @author Marcus Bointon <phpmailer@synchromedia.co.uk>
* @author Marcus Bointon <phpmailer@synchromedia.co.uk>
*/
class Exception extends \Exception
{
File diff suppressed because it is too large Load Diff
+8 -8
View File
@@ -3,13 +3,13 @@
* PHPMailer POP-Before-SMTP Authentication Class.
* PHP Version 5.5.
*
* @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
* @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
*
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2017 Marcus Bointon
* @copyright 2012 - 2019 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
@@ -29,14 +29,14 @@ namespace PHPMailer\PHPMailer;
* and then loop through your mail sending script. Providing this process doesn't
* take longer than the verification period lasts on your POP3 server, you should be fine.
* 3) This is really ancient technology; you should only need to use it to talk to very old systems.
* 4) This POP3 class is deliberately lightweight and incomplete, and implements just
* 4) This POP3 class is deliberately lightweight and incomplete, implementing just
* enough to do authentication.
* If you want a more complete class there are other POP3 classes for PHP available.
*
* @author Richard Davey (original author) <rich@corephp.co.uk>
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Richard Davey (original author) <rich@corephp.co.uk>
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
*/
class POP3
{
@@ -45,7 +45,7 @@ class POP3
*
* @var string
*/
const VERSION = '6.0.7';
const VERSION = '6.1.1';
/**
* Default POP3 port number.
+41 -10
View File
@@ -9,7 +9,7 @@
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2017 Marcus Bointon
* @copyright 2012 - 2019 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
@@ -24,8 +24,8 @@ namespace PHPMailer\PHPMailer;
* PHPMailer RFC821 SMTP email transport class.
* Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server.
*
* @author Chris Ryan
* @author Marcus Bointon <phpmailer@synchromedia.co.uk>
* @author Chris Ryan
* @author Marcus Bointon <phpmailer@synchromedia.co.uk>
*/
class SMTP
{
@@ -34,7 +34,7 @@ class SMTP
*
* @var string
*/
const VERSION = '6.0.7';
const VERSION = '6.1.1';
/**
* SMTP line break constant.
@@ -59,26 +59,36 @@ class SMTP
/**
* Debug level for no output.
*
* @var int
*/
const DEBUG_OFF = 0;
/**
* Debug level to show client -> server messages.
*
* @var int
*/
const DEBUG_CLIENT = 1;
/**
* Debug level to show client -> server and server -> client messages.
*
* @var int
*/
const DEBUG_SERVER = 2;
/**
* Debug level to show connection status, client -> server and server -> client messages.
*
* @var int
*/
const DEBUG_CONNECTION = 3;
/**
* Debug level to show all messages.
*
* @var int
*/
const DEBUG_LOWLEVEL = 4;
@@ -745,7 +755,7 @@ class SMTP
*
* @return bool
*
* @see hello()
* @see hello()
*/
protected function sendHello($hello, $host)
{
@@ -853,14 +863,35 @@ class SMTP
* Implements from RFC 821: RCPT <SP> TO:<forward-path> <CRLF>.
*
* @param string $address The address the message is being sent to
* @param string $dsn Comma separated list of DSN notifications. NEVER, SUCCESS, FAILURE
* or DELAY. If you specify NEVER all other notifications are ignored.
*
* @return bool
*/
public function recipient($address)
public function recipient($address, $dsn = '')
{
if (empty($dsn)) {
$rcpt = 'RCPT TO:<' . $address . '>';
} else {
$dsn = strtoupper($dsn);
$notify = [];
if (strpos($dsn, 'NEVER') !== false) {
$notify[] = 'NEVER';
} else {
foreach (['SUCCESS', 'FAILURE', 'DELAY'] as $value) {
if (strpos($dsn, $value) !== false) {
$notify[] = $value;
}
}
}
$rcpt = 'RCPT TO:<' . $address . '> NOTIFY=' . implode(',', $notify);
}
return $this->sendCommand(
'RCPT TO',
'RCPT TO:<' . $address . '>',
$rcpt,
[250, 251]
);
}
@@ -904,7 +935,7 @@ 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]) )?/', $this->last_reply, $matches)) {
if (preg_match('/^([0-9]{3})[ -](?:([0-9]\\.[0-9]\\.[0-9]{1,2}) )?/', $this->last_reply, $matches)) {
$code = $matches[1];
$code_ex = (count($matches) > 2 ? $matches[2] : null);
// Cut off error code from each response line
@@ -1289,7 +1320,7 @@ class SMTP
* If no reply has been received yet, it will return null.
* If no pattern was matched, it will return false.
*
* @return bool|null|string
* @return bool|string|null
*/
protected function recordLastTransactionID()
{
@@ -1315,7 +1346,7 @@ class SMTP
* If no reply has been received yet, it will return null.
* If no pattern was matched, it will return false.
*
* @return bool|null|string
* @return bool|string|null
*
* @see recordLastTransactionID()
*/
@@ -47,7 +47,6 @@ class BucketStyleListener implements EventSubscriberInterface {
* @param Event $event Event emitted.
*/
public function onCommandAfterPrepare(Event $event) {
$command = $event['command'];
$bucket = $command['Bucket'];
$request = $command->getRequest();
@@ -81,7 +80,7 @@ class BucketStyleListener implements EventSubscriberInterface {
$bucket = $bucket.'-'.$this->appId;
}
$request->getParams()->set('bucket', $bucket)->set('key', $key);
$realHost = $bucket. '.' . $request->getHost();
if($this->ipport != null) {
$request->setHost($this->ipport);
+1 -1
View File
@@ -12,7 +12,7 @@ use Qcloud\Cos\Signature;
use Qcloud\Cos\TokenListener;
class Client extends GSClient {
const VERSION = '1.3.3';
const VERSION = '1.3.4';
private $region; // string: region.
private $credentials;
+4 -2
View File
@@ -11,9 +11,10 @@ class Signature {
public function __destruct() {
}
public function signRequest(RequestInterface $request) {
$host = $request->getHeader('Host');
$signTime = (string)(time() - 60) . ';' . (string)(time() + 3600);
$httpString = strtolower($request->getMethod()) . "\n" . urldecode($request->getPath()) .
"\n\nhost=" . $request->getHost() . "\n";
"\n\nhost=" . $host . "\n";
$sha1edHttpString = sha1($httpString);
$stringToSign = "sha1\n$signTime\n$sha1edHttpString\n";
$signKey = hash_hmac('sha1', $signTime, $this->secretKey);
@@ -27,9 +28,10 @@ class Signature {
RequestInterface $request,
$expires = "10 minutes"
) {
$host = $request->getHeader('Host');
$signTime = (string)(time() - 60) . ';' . (string)(strtotime($expires));
$httpString = strtolower($request->getMethod()) . "\n" . urldecode($request->getPath()) .
"\n\nhost=" . $request->getHost() . "\n";
"\n\nhost=" . $host . "\n";
$sha1edHttpString = sha1($httpString);
$stringToSign = "sha1\n$signTime\n$sha1edHttpString\n";
$signKey = hash_hmac('sha1', $signTime, $this->secretKey);
+2
View File
@@ -7,6 +7,8 @@ php:
- 5.6
- 7.0
dist: trusty
before_script:
- export QINIU_TEST_ENV="travis"
- travis_retry composer self-update
+2 -9
View File
@@ -170,23 +170,16 @@ final class CdnManager
public static function createTimestampAntiLeechUrl($rawUrl, $encryptKey, $durationInSeconds)
{
$parsedUrl = parse_url($rawUrl);
$deadline = time() + $durationInSeconds;
$expireHex = dechex($deadline);
$path = isset($parsedUrl['path']) ? $parsedUrl['path'] : '';
$path = implode('/', array_map('rawurlencode', explode('/', $path)));
$strToSign = $encryptKey . $path . $expireHex;
$signStr = md5($strToSign);
$url = $parsedUrl['scheme'].'://'.$parsedUrl['host'].$path;
if (isset($parsedUrl['query'])) {
$signedUrl = $url . '&sign=' . $signStr . '&t=' . $expireHex;
$signedUrl = $rawUrl . '&sign=' . $signStr . '&t=' . $expireHex;
} else {
$signedUrl = $url . '?sign=' . $signStr . '&t=' . $expireHex;
$signedUrl = $rawUrl . '?sign=' . $signStr . '&t=' . $expireHex;
}
return $signedUrl;
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ namespace Qiniu;
final class Config
{
const SDK_VER = '7.2.9';
const SDK_VER = '7.2.10';
const BLOCK_SIZE = 4194304; //4*1024*1024 分块上传块大小,该参数为接口规格,不能修改
+2 -2
View File
@@ -33,7 +33,7 @@ class AppClient
if (!empty($maxUsers)) {
$params['maxUsers'] = $maxUsers;
}
if (!empty($noAutoKickUser)) {
if ($noAutoKickUser !== null) {
$params['noAutoKickUser'] = $noAutoKickUser;
}
$body = json_encode($params);
@@ -65,7 +65,7 @@ class AppClient
if (!empty($maxUsers)) {
$params['maxUsers'] = $maxUsers;
}
if (!empty($noAutoKickUser)) {
if ($noAutoKickUser !== null) {
$params['noAutoKickUser'] = $noAutoKickUser;
}
if (!empty($mergePublishRtmp)) {
+18 -18
View File
@@ -33,7 +33,7 @@ class Sms
"signature_id": <signature_id>
}
*/
public function createSignature(string $signature, string $source, string $pics = null)
public function createSignature($signature, $source, $pics = null)
{
$params['signature'] = $signature;
$params['source'] = $source;
@@ -62,7 +62,7 @@ class Sms
"signature": string
}
*/
public function updateSignature(string $id, string $signature, string $source, string $pics = null)
public function updateSignature($id, $signature, $source, $pics = null)
{
$params['signature'] = $signature;
$params['source'] = $source;
@@ -96,7 +96,7 @@ class Sms
"page_size": int,
}
*/
public function checkSignature(string $audit_status = null, int $page = 1, int $page_size = 20)
public function checkSignature($audit_status = null, $page = 1, $page_size = 20)
{
$url = sprintf(
@@ -116,7 +116,7 @@ class Sms
* id 签名id string 类型,必填,
* @retrun : 请求成功 HTTP 状态码为 200
*/
public function deleteSignature(string $id)
public function deleteSignature($id)
{
$url = $this->baseURL . 'signature/' . $id;
list(, $err) = $this->delete($url);
@@ -139,11 +139,11 @@ class Sms
}
*/
public function createTemplate(
string $name,
string $template,
string $type,
string $description,
string $signture_id
$name,
$template,
$type,
$description,
$signture_id
) {
$params['name'] = $name;
$params['template'] = $template;
@@ -181,7 +181,7 @@ class Sms
"page_size": int
}
*/
public function queryTemplate(string $audit_status = null, int $page = 1, int $page_size = 20)
public function queryTemplate($audit_status = null, $page = 1, $page_size = 20)
{
$url = sprintf(
@@ -205,11 +205,11 @@ class Sms
* @retrun : 请求成功 HTTP 状态码为 200
*/
public function updateTemplate(
string $id,
string $name,
string $template,
string $description,
string $signature_id
$id,
$name,
$template,
$description,
$signature_id
) {
$params['name'] = $name;
$params['template'] = $template;
@@ -226,7 +226,7 @@ class Sms
* id :模板id string 类型,必填,
* @retrun : 请求成功 HTTP 状态码为 200
*/
public function deleteTemplate(string $id)
public function deleteTemplate($id)
{
$url = $this->baseURL . 'template/' . $id;
list(, $err) = $this->delete($url);
@@ -243,7 +243,7 @@ class Sms
"job_id": string
}
*/
public function sendMessage(string $template_id, array $mobiles, array $parameters = null)
public function sendMessage($template_id, $mobiles, $parameters = null)
{
$params['template_id'] = $template_id;
$params['mobiles'] = $mobiles;
@@ -256,7 +256,7 @@ class Sms
return $ret;
}
public function imgToBase64(string $img_file)
public function imgToBase64($img_file)
{
$img_base64 = '';
if (file_exists($img_file)) {
+1 -1
View File
@@ -59,7 +59,7 @@ final class BucketManager
$line = 'false',
$shared = 'false'
) {
$path = '/v3/buckets?region=' . $region . '&line=' . $line . '&shared=' . $share;
$path = '/v3/buckets?region=' . $region . '&line=' . $line . '&shared=' . $shared;
$info = $this->ucPost($path);
return $info;
}
+1 -1
View File
@@ -46,7 +46,7 @@ final class UploadManager
$data,
$params = null,
$mime = 'application/octet-stream',
$fname = null
$fname = "default_filename"
) {
$params = self::trimParams($params);
+1 -1
View File
@@ -25,7 +25,7 @@ class CdnManagerTest extends \PHPUnit_Framework_TestCase
$this->cdnManager = new CdnManager($testAuth);
$this->encryptKey = $timestampAntiLeechEncryptKey;
$this->imgUrl = $customDomain . '/24.jpg';
$this->imgUrl = $customDomain . '/sdktest.png';
}
public function testCreateTimestampAntiLeechUrl()
+2 -2
View File
@@ -8,7 +8,7 @@ class DownloadTest extends \PHPUnit_Framework_TestCase
public function test()
{
global $testAuth;
$base_url = 'http://private-res.qiniudn.com/gogopher.jpg';
$base_url = 'http://sdk.peterpy.cn/gogopher.jpg';
$private_url = $testAuth->privateDownloadUrl($base_url);
$response = Client::get($private_url);
$this->assertEquals(200, $response->statusCode);
@@ -17,7 +17,7 @@ class DownloadTest extends \PHPUnit_Framework_TestCase
public function testFop()
{
global $testAuth;
$base_url = 'http://private-res.qiniudn.com/gogopher.jpg?exif';
$base_url = 'http://sdk.peterpy.cn/gogopher.jpg?exif';
$private_url = $testAuth->privateDownloadUrl($base_url);
$response = Client::get($private_url);
$this->assertEquals(200, $response->statusCode);
+1 -1
View File
@@ -8,7 +8,7 @@ class FopTest extends \PHPUnit_Framework_TestCase
{
public function testExifPub()
{
$fop = new Operation('testres.qiniudn.com');
$fop = new Operation('sdk.peterpy.cn');
list($exif, $error) = $fop->execute('gogopher.jpg', 'exif');
$this->assertNull($error);
$this->assertNotNull($exif);
+1 -1
View File
@@ -21,7 +21,7 @@ $dummyAuth = new Auth($dummyAccessKey, $dummySecretKey);
//cdn
$timestampAntiLeechEncryptKey = getenv('QINIU_TIMESTAMP_ENCRPTKEY');
$customDomain = "http://phpsdk.peterpy.cn";
$customDomain = "http://sdk.peterpy.cn";
$tid = getenv('TRAVIS_JOB_NUMBER');
if (!empty($tid)) {
+6
View File
@@ -0,0 +1,6 @@
* text=auto
/examples export-ignore
/tests export-ignore
/doc.md export-ignore
/phpunit.xml export-ignore
+9
View File
@@ -95,6 +95,15 @@ $file = fopen('/local/path/file', 'r');
$client->write('/save/path', $file);
```
#### 使用并行式断点续传上传文件
```
$serviceConfig->setUploadType('BLOCK_PARALLEL');
$client = new Upyun($serviceConfig);
$file = fopen('/local/path/file', 'r');
$client->write('/save/path', $file);
```
#### 上传图片并转换格式为 `png`,详见[上传作图](http://docs.upyun.com/cloud/image/#_2)
```
-517
View File
@@ -1,517 +0,0 @@
# SDK 文档
又拍云 php sdk 中所有封装的接口,均通过 `Upyun\Upyun` 类封装,后续新版本也会保持
该类方法向下兼容,sdk 中其他类及其方法不保证兼容性。如果有使用疑问欢迎提 [issues](https://github.com/upyun/php-sdk/issues)
## 方法列表
* [Upyun](#upyun)
* [__construct](#__construct)
* [setConfig](#setconfig) 更新服务配置
* [write](#write) 上传一个文件到又拍云存储
* [read](#read) 读取云存储文件/目录内容
* [has](#has) 判断文件是否存在于又拍云存储
* [info](#info) 获取云存储文件/目录的基本信息
* [getMimetype](#getmimetype) 获取云存储文件类型
* [delete](#delete) 删除文件或者目录
* [createDir](#createdir) 创建目录
* [deleteDir](#deletedir) 删除文件或者目录
* [usage](#usage) 获取目录下存储使用量
* [purge](#purge) 刷新缓存
* [process](#process) 异步云处理
* [queryProcessStatus](#queryprocessstatus) 查询异步云处理任务进度
* [queryProcessResult](#queryprocessresult) 查询异步云处理任务结果
## Upyun
`Upyun\Upyun` 类实现了又拍云云存储和云处理的所有接口,通过该类可以实现文件上传、下载;图片视频等多媒体资源云处理。
本文档中,提到的"服务"是指又拍云文件加速回又拍云源类型的服务(即原先的存储类服务)。
* 命名空间: `\Upyun\Upyun`
### __construct
Upyun constructor.
```php
Upyun::__construct( \Upyun\Config $config )
```
**参数列表:**
- **\Upyun\Config** `$config`
服务配置
---
### setConfig
更新服务配置
```php
Upyun::setConfig( \Upyun\Config $config )
```
当需要操作的新的服务时,使用该方法传入新的服务配置即可
**参数列表:**
- **\Upyun\Config** `$config`
服务配置
---
### write
上传一个文件到又拍云存储
```php
Upyun::write( string $path, string|resource $content, array $params = array(), boolean $withAsyncProcess = false )
```
上传的文件格式支持文件流或者字符串方式上传。除简单的文件上传外,针对多媒体资源(图片、音视频),还可以设置同步/异步预处理多媒体资源,例如:图片的裁剪缩放,音视频的转码截图等等众多又拍云强大的云处理功能
**参数列表:**
- **string** `$path`
被上传的文件在又拍云存储服务中保存的路径
- **string&#124;resource** `$content`
被上传的文件内容(字符串),或者打开该文件获得的文件句柄(文件流)。当上传本地大文件时,推荐使用文件流的方式上传
- **array** `$params`
上传文件时,附加的自定义参数。支持 Content-MD5 Content-Type Content-Secret 等,详见 [上传参数](http://docs.upyun.com/api/rest_api/#_2),例如:
- 设置文件[保护秘钥](http://docs.upyun.com/api/rest_api/#Content-Secret) `write($path, $content, array('Content-Secret' => 'my-secret'))`
- 添加[文件元信息](http://docs.upyun.com/api/rest_api/#metadata) `write($path, $content, array('X-Upyun-Meta-Foo' =>
'bar'))`
- [图片同步预处理](http://docs.upyun.com/cloud/image/#_5) `write($path, $content, array('x-gmkerl-thumb' => '/format/png'))`
- **boolean** `$withAsyncProcess`
默认为 `false`,当上传图片或者音视频资源时,可以设置该参数为 `true`,开启图片音视频的[异步处理功能](http://docs.upyun.com/api/form_api/#_6) ,例如:
```
// 以下参数会将新上传的图片,再异步生成另一份 png 格式的图片,原图不受影响
write($path, $content, array(
'apps' => array(
array(
'name' => 'thumb', //异步图片处理任务
'x-gmkerl-thumb' => '/format/png', // 格式化图片为 png 格式
'save_as': '/iamge/png/new.png', // 处理成功后的图片保存路径
'notify_url': 'http://your.notify.url' // 异步任务完成后的回调地址
)
)
), true);
```
**返回值:**
若文件是图片则返回图片基本信息,如:`array('x-upyun-width' => 123, 'x-upyun-height' => 50, 'x-upyun-frames'
=> 1, 'x-upyun-file-type' => 'JPEG')`,否则返回空数组。当使用异步预处理功能时,返回结果为布尔值,成功为 `true`。
---
### read
读取云存储文件/目录内容
```php
Upyun::read( string $path, resource $saveHandler = NULL, array $params = array() )
```
**参数列表:**
- **string** `$path`
又拍云存储中的文件或者目录路径
- **resource** `$saveHandler`
文件内容写入本地文件流。例如 `$saveHandler = fopen('/local/file', 'w')
`。当设置该参数时,将以文件流的方式,直接将又拍云中的文件写入本地的文件流,或其他可以写入的流
- **array** `$params`
可选参数,读取目录内容时,需要设置三个参数: `X-List-Iter` 分页开始位置(第一页不需要设置),`X-List-Limit` 获取的文件数量(默认 100,最大
10000),`X-List-Order` 结果以时间正序或者倒序
**返回值:**
$return 当读取文件且没有设置 `$saveHandler` 参数时,返回一个字符串类型,表示文件内容;设置了 `$saveHandler` 参数时,返回布尔值
`true`。当读取目录时,返回一个数组,表示目录下的文件列表。目录下文件内容过多时,需要通过判断返回数组中的 `is_end` 属性,进行分页读取内容
---
### has
判断文件是否存在于又拍云存储
```php
Upyun::has( string $path )
```
注意: 对刚删除的文件, 立即调用该方法可能会返回 true, 因为服务端执行删除操作后可能会有很短暂的延迟.
**参数列表:**
- **string** `$path`
云存储的文件路径
**返回值:**
存在时返回 `true`,否则返回 `false`
---
### info
获取云存储文件/目录的基本信息
```php
Upyun::info( string $path, array $otherHeaders)
```
**参数列表:**
- **string** `$path`
云存储的文件路径
- **string** `$otherHeaders`
设置了后,方法将返回其他 http header 中的信息,默认为空
**返回值:**
返回一个数组,默认包含以下 key
- `x-upyun-file-type` 当 $path 是目录时,值为 *folder*,当 $path 是文件时,值为 *file*
- `x-upyun-file-size` 文件大小
- `x-upyun-file-date` 文件的创建时间
---
### getMimetype
获取云存储文件的文档类型
```php
Upyun::getMimetype( string $path )
```
**参数列表:**
- **string** `$path`
云存储的文件路径
**返回值:**
文档类型,e.g: `appcation/json`,获取失败返回空字符串
---
### delete
删除文件或者目录
```php
Upyun::delete( string $path, boolean $async = false )
```
**参数列表:**
- **string** `$path`
文件或目录在又拍云存储的路径
- **boolean** `$async`
是否异步删除,默认为 false,表示同步删除。当需要批量删除大量文件时,必须选择异步删除
**返回值:**
删除成功返回 true,否则 false
---
### createDir
创建目录
```php
Upyun::createDir( string $path )
```
**参数列表:**
- **string** `$path`
需要在又拍云存储创建的目录路径
**返回值:**
创建成功返回 true,否则返回 false
---
### deleteDir
删除文件或者目录
```php
Upyun::deleteDir( string $path )
```
**参数列表:**
- **string** `$path`
需要被删除的云存储文件或目录路径
**返回值:**
成功返回 true,否则 false
---
### usage
获取目录下存储使用量
```php
Upyun::usage( string $path = &#039;/&#039; )
```
**参数列表:**
- **string** `$path`
云存储目录路径,默认为根目录,表示整个云存储服务使用的空间大小
**返回值:**
存储使用量,单位字节
---
### purge
刷新缓存
```php
Upyun::purge( array|string $urls )
```
**参数列表:**
- **array&#124;string** `$urls`
需要刷新的文件 url 列表
**返回值:**
刷新失败的 url 列表,若全部刷新成功则为空数组
---
### process
异步云处理
```php
Upyun::process( array $tasks, string $type, string $source )
```
该方法是基于[又拍云云处理](http://docs.upyun.com/cloud/) 服务实现,可以实现音视频的转码、切片、剪辑;文件的压缩解压缩;文件拉取功能
注意:
- 所有需要调用该方法处理的资源,必须已经上传到云存储服务
- 使用 `process` 之前,必须配置 `config->processNotifyUrl`,否则会提交任务失败
例如视频转码:
```
process(array(
array(
'type' => 'video', // video 表示视频任务, audio 表示音频任务
'avopts' => '/s/240p(4:3)/as/1/r/30', // 处理参数,`s` 表示输出的分辨率,`r` 表示视频帧率,`as` 表示是否自动调整分辨率
'save_as' => '/video/240/new.mp4', // 新视频在又拍云存储的保存路径
),
... // 同时还可以添加其他任务
), Upyun::$PROCESS_TYPE_MEDIA, $source)
```
注意,被处理的资源需要已经上传到又拍云云存储
**参数列表:**
- **array** `$tasks`
需要处理的任务
- **string** `$type`
异步云处理任务类型,可选值:
- `Upyun::$PROCESS_TYPE_MEDIA` 异步音视频处理
- `Upyun::$PROCESS_TYPE_ZIP` 文件压缩
- `Upyun::$PROCESS_TYPE_UNZIP` 文件解压
- `Upyun::$PROCESS_TYPE_SYNC_FILE` 文件拉取
- `Upyun::$PROCESS_TYPE_STITCH` 图片拼接
- **string** `$source`
可选参数,处理异步音视频任务时,需要传递该参数,表示需要处理的文件路径
**返回值:**
任务 ID,提交了多少任务,便会返回多少任务 ID,与提交任务的顺序保持一致。可以通过任务 ID 查询处理进度。格式如下:
```
array(
'35f0148d414a688a275bf915ba7cebb2',
'98adbaa52b2f63d6d7f327a0ff223348',
)
```
---
### queryProcessStatus
音视频预处理任务进度查询
```php
Upyun::queryProcessStatus( array $taskIds )
```
根据 `process` 方法返回的任务 ID,通过该访问查询处理进度
**参数列表:**
- **array** `$taskIds`
任务 ID
**返回值:**
查询失败返回布尔值 `false`,否则返回每个任务的百分比进度信息,格式如下:
```
array(
'35f0148d414a688a275bf915ba7cebb2' => 100, // 100 表示任务完成
'c3103189fa906a5354d29bd807e8dc51' => 35,
'98adbaa52b2f63d6d7f327a0ff223348' => null, // null 表示任务未开始,或异常
)
```
---
### queryProcessResult
音视频预处理任务结果查询
```php
Upyun::queryProcessResult( array $taskIds )
```
根据 `process` 方法返回的任务 ID,通过该访问查询处理结果,会包含每个任务详细信息
**参数列表:**
- **array** `$taskIds`
任务 ID
**返回值:**
查询失败返回 `false`,否则返回每个任务的处理结果,格式如下:
```
array(
'9d9c32b63a1034834e77672c6f51f661' => array(
'path' => array('/v2.mp4'),
'signature' => '4042c1f07f546d28',
'status_code' => 200,
'service' => 'your_storage_service',
'description' => 'OK',
'task_id' => '9d9c32b63a1034834e77672c6f51f661',
'timestamp' => 1472010684
)
)
```
---
--------
> This document was automatically generated from source code comments on 2017-02-06 using [phpDocumentor](http://www.phpdoc.org/) and [cvuorinen/phpdoc-markdown-public](https://github.com/cvuorinen/phpdoc-markdown-public)
-13
View File
@@ -1,13 +0,0 @@
## 客户端上传
本示例展示了如何使用表单 API, 直接从客户端进行安全的文件上传, 这种方式不需要客户服务器进行中转, 节省了客户服务器流量, 并且支持 HTTP/HTTPS 两种协议
DEMO 使用 `sdkimg` 空间进行演示, 上传成功后, 访问路径为 `http://sdkimg.b0.upaiyun.com/` 拼接保存路径
#### 运行示例
- `cd examples/client-upload`
- `php -S localhost:9000`
打开浏览器访问 `http://localhost:9000`, 选则文件上传即可.
示例中使用 body 签名,避免 header 签名存在跨域失败的情况,因为 `Access-Control-Allow-Headers: *` 兼容性不好,是刚设定的协议[标准](https://github.com/whatwg/fetch)
-64
View File
@@ -1,64 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="normalize.css">
<script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js" type="text/javascript"></script>
<style>
form {
margin: 30px 0;
}
.submit {
display: inline-block;
width: 100px;
background: #02a3c6;
border: none;
color: #fff;
line-height: 40px;
text-align: center;
cursor: pointer;
}
</style>
</head>
<body>
<form action="http://v0.api.upyun.com/sdkimg" id="demoForm" method="POST" enctype="multipart/form-data">
<fieldset>
<legend>Client Upload Demo</legend>
<input name="file" type="file">
<input type="button" value="submit" class="submit" id="upload">
</fieldset>
</form>
<script>
// 文件保存的路径
var save_path = '/test/filename.txt';
$('#upload').on('click', function() {
// 获取 policy 和 secret
$.getJSON('http://localhost:9000/policy.php?save_path=' + save_path, function (data) {
var uploadData = new FormData($('#demoForm')[0]);
uploadData.append('policy', data.policy);
uploadData.append('authorization', data.authorization);
$.ajax({
url: 'http://v0.api.upyun.com/sdkimg',
type: 'POST',
data: uploadData,
cache: false,
processData: false,
contentType: false,
}).done(function(data, textStatus) {
alert('upload success');
}).fail(function(res, textStatus, error) {
try {
var body = JSON.parse(res.responseText);
alert('error: ' + body.message);
} catch(e) {
console.error(e);
}
});
});
});
</script>
</body>
</html>
-427
View File
@@ -1,427 +0,0 @@
/*! normalize.css v3.0.2 | MIT License | git.io/normalize */
/**
* 1. Set default font family to sans-serif.
* 2. Prevent iOS text size adjust after orientation change, without disabling
* user zoom.
*/
html {
font-family: sans-serif; /* 1 */
-ms-text-size-adjust: 100%; /* 2 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/**
* Remove default margin.
*/
body {
margin: 0;
}
/* HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined for any HTML5 element in IE 8/9.
* Correct `block` display not defined for `details` or `summary` in IE 10/11
* and Firefox.
* Correct `block` display not defined for `main` in IE 11.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
menu,
nav,
section,
summary {
display: block;
}
/**
* 1. Correct `inline-block` display not defined in IE 8/9.
* 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
*/
audio,
canvas,
progress,
video {
display: inline-block; /* 1 */
vertical-align: baseline; /* 2 */
}
/**
* Prevent modern browsers from displaying `audio` without controls.
* Remove excess height in iOS 5 devices.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/**
* Address `[hidden]` styling not present in IE 8/9/10.
* Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.
*/
[hidden],
template {
display: none;
}
/* Links
========================================================================== */
/**
* Remove the gray background color from active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* Improve readability when focused and also mouse hovered in all browsers.
*/
a:active,
a:hover {
outline: 0;
}
/* Text-level semantics
========================================================================== */
/**
* Address styling not present in IE 8/9/10/11, Safari, and Chrome.
*/
abbr[title] {
border-bottom: 1px dotted;
}
/**
* Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
*/
b,
strong {
font-weight: bold;
}
/**
* Address styling not present in Safari and Chrome.
*/
dfn {
font-style: italic;
}
/**
* Address variable `h1` font-size and margin within `section` and `article`
* contexts in Firefox 4+, Safari, and Chrome.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/**
* Address styling not present in IE 8/9.
*/
mark {
background: #ff0;
color: #000;
}
/**
* Address inconsistent and variable font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` affecting `line-height` in all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
/* Embedded content
========================================================================== */
/**
* Remove border when inside `a` element in IE 8/9/10.
*/
img {
border: 0;
}
/**
* Correct overflow not hidden in IE 9/10/11.
*/
svg:not(:root) {
overflow: hidden;
}
/* Grouping content
========================================================================== */
/**
* Address margin not present in IE 8/9 and Safari.
*/
figure {
margin: 1em 40px;
}
/**
* Address differences between Firefox and other browsers.
*/
hr {
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 0;
}
/**
* Contain overflow in all browsers.
*/
pre {
overflow: auto;
}
/**
* Address odd `em`-unit font size rendering in all browsers.
*/
code,
kbd,
pre,
samp {
font-family: monospace, monospace;
font-size: 1em;
}
/* Forms
========================================================================== */
/**
* Known limitation: by default, Chrome and Safari on OS X allow very limited
* styling of `select`, unless a `border` property is set.
*/
/**
* 1. Correct color not being inherited.
* Known issue: affects color of disabled elements.
* 2. Correct font properties not being inherited.
* 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
*/
button,
input,
optgroup,
select,
textarea {
color: inherit; /* 1 */
font: inherit; /* 2 */
margin: 0; /* 3 */
}
/**
* Address `overflow` set to `hidden` in IE 8/9/10/11.
*/
button {
overflow: visible;
}
/**
* Address inconsistent `text-transform` inheritance for `button` and `select`.
* All other form control elements do not inherit `text-transform` values.
* Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
* Correct `select` style inheritance in Firefox.
*/
button,
select {
text-transform: none;
}
/**
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
* and `video` controls.
* 2. Correct inability to style clickable `input` types in iOS.
* 3. Improve usability and consistency of cursor style between image-type
* `input` and others.
*/
button,
html input[type="button"], /* 1 */
input[type="reset"],
input[type="submit"] {
-webkit-appearance: button; /* 2 */
cursor: pointer; /* 3 */
}
/**
* Re-set default cursor for disabled elements.
*/
button[disabled],
html input[disabled] {
cursor: default;
}
/**
* Remove inner padding and border in Firefox 4+.
*/
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
/**
* Address Firefox 4+ setting `line-height` on `input` using `!important` in
* the UA stylesheet.
*/
input {
line-height: normal;
}
/**
* It's recommended that you don't attempt to style these elements.
* Firefox's implementation doesn't respect box-sizing, padding, or width.
*
* 1. Address box sizing set to `content-box` in IE 8/9/10.
* 2. Remove excess padding in IE 8/9/10.
*/
input[type="checkbox"],
input[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/**
* Fix the cursor style for Chrome's increment/decrement buttons. For certain
* `font-size` values of the `input`, it causes the cursor style of the
* decrement button to change from `default` to `text`.
*/
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Address `appearance` set to `searchfield` in Safari and Chrome.
* 2. Address `box-sizing` set to `border-box` in Safari and Chrome
* (include `-moz` to future-proof).
*/
input[type="search"] {
-webkit-appearance: textfield; /* 1 */
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box; /* 2 */
box-sizing: content-box;
}
/**
* Remove inner padding and search cancel button in Safari and Chrome on OS X.
* Safari (but not Chrome) clips the cancel button when the search input has
* padding (and `textfield` appearance).
*/
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* Define consistent border, margin, and padding.
*/
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
/**
* 1. Correct `color` not being inherited in IE 8/9/10/11.
* 2. Remove padding so people aren't caught out if they zero out fieldsets.
*/
legend {
border: 0; /* 1 */
padding: 0; /* 2 */
}
/**
* Remove default vertical scrollbar in IE 8/9/10/11.
*/
textarea {
overflow: auto;
}
/**
* Don't inherit the `font-weight` (applied by a rule above).
* NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
*/
optgroup {
font-weight: bold;
}
/* Tables
========================================================================== */
/**
* Remove most spacing between table cells.
*/
table {
border-collapse: collapse;
border-spacing: 0;
}
td,
th {
padding: 0;
}
-21
View File
@@ -1,21 +0,0 @@
<?php
require __DIR__ . '/../../tests/bootstrap.php';
use Upyun\Config;
use Upyun\Signature;
use Upyun\Util;
$config = new Config(BUCKET, USER_NAME, PWD);
$config->setFormApiKey('Mv83tlocuzkmfKKUFbz2s04FzTw=');
$data['save-key'] = $_GET['save_path'];
$data['expiration'] = time() + 120;
$data['bucket'] = BUCKET;
$policy = Util::base64Json($data);
$method = 'POST';
$uri = '/' . $data['bucket'];
$signature = Signature::getBodySignature($config, $method, $uri, null, $policy);
echo json_encode(array(
'policy' => $policy,
'authorization' => $signature
));
-35
View File
@@ -1,35 +0,0 @@
<?php
require __DIR__ . '/../tests/bootstrap.php';
use Upyun\Config;
use Upyun\Upyun;
$config = new Config(BUCKET, USER_NAME, PWD);
$upyun = new Upyun($config);
$start = null;
$total = 0;
do {
$list = $upyun->read('/', null, array(
'X-List-Limit' => 100,
'X-List-Iter' => $start,
));
if (is_array($list['files'])) {
foreach ($list['files'] as $file) {
$total++;
if ($file['type'] === 'N') {
echo '文件名: ';
} else {
echo '目录名: ';
}
echo $file['name'];
echo ' 大小:' . $file['size'];
echo ' 修改时间:' . date('Y-m-d H:i:s', $file['time']);
echo "\n";
}
}
$start = $list['iter'];
} while (!$list['is_end']);
echo '总共存有文件 ' . $total . ' 个';
-25
View File
@@ -1,25 +0,0 @@
<phpunit backupGlobals="true"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php">
<testsuites>
<testsuite name="upyun test cases">
<file>./tests/SignatureTest.php</file>
<file>./tests/UpyunTest.php</file>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="coverage.clover"/>
</logging>
</phpunit>
+24
View File
@@ -105,4 +105,28 @@ class Rest
}
return $this;
}
public function toRequest()
{
$url = $this->endpoint . $this->storagePath;
$body = null;
if ($this->file && $this->method === 'PUT') {
$body = $this->file;
}
$request = new Psr7\Request(
$this->method,
Util::encodeURI($url),
$this->headers,
$body
);
$authHeader = Signature::getHeaderSign($this->config,
$this->method,
$request->getUri()->getPath()
);
foreach ($authHeader as $head => $value) {
$request = $request->withHeader($head, $value);
}
return $request;
}
}
+16 -1
View File
@@ -32,7 +32,7 @@ class Config
public $useSsl;
/**
* @var string 上传使用的接口类型,可以设置为 `REST`:使用 rest api 上传,`AUTO` 根据文件大小自动判断,`BLOCK` 使用断点续传
* @var string 上传使用的接口类型,可以设置为 `REST`:使用 rest api 上传,`AUTO` 根据文件大小自动判断,`BLOCK` 使用串行式断点续传,`BLOCK_PARALLEL` 使用并行式断点续传
* 当上传小文件时,不推荐使用断点续传;上传时如果设置了异步预处理`withAsyncProcess=true`,将会使用表单 api 上传
*/
public $uploadType = 'AUTO';
@@ -42,6 +42,11 @@ class Config
*/
public $sizeBoundary = 31457280;
/**
* @var int 并行式断点续传的并发数
*/
public $concurrency = 5;
/**
* @var int request timeout seconds
*/
@@ -144,4 +149,14 @@ class Config
{
return $this->useSsl ? 'https://' : 'http://';
}
public function setUploadType($uploadType)
{
$this->uploadType = $uploadType;
}
public function setConcurrency($concurrency)
{
$this->concurrency = $concurrency;
}
}
+84 -2
View File
@@ -4,6 +4,8 @@ namespace Upyun;
use Upyun\Api\Rest;
use Upyun\Api\Form;
use GuzzleHttp\Psr7;
use GuzzleHttp\Pool;
use GuzzleHttp\Client;
class Uploader
{
@@ -37,13 +39,15 @@ class Uploader
->withHeaders($params)
->withFile($stream)
->send();
} elseif ($this->config->uploadType === 'BLOCK_PARALLEL') {
return $this->concurrentPointUpload($path, $stream, $params);
} else {
return $this->pointUpload($path, $stream, $params);
}
}
/**
* 断点续传
* 串行式断点续传
* @param $path
* @param $stream
* @param $params
@@ -108,7 +112,8 @@ class Uploader
private function needUseBlock($fileSize)
{
if ($this->config->uploadType === 'BLOCK') {
if ($this->config->uploadType === 'BLOCK' ||
$this->config->uploadType === 'BLOCK_PARALLEL') {
return true;
} elseif ($this->config->uploadType === 'AUTO' &&
$fileSize >= $this->config->sizeBoundary) {
@@ -117,4 +122,81 @@ class Uploader
return false;
}
}
/**
* 并行式断点续传
* @param $path
* @param $stream
* @param $params
*
* @return mixed|\Psr\Http\Message\ResponseInterface
* @throws \Exception
*/
private function concurrentPointUpload($path, $stream, $params)
{
$req = new Rest($this->config);
$headers = array();
if (is_array($params)) {
foreach ($params as $key => $val) {
$headers['X-Upyun-Meta-' . $key] = $val;
}
}
$res = $req->request('PUT', $path)
->withHeaders(array_merge(array(
'X-Upyun-Multi-Disorder' => 'true',
'X-Upyun-Multi-Stage' => 'initiate',
'X-Upyun-Multi-Type' => Psr7\mimetype_from_filename($path),
'X-Upyun-Multi-Length' => $stream->getSize(),
), $headers))
->send();
if ($res->getStatusCode() !== 204) {
throw new \Exception('init request failed when poinit upload!');
}
$init = Util::getHeaderParams($res->getHeaders());
$uuid = $init['x-upyun-multi-uuid'];
$requests = function ($req, $path, $stream, $uuid) {
$blockSize = 1024 * 1024;
$total = ceil($stream->getSize() / $blockSize);
for ($i = 0; $i < $total; $i++) {
$fileBlock = $stream->read($blockSize);
yield $req->request('PUT', $path)
->withHeaders(array(
'X-Upyun-Multi-Stage' => 'upload',
'X-Upyun-Multi-Uuid' => $uuid,
'X-Upyun-Part-Id' => $i
))
->withFile(Psr7\stream_for($fileBlock))
->toRequest();
}
};
$client = new Client([
'timeout' => $this->config->timeout,
]);
$pool = new Pool($client, $requests($req, $path, $stream, $uuid), [
'concurrency' => $this->config->concurrency,
'fulfilled' => function ($res) {
if ($res->getStatusCode() !== 204) {
throw new \Exception('upload request failed when poinit upload!');
}
},
'rejected' => function () {
throw new \Exception('upload request failed when poinit upload!');
},
]);
$promise = $pool->promise();
$promise->wait();
$res = $req->request('PUT', $path)
->withHeaders(array(
'X-Upyun-Multi-Uuid' => $uuid,
'X-Upyun-Multi-Stage' => 'complete'
))
->send();
if ($res->getStatusCode() != 204 && $res->getStatusCode() != 201) {
throw new \Exception('end request failed when poinit upload!');
}
return $res;
}
}
+3 -3
View File
@@ -377,7 +377,7 @@ class Upyun
case self::$PROCESS_TYPE_SYNC_FILE:
$options['app_name'] = 'spiderman';
break;
case self::$PROCESS_TYPE_SYNC_FILE:
case self::$PROCESS_TYPE_CONVERT:
$options['app_name'] = 'uconvert';
break;
case self::$PROCESS_TYPE_STITCH:
@@ -460,7 +460,7 @@ class Upyun
* @param string $file 需要剪辑的又拍云云存储中的 m3u8 文件路径
* @param string $saveAs 剪辑完成后新的 m3u8 文件保存路径
* @param array $slice 需要被保留或删除的片段。
* @param bool $$isInclude 默认为 `true` 表示 `$slice` 参数描述的片段被保留,否则表示 `$slice` 参数描述的片段被删除
* @param bool $isInclude 默认为 `true` 表示 `$slice` 参数描述的片段被保留,否则表示 `$slice` 参数描述的片段被删除
* @param bool $index 指定 `$slice` 参数的格式,默认为 `false` 表示使用时间范围描述片段,单位秒:`[<开始时间>, <结束时间>]``true` 表示使用 `m3u8` 文件的分片序号,从 0 开始,这种方式可以一次对多个片段操作
*
* @return array 见 [m3u8 剪辑 - 响应](http://docs.upyun.com/cloud/sync_video/#_6)
@@ -473,7 +473,7 @@ class Upyun
'save_as' => $saveAs,
'index' => $index,
];
if ($$isInclude) {
if ($isInclude) {
$params['include'] = $slice;
} else {
$params['exclude'] = $slice;
-25
View File
@@ -1,25 +0,0 @@
<?php
namespace Upyun\Tests;
use Upyun\Signature;
use Upyun\Config;
class SignatureTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Config;
*/
public $config;
public function setUp()
{
$this->config = new Config('bucket', 'operator', 'password');
}
public function testGetBodySignature()
{
$sign = Signature::getBodySignature($this->config, 'POST', '/bucket');
$this->assertEquals($sign, 'UPYUN operator:Xx3G6+DAvUyCL2Y2npSW/giTFI8=');
}
}
-272
View File
@@ -1,272 +0,0 @@
<?php
namespace Upyun\Tests;
use Upyun\Config;
use Upyun\Upyun;
class UpyunTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Upyun
*/
public static $upyun;
protected static $taskId;
protected static $tempFilePath;
public static function setUpBeforeClass()
{
$config = new Config(BUCKET, USER_NAME, PWD);
$config->setFormApiKey('Mv83tlocuzkmfKKUFbz2s04FzTw=');
$config->processNotifyUrl = 'http://localhost:9999';
self::$upyun = new Upyun($config);
self::$tempFilePath = __DIR__ . '/assets/test.txt';
touch(self::$tempFilePath);
}
public static function tearDownAfterClass()
{
unlink(self::$tempFilePath);
}
public function testWriteString()
{
$filename = '/中文/测试 +.txt';
$content = 'test file content';
self::$upyun->write($filename, $content);
$size = getUpyunFileSize($filename);
$this->assertEquals($size, strlen($content));
}
public function testWriteStream()
{
$filename = 'test.jpeg';
$f = fopen(__DIR__ . '/assets/sample.jpeg', 'rb');
if (!$f) {
throw new \Exception('open test file failed!');
}
self::$upyun->write($filename, $f);
$size = getUpyunFileSize($filename);
$this->assertEquals($size, PIC_SIZE);
}
public function testWriteWithAsyncProcess()
{
$filename = 'test_async.jpeg';
$newFilename = 'test_async.png';
$f = fopen(__DIR__ . '/assets/sample.jpeg', 'rb');
if (!$f) {
throw new \Exception('open test file failed!');
}
$result = self::$upyun->write($filename, $f, array(
'apps' => array(
array(
'name' => 'thumb',
'x-gmkerl-thumb' => '/format/png/fw/50',
'save_as' => $newFilename,
)
)
), true);
$size = getUpyunFileSize($filename);
$this->assertEquals($size, PIC_SIZE);
$this->assertEquals($result, true);
}
public function testWriteWithException()
{
$fs = new Upyun(new Config(BUCKET, USER_NAME, 'error-password'));
try {
$fs->write('test.txt', 'test file content');
} catch (\Exception $e) {
return ;
}
throw new \Exception('should get sign error.');
}
/**
* @depends testWriteString
*/
public function testReadFile()
{
$name = 'test-read.txt';
$str = 'test file content 2';
self::$upyun->write($name, $str);
//读取内容写入字符串
$content = self::$upyun->read($name);
$this->assertEquals($content, $str);
//读取内容写入文件流
$this->assertTrue(self::$upyun->read($name, fopen(self::$tempFilePath, 'wb')));
$this->assertEquals($str, file_get_contents(self::$tempFilePath));
}
/**
* @depends testWriteString
* @depends testReadFile
*/
public function testDeleteFile()
{
self::$upyun->write('test-delete.txt', 'test file content 3');
self::$upyun->delete('test-delete.txt');
try {
self::$upyun->read('test-delete.txt');
} catch (\Exception $e) {
return ;
}
throw new \Exception('delete file failed');
}
/**
* @expectedException \Exception
*/
public function testDeleteNotExistsFile()
{
self::$upyun->delete('not-exists-test.txt');
}
/**
*/
public function testHas()
{
$name = 'test-has.txt';
self::$upyun->write($name, 'test file content 4');
$this->assertEquals(self::$upyun->has($name), true);
self::$upyun->delete($name);
sleep(5);
$this->assertEquals(self::$upyun->has($name), false);
}
/**
* @depends testWriteString
* @depends testDeleteFile
*/
public function testInfo()
{
self::$upyun->write('test-info.txt', 'test file content 4');
$info = self::$upyun->info('test-info.txt');
$this->assertEquals($info['x-upyun-file-type'], 'file');
$this->assertEquals($info['x-upyun-file-size'], 19);
}
/**
* @depends testInfo
*/
public function testGetMimetype()
{
$type = self::$upyun->getMimetype('test-info.txt');
$this->assertEquals($type, 'text/plain');
}
/**
*/
public function testCreateDir()
{
self::$upyun->createDir('/test-dir');
$this->assertEquals(self::$upyun->has('/test-dir'), true);
self::$upyun->createDir('/test-dir2/');
$this->assertEquals(self::$upyun->has('/test-dir2'), true);
}
public function testReadDir()
{
$list = self::$upyun->read('/test-dir2/');
$this->assertEquals($list['is_end'], true);
self::$upyun->write('/test-dir2/test.txt', 'test file content 5');
$list = self::$upyun->read('/test-dir2/');
$this->assertEquals($list['is_end'], true);
$this->assertEquals(count($list['files']), 1);
$file = $list['files'][0];
$this->assertEquals($file['name'], 'test.txt');
$this->assertEquals($file['type'], 'N');
$this->assertEquals($file['size'], 19);
}
/**
* @depends testCreateDir
*/
public function testDeleteDir()
{
$result = self::$upyun->createDir('/test-delete-dir');
$this->assertEquals($result, true);
sleep(5);
$result = self::$upyun->deleteDir('/test-delete-dir');
$this->assertEquals($result, true);
}
public function testUsage()
{
$size = self::$upyun->usage();
$this->assertTrue($size > 0);
}
public function testPurge()
{
$urls = self::$upyun->purge(getFileUrl('test.txt'));
$this->assertTrue(empty($urls));
$invalidUrl = 'http://xxxx.b0.xxxxxxxx-upyun.com/test.txt';
$urls = self::$upyun->purge($invalidUrl);
$this->assertTrue(count($urls) === 1);
$this->assertTrue($urls[0] === $invalidUrl);
}
public function testProcess()
{
$source = 'php-sdk-sample.mp4';
self::$upyun->write($source, fopen(__DIR__ . '/assets/SampleVideo_640x360_1mb.mp4', 'r'));
$result = self::$upyun->process(array(
array('type' => 'video', 'avopts' => '/s/240p(4:3)/as/1/r/30', 'return_info' => true, 'save_as' => '/video/result.mp4')
), Upyun::$PROCESS_TYPE_MEDIA, $source);
$this->assertTrue(strlen($result[0]) === 32);
self::$taskId = $result[0];
// test zip
$result2 = self::$upyun->process(array(array(
'sources' => ['./php-sdk-sample.mp4'],
'save_as' => '/php-sdk-sample-mp4.zip'
)), Upyun::$PROCESS_TYPE_ZIP);
$this->assertTrue(strlen($result2[0]) === 32);
}
/**
* @depends testProcess
*/
public function testQueryProcessStatus()
{
sleep(5);
$status = self::$upyun->queryProcessStatus(array(self::$taskId));
$this->assertTrue(array_key_exists(self::$taskId, $status));
}
/**
* @depends testProcess
*/
public function testQueryProcessResult()
{
sleep(5);
$result = self::$upyun->queryProcessResult(array(self::$taskId));
$this->assertTrue($result[self::$taskId]['path'][0] === '/video/result.mp4');
$this->assertTrue($result[self::$taskId]['status_code'] === 200);
}
public function testAvMeta()
{
$source = 'php-sdk-sample.mp4';
self::$upyun->write($source, fopen(__DIR__ . '/assets/SampleVideo_640x360_1mb.mp4', 'r'));
$result = self::$upyun->avMeta('/php-sdk-sample.mp4');
$this->assertTrue(count($result) === 2);
$this->assertTrue($result['streams'][0]['type'] === 'video');
}
public function testSnapshot()
{
$source = 'php-sdk-sample.mp4';
self::$upyun->write($source, fopen(__DIR__ . '/assets/SampleVideo_640x360_1mb.mp4', 'r'));
$result = self::$upyun->snapshot('/php-sdk-sample.mp4', '/snapshot.jpg', '00:00:01', '720x480', 'jpg');
$this->assertTrue($result['status_code'] === 200);
}
}
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

-31
View File
@@ -1,31 +0,0 @@
<?php
require dirname(__DIR__) . '/vendor/autoload.php';
define('USER_NAME', 'tester');
define('PWD', 'grjxv2mxELR3');
define('BUCKET', 'sdkimg');
define('PIC_PATH', dirname(__FILE__) . '/assets/sample.jpeg');
define('PIC_SIZE', filesize(PIC_PATH));
function getFileUrl($path)
{
return "http://" . BUCKET . ".b0.upaiyun.com/" . ltrim($path, '/');
}
function getUpyunFileSize($path)
{
$url = getFileUrl($path);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$return = curl_exec($ch);
preg_match('~^HTTP/1.1 (\d{3})~', $return, $match1);
preg_match('~Content-Length: (\d+)~', $return, $match2);
if (isset($match1[1]) && $match1[1] == 200) {
return isset($match2[1]) ? intval($match2[1]) : false;
} else {
return false;
}
}