update curl;

require https://github.com/ledccn/IYUUBittorrentClient
This commit is contained in:
david
2021-01-12 14:14:14 +08:00
parent 87d9f81bad
commit e66d632ba3
12 changed files with 227 additions and 1341 deletions

View File

@ -6,5 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'IYUU\\Client\\' => array($vendorDir . '/ledccn/iyuubittorrentclient/src'),
'IYUU\\' => array($baseDir . '/app'),
);

View File

@ -13,11 +13,16 @@ class ComposerStaticInitd8553673db02b2a444a853f28e16196e
public static $prefixLengthsPsr4 = array (
'I' =>
array (
'IYUU\\Client\\' => 12,
'IYUU\\' => 5,
),
);
public static $prefixDirsPsr4 = array (
'IYUU\\Client\\' =>
array (
0 => __DIR__ . '/..' . '/ledccn/iyuubittorrentclient/src',
),
'IYUU\\' =>
array (
0 => __DIR__ . '/../..' . '/app',

View File

@ -1,17 +1,17 @@
[
{
"name": "curl/curl",
"version": "2.2.0",
"version_normalized": "2.2.0.0",
"version": "2.3.0",
"version_normalized": "2.3.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-mod/curl.git",
"reference": "d22086dd2eee5ca02e4c29b9a5bdf3645bfdbbff"
"reference": "3ad560b1fc1bbdf5c7681356ab953fb961f255e5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-mod/curl/zipball/d22086dd2eee5ca02e4c29b9a5bdf3645bfdbbff",
"reference": "d22086dd2eee5ca02e4c29b9a5bdf3645bfdbbff",
"url": "https://api.github.com/repos/php-mod/curl/zipball/3ad560b1fc1bbdf5c7681356ab953fb961f255e5",
"reference": "3ad560b1fc1bbdf5c7681356ab953fb961f255e5",
"shasum": "",
"mirrors": [
{
@ -28,7 +28,7 @@
"phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "~2.1"
},
"time": "2018-12-04T19:47:03+00:00",
"time": "2020-03-19T20:07:26+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -41,15 +41,15 @@
"MIT"
],
"authors": [
{
"name": "php-curl-class",
"homepage": "https://github.com/php-curl-class"
},
{
"name": "Hassan Amouhzi",
"email": "hassan@anezi.net",
"homepage": "http://hassan.amouhzi.com"
},
{
"name": "php-curl-class",
"homepage": "https://github.com/php-curl-class"
},
{
"name": "user52",
"homepage": "https://github.com/user52"
@ -63,18 +63,18 @@
]
},
{
"name": "owner888/phpspider",
"version": "v2.1.6",
"version_normalized": "2.1.6.0",
"name": "ledccn/iyuubittorrentclient",
"version": "dev-master",
"version_normalized": "9999999-dev",
"source": {
"type": "git",
"url": "https://github.com/owner888/phpspider.git",
"reference": "e6021148adec201418c16ba26f39bc013ba5b4d9"
"url": "https://github.com/ledccn/IYUUBittorrentClient.git",
"reference": "cb59d3380efd8cab7d277eefbc7e2590845bf805"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/owner888/phpspider/zipball/e6021148adec201418c16ba26f39bc013ba5b4d9",
"reference": "e6021148adec201418c16ba26f39bc013ba5b4d9",
"url": "https://api.github.com/repos/ledccn/IYUUBittorrentClient/zipball/cb59d3380efd8cab7d277eefbc7e2590845bf805",
"reference": "cb59d3380efd8cab7d277eefbc7e2590845bf805",
"shasum": "",
"mirrors": [
{
@ -84,36 +84,35 @@
]
},
"require": {
"php": ">=5.5.0"
"curl/curl": "^2.3",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"php": "^5.6 | ^7.0"
},
"suggest": {
"ext-pcntl、ext-redis": "For better performance. "
},
"time": "2018-08-15T08:04:29+00:00",
"time": "2021-01-12T06:07:08+00:00",
"type": "library",
"installation-source": "dist",
"installation-source": "source",
"autoload": {
"psr-4": {
"phpspider\\": "./"
"IYUU\\Client\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
"GPL-3.0-or-later"
],
"authors": [
{
"name": "Seatle Yang",
"email": "seatle@foxmail.com",
"homepage": "http://www.phpspider.org",
"role": "Developer"
"name": "David",
"email": "367013672@qq.com"
}
],
"description": "The PHPSpider Framework.",
"homepage": "http://www.phpspider.org",
"description": "实现pt客户端管理的代码库",
"homepage": "https://github.com/ledccn/IYUUBittorrentClient",
"keywords": [
"framework",
"phpspider"
"qbittorrent",
"transmission"
]
}
]

View File

@ -27,7 +27,6 @@ tests-php5.6:
- php --version
- if [ ! -f composer.phar ]; then DOWLOAD_COMPOSER=1 ; fi;
- if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" ; fi;
- if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" ; fi;
- if [ -n "$DOWLOAD_COMPOSER" ] ; then php composer-setup.php ; fi;
- if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "unlink('composer-setup.php');" ; fi;
- php composer.phar install
@ -36,7 +35,6 @@ tests-php5.6:
cache:
key: php5.6
paths:
- composer.phar
- vendor
tests-php7.0:
@ -51,7 +49,6 @@ tests-php7.0:
- php --version
- if [ ! -f composer.phar ]; then DOWLOAD_COMPOSER=1 ; fi;
- if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" ; fi;
- if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" ; fi;
- if [ -n "$DOWLOAD_COMPOSER" ] ; then php composer-setup.php ; fi;
- if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "unlink('composer-setup.php');" ; fi;
- php composer.phar install
@ -75,7 +72,6 @@ tests-php7.1:
- php --version
- if [ ! -f composer.phar ]; then DOWLOAD_COMPOSER=1 ; fi;
- if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" ; fi;
- if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" ; fi;
- if [ -n "$DOWLOAD_COMPOSER" ] ; then php composer-setup.php ; fi;
- if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "unlink('composer-setup.php');" ; fi;
- php composer.phar install
@ -89,25 +85,37 @@ tests-php7.1:
- vendor
tests-php7.2:
image: alpine:3.8
image: alpine:3.9
stage: test
services:
- name: "$CI_REGISTRY_IMAGE:server-test"
alias: server_test
script:
- apk add --no-cache php7-cli php7-curl php7-gd php7-phar php7-json php7-openssl php7-dom php7-simplexml php7-tokenizer php7-mbstring php7-xml
- apk add --no-cache composer php7-cli php7-curl php7-gd php7-phar php7-json php7-openssl php7-dom php7-simplexml php7-tokenizer php7-mbstring php7-xml
- php --version
- if [ ! -f composer.phar ]; then DOWLOAD_COMPOSER=1 ; fi;
- if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" ; fi;
- if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" ; fi;
- if [ -n "$DOWLOAD_COMPOSER" ] ; then php composer-setup.php ; fi;
- if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "unlink('composer-setup.php');" ; fi;
- php composer.phar install
- composer install
- vendor/bin/phpcs --warning-severity=0 --standard=PSR2 src
- nohup php -S localhost:8000 -t tests/server/php-curl-test > phpd.log 2>&1 &
- vendor/bin/phpunit
cache:
key: php7.2
paths:
- composer.phar
- vendor
tests-php7.3:
image: alpine:3.11
stage: test
services:
- name: "$CI_REGISTRY_IMAGE:server-test"
alias: server_test
script:
- apk add --no-cache composer php7-cli php7-curl php7-gd php7-phar php7-json php7-openssl php7-dom php7-simplexml php7-tokenizer php7-mbstring php7-xml
- php --version
- composer install
- vendor/bin/phpcs --warning-severity=0 --standard=PSR2 src
- nohup php -S localhost:8000 -t tests/server/php-curl-test > phpd.log 2>&1 &
- vendor/bin/phpunit
cache:
key: php7.3
paths:
- vendor

View File

@ -78,12 +78,12 @@ class Curl
public $curl;
/**
* @var bool Whether an error occured or not
* @var bool Whether an error occurred or not
*/
public $error = false;
/**
* @var int Contains the error code of the curren request, 0 means no error happend
* @var int Contains the error code of the current request, 0 means no error happened
*/
public $error_code = 0;
@ -93,12 +93,12 @@ class Curl
public $error_message = null;
/**
* @var bool Whether an error occured or not
* @var bool Whether an error occurred or not
*/
public $curl_error = false;
/**
* @var int Contains the error code of the curren request, 0 means no error happend.
* @var int Contains the error code of the current request, 0 means no error happened.
* @see https://curl.haxx.se/libcurl/c/libcurl-errors.html
*/
public $curl_error_code = 0;
@ -109,7 +109,7 @@ class Curl
public $curl_error_message = null;
/**
* @var bool Whether an error occured or not
* @var bool Whether an error occurred or not
*/
public $http_error = false;
@ -124,17 +124,17 @@ class Curl
public $http_error_message = null;
/**
* @var string|array TBD (ensure type) Contains the request header informations
* @var string|array TBD (ensure type) Contains the request header information
*/
public $request_headers = null;
/**
* @var string|array TBD (ensure type) Contains the response header informations
* @var string|array TBD (ensure type) Contains the response header information
*/
public $response_headers = array();
/**
* @var string Contains the response from the curl request
* @var string|false|null Contains the response from the curl request
*/
public $response = null;
@ -146,12 +146,12 @@ class Curl
/**
* Constructor ensures the available curl extension is loaded.
*
* @throws \ErrorException
* @throws \RuntimeException
*/
public function __construct()
{
if (!extension_loaded('curl')) {
throw new \ErrorException('The cURL extensions is not loaded, make sure you have installed the cURL extension: https://php.net/manual/curl.setup.php');
throw new \RuntimeException('The cURL extensions is not loaded, make sure you have installed the cURL extension: https://php.net/manual/curl.setup.php');
}
$this->init();
@ -162,7 +162,7 @@ class Curl
/**
* Initializer for the curl resource.
*
* Is called by the __construct() of the class or when the curl request is reseted.
* Is called by the __construct() of the class or when the curl request is reset.
* @return self
*/
private function init()
@ -202,7 +202,7 @@ class Curl
// protected methods
/**
* Execute the curl request based on the respectiv settings.
* Execute the curl request based on the respective settings.
*
* @return int Returns the error code for the current curl request
*/
@ -212,14 +212,14 @@ class Curl
$this->response = curl_exec($this->curl);
$this->curl_error_code = curl_errno($this->curl);
$this->curl_error_message = curl_error($this->curl);
$this->curl_error = !($this->curl_error_code === 0);
$this->http_status_code = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
$this->http_error = in_array(floor($this->http_status_code / 100), array(4, 5));
$this->curl_error = !($this->getErrorCode() === 0);
$this->http_status_code = intval(curl_getinfo($this->curl, CURLINFO_HTTP_CODE));
$this->http_error = $this->isError();
$this->error = $this->curl_error || $this->http_error;
$this->error_code = $this->error ? ($this->curl_error ? $this->curl_error_code : $this->http_status_code) : 0;
$this->error_code = $this->error ? ($this->curl_error ? $this->getErrorCode() : $this->getHttpStatus()) : 0;
$this->request_headers = preg_split('/\r\n/', curl_getinfo($this->curl, CURLINFO_HEADER_OUT), null, PREG_SPLIT_NO_EMPTY);
$this->http_error_message = $this->error ? (isset($this->response_headers['0']) ? $this->response_headers['0'] : '') : '';
$this->error_message = $this->curl_error ? $this->curl_error_message : $this->http_error_message;
$this->error_message = $this->curl_error ? $this->getErrorMessage() : $this->http_error_message;
return $this->error_code;
}
@ -250,6 +250,18 @@ class Curl
$this->setOpt(CURLOPT_POSTFIELDS, $data);
}
/**
* Set the json payload informations to the postfield curl option.
*
* @param array $data The data to be sent.
* @return void
*/
protected function prepareJsonPayload(array $data)
{
$this->setOpt(CURLOPT_POST, true);
$this->setOpt(CURLOPT_POSTFIELDS, json_encode($data));
}
/**
* Set auth options for the current request.
*
@ -307,12 +319,17 @@ class Curl
*
* @param string $url The url to make the post request
* @param array $data Post data to pass to the url
* @param boolean $asJson Whether the data should be passed as json or not. {@insce 2.2.1}
* @return self
*/
public function post($url, $data = array())
public function post($url, $data = array(), $asJson = false)
{
$this->setOpt(CURLOPT_URL, $url);
$this->preparePayload($data);
if ($asJson) {
$this->prepareJsonPayload($data);
} else {
$this->preparePayload($data);
}
$this->exec();
return $this;
}
@ -320,7 +337,7 @@ class Curl
/**
* Make a put request with optional data.
*
* The put request data can be either sent via payload or as get paramters of the string.
* The put request data can be either sent via payload or as get parameters of the string.
*
* @param string $url The url to make the put request
* @param array $data Optional data to pass to the $url
@ -346,7 +363,7 @@ class Curl
/**
* Make a patch request with optional data.
*
* The patch request data can be either sent via payload or as get paramters of the string.
* The patch request data can be either sent via payload or as get parameters of the string.
*
* @param string $url The url to make the patch request
* @param array $data Optional data to pass to the $url
@ -398,7 +415,7 @@ class Curl
/**
* Pass basic auth data.
*
* If the the rquested url is secured by an httaccess basic auth mechanism you can use this method to provided the auth data.
* If the the requested url is secured by an htaccess basic auth mechanism you can use this method to provided the auth data.
*
* ```php
* $curl = new Curl();
@ -406,8 +423,8 @@ class Curl
* $curl->get('http://example.com/secure.php');
* ```
*
* @param string $username The username for the authentification
* @param string $password The password for the given username for the authentification
* @param string $username The username for the authentication
* @param string $password The password for the given username for the authentication
* @return self
*/
public function setBasicAuthentication($username, $password)
@ -418,7 +435,7 @@ class Curl
}
/**
* Provide optional header informations.
* Provide optional header information.
*
* In order to pass optional headers by key value pairing:
*
@ -442,7 +459,7 @@ class Curl
/**
* Provide a User Agent.
*
* In order to provide you cusomtized user agent name you can use this method.
* In order to provide you customized user agent name you can use this method.
*
* ```php
* $curl = new Curl();
@ -461,6 +478,9 @@ class Curl
/**
* @deprecated Call setReferer() instead
*
* @param $referrer
* @return self
*/
public function setReferrer($referrer)
{
@ -471,7 +491,7 @@ class Curl
/**
* Set the HTTP referer header.
*
* The $referer informations can help identify the requested client where the requested was made.
* The $referer Information can help identify the requested client where the requested was made.
*
* @param string $referer An url to pass and will be set as referer header
* @return self
@ -503,24 +523,26 @@ class Curl
*
* @see http://php.net/curl_setopt
*
* @param int $option The curl option constante e.g. `CURLOPT_AUTOREFERER`, `CURLOPT_COOKIESESSION`
* @param mixed $value The value to pass for the given $option
* @param int $option The curl option constant e.g. `CURLOPT_AUTOREFERER`, `CURLOPT_COOKIESESSION`
* @param mixed $value The value to pass for the given $option
* @return bool
*/
public function setOpt($option, $value)
{
return curl_setopt($this->curl, $option, $value);
}
/**
* Get customized curl options.
*
* To see a full list of options: http://php.net/curl_getinfo
*
* @see http://php.net/curl_getinfo
*
* @param int $option The curl option constante e.g. `CURLOPT_AUTOREFERER`, `CURLOPT_COOKIESESSION`
* @param mixed $value The value to check for the given $option
*/
* Get customized curl options.
*
* To see a full list of options: http://php.net/curl_getinfo
*
* @see http://php.net/curl_getinfo
*
* @param int $option The curl option constant e.g. `CURLOPT_AUTOREFERER`, `CURLOPT_COOKIESESSION`
* @param mixed The value to check for the given $option
* @return mixed
*/
public function getOpt($option)
{
return curl_getinfo($this->curl, $option);
@ -539,17 +561,26 @@ class Curl
}
/**
* Enable verbositiy.
* Enable verbosity.
*
* @todo As to keep naming convention it should be renamed to `setVerbose()`
* @param bool $on
* @return self
*/
public function setVerbose($on = true)
{
$this->setOpt(CURLOPT_VERBOSE, $on);
return $this;
}
/**
* @deprecated Call setVerbose() instead
*
* @param string $on
* @param bool $on
* @return self
*/
public function verbose($on = true)
{
$this->setOpt(CURLOPT_VERBOSE, $on);
return $this;
return $this->setVerbose($on);
}
/**
@ -574,7 +605,7 @@ class Curl
$this->http_error_message = null;
$this->request_headers = null;
$this->response_headers = array();
$this->response = null;
$this->response = false;
$this->init();
return $this;
}
@ -605,7 +636,7 @@ class Curl
*/
public function isInfo()
{
return $this->http_status_code >= 100 && $this->http_status_code < 200;
return $this->getHttpStatus() >= 100 && $this->getHttpStatus() < 200;
}
/**
@ -614,7 +645,7 @@ class Curl
*/
public function isSuccess()
{
return $this->http_status_code >= 200 && $this->http_status_code < 300;
return $this->getHttpStatus() >= 200 && $this->getHttpStatus() < 300;
}
/**
@ -623,7 +654,7 @@ class Curl
*/
public function isRedirect()
{
return $this->http_status_code >= 300 && $this->http_status_code < 400;
return $this->getHttpStatus() >= 300 && $this->getHttpStatus() < 400;
}
/**
@ -632,7 +663,7 @@ class Curl
*/
public function isError()
{
return $this->http_status_code >= 400 && $this->http_status_code < 600;
return $this->getHttpStatus() >= 400 && $this->getHttpStatus() < 600;
}
/**
@ -641,7 +672,7 @@ class Curl
*/
public function isClientError()
{
return $this->http_status_code >= 400 && $this->http_status_code < 500;
return $this->getHttpStatus() >= 400 && $this->getHttpStatus() < 500;
}
/**
@ -650,7 +681,7 @@ class Curl
*/
public function isServerError()
{
return $this->http_status_code >= 500 && $this->http_status_code < 600;
return $this->getHttpStatus() >= 500 && $this->getHttpStatus() < 600;
}
/**
@ -673,7 +704,7 @@ class Curl
* ```
*
* @param string $headerKey Optional key to get from the array.
* @return bool|string
* @return bool|string|array
* @since 1.9
*/
public function getResponseHeaders($headerKey = null)
@ -697,21 +728,37 @@ class Curl
return $headers;
}
/**
* Get response from the curl request
* @return string|false
*/
public function getResponse()
{
return $this->response;
}
/**
* Get curl error code
* @return string
*/
public function getErrorCode()
{
return $this->curl_error_code;
}
/**
* Get curl error message
* @return string
*/
public function getErrorMessage()
{
return $this->curl_error_message;
}
/**
* Get http status code from the curl request
* @return int
*/
public function getHttpStatus()
{
return $this->http_status_code;