From 192e81620d41dd1d2b7ccfcb71b1b26cfa0eb962 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 13 Jan 2016 15:17:13 +0900 Subject: [PATCH] Replace Pear HTTP_Request with rmccue/Requests --- classes/file/FileHandler.class.php | 135 +- composer.json | 1 - composer.lock | 208 +- config/func.inc.php | 2 +- libs/PEAR.1.9.5/HTTP/Request.php | 55 - libs/PEAR.1.9.5/HTTP/Request2.php | 1030 --- libs/PEAR.1.9.5/HTTP/Request2/Adapter.php | 137 - .../PEAR.1.9.5/HTTP/Request2/Adapter/Curl.php | 567 -- .../PEAR.1.9.5/HTTP/Request2/Adapter/Mock.php | 166 - .../HTTP/Request2/Adapter/Socket.php | 1121 --- libs/PEAR.1.9.5/HTTP/Request2/CookieJar.php | 494 -- libs/PEAR.1.9.5/HTTP/Request2/Exception.php | 160 - .../HTTP/Request2/MultipartBody.php | 268 - .../PEAR.1.9.5/HTTP/Request2/Observer/Log.php | 192 - libs/PEAR.1.9.5/HTTP/Request2/Response.php | 631 -- libs/PEAR.1.9.5/HTTP/Request2/SOCKS5.php | 135 - .../HTTP/Request2/SocketWrapper.php | 297 - libs/PEAR.1.9.5/Net/URL2.php | 1219 --- libs/PEAR.1.9.5/PEAR.php | 1063 --- libs/PEAR.1.9.5/PEAR/Exception.php | 389 - libs/PEAR.1.9.5/PEAR5.php | 33 - libs/PEAR.1.9/HTTP/Request.php | 55 - libs/PEAR.1.9/HTTP/Request2.php | 861 --- libs/PEAR.1.9/HTTP/Request2/Adapter.php | 154 - libs/PEAR.1.9/HTTP/Request2/Adapter/Curl.php | 461 -- libs/PEAR.1.9/HTTP/Request2/Adapter/Mock.php | 171 - .../PEAR.1.9/HTTP/Request2/Adapter/Socket.php | 1046 --- libs/PEAR.1.9/HTTP/Request2/Exception.php | 62 - libs/PEAR.1.9/HTTP/Request2/MultipartBody.php | 274 - libs/PEAR.1.9/HTTP/Request2/Observer/Log.php | 215 - libs/PEAR.1.9/HTTP/Request2/Response.php | 559 -- libs/PEAR.1.9/Net/URL2.php | 894 --- libs/PEAR.1.9/PEAR.php | 1137 --- libs/PEAR.1.9/PEAR/Exception.php | 391 - libs/PEAR.1.9/PEAR5.php | 33 - libs/PEAR/HTTP/Request.php | 1461 ---- libs/PEAR/HTTP/Request/Listener.php | 106 - libs/PEAR/Net/Socket.php | 528 -- libs/PEAR/Net/URL.php | 410 - libs/PEAR/PEAR.php | 1108 --- vendor/composer/autoload_classmap.php | 34 - vendor/composer/autoload_namespaces.php | 2 - vendor/composer/autoload_real.php | 4 - vendor/composer/include_paths.php | 10 - vendor/composer/installed.json | 174 - vendor/pear/http_request2/HTTP/Request2.php | 1030 --- .../http_request2/HTTP/Request2/Adapter.php | 137 - .../HTTP/Request2/Adapter/Curl.php | 567 -- .../HTTP/Request2/Adapter/Mock.php | 166 - .../HTTP/Request2/Adapter/Socket.php | 1121 --- .../http_request2/HTTP/Request2/CookieJar.php | 494 -- .../http_request2/HTTP/Request2/Exception.php | 160 - .../HTTP/Request2/MultipartBody.php | 268 - .../HTTP/Request2/Observer/Log.php | 192 - .../http_request2/HTTP/Request2/Response.php | 631 -- .../http_request2/HTTP/Request2/SOCKS5.php | 135 - .../HTTP/Request2/SocketWrapper.php | 297 - vendor/pear/http_request2/README.md | 80 - vendor/pear/http_request2/composer.json | 34 - .../pear/http_request2/data/generate-list.php | 96 - .../http_request2/data/public-suffix-list.php | 6701 ----------------- vendor/pear/http_request2/docs/LICENSE | 31 - .../docs/examples/upload-rapidshare.php | 58 - vendor/pear/http_request2/package.xml | 646 -- vendor/pear/http_request2/tests/AllTests.php | 54 - .../tests/NetworkConfig.php.dist | 58 - .../pear/http_request2/tests/ObserverTest.php | 95 - .../tests/Request2/Adapter/AllTests.php | 70 - .../Request2/Adapter/CommonNetworkTest.php | 387 - .../tests/Request2/Adapter/CurlTest.php | 120 - .../tests/Request2/Adapter/MockTest.php | 157 - .../tests/Request2/Adapter/SkippedTests.php | 56 - .../Request2/Adapter/SocketProxyTest.php | 55 - .../tests/Request2/Adapter/SocketTest.php | 159 - .../http_request2/tests/Request2/AllTests.php | 56 - .../tests/Request2/CookieJarTest.php | 370 - .../tests/Request2/MultipartBodyTest.php | 102 - .../tests/Request2/ResponseTest.php | 128 - .../pear/http_request2/tests/Request2Test.php | 391 - .../pear/http_request2/tests/TestHelper.php | 51 - .../pear/http_request2/tests/_files/bug_15305 | Bin 16338 -> 0 bytes .../pear/http_request2/tests/_files/bug_18169 | 9 - .../pear/http_request2/tests/_files/empty.gif | Bin 43 -> 0 bytes .../http_request2/tests/_files/plaintext.txt | 1 - .../tests/_files/response_cookies | 13 - .../tests/_files/response_deflate | Bin 1654 -> 0 bytes .../http_request2/tests/_files/response_gzip | Bin 1672 -> 0 bytes .../tests/_files/response_gzip_broken | Bin 221 -> 0 bytes .../tests/_files/response_headers | 12 - .../tests/_network/basicauth.php | 33 - .../http_request2/tests/_network/bug19934.php | 27 - .../http_request2/tests/_network/cookies.php | 24 - .../tests/_network/digestauth.php | 83 - .../tests/_network/getparameters.php | 24 - .../tests/_network/postparameters.php | 24 - .../tests/_network/rawpostdata.php | 22 - .../tests/_network/redirects.php | 47 - .../tests/_network/setcookie.php | 27 - .../http_request2/tests/_network/timeout.php | 23 - .../http_request2/tests/_network/uploads.php | 36 - vendor/pear/net_url2/.gitignore | 7 - vendor/pear/net_url2/.scrutinizer.yml | 38 - vendor/pear/net_url2/.travis.yml | 17 - vendor/pear/net_url2/Net/URL2.php | 1219 --- vendor/pear/net_url2/README.md | 43 - vendor/pear/net_url2/composer.json | 47 - vendor/pear/net_url2/docs/6470.php | 56 - vendor/pear/net_url2/docs/BSD-3-CLAUSE-Heyes | 27 - vendor/pear/net_url2/docs/example.php | 62 - vendor/pear/net_url2/package.xml | 469 -- vendor/pear/net_url2/phpunit.xml.dist | 17 - vendor/pear/net_url2/tests/AllTests.php | 59 - vendor/pear/net_url2/tests/Net/URL2Test.php | 1088 --- vendor/pear/pear_exception/.gitignore | 6 - vendor/pear/pear_exception/.travis.yml | 7 - vendor/pear/pear_exception/LICENSE | 27 - vendor/pear/pear_exception/PEAR/Exception.php | 456 -- vendor/pear/pear_exception/composer.json | 43 - vendor/pear/pear_exception/package.xml | 120 - .../tests/PEAR/ExceptionTest.php | 78 - 120 files changed, 94 insertions(+), 37803 deletions(-) delete mode 100644 libs/PEAR.1.9.5/HTTP/Request.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/Adapter.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/Adapter/Curl.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/Adapter/Mock.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/Adapter/Socket.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/CookieJar.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/Exception.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/MultipartBody.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/Observer/Log.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/Response.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/SOCKS5.php delete mode 100644 libs/PEAR.1.9.5/HTTP/Request2/SocketWrapper.php delete mode 100644 libs/PEAR.1.9.5/Net/URL2.php delete mode 100644 libs/PEAR.1.9.5/PEAR.php delete mode 100644 libs/PEAR.1.9.5/PEAR/Exception.php delete mode 100644 libs/PEAR.1.9.5/PEAR5.php delete mode 100644 libs/PEAR.1.9/HTTP/Request.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2/Adapter.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2/Adapter/Curl.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2/Adapter/Mock.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2/Adapter/Socket.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2/Exception.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2/MultipartBody.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2/Observer/Log.php delete mode 100644 libs/PEAR.1.9/HTTP/Request2/Response.php delete mode 100644 libs/PEAR.1.9/Net/URL2.php delete mode 100644 libs/PEAR.1.9/PEAR.php delete mode 100644 libs/PEAR.1.9/PEAR/Exception.php delete mode 100644 libs/PEAR.1.9/PEAR5.php delete mode 100644 libs/PEAR/HTTP/Request.php delete mode 100644 libs/PEAR/HTTP/Request/Listener.php delete mode 100644 libs/PEAR/Net/Socket.php delete mode 100644 libs/PEAR/Net/URL.php delete mode 100644 libs/PEAR/PEAR.php delete mode 100644 vendor/composer/include_paths.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/Adapter.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/Adapter/Curl.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/Adapter/Mock.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/Adapter/Socket.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/CookieJar.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/Exception.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/MultipartBody.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/Observer/Log.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/Response.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/SOCKS5.php delete mode 100644 vendor/pear/http_request2/HTTP/Request2/SocketWrapper.php delete mode 100644 vendor/pear/http_request2/README.md delete mode 100644 vendor/pear/http_request2/composer.json delete mode 100644 vendor/pear/http_request2/data/generate-list.php delete mode 100644 vendor/pear/http_request2/data/public-suffix-list.php delete mode 100644 vendor/pear/http_request2/docs/LICENSE delete mode 100644 vendor/pear/http_request2/docs/examples/upload-rapidshare.php delete mode 100644 vendor/pear/http_request2/package.xml delete mode 100644 vendor/pear/http_request2/tests/AllTests.php delete mode 100644 vendor/pear/http_request2/tests/NetworkConfig.php.dist delete mode 100644 vendor/pear/http_request2/tests/ObserverTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/AllTests.php delete mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/CommonNetworkTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/CurlTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/MockTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/SkippedTests.php delete mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/SocketProxyTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2/Adapter/SocketTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2/AllTests.php delete mode 100644 vendor/pear/http_request2/tests/Request2/CookieJarTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2/MultipartBodyTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2/ResponseTest.php delete mode 100644 vendor/pear/http_request2/tests/Request2Test.php delete mode 100644 vendor/pear/http_request2/tests/TestHelper.php delete mode 100644 vendor/pear/http_request2/tests/_files/bug_15305 delete mode 100644 vendor/pear/http_request2/tests/_files/bug_18169 delete mode 100644 vendor/pear/http_request2/tests/_files/empty.gif delete mode 100644 vendor/pear/http_request2/tests/_files/plaintext.txt delete mode 100644 vendor/pear/http_request2/tests/_files/response_cookies delete mode 100644 vendor/pear/http_request2/tests/_files/response_deflate delete mode 100644 vendor/pear/http_request2/tests/_files/response_gzip delete mode 100644 vendor/pear/http_request2/tests/_files/response_gzip_broken delete mode 100644 vendor/pear/http_request2/tests/_files/response_headers delete mode 100644 vendor/pear/http_request2/tests/_network/basicauth.php delete mode 100644 vendor/pear/http_request2/tests/_network/bug19934.php delete mode 100644 vendor/pear/http_request2/tests/_network/cookies.php delete mode 100644 vendor/pear/http_request2/tests/_network/digestauth.php delete mode 100644 vendor/pear/http_request2/tests/_network/getparameters.php delete mode 100644 vendor/pear/http_request2/tests/_network/postparameters.php delete mode 100644 vendor/pear/http_request2/tests/_network/rawpostdata.php delete mode 100644 vendor/pear/http_request2/tests/_network/redirects.php delete mode 100644 vendor/pear/http_request2/tests/_network/setcookie.php delete mode 100644 vendor/pear/http_request2/tests/_network/timeout.php delete mode 100644 vendor/pear/http_request2/tests/_network/uploads.php delete mode 100644 vendor/pear/net_url2/.gitignore delete mode 100644 vendor/pear/net_url2/.scrutinizer.yml delete mode 100644 vendor/pear/net_url2/.travis.yml delete mode 100755 vendor/pear/net_url2/Net/URL2.php delete mode 100644 vendor/pear/net_url2/README.md delete mode 100644 vendor/pear/net_url2/composer.json delete mode 100755 vendor/pear/net_url2/docs/6470.php delete mode 100644 vendor/pear/net_url2/docs/BSD-3-CLAUSE-Heyes delete mode 100755 vendor/pear/net_url2/docs/example.php delete mode 100644 vendor/pear/net_url2/package.xml delete mode 100644 vendor/pear/net_url2/phpunit.xml.dist delete mode 100644 vendor/pear/net_url2/tests/AllTests.php delete mode 100644 vendor/pear/net_url2/tests/Net/URL2Test.php delete mode 100644 vendor/pear/pear_exception/.gitignore delete mode 100644 vendor/pear/pear_exception/.travis.yml delete mode 100644 vendor/pear/pear_exception/LICENSE delete mode 100644 vendor/pear/pear_exception/PEAR/Exception.php delete mode 100644 vendor/pear/pear_exception/composer.json delete mode 100644 vendor/pear/pear_exception/package.xml delete mode 100644 vendor/pear/pear_exception/tests/PEAR/ExceptionTest.php diff --git a/classes/file/FileHandler.class.php b/classes/file/FileHandler.class.php index d725d95aa..9bafafd0c 100644 --- a/classes/file/FileHandler.class.php +++ b/classes/file/FileHandler.class.php @@ -516,8 +516,6 @@ class FileHandler /** * Return remote file's content via HTTP * - * If the target is moved (when return code is 300~399), this function follows the location specified response header. - * * @param string $url The address of the target file * @param string $body HTTP request body * @param int $timeout Connection timeout @@ -532,89 +530,66 @@ class FileHandler { try { - requirePear(); - if(!class_exists('HTTP_Request')) require_once('HTTP/Request.php'); - - $parsed_url = parse_url(__PROXY_SERVER__); - if($parsed_url["host"]) + $request_headers = array(); + $request_cookies = array(); + $request_options = array('timeout' => $timeout); + + foreach($headers as $key => $val) { - $oRequest = new HTTP_Request(__PROXY_SERVER__); - $oRequest->setMethod('POST'); - $oRequest->addPostData('arg', serialize(array('Destination' => $url, 'method' => $method, 'body' => $body, 'content_type' => $content_type, "headers" => $headers, "post_data" => $post_data))); + $request_headers[$key] = $val; + } + + if(isset($cookies[$host]) && is_array($cookies[$host])) + { + foreach($cookies[$host] as $key => $val) + { + $request_cookies[] = rawurlencode($key) . '=' . rawurlencode($val); + } + } + if(count($request_cookies)) + { + $request_headers['Cookie'] = implode('; ', $request_cookies); + } + + foreach($request_config as $key => $val) + { + $request_options[$key] = $val; + } + + if($content_type) + { + $request_headers['Content-Type'] = $content_type; + } + + $proxy = parse_url(__PROXY_SERVER__); + if($proxy["host"]) + { + $request_options['proxy'] = array($proxy['host'] . ($proxy['port'] ? (':' . $proxy['port']) : '')); + if($proxy['user'] && $proxy['pass']) + { + $request_options['proxy'][] = $proxy['user']; + $request_options['proxy'][] = $proxy['pass']; + } + } + + $response = Requests::request($url, $request_headers, $body ?: $post_data, $method, $request_options); + + if(count($response->cookies)) + { + foreach($response->cookies as $cookie) + { + $cookies[$host][$cookie->name] = $cookie->value; + } + } + + if($response->success) + { + return $response->body; } else { - $oRequest = new HTTP_Request($url); - - if(count($request_config) && method_exists($oRequest, 'setConfig')) - { - foreach($request_config as $key=>$val) - { - $oRequest->setConfig($key, $val); - } - } - - if(count($headers) > 0) - { - foreach($headers as $key => $val) - { - $oRequest->addHeader($key, $val); - } - } - if($cookies[$host]) - { - foreach($cookies[$host] as $key => $val) - { - $oRequest->addCookie($key, $val); - } - } - if(count($post_data) > 0) - { - foreach($post_data as $key => $val) - { - $oRequest->addPostData($key, $val); - } - } - if(!$content_type) - $oRequest->addHeader('Content-Type', 'text/html'); - else - $oRequest->addHeader('Content-Type', $content_type); - $oRequest->setMethod($method); - if($body) - $oRequest->setBody($body); + return NULL; } - - if(method_exists($oRequest, 'setConfig')) - { - $oRequest->setConfig('timeout', $timeout); - } - elseif(property_exists($oRequest, '_timeout')) - { - $oRequest->_timeout = $timeout; - } - - $oResponse = $oRequest->sendRequest(); - - $code = $oRequest->getResponseCode(); - $header = $oRequest->getResponseHeader(); - $response = $oRequest->getResponseBody(); - if($c = $oRequest->getResponseCookies()) - { - foreach($c as $k => $v) - { - $cookies[$host][$v['name']] = $v['value']; - } - } - - if($code > 300 && $code < 399 && $header['location']) - { - return self::getRemoteResource($header['location'], $body, $timeout, $method, $content_type, $headers, $cookies, $post_data); - } - - if($code != 200) - return; - - return $response; } catch(Exception $e) { diff --git a/composer.json b/composer.json index 3678be41e..faf97627b 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,6 @@ "firephp/firephp-core": "0.4.0", "matthiasmullie/minify": "1.3.*", "michelf/php-markdown": "1.5.*", - "pear/http_request2": "2.2.*", "rmccue/requests": "1.6.*", "sunra/php-simple-html-dom-parser": "1.5.*", "swiftmailer/swiftmailer": "5.4.*", diff --git a/composer.lock b/composer.lock index fb06f62f0..043cbfd87 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "97c72bd2862f9d0a77824d769085e926", - "content-hash": "ffd2aaf7dc6705d78c09488d2c7ab024", + "hash": "a35061b94658a2dbdafe943dddcdc898", + "content-hash": "1a71937e1cbc600f8a237c6445d6a69f", "packages": [ { "name": "defuse/php-encryption", @@ -96,6 +96,42 @@ ], "time": "2015-08-05 01:03:42" }, + { + "name": "firephp/firephp-core", + "version": "v0.4.0", + "source": { + "type": "git", + "url": "https://github.com/firephp/firephp-core.git", + "reference": "fabad0f2503f9577fe8dd2cb1d1c7cd73ed2aacf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/firephp/firephp-core/zipball/fabad0f2503f9577fe8dd2cb1d1c7cd73ed2aacf", + "reference": "fabad0f2503f9577fe8dd2cb1d1c7cd73ed2aacf", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "lib/FirePHPCore/FirePHP.class.php", + "lib/FirePHPCore/fb.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christoph Dorn", + "email": "christoph@christophdorn.com", + "homepage": "http://christophdorn.com" + } + ], + "description": "Traditional FirePHPCore library for sending PHP variables to the browser.", + "homepage": "https://github.com/firephp/firephp-core", + "time": "2013-04-23 15:28:20" + }, { "name": "matthiasmullie/minify", "version": "1.3.32", @@ -254,174 +290,6 @@ ], "time": "2015-03-01 12:03:08" }, - { - "name": "pear/http_request2", - "version": "v2.2.1", - "source": { - "type": "git", - "url": "https://github.com/pear/HTTP_Request2.git", - "reference": "d6c81670c504045248c1afdf896bb9a3288158de" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/pear/HTTP_Request2/zipball/d6c81670c504045248c1afdf896bb9a3288158de", - "reference": "d6c81670c504045248c1afdf896bb9a3288158de", - "shasum": "" - }, - "require": { - "pear/net_url2": ">=2.0.0", - "pear/pear_exception": "*", - "php": ">=5.2.0" - }, - "suggest": { - "ext-fileinfo": "Adds support for looking up mime-types using finfo.", - "ext-zlib": "Allows handling gzip compressed responses.", - "lib-curl": "Allows using cURL as a request backend.", - "lib-openssl": "Allows handling SSL requests when not using cURL." - }, - "type": "library", - "autoload": { - "psr-0": { - "HTTP_Request2": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Alexey Borzov", - "email": "avb@php.net", - "role": "Developer HTML_Common2" - } - ], - "description": "Provides an easy way to perform HTTP requests.", - "homepage": "http://pear.php.net/package/HTTP_Request2", - "keywords": [ - "PEAR", - "curl", - "http", - "request" - ], - "time": "2014-01-16 17:27:21" - }, - { - "name": "pear/net_url2", - "version": "v2.2.0", - "source": { - "type": "git", - "url": "https://github.com/pear/Net_URL2.git", - "reference": "fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/pear/Net_URL2/zipball/fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e", - "reference": "fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e", - "shasum": "" - }, - "require": { - "php": ">=5.1.4" - }, - "require-dev": { - "phpunit/phpunit": ">=3.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "Net/URL2.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "David Coallier", - "email": "davidc@php.net" - }, - { - "name": "Tom Klingenberg", - "email": "tkli@php.net" - }, - { - "name": "Christian Schmidt", - "email": "chmidt@php.net" - } - ], - "description": "Class for parsing and handling URL. Provides parsing of URLs into their constituent parts (scheme, host, path etc.), URL generation, and resolving of relative URLs.", - "homepage": "https://github.com/pear/Net_URL2", - "keywords": [ - "PEAR", - "net", - "networking", - "rfc3986", - "uri", - "url" - ], - "time": "2015-04-18 17:36:57" - }, - { - "name": "pear/pear_exception", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/pear/PEAR_Exception.git", - "reference": "8c18719fdae000b690e3912be401c76e406dd13b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/pear/PEAR_Exception/zipball/8c18719fdae000b690e3912be401c76e406dd13b", - "reference": "8c18719fdae000b690e3912be401c76e406dd13b", - "shasum": "" - }, - "require": { - "php": ">=4.4.0" - }, - "require-dev": { - "phpunit/phpunit": "*" - }, - "type": "class", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "PEAR": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "." - ], - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Helgi Thormar", - "email": "dufuz@php.net" - }, - { - "name": "Greg Beaver", - "email": "cellog@php.net" - } - ], - "description": "The PEAR Exception base class.", - "homepage": "https://github.com/pear/PEAR_Exception", - "keywords": [ - "exception" - ], - "time": "2015-02-10 20:07:52" - }, { "name": "rmccue/requests", "version": "v1.6.1", diff --git a/config/func.inc.php b/config/func.inc.php index 89a3a8e25..c35f9b562 100644 --- a/config/func.inc.php +++ b/config/func.inc.php @@ -1448,7 +1448,7 @@ function stripEmbedTagForAdmin(&$content, $writer_member_srl) */ function requirePear() { - set_include_path(_XE_PATH_ . "libs/PEAR.1.9.5" . PATH_SEPARATOR . get_include_path()); + } /** diff --git a/libs/PEAR.1.9.5/HTTP/Request.php b/libs/PEAR.1.9.5/HTTP/Request.php deleted file mode 100644 index 7fb0645d0..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request.php +++ /dev/null @@ -1,55 +0,0 @@ -setHeader($name, $value); - } - - public function sendRequest($saveBody = true) - { - $response = $this->send(); - $this->response = $response; - return $response; - } - - public function getResponseCode() { - if($this->response) - { - return $this->response->getStatus(); - } - } - - public function getResponseHeader() { - if($this->response) - { - return $this->response->getHeader(); - } - } - - public function getResponseBody() { - if($this->response) - { - return $this->response->getBody(); - } - } - - public function getResponseCookies() { - if($this->response) - { - return $this->response->getCookies(); - } - } - - public function addPostData($name, $value, $preencoded = false) - { - $this->addPostParameter($name, $value); - } - -} - -?> diff --git a/libs/PEAR.1.9.5/HTTP/Request2.php b/libs/PEAR.1.9.5/HTTP/Request2.php deleted file mode 100644 index d2f36e17b..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2.php +++ /dev/null @@ -1,1030 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * A class representing an URL as per RFC 3986. - */ -require_once 'Net/URL2.php'; - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class representing a HTTP request message - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://tools.ietf.org/html/rfc2616#section-5 - */ -class HTTP_Request2 implements SplSubject -{ - /**#@+ - * Constants for HTTP request methods - * - * @link http://tools.ietf.org/html/rfc2616#section-5.1.1 - */ - const METHOD_OPTIONS = 'OPTIONS'; - const METHOD_GET = 'GET'; - const METHOD_HEAD = 'HEAD'; - const METHOD_POST = 'POST'; - const METHOD_PUT = 'PUT'; - const METHOD_DELETE = 'DELETE'; - const METHOD_TRACE = 'TRACE'; - const METHOD_CONNECT = 'CONNECT'; - /**#@-*/ - - /**#@+ - * Constants for HTTP authentication schemes - * - * @link http://tools.ietf.org/html/rfc2617 - */ - const AUTH_BASIC = 'basic'; - const AUTH_DIGEST = 'digest'; - /**#@-*/ - - /** - * Regular expression used to check for invalid symbols in RFC 2616 tokens - * @link http://pear.php.net/bugs/bug.php?id=15630 - */ - const REGEXP_INVALID_TOKEN = '![\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]!'; - - /** - * Regular expression used to check for invalid symbols in cookie strings - * @link http://pear.php.net/bugs/bug.php?id=15630 - * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html - */ - const REGEXP_INVALID_COOKIE = '/[\s,;]/'; - - /** - * Fileinfo magic database resource - * @var resource - * @see detectMimeType() - */ - private static $_fileinfoDb; - - /** - * Observers attached to the request (instances of SplObserver) - * @var array - */ - protected $observers = array(); - - /** - * Request URL - * @var Net_URL2 - */ - protected $url; - - /** - * Request method - * @var string - */ - protected $method = self::METHOD_GET; - - /** - * Authentication data - * @var array - * @see getAuth() - */ - protected $auth; - - /** - * Request headers - * @var array - */ - protected $headers = array(); - - /** - * Configuration parameters - * @var array - * @see setConfig() - */ - protected $config = array( - 'adapter' => 'HTTP_Request2_Adapter_Socket', - 'connect_timeout' => 10, - 'timeout' => 0, - 'use_brackets' => true, - 'protocol_version' => '1.1', - 'buffer_size' => 16384, - 'store_body' => true, - 'local_ip' => null, - - 'proxy_host' => '', - 'proxy_port' => '', - 'proxy_user' => '', - 'proxy_password' => '', - 'proxy_auth_scheme' => self::AUTH_BASIC, - 'proxy_type' => 'http', - - 'ssl_verify_peer' => true, - 'ssl_verify_host' => true, - 'ssl_cafile' => null, - 'ssl_capath' => null, - 'ssl_local_cert' => null, - 'ssl_passphrase' => null, - - 'digest_compat_ie' => false, - - 'follow_redirects' => false, - 'max_redirects' => 5, - 'strict_redirects' => false - ); - - /** - * Last event in request / response handling, intended for observers - * @var array - * @see getLastEvent() - */ - protected $lastEvent = array( - 'name' => 'start', - 'data' => null - ); - - /** - * Request body - * @var string|resource - * @see setBody() - */ - protected $body = ''; - - /** - * Array of POST parameters - * @var array - */ - protected $postParams = array(); - - /** - * Array of file uploads (for multipart/form-data POST requests) - * @var array - */ - protected $uploads = array(); - - /** - * Adapter used to perform actual HTTP request - * @var HTTP_Request2_Adapter - */ - protected $adapter; - - /** - * Cookie jar to persist cookies between requests - * @var HTTP_Request2_CookieJar - */ - protected $cookieJar = null; - - /** - * Constructor. Can set request URL, method and configuration array. - * - * Also sets a default value for User-Agent header. - * - * @param string|Net_Url2 $url Request URL - * @param string $method Request method - * @param array $config Configuration for this Request instance - */ - public function __construct( - $url = null, $method = self::METHOD_GET, array $config = array() - ) { - $this->setConfig($config); - if (!empty($url)) { - $this->setUrl($url); - } - if (!empty($method)) { - $this->setMethod($method); - } - $this->setHeader( - 'user-agent', 'HTTP_Request2/2.2.1 ' . - '(http://pear.php.net/package/http_request2) PHP/' . phpversion() - ); - } - - /** - * Sets the URL for this request - * - * If the URL has userinfo part (username & password) these will be removed - * and converted to auth data. If the URL does not have a path component, - * that will be set to '/'. - * - * @param string|Net_URL2 $url Request URL - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setUrl($url) - { - if (is_string($url)) { - $url = new Net_URL2( - $url, array(Net_URL2::OPTION_USE_BRACKETS => $this->config['use_brackets']) - ); - } - if (!$url instanceof Net_URL2) { - throw new HTTP_Request2_LogicException( - 'Parameter is not a valid HTTP URL', - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - // URL contains username / password? - if ($url->getUserinfo()) { - $username = $url->getUser(); - $password = $url->getPassword(); - $this->setAuth(rawurldecode($username), $password? rawurldecode($password): ''); - $url->setUserinfo(''); - } - if ('' == $url->getPath()) { - $url->setPath('/'); - } - $this->url = $url; - - return $this; - } - - /** - * Returns the request URL - * - * @return Net_URL2 - */ - public function getUrl() - { - return $this->url; - } - - /** - * Sets the request method - * - * @param string $method one of the methods defined in RFC 2616 - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException if the method name is invalid - */ - public function setMethod($method) - { - // Method name should be a token: http://tools.ietf.org/html/rfc2616#section-5.1.1 - if (preg_match(self::REGEXP_INVALID_TOKEN, $method)) { - throw new HTTP_Request2_LogicException( - "Invalid request method '{$method}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $this->method = $method; - - return $this; - } - - /** - * Returns the request method - * - * @return string - */ - public function getMethod() - { - return $this->method; - } - - /** - * Sets the configuration parameter(s) - * - * The following parameters are available: - *
    - *
  • 'adapter' - adapter to use (string)
  • - *
  • 'connect_timeout' - Connection timeout in seconds (integer)
  • - *
  • 'timeout' - Total number of seconds a request can take. - * Use 0 for no limit, should be greater than - * 'connect_timeout' if set (integer)
  • - *
  • 'use_brackets' - Whether to append [] to array variable names (bool)
  • - *
  • 'protocol_version' - HTTP Version to use, '1.0' or '1.1' (string)
  • - *
  • 'buffer_size' - Buffer size to use for reading and writing (int)
  • - *
  • 'store_body' - Whether to store response body in response object. - * Set to false if receiving a huge response and - * using an Observer to save it (boolean)
  • - *
  • 'local_ip' - Specifies the IP address that will be used for accessing - * the network (string)
  • - *
  • 'proxy_type' - Proxy type, 'http' or 'socks5' (string)
  • - *
  • 'proxy_host' - Proxy server host (string)
  • - *
  • 'proxy_port' - Proxy server port (integer)
  • - *
  • 'proxy_user' - Proxy auth username (string)
  • - *
  • 'proxy_password' - Proxy auth password (string)
  • - *
  • 'proxy_auth_scheme' - Proxy auth scheme, one of HTTP_Request2::AUTH_* constants (string)
  • - *
  • 'proxy' - Shorthand for proxy_* parameters, proxy given as URL, - * e.g. 'socks5://localhost:1080/' (string)
  • - *
  • 'ssl_verify_peer' - Whether to verify peer's SSL certificate (bool)
  • - *
  • 'ssl_verify_host' - Whether to check that Common Name in SSL - * certificate matches host name (bool)
  • - *
  • 'ssl_cafile' - Cerificate Authority file to verify the peer - * with (use with 'ssl_verify_peer') (string)
  • - *
  • 'ssl_capath' - Directory holding multiple Certificate - * Authority files (string)
  • - *
  • 'ssl_local_cert' - Name of a file containing local cerificate (string)
  • - *
  • 'ssl_passphrase' - Passphrase with which local certificate - * was encoded (string)
  • - *
  • 'digest_compat_ie' - Whether to imitate behaviour of MSIE 5 and 6 - * in using URL without query string in digest - * authentication (boolean)
  • - *
  • 'follow_redirects' - Whether to automatically follow HTTP Redirects (boolean)
  • - *
  • 'max_redirects' - Maximum number of redirects to follow (integer)
  • - *
  • 'strict_redirects' - Whether to keep request method on redirects via status 301 and - * 302 (true, needed for compatibility with RFC 2616) - * or switch to GET (false, needed for compatibility with most - * browsers) (boolean)
  • - *
- * - * @param string|array $nameOrConfig configuration parameter name or array - * ('parameter name' => 'parameter value') - * @param mixed $value parameter value if $nameOrConfig is not an array - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException If the parameter is unknown - */ - public function setConfig($nameOrConfig, $value = null) - { - if (is_array($nameOrConfig)) { - foreach ($nameOrConfig as $name => $value) { - $this->setConfig($name, $value); - } - - } elseif ('proxy' == $nameOrConfig) { - $url = new Net_URL2($value); - $this->setConfig(array( - 'proxy_type' => $url->getScheme(), - 'proxy_host' => $url->getHost(), - 'proxy_port' => $url->getPort(), - 'proxy_user' => rawurldecode($url->getUser()), - 'proxy_password' => rawurldecode($url->getPassword()) - )); - - } else { - if (!array_key_exists($nameOrConfig, $this->config)) { - throw new HTTP_Request2_LogicException( - "Unknown configuration parameter '{$nameOrConfig}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $this->config[$nameOrConfig] = $value; - } - - return $this; - } - - /** - * Returns the value(s) of the configuration parameter(s) - * - * @param string $name parameter name - * - * @return mixed value of $name parameter, array of all configuration - * parameters if $name is not given - * @throws HTTP_Request2_LogicException If the parameter is unknown - */ - public function getConfig($name = null) - { - if (null === $name) { - return $this->config; - } elseif (!array_key_exists($name, $this->config)) { - throw new HTTP_Request2_LogicException( - "Unknown configuration parameter '{$name}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - return $this->config[$name]; - } - - /** - * Sets the autentification data - * - * @param string $user user name - * @param string $password password - * @param string $scheme authentication scheme - * - * @return HTTP_Request2 - */ - public function setAuth($user, $password = '', $scheme = self::AUTH_BASIC) - { - if (empty($user)) { - $this->auth = null; - } else { - $this->auth = array( - 'user' => (string)$user, - 'password' => (string)$password, - 'scheme' => $scheme - ); - } - - return $this; - } - - /** - * Returns the authentication data - * - * The array has the keys 'user', 'password' and 'scheme', where 'scheme' - * is one of the HTTP_Request2::AUTH_* constants. - * - * @return array - */ - public function getAuth() - { - return $this->auth; - } - - /** - * Sets request header(s) - * - * The first parameter may be either a full header string 'header: value' or - * header name. In the former case $value parameter is ignored, in the latter - * the header's value will either be set to $value or the header will be - * removed if $value is null. The first parameter can also be an array of - * headers, in that case method will be called recursively. - * - * Note that headers are treated case insensitively as per RFC 2616. - * - * - * $req->setHeader('Foo: Bar'); // sets the value of 'Foo' header to 'Bar' - * $req->setHeader('FoO', 'Baz'); // sets the value of 'Foo' header to 'Baz' - * $req->setHeader(array('foo' => 'Quux')); // sets the value of 'Foo' header to 'Quux' - * $req->setHeader('FOO'); // removes 'Foo' header from request - * - * - * @param string|array $name header name, header string ('Header: value') - * or an array of headers - * @param string|array|null $value header value if $name is not an array, - * header will be removed if value is null - * @param bool $replace whether to replace previous header with the - * same name or append to its value - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setHeader($name, $value = null, $replace = true) - { - if (is_array($name)) { - foreach ($name as $k => $v) { - if (is_string($k)) { - $this->setHeader($k, $v, $replace); - } else { - $this->setHeader($v, null, $replace); - } - } - } else { - if (null === $value && strpos($name, ':')) { - list($name, $value) = array_map('trim', explode(':', $name, 2)); - } - // Header name should be a token: http://tools.ietf.org/html/rfc2616#section-4.2 - if (preg_match(self::REGEXP_INVALID_TOKEN, $name)) { - throw new HTTP_Request2_LogicException( - "Invalid header name '{$name}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - // Header names are case insensitive anyway - $name = strtolower($name); - if (null === $value) { - unset($this->headers[$name]); - - } else { - if (is_array($value)) { - $value = implode(', ', array_map('trim', $value)); - } elseif (is_string($value)) { - $value = trim($value); - } - if (!isset($this->headers[$name]) || $replace) { - $this->headers[$name] = $value; - } else { - $this->headers[$name] .= ', ' . $value; - } - } - } - - return $this; - } - - /** - * Returns the request headers - * - * The array is of the form ('header name' => 'header value'), header names - * are lowercased - * - * @return array - */ - public function getHeaders() - { - return $this->headers; - } - - /** - * Adds a cookie to the request - * - * If the request does not have a CookieJar object set, this method simply - * appends a cookie to "Cookie:" header. - * - * If a CookieJar object is available, the cookie is stored in that object. - * Data from request URL will be used for setting its 'domain' and 'path' - * parameters, 'expires' and 'secure' will be set to null and false, - * respectively. If you need further control, use CookieJar's methods. - * - * @param string $name cookie name - * @param string $value cookie value - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - * @see setCookieJar() - */ - public function addCookie($name, $value) - { - if (!empty($this->cookieJar)) { - $this->cookieJar->store( - array('name' => $name, 'value' => $value), $this->url - ); - - } else { - $cookie = $name . '=' . $value; - if (preg_match(self::REGEXP_INVALID_COOKIE, $cookie)) { - throw new HTTP_Request2_LogicException( - "Invalid cookie: '{$cookie}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $cookies = empty($this->headers['cookie'])? '': $this->headers['cookie'] . '; '; - $this->setHeader('cookie', $cookies . $cookie); - } - - return $this; - } - - /** - * Sets the request body - * - * If you provide file pointer rather than file name, it should support - * fstat() and rewind() operations. - * - * @param string|resource|HTTP_Request2_MultipartBody $body Either a - * string with the body or filename containing body or - * pointer to an open file or object with multipart body data - * @param bool $isFilename Whether - * first parameter is a filename - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setBody($body, $isFilename = false) - { - if (!$isFilename && !is_resource($body)) { - if (!$body instanceof HTTP_Request2_MultipartBody) { - $this->body = (string)$body; - } else { - $this->body = $body; - } - } else { - $fileData = $this->fopenWrapper($body, empty($this->headers['content-type'])); - $this->body = $fileData['fp']; - if (empty($this->headers['content-type'])) { - $this->setHeader('content-type', $fileData['type']); - } - } - $this->postParams = $this->uploads = array(); - - return $this; - } - - /** - * Returns the request body - * - * @return string|resource|HTTP_Request2_MultipartBody - */ - public function getBody() - { - if (self::METHOD_POST == $this->method - && (!empty($this->postParams) || !empty($this->uploads)) - ) { - if (0 === strpos($this->headers['content-type'], 'application/x-www-form-urlencoded')) { - $body = http_build_query($this->postParams, '', '&'); - if (!$this->getConfig('use_brackets')) { - $body = preg_replace('/%5B\d+%5D=/', '=', $body); - } - // support RFC 3986 by not encoding '~' symbol (request #15368) - return str_replace('%7E', '~', $body); - - } elseif (0 === strpos($this->headers['content-type'], 'multipart/form-data')) { - require_once 'HTTP/Request2/MultipartBody.php'; - return new HTTP_Request2_MultipartBody( - $this->postParams, $this->uploads, $this->getConfig('use_brackets') - ); - } - } - return $this->body; - } - - /** - * Adds a file to form-based file upload - * - * Used to emulate file upload via a HTML form. The method also sets - * Content-Type of HTTP request to 'multipart/form-data'. - * - * If you just want to send the contents of a file as the body of HTTP - * request you should use setBody() method. - * - * If you provide file pointers rather than file names, they should support - * fstat() and rewind() operations. - * - * @param string $fieldName name of file-upload field - * @param string|resource|array $filename full name of local file, - * pointer to open file or an array of files - * @param string $sendFilename filename to send in the request - * @param string $contentType content-type of file being uploaded - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function addUpload( - $fieldName, $filename, $sendFilename = null, $contentType = null - ) { - if (!is_array($filename)) { - $fileData = $this->fopenWrapper($filename, empty($contentType)); - $this->uploads[$fieldName] = array( - 'fp' => $fileData['fp'], - 'filename' => !empty($sendFilename)? $sendFilename - :(is_string($filename)? basename($filename): 'anonymous.blob') , - 'size' => $fileData['size'], - 'type' => empty($contentType)? $fileData['type']: $contentType - ); - } else { - $fps = $names = $sizes = $types = array(); - foreach ($filename as $f) { - if (!is_array($f)) { - $f = array($f); - } - $fileData = $this->fopenWrapper($f[0], empty($f[2])); - $fps[] = $fileData['fp']; - $names[] = !empty($f[1])? $f[1] - :(is_string($f[0])? basename($f[0]): 'anonymous.blob'); - $sizes[] = $fileData['size']; - $types[] = empty($f[2])? $fileData['type']: $f[2]; - } - $this->uploads[$fieldName] = array( - 'fp' => $fps, 'filename' => $names, 'size' => $sizes, 'type' => $types - ); - } - if (empty($this->headers['content-type']) - || 'application/x-www-form-urlencoded' == $this->headers['content-type'] - ) { - $this->setHeader('content-type', 'multipart/form-data'); - } - - return $this; - } - - /** - * Adds POST parameter(s) to the request. - * - * @param string|array $name parameter name or array ('name' => 'value') - * @param mixed $value parameter value (can be an array) - * - * @return HTTP_Request2 - */ - public function addPostParameter($name, $value = null) - { - if (!is_array($name)) { - $this->postParams[$name] = $value; - } else { - foreach ($name as $k => $v) { - $this->addPostParameter($k, $v); - } - } - if (empty($this->headers['content-type'])) { - $this->setHeader('content-type', 'application/x-www-form-urlencoded'); - } - - return $this; - } - - /** - * Attaches a new observer - * - * @param SplObserver $observer any object implementing SplObserver - */ - public function attach(SplObserver $observer) - { - foreach ($this->observers as $attached) { - if ($attached === $observer) { - return; - } - } - $this->observers[] = $observer; - } - - /** - * Detaches an existing observer - * - * @param SplObserver $observer any object implementing SplObserver - */ - public function detach(SplObserver $observer) - { - foreach ($this->observers as $key => $attached) { - if ($attached === $observer) { - unset($this->observers[$key]); - return; - } - } - } - - /** - * Notifies all observers - */ - public function notify() - { - foreach ($this->observers as $observer) { - $observer->update($this); - } - } - - /** - * Sets the last event - * - * Adapters should use this method to set the current state of the request - * and notify the observers. - * - * @param string $name event name - * @param mixed $data event data - */ - public function setLastEvent($name, $data = null) - { - $this->lastEvent = array( - 'name' => $name, - 'data' => $data - ); - $this->notify(); - } - - /** - * Returns the last event - * - * Observers should use this method to access the last change in request. - * The following event names are possible: - *
    - *
  • 'connect' - after connection to remote server, - * data is the destination (string)
  • - *
  • 'disconnect' - after disconnection from server
  • - *
  • 'sentHeaders' - after sending the request headers, - * data is the headers sent (string)
  • - *
  • 'sentBodyPart' - after sending a part of the request body, - * data is the length of that part (int)
  • - *
  • 'sentBody' - after sending the whole request body, - * data is request body length (int)
  • - *
  • 'receivedHeaders' - after receiving the response headers, - * data is HTTP_Request2_Response object
  • - *
  • 'receivedBodyPart' - after receiving a part of the response - * body, data is that part (string)
  • - *
  • 'receivedEncodedBodyPart' - as 'receivedBodyPart', but data is still - * encoded by Content-Encoding
  • - *
  • 'receivedBody' - after receiving the complete response - * body, data is HTTP_Request2_Response object
  • - *
- * Different adapters may not send all the event types. Mock adapter does - * not send any events to the observers. - * - * @return array The array has two keys: 'name' and 'data' - */ - public function getLastEvent() - { - return $this->lastEvent; - } - - /** - * Sets the adapter used to actually perform the request - * - * You can pass either an instance of a class implementing HTTP_Request2_Adapter - * or a class name. The method will only try to include a file if the class - * name starts with HTTP_Request2_Adapter_, it will also try to prepend this - * prefix to the class name if it doesn't contain any underscores, so that - * - * $request->setAdapter('curl'); - * - * will work. - * - * @param string|HTTP_Request2_Adapter $adapter Adapter to use - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setAdapter($adapter) - { - if (is_string($adapter)) { - if (!class_exists($adapter, false)) { - if (false === strpos($adapter, '_')) { - $adapter = 'HTTP_Request2_Adapter_' . ucfirst($adapter); - } - if (!class_exists($adapter, false) - && preg_match('/^HTTP_Request2_Adapter_([a-zA-Z0-9]+)$/', $adapter) - ) { - include_once str_replace('_', DIRECTORY_SEPARATOR, $adapter) . '.php'; - } - if (!class_exists($adapter, false)) { - throw new HTTP_Request2_LogicException( - "Class {$adapter} not found", - HTTP_Request2_Exception::MISSING_VALUE - ); - } - } - $adapter = new $adapter; - } - if (!$adapter instanceof HTTP_Request2_Adapter) { - throw new HTTP_Request2_LogicException( - 'Parameter is not a HTTP request adapter', - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $this->adapter = $adapter; - - return $this; - } - - /** - * Sets the cookie jar - * - * A cookie jar is used to maintain cookies across HTTP requests and - * responses. Cookies from jar will be automatically added to the request - * headers based on request URL. - * - * @param HTTP_Request2_CookieJar|bool $jar Existing CookieJar object, true to - * create a new one, false to remove - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setCookieJar($jar = true) - { - if (!class_exists('HTTP_Request2_CookieJar', false)) { - require_once 'HTTP/Request2/CookieJar.php'; - } - - if ($jar instanceof HTTP_Request2_CookieJar) { - $this->cookieJar = $jar; - } elseif (true === $jar) { - $this->cookieJar = new HTTP_Request2_CookieJar(); - } elseif (!$jar) { - $this->cookieJar = null; - } else { - throw new HTTP_Request2_LogicException( - 'Invalid parameter passed to setCookieJar()', - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - - return $this; - } - - /** - * Returns current CookieJar object or null if none - * - * @return HTTP_Request2_CookieJar|null - */ - public function getCookieJar() - { - return $this->cookieJar; - } - - /** - * Sends the request and returns the response - * - * @throws HTTP_Request2_Exception - * @return HTTP_Request2_Response - */ - public function send() - { - // Sanity check for URL - if (!$this->url instanceof Net_URL2 - || !$this->url->isAbsolute() - || !in_array(strtolower($this->url->getScheme()), array('https', 'http')) - ) { - throw new HTTP_Request2_LogicException( - 'HTTP_Request2 needs an absolute HTTP(S) request URL, ' - . ($this->url instanceof Net_URL2 - ? "'" . $this->url->__toString() . "'" : 'none') - . ' given', - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - if (empty($this->adapter)) { - $this->setAdapter($this->getConfig('adapter')); - } - // magic_quotes_runtime may break file uploads and chunked response - // processing; see bug #4543. Don't use ini_get() here; see bug #16440. - if ($magicQuotes = get_magic_quotes_runtime()) { - set_magic_quotes_runtime(false); - } - // force using single byte encoding if mbstring extension overloads - // strlen() and substr(); see bug #1781, bug #10605 - if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { - $oldEncoding = mb_internal_encoding(); - mb_internal_encoding('8bit'); - } - - try { - $response = $this->adapter->sendRequest($this); - } catch (Exception $e) { - } - // cleanup in either case (poor man's "finally" clause) - if ($magicQuotes) { - set_magic_quotes_runtime(true); - } - if (!empty($oldEncoding)) { - mb_internal_encoding($oldEncoding); - } - // rethrow the exception - if (!empty($e)) { - throw $e; - } - return $response; - } - - /** - * Wrapper around fopen()/fstat() used by setBody() and addUpload() - * - * @param string|resource $file file name or pointer to open file - * @param bool $detectType whether to try autodetecting MIME - * type of file, will only work if $file is a - * filename, not pointer - * - * @return array array('fp' => file pointer, 'size' => file size, 'type' => MIME type) - * @throws HTTP_Request2_LogicException - */ - protected function fopenWrapper($file, $detectType = false) - { - if (!is_string($file) && !is_resource($file)) { - throw new HTTP_Request2_LogicException( - "Filename or file pointer resource expected", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $fileData = array( - 'fp' => is_string($file)? null: $file, - 'type' => 'application/octet-stream', - 'size' => 0 - ); - if (is_string($file)) { - if (!($fileData['fp'] = @fopen($file, 'rb'))) { - $error = error_get_last(); - throw new HTTP_Request2_LogicException( - $error['message'], HTTP_Request2_Exception::READ_ERROR - ); - } - if ($detectType) { - $fileData['type'] = self::detectMimeType($file); - } - } - if (!($stat = fstat($fileData['fp']))) { - throw new HTTP_Request2_LogicException( - "fstat() call failed", HTTP_Request2_Exception::READ_ERROR - ); - } - $fileData['size'] = $stat['size']; - - return $fileData; - } - - /** - * Tries to detect MIME type of a file - * - * The method will try to use fileinfo extension if it is available, - * deprecated mime_content_type() function in the other case. If neither - * works, default 'application/octet-stream' MIME type is returned - * - * @param string $filename file name - * - * @return string file MIME type - */ - protected static function detectMimeType($filename) - { - // finfo extension from PECL available - if (function_exists('finfo_open')) { - if (!isset(self::$_fileinfoDb)) { - self::$_fileinfoDb = @finfo_open(FILEINFO_MIME); - } - if (self::$_fileinfoDb) { - $info = finfo_file(self::$_fileinfoDb, $filename); - } - } - // (deprecated) mime_content_type function available - if (empty($info) && function_exists('mime_content_type')) { - return mime_content_type($filename); - } - return empty($info)? 'application/octet-stream': $info; - } -} -?> diff --git a/libs/PEAR.1.9.5/HTTP/Request2/Adapter.php b/libs/PEAR.1.9.5/HTTP/Request2/Adapter.php deleted file mode 100644 index 4e4b0b10a..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/Adapter.php +++ /dev/null @@ -1,137 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Class representing a HTTP response - */ -require_once 'HTTP/Request2/Response.php'; - -/** - * Base class for HTTP_Request2 adapters - * - * HTTP_Request2 class itself only defines methods for aggregating the request - * data, all actual work of sending the request to the remote server and - * receiving its response is performed by adapters. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -abstract class HTTP_Request2_Adapter -{ - /** - * A list of methods that MUST NOT have a request body, per RFC 2616 - * @var array - */ - protected static $bodyDisallowed = array('TRACE'); - - /** - * Methods having defined semantics for request body - * - * Content-Length header (indicating that the body follows, section 4.3 of - * RFC 2616) will be sent for these methods even if no body was added - * - * @var array - * @link http://pear.php.net/bugs/bug.php?id=12900 - * @link http://pear.php.net/bugs/bug.php?id=14740 - */ - protected static $bodyRequired = array('POST', 'PUT'); - - /** - * Request being sent - * @var HTTP_Request2 - */ - protected $request; - - /** - * Request body - * @var string|resource|HTTP_Request2_MultipartBody - * @see HTTP_Request2::getBody() - */ - protected $requestBody; - - /** - * Length of the request body - * @var integer - */ - protected $contentLength; - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - abstract public function sendRequest(HTTP_Request2 $request); - - /** - * Calculates length of the request body, adds proper headers - * - * @param array &$headers associative array of request headers, this method - * will add proper 'Content-Length' and 'Content-Type' - * headers to this array (or remove them if not needed) - */ - protected function calculateRequestLength(&$headers) - { - $this->requestBody = $this->request->getBody(); - - if (is_string($this->requestBody)) { - $this->contentLength = strlen($this->requestBody); - } elseif (is_resource($this->requestBody)) { - $stat = fstat($this->requestBody); - $this->contentLength = $stat['size']; - rewind($this->requestBody); - } else { - $this->contentLength = $this->requestBody->getLength(); - $headers['content-type'] = 'multipart/form-data; boundary=' . - $this->requestBody->getBoundary(); - $this->requestBody->rewind(); - } - - if (in_array($this->request->getMethod(), self::$bodyDisallowed) - || 0 == $this->contentLength - ) { - // No body: send a Content-Length header nonetheless (request #12900), - // but do that only for methods that require a body (bug #14740) - if (in_array($this->request->getMethod(), self::$bodyRequired)) { - $headers['content-length'] = 0; - } else { - unset($headers['content-length']); - // if the method doesn't require a body and doesn't have a - // body, don't send a Content-Type header. (request #16799) - unset($headers['content-type']); - } - } else { - if (empty($headers['content-type'])) { - $headers['content-type'] = 'application/x-www-form-urlencoded'; - } - // Content-Length should not be sent for chunked Transfer-Encoding (bug #20125) - if (!isset($headers['transfer-encoding'])) { - $headers['content-length'] = $this->contentLength; - } - } - } -} -?> diff --git a/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Curl.php b/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Curl.php deleted file mode 100644 index ef75b8c95..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Curl.php +++ /dev/null @@ -1,567 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for HTTP_Request2 adapters - */ -require_once 'HTTP/Request2/Adapter.php'; - -/** - * Adapter for HTTP_Request2 wrapping around cURL extension - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter -{ - /** - * Mapping of header names to cURL options - * @var array - */ - protected static $headerMap = array( - 'accept-encoding' => CURLOPT_ENCODING, - 'cookie' => CURLOPT_COOKIE, - 'referer' => CURLOPT_REFERER, - 'user-agent' => CURLOPT_USERAGENT - ); - - /** - * Mapping of SSL context options to cURL options - * @var array - */ - protected static $sslContextMap = array( - 'ssl_verify_peer' => CURLOPT_SSL_VERIFYPEER, - 'ssl_cafile' => CURLOPT_CAINFO, - 'ssl_capath' => CURLOPT_CAPATH, - 'ssl_local_cert' => CURLOPT_SSLCERT, - 'ssl_passphrase' => CURLOPT_SSLCERTPASSWD - ); - - /** - * Mapping of CURLE_* constants to Exception subclasses and error codes - * @var array - */ - protected static $errorMap = array( - CURLE_UNSUPPORTED_PROTOCOL => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::NON_HTTP_REDIRECT), - CURLE_COULDNT_RESOLVE_PROXY => array('HTTP_Request2_ConnectionException'), - CURLE_COULDNT_RESOLVE_HOST => array('HTTP_Request2_ConnectionException'), - CURLE_COULDNT_CONNECT => array('HTTP_Request2_ConnectionException'), - // error returned from write callback - CURLE_WRITE_ERROR => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::NON_HTTP_REDIRECT), - CURLE_OPERATION_TIMEOUTED => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::TIMEOUT), - CURLE_HTTP_RANGE_ERROR => array('HTTP_Request2_MessageException'), - CURLE_SSL_CONNECT_ERROR => array('HTTP_Request2_ConnectionException'), - CURLE_LIBRARY_NOT_FOUND => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_FUNCTION_NOT_FOUND => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_ABORTED_BY_CALLBACK => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::NON_HTTP_REDIRECT), - CURLE_TOO_MANY_REDIRECTS => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::TOO_MANY_REDIRECTS), - CURLE_SSL_PEER_CERTIFICATE => array('HTTP_Request2_ConnectionException'), - CURLE_GOT_NOTHING => array('HTTP_Request2_MessageException'), - CURLE_SSL_ENGINE_NOTFOUND => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_SSL_ENGINE_SETFAILED => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_SEND_ERROR => array('HTTP_Request2_MessageException'), - CURLE_RECV_ERROR => array('HTTP_Request2_MessageException'), - CURLE_SSL_CERTPROBLEM => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::INVALID_ARGUMENT), - CURLE_SSL_CIPHER => array('HTTP_Request2_ConnectionException'), - CURLE_SSL_CACERT => array('HTTP_Request2_ConnectionException'), - CURLE_BAD_CONTENT_ENCODING => array('HTTP_Request2_MessageException'), - ); - - /** - * Response being received - * @var HTTP_Request2_Response - */ - protected $response; - - /** - * Whether 'sentHeaders' event was sent to observers - * @var boolean - */ - protected $eventSentHeaders = false; - - /** - * Whether 'receivedHeaders' event was sent to observers - * @var boolean - */ - protected $eventReceivedHeaders = false; - - /** - * Position within request body - * @var integer - * @see callbackReadBody() - */ - protected $position = 0; - - /** - * Information about last transfer, as returned by curl_getinfo() - * @var array - */ - protected $lastInfo; - - /** - * Creates a subclass of HTTP_Request2_Exception from curl error data - * - * @param resource $ch curl handle - * - * @return HTTP_Request2_Exception - */ - protected static function wrapCurlError($ch) - { - $nativeCode = curl_errno($ch); - $message = 'Curl error: ' . curl_error($ch); - if (!isset(self::$errorMap[$nativeCode])) { - return new HTTP_Request2_Exception($message, 0, $nativeCode); - } else { - $class = self::$errorMap[$nativeCode][0]; - $code = empty(self::$errorMap[$nativeCode][1]) - ? 0 : self::$errorMap[$nativeCode][1]; - return new $class($message, $code, $nativeCode); - } - } - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - if (!extension_loaded('curl')) { - throw new HTTP_Request2_LogicException( - 'cURL extension not available', HTTP_Request2_Exception::MISCONFIGURATION - ); - } - - $this->request = $request; - $this->response = null; - $this->position = 0; - $this->eventSentHeaders = false; - $this->eventReceivedHeaders = false; - - try { - if (false === curl_exec($ch = $this->createCurlHandle())) { - $e = self::wrapCurlError($ch); - } - } catch (Exception $e) { - } - if (isset($ch)) { - $this->lastInfo = curl_getinfo($ch); - curl_close($ch); - } - - $response = $this->response; - unset($this->request, $this->requestBody, $this->response); - - if (!empty($e)) { - throw $e; - } - - if ($jar = $request->getCookieJar()) { - $jar->addCookiesFromResponse($response, $request->getUrl()); - } - - if (0 < $this->lastInfo['size_download']) { - $request->setLastEvent('receivedBody', $response); - } - return $response; - } - - /** - * Returns information about last transfer - * - * @return array associative array as returned by curl_getinfo() - */ - public function getInfo() - { - return $this->lastInfo; - } - - /** - * Creates a new cURL handle and populates it with data from the request - * - * @return resource a cURL handle, as created by curl_init() - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_NotImplementedException - */ - protected function createCurlHandle() - { - $ch = curl_init(); - - curl_setopt_array($ch, array( - // setup write callbacks - CURLOPT_HEADERFUNCTION => array($this, 'callbackWriteHeader'), - CURLOPT_WRITEFUNCTION => array($this, 'callbackWriteBody'), - // buffer size - CURLOPT_BUFFERSIZE => $this->request->getConfig('buffer_size'), - // connection timeout - CURLOPT_CONNECTTIMEOUT => $this->request->getConfig('connect_timeout'), - // save full outgoing headers, in case someone is interested - CURLINFO_HEADER_OUT => true, - // request url - CURLOPT_URL => $this->request->getUrl()->getUrl() - )); - - // set up redirects - if (!$this->request->getConfig('follow_redirects')) { - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); - } else { - if (!@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true)) { - throw new HTTP_Request2_LogicException( - 'Redirect support in curl is unavailable due to open_basedir or safe_mode setting', - HTTP_Request2_Exception::MISCONFIGURATION - ); - } - curl_setopt($ch, CURLOPT_MAXREDIRS, $this->request->getConfig('max_redirects')); - // limit redirects to http(s), works in 5.2.10+ - if (defined('CURLOPT_REDIR_PROTOCOLS')) { - curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); - } - // works in 5.3.2+, http://bugs.php.net/bug.php?id=49571 - if ($this->request->getConfig('strict_redirects') && defined('CURLOPT_POSTREDIR')) { - curl_setopt($ch, CURLOPT_POSTREDIR, 3); - } - } - - // set local IP via CURLOPT_INTERFACE (request #19515) - if ($ip = $this->request->getConfig('local_ip')) { - curl_setopt($ch, CURLOPT_INTERFACE, $ip); - } - - // request timeout - if ($timeout = $this->request->getConfig('timeout')) { - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); - } - - // set HTTP version - switch ($this->request->getConfig('protocol_version')) { - case '1.0': - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); - break; - case '1.1': - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); - } - - // set request method - switch ($this->request->getMethod()) { - case HTTP_Request2::METHOD_GET: - curl_setopt($ch, CURLOPT_HTTPGET, true); - break; - case HTTP_Request2::METHOD_POST: - curl_setopt($ch, CURLOPT_POST, true); - break; - case HTTP_Request2::METHOD_HEAD: - curl_setopt($ch, CURLOPT_NOBODY, true); - break; - case HTTP_Request2::METHOD_PUT: - curl_setopt($ch, CURLOPT_UPLOAD, true); - break; - default: - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->request->getMethod()); - } - - // set proxy, if needed - if ($host = $this->request->getConfig('proxy_host')) { - if (!($port = $this->request->getConfig('proxy_port'))) { - throw new HTTP_Request2_LogicException( - 'Proxy port not provided', HTTP_Request2_Exception::MISSING_VALUE - ); - } - curl_setopt($ch, CURLOPT_PROXY, $host . ':' . $port); - if ($user = $this->request->getConfig('proxy_user')) { - curl_setopt( - $ch, CURLOPT_PROXYUSERPWD, - $user . ':' . $this->request->getConfig('proxy_password') - ); - switch ($this->request->getConfig('proxy_auth_scheme')) { - case HTTP_Request2::AUTH_BASIC: - curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); - break; - case HTTP_Request2::AUTH_DIGEST: - curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST); - } - } - if ($type = $this->request->getConfig('proxy_type')) { - switch ($type) { - case 'http': - curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); - break; - case 'socks5': - curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); - break; - default: - throw new HTTP_Request2_NotImplementedException( - "Proxy type '{$type}' is not supported" - ); - } - } - } - - // set authentication data - if ($auth = $this->request->getAuth()) { - curl_setopt($ch, CURLOPT_USERPWD, $auth['user'] . ':' . $auth['password']); - switch ($auth['scheme']) { - case HTTP_Request2::AUTH_BASIC: - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - break; - case HTTP_Request2::AUTH_DIGEST: - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); - } - } - - // set SSL options - foreach ($this->request->getConfig() as $name => $value) { - if ('ssl_verify_host' == $name && null !== $value) { - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $value? 2: 0); - } elseif (isset(self::$sslContextMap[$name]) && null !== $value) { - curl_setopt($ch, self::$sslContextMap[$name], $value); - } - } - - $headers = $this->request->getHeaders(); - // make cURL automagically send proper header - if (!isset($headers['accept-encoding'])) { - $headers['accept-encoding'] = ''; - } - - if (($jar = $this->request->getCookieJar()) - && ($cookies = $jar->getMatching($this->request->getUrl(), true)) - ) { - $headers['cookie'] = (empty($headers['cookie'])? '': $headers['cookie'] . '; ') . $cookies; - } - - // set headers having special cURL keys - foreach (self::$headerMap as $name => $option) { - if (isset($headers[$name])) { - curl_setopt($ch, $option, $headers[$name]); - unset($headers[$name]); - } - } - - $this->calculateRequestLength($headers); - if (isset($headers['content-length']) || isset($headers['transfer-encoding'])) { - $this->workaroundPhpBug47204($ch, $headers); - } - - // set headers not having special keys - $headersFmt = array(); - foreach ($headers as $name => $value) { - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - $headersFmt[] = $canonicalName . ': ' . $value; - } - curl_setopt($ch, CURLOPT_HTTPHEADER, $headersFmt); - - return $ch; - } - - /** - * Workaround for PHP bug #47204 that prevents rewinding request body - * - * The workaround consists of reading the entire request body into memory - * and setting it as CURLOPT_POSTFIELDS, so it isn't recommended for large - * file uploads, use Socket adapter instead. - * - * @param resource $ch cURL handle - * @param array &$headers Request headers - */ - protected function workaroundPhpBug47204($ch, &$headers) - { - // no redirects, no digest auth -> probably no rewind needed - if (!$this->request->getConfig('follow_redirects') - && (!($auth = $this->request->getAuth()) - || HTTP_Request2::AUTH_DIGEST != $auth['scheme']) - ) { - curl_setopt($ch, CURLOPT_READFUNCTION, array($this, 'callbackReadBody')); - - } else { - // rewind may be needed, read the whole body into memory - if ($this->requestBody instanceof HTTP_Request2_MultipartBody) { - $this->requestBody = $this->requestBody->__toString(); - - } elseif (is_resource($this->requestBody)) { - $fp = $this->requestBody; - $this->requestBody = ''; - while (!feof($fp)) { - $this->requestBody .= fread($fp, 16384); - } - } - // curl hangs up if content-length is present - unset($headers['content-length']); - curl_setopt($ch, CURLOPT_POSTFIELDS, $this->requestBody); - } - } - - /** - * Callback function called by cURL for reading the request body - * - * @param resource $ch cURL handle - * @param resource $fd file descriptor (not used) - * @param integer $length maximum length of data to return - * - * @return string part of the request body, up to $length bytes - */ - protected function callbackReadBody($ch, $fd, $length) - { - if (!$this->eventSentHeaders) { - $this->request->setLastEvent( - 'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT) - ); - $this->eventSentHeaders = true; - } - if (in_array($this->request->getMethod(), self::$bodyDisallowed) - || 0 == $this->contentLength || $this->position >= $this->contentLength - ) { - return ''; - } - if (is_string($this->requestBody)) { - $string = substr($this->requestBody, $this->position, $length); - } elseif (is_resource($this->requestBody)) { - $string = fread($this->requestBody, $length); - } else { - $string = $this->requestBody->read($length); - } - $this->request->setLastEvent('sentBodyPart', strlen($string)); - $this->position += strlen($string); - return $string; - } - - /** - * Callback function called by cURL for saving the response headers - * - * @param resource $ch cURL handle - * @param string $string response header (with trailing CRLF) - * - * @return integer number of bytes saved - * @see HTTP_Request2_Response::parseHeaderLine() - */ - protected function callbackWriteHeader($ch, $string) - { - // we may receive a second set of headers if doing e.g. digest auth - if ($this->eventReceivedHeaders || !$this->eventSentHeaders) { - // don't bother with 100-Continue responses (bug #15785) - if (!$this->eventSentHeaders - || $this->response->getStatus() >= 200 - ) { - $this->request->setLastEvent( - 'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT) - ); - } - $upload = curl_getinfo($ch, CURLINFO_SIZE_UPLOAD); - // if body wasn't read by a callback, send event with total body size - if ($upload > $this->position) { - $this->request->setLastEvent( - 'sentBodyPart', $upload - $this->position - ); - $this->position = $upload; - } - if ($upload && (!$this->eventSentHeaders - || $this->response->getStatus() >= 200) - ) { - $this->request->setLastEvent('sentBody', $upload); - } - $this->eventSentHeaders = true; - // we'll need a new response object - if ($this->eventReceivedHeaders) { - $this->eventReceivedHeaders = false; - $this->response = null; - } - } - if (empty($this->response)) { - $this->response = new HTTP_Request2_Response( - $string, false, curl_getinfo($ch, CURLINFO_EFFECTIVE_URL) - ); - } else { - $this->response->parseHeaderLine($string); - if ('' == trim($string)) { - // don't bother with 100-Continue responses (bug #15785) - if (200 <= $this->response->getStatus()) { - $this->request->setLastEvent('receivedHeaders', $this->response); - } - - if ($this->request->getConfig('follow_redirects') && $this->response->isRedirect()) { - $redirectUrl = new Net_URL2($this->response->getHeader('location')); - - // for versions lower than 5.2.10, check the redirection URL protocol - if (!defined('CURLOPT_REDIR_PROTOCOLS') && $redirectUrl->isAbsolute() - && !in_array($redirectUrl->getScheme(), array('http', 'https')) - ) { - return -1; - } - - if ($jar = $this->request->getCookieJar()) { - $jar->addCookiesFromResponse($this->response, $this->request->getUrl()); - if (!$redirectUrl->isAbsolute()) { - $redirectUrl = $this->request->getUrl()->resolve($redirectUrl); - } - if ($cookies = $jar->getMatching($redirectUrl, true)) { - curl_setopt($ch, CURLOPT_COOKIE, $cookies); - } - } - } - $this->eventReceivedHeaders = true; - } - } - return strlen($string); - } - - /** - * Callback function called by cURL for saving the response body - * - * @param resource $ch cURL handle (not used) - * @param string $string part of the response body - * - * @return integer number of bytes saved - * @throws HTTP_Request2_MessageException - * @see HTTP_Request2_Response::appendBody() - */ - protected function callbackWriteBody($ch, $string) - { - // cURL calls WRITEFUNCTION callback without calling HEADERFUNCTION if - // response doesn't start with proper HTTP status line (see bug #15716) - if (empty($this->response)) { - throw new HTTP_Request2_MessageException( - "Malformed response: {$string}", - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } - if ($this->request->getConfig('store_body')) { - $this->response->appendBody($string); - } - $this->request->setLastEvent('receivedBodyPart', $string); - return strlen($string); - } -} -?> diff --git a/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Mock.php b/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Mock.php deleted file mode 100644 index d6e274ab9..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Mock.php +++ /dev/null @@ -1,166 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for HTTP_Request2 adapters - */ -require_once 'HTTP/Request2/Adapter.php'; - -/** - * Mock adapter intended for testing - * - * Can be used to test applications depending on HTTP_Request2 package without - * actually performing any HTTP requests. This adapter will return responses - * previously added via addResponse() - * - * $mock = new HTTP_Request2_Adapter_Mock(); - * $mock->addResponse("HTTP/1.1 ... "); - * - * $request = new HTTP_Request2(); - * $request->setAdapter($mock); - * - * // This will return the response set above - * $response = $req->send(); - * - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter -{ - /** - * A queue of responses to be returned by sendRequest() - * @var array - */ - protected $responses = array(); - - /** - * Returns the next response from the queue built by addResponse() - * - * Only responses without explicit URLs or with URLs equal to request URL - * will be considered. If matching response is not found or the queue is - * empty then default empty response with status 400 will be returned, - * if an Exception object was added to the queue it will be thrown. - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - $requestUrl = (string)$request->getUrl(); - $response = null; - foreach ($this->responses as $k => $v) { - if (!$v[1] || $requestUrl == $v[1]) { - $response = $v[0]; - array_splice($this->responses, $k, 1); - break; - } - } - if (!$response) { - return self::createResponseFromString("HTTP/1.1 400 Bad Request\r\n\r\n"); - - } elseif ($response instanceof HTTP_Request2_Response) { - return $response; - - } else { - // rethrow the exception - $class = get_class($response); - $message = $response->getMessage(); - $code = $response->getCode(); - throw new $class($message, $code); - } - } - - /** - * Adds response to the queue - * - * @param mixed $response either a string, a pointer to an open file, - * an instance of HTTP_Request2_Response or Exception - * @param string $url A request URL this response should be valid for - * (see {@link http://pear.php.net/bugs/bug.php?id=19276}) - * - * @throws HTTP_Request2_Exception - */ - public function addResponse($response, $url = null) - { - if (is_string($response)) { - $response = self::createResponseFromString($response); - } elseif (is_resource($response)) { - $response = self::createResponseFromFile($response); - } elseif (!$response instanceof HTTP_Request2_Response && - !$response instanceof Exception - ) { - throw new HTTP_Request2_Exception('Parameter is not a valid response'); - } - $this->responses[] = array($response, $url); - } - - /** - * Creates a new HTTP_Request2_Response object from a string - * - * @param string $str string containing HTTP response message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public static function createResponseFromString($str) - { - $parts = preg_split('!(\r?\n){2}!m', $str, 2); - $headerLines = explode("\n", $parts[0]); - $response = new HTTP_Request2_Response(array_shift($headerLines)); - foreach ($headerLines as $headerLine) { - $response->parseHeaderLine($headerLine); - } - $response->parseHeaderLine(''); - if (isset($parts[1])) { - $response->appendBody($parts[1]); - } - return $response; - } - - /** - * Creates a new HTTP_Request2_Response object from a file - * - * @param resource $fp file pointer returned by fopen() - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public static function createResponseFromFile($fp) - { - $response = new HTTP_Request2_Response(fgets($fp)); - do { - $headerLine = fgets($fp); - $response->parseHeaderLine($headerLine); - } while ('' != trim($headerLine)); - - while (!feof($fp)) { - $response->appendBody(fread($fp, 8192)); - } - return $response; - } -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Socket.php b/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Socket.php deleted file mode 100644 index 7946b0a37..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/Adapter/Socket.php +++ /dev/null @@ -1,1121 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Base class for HTTP_Request2 adapters */ -require_once 'HTTP/Request2/Adapter.php'; - -/** Socket wrapper class */ -require_once 'HTTP/Request2/SocketWrapper.php'; - -/** - * Socket-based adapter for HTTP_Request2 - * - * This adapter uses only PHP sockets and will work on almost any PHP - * environment. Code is based on original HTTP_Request PEAR package. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter -{ - /** - * Regular expression for 'token' rule from RFC 2616 - */ - const REGEXP_TOKEN = '[^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+'; - - /** - * Regular expression for 'quoted-string' rule from RFC 2616 - */ - const REGEXP_QUOTED_STRING = '"(?>[^"\\\\]+|\\\\.)*"'; - - /** - * Connected sockets, needed for Keep-Alive support - * @var array - * @see connect() - */ - protected static $sockets = array(); - - /** - * Data for digest authentication scheme - * - * The keys for the array are URL prefixes. - * - * The values are associative arrays with data (realm, nonce, nonce-count, - * opaque...) needed for digest authentication. Stored here to prevent making - * duplicate requests to digest-protected resources after we have already - * received the challenge. - * - * @var array - */ - protected static $challenges = array(); - - /** - * Connected socket - * @var HTTP_Request2_SocketWrapper - * @see connect() - */ - protected $socket; - - /** - * Challenge used for server digest authentication - * @var array - */ - protected $serverChallenge; - - /** - * Challenge used for proxy digest authentication - * @var array - */ - protected $proxyChallenge; - - /** - * Remaining length of the current chunk, when reading chunked response - * @var integer - * @see readChunked() - */ - protected $chunkLength = 0; - - /** - * Remaining amount of redirections to follow - * - * Starts at 'max_redirects' configuration parameter and is reduced on each - * subsequent redirect. An Exception will be thrown once it reaches zero. - * - * @var integer - */ - protected $redirectCountdown = null; - - /** - * Whether to wait for "100 Continue" response before sending request body - * @var bool - */ - protected $expect100Continue = false; - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - $this->request = $request; - - try { - $keepAlive = $this->connect(); - $headers = $this->prepareHeaders(); - $this->socket->write($headers); - // provide request headers to the observer, see request #7633 - $this->request->setLastEvent('sentHeaders', $headers); - - if (!$this->expect100Continue) { - $this->writeBody(); - $response = $this->readResponse(); - - } else { - $response = $this->readResponse(); - if (!$response || 100 == $response->getStatus()) { - $this->expect100Continue = false; - // either got "100 Continue" or timed out -> send body - $this->writeBody(); - $response = $this->readResponse(); - } - } - - - if ($jar = $request->getCookieJar()) { - $jar->addCookiesFromResponse($response, $request->getUrl()); - } - - if (!$this->canKeepAlive($keepAlive, $response)) { - $this->disconnect(); - } - - if ($this->shouldUseProxyDigestAuth($response)) { - return $this->sendRequest($request); - } - if ($this->shouldUseServerDigestAuth($response)) { - return $this->sendRequest($request); - } - if ($authInfo = $response->getHeader('authentication-info')) { - $this->updateChallenge($this->serverChallenge, $authInfo); - } - if ($proxyInfo = $response->getHeader('proxy-authentication-info')) { - $this->updateChallenge($this->proxyChallenge, $proxyInfo); - } - - } catch (Exception $e) { - $this->disconnect(); - } - - unset($this->request, $this->requestBody); - - if (!empty($e)) { - $this->redirectCountdown = null; - throw $e; - } - - if (!$request->getConfig('follow_redirects') || !$response->isRedirect()) { - $this->redirectCountdown = null; - return $response; - } else { - return $this->handleRedirect($request, $response); - } - } - - /** - * Connects to the remote server - * - * @return bool whether the connection can be persistent - * @throws HTTP_Request2_Exception - */ - protected function connect() - { - $secure = 0 == strcasecmp($this->request->getUrl()->getScheme(), 'https'); - $tunnel = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod(); - $headers = $this->request->getHeaders(); - $reqHost = $this->request->getUrl()->getHost(); - if (!($reqPort = $this->request->getUrl()->getPort())) { - $reqPort = $secure? 443: 80; - } - - $httpProxy = $socksProxy = false; - if (!($host = $this->request->getConfig('proxy_host'))) { - $host = $reqHost; - $port = $reqPort; - } else { - if (!($port = $this->request->getConfig('proxy_port'))) { - throw new HTTP_Request2_LogicException( - 'Proxy port not provided', - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if ('http' == ($type = $this->request->getConfig('proxy_type'))) { - $httpProxy = true; - } elseif ('socks5' == $type) { - $socksProxy = true; - } else { - throw new HTTP_Request2_NotImplementedException( - "Proxy type '{$type}' is not supported" - ); - } - } - - if ($tunnel && !$httpProxy) { - throw new HTTP_Request2_LogicException( - "Trying to perform CONNECT request without proxy", - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if ($secure && !in_array('ssl', stream_get_transports())) { - throw new HTTP_Request2_LogicException( - 'Need OpenSSL support for https:// requests', - HTTP_Request2_Exception::MISCONFIGURATION - ); - } - - // RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive - // connection token to a proxy server... - if ($httpProxy && !$secure && !empty($headers['connection']) - && 'Keep-Alive' == $headers['connection'] - ) { - $this->request->setHeader('connection'); - } - - $keepAlive = ('1.1' == $this->request->getConfig('protocol_version') && - empty($headers['connection'])) || - (!empty($headers['connection']) && - 'Keep-Alive' == $headers['connection']); - - $options = array(); - if ($ip = $this->request->getConfig('local_ip')) { - $options['socket'] = array( - 'bindto' => (false === strpos($ip, ':') ? $ip : '[' . $ip . ']') . ':0' - ); - } - if ($secure || $tunnel) { - $options['ssl'] = array(); - foreach ($this->request->getConfig() as $name => $value) { - if ('ssl_' == substr($name, 0, 4) && null !== $value) { - if ('ssl_verify_host' == $name) { - if ($value) { - $options['ssl']['CN_match'] = $reqHost; - } - } else { - $options['ssl'][substr($name, 4)] = $value; - } - } - } - ksort($options['ssl']); - } - - // Use global request timeout if given, see feature requests #5735, #8964 - if ($timeout = $this->request->getConfig('timeout')) { - $deadline = time() + $timeout; - } else { - $deadline = null; - } - - // Changing SSL context options after connection is established does *not* - // work, we need a new connection if options change - $remote = ((!$secure || $httpProxy || $socksProxy)? 'tcp://': 'ssl://') - . $host . ':' . $port; - $socketKey = $remote . ( - ($secure && $httpProxy || $socksProxy) - ? "->{$reqHost}:{$reqPort}" : '' - ) . (empty($options)? '': ':' . serialize($options)); - unset($this->socket); - - // We use persistent connections and have a connected socket? - // Ensure that the socket is still connected, see bug #16149 - if ($keepAlive && !empty(self::$sockets[$socketKey]) - && !self::$sockets[$socketKey]->eof() - ) { - $this->socket =& self::$sockets[$socketKey]; - - } else { - if ($socksProxy) { - require_once 'HTTP/Request2/SOCKS5.php'; - - $this->socket = new HTTP_Request2_SOCKS5( - $remote, $this->request->getConfig('connect_timeout'), - $options, $this->request->getConfig('proxy_user'), - $this->request->getConfig('proxy_password') - ); - // handle request timeouts ASAP - $this->socket->setDeadline($deadline, $this->request->getConfig('timeout')); - $this->socket->connect($reqHost, $reqPort); - if (!$secure) { - $conninfo = "tcp://{$reqHost}:{$reqPort} via {$remote}"; - } else { - $this->socket->enableCrypto(); - $conninfo = "ssl://{$reqHost}:{$reqPort} via {$remote}"; - } - - } elseif ($secure && $httpProxy && !$tunnel) { - $this->establishTunnel(); - $conninfo = "ssl://{$reqHost}:{$reqPort} via {$remote}"; - - } else { - $this->socket = new HTTP_Request2_SocketWrapper( - $remote, $this->request->getConfig('connect_timeout'), $options - ); - } - $this->request->setLastEvent('connect', empty($conninfo)? $remote: $conninfo); - self::$sockets[$socketKey] =& $this->socket; - } - $this->socket->setDeadline($deadline, $this->request->getConfig('timeout')); - return $keepAlive; - } - - /** - * Establishes a tunnel to a secure remote server via HTTP CONNECT request - * - * This method will fail if 'ssl_verify_peer' is enabled. Probably because PHP - * sees that we are connected to a proxy server (duh!) rather than the server - * that presents its certificate. - * - * @link http://tools.ietf.org/html/rfc2817#section-5.2 - * @throws HTTP_Request2_Exception - */ - protected function establishTunnel() - { - $donor = new self; - $connect = new HTTP_Request2( - $this->request->getUrl(), HTTP_Request2::METHOD_CONNECT, - array_merge($this->request->getConfig(), array('adapter' => $donor)) - ); - $response = $connect->send(); - // Need any successful (2XX) response - if (200 > $response->getStatus() || 300 <= $response->getStatus()) { - throw new HTTP_Request2_ConnectionException( - 'Failed to connect via HTTPS proxy. Proxy response: ' . - $response->getStatus() . ' ' . $response->getReasonPhrase() - ); - } - $this->socket = $donor->socket; - $this->socket->enableCrypto(); - } - - /** - * Checks whether current connection may be reused or should be closed - * - * @param boolean $requestKeepAlive whether connection could - * be persistent in the first place - * @param HTTP_Request2_Response $response response object to check - * - * @return boolean - */ - protected function canKeepAlive($requestKeepAlive, HTTP_Request2_Response $response) - { - // Do not close socket on successful CONNECT request - if (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() - && 200 <= $response->getStatus() && 300 > $response->getStatus() - ) { - return true; - } - - $lengthKnown = 'chunked' == strtolower($response->getHeader('transfer-encoding')) - || null !== $response->getHeader('content-length') - // no body possible for such responses, see also request #17031 - || HTTP_Request2::METHOD_HEAD == $this->request->getMethod() - || in_array($response->getStatus(), array(204, 304)); - $persistent = 'keep-alive' == strtolower($response->getHeader('connection')) || - (null === $response->getHeader('connection') && - '1.1' == $response->getVersion()); - return $requestKeepAlive && $lengthKnown && $persistent; - } - - /** - * Disconnects from the remote server - */ - protected function disconnect() - { - if (!empty($this->socket)) { - $this->socket = null; - $this->request->setLastEvent('disconnect'); - } - } - - /** - * Handles HTTP redirection - * - * This method will throw an Exception if redirect to a non-HTTP(S) location - * is attempted, also if number of redirects performed already is equal to - * 'max_redirects' configuration parameter. - * - * @param HTTP_Request2 $request Original request - * @param HTTP_Request2_Response $response Response containing redirect - * - * @return HTTP_Request2_Response Response from a new location - * @throws HTTP_Request2_Exception - */ - protected function handleRedirect( - HTTP_Request2 $request, HTTP_Request2_Response $response - ) { - if (is_null($this->redirectCountdown)) { - $this->redirectCountdown = $request->getConfig('max_redirects'); - } - if (0 == $this->redirectCountdown) { - $this->redirectCountdown = null; - // Copying cURL behaviour - throw new HTTP_Request2_MessageException( - 'Maximum (' . $request->getConfig('max_redirects') . ') redirects followed', - HTTP_Request2_Exception::TOO_MANY_REDIRECTS - ); - } - $redirectUrl = new Net_URL2( - $response->getHeader('location'), - array(Net_URL2::OPTION_USE_BRACKETS => $request->getConfig('use_brackets')) - ); - // refuse non-HTTP redirect - if ($redirectUrl->isAbsolute() - && !in_array($redirectUrl->getScheme(), array('http', 'https')) - ) { - $this->redirectCountdown = null; - throw new HTTP_Request2_MessageException( - 'Refusing to redirect to a non-HTTP URL ' . $redirectUrl->__toString(), - HTTP_Request2_Exception::NON_HTTP_REDIRECT - ); - } - // Theoretically URL should be absolute (see http://tools.ietf.org/html/rfc2616#section-14.30), - // but in practice it is often not - if (!$redirectUrl->isAbsolute()) { - $redirectUrl = $request->getUrl()->resolve($redirectUrl); - } - $redirect = clone $request; - $redirect->setUrl($redirectUrl); - if (303 == $response->getStatus() - || (!$request->getConfig('strict_redirects') - && in_array($response->getStatus(), array(301, 302))) - ) { - $redirect->setMethod(HTTP_Request2::METHOD_GET); - $redirect->setBody(''); - } - - if (0 < $this->redirectCountdown) { - $this->redirectCountdown--; - } - return $this->sendRequest($redirect); - } - - /** - * Checks whether another request should be performed with server digest auth - * - * Several conditions should be satisfied for it to return true: - * - response status should be 401 - * - auth credentials should be set in the request object - * - response should contain WWW-Authenticate header with digest challenge - * - there is either no challenge stored for this URL or new challenge - * contains stale=true parameter (in other case we probably just failed - * due to invalid username / password) - * - * The method stores challenge values in $challenges static property - * - * @param HTTP_Request2_Response $response response to check - * - * @return boolean whether another request should be performed - * @throws HTTP_Request2_Exception in case of unsupported challenge parameters - */ - protected function shouldUseServerDigestAuth(HTTP_Request2_Response $response) - { - // no sense repeating a request if we don't have credentials - if (401 != $response->getStatus() || !$this->request->getAuth()) { - return false; - } - if (!$challenge = $this->parseDigestChallenge($response->getHeader('www-authenticate'))) { - return false; - } - - $url = $this->request->getUrl(); - $scheme = $url->getScheme(); - $host = $scheme . '://' . $url->getHost(); - if ($port = $url->getPort()) { - if ((0 == strcasecmp($scheme, 'http') && 80 != $port) - || (0 == strcasecmp($scheme, 'https') && 443 != $port) - ) { - $host .= ':' . $port; - } - } - - if (!empty($challenge['domain'])) { - $prefixes = array(); - foreach (preg_split('/\\s+/', $challenge['domain']) as $prefix) { - // don't bother with different servers - if ('/' == substr($prefix, 0, 1)) { - $prefixes[] = $host . $prefix; - } - } - } - if (empty($prefixes)) { - $prefixes = array($host . '/'); - } - - $ret = true; - foreach ($prefixes as $prefix) { - if (!empty(self::$challenges[$prefix]) - && (empty($challenge['stale']) || strcasecmp('true', $challenge['stale'])) - ) { - // probably credentials are invalid - $ret = false; - } - self::$challenges[$prefix] =& $challenge; - } - return $ret; - } - - /** - * Checks whether another request should be performed with proxy digest auth - * - * Several conditions should be satisfied for it to return true: - * - response status should be 407 - * - proxy auth credentials should be set in the request object - * - response should contain Proxy-Authenticate header with digest challenge - * - there is either no challenge stored for this proxy or new challenge - * contains stale=true parameter (in other case we probably just failed - * due to invalid username / password) - * - * The method stores challenge values in $challenges static property - * - * @param HTTP_Request2_Response $response response to check - * - * @return boolean whether another request should be performed - * @throws HTTP_Request2_Exception in case of unsupported challenge parameters - */ - protected function shouldUseProxyDigestAuth(HTTP_Request2_Response $response) - { - if (407 != $response->getStatus() || !$this->request->getConfig('proxy_user')) { - return false; - } - if (!($challenge = $this->parseDigestChallenge($response->getHeader('proxy-authenticate')))) { - return false; - } - - $key = 'proxy://' . $this->request->getConfig('proxy_host') . - ':' . $this->request->getConfig('proxy_port'); - - if (!empty(self::$challenges[$key]) - && (empty($challenge['stale']) || strcasecmp('true', $challenge['stale'])) - ) { - $ret = false; - } else { - $ret = true; - } - self::$challenges[$key] = $challenge; - return $ret; - } - - /** - * Extracts digest method challenge from (WWW|Proxy)-Authenticate header value - * - * There is a problem with implementation of RFC 2617: several of the parameters - * are defined as quoted-string there and thus may contain backslash escaped - * double quotes (RFC 2616, section 2.2). However, RFC 2617 defines unq(X) as - * just value of quoted-string X without surrounding quotes, it doesn't speak - * about removing backslash escaping. - * - * Now realm parameter is user-defined and human-readable, strange things - * happen when it contains quotes: - * - Apache allows quotes in realm, but apparently uses realm value without - * backslashes for digest computation - * - Squid allows (manually escaped) quotes there, but it is impossible to - * authorize with either escaped or unescaped quotes used in digest, - * probably it can't parse the response (?) - * - Both IE and Firefox display realm value with backslashes in - * the password popup and apparently use the same value for digest - * - * HTTP_Request2 follows IE and Firefox (and hopefully RFC 2617) in - * quoted-string handling, unfortunately that means failure to authorize - * sometimes - * - * @param string $headerValue value of WWW-Authenticate or Proxy-Authenticate header - * - * @return mixed associative array with challenge parameters, false if - * no challenge is present in header value - * @throws HTTP_Request2_NotImplementedException in case of unsupported challenge parameters - */ - protected function parseDigestChallenge($headerValue) - { - $authParam = '(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' . - self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')'; - $challenge = "!(?<=^|\\s|,)Digest ({$authParam}\\s*(,\\s*|$))+!"; - if (!preg_match($challenge, $headerValue, $matches)) { - return false; - } - - preg_match_all('!' . $authParam . '!', $matches[0], $params); - $paramsAry = array(); - $knownParams = array('realm', 'domain', 'nonce', 'opaque', 'stale', - 'algorithm', 'qop'); - for ($i = 0; $i < count($params[0]); $i++) { - // section 3.2.1: Any unrecognized directive MUST be ignored. - if (in_array($params[1][$i], $knownParams)) { - if ('"' == substr($params[2][$i], 0, 1)) { - $paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1); - } else { - $paramsAry[$params[1][$i]] = $params[2][$i]; - } - } - } - // we only support qop=auth - if (!empty($paramsAry['qop']) - && !in_array('auth', array_map('trim', explode(',', $paramsAry['qop']))) - ) { - throw new HTTP_Request2_NotImplementedException( - "Only 'auth' qop is currently supported in digest authentication, " . - "server requested '{$paramsAry['qop']}'" - ); - } - // we only support algorithm=MD5 - if (!empty($paramsAry['algorithm']) && 'MD5' != $paramsAry['algorithm']) { - throw new HTTP_Request2_NotImplementedException( - "Only 'MD5' algorithm is currently supported in digest authentication, " . - "server requested '{$paramsAry['algorithm']}'" - ); - } - - return $paramsAry; - } - - /** - * Parses [Proxy-]Authentication-Info header value and updates challenge - * - * @param array &$challenge challenge to update - * @param string $headerValue value of [Proxy-]Authentication-Info header - * - * @todo validate server rspauth response - */ - protected function updateChallenge(&$challenge, $headerValue) - { - $authParam = '!(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' . - self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')!'; - $paramsAry = array(); - - preg_match_all($authParam, $headerValue, $params); - for ($i = 0; $i < count($params[0]); $i++) { - if ('"' == substr($params[2][$i], 0, 1)) { - $paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1); - } else { - $paramsAry[$params[1][$i]] = $params[2][$i]; - } - } - // for now, just update the nonce value - if (!empty($paramsAry['nextnonce'])) { - $challenge['nonce'] = $paramsAry['nextnonce']; - $challenge['nc'] = 1; - } - } - - /** - * Creates a value for [Proxy-]Authorization header when using digest authentication - * - * @param string $user user name - * @param string $password password - * @param string $url request URL - * @param array &$challenge digest challenge parameters - * - * @return string value of [Proxy-]Authorization request header - * @link http://tools.ietf.org/html/rfc2617#section-3.2.2 - */ - protected function createDigestResponse($user, $password, $url, &$challenge) - { - if (false !== ($q = strpos($url, '?')) - && $this->request->getConfig('digest_compat_ie') - ) { - $url = substr($url, 0, $q); - } - - $a1 = md5($user . ':' . $challenge['realm'] . ':' . $password); - $a2 = md5($this->request->getMethod() . ':' . $url); - - if (empty($challenge['qop'])) { - $digest = md5($a1 . ':' . $challenge['nonce'] . ':' . $a2); - } else { - $challenge['cnonce'] = 'Req2.' . rand(); - if (empty($challenge['nc'])) { - $challenge['nc'] = 1; - } - $nc = sprintf('%08x', $challenge['nc']++); - $digest = md5( - $a1 . ':' . $challenge['nonce'] . ':' . $nc . ':' . - $challenge['cnonce'] . ':auth:' . $a2 - ); - } - return 'Digest username="' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $user) . '", ' . - 'realm="' . $challenge['realm'] . '", ' . - 'nonce="' . $challenge['nonce'] . '", ' . - 'uri="' . $url . '", ' . - 'response="' . $digest . '"' . - (!empty($challenge['opaque'])? - ', opaque="' . $challenge['opaque'] . '"': - '') . - (!empty($challenge['qop'])? - ', qop="auth", nc=' . $nc . ', cnonce="' . $challenge['cnonce'] . '"': - ''); - } - - /** - * Adds 'Authorization' header (if needed) to request headers array - * - * @param array &$headers request headers - * @param string $requestHost request host (needed for digest authentication) - * @param string $requestUrl request URL (needed for digest authentication) - * - * @throws HTTP_Request2_NotImplementedException - */ - protected function addAuthorizationHeader(&$headers, $requestHost, $requestUrl) - { - if (!($auth = $this->request->getAuth())) { - return; - } - switch ($auth['scheme']) { - case HTTP_Request2::AUTH_BASIC: - $headers['authorization'] = 'Basic ' . base64_encode( - $auth['user'] . ':' . $auth['password'] - ); - break; - - case HTTP_Request2::AUTH_DIGEST: - unset($this->serverChallenge); - $fullUrl = ('/' == $requestUrl[0])? - $this->request->getUrl()->getScheme() . '://' . - $requestHost . $requestUrl: - $requestUrl; - foreach (array_keys(self::$challenges) as $key) { - if ($key == substr($fullUrl, 0, strlen($key))) { - $headers['authorization'] = $this->createDigestResponse( - $auth['user'], $auth['password'], - $requestUrl, self::$challenges[$key] - ); - $this->serverChallenge =& self::$challenges[$key]; - break; - } - } - break; - - default: - throw new HTTP_Request2_NotImplementedException( - "Unknown HTTP authentication scheme '{$auth['scheme']}'" - ); - } - } - - /** - * Adds 'Proxy-Authorization' header (if needed) to request headers array - * - * @param array &$headers request headers - * @param string $requestUrl request URL (needed for digest authentication) - * - * @throws HTTP_Request2_NotImplementedException - */ - protected function addProxyAuthorizationHeader(&$headers, $requestUrl) - { - if (!$this->request->getConfig('proxy_host') - || !($user = $this->request->getConfig('proxy_user')) - || (0 == strcasecmp('https', $this->request->getUrl()->getScheme()) - && HTTP_Request2::METHOD_CONNECT != $this->request->getMethod()) - ) { - return; - } - - $password = $this->request->getConfig('proxy_password'); - switch ($this->request->getConfig('proxy_auth_scheme')) { - case HTTP_Request2::AUTH_BASIC: - $headers['proxy-authorization'] = 'Basic ' . base64_encode( - $user . ':' . $password - ); - break; - - case HTTP_Request2::AUTH_DIGEST: - unset($this->proxyChallenge); - $proxyUrl = 'proxy://' . $this->request->getConfig('proxy_host') . - ':' . $this->request->getConfig('proxy_port'); - if (!empty(self::$challenges[$proxyUrl])) { - $headers['proxy-authorization'] = $this->createDigestResponse( - $user, $password, - $requestUrl, self::$challenges[$proxyUrl] - ); - $this->proxyChallenge =& self::$challenges[$proxyUrl]; - } - break; - - default: - throw new HTTP_Request2_NotImplementedException( - "Unknown HTTP authentication scheme '" . - $this->request->getConfig('proxy_auth_scheme') . "'" - ); - } - } - - - /** - * Creates the string with the Request-Line and request headers - * - * @return string - * @throws HTTP_Request2_Exception - */ - protected function prepareHeaders() - { - $headers = $this->request->getHeaders(); - $url = $this->request->getUrl(); - $connect = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod(); - $host = $url->getHost(); - - $defaultPort = 0 == strcasecmp($url->getScheme(), 'https')? 443: 80; - if (($port = $url->getPort()) && $port != $defaultPort || $connect) { - $host .= ':' . (empty($port)? $defaultPort: $port); - } - // Do not overwrite explicitly set 'Host' header, see bug #16146 - if (!isset($headers['host'])) { - $headers['host'] = $host; - } - - if ($connect) { - $requestUrl = $host; - - } else { - if (!$this->request->getConfig('proxy_host') - || 'http' != $this->request->getConfig('proxy_type') - || 0 == strcasecmp($url->getScheme(), 'https') - ) { - $requestUrl = ''; - } else { - $requestUrl = $url->getScheme() . '://' . $host; - } - $path = $url->getPath(); - $query = $url->getQuery(); - $requestUrl .= (empty($path)? '/': $path) . (empty($query)? '': '?' . $query); - } - - if ('1.1' == $this->request->getConfig('protocol_version') - && extension_loaded('zlib') && !isset($headers['accept-encoding']) - ) { - $headers['accept-encoding'] = 'gzip, deflate'; - } - if (($jar = $this->request->getCookieJar()) - && ($cookies = $jar->getMatching($this->request->getUrl(), true)) - ) { - $headers['cookie'] = (empty($headers['cookie'])? '': $headers['cookie'] . '; ') . $cookies; - } - - $this->addAuthorizationHeader($headers, $host, $requestUrl); - $this->addProxyAuthorizationHeader($headers, $requestUrl); - $this->calculateRequestLength($headers); - if ('1.1' == $this->request->getConfig('protocol_version')) { - $this->updateExpectHeader($headers); - } else { - $this->expect100Continue = false; - } - - $headersStr = $this->request->getMethod() . ' ' . $requestUrl . ' HTTP/' . - $this->request->getConfig('protocol_version') . "\r\n"; - foreach ($headers as $name => $value) { - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - $headersStr .= $canonicalName . ': ' . $value . "\r\n"; - } - return $headersStr . "\r\n"; - } - - /** - * Adds or removes 'Expect: 100-continue' header from request headers - * - * Also sets the $expect100Continue property. Parsing of existing header - * is somewhat needed due to its complex structure and due to the - * requirement in section 8.2.3 of RFC 2616: - * > A client MUST NOT send an Expect request-header field (section - * > 14.20) with the "100-continue" expectation if it does not intend - * > to send a request body. - * - * @param array &$headers Array of headers prepared for the request - * - * @throws HTTP_Request2_LogicException - * @link http://pear.php.net/bugs/bug.php?id=19233 - * @link http://tools.ietf.org/html/rfc2616#section-8.2.3 - */ - protected function updateExpectHeader(&$headers) - { - $this->expect100Continue = false; - $expectations = array(); - if (isset($headers['expect'])) { - if ('' === $headers['expect']) { - // empty 'Expect' header is technically invalid, so just get rid of it - unset($headers['expect']); - return; - } - // build regexp to parse the value of existing Expect header - $expectParam = ';\s*' . self::REGEXP_TOKEN . '(?:\s*=\s*(?:' - . self::REGEXP_TOKEN . '|' - . self::REGEXP_QUOTED_STRING . '))?\s*'; - $expectExtension = self::REGEXP_TOKEN . '(?:\s*=\s*(?:' - . self::REGEXP_TOKEN . '|' - . self::REGEXP_QUOTED_STRING . ')\s*(?:' - . $expectParam . ')*)?'; - $expectItem = '!(100-continue|' . $expectExtension . ')!A'; - - $pos = 0; - $length = strlen($headers['expect']); - - while ($pos < $length) { - $pos += strspn($headers['expect'], " \t", $pos); - if (',' === substr($headers['expect'], $pos, 1)) { - $pos++; - continue; - - } elseif (!preg_match($expectItem, $headers['expect'], $m, 0, $pos)) { - throw new HTTP_Request2_LogicException( - "Cannot parse value '{$headers['expect']}' of Expect header", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - - } else { - $pos += strlen($m[0]); - if (strcasecmp('100-continue', $m[0])) { - $expectations[] = $m[0]; - } - } - } - } - - if (1024 < $this->contentLength) { - $expectations[] = '100-continue'; - $this->expect100Continue = true; - } - - if (empty($expectations)) { - unset($headers['expect']); - } else { - $headers['expect'] = implode(',', $expectations); - } - } - - /** - * Sends the request body - * - * @throws HTTP_Request2_MessageException - */ - protected function writeBody() - { - if (in_array($this->request->getMethod(), self::$bodyDisallowed) - || 0 == $this->contentLength - ) { - return; - } - - $position = 0; - $bufferSize = $this->request->getConfig('buffer_size'); - $headers = $this->request->getHeaders(); - $chunked = isset($headers['transfer-encoding']); - while ($position < $this->contentLength) { - if (is_string($this->requestBody)) { - $str = substr($this->requestBody, $position, $bufferSize); - } elseif (is_resource($this->requestBody)) { - $str = fread($this->requestBody, $bufferSize); - } else { - $str = $this->requestBody->read($bufferSize); - } - if (!$chunked) { - $this->socket->write($str); - } else { - $this->socket->write(dechex(strlen($str)) . "\r\n{$str}\r\n"); - } - // Provide the length of written string to the observer, request #7630 - $this->request->setLastEvent('sentBodyPart', strlen($str)); - $position += strlen($str); - } - - // write zero-length chunk - if ($chunked) { - $this->socket->write("0\r\n\r\n"); - } - $this->request->setLastEvent('sentBody', $this->contentLength); - } - - /** - * Reads the remote server's response - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - protected function readResponse() - { - $bufferSize = $this->request->getConfig('buffer_size'); - // http://tools.ietf.org/html/rfc2616#section-8.2.3 - // ...the client SHOULD NOT wait for an indefinite period before sending the request body - $timeout = $this->expect100Continue ? 1 : null; - - do { - try { - $response = new HTTP_Request2_Response( - $this->socket->readLine($bufferSize, $timeout), true, $this->request->getUrl() - ); - do { - $headerLine = $this->socket->readLine($bufferSize); - $response->parseHeaderLine($headerLine); - } while ('' != $headerLine); - - } catch (HTTP_Request2_MessageException $e) { - if (HTTP_Request2_Exception::TIMEOUT === $e->getCode() - && $this->expect100Continue - ) { - return null; - } - throw $e; - } - if ($this->expect100Continue && 100 == $response->getStatus()) { - return $response; - } - } while (in_array($response->getStatus(), array(100, 101))); - - $this->request->setLastEvent('receivedHeaders', $response); - - // No body possible in such responses - if (HTTP_Request2::METHOD_HEAD == $this->request->getMethod() - || (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() - && 200 <= $response->getStatus() && 300 > $response->getStatus()) - || in_array($response->getStatus(), array(204, 304)) - ) { - return $response; - } - - $chunked = 'chunked' == $response->getHeader('transfer-encoding'); - $length = $response->getHeader('content-length'); - $hasBody = false; - if ($chunked || null === $length || 0 < intval($length)) { - // RFC 2616, section 4.4: - // 3. ... If a message is received with both a - // Transfer-Encoding header field and a Content-Length header field, - // the latter MUST be ignored. - $toRead = ($chunked || null === $length)? null: $length; - $this->chunkLength = 0; - - while (!$this->socket->eof() && (is_null($toRead) || 0 < $toRead)) { - if ($chunked) { - $data = $this->readChunked($bufferSize); - } elseif (is_null($toRead)) { - $data = $this->socket->read($bufferSize); - } else { - $data = $this->socket->read(min($toRead, $bufferSize)); - $toRead -= strlen($data); - } - if ('' == $data && (!$this->chunkLength || $this->socket->eof())) { - break; - } - - $hasBody = true; - if ($this->request->getConfig('store_body')) { - $response->appendBody($data); - } - if (!in_array($response->getHeader('content-encoding'), array('identity', null))) { - $this->request->setLastEvent('receivedEncodedBodyPart', $data); - } else { - $this->request->setLastEvent('receivedBodyPart', $data); - } - } - } - - if ($hasBody) { - $this->request->setLastEvent('receivedBody', $response); - } - return $response; - } - - /** - * Reads a part of response body encoded with chunked Transfer-Encoding - * - * @param int $bufferSize buffer size to use for reading - * - * @return string - * @throws HTTP_Request2_MessageException - */ - protected function readChunked($bufferSize) - { - // at start of the next chunk? - if (0 == $this->chunkLength) { - $line = $this->socket->readLine($bufferSize); - if (!preg_match('/^([0-9a-f]+)/i', $line, $matches)) { - throw new HTTP_Request2_MessageException( - "Cannot decode chunked response, invalid chunk length '{$line}'", - HTTP_Request2_Exception::DECODE_ERROR - ); - } else { - $this->chunkLength = hexdec($matches[1]); - // Chunk with zero length indicates the end - if (0 == $this->chunkLength) { - $this->socket->readLine($bufferSize); - return ''; - } - } - } - $data = $this->socket->read(min($this->chunkLength, $bufferSize)); - $this->chunkLength -= strlen($data); - if (0 == $this->chunkLength) { - $this->socket->readLine($bufferSize); // Trailing CRLF - } - return $data; - } -} - -?> \ No newline at end of file diff --git a/libs/PEAR.1.9.5/HTTP/Request2/CookieJar.php b/libs/PEAR.1.9.5/HTTP/Request2/CookieJar.php deleted file mode 100644 index 79ac08bb7..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/CookieJar.php +++ /dev/null @@ -1,494 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Class representing a HTTP request message */ -require_once 'HTTP/Request2.php'; - -/** - * Stores cookies and passes them between HTTP requests - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_CookieJar implements Serializable -{ - /** - * Array of stored cookies - * - * The array is indexed by domain, path and cookie name - * .example.com - * / - * some_cookie => cookie data - * /subdir - * other_cookie => cookie data - * .example.org - * ... - * - * @var array - */ - protected $cookies = array(); - - /** - * Whether session cookies should be serialized when serializing the jar - * @var bool - */ - protected $serializeSession = false; - - /** - * Whether Public Suffix List should be used for domain matching - * @var bool - */ - protected $useList = true; - - /** - * Array with Public Suffix List data - * @var array - * @link http://publicsuffix.org/ - */ - protected static $psl = array(); - - /** - * Class constructor, sets various options - * - * @param bool $serializeSessionCookies Controls serializing session cookies, - * see {@link serializeSessionCookies()} - * @param bool $usePublicSuffixList Controls using Public Suffix List, - * see {@link usePublicSuffixList()} - */ - public function __construct( - $serializeSessionCookies = false, $usePublicSuffixList = true - ) { - $this->serializeSessionCookies($serializeSessionCookies); - $this->usePublicSuffixList($usePublicSuffixList); - } - - /** - * Returns current time formatted in ISO-8601 at UTC timezone - * - * @return string - */ - protected function now() - { - $dt = new DateTime(); - $dt->setTimezone(new DateTimeZone('UTC')); - return $dt->format(DateTime::ISO8601); - } - - /** - * Checks cookie array for correctness, possibly updating its 'domain', 'path' and 'expires' fields - * - * The checks are as follows: - * - cookie array should contain 'name' and 'value' fields; - * - name and value should not contain disallowed symbols; - * - 'expires' should be either empty parseable by DateTime; - * - 'domain' and 'path' should be either not empty or an URL where - * cookie was set should be provided. - * - if $setter is provided, then document at that URL should be allowed - * to set a cookie for that 'domain'. If $setter is not provided, - * then no domain checks will be made. - * - * 'expires' field will be converted to ISO8601 format from COOKIE format, - * 'domain' and 'path' will be set from setter URL if empty. - * - * @param array $cookie cookie data, as returned by - * {@link HTTP_Request2_Response::getCookies()} - * @param Net_URL2 $setter URL of the document that sent Set-Cookie header - * - * @return array Updated cookie array - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_MessageException - */ - protected function checkAndUpdateFields(array $cookie, Net_URL2 $setter = null) - { - if ($missing = array_diff(array('name', 'value'), array_keys($cookie))) { - throw new HTTP_Request2_LogicException( - "Cookie array should contain 'name' and 'value' fields", - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if (preg_match(HTTP_Request2::REGEXP_INVALID_COOKIE, $cookie['name'])) { - throw new HTTP_Request2_LogicException( - "Invalid cookie name: '{$cookie['name']}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - if (preg_match(HTTP_Request2::REGEXP_INVALID_COOKIE, $cookie['value'])) { - throw new HTTP_Request2_LogicException( - "Invalid cookie value: '{$cookie['value']}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $cookie += array('domain' => '', 'path' => '', 'expires' => null, 'secure' => false); - - // Need ISO-8601 date @ UTC timezone - if (!empty($cookie['expires']) - && !preg_match('/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+0000$/', $cookie['expires']) - ) { - try { - $dt = new DateTime($cookie['expires']); - $dt->setTimezone(new DateTimeZone('UTC')); - $cookie['expires'] = $dt->format(DateTime::ISO8601); - } catch (Exception $e) { - throw new HTTP_Request2_LogicException($e->getMessage()); - } - } - - if (empty($cookie['domain']) || empty($cookie['path'])) { - if (!$setter) { - throw new HTTP_Request2_LogicException( - 'Cookie misses domain and/or path component, cookie setter URL needed', - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if (empty($cookie['domain'])) { - if ($host = $setter->getHost()) { - $cookie['domain'] = $host; - } else { - throw new HTTP_Request2_LogicException( - 'Setter URL does not contain host part, can\'t set cookie domain', - HTTP_Request2_Exception::MISSING_VALUE - ); - } - } - if (empty($cookie['path'])) { - $path = $setter->getPath(); - $cookie['path'] = empty($path)? '/': substr($path, 0, strrpos($path, '/') + 1); - } - } - - if ($setter && !$this->domainMatch($setter->getHost(), $cookie['domain'])) { - throw new HTTP_Request2_MessageException( - "Domain " . $setter->getHost() . " cannot set cookies for " - . $cookie['domain'] - ); - } - - return $cookie; - } - - /** - * Stores a cookie in the jar - * - * @param array $cookie cookie data, as returned by - * {@link HTTP_Request2_Response::getCookies()} - * @param Net_URL2 $setter URL of the document that sent Set-Cookie header - * - * @throws HTTP_Request2_Exception - */ - public function store(array $cookie, Net_URL2 $setter = null) - { - $cookie = $this->checkAndUpdateFields($cookie, $setter); - - if (strlen($cookie['value']) - && (is_null($cookie['expires']) || $cookie['expires'] > $this->now()) - ) { - if (!isset($this->cookies[$cookie['domain']])) { - $this->cookies[$cookie['domain']] = array(); - } - if (!isset($this->cookies[$cookie['domain']][$cookie['path']])) { - $this->cookies[$cookie['domain']][$cookie['path']] = array(); - } - $this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']] = $cookie; - - } elseif (isset($this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']])) { - unset($this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']]); - } - } - - /** - * Adds cookies set in HTTP response to the jar - * - * @param HTTP_Request2_Response $response HTTP response message - * @param Net_URL2 $setter original request URL, needed for - * setting default domain/path - */ - public function addCookiesFromResponse(HTTP_Request2_Response $response, Net_URL2 $setter) - { - foreach ($response->getCookies() as $cookie) { - $this->store($cookie, $setter); - } - } - - /** - * Returns all cookies matching a given request URL - * - * The following checks are made: - * - cookie domain should match request host - * - cookie path should be a prefix for request path - * - 'secure' cookies will only be sent for HTTPS requests - * - * @param Net_URL2 $url Request url - * @param bool $asString Whether to return cookies as string for "Cookie: " header - * - * @return array|string Matching cookies - */ - public function getMatching(Net_URL2 $url, $asString = false) - { - $host = $url->getHost(); - $path = $url->getPath(); - $secure = 0 == strcasecmp($url->getScheme(), 'https'); - - $matched = $ret = array(); - foreach (array_keys($this->cookies) as $domain) { - if ($this->domainMatch($host, $domain)) { - foreach (array_keys($this->cookies[$domain]) as $cPath) { - if (0 === strpos($path, $cPath)) { - foreach ($this->cookies[$domain][$cPath] as $name => $cookie) { - if (!$cookie['secure'] || $secure) { - $matched[$name][strlen($cookie['path'])] = $cookie; - } - } - } - } - } - } - foreach ($matched as $cookies) { - krsort($cookies); - $ret = array_merge($ret, $cookies); - } - if (!$asString) { - return $ret; - } else { - $str = ''; - foreach ($ret as $c) { - $str .= (empty($str)? '': '; ') . $c['name'] . '=' . $c['value']; - } - return $str; - } - } - - /** - * Returns all cookies stored in a jar - * - * @return array - */ - public function getAll() - { - $cookies = array(); - foreach (array_keys($this->cookies) as $domain) { - foreach (array_keys($this->cookies[$domain]) as $path) { - foreach ($this->cookies[$domain][$path] as $name => $cookie) { - $cookies[] = $cookie; - } - } - } - return $cookies; - } - - /** - * Sets whether session cookies should be serialized when serializing the jar - * - * @param boolean $serialize serialize? - */ - public function serializeSessionCookies($serialize) - { - $this->serializeSession = (bool)$serialize; - } - - /** - * Sets whether Public Suffix List should be used for restricting cookie-setting - * - * Without PSL {@link domainMatch()} will only prevent setting cookies for - * top-level domains like '.com' or '.org'. However, it will not prevent - * setting a cookie for '.co.uk' even though only third-level registrations - * are possible in .uk domain. - * - * With the List it is possible to find the highest level at which a domain - * may be registered for a particular top-level domain and consequently - * prevent cookies set for '.co.uk' or '.msk.ru'. The same list is used by - * Firefox, Chrome and Opera browsers to restrict cookie setting. - * - * Note that PSL is licensed differently to HTTP_Request2 package (refer to - * the license information in public-suffix-list.php), so you can disable - * its use if this is an issue for you. - * - * @param boolean $useList use the list? - * - * @link http://publicsuffix.org/learn/ - */ - public function usePublicSuffixList($useList) - { - $this->useList = (bool)$useList; - } - - /** - * Returns string representation of object - * - * @return string - * - * @see Serializable::serialize() - */ - public function serialize() - { - $cookies = $this->getAll(); - if (!$this->serializeSession) { - for ($i = count($cookies) - 1; $i >= 0; $i--) { - if (empty($cookies[$i]['expires'])) { - unset($cookies[$i]); - } - } - } - return serialize(array( - 'cookies' => $cookies, - 'serializeSession' => $this->serializeSession, - 'useList' => $this->useList - )); - } - - /** - * Constructs the object from serialized string - * - * @param string $serialized string representation - * - * @see Serializable::unserialize() - */ - public function unserialize($serialized) - { - $data = unserialize($serialized); - $now = $this->now(); - $this->serializeSessionCookies($data['serializeSession']); - $this->usePublicSuffixList($data['useList']); - foreach ($data['cookies'] as $cookie) { - if (!empty($cookie['expires']) && $cookie['expires'] <= $now) { - continue; - } - if (!isset($this->cookies[$cookie['domain']])) { - $this->cookies[$cookie['domain']] = array(); - } - if (!isset($this->cookies[$cookie['domain']][$cookie['path']])) { - $this->cookies[$cookie['domain']][$cookie['path']] = array(); - } - $this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']] = $cookie; - } - } - - /** - * Checks whether a cookie domain matches a request host. - * - * The method is used by {@link store()} to check for whether a document - * at given URL can set a cookie with a given domain attribute and by - * {@link getMatching()} to find cookies matching the request URL. - * - * @param string $requestHost request host - * @param string $cookieDomain cookie domain - * - * @return bool match success - */ - public function domainMatch($requestHost, $cookieDomain) - { - if ($requestHost == $cookieDomain) { - return true; - } - // IP address, we require exact match - if (preg_match('/^(?:\d{1,3}\.){3}\d{1,3}$/', $requestHost)) { - return false; - } - if ('.' != $cookieDomain[0]) { - $cookieDomain = '.' . $cookieDomain; - } - // prevents setting cookies for '.com' and similar domains - if (!$this->useList && substr_count($cookieDomain, '.') < 2 - || $this->useList && !self::getRegisteredDomain($cookieDomain) - ) { - return false; - } - return substr('.' . $requestHost, -strlen($cookieDomain)) == $cookieDomain; - } - - /** - * Removes subdomains to get the registered domain (the first after top-level) - * - * The method will check Public Suffix List to find out where top-level - * domain ends and registered domain starts. It will remove domain parts - * to the left of registered one. - * - * @param string $domain domain name - * - * @return string|bool registered domain, will return false if $domain is - * either invalid or a TLD itself - */ - public static function getRegisteredDomain($domain) - { - $domainParts = explode('.', ltrim($domain, '.')); - - // load the list if needed - if (empty(self::$psl)) { - $path = '@data_dir@' . DIRECTORY_SEPARATOR . 'HTTP_Request2'; - if (0 === strpos($path, '@' . 'data_dir@')) { - $path = realpath( - dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' - . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' - ); - } - self::$psl = include_once $path . DIRECTORY_SEPARATOR . 'public-suffix-list.php'; - } - - if (!($result = self::checkDomainsList($domainParts, self::$psl))) { - // known TLD, invalid domain name - return false; - } - - // unknown TLD - if (!strpos($result, '.')) { - // fallback to checking that domain "has at least two dots" - if (2 > ($count = count($domainParts))) { - return false; - } - return $domainParts[$count - 2] . '.' . $domainParts[$count - 1]; - } - return $result; - } - - /** - * Recursive helper method for {@link getRegisteredDomain()} - * - * @param array $domainParts remaining domain parts - * @param mixed $listNode node in {@link HTTP_Request2_CookieJar::$psl} to check - * - * @return string|null concatenated domain parts, null in case of error - */ - protected static function checkDomainsList(array $domainParts, $listNode) - { - $sub = array_pop($domainParts); - $result = null; - - if (!is_array($listNode) || is_null($sub) - || array_key_exists('!' . $sub, $listNode) - ) { - return $sub; - - } elseif (array_key_exists($sub, $listNode)) { - $result = self::checkDomainsList($domainParts, $listNode[$sub]); - - } elseif (array_key_exists('*', $listNode)) { - $result = self::checkDomainsList($domainParts, $listNode['*']); - - } else { - return $sub; - } - - return (strlen($result) > 0) ? ($result . '.' . $sub) : null; - } -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9.5/HTTP/Request2/Exception.php b/libs/PEAR.1.9.5/HTTP/Request2/Exception.php deleted file mode 100644 index d0b5d4ee0..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/Exception.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for exceptions in PEAR - */ -require_once 'PEAR/Exception.php'; - -/** - * Base exception class for HTTP_Request2 package - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=132 - */ -class HTTP_Request2_Exception extends PEAR_Exception -{ - /** An invalid argument was passed to a method */ - const INVALID_ARGUMENT = 1; - /** Some required value was not available */ - const MISSING_VALUE = 2; - /** Request cannot be processed due to errors in PHP configuration */ - const MISCONFIGURATION = 3; - /** Error reading the local file */ - const READ_ERROR = 4; - - /** Server returned a response that does not conform to HTTP protocol */ - const MALFORMED_RESPONSE = 10; - /** Failure decoding Content-Encoding or Transfer-Encoding of response */ - const DECODE_ERROR = 20; - /** Operation timed out */ - const TIMEOUT = 30; - /** Number of redirects exceeded 'max_redirects' configuration parameter */ - const TOO_MANY_REDIRECTS = 40; - /** Redirect to a protocol other than http(s):// */ - const NON_HTTP_REDIRECT = 50; - - /** - * Native error code - * @var int - */ - private $_nativeCode; - - /** - * Constructor, can set package error code and native error code - * - * @param string $message exception message - * @param int $code package error code, one of class constants - * @param int $nativeCode error code from underlying PHP extension - */ - public function __construct($message = null, $code = null, $nativeCode = null) - { - parent::__construct($message, $code); - $this->_nativeCode = $nativeCode; - } - - /** - * Returns error code produced by underlying PHP extension - * - * For Socket Adapter this may contain error number returned by - * stream_socket_client(), for Curl Adapter this will contain error number - * returned by curl_errno() - * - * @return integer - */ - public function getNativeCode() - { - return $this->_nativeCode; - } -} - -/** - * Exception thrown in case of missing features - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_NotImplementedException extends HTTP_Request2_Exception -{ -} - -/** - * Exception that represents error in the program logic - * - * This exception usually implies a programmer's error, like passing invalid - * data to methods or trying to use PHP extensions that weren't installed or - * enabled. Usually exceptions of this kind will be thrown before request even - * starts. - * - * The exception will usually contain a package error code. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_LogicException extends HTTP_Request2_Exception -{ -} - -/** - * Exception thrown when connection to a web or proxy server fails - * - * The exception will not contain a package error code, but will contain - * native error code, as returned by stream_socket_client() or curl_errno(). - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_ConnectionException extends HTTP_Request2_Exception -{ -} - -/** - * Exception thrown when sending or receiving HTTP message fails - * - * The exception may contain both package error code and native error code. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_MessageException extends HTTP_Request2_Exception -{ -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9.5/HTTP/Request2/MultipartBody.php b/libs/PEAR.1.9.5/HTTP/Request2/MultipartBody.php deleted file mode 100644 index c68b6602b..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/MultipartBody.php +++ /dev/null @@ -1,268 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Exception class for HTTP_Request2 package */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class for building multipart/form-data request body - * - * The class helps to reduce memory consumption by streaming large file uploads - * from disk, it also allows monitoring of upload progress (see request #7630) - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://tools.ietf.org/html/rfc1867 - */ -class HTTP_Request2_MultipartBody -{ - /** - * MIME boundary - * @var string - */ - private $_boundary; - - /** - * Form parameters added via {@link HTTP_Request2::addPostParameter()} - * @var array - */ - private $_params = array(); - - /** - * File uploads added via {@link HTTP_Request2::addUpload()} - * @var array - */ - private $_uploads = array(); - - /** - * Header for parts with parameters - * @var string - */ - private $_headerParam = "--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n"; - - /** - * Header for parts with uploads - * @var string - */ - private $_headerUpload = "--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\nContent-Type: %s\r\n\r\n"; - - /** - * Current position in parameter and upload arrays - * - * First number is index of "current" part, second number is position within - * "current" part - * - * @var array - */ - private $_pos = array(0, 0); - - - /** - * Constructor. Sets the arrays with POST data. - * - * @param array $params values of form fields set via - * {@link HTTP_Request2::addPostParameter()} - * @param array $uploads file uploads set via - * {@link HTTP_Request2::addUpload()} - * @param bool $useBrackets whether to append brackets to array variable names - */ - public function __construct(array $params, array $uploads, $useBrackets = true) - { - $this->_params = self::_flattenArray('', $params, $useBrackets); - foreach ($uploads as $fieldName => $f) { - if (!is_array($f['fp'])) { - $this->_uploads[] = $f + array('name' => $fieldName); - } else { - for ($i = 0; $i < count($f['fp']); $i++) { - $upload = array( - 'name' => ($useBrackets? $fieldName . '[' . $i . ']': $fieldName) - ); - foreach (array('fp', 'filename', 'size', 'type') as $key) { - $upload[$key] = $f[$key][$i]; - } - $this->_uploads[] = $upload; - } - } - } - } - - /** - * Returns the length of the body to use in Content-Length header - * - * @return integer - */ - public function getLength() - { - $boundaryLength = strlen($this->getBoundary()); - $headerParamLength = strlen($this->_headerParam) - 4 + $boundaryLength; - $headerUploadLength = strlen($this->_headerUpload) - 8 + $boundaryLength; - $length = $boundaryLength + 6; - foreach ($this->_params as $p) { - $length += $headerParamLength + strlen($p[0]) + strlen($p[1]) + 2; - } - foreach ($this->_uploads as $u) { - $length += $headerUploadLength + strlen($u['name']) + strlen($u['type']) + - strlen($u['filename']) + $u['size'] + 2; - } - return $length; - } - - /** - * Returns the boundary to use in Content-Type header - * - * @return string - */ - public function getBoundary() - { - if (empty($this->_boundary)) { - $this->_boundary = '--' . md5('PEAR-HTTP_Request2-' . microtime()); - } - return $this->_boundary; - } - - /** - * Returns next chunk of request body - * - * @param integer $length Number of bytes to read - * - * @return string Up to $length bytes of data, empty string if at end - * @throws HTTP_Request2_LogicException - */ - public function read($length) - { - $ret = ''; - $boundary = $this->getBoundary(); - $paramCount = count($this->_params); - $uploadCount = count($this->_uploads); - while ($length > 0 && $this->_pos[0] <= $paramCount + $uploadCount) { - $oldLength = $length; - if ($this->_pos[0] < $paramCount) { - $param = sprintf( - $this->_headerParam, $boundary, $this->_params[$this->_pos[0]][0] - ) . $this->_params[$this->_pos[0]][1] . "\r\n"; - $ret .= substr($param, $this->_pos[1], $length); - $length -= min(strlen($param) - $this->_pos[1], $length); - - } elseif ($this->_pos[0] < $paramCount + $uploadCount) { - $pos = $this->_pos[0] - $paramCount; - $header = sprintf( - $this->_headerUpload, $boundary, $this->_uploads[$pos]['name'], - $this->_uploads[$pos]['filename'], $this->_uploads[$pos]['type'] - ); - if ($this->_pos[1] < strlen($header)) { - $ret .= substr($header, $this->_pos[1], $length); - $length -= min(strlen($header) - $this->_pos[1], $length); - } - $filePos = max(0, $this->_pos[1] - strlen($header)); - if ($filePos < $this->_uploads[$pos]['size']) { - while ($length > 0 && !feof($this->_uploads[$pos]['fp'])) { - if (false === ($chunk = fread($this->_uploads[$pos]['fp'], $length))) { - throw new HTTP_Request2_LogicException( - 'Failed reading file upload', HTTP_Request2_Exception::READ_ERROR - ); - } - $ret .= $chunk; - $length -= strlen($chunk); - } - } - if ($length > 0) { - $start = $this->_pos[1] + ($oldLength - $length) - - strlen($header) - $this->_uploads[$pos]['size']; - $ret .= substr("\r\n", $start, $length); - $length -= min(2 - $start, $length); - } - - } else { - $closing = '--' . $boundary . "--\r\n"; - $ret .= substr($closing, $this->_pos[1], $length); - $length -= min(strlen($closing) - $this->_pos[1], $length); - } - if ($length > 0) { - $this->_pos = array($this->_pos[0] + 1, 0); - } else { - $this->_pos[1] += $oldLength; - } - } - return $ret; - } - - /** - * Sets the current position to the start of the body - * - * This allows reusing the same body in another request - */ - public function rewind() - { - $this->_pos = array(0, 0); - foreach ($this->_uploads as $u) { - rewind($u['fp']); - } - } - - /** - * Returns the body as string - * - * Note that it reads all file uploads into memory so it is a good idea not - * to use this method with large file uploads and rely on read() instead. - * - * @return string - */ - public function __toString() - { - $this->rewind(); - return $this->read($this->getLength()); - } - - - /** - * Helper function to change the (probably multidimensional) associative array - * into the simple one. - * - * @param string $name name for item - * @param mixed $values item's values - * @param bool $useBrackets whether to append [] to array variables' names - * - * @return array array with the following items: array('item name', 'item value'); - */ - private static function _flattenArray($name, $values, $useBrackets) - { - if (!is_array($values)) { - return array(array($name, $values)); - } else { - $ret = array(); - foreach ($values as $k => $v) { - if (empty($name)) { - $newName = $k; - } elseif ($useBrackets) { - $newName = $name . '[' . $k . ']'; - } else { - $newName = $name; - } - $ret = array_merge($ret, self::_flattenArray($newName, $v, $useBrackets)); - } - return $ret; - } - } -} -?> diff --git a/libs/PEAR.1.9.5/HTTP/Request2/Observer/Log.php b/libs/PEAR.1.9.5/HTTP/Request2/Observer/Log.php deleted file mode 100644 index 341e29907..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/Observer/Log.php +++ /dev/null @@ -1,192 +0,0 @@ - - * @author Alexey Borzov - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * A debug observer useful for debugging / testing. - * - * This observer logs to a log target data corresponding to the various request - * and response events, it logs by default to php://output but can be configured - * to log to a file or via the PEAR Log package. - * - * A simple example: - * - * require_once 'HTTP/Request2.php'; - * require_once 'HTTP/Request2/Observer/Log.php'; - * - * $request = new HTTP_Request2('http://www.example.com'); - * $observer = new HTTP_Request2_Observer_Log(); - * $request->attach($observer); - * $request->send(); - * - * - * A more complex example with PEAR Log: - * - * require_once 'HTTP/Request2.php'; - * require_once 'HTTP/Request2/Observer/Log.php'; - * require_once 'Log.php'; - * - * $request = new HTTP_Request2('http://www.example.com'); - * // we want to log with PEAR log - * $observer = new HTTP_Request2_Observer_Log(Log::factory('console')); - * - * // we only want to log received headers - * $observer->events = array('receivedHeaders'); - * - * $request->attach($observer); - * $request->send(); - * - * - * @category HTTP - * @package HTTP_Request2 - * @author David Jean Louis - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Observer_Log implements SplObserver -{ - // properties {{{ - - /** - * The log target, it can be a a resource or a PEAR Log instance. - * - * @var resource|Log $target - */ - protected $target = null; - - /** - * The events to log. - * - * @var array $events - */ - public $events = array( - 'connect', - 'sentHeaders', - 'sentBody', - 'receivedHeaders', - 'receivedBody', - 'disconnect', - ); - - // }}} - // __construct() {{{ - - /** - * Constructor. - * - * @param mixed $target Can be a file path (default: php://output), a resource, - * or an instance of the PEAR Log class. - * @param array $events Array of events to listen to (default: all events) - * - * @return void - */ - public function __construct($target = 'php://output', array $events = array()) - { - if (!empty($events)) { - $this->events = $events; - } - if (is_resource($target) || $target instanceof Log) { - $this->target = $target; - } elseif (false === ($this->target = @fopen($target, 'ab'))) { - throw new HTTP_Request2_Exception("Unable to open '{$target}'"); - } - } - - // }}} - // update() {{{ - - /** - * Called when the request notifies us of an event. - * - * @param HTTP_Request2 $subject The HTTP_Request2 instance - * - * @return void - */ - public function update(SplSubject $subject) - { - $event = $subject->getLastEvent(); - if (!in_array($event['name'], $this->events)) { - return; - } - - switch ($event['name']) { - case 'connect': - $this->log('* Connected to ' . $event['data']); - break; - case 'sentHeaders': - $headers = explode("\r\n", $event['data']); - array_pop($headers); - foreach ($headers as $header) { - $this->log('> ' . $header); - } - break; - case 'sentBody': - $this->log('> ' . $event['data'] . ' byte(s) sent'); - break; - case 'receivedHeaders': - $this->log(sprintf( - '< HTTP/%s %s %s', $event['data']->getVersion(), - $event['data']->getStatus(), $event['data']->getReasonPhrase() - )); - $headers = $event['data']->getHeader(); - foreach ($headers as $key => $val) { - $this->log('< ' . $key . ': ' . $val); - } - $this->log('< '); - break; - case 'receivedBody': - $this->log($event['data']->getBody()); - break; - case 'disconnect': - $this->log('* Disconnected'); - break; - } - } - - // }}} - // log() {{{ - - /** - * Logs the given message to the configured target. - * - * @param string $message Message to display - * - * @return void - */ - protected function log($message) - { - if ($this->target instanceof Log) { - $this->target->debug($message); - } elseif (is_resource($this->target)) { - fwrite($this->target, $message . "\r\n"); - } - } - - // }}} -} - -?> \ No newline at end of file diff --git a/libs/PEAR.1.9.5/HTTP/Request2/Response.php b/libs/PEAR.1.9.5/HTTP/Request2/Response.php deleted file mode 100644 index d2f414cf6..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/Response.php +++ /dev/null @@ -1,631 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class representing a HTTP response - * - * The class is designed to be used in "streaming" scenario, building the - * response as it is being received: - * - * $statusLine = read_status_line(); - * $response = new HTTP_Request2_Response($statusLine); - * do { - * $headerLine = read_header_line(); - * $response->parseHeaderLine($headerLine); - * } while ($headerLine != ''); - * - * while ($chunk = read_body()) { - * $response->appendBody($chunk); - * } - * - * var_dump($response->getHeader(), $response->getCookies(), $response->getBody()); - * - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://tools.ietf.org/html/rfc2616#section-6 - */ -class HTTP_Request2_Response -{ - /** - * HTTP protocol version (e.g. 1.0, 1.1) - * @var string - */ - protected $version; - - /** - * Status code - * @var integer - * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 - */ - protected $code; - - /** - * Reason phrase - * @var string - * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 - */ - protected $reasonPhrase; - - /** - * Effective URL (may be different from original request URL in case of redirects) - * @var string - */ - protected $effectiveUrl; - - /** - * Associative array of response headers - * @var array - */ - protected $headers = array(); - - /** - * Cookies set in the response - * @var array - */ - protected $cookies = array(); - - /** - * Name of last header processed by parseHederLine() - * - * Used to handle the headers that span multiple lines - * - * @var string - */ - protected $lastHeader = null; - - /** - * Response body - * @var string - */ - protected $body = ''; - - /** - * Whether the body is still encoded by Content-Encoding - * - * cURL provides the decoded body to the callback; if we are reading from - * socket the body is still gzipped / deflated - * - * @var bool - */ - protected $bodyEncoded; - - /** - * Associative array of HTTP status code / reason phrase. - * - * @var array - * @link http://tools.ietf.org/html/rfc2616#section-10 - */ - protected static $phrases = array( - - // 1xx: Informational - Request received, continuing process - 100 => 'Continue', - 101 => 'Switching Protocols', - - // 2xx: Success - The action was successfully received, understood and - // accepted - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - - // 3xx: Redirection - Further action must be taken in order to complete - // the request - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', // 1.1 - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 307 => 'Temporary Redirect', - - // 4xx: Client Error - The request contains bad syntax or cannot be - // fulfilled - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - - // 5xx: Server Error - The server failed to fulfill an apparently - // valid request - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 509 => 'Bandwidth Limit Exceeded', - - ); - - /** - * Returns the default reason phrase for the given code or all reason phrases - * - * @param int $code Response code - * - * @return string|array|null Default reason phrase for $code if $code is given - * (null if no phrase is available), array of all - * reason phrases if $code is null - * @link http://pear.php.net/bugs/18716 - */ - public static function getDefaultReasonPhrase($code = null) - { - if (null === $code) { - return self::$phrases; - } else { - return isset(self::$phrases[$code]) ? self::$phrases[$code] : null; - } - } - - /** - * Constructor, parses the response status line - * - * @param string $statusLine Response status line (e.g. "HTTP/1.1 200 OK") - * @param bool $bodyEncoded Whether body is still encoded by Content-Encoding - * @param string $effectiveUrl Effective URL of the response - * - * @throws HTTP_Request2_MessageException if status line is invalid according to spec - */ - public function __construct($statusLine, $bodyEncoded = true, $effectiveUrl = null) - { - if (!preg_match('!^HTTP/(\d\.\d) (\d{3})(?: (.+))?!', $statusLine, $m)) { - throw new HTTP_Request2_MessageException( - "Malformed response: {$statusLine}", - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } - $this->version = $m[1]; - $this->code = intval($m[2]); - $this->reasonPhrase = !empty($m[3]) ? trim($m[3]) : self::getDefaultReasonPhrase($this->code); - $this->bodyEncoded = (bool)$bodyEncoded; - $this->effectiveUrl = (string)$effectiveUrl; - } - - /** - * Parses the line from HTTP response filling $headers array - * - * The method should be called after reading the line from socket or receiving - * it into cURL callback. Passing an empty string here indicates the end of - * response headers and triggers additional processing, so be sure to pass an - * empty string in the end. - * - * @param string $headerLine Line from HTTP response - */ - public function parseHeaderLine($headerLine) - { - $headerLine = trim($headerLine, "\r\n"); - - if ('' == $headerLine) { - // empty string signals the end of headers, process the received ones - if (!empty($this->headers['set-cookie'])) { - $cookies = is_array($this->headers['set-cookie'])? - $this->headers['set-cookie']: - array($this->headers['set-cookie']); - foreach ($cookies as $cookieString) { - $this->parseCookie($cookieString); - } - unset($this->headers['set-cookie']); - } - foreach (array_keys($this->headers) as $k) { - if (is_array($this->headers[$k])) { - $this->headers[$k] = implode(', ', $this->headers[$k]); - } - } - - } elseif (preg_match('!^([^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+):(.+)$!', $headerLine, $m)) { - // string of the form header-name: header value - $name = strtolower($m[1]); - $value = trim($m[2]); - if (empty($this->headers[$name])) { - $this->headers[$name] = $value; - } else { - if (!is_array($this->headers[$name])) { - $this->headers[$name] = array($this->headers[$name]); - } - $this->headers[$name][] = $value; - } - $this->lastHeader = $name; - - } elseif (preg_match('!^\s+(.+)$!', $headerLine, $m) && $this->lastHeader) { - // continuation of a previous header - if (!is_array($this->headers[$this->lastHeader])) { - $this->headers[$this->lastHeader] .= ' ' . trim($m[1]); - } else { - $key = count($this->headers[$this->lastHeader]) - 1; - $this->headers[$this->lastHeader][$key] .= ' ' . trim($m[1]); - } - } - } - - /** - * Parses a Set-Cookie header to fill $cookies array - * - * @param string $cookieString value of Set-Cookie header - * - * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html - */ - protected function parseCookie($cookieString) - { - $cookie = array( - 'expires' => null, - 'domain' => null, - 'path' => null, - 'secure' => false - ); - - if (!strpos($cookieString, ';')) { - // Only a name=value pair - $pos = strpos($cookieString, '='); - $cookie['name'] = trim(substr($cookieString, 0, $pos)); - $cookie['value'] = trim(substr($cookieString, $pos + 1)); - - } else { - // Some optional parameters are supplied - $elements = explode(';', $cookieString); - $pos = strpos($elements[0], '='); - $cookie['name'] = trim(substr($elements[0], 0, $pos)); - $cookie['value'] = trim(substr($elements[0], $pos + 1)); - - for ($i = 1; $i < count($elements); $i++) { - if (false === strpos($elements[$i], '=')) { - $elName = trim($elements[$i]); - $elValue = null; - } else { - list ($elName, $elValue) = array_map('trim', explode('=', $elements[$i])); - } - $elName = strtolower($elName); - if ('secure' == $elName) { - $cookie['secure'] = true; - } elseif ('expires' == $elName) { - $cookie['expires'] = str_replace('"', '', $elValue); - } elseif ('path' == $elName || 'domain' == $elName) { - $cookie[$elName] = urldecode($elValue); - } else { - $cookie[$elName] = $elValue; - } - } - } - $this->cookies[] = $cookie; - } - - /** - * Appends a string to the response body - * - * @param string $bodyChunk part of response body - */ - public function appendBody($bodyChunk) - { - $this->body .= $bodyChunk; - } - - /** - * Returns the effective URL of the response - * - * This may be different from the request URL if redirects were followed. - * - * @return string - * @link http://pear.php.net/bugs/bug.php?id=18412 - */ - public function getEffectiveUrl() - { - return $this->effectiveUrl; - } - - /** - * Returns the status code - * - * @return integer - */ - public function getStatus() - { - return $this->code; - } - - /** - * Returns the reason phrase - * - * @return string - */ - public function getReasonPhrase() - { - return $this->reasonPhrase; - } - - /** - * Whether response is a redirect that can be automatically handled by HTTP_Request2 - * - * @return bool - */ - public function isRedirect() - { - return in_array($this->code, array(300, 301, 302, 303, 307)) - && isset($this->headers['location']); - } - - /** - * Returns either the named header or all response headers - * - * @param string $headerName Name of header to return - * - * @return string|array Value of $headerName header (null if header is - * not present), array of all response headers if - * $headerName is null - */ - public function getHeader($headerName = null) - { - if (null === $headerName) { - return $this->headers; - } else { - $headerName = strtolower($headerName); - return isset($this->headers[$headerName])? $this->headers[$headerName]: null; - } - } - - /** - * Returns cookies set in response - * - * @return array - */ - public function getCookies() - { - return $this->cookies; - } - - /** - * Returns the body of the response - * - * @return string - * @throws HTTP_Request2_Exception if body cannot be decoded - */ - public function getBody() - { - if (0 == strlen($this->body) || !$this->bodyEncoded - || !in_array(strtolower($this->getHeader('content-encoding')), array('gzip', 'deflate')) - ) { - return $this->body; - - } else { - if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { - $oldEncoding = mb_internal_encoding(); - mb_internal_encoding('8bit'); - } - - try { - switch (strtolower($this->getHeader('content-encoding'))) { - case 'gzip': - $decoded = self::decodeGzip($this->body); - break; - case 'deflate': - $decoded = self::decodeDeflate($this->body); - } - } catch (Exception $e) { - } - - if (!empty($oldEncoding)) { - mb_internal_encoding($oldEncoding); - } - if (!empty($e)) { - throw $e; - } - return $decoded; - } - } - - /** - * Get the HTTP version of the response - * - * @return string - */ - public function getVersion() - { - return $this->version; - } - - /** - * Decodes the message-body encoded by gzip - * - * The real decoding work is done by gzinflate() built-in function, this - * method only parses the header and checks data for compliance with - * RFC 1952 - * - * @param string $data gzip-encoded data - * - * @return string decoded data - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_MessageException - * @link http://tools.ietf.org/html/rfc1952 - */ - public static function decodeGzip($data) - { - $length = strlen($data); - // If it doesn't look like gzip-encoded data, don't bother - if (18 > $length || strcmp(substr($data, 0, 2), "\x1f\x8b")) { - return $data; - } - if (!function_exists('gzinflate')) { - throw new HTTP_Request2_LogicException( - 'Unable to decode body: gzip extension not available', - HTTP_Request2_Exception::MISCONFIGURATION - ); - } - $method = ord(substr($data, 2, 1)); - if (8 != $method) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: unknown compression method', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $flags = ord(substr($data, 3, 1)); - if ($flags & 224) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: reserved bits are set', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - - // header is 10 bytes minimum. may be longer, though. - $headerLength = 10; - // extra fields, need to skip 'em - if ($flags & 4) { - if ($length - $headerLength - 2 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $extraLength = unpack('v', substr($data, 10, 2)); - if ($length - $headerLength - 2 - $extraLength[1] < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $headerLength += $extraLength[1] + 2; - } - // file name, need to skip that - if ($flags & 8) { - if ($length - $headerLength - 1 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $filenameLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $filenameLength || $length - $headerLength - $filenameLength - 1 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $headerLength += $filenameLength + 1; - } - // comment, need to skip that also - if ($flags & 16) { - if ($length - $headerLength - 1 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $commentLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $commentLength || $length - $headerLength - $commentLength - 1 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $headerLength += $commentLength + 1; - } - // have a CRC for header. let's check - if ($flags & 2) { - if ($length - $headerLength - 2 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $crcReal = 0xffff & crc32(substr($data, 0, $headerLength)); - $crcStored = unpack('v', substr($data, $headerLength, 2)); - if ($crcReal != $crcStored[1]) { - throw new HTTP_Request2_MessageException( - 'Header CRC check failed', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $headerLength += 2; - } - // unpacked data CRC and size at the end of encoded data - $tmp = unpack('V2', substr($data, -8)); - $dataCrc = $tmp[1]; - $dataSize = $tmp[2]; - - // finally, call the gzinflate() function - // don't pass $dataSize to gzinflate, see bugs #13135, #14370 - $unpacked = gzinflate(substr($data, $headerLength, -8)); - if (false === $unpacked) { - throw new HTTP_Request2_MessageException( - 'gzinflate() call failed', - HTTP_Request2_Exception::DECODE_ERROR - ); - } elseif ($dataSize != strlen($unpacked)) { - throw new HTTP_Request2_MessageException( - 'Data size check failed', - HTTP_Request2_Exception::DECODE_ERROR - ); - } elseif ((0xffffffff & $dataCrc) != (0xffffffff & crc32($unpacked))) { - throw new HTTP_Request2_Exception( - 'Data CRC check failed', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - return $unpacked; - } - - /** - * Decodes the message-body encoded by deflate - * - * @param string $data deflate-encoded data - * - * @return string decoded data - * @throws HTTP_Request2_LogicException - */ - public static function decodeDeflate($data) - { - if (!function_exists('gzuncompress')) { - throw new HTTP_Request2_LogicException( - 'Unable to decode body: gzip extension not available', - HTTP_Request2_Exception::MISCONFIGURATION - ); - } - // RFC 2616 defines 'deflate' encoding as zlib format from RFC 1950, - // while many applications send raw deflate stream from RFC 1951. - // We should check for presence of zlib header and use gzuncompress() or - // gzinflate() as needed. See bug #15305 - $header = unpack('n', substr($data, 0, 2)); - return (0 == $header[1] % 31)? gzuncompress($data): gzinflate($data); - } -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9.5/HTTP/Request2/SOCKS5.php b/libs/PEAR.1.9.5/HTTP/Request2/SOCKS5.php deleted file mode 100644 index d54049585..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/SOCKS5.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Socket wrapper class used by Socket Adapter */ -require_once 'HTTP/Request2/SocketWrapper.php'; - -/** - * SOCKS5 proxy connection class (used by Socket Adapter) - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://pear.php.net/bugs/bug.php?id=19332 - * @link http://tools.ietf.org/html/rfc1928 - */ -class HTTP_Request2_SOCKS5 extends HTTP_Request2_SocketWrapper -{ - /** - * Constructor, tries to connect and authenticate to a SOCKS5 proxy - * - * @param string $address Proxy address, e.g. 'tcp://localhost:1080' - * @param int $timeout Connection timeout (seconds) - * @param array $contextOptions Stream context options - * @param string $username Proxy user name - * @param string $password Proxy password - * - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_ConnectionException - * @throws HTTP_Request2_MessageException - */ - public function __construct( - $address, $timeout = 10, array $contextOptions = array(), - $username = null, $password = null - ) { - parent::__construct($address, $timeout, $contextOptions); - - if (strlen($username)) { - $request = pack('C4', 5, 2, 0, 2); - } else { - $request = pack('C3', 5, 1, 0); - } - $this->write($request); - $response = unpack('Cversion/Cmethod', $this->read(3)); - if (5 != $response['version']) { - throw new HTTP_Request2_MessageException( - 'Invalid version received from SOCKS5 proxy: ' . $response['version'], - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } - switch ($response['method']) { - case 2: - $this->performAuthentication($username, $password); - case 0: - break; - default: - throw new HTTP_Request2_ConnectionException( - "Connection rejected by proxy due to unsupported auth method" - ); - } - } - - /** - * Performs username/password authentication for SOCKS5 - * - * @param string $username Proxy user name - * @param string $password Proxy password - * - * @throws HTTP_Request2_ConnectionException - * @throws HTTP_Request2_MessageException - * @link http://tools.ietf.org/html/rfc1929 - */ - protected function performAuthentication($username, $password) - { - $request = pack('C2', 1, strlen($username)) . $username - . pack('C', strlen($password)) . $password; - - $this->write($request); - $response = unpack('Cvn/Cstatus', $this->read(3)); - if (1 != $response['vn'] || 0 != $response['status']) { - throw new HTTP_Request2_ConnectionException( - 'Connection rejected by proxy due to invalid username and/or password' - ); - } - } - - /** - * Connects to a remote host via proxy - * - * @param string $remoteHost Remote host - * @param int $remotePort Remote port - * - * @throws HTTP_Request2_ConnectionException - * @throws HTTP_Request2_MessageException - */ - public function connect($remoteHost, $remotePort) - { - $request = pack('C5', 0x05, 0x01, 0x00, 0x03, strlen($remoteHost)) - . $remoteHost . pack('n', $remotePort); - - $this->write($request); - $response = unpack('Cversion/Creply/Creserved', $this->read(1024)); - if (5 != $response['version'] || 0 != $response['reserved']) { - throw new HTTP_Request2_MessageException( - 'Invalid response received from SOCKS5 proxy', - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } elseif (0 != $response['reply']) { - throw new HTTP_Request2_ConnectionException( - "Unable to connect to {$remoteHost}:{$remotePort} through SOCKS5 proxy", - 0, $response['reply'] - ); - } - } -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9.5/HTTP/Request2/SocketWrapper.php b/libs/PEAR.1.9.5/HTTP/Request2/SocketWrapper.php deleted file mode 100644 index 43081a196..000000000 --- a/libs/PEAR.1.9.5/HTTP/Request2/SocketWrapper.php +++ /dev/null @@ -1,297 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Exception classes for HTTP_Request2 package */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Socket wrapper class used by Socket Adapter - * - * Needed to properly handle connection errors, global timeout support and - * similar things. Loosely based on Net_Socket used by older HTTP_Request. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.2.1 - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://pear.php.net/bugs/bug.php?id=19332 - * @link http://tools.ietf.org/html/rfc1928 - */ -class HTTP_Request2_SocketWrapper -{ - /** - * PHP warning messages raised during stream_socket_client() call - * @var array - */ - protected $connectionWarnings = array(); - - /** - * Connected socket - * @var resource - */ - protected $socket; - - /** - * Sum of start time and global timeout, exception will be thrown if request continues past this time - * @var integer - */ - protected $deadline; - - /** - * Global timeout value, mostly for exception messages - * @var integer - */ - protected $timeout; - - /** - * Class constructor, tries to establish connection - * - * @param string $address Address for stream_socket_client() call, - * e.g. 'tcp://localhost:80' - * @param int $timeout Connection timeout (seconds) - * @param array $contextOptions Context options - * - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_ConnectionException - */ - public function __construct($address, $timeout, array $contextOptions = array()) - { - if (!empty($contextOptions) - && !isset($contextOptions['socket']) && !isset($contextOptions['ssl']) - ) { - // Backwards compatibility with 2.1.0 and 2.1.1 releases - $contextOptions = array('ssl' => $contextOptions); - } - $context = stream_context_create(); - foreach ($contextOptions as $wrapper => $options) { - foreach ($options as $name => $value) { - if (!stream_context_set_option($context, $wrapper, $name, $value)) { - throw new HTTP_Request2_LogicException( - "Error setting '{$wrapper}' wrapper context option '{$name}'" - ); - } - } - } - set_error_handler(array($this, 'connectionWarningsHandler')); - $this->socket = stream_socket_client( - $address, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context - ); - restore_error_handler(); - // if we fail to bind to a specified local address (see request #19515), - // connection still succeeds, albeit with a warning. Throw an Exception - // with the warning text in this case as that connection is unlikely - // to be what user wants and as Curl throws an error in similar case. - if ($this->connectionWarnings) { - if ($this->socket) { - fclose($this->socket); - } - $error = $errstr ? $errstr : implode("\n", $this->connectionWarnings); - throw new HTTP_Request2_ConnectionException( - "Unable to connect to {$address}. Error: {$error}", 0, $errno - ); - } - } - - /** - * Destructor, disconnects socket - */ - public function __destruct() - { - fclose($this->socket); - } - - /** - * Wrapper around fread(), handles global request timeout - * - * @param int $length Reads up to this number of bytes - * - * @return string Data read from socket - * @throws HTTP_Request2_MessageException In case of timeout - */ - public function read($length) - { - if ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - $data = fread($this->socket, $length); - $this->checkTimeout(); - return $data; - } - - /** - * Reads until either the end of the socket or a newline, whichever comes first - * - * Strips the trailing newline from the returned data, handles global - * request timeout. Method idea borrowed from Net_Socket PEAR package. - * - * @param int $bufferSize buffer size to use for reading - * @param int $localTimeout timeout value to use just for this call - * (used when waiting for "100 Continue" response) - * - * @return string Available data up to the newline (not including newline) - * @throws HTTP_Request2_MessageException In case of timeout - */ - public function readLine($bufferSize, $localTimeout = null) - { - $line = ''; - while (!feof($this->socket)) { - if (null !== $localTimeout) { - stream_set_timeout($this->socket, $localTimeout); - } elseif ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - - $line .= @fgets($this->socket, $bufferSize); - - if (null === $localTimeout) { - $this->checkTimeout(); - - } else { - $info = stream_get_meta_data($this->socket); - // reset socket timeout if we don't have request timeout specified, - // prevents further calls failing with a bogus Exception - if (!$this->deadline) { - $default = (int)@ini_get('default_socket_timeout'); - stream_set_timeout($this->socket, $default > 0 ? $default : PHP_INT_MAX); - } - if ($info['timed_out']) { - throw new HTTP_Request2_MessageException( - "readLine() call timed out", HTTP_Request2_Exception::TIMEOUT - ); - } - } - if (substr($line, -1) == "\n") { - return rtrim($line, "\r\n"); - } - } - return $line; - } - - /** - * Wrapper around fwrite(), handles global request timeout - * - * @param string $data String to be written - * - * @return int - * @throws HTTP_Request2_MessageException - */ - public function write($data) - { - if ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - $written = fwrite($this->socket, $data); - $this->checkTimeout(); - // http://www.php.net/manual/en/function.fwrite.php#96951 - if ($written < strlen($data)) { - throw new HTTP_Request2_MessageException('Error writing request'); - } - return $written; - } - - /** - * Tests for end-of-file on a socket - * - * @return bool - */ - public function eof() - { - return feof($this->socket); - } - - /** - * Sets request deadline - * - * @param int $deadline Exception will be thrown if request continues - * past this time - * @param int $timeout Original request timeout value, to use in - * Exception message - */ - public function setDeadline($deadline, $timeout) - { - $this->deadline = $deadline; - $this->timeout = $timeout; - } - - /** - * Turns on encryption on a socket - * - * @throws HTTP_Request2_ConnectionException - */ - public function enableCrypto() - { - $modes = array( - STREAM_CRYPTO_METHOD_TLS_CLIENT, - STREAM_CRYPTO_METHOD_SSLv3_CLIENT, - STREAM_CRYPTO_METHOD_SSLv23_CLIENT, - STREAM_CRYPTO_METHOD_SSLv2_CLIENT - ); - - foreach ($modes as $mode) { - if (stream_socket_enable_crypto($this->socket, true, $mode)) { - return; - } - } - throw new HTTP_Request2_ConnectionException( - 'Failed to enable secure connection when connecting through proxy' - ); - } - - /** - * Throws an Exception if stream timed out - * - * @throws HTTP_Request2_MessageException - */ - protected function checkTimeout() - { - $info = stream_get_meta_data($this->socket); - if ($info['timed_out'] || $this->deadline && time() > $this->deadline) { - $reason = $this->deadline - ? "after {$this->timeout} second(s)" - : 'due to default_socket_timeout php.ini setting'; - throw new HTTP_Request2_MessageException( - "Request timed out {$reason}", HTTP_Request2_Exception::TIMEOUT - ); - } - } - - /** - * Error handler to use during stream_socket_client() call - * - * One stream_socket_client() call may produce *multiple* PHP warnings - * (especially OpenSSL-related), we keep them in an array to later use for - * the message of HTTP_Request2_ConnectionException - * - * @param int $errno error level - * @param string $errstr error message - * - * @return bool - */ - protected function connectionWarningsHandler($errno, $errstr) - { - if ($errno & E_WARNING) { - array_unshift($this->connectionWarnings, $errstr); - } - return true; - } -} -?> diff --git a/libs/PEAR.1.9.5/Net/URL2.php b/libs/PEAR.1.9.5/Net/URL2.php deleted file mode 100644 index d5bab1141..000000000 --- a/libs/PEAR.1.9.5/Net/URL2.php +++ /dev/null @@ -1,1219 +0,0 @@ - - * @copyright 2007-2009 Peytz & Co. A/S - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @version CVS: $Id$ - * @link https://tools.ietf.org/html/rfc3986 - */ - -/** - * Represents a URL as per RFC 3986. - * - * @category Networking - * @package Net_URL2 - * @author Christian Schmidt - * @copyright 2007-2009 Peytz & Co. A/S - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @version Release: 2.1.1 - * @link https://pear.php.net/package/Net_URL2 - */ -class Net_URL2 -{ - /** - * Do strict parsing in resolve() (see RFC 3986, section 5.2.2). Default - * is true. - */ - const OPTION_STRICT = 'strict'; - - /** - * Represent arrays in query using PHP's [] notation. Default is true. - */ - const OPTION_USE_BRACKETS = 'use_brackets'; - - /** - * Drop zero-based integer sequences in query using PHP's [] notation. Default - * is true. - */ - const OPTION_DROP_SEQUENCE = 'drop_sequence'; - - /** - * URL-encode query variable keys. Default is true. - */ - const OPTION_ENCODE_KEYS = 'encode_keys'; - - /** - * Query variable separators when parsing the query string. Every character - * is considered a separator. Default is "&". - */ - const OPTION_SEPARATOR_INPUT = 'input_separator'; - - /** - * Query variable separator used when generating the query string. Default - * is "&". - */ - const OPTION_SEPARATOR_OUTPUT = 'output_separator'; - - /** - * Default options corresponds to how PHP handles $_GET. - */ - private $_options = array( - self::OPTION_STRICT => true, - self::OPTION_USE_BRACKETS => true, - self::OPTION_DROP_SEQUENCE => true, - self::OPTION_ENCODE_KEYS => true, - self::OPTION_SEPARATOR_INPUT => '&', - self::OPTION_SEPARATOR_OUTPUT => '&', - ); - - /** - * @var string|bool - */ - private $_scheme = false; - - /** - * @var string|bool - */ - private $_userinfo = false; - - /** - * @var string|bool - */ - private $_host = false; - - /** - * @var string|bool - */ - private $_port = false; - - /** - * @var string - */ - private $_path = ''; - - /** - * @var string|bool - */ - private $_query = false; - - /** - * @var string|bool - */ - private $_fragment = false; - - /** - * Constructor. - * - * @param string $url an absolute or relative URL - * @param array $options an array of OPTION_xxx constants - * - * @uses self::parseUrl() - */ - public function __construct($url, array $options = array()) - { - foreach ($options as $optionName => $value) { - if (array_key_exists($optionName, $this->_options)) { - $this->_options[$optionName] = $value; - } - } - - $this->parseUrl($url); - } - - /** - * Magic Setter. - * - * This method will magically set the value of a private variable ($var) - * with the value passed as the args - * - * @param string $var The private variable to set. - * @param mixed $arg An argument of any type. - * - * @return void - */ - public function __set($var, $arg) - { - $method = 'set' . $var; - if (method_exists($this, $method)) { - $this->$method($arg); - } - } - - /** - * Magic Getter. - * - * This is the magic get method to retrieve the private variable - * that was set by either __set() or it's setter... - * - * @param string $var The property name to retrieve. - * - * @return mixed $this->$var Either a boolean false if the - * property is not set or the value - * of the private property. - */ - public function __get($var) - { - $method = 'get' . $var; - if (method_exists($this, $method)) { - return $this->$method(); - } - - return false; - } - - /** - * Returns the scheme, e.g. "http" or "urn", or false if there is no - * scheme specified, i.e. if this is a relative URL. - * - * @return string|bool - */ - public function getScheme() - { - return $this->_scheme; - } - - /** - * Sets the scheme, e.g. "http" or "urn". Specify false if there is no - * scheme specified, i.e. if this is a relative URL. - * - * @param string|bool $scheme e.g. "http" or "urn", or false if there is no - * scheme specified, i.e. if this is a relative - * URL - * - * @return $this - * @see getScheme - */ - public function setScheme($scheme) - { - $this->_scheme = $scheme; - return $this; - } - - /** - * Returns the user part of the userinfo part (the part preceding the first - * ":"), or false if there is no userinfo part. - * - * @return string|bool - */ - public function getUser() - { - return $this->_userinfo !== false - ? preg_replace('(:.*$)', '', $this->_userinfo) - : false; - } - - /** - * Returns the password part of the userinfo part (the part after the first - * ":"), or false if there is no userinfo part (i.e. the URL does not - * contain "@" in front of the hostname) or the userinfo part does not - * contain ":". - * - * @return string|bool - */ - public function getPassword() - { - return $this->_userinfo !== false - ? substr(strstr($this->_userinfo, ':'), 1) - : false; - } - - /** - * Returns the userinfo part, or false if there is none, i.e. if the - * authority part does not contain "@". - * - * @return string|bool - */ - public function getUserinfo() - { - return $this->_userinfo; - } - - /** - * Sets the userinfo part. If two arguments are passed, they are combined - * in the userinfo part as username ":" password. - * - * @param string|bool $userinfo userinfo or username - * @param string|bool $password optional password, or false - * - * @return $this - */ - public function setUserinfo($userinfo, $password = false) - { - if ($password !== false) { - $userinfo .= ':' . $password; - } - - if ($userinfo !== false) { - $userinfo = $this->_encodeData($userinfo); - } - - $this->_userinfo = $userinfo; - return $this; - } - - /** - * Returns the host part, or false if there is no authority part, e.g. - * relative URLs. - * - * @return string|bool a hostname, an IP address, or false - */ - public function getHost() - { - return $this->_host; - } - - /** - * Sets the host part. Specify false if there is no authority part, e.g. - * relative URLs. - * - * @param string|bool $host a hostname, an IP address, or false - * - * @return $this - */ - public function setHost($host) - { - $this->_host = $host; - return $this; - } - - /** - * Returns the port number, or false if there is no port number specified, - * i.e. if the default port is to be used. - * - * @return string|bool - */ - public function getPort() - { - return $this->_port; - } - - /** - * Sets the port number. Specify false if there is no port number specified, - * i.e. if the default port is to be used. - * - * @param string|bool $port a port number, or false - * - * @return $this - */ - public function setPort($port) - { - $this->_port = $port; - return $this; - } - - /** - * Returns the authority part, i.e. [ userinfo "@" ] host [ ":" port ], or - * false if there is no authority. - * - * @return string|bool - */ - public function getAuthority() - { - if (false === $this->_host) { - return false; - } - - $authority = ''; - - if (strlen($this->_userinfo)) { - $authority .= $this->_userinfo . '@'; - } - - $authority .= $this->_host; - - if ($this->_port !== false) { - $authority .= ':' . $this->_port; - } - - return $authority; - } - - /** - * Sets the authority part, i.e. [ userinfo "@" ] host [ ":" port ]. Specify - * false if there is no authority. - * - * @param string|bool $authority a hostname or an IP address, possibly - * with userinfo prefixed and port number - * appended, e.g. "foo:bar@example.org:81". - * - * @return $this - */ - public function setAuthority($authority) - { - $this->_userinfo = false; - $this->_host = false; - $this->_port = false; - - if ('' === $authority) { - $this->_host = $authority; - return $this; - } - - if (!preg_match('(^(([^\@]*)\@)?(.+?)(:(\d*))?$)', $authority, $matches)) { - return $this; - } - - if ($matches[1]) { - $this->_userinfo = $this->_encodeData($matches[2]); - } - - $this->_host = $matches[3]; - - if (isset($matches[5]) && strlen($matches[5])) { - $this->_port = $matches[5]; - } - return $this; - } - - /** - * Returns the path part (possibly an empty string). - * - * @return string - */ - public function getPath() - { - return $this->_path; - } - - /** - * Sets the path part (possibly an empty string). - * - * @param string $path a path - * - * @return $this - */ - public function setPath($path) - { - $this->_path = $path; - return $this; - } - - /** - * Returns the query string (excluding the leading "?"), or false if "?" - * is not present in the URL. - * - * @return string|bool - * @see getQueryVariables - */ - public function getQuery() - { - return $this->_query; - } - - /** - * Sets the query string (excluding the leading "?"). Specify false if "?" - * is not present in the URL. - * - * @param string|bool $query a query string, e.g. "foo=1&bar=2" - * - * @return $this - * @see setQueryVariables - */ - public function setQuery($query) - { - $this->_query = $query; - return $this; - } - - /** - * Returns the fragment name, or false if "#" is not present in the URL. - * - * @return string|bool - */ - public function getFragment() - { - return $this->_fragment; - } - - /** - * Sets the fragment name. Specify false if "#" is not present in the URL. - * - * @param string|bool $fragment a fragment excluding the leading "#", or - * false - * - * @return $this - */ - public function setFragment($fragment) - { - $this->_fragment = $fragment; - return $this; - } - - /** - * Returns the query string like an array as the variables would appear in - * $_GET in a PHP script. If the URL does not contain a "?", an empty array - * is returned. - * - * @return array - */ - public function getQueryVariables() - { - $separator = $this->getOption(self::OPTION_SEPARATOR_INPUT); - $encodeKeys = $this->getOption(self::OPTION_ENCODE_KEYS); - $useBrackets = $this->getOption(self::OPTION_USE_BRACKETS); - - $return = array(); - - for ($part = strtok($this->_query, $separator); - strlen($part); - $part = strtok($separator) - ) { - list($key, $value) = explode('=', $part, 2) + array(1 => ''); - - if ($encodeKeys) { - $key = rawurldecode($key); - } - $value = rawurldecode($value); - - if ($useBrackets) { - $return = $this->_queryArrayByKey($key, $value, $return); - } else { - if (isset($return[$key])) { - $return[$key] = (array) $return[$key]; - $return[$key][] = $value; - } else { - $return[$key] = $value; - } - } - } - - return $return; - } - - /** - * Parse a single query key=value pair into an existing php array - * - * @param string $key query-key - * @param string $value query-value - * @param array $array of existing query variables (if any) - * - * @return mixed - */ - private function _queryArrayByKey($key, $value, array $array = array()) - { - if (!strlen($key)) { - return $array; - } - - $offset = $this->_queryKeyBracketOffset($key); - if ($offset === false) { - $name = $key; - } else { - $name = substr($key, 0, $offset); - } - - if (!strlen($name)) { - return $array; - } - - if (!$offset) { - // named value - $array[$name] = $value; - } else { - // array - $brackets = substr($key, $offset); - if (!isset($array[$name])) { - $array[$name] = null; - } - $array[$name] = $this->_queryArrayByBrackets( - $brackets, $value, $array[$name] - ); - } - - return $array; - } - - /** - * Parse a key-buffer to place value in array - * - * @param string $buffer to consume all keys from - * @param string $value to be set/add - * @param array $array to traverse and set/add value in - * - * @throws Exception - * @return array - */ - private function _queryArrayByBrackets($buffer, $value, array $array = null) - { - $entry = &$array; - - for ($iteration = 0; strlen($buffer); $iteration++) { - $open = $this->_queryKeyBracketOffset($buffer); - if ($open !== 0) { - // Opening bracket [ must exist at offset 0, if not, there is - // no bracket to parse and the value dropped. - // if this happens in the first iteration, this is flawed, see - // as well the second exception below. - if ($iteration) { - break; - } - // @codeCoverageIgnoreStart - throw new Exception( - 'Net_URL2 Internal Error: '. __METHOD__ .'(): ' . - 'Opening bracket [ must exist at offset 0' - ); - // @codeCoverageIgnoreEnd - } - - $close = strpos($buffer, ']', 1); - if (!$close) { - // this error condition should never be reached as this is a - // private method and bracket pairs are checked beforehand. - // See as well the first exception for the opening bracket. - // @codeCoverageIgnoreStart - throw new Exception( - 'Net_URL2 Internal Error: '. __METHOD__ .'(): ' . - 'Closing bracket ] must exist, not found' - ); - // @codeCoverageIgnoreEnd - } - - $index = substr($buffer, 1, $close - 1); - if (strlen($index)) { - $entry = &$entry[$index]; - } else { - if (!is_array($entry)) { - $entry = array(); - } - $entry[] = &$new; - $entry = &$new; - unset($new); - } - $buffer = substr($buffer, $close + 1); - } - - $entry = $value; - - return $array; - } - - /** - * Query-key has brackets ("...[]") - * - * @param string $key query-key - * - * @return bool|int offset of opening bracket, false if no brackets - */ - private function _queryKeyBracketOffset($key) - { - if (false !== $open = strpos($key, '[') - and false === strpos($key, ']', $open + 1) - ) { - $open = false; - } - - return $open; - } - - /** - * Sets the query string to the specified variable in the query string. - * - * @param array $array (name => value) array - * - * @return $this - */ - public function setQueryVariables(array $array) - { - if (!$array) { - $this->_query = false; - } else { - $this->_query = $this->buildQuery( - $array, - $this->getOption(self::OPTION_SEPARATOR_OUTPUT) - ); - } - return $this; - } - - /** - * Sets the specified variable in the query string. - * - * @param string $name variable name - * @param mixed $value variable value - * - * @return $this - */ - public function setQueryVariable($name, $value) - { - $array = $this->getQueryVariables(); - $array[$name] = $value; - $this->setQueryVariables($array); - return $this; - } - - /** - * Removes the specified variable from the query string. - * - * @param string $name a query string variable, e.g. "foo" in "?foo=1" - * - * @return void - */ - public function unsetQueryVariable($name) - { - $array = $this->getQueryVariables(); - unset($array[$name]); - $this->setQueryVariables($array); - } - - /** - * Returns a string representation of this URL. - * - * @return string - */ - public function getURL() - { - // See RFC 3986, section 5.3 - $url = ''; - - if ($this->_scheme !== false) { - $url .= $this->_scheme . ':'; - } - - $authority = $this->getAuthority(); - if ($authority === false && strtolower($this->_scheme) === 'file') { - $authority = ''; - } - - $url .= $this->_buildAuthorityAndPath($authority, $this->_path); - - if ($this->_query !== false) { - $url .= '?' . $this->_query; - } - - if ($this->_fragment !== false) { - $url .= '#' . $this->_fragment; - } - - return $url; - } - - /** - * Put authority and path together, wrapping authority - * into proper separators/terminators. - * - * @param string|bool $authority authority - * @param string $path path - * - * @return string - */ - private function _buildAuthorityAndPath($authority, $path) - { - if ($authority === false) { - return $path; - } - - $terminator = ($path !== '' && $path[0] !== '/') ? '/' : ''; - - return '//' . $authority . $terminator . $path; - } - - /** - * Returns a string representation of this URL. - * - * @return string - * @link https://php.net/language.oop5.magic#object.tostring - */ - public function __toString() - { - return $this->getURL(); - } - - /** - * Returns a normalized string representation of this URL. This is useful - * for comparison of URLs. - * - * @return string - */ - public function getNormalizedURL() - { - $url = clone $this; - $url->normalize(); - return $url->getUrl(); - } - - /** - * Normalizes the URL - * - * See RFC 3986, Section 6. Normalization and Comparison - * - * @link https://tools.ietf.org/html/rfc3986#section-6 - * - * @return void - */ - public function normalize() - { - // See RFC 3986, section 6 - - // Scheme is case-insensitive - if ($this->_scheme) { - $this->_scheme = strtolower($this->_scheme); - } - - // Hostname is case-insensitive - if ($this->_host) { - $this->_host = strtolower($this->_host); - } - - // Remove default port number for known schemes (RFC 3986, section 6.2.3) - if ('' === $this->_port - || $this->_port - && $this->_scheme - && $this->_port == getservbyname($this->_scheme, 'tcp') - ) { - $this->_port = false; - } - - // Normalize case of %XX percentage-encodings (RFC 3986, section 6.2.2.1) - // Normalize percentage-encoded unreserved characters (section 6.2.2.2) - $fields = array(&$this->_userinfo, &$this->_host, &$this->_path, - &$this->_query, &$this->_fragment); - foreach ($fields as &$field) { - if ($field !== false) { - $field = $this->_normalize("$field"); - } - } - unset($field); - - // Path segment normalization (RFC 3986, section 6.2.2.3) - $this->_path = self::removeDotSegments($this->_path); - - // Scheme based normalization (RFC 3986, section 6.2.3) - if (false !== $this->_host && '' === $this->_path) { - $this->_path = '/'; - } - - // path should start with '/' if there is authority (section 3.3.) - if (strlen($this->getAuthority()) - && strlen($this->_path) - && $this->_path[0] !== '/' - ) { - $this->_path = '/' . $this->_path; - } - } - - /** - * Normalize case of %XX percentage-encodings (RFC 3986, section 6.2.2.1) - * Normalize percentage-encoded unreserved characters (section 6.2.2.2) - * - * @param string|array $mixed string or array of strings to normalize - * - * @return string|array - * @see normalize - * @see _normalizeCallback() - */ - private function _normalize($mixed) - { - return preg_replace_callback( - '((?:%[0-9a-fA-Z]{2})+)', array($this, '_normalizeCallback'), - $mixed - ); - } - - /** - * Callback for _normalize() of %XX percentage-encodings - * - * @param array $matches as by preg_replace_callback - * - * @return string - * @see normalize - * @see _normalize - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) - */ - private function _normalizeCallback($matches) - { - return self::urlencode(urldecode($matches[0])); - } - - /** - * Returns whether this instance represents an absolute URL. - * - * @return bool - */ - public function isAbsolute() - { - return (bool) $this->_scheme; - } - - /** - * Returns an Net_URL2 instance representing an absolute URL relative to - * this URL. - * - * @param Net_URL2|string $reference relative URL - * - * @throws Exception - * @return $this - */ - public function resolve($reference) - { - if (!$reference instanceof Net_URL2) { - $reference = new self($reference); - } - if (!$reference->_isFragmentOnly() && !$this->isAbsolute()) { - throw new Exception( - 'Base-URL must be absolute if reference is not fragment-only' - ); - } - - // A non-strict parser may ignore a scheme in the reference if it is - // identical to the base URI's scheme. - if (!$this->getOption(self::OPTION_STRICT) - && $reference->_scheme == $this->_scheme - ) { - $reference->_scheme = false; - } - - $target = new self(''); - if ($reference->_scheme !== false) { - $target->_scheme = $reference->_scheme; - $target->setAuthority($reference->getAuthority()); - $target->_path = self::removeDotSegments($reference->_path); - $target->_query = $reference->_query; - } else { - $authority = $reference->getAuthority(); - if ($authority !== false) { - $target->setAuthority($authority); - $target->_path = self::removeDotSegments($reference->_path); - $target->_query = $reference->_query; - } else { - if ($reference->_path == '') { - $target->_path = $this->_path; - if ($reference->_query !== false) { - $target->_query = $reference->_query; - } else { - $target->_query = $this->_query; - } - } else { - if (substr($reference->_path, 0, 1) == '/') { - $target->_path = self::removeDotSegments($reference->_path); - } else { - // Merge paths (RFC 3986, section 5.2.3) - if ($this->_host !== false && $this->_path == '') { - $target->_path = '/' . $reference->_path; - } else { - $i = strrpos($this->_path, '/'); - if ($i !== false) { - $target->_path = substr($this->_path, 0, $i + 1); - } - $target->_path .= $reference->_path; - } - $target->_path = self::removeDotSegments($target->_path); - } - $target->_query = $reference->_query; - } - $target->setAuthority($this->getAuthority()); - } - $target->_scheme = $this->_scheme; - } - - $target->_fragment = $reference->_fragment; - - return $target; - } - - /** - * URL is fragment-only - * - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) - * @return bool - */ - private function _isFragmentOnly() - { - return ( - $this->_fragment !== false - && $this->_query === false - && $this->_path === '' - && $this->_port === false - && $this->_host === false - && $this->_userinfo === false - && $this->_scheme === false - ); - } - - /** - * Removes dots as described in RFC 3986, section 5.2.4, e.g. - * "/foo/../bar/baz" => "/bar/baz" - * - * @param string $path a path - * - * @return string a path - */ - public static function removeDotSegments($path) - { - $path = (string) $path; - $output = ''; - - // Make sure not to be trapped in an infinite loop due to a bug in this - // method - $loopLimit = 256; - $j = 0; - while ('' !== $path && $j++ < $loopLimit) { - if (substr($path, 0, 2) === './') { - // Step 2.A - $path = substr($path, 2); - } elseif (substr($path, 0, 3) === '../') { - // Step 2.A - $path = substr($path, 3); - } elseif (substr($path, 0, 3) === '/./' || $path === '/.') { - // Step 2.B - $path = '/' . substr($path, 3); - } elseif (substr($path, 0, 4) === '/../' || $path === '/..') { - // Step 2.C - $path = '/' . substr($path, 4); - $i = strrpos($output, '/'); - $output = $i === false ? '' : substr($output, 0, $i); - } elseif ($path === '.' || $path === '..') { - // Step 2.D - $path = ''; - } else { - // Step 2.E - $i = strpos($path, '/', $path[0] === '/'); - if ($i === false) { - $output .= $path; - $path = ''; - break; - } - $output .= substr($path, 0, $i); - $path = substr($path, $i); - } - } - - if ($path !== '') { - $message = sprintf( - 'Unable to remove dot segments; hit loop limit %d (left: %s)', - $j, var_export($path, true) - ); - trigger_error($message, E_USER_WARNING); - } - - return $output; - } - - /** - * Percent-encodes all non-alphanumeric characters except these: _ . - ~ - * Similar to PHP's rawurlencode(), except that it also encodes ~ in PHP - * 5.2.x and earlier. - * - * @param string $string string to encode - * - * @return string - */ - public static function urlencode($string) - { - $encoded = rawurlencode($string); - - // This is only necessary in PHP < 5.3. - $encoded = str_replace('%7E', '~', $encoded); - return $encoded; - } - - /** - * Returns a Net_URL2 instance representing the canonical URL of the - * currently executing PHP script. - * - * @throws Exception - * @return string - */ - public static function getCanonical() - { - if (!isset($_SERVER['REQUEST_METHOD'])) { - // ALERT - no current URL - throw new Exception('Script was not called through a webserver'); - } - - // Begin with a relative URL - $url = new self($_SERVER['PHP_SELF']); - $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; - $url->_host = $_SERVER['SERVER_NAME']; - $port = $_SERVER['SERVER_PORT']; - if ($url->_scheme == 'http' && $port != 80 - || $url->_scheme == 'https' && $port != 443 - ) { - $url->_port = $port; - } - return $url; - } - - /** - * Returns the URL used to retrieve the current request. - * - * @return string - */ - public static function getRequestedURL() - { - return self::getRequested()->getUrl(); - } - - /** - * Returns a Net_URL2 instance representing the URL used to retrieve the - * current request. - * - * @throws Exception - * @return $this - */ - public static function getRequested() - { - if (!isset($_SERVER['REQUEST_METHOD'])) { - // ALERT - no current URL - throw new Exception('Script was not called through a webserver'); - } - - // Begin with a relative URL - $url = new self($_SERVER['REQUEST_URI']); - $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; - // Set host and possibly port - $url->setAuthority($_SERVER['HTTP_HOST']); - return $url; - } - - /** - * Returns the value of the specified option. - * - * @param string $optionName The name of the option to retrieve - * - * @return mixed - */ - public function getOption($optionName) - { - return isset($this->_options[$optionName]) - ? $this->_options[$optionName] : false; - } - - /** - * A simple version of http_build_query in userland. The encoded string is - * percentage encoded according to RFC 3986. - * - * @param array $data An array, which has to be converted into - * QUERY_STRING. Anything is possible. - * @param string $separator Separator {@link self::OPTION_SEPARATOR_OUTPUT} - * @param string $key For stacked values (arrays in an array). - * - * @return string - */ - protected function buildQuery(array $data, $separator, $key = null) - { - $query = array(); - $drop_names = ( - $this->_options[self::OPTION_DROP_SEQUENCE] === true - && array_keys($data) === array_keys(array_values($data)) - ); - foreach ($data as $name => $value) { - if ($this->getOption(self::OPTION_ENCODE_KEYS) === true) { - $name = rawurlencode($name); - } - if ($key !== null) { - if ($this->getOption(self::OPTION_USE_BRACKETS) === true) { - $drop_names && $name = ''; - $name = $key . '[' . $name . ']'; - } else { - $name = $key; - } - } - if (is_array($value)) { - $query[] = $this->buildQuery($value, $separator, $name); - } else { - $query[] = $name . '=' . rawurlencode($value); - } - } - return implode($separator, $query); - } - - /** - * This method uses a regex to parse the url into the designated parts. - * - * @param string $url URL - * - * @return void - * @uses self::$_scheme, self::setAuthority(), self::$_path, self::$_query, - * self::$_fragment - * @see __construct - */ - protected function parseUrl($url) - { - // The regular expression is copied verbatim from RFC 3986, appendix B. - // The expression does not validate the URL but matches any string. - preg_match( - '(^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)', - $url, $matches - ); - - // "path" is always present (possibly as an empty string); the rest - // are optional. - $this->_scheme = !empty($matches[1]) ? $matches[2] : false; - $this->setAuthority(!empty($matches[3]) ? $matches[4] : false); - $this->_path = $this->_encodeData($matches[5]); - $this->_query = !empty($matches[6]) - ? $this->_encodeData($matches[7]) - : false - ; - $this->_fragment = !empty($matches[8]) ? $matches[9] : false; - } - - /** - * Encode characters that might have been forgotten to encode when passing - * in an URL. Applied onto Userinfo, Path and Query. - * - * @param string $url URL - * - * @return string - * @see parseUrl - * @see setAuthority - * @link https://pear.php.net/bugs/bug.php?id=20425 - */ - private function _encodeData($url) - { - return preg_replace_callback( - '([\x-\x20\x22\x3C\x3E\x7F-\xFF]+)', - array($this, '_encodeCallback'), $url - ); - } - - /** - * callback for encoding character data - * - * @param array $matches Matches - * - * @return string - * @see _encodeData - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) - */ - private function _encodeCallback(array $matches) - { - return rawurlencode($matches[0]); - } -} diff --git a/libs/PEAR.1.9.5/PEAR.php b/libs/PEAR.1.9.5/PEAR.php deleted file mode 100644 index e6f8edc2a..000000000 --- a/libs/PEAR.1.9.5/PEAR.php +++ /dev/null @@ -1,1063 +0,0 @@ - - * @author Stig Bakken - * @author Tomas V.V.Cox - * @author Greg Beaver - * @copyright 1997-2010 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id$ - * @link http://pear.php.net/package/PEAR - * @since File available since Release 0.1 - */ - -/**#@+ - * ERROR constants - */ -define('PEAR_ERROR_RETURN', 1); -define('PEAR_ERROR_PRINT', 2); -define('PEAR_ERROR_TRIGGER', 4); -define('PEAR_ERROR_DIE', 8); -define('PEAR_ERROR_CALLBACK', 16); -/** - * WARNING: obsolete - * @deprecated - */ -define('PEAR_ERROR_EXCEPTION', 32); -/**#@-*/ -define('PEAR_ZE2', (function_exists('version_compare') && - version_compare(zend_version(), "2-dev", "ge"))); - -if (substr(PHP_OS, 0, 3) == 'WIN') { - define('OS_WINDOWS', true); - define('OS_UNIX', false); - define('PEAR_OS', 'Windows'); -} else { - define('OS_WINDOWS', false); - define('OS_UNIX', true); - define('PEAR_OS', 'Unix'); // blatant assumption -} - -$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN; -$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE; -$GLOBALS['_PEAR_destructor_object_list'] = array(); -$GLOBALS['_PEAR_shutdown_funcs'] = array(); -$GLOBALS['_PEAR_error_handler_stack'] = array(); - -@ini_set('track_errors', true); - -/** - * Base class for other PEAR classes. Provides rudimentary - * emulation of destructors. - * - * If you want a destructor in your class, inherit PEAR and make a - * destructor method called _yourclassname (same name as the - * constructor, but with a "_" prefix). Also, in your constructor you - * have to call the PEAR constructor: $this->PEAR();. - * The destructor method will be called without parameters. Note that - * at in some SAPI implementations (such as Apache), any output during - * the request shutdown (in which destructors are called) seems to be - * discarded. If you need to get any debug information from your - * destructor, use error_log(), syslog() or something similar. - * - * IMPORTANT! To use the emulated destructors you need to create the - * objects by reference: $obj =& new PEAR_child; - * - * @category pear - * @package PEAR - * @author Stig Bakken - * @author Tomas V.V. Cox - * @author Greg Beaver - * @copyright 1997-2006 The PHP Group - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.9.5 - * @link http://pear.php.net/package/PEAR - * @see PEAR_Error - * @since Class available since PHP 4.0.2 - * @link http://pear.php.net/manual/en/core.pear.php#core.pear.pear - */ -class PEAR -{ - /** - * Whether to enable internal debug messages. - * - * @var bool - * @access private - */ - var $_debug = false; - - /** - * Default error mode for this object. - * - * @var int - * @access private - */ - var $_default_error_mode = null; - - /** - * Default error options used for this object when error mode - * is PEAR_ERROR_TRIGGER. - * - * @var int - * @access private - */ - var $_default_error_options = null; - - /** - * Default error handler (callback) for this object, if error mode is - * PEAR_ERROR_CALLBACK. - * - * @var string - * @access private - */ - var $_default_error_handler = ''; - - /** - * Which class to use for error objects. - * - * @var string - * @access private - */ - var $_error_class = 'PEAR_Error'; - - /** - * An array of expected errors. - * - * @var array - * @access private - */ - var $_expected_errors = array(); - - /** - * Constructor. Registers this object in - * $_PEAR_destructor_object_list for destructor emulation if a - * destructor object exists. - * - * @param string $error_class (optional) which class to use for - * error objects, defaults to PEAR_Error. - * @access public - * @return void - */ - function PEAR($error_class = null) - { - $classname = strtolower(get_class($this)); - if ($this->_debug) { - print "PEAR constructor called, class=$classname\n"; - } - - if ($error_class !== null) { - $this->_error_class = $error_class; - } - - while ($classname && strcasecmp($classname, "pear")) { - $destructor = "_$classname"; - if (method_exists($this, $destructor)) { - global $_PEAR_destructor_object_list; - $_PEAR_destructor_object_list[] = &$this; - if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { - register_shutdown_function("_PEAR_call_destructors"); - $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; - } - break; - } else { - $classname = get_parent_class($classname); - } - } - } - - /** - * Destructor (the emulated type of...). Does nothing right now, - * but is included for forward compatibility, so subclass - * destructors should always call it. - * - * See the note in the class desciption about output from - * destructors. - * - * @access public - * @return void - */ - function _PEAR() { - if ($this->_debug) { - printf("PEAR destructor called, class=%s\n", strtolower(get_class($this))); - } - } - - /** - * If you have a class that's mostly/entirely static, and you need static - * properties, you can use this method to simulate them. Eg. in your method(s) - * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); - * You MUST use a reference, or they will not persist! - * - * @access public - * @param string $class The calling classname, to prevent clashes - * @param string $var The variable to retrieve. - * @return mixed A reference to the variable. If not set it will be - * auto initialised to NULL. - */ - function &getStaticProperty($class, $var) - { - static $properties; - if (!isset($properties[$class])) { - $properties[$class] = array(); - } - - if (!array_key_exists($var, $properties[$class])) { - $properties[$class][$var] = null; - } - - return $properties[$class][$var]; - } - - /** - * Use this function to register a shutdown method for static - * classes. - * - * @access public - * @param mixed $func The function name (or array of class/method) to call - * @param mixed $args The arguments to pass to the function - * @return void - */ - function registerShutdownFunc($func, $args = array()) - { - // if we are called statically, there is a potential - // that no shutdown func is registered. Bug #6445 - if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { - register_shutdown_function("_PEAR_call_destructors"); - $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; - } - $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args); - } - - /** - * Tell whether a value is a PEAR error. - * - * @param mixed $data the value to test - * @param int $code if $data is an error object, return true - * only if $code is a string and - * $obj->getMessage() == $code or - * $code is an integer and $obj->getCode() == $code - * @access public - * @return bool true if parameter is an error - */ - function isError($data, $code = null) - { - if (!is_a($data, 'PEAR_Error')) { - return false; - } - - if (is_null($code)) { - return true; - } elseif (is_string($code)) { - return $data->getMessage() == $code; - } - - return $data->getCode() == $code; - } - - /** - * Sets how errors generated by this object should be handled. - * Can be invoked both in objects and statically. If called - * statically, setErrorHandling sets the default behaviour for all - * PEAR objects. If called in an object, setErrorHandling sets - * the default behaviour for that object. - * - * @param int $mode - * One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, - * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION. - * - * @param mixed $options - * When $mode is PEAR_ERROR_TRIGGER, this is the error level (one - * of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * - * When $mode is PEAR_ERROR_CALLBACK, this parameter is expected - * to be the callback function or method. A callback - * function is a string with the name of the function, a - * callback method is an array of two elements: the element - * at index 0 is the object, and the element at index 1 is - * the name of the method to call in the object. - * - * When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is - * a printf format string used when printing the error - * message. - * - * @access public - * @return void - * @see PEAR_ERROR_RETURN - * @see PEAR_ERROR_PRINT - * @see PEAR_ERROR_TRIGGER - * @see PEAR_ERROR_DIE - * @see PEAR_ERROR_CALLBACK - * @see PEAR_ERROR_EXCEPTION - * - * @since PHP 4.0.5 - */ - function setErrorHandling($mode = null, $options = null) - { - if (isset($this) && is_a($this, 'PEAR')) { - $setmode = &$this->_default_error_mode; - $setoptions = &$this->_default_error_options; - } else { - $setmode = &$GLOBALS['_PEAR_default_error_mode']; - $setoptions = &$GLOBALS['_PEAR_default_error_options']; - } - - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $setmode = $mode; - $setoptions = $options; - break; - - case PEAR_ERROR_CALLBACK: - $setmode = $mode; - // class/object method callback - if (is_callable($options)) { - $setoptions = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - } - - /** - * This method is used to tell which errors you expect to get. - * Expected errors are always returned with error mode - * PEAR_ERROR_RETURN. Expected error codes are stored in a stack, - * and this method pushes a new element onto it. The list of - * expected errors are in effect until they are popped off the - * stack with the popExpect() method. - * - * Note that this method can not be called statically - * - * @param mixed $code a single error code or an array of error codes to expect - * - * @return int the new depth of the "expected errors" stack - * @access public - */ - function expectError($code = '*') - { - if (is_array($code)) { - array_push($this->_expected_errors, $code); - } else { - array_push($this->_expected_errors, array($code)); - } - return count($this->_expected_errors); - } - - /** - * This method pops one element off the expected error codes - * stack. - * - * @return array the list of error codes that were popped - */ - function popExpect() - { - return array_pop($this->_expected_errors); - } - - /** - * This method checks unsets an error code if available - * - * @param mixed error code - * @return bool true if the error code was unset, false otherwise - * @access private - * @since PHP 4.3.0 - */ - function _checkDelExpect($error_code) - { - $deleted = false; - foreach ($this->_expected_errors as $key => $error_array) { - if (in_array($error_code, $error_array)) { - unset($this->_expected_errors[$key][array_search($error_code, $error_array)]); - $deleted = true; - } - - // clean up empty arrays - if (0 == count($this->_expected_errors[$key])) { - unset($this->_expected_errors[$key]); - } - } - - return $deleted; - } - - /** - * This method deletes all occurences of the specified element from - * the expected error codes stack. - * - * @param mixed $error_code error code that should be deleted - * @return mixed list of error codes that were deleted or error - * @access public - * @since PHP 4.3.0 - */ - function delExpect($error_code) - { - $deleted = false; - if ((is_array($error_code) && (0 != count($error_code)))) { - // $error_code is a non-empty array here; we walk through it trying - // to unset all values - foreach ($error_code as $key => $error) { - $deleted = $this->_checkDelExpect($error) ? true : false; - } - - return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME - } elseif (!empty($error_code)) { - // $error_code comes alone, trying to unset it - if ($this->_checkDelExpect($error_code)) { - return true; - } - - return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME - } - - // $error_code is empty - return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME - } - - /** - * This method is a wrapper that returns an instance of the - * configured error class with this object's default error - * handling applied. If the $mode and $options parameters are not - * specified, the object's defaults are used. - * - * @param mixed $message a text error message or a PEAR error object - * - * @param int $code a numeric error code (it is up to your class - * to define these if you want to use codes) - * - * @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, - * PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION. - * - * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter - * specifies the PHP-internal error level (one of - * E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * If $mode is PEAR_ERROR_CALLBACK, this - * parameter specifies the callback function or - * method. In other error modes this parameter - * is ignored. - * - * @param string $userinfo If you need to pass along for example debug - * information, this parameter is meant for that. - * - * @param string $error_class The returned error object will be - * instantiated from this class, if specified. - * - * @param bool $skipmsg If true, raiseError will only pass error codes, - * the error message parameter will be dropped. - * - * @access public - * @return object a PEAR error object - * @see PEAR::setErrorHandling - * @since PHP 4.0.5 - */ - function &raiseError($message = null, - $code = null, - $mode = null, - $options = null, - $userinfo = null, - $error_class = null, - $skipmsg = false) - { - // The error is yet a PEAR error object - if (is_object($message)) { - $code = $message->getCode(); - $userinfo = $message->getUserInfo(); - $error_class = $message->getType(); - $message->error_message_prefix = ''; - $message = $message->getMessage(); - } - - if ( - isset($this) && - isset($this->_expected_errors) && - count($this->_expected_errors) > 0 && - count($exp = end($this->_expected_errors)) - ) { - if ($exp[0] == "*" || - (is_int(reset($exp)) && in_array($code, $exp)) || - (is_string(reset($exp)) && in_array($message, $exp)) - ) { - $mode = PEAR_ERROR_RETURN; - } - } - - // No mode given, try global ones - if ($mode === null) { - // Class error handler - if (isset($this) && isset($this->_default_error_mode)) { - $mode = $this->_default_error_mode; - $options = $this->_default_error_options; - // Global error handler - } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) { - $mode = $GLOBALS['_PEAR_default_error_mode']; - $options = $GLOBALS['_PEAR_default_error_options']; - } - } - - if ($error_class !== null) { - $ec = $error_class; - } elseif (isset($this) && isset($this->_error_class)) { - $ec = $this->_error_class; - } else { - $ec = 'PEAR_Error'; - } - - if (intval(PHP_VERSION) < 5) { - // little non-eval hack to fix bug #12147 - include 'PEAR/FixPHP5PEARWarnings.php'; - return $a; - } - - if ($skipmsg) { - $a = new $ec($code, $mode, $options, $userinfo); - } else { - $a = new $ec($message, $code, $mode, $options, $userinfo); - } - - return $a; - } - - /** - * Simpler form of raiseError with fewer options. In most cases - * message, code and userinfo are enough. - * - * @param mixed $message a text error message or a PEAR error object - * - * @param int $code a numeric error code (it is up to your class - * to define these if you want to use codes) - * - * @param string $userinfo If you need to pass along for example debug - * information, this parameter is meant for that. - * - * @access public - * @return object a PEAR error object - * @see PEAR::raiseError - */ - function &throwError($message = null, $code = null, $userinfo = null) - { - if (isset($this) && is_a($this, 'PEAR')) { - $a = &$this->raiseError($message, $code, null, null, $userinfo); - return $a; - } - - $a = &PEAR::raiseError($message, $code, null, null, $userinfo); - return $a; - } - - function staticPushErrorHandling($mode, $options = null) - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - $def_mode = &$GLOBALS['_PEAR_default_error_mode']; - $def_options = &$GLOBALS['_PEAR_default_error_options']; - $stack[] = array($def_mode, $def_options); - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $def_mode = $mode; - $def_options = $options; - break; - - case PEAR_ERROR_CALLBACK: - $def_mode = $mode; - // class/object method callback - if (is_callable($options)) { - $def_options = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - $stack[] = array($mode, $options); - return true; - } - - function staticPopErrorHandling() - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - $setmode = &$GLOBALS['_PEAR_default_error_mode']; - $setoptions = &$GLOBALS['_PEAR_default_error_options']; - array_pop($stack); - list($mode, $options) = $stack[sizeof($stack) - 1]; - array_pop($stack); - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $setmode = $mode; - $setoptions = $options; - break; - - case PEAR_ERROR_CALLBACK: - $setmode = $mode; - // class/object method callback - if (is_callable($options)) { - $setoptions = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - return true; - } - - /** - * Push a new error handler on top of the error handler options stack. With this - * you can easily override the actual error handler for some code and restore - * it later with popErrorHandling. - * - * @param mixed $mode (same as setErrorHandling) - * @param mixed $options (same as setErrorHandling) - * - * @return bool Always true - * - * @see PEAR::setErrorHandling - */ - function pushErrorHandling($mode, $options = null) - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - if (isset($this) && is_a($this, 'PEAR')) { - $def_mode = &$this->_default_error_mode; - $def_options = &$this->_default_error_options; - } else { - $def_mode = &$GLOBALS['_PEAR_default_error_mode']; - $def_options = &$GLOBALS['_PEAR_default_error_options']; - } - $stack[] = array($def_mode, $def_options); - - if (isset($this) && is_a($this, 'PEAR')) { - $this->setErrorHandling($mode, $options); - } else { - PEAR::setErrorHandling($mode, $options); - } - $stack[] = array($mode, $options); - return true; - } - - /** - * Pop the last error handler used - * - * @return bool Always true - * - * @see PEAR::pushErrorHandling - */ - function popErrorHandling() - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - array_pop($stack); - list($mode, $options) = $stack[sizeof($stack) - 1]; - array_pop($stack); - if (isset($this) && is_a($this, 'PEAR')) { - $this->setErrorHandling($mode, $options); - } else { - PEAR::setErrorHandling($mode, $options); - } - return true; - } - - /** - * OS independent PHP extension load. Remember to take care - * on the correct extension name for case sensitive OSes. - * - * @param string $ext The extension name - * @return bool Success or not on the dl() call - */ - function loadExtension($ext) - { - if (extension_loaded($ext)) { - return true; - } - - // if either returns true dl() will produce a FATAL error, stop that - if ( - function_exists('dl') === false || - ini_get('enable_dl') != 1 || - ini_get('safe_mode') == 1 - ) { - return false; - } - - if (OS_WINDOWS) { - $suffix = '.dll'; - } elseif (PHP_OS == 'HP-UX') { - $suffix = '.sl'; - } elseif (PHP_OS == 'AIX') { - $suffix = '.a'; - } elseif (PHP_OS == 'OSX') { - $suffix = '.bundle'; - } else { - $suffix = '.so'; - } - - return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix); - } -} - -if (PEAR_ZE2) { - include_once 'PEAR5.php'; -} - -function _PEAR_call_destructors() -{ - global $_PEAR_destructor_object_list; - if (is_array($_PEAR_destructor_object_list) && - sizeof($_PEAR_destructor_object_list)) - { - reset($_PEAR_destructor_object_list); - if (PEAR_ZE2) { - $destructLifoExists = PEAR5::getStaticProperty('PEAR', 'destructlifo'); - } else { - $destructLifoExists = PEAR::getStaticProperty('PEAR', 'destructlifo'); - } - - if ($destructLifoExists) { - $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list); - } - - while (list($k, $objref) = each($_PEAR_destructor_object_list)) { - $classname = get_class($objref); - while ($classname) { - $destructor = "_$classname"; - if (method_exists($objref, $destructor)) { - $objref->$destructor(); - break; - } else { - $classname = get_parent_class($classname); - } - } - } - // Empty the object list to ensure that destructors are - // not called more than once. - $_PEAR_destructor_object_list = array(); - } - - // Now call the shutdown functions - if ( - isset($GLOBALS['_PEAR_shutdown_funcs']) && - is_array($GLOBALS['_PEAR_shutdown_funcs']) && - !empty($GLOBALS['_PEAR_shutdown_funcs']) - ) { - foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) { - call_user_func_array($value[0], $value[1]); - } - } -} - -/** - * Standard PEAR error class for PHP 4 - * - * This class is supserseded by {@link PEAR_Exception} in PHP 5 - * - * @category pear - * @package PEAR - * @author Stig Bakken - * @author Tomas V.V. Cox - * @author Gregory Beaver - * @copyright 1997-2006 The PHP Group - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.9.5 - * @link http://pear.php.net/manual/en/core.pear.pear-error.php - * @see PEAR::raiseError(), PEAR::throwError() - * @since Class available since PHP 4.0.2 - */ -class PEAR_Error -{ - var $error_message_prefix = ''; - var $mode = PEAR_ERROR_RETURN; - var $level = E_USER_NOTICE; - var $code = -1; - var $message = ''; - var $userinfo = ''; - var $backtrace = null; - - /** - * PEAR_Error constructor - * - * @param string $message message - * - * @param int $code (optional) error code - * - * @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN, - * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER, - * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION - * - * @param mixed $options (optional) error level, _OR_ in the case of - * PEAR_ERROR_CALLBACK, the callback function or object/method - * tuple. - * - * @param string $userinfo (optional) additional user/debug info - * - * @access public - * - */ - function PEAR_Error($message = 'unknown error', $code = null, - $mode = null, $options = null, $userinfo = null) - { - if ($mode === null) { - $mode = PEAR_ERROR_RETURN; - } - $this->message = $message; - $this->code = $code; - $this->mode = $mode; - $this->userinfo = $userinfo; - - if (PEAR_ZE2) { - $skiptrace = PEAR5::getStaticProperty('PEAR_Error', 'skiptrace'); - } else { - $skiptrace = PEAR::getStaticProperty('PEAR_Error', 'skiptrace'); - } - - if (!$skiptrace) { - $this->backtrace = debug_backtrace(); - if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) { - unset($this->backtrace[0]['object']); - } - } - - if ($mode & PEAR_ERROR_CALLBACK) { - $this->level = E_USER_NOTICE; - $this->callback = $options; - } else { - if ($options === null) { - $options = E_USER_NOTICE; - } - - $this->level = $options; - $this->callback = null; - } - - if ($this->mode & PEAR_ERROR_PRINT) { - if (is_null($options) || is_int($options)) { - $format = "%s"; - } else { - $format = $options; - } - - printf($format, $this->getMessage()); - } - - if ($this->mode & PEAR_ERROR_TRIGGER) { - trigger_error($this->getMessage(), $this->level); - } - - if ($this->mode & PEAR_ERROR_DIE) { - $msg = $this->getMessage(); - if (is_null($options) || is_int($options)) { - $format = "%s"; - if (substr($msg, -1) != "\n") { - $msg .= "\n"; - } - } else { - $format = $options; - } - die(sprintf($format, $msg)); - } - - if ($this->mode & PEAR_ERROR_CALLBACK && is_callable($this->callback)) { - call_user_func($this->callback, $this); - } - - if ($this->mode & PEAR_ERROR_EXCEPTION) { - trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING); - eval('$e = new Exception($this->message, $this->code);throw($e);'); - } - } - - /** - * Get the error mode from an error object. - * - * @return int error mode - * @access public - */ - function getMode() - { - return $this->mode; - } - - /** - * Get the callback function/method from an error object. - * - * @return mixed callback function or object/method array - * @access public - */ - function getCallback() - { - return $this->callback; - } - - /** - * Get the error message from an error object. - * - * @return string full error message - * @access public - */ - function getMessage() - { - return ($this->error_message_prefix . $this->message); - } - - /** - * Get error code from an error object - * - * @return int error code - * @access public - */ - function getCode() - { - return $this->code; - } - - /** - * Get the name of this error/exception. - * - * @return string error/exception name (type) - * @access public - */ - function getType() - { - return get_class($this); - } - - /** - * Get additional user-supplied information. - * - * @return string user-supplied information - * @access public - */ - function getUserInfo() - { - return $this->userinfo; - } - - /** - * Get additional debug information supplied by the application. - * - * @return string debug information - * @access public - */ - function getDebugInfo() - { - return $this->getUserInfo(); - } - - /** - * Get the call backtrace from where the error was generated. - * Supported with PHP 4.3.0 or newer. - * - * @param int $frame (optional) what frame to fetch - * @return array Backtrace, or NULL if not available. - * @access public - */ - function getBacktrace($frame = null) - { - if (defined('PEAR_IGNORE_BACKTRACE')) { - return null; - } - if ($frame === null) { - return $this->backtrace; - } - return $this->backtrace[$frame]; - } - - function addUserInfo($info) - { - if (empty($this->userinfo)) { - $this->userinfo = $info; - } else { - $this->userinfo .= " ** $info"; - } - } - - function __toString() - { - return $this->getMessage(); - } - - /** - * Make a string representation of this object. - * - * @return string a string with an object summary - * @access public - */ - function toString() - { - $modes = array(); - $levels = array(E_USER_NOTICE => 'notice', - E_USER_WARNING => 'warning', - E_USER_ERROR => 'error'); - if ($this->mode & PEAR_ERROR_CALLBACK) { - if (is_array($this->callback)) { - $callback = (is_object($this->callback[0]) ? - strtolower(get_class($this->callback[0])) : - $this->callback[0]) . '::' . - $this->callback[1]; - } else { - $callback = $this->callback; - } - return sprintf('[%s: message="%s" code=%d mode=callback '. - 'callback=%s prefix="%s" info="%s"]', - strtolower(get_class($this)), $this->message, $this->code, - $callback, $this->error_message_prefix, - $this->userinfo); - } - if ($this->mode & PEAR_ERROR_PRINT) { - $modes[] = 'print'; - } - if ($this->mode & PEAR_ERROR_TRIGGER) { - $modes[] = 'trigger'; - } - if ($this->mode & PEAR_ERROR_DIE) { - $modes[] = 'die'; - } - if ($this->mode & PEAR_ERROR_RETURN) { - $modes[] = 'return'; - } - return sprintf('[%s: message="%s" code=%d mode=%s level=%s '. - 'prefix="%s" info="%s"]', - strtolower(get_class($this)), $this->message, $this->code, - implode("|", $modes), $levels[$this->level], - $this->error_message_prefix, - $this->userinfo); - } -} - -/* - * Local Variables: - * mode: php - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/libs/PEAR.1.9.5/PEAR/Exception.php b/libs/PEAR.1.9.5/PEAR/Exception.php deleted file mode 100644 index 2990cb612..000000000 --- a/libs/PEAR.1.9.5/PEAR/Exception.php +++ /dev/null @@ -1,389 +0,0 @@ - - * @author Hans Lellelid - * @author Bertrand Mansion - * @author Greg Beaver - * @copyright 1997-2009 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id$ - * @link http://pear.php.net/package/PEAR - * @since File available since Release 1.3.3 - */ - - -/** - * Base PEAR_Exception Class - * - * 1) Features: - * - * - Nestable exceptions (throw new PEAR_Exception($msg, $prev_exception)) - * - Definable triggers, shot when exceptions occur - * - Pretty and informative error messages - * - Added more context info available (like class, method or cause) - * - cause can be a PEAR_Exception or an array of mixed - * PEAR_Exceptions/PEAR_ErrorStack warnings - * - callbacks for specific exception classes and their children - * - * 2) Ideas: - * - * - Maybe a way to define a 'template' for the output - * - * 3) Inherited properties from PHP Exception Class: - * - * protected $message - * protected $code - * protected $line - * protected $file - * private $trace - * - * 4) Inherited methods from PHP Exception Class: - * - * __clone - * __construct - * getMessage - * getCode - * getFile - * getLine - * getTraceSafe - * getTraceSafeAsString - * __toString - * - * 5) Usage example - * - * - * require_once 'PEAR/Exception.php'; - * - * class Test { - * function foo() { - * throw new PEAR_Exception('Error Message', ERROR_CODE); - * } - * } - * - * function myLogger($pear_exception) { - * echo $pear_exception->getMessage(); - * } - * // each time a exception is thrown the 'myLogger' will be called - * // (its use is completely optional) - * PEAR_Exception::addObserver('myLogger'); - * $test = new Test; - * try { - * $test->foo(); - * } catch (PEAR_Exception $e) { - * print $e; - * } - * - * - * @category pear - * @package PEAR - * @author Tomas V.V.Cox - * @author Hans Lellelid - * @author Bertrand Mansion - * @author Greg Beaver - * @copyright 1997-2009 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.9.5 - * @link http://pear.php.net/package/PEAR - * @since Class available since Release 1.3.3 - * - */ -class PEAR_Exception extends Exception -{ - const OBSERVER_PRINT = -2; - const OBSERVER_TRIGGER = -4; - const OBSERVER_DIE = -8; - protected $cause; - private static $_observers = array(); - private static $_uniqueid = 0; - private $_trace; - - /** - * Supported signatures: - * - PEAR_Exception(string $message); - * - PEAR_Exception(string $message, int $code); - * - PEAR_Exception(string $message, Exception $cause); - * - PEAR_Exception(string $message, Exception $cause, int $code); - * - PEAR_Exception(string $message, PEAR_Error $cause); - * - PEAR_Exception(string $message, PEAR_Error $cause, int $code); - * - PEAR_Exception(string $message, array $causes); - * - PEAR_Exception(string $message, array $causes, int $code); - * @param string exception message - * @param int|Exception|PEAR_Error|array|null exception cause - * @param int|null exception code or null - */ - public function __construct($message, $p2 = null, $p3 = null) - { - if (is_int($p2)) { - $code = $p2; - $this->cause = null; - } elseif (is_object($p2) || is_array($p2)) { - // using is_object allows both Exception and PEAR_Error - if (is_object($p2) && !($p2 instanceof Exception)) { - if (!class_exists('PEAR_Error') || !($p2 instanceof PEAR_Error)) { - throw new PEAR_Exception('exception cause must be Exception, ' . - 'array, or PEAR_Error'); - } - } - $code = $p3; - if (is_array($p2) && isset($p2['message'])) { - // fix potential problem of passing in a single warning - $p2 = array($p2); - } - $this->cause = $p2; - } else { - $code = null; - $this->cause = null; - } - parent::__construct($message, $code); - $this->signal(); - } - - /** - * @param mixed $callback - A valid php callback, see php func is_callable() - * - A PEAR_Exception::OBSERVER_* constant - * - An array(const PEAR_Exception::OBSERVER_*, - * mixed $options) - * @param string $label The name of the observer. Use this if you want - * to remove it later with removeObserver() - */ - public static function addObserver($callback, $label = 'default') - { - self::$_observers[$label] = $callback; - } - - public static function removeObserver($label = 'default') - { - unset(self::$_observers[$label]); - } - - /** - * @return int unique identifier for an observer - */ - public static function getUniqueId() - { - return self::$_uniqueid++; - } - - private function signal() - { - foreach (self::$_observers as $func) { - if (is_callable($func)) { - call_user_func($func, $this); - continue; - } - settype($func, 'array'); - switch ($func[0]) { - case self::OBSERVER_PRINT : - $f = (isset($func[1])) ? $func[1] : '%s'; - printf($f, $this->getMessage()); - break; - case self::OBSERVER_TRIGGER : - $f = (isset($func[1])) ? $func[1] : E_USER_NOTICE; - trigger_error($this->getMessage(), $f); - break; - case self::OBSERVER_DIE : - $f = (isset($func[1])) ? $func[1] : '%s'; - die(printf($f, $this->getMessage())); - break; - default: - trigger_error('invalid observer type', E_USER_WARNING); - } - } - } - - /** - * Return specific error information that can be used for more detailed - * error messages or translation. - * - * This method may be overridden in child exception classes in order - * to add functionality not present in PEAR_Exception and is a placeholder - * to define API - * - * The returned array must be an associative array of parameter => value like so: - *
-     * array('name' => $name, 'context' => array(...))
-     * 
- * @return array - */ - public function getErrorData() - { - return array(); - } - - /** - * Returns the exception that caused this exception to be thrown - * @access public - * @return Exception|array The context of the exception - */ - public function getCause() - { - return $this->cause; - } - - /** - * Function must be public to call on caused exceptions - * @param array - */ - public function getCauseMessage(&$causes) - { - $trace = $this->getTraceSafe(); - $cause = array('class' => get_class($this), - 'message' => $this->message, - 'file' => 'unknown', - 'line' => 'unknown'); - if (isset($trace[0])) { - if (isset($trace[0]['file'])) { - $cause['file'] = $trace[0]['file']; - $cause['line'] = $trace[0]['line']; - } - } - $causes[] = $cause; - if ($this->cause instanceof PEAR_Exception) { - $this->cause->getCauseMessage($causes); - } elseif ($this->cause instanceof Exception) { - $causes[] = array('class' => get_class($this->cause), - 'message' => $this->cause->getMessage(), - 'file' => $this->cause->getFile(), - 'line' => $this->cause->getLine()); - } elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) { - $causes[] = array('class' => get_class($this->cause), - 'message' => $this->cause->getMessage(), - 'file' => 'unknown', - 'line' => 'unknown'); - } elseif (is_array($this->cause)) { - foreach ($this->cause as $cause) { - if ($cause instanceof PEAR_Exception) { - $cause->getCauseMessage($causes); - } elseif ($cause instanceof Exception) { - $causes[] = array('class' => get_class($cause), - 'message' => $cause->getMessage(), - 'file' => $cause->getFile(), - 'line' => $cause->getLine()); - } elseif (class_exists('PEAR_Error') && $cause instanceof PEAR_Error) { - $causes[] = array('class' => get_class($cause), - 'message' => $cause->getMessage(), - 'file' => 'unknown', - 'line' => 'unknown'); - } elseif (is_array($cause) && isset($cause['message'])) { - // PEAR_ErrorStack warning - $causes[] = array( - 'class' => $cause['package'], - 'message' => $cause['message'], - 'file' => isset($cause['context']['file']) ? - $cause['context']['file'] : - 'unknown', - 'line' => isset($cause['context']['line']) ? - $cause['context']['line'] : - 'unknown', - ); - } - } - } - } - - public function getTraceSafe() - { - if (!isset($this->_trace)) { - $this->_trace = $this->getTrace(); - if (empty($this->_trace)) { - $backtrace = debug_backtrace(); - $this->_trace = array($backtrace[count($backtrace)-1]); - } - } - return $this->_trace; - } - - public function getErrorClass() - { - $trace = $this->getTraceSafe(); - return $trace[0]['class']; - } - - public function getErrorMethod() - { - $trace = $this->getTraceSafe(); - return $trace[0]['function']; - } - - public function __toString() - { - if (isset($_SERVER['REQUEST_URI'])) { - return $this->toHtml(); - } - return $this->toText(); - } - - public function toHtml() - { - $trace = $this->getTraceSafe(); - $causes = array(); - $this->getCauseMessage($causes); - $html = '' . "\n"; - foreach ($causes as $i => $cause) { - $html .= '\n"; - } - $html .= '' . "\n" - . '' - . '' - . '' . "\n"; - - foreach ($trace as $k => $v) { - $html .= '' - . '' - . '' . "\n"; - } - $html .= '' - . '' - . '' . "\n" - . '
' - . str_repeat('-', $i) . ' ' . $cause['class'] . ': ' - . htmlspecialchars($cause['message']) . ' in ' . $cause['file'] . ' ' - . 'on line ' . $cause['line'] . '' - . "
Exception trace
#FunctionLocation
' . $k . ''; - if (!empty($v['class'])) { - $html .= $v['class'] . $v['type']; - } - $html .= $v['function']; - $args = array(); - if (!empty($v['args'])) { - foreach ($v['args'] as $arg) { - if (is_null($arg)) $args[] = 'null'; - elseif (is_array($arg)) $args[] = 'Array'; - elseif (is_object($arg)) $args[] = 'Object('.get_class($arg).')'; - elseif (is_bool($arg)) $args[] = $arg ? 'true' : 'false'; - elseif (is_int($arg) || is_double($arg)) $args[] = $arg; - else { - $arg = (string)$arg; - $str = htmlspecialchars(substr($arg, 0, 16)); - if (strlen($arg) > 16) $str .= '…'; - $args[] = "'" . $str . "'"; - } - } - } - $html .= '(' . implode(', ',$args) . ')' - . '' . (isset($v['file']) ? $v['file'] : 'unknown') - . ':' . (isset($v['line']) ? $v['line'] : 'unknown') - . '
' . ($k+1) . '{main} 
'; - return $html; - } - - public function toText() - { - $causes = array(); - $this->getCauseMessage($causes); - $causeMsg = ''; - foreach ($causes as $i => $cause) { - $causeMsg .= str_repeat(' ', $i) . $cause['class'] . ': ' - . $cause['message'] . ' in ' . $cause['file'] - . ' on line ' . $cause['line'] . "\n"; - } - return $causeMsg . $this->getTraceAsString(); - } -} \ No newline at end of file diff --git a/libs/PEAR.1.9.5/PEAR5.php b/libs/PEAR.1.9.5/PEAR5.php deleted file mode 100644 index 428606780..000000000 --- a/libs/PEAR.1.9.5/PEAR5.php +++ /dev/null @@ -1,33 +0,0 @@ -setHeader($name, $value); - } - - public function sendRequest($saveBody = true) - { - $response = $this->send(); - $this->response = $response; - return $response; - } - - public function getResponseCode() { - if($this->response) - { - return $this->response->getStatus(); - } - } - - public function getResponseHeader() { - if($this->response) - { - return $this->response->getHeader(); - } - } - - public function getResponseBody() { - if($this->response) - { - return $this->response->getBody(); - } - } - - public function getResponseCookies() { - if($this->response) - { - return $this->response->getCookies(); - } - } - - public function addPostData($name, $value, $preencoded = false) - { - $this->addPostParameter($name, $value); - } - -} - -?> diff --git a/libs/PEAR.1.9/HTTP/Request2.php b/libs/PEAR.1.9/HTTP/Request2.php deleted file mode 100644 index 1347d6ece..000000000 --- a/libs/PEAR.1.9/HTTP/Request2.php +++ /dev/null @@ -1,861 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: Request2.php 298246 2010-04-21 10:41:16Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * A class representing an URL as per RFC 3986. - */ -require_once 'Net/URL2.php'; - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class representing a HTTP request message - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @version Release: 0.5.2 - * @link http://tools.ietf.org/html/rfc2616#section-5 - */ -class HTTP_Request2 implements SplSubject -{ - /**#@+ - * Constants for HTTP request methods - * - * @link http://tools.ietf.org/html/rfc2616#section-5.1.1 - */ - const METHOD_OPTIONS = 'OPTIONS'; - const METHOD_GET = 'GET'; - const METHOD_HEAD = 'HEAD'; - const METHOD_POST = 'POST'; - const METHOD_PUT = 'PUT'; - const METHOD_DELETE = 'DELETE'; - const METHOD_TRACE = 'TRACE'; - const METHOD_CONNECT = 'CONNECT'; - /**#@-*/ - - /**#@+ - * Constants for HTTP authentication schemes - * - * @link http://tools.ietf.org/html/rfc2617 - */ - const AUTH_BASIC = 'basic'; - const AUTH_DIGEST = 'digest'; - /**#@-*/ - - /** - * Regular expression used to check for invalid symbols in RFC 2616 tokens - * @link http://pear.php.net/bugs/bug.php?id=15630 - */ - const REGEXP_INVALID_TOKEN = '![\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]!'; - - /** - * Regular expression used to check for invalid symbols in cookie strings - * @link http://pear.php.net/bugs/bug.php?id=15630 - * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html - */ - const REGEXP_INVALID_COOKIE = '/[\s,;]/'; - - /** - * Fileinfo magic database resource - * @var resource - * @see detectMimeType() - */ - private static $_fileinfoDb; - - /** - * Observers attached to the request (instances of SplObserver) - * @var array - */ - protected $observers = array(); - - /** - * Request URL - * @var Net_URL2 - */ - protected $url; - - /** - * Request method - * @var string - */ - protected $method = self::METHOD_GET; - - /** - * Authentication data - * @var array - * @see getAuth() - */ - protected $auth; - - /** - * Request headers - * @var array - */ - protected $headers = array(); - - /** - * Configuration parameters - * @var array - * @see setConfig() - */ - protected $config = array( - 'adapter' => 'HTTP_Request2_Adapter_Socket', - 'connect_timeout' => 10, - 'timeout' => 0, - 'use_brackets' => true, - 'protocol_version' => '1.1', - 'buffer_size' => 16384, - 'store_body' => true, - - 'proxy_host' => '', - 'proxy_port' => '', - 'proxy_user' => '', - 'proxy_password' => '', - 'proxy_auth_scheme' => self::AUTH_BASIC, - - 'ssl_verify_peer' => true, - 'ssl_verify_host' => true, - 'ssl_cafile' => null, - 'ssl_capath' => null, - 'ssl_local_cert' => null, - 'ssl_passphrase' => null, - - 'digest_compat_ie' => false, - - 'follow_redirects' => false, - 'max_redirects' => 5, - 'strict_redirects' => false - ); - - /** - * Last event in request / response handling, intended for observers - * @var array - * @see getLastEvent() - */ - protected $lastEvent = array( - 'name' => 'start', - 'data' => null - ); - - /** - * Request body - * @var string|resource - * @see setBody() - */ - protected $body = ''; - - /** - * Array of POST parameters - * @var array - */ - protected $postParams = array(); - - /** - * Array of file uploads (for multipart/form-data POST requests) - * @var array - */ - protected $uploads = array(); - - /** - * Adapter used to perform actual HTTP request - * @var HTTP_Request2_Adapter - */ - protected $adapter; - - - /** - * Constructor. Can set request URL, method and configuration array. - * - * Also sets a default value for User-Agent header. - * - * @param string|Net_Url2 Request URL - * @param string Request method - * @param array Configuration for this Request instance - */ - public function __construct($url = null, $method = self::METHOD_GET, array $config = array()) - { - $this->setConfig($config); - if (!empty($url)) { - $this->setUrl($url); - } - if (!empty($method)) { - $this->setMethod($method); - } - $this->setHeader('user-agent', 'HTTP_Request2/0.5.2 ' . - '(http://pear.php.net/package/http_request2) ' . - 'PHP/' . phpversion()); - } - - /** - * Sets the URL for this request - * - * If the URL has userinfo part (username & password) these will be removed - * and converted to auth data. If the URL does not have a path component, - * that will be set to '/'. - * - * @param string|Net_URL2 Request URL - * @return HTTP_Request2 - * @throws HTTP_Request2_Exception - */ - public function setUrl($url) - { - if (is_string($url)) { - $url = new Net_URL2( - $url, array(Net_URL2::OPTION_USE_BRACKETS => $this->config['use_brackets']) - ); - } - if (!$url instanceof Net_URL2) { - throw new HTTP_Request2_Exception('Parameter is not a valid HTTP URL'); - } - // URL contains username / password? - if ($url->getUserinfo()) { - $username = $url->getUser(); - $password = $url->getPassword(); - $this->setAuth(rawurldecode($username), $password? rawurldecode($password): ''); - $url->setUserinfo(''); - } - if ('' == $url->getPath()) { - $url->setPath('/'); - } - $this->url = $url; - - return $this; - } - - /** - * Returns the request URL - * - * @return Net_URL2 - */ - public function getUrl() - { - return $this->url; - } - - /** - * Sets the request method - * - * @param string - * @return HTTP_Request2 - * @throws HTTP_Request2_Exception if the method name is invalid - */ - public function setMethod($method) - { - // Method name should be a token: http://tools.ietf.org/html/rfc2616#section-5.1.1 - if (preg_match(self::REGEXP_INVALID_TOKEN, $method)) { - throw new HTTP_Request2_Exception("Invalid request method '{$method}'"); - } - $this->method = $method; - - return $this; - } - - /** - * Returns the request method - * - * @return string - */ - public function getMethod() - { - return $this->method; - } - - /** - * Sets the configuration parameter(s) - * - * The following parameters are available: - *
    - *
  • 'adapter' - adapter to use (string)
  • - *
  • 'connect_timeout' - Connection timeout in seconds (integer)
  • - *
  • 'timeout' - Total number of seconds a request can take. - * Use 0 for no limit, should be greater than - * 'connect_timeout' if set (integer)
  • - *
  • 'use_brackets' - Whether to append [] to array variable names (bool)
  • - *
  • 'protocol_version' - HTTP Version to use, '1.0' or '1.1' (string)
  • - *
  • 'buffer_size' - Buffer size to use for reading and writing (int)
  • - *
  • 'store_body' - Whether to store response body in response object. - * Set to false if receiving a huge response and - * using an Observer to save it (boolean)
  • - *
  • 'proxy_host' - Proxy server host (string)
  • - *
  • 'proxy_port' - Proxy server port (integer)
  • - *
  • 'proxy_user' - Proxy auth username (string)
  • - *
  • 'proxy_password' - Proxy auth password (string)
  • - *
  • 'proxy_auth_scheme' - Proxy auth scheme, one of HTTP_Request2::AUTH_* constants (string)
  • - *
  • 'ssl_verify_peer' - Whether to verify peer's SSL certificate (bool)
  • - *
  • 'ssl_verify_host' - Whether to check that Common Name in SSL - * certificate matches host name (bool)
  • - *
  • 'ssl_cafile' - Cerificate Authority file to verify the peer - * with (use with 'ssl_verify_peer') (string)
  • - *
  • 'ssl_capath' - Directory holding multiple Certificate - * Authority files (string)
  • - *
  • 'ssl_local_cert' - Name of a file containing local cerificate (string)
  • - *
  • 'ssl_passphrase' - Passphrase with which local certificate - * was encoded (string)
  • - *
  • 'digest_compat_ie' - Whether to imitate behaviour of MSIE 5 and 6 - * in using URL without query string in digest - * authentication (boolean)
  • - *
  • 'follow_redirects' - Whether to automatically follow HTTP Redirects (boolean)
  • - *
  • 'max_redirects' - Maximum number of redirects to follow (integer)
  • - *
  • 'strict_redirects' - Whether to keep request method on redirects via status 301 and - * 302 (true, needed for compatibility with RFC 2616) - * or switch to GET (false, needed for compatibility with most - * browsers) (boolean)
  • - *
- * - * @param string|array configuration parameter name or array - * ('parameter name' => 'parameter value') - * @param mixed parameter value if $nameOrConfig is not an array - * @return HTTP_Request2 - * @throws HTTP_Request2_Exception If the parameter is unknown - */ - public function setConfig($nameOrConfig, $value = null) - { - if (is_array($nameOrConfig)) { - foreach ($nameOrConfig as $name => $value) { - $this->setConfig($name, $value); - } - - } else { - if (!array_key_exists($nameOrConfig, $this->config)) { - throw new HTTP_Request2_Exception( - "Unknown configuration parameter '{$nameOrConfig}'" - ); - } - $this->config[$nameOrConfig] = $value; - } - - return $this; - } - - /** - * Returns the value(s) of the configuration parameter(s) - * - * @param string parameter name - * @return mixed value of $name parameter, array of all configuration - * parameters if $name is not given - * @throws HTTP_Request2_Exception If the parameter is unknown - */ - public function getConfig($name = null) - { - if (null === $name) { - return $this->config; - } elseif (!array_key_exists($name, $this->config)) { - throw new HTTP_Request2_Exception( - "Unknown configuration parameter '{$name}'" - ); - } - return $this->config[$name]; - } - - /** - * Sets the autentification data - * - * @param string user name - * @param string password - * @param string authentication scheme - * @return HTTP_Request2 - */ - public function setAuth($user, $password = '', $scheme = self::AUTH_BASIC) - { - if (empty($user)) { - $this->auth = null; - } else { - $this->auth = array( - 'user' => (string)$user, - 'password' => (string)$password, - 'scheme' => $scheme - ); - } - - return $this; - } - - /** - * Returns the authentication data - * - * The array has the keys 'user', 'password' and 'scheme', where 'scheme' - * is one of the HTTP_Request2::AUTH_* constants. - * - * @return array - */ - public function getAuth() - { - return $this->auth; - } - - /** - * Sets request header(s) - * - * The first parameter may be either a full header string 'header: value' or - * header name. In the former case $value parameter is ignored, in the latter - * the header's value will either be set to $value or the header will be - * removed if $value is null. The first parameter can also be an array of - * headers, in that case method will be called recursively. - * - * Note that headers are treated case insensitively as per RFC 2616. - * - * - * $req->setHeader('Foo: Bar'); // sets the value of 'Foo' header to 'Bar' - * $req->setHeader('FoO', 'Baz'); // sets the value of 'Foo' header to 'Baz' - * $req->setHeader(array('foo' => 'Quux')); // sets the value of 'Foo' header to 'Quux' - * $req->setHeader('FOO'); // removes 'Foo' header from request - * - * - * @param string|array header name, header string ('Header: value') - * or an array of headers - * @param string|null header value, header will be removed if null - * @return HTTP_Request2 - * @throws HTTP_Request2_Exception - */ - public function setHeader($name, $value = null) - { - if (is_array($name)) { - foreach ($name as $k => $v) { - if (is_string($k)) { - $this->setHeader($k, $v); - } else { - $this->setHeader($v); - } - } - } else { - if (null === $value && strpos($name, ':')) { - list($name, $value) = array_map('trim', explode(':', $name, 2)); - } - // Header name should be a token: http://tools.ietf.org/html/rfc2616#section-4.2 - if (preg_match(self::REGEXP_INVALID_TOKEN, $name)) { - throw new HTTP_Request2_Exception("Invalid header name '{$name}'"); - } - // Header names are case insensitive anyway - $name = strtolower($name); - if (null === $value) { - unset($this->headers[$name]); - } else { - $this->headers[$name] = $value; - } - } - - return $this; - } - - /** - * Returns the request headers - * - * The array is of the form ('header name' => 'header value'), header names - * are lowercased - * - * @return array - */ - public function getHeaders() - { - return $this->headers; - } - - /** - * Appends a cookie to "Cookie:" header - * - * @param string cookie name - * @param string cookie value - * @return HTTP_Request2 - * @throws HTTP_Request2_Exception - */ - public function addCookie($name, $value) - { - $cookie = $name . '=' . $value; - if (preg_match(self::REGEXP_INVALID_COOKIE, $cookie)) { - throw new HTTP_Request2_Exception("Invalid cookie: '{$cookie}'"); - } - $cookies = empty($this->headers['cookie'])? '': $this->headers['cookie'] . '; '; - $this->setHeader('cookie', $cookies . $cookie); - - return $this; - } - - /** - * Sets the request body - * - * @param string Either a string with the body or filename containing body - * @param bool Whether first parameter is a filename - * @return HTTP_Request2 - * @throws HTTP_Request2_Exception - */ - public function setBody($body, $isFilename = false) - { - if (!$isFilename) { - if (!$body instanceof HTTP_Request2_MultipartBody) { - $this->body = (string)$body; - } else { - $this->body = $body; - } - } else { - if (!($fp = @fopen($body, 'rb'))) { - throw new HTTP_Request2_Exception("Cannot open file {$body}"); - } - $this->body = $fp; - if (empty($this->headers['content-type'])) { - $this->setHeader('content-type', self::detectMimeType($body)); - } - } - $this->postParams = $this->uploads = array(); - - return $this; - } - - /** - * Returns the request body - * - * @return string|resource|HTTP_Request2_MultipartBody - */ - public function getBody() - { - if (self::METHOD_POST == $this->method && - (!empty($this->postParams) || !empty($this->uploads)) - ) { - if ('application/x-www-form-urlencoded' == $this->headers['content-type']) { - $body = http_build_query($this->postParams, '', '&'); - if (!$this->getConfig('use_brackets')) { - $body = preg_replace('/%5B\d+%5D=/', '=', $body); - } - // support RFC 3986 by not encoding '~' symbol (request #15368) - return str_replace('%7E', '~', $body); - - } elseif ('multipart/form-data' == $this->headers['content-type']) { - require_once 'HTTP/Request2/MultipartBody.php'; - return new HTTP_Request2_MultipartBody( - $this->postParams, $this->uploads, $this->getConfig('use_brackets') - ); - } - } - return $this->body; - } - - /** - * Adds a file to form-based file upload - * - * Used to emulate file upload via a HTML form. The method also sets - * Content-Type of HTTP request to 'multipart/form-data'. - * - * If you just want to send the contents of a file as the body of HTTP - * request you should use setBody() method. - * - * @param string name of file-upload field - * @param mixed full name of local file - * @param string filename to send in the request - * @param string content-type of file being uploaded - * @return HTTP_Request2 - * @throws HTTP_Request2_Exception - */ - public function addUpload($fieldName, $filename, $sendFilename = null, - $contentType = null) - { - if (!is_array($filename)) { - if (!($fp = @fopen($filename, 'rb'))) { - throw new HTTP_Request2_Exception("Cannot open file {$filename}"); - } - $this->uploads[$fieldName] = array( - 'fp' => $fp, - 'filename' => empty($sendFilename)? basename($filename): $sendFilename, - 'size' => filesize($filename), - 'type' => empty($contentType)? self::detectMimeType($filename): $contentType - ); - } else { - $fps = $names = $sizes = $types = array(); - foreach ($filename as $f) { - if (!is_array($f)) { - $f = array($f); - } - if (!($fp = @fopen($f[0], 'rb'))) { - throw new HTTP_Request2_Exception("Cannot open file {$f[0]}"); - } - $fps[] = $fp; - $names[] = empty($f[1])? basename($f[0]): $f[1]; - $sizes[] = filesize($f[0]); - $types[] = empty($f[2])? self::detectMimeType($f[0]): $f[2]; - } - $this->uploads[$fieldName] = array( - 'fp' => $fps, 'filename' => $names, 'size' => $sizes, 'type' => $types - ); - } - if (empty($this->headers['content-type']) || - 'application/x-www-form-urlencoded' == $this->headers['content-type'] - ) { - $this->setHeader('content-type', 'multipart/form-data'); - } - - return $this; - } - - /** - * Adds POST parameter(s) to the request. - * - * @param string|array parameter name or array ('name' => 'value') - * @param mixed parameter value (can be an array) - * @return HTTP_Request2 - */ - public function addPostParameter($name, $value = null) - { - if (!is_array($name)) { - $this->postParams[$name] = $value; - } else { - foreach ($name as $k => $v) { - $this->addPostParameter($k, $v); - } - } - if (empty($this->headers['content-type'])) { - $this->setHeader('content-type', 'application/x-www-form-urlencoded'); - } - - return $this; - } - - /** - * Attaches a new observer - * - * @param SplObserver - */ - public function attach(SplObserver $observer) - { - foreach ($this->observers as $attached) { - if ($attached === $observer) { - return; - } - } - $this->observers[] = $observer; - } - - /** - * Detaches an existing observer - * - * @param SplObserver - */ - public function detach(SplObserver $observer) - { - foreach ($this->observers as $key => $attached) { - if ($attached === $observer) { - unset($this->observers[$key]); - return; - } - } - } - - /** - * Notifies all observers - */ - public function notify() - { - foreach ($this->observers as $observer) { - $observer->update($this); - } - } - - /** - * Sets the last event - * - * Adapters should use this method to set the current state of the request - * and notify the observers. - * - * @param string event name - * @param mixed event data - */ - public function setLastEvent($name, $data = null) - { - $this->lastEvent = array( - 'name' => $name, - 'data' => $data - ); - $this->notify(); - } - - /** - * Returns the last event - * - * Observers should use this method to access the last change in request. - * The following event names are possible: - *
    - *
  • 'connect' - after connection to remote server, - * data is the destination (string)
  • - *
  • 'disconnect' - after disconnection from server
  • - *
  • 'sentHeaders' - after sending the request headers, - * data is the headers sent (string)
  • - *
  • 'sentBodyPart' - after sending a part of the request body, - * data is the length of that part (int)
  • - *
  • 'receivedHeaders' - after receiving the response headers, - * data is HTTP_Request2_Response object
  • - *
  • 'receivedBodyPart' - after receiving a part of the response - * body, data is that part (string)
  • - *
  • 'receivedEncodedBodyPart' - as 'receivedBodyPart', but data is still - * encoded by Content-Encoding
  • - *
  • 'receivedBody' - after receiving the complete response - * body, data is HTTP_Request2_Response object
  • - *
- * Different adapters may not send all the event types. Mock adapter does - * not send any events to the observers. - * - * @return array The array has two keys: 'name' and 'data' - */ - public function getLastEvent() - { - return $this->lastEvent; - } - - /** - * Sets the adapter used to actually perform the request - * - * You can pass either an instance of a class implementing HTTP_Request2_Adapter - * or a class name. The method will only try to include a file if the class - * name starts with HTTP_Request2_Adapter_, it will also try to prepend this - * prefix to the class name if it doesn't contain any underscores, so that - * - * $request->setAdapter('curl'); - * - * will work. - * - * @param string|HTTP_Request2_Adapter - * @return HTTP_Request2 - * @throws HTTP_Request2_Exception - */ - public function setAdapter($adapter) - { - if (is_string($adapter)) { - if (!class_exists($adapter, false)) { - if (false === strpos($adapter, '_')) { - $adapter = 'HTTP_Request2_Adapter_' . ucfirst($adapter); - } - if (preg_match('/^HTTP_Request2_Adapter_([a-zA-Z0-9]+)$/', $adapter)) { - include_once str_replace('_', DIRECTORY_SEPARATOR, $adapter) . '.php'; - } - if (!class_exists($adapter, false)) { - throw new HTTP_Request2_Exception("Class {$adapter} not found"); - } - } - $adapter = new $adapter; - } - if (!$adapter instanceof HTTP_Request2_Adapter) { - throw new HTTP_Request2_Exception('Parameter is not a HTTP request adapter'); - } - $this->adapter = $adapter; - - return $this; - } - - /** - * Sends the request and returns the response - * - * @throws HTTP_Request2_Exception - * @return HTTP_Request2_Response - */ - public function send() - { - // Sanity check for URL - if (!$this->url instanceof Net_URL2) { - throw new HTTP_Request2_Exception('No URL given'); - } elseif (!$this->url->isAbsolute()) { - throw new HTTP_Request2_Exception('Absolute URL required'); - } elseif (!in_array(strtolower($this->url->getScheme()), array('https', 'http'))) { - throw new HTTP_Request2_Exception('Not a HTTP URL'); - } - if (empty($this->adapter)) { - $this->setAdapter($this->getConfig('adapter')); - } - // magic_quotes_runtime may break file uploads and chunked response - // processing; see bug #4543. Don't use ini_get() here; see bug #16440. - if ($magicQuotes = get_magic_quotes_runtime()) { - set_magic_quotes_runtime(false); - } - // force using single byte encoding if mbstring extension overloads - // strlen() and substr(); see bug #1781, bug #10605 - if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { - $oldEncoding = mb_internal_encoding(); - mb_internal_encoding('iso-8859-1'); - } - - try { - $response = $this->adapter->sendRequest($this); - } catch (Exception $e) { - } - // cleanup in either case (poor man's "finally" clause) - if ($magicQuotes) { - set_magic_quotes_runtime(true); - } - if (!empty($oldEncoding)) { - mb_internal_encoding($oldEncoding); - } - // rethrow the exception - if (!empty($e)) { - throw $e; - } - return $response; - } - - /** - * Tries to detect MIME type of a file - * - * The method will try to use fileinfo extension if it is available, - * deprecated mime_content_type() function in the other case. If neither - * works, default 'application/octet-stream' MIME type is returned - * - * @param string filename - * @return string file MIME type - */ - protected static function detectMimeType($filename) - { - // finfo extension from PECL available - if (function_exists('finfo_open')) { - if (!isset(self::$_fileinfoDb)) { - self::$_fileinfoDb = @finfo_open(FILEINFO_MIME); - } - if (self::$_fileinfoDb) { - $info = finfo_file(self::$_fileinfoDb, $filename); - } - } - // (deprecated) mime_content_type function available - if (empty($info) && function_exists('mime_content_type')) { - return mime_content_type($filename); - } - return empty($info)? 'application/octet-stream': $info; - } -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9/HTTP/Request2/Adapter.php b/libs/PEAR.1.9/HTTP/Request2/Adapter.php deleted file mode 100644 index 8ebbf4607..000000000 --- a/libs/PEAR.1.9/HTTP/Request2/Adapter.php +++ /dev/null @@ -1,154 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: Adapter.php 291118 2009-11-21 17:58:23Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Class representing a HTTP response - */ -require_once 'HTTP/Request2/Response.php'; - -/** - * Base class for HTTP_Request2 adapters - * - * HTTP_Request2 class itself only defines methods for aggregating the request - * data, all actual work of sending the request to the remote server and - * receiving its response is performed by adapters. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @version Release: 0.5.2 - */ -abstract class HTTP_Request2_Adapter -{ - /** - * A list of methods that MUST NOT have a request body, per RFC 2616 - * @var array - */ - protected static $bodyDisallowed = array('TRACE'); - - /** - * Methods having defined semantics for request body - * - * Content-Length header (indicating that the body follows, section 4.3 of - * RFC 2616) will be sent for these methods even if no body was added - * - * @var array - * @link http://pear.php.net/bugs/bug.php?id=12900 - * @link http://pear.php.net/bugs/bug.php?id=14740 - */ - protected static $bodyRequired = array('POST', 'PUT'); - - /** - * Request being sent - * @var HTTP_Request2 - */ - protected $request; - - /** - * Request body - * @var string|resource|HTTP_Request2_MultipartBody - * @see HTTP_Request2::getBody() - */ - protected $requestBody; - - /** - * Length of the request body - * @var integer - */ - protected $contentLength; - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - abstract public function sendRequest(HTTP_Request2 $request); - - /** - * Calculates length of the request body, adds proper headers - * - * @param array associative array of request headers, this method will - * add proper 'Content-Length' and 'Content-Type' headers - * to this array (or remove them if not needed) - */ - protected function calculateRequestLength(&$headers) - { - $this->requestBody = $this->request->getBody(); - - if (is_string($this->requestBody)) { - $this->contentLength = strlen($this->requestBody); - } elseif (is_resource($this->requestBody)) { - $stat = fstat($this->requestBody); - $this->contentLength = $stat['size']; - rewind($this->requestBody); - } else { - $this->contentLength = $this->requestBody->getLength(); - $headers['content-type'] = 'multipart/form-data; boundary=' . - $this->requestBody->getBoundary(); - $this->requestBody->rewind(); - } - - if (in_array($this->request->getMethod(), self::$bodyDisallowed) || - 0 == $this->contentLength - ) { - // No body: send a Content-Length header nonetheless (request #12900), - // but do that only for methods that require a body (bug #14740) - if (in_array($this->request->getMethod(), self::$bodyRequired)) { - $headers['content-length'] = 0; - } else { - unset($headers['content-length']); - // if the method doesn't require a body and doesn't have a - // body, don't send a Content-Type header. (request #16799) - unset($headers['content-type']); - } - } else { - if (empty($headers['content-type'])) { - $headers['content-type'] = 'application/x-www-form-urlencoded'; - } - $headers['content-length'] = $this->contentLength; - } - } -} -?> diff --git a/libs/PEAR.1.9/HTTP/Request2/Adapter/Curl.php b/libs/PEAR.1.9/HTTP/Request2/Adapter/Curl.php deleted file mode 100644 index 3d9833403..000000000 --- a/libs/PEAR.1.9/HTTP/Request2/Adapter/Curl.php +++ /dev/null @@ -1,461 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: Curl.php 291118 2009-11-21 17:58:23Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for HTTP_Request2 adapters - */ -require_once 'HTTP/Request2/Adapter.php'; - -/** - * Adapter for HTTP_Request2 wrapping around cURL extension - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @version Release: 0.5.2 - */ -class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter -{ - /** - * Mapping of header names to cURL options - * @var array - */ - protected static $headerMap = array( - 'accept-encoding' => CURLOPT_ENCODING, - 'cookie' => CURLOPT_COOKIE, - 'referer' => CURLOPT_REFERER, - 'user-agent' => CURLOPT_USERAGENT - ); - - /** - * Mapping of SSL context options to cURL options - * @var array - */ - protected static $sslContextMap = array( - 'ssl_verify_peer' => CURLOPT_SSL_VERIFYPEER, - 'ssl_cafile' => CURLOPT_CAINFO, - 'ssl_capath' => CURLOPT_CAPATH, - 'ssl_local_cert' => CURLOPT_SSLCERT, - 'ssl_passphrase' => CURLOPT_SSLCERTPASSWD - ); - - /** - * Response being received - * @var HTTP_Request2_Response - */ - protected $response; - - /** - * Whether 'sentHeaders' event was sent to observers - * @var boolean - */ - protected $eventSentHeaders = false; - - /** - * Whether 'receivedHeaders' event was sent to observers - * @var boolean - */ - protected $eventReceivedHeaders = false; - - /** - * Position within request body - * @var integer - * @see callbackReadBody() - */ - protected $position = 0; - - /** - * Information about last transfer, as returned by curl_getinfo() - * @var array - */ - protected $lastInfo; - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - if (!extension_loaded('curl')) { - throw new HTTP_Request2_Exception('cURL extension not available'); - } - - $this->request = $request; - $this->response = null; - $this->position = 0; - $this->eventSentHeaders = false; - $this->eventReceivedHeaders = false; - - try { - if (false === curl_exec($ch = $this->createCurlHandle())) { - $errorMessage = 'Error sending request: #' . curl_errno($ch) . - ' ' . curl_error($ch); - } - } catch (Exception $e) { - } - $this->lastInfo = curl_getinfo($ch); - curl_close($ch); - - $response = $this->response; - unset($this->request, $this->requestBody, $this->response); - - if (!empty($e)) { - throw $e; - } elseif (!empty($errorMessage)) { - throw new HTTP_Request2_Exception($errorMessage); - } - - if (0 < $this->lastInfo['size_download']) { - $request->setLastEvent('receivedBody', $response); - } - return $response; - } - - /** - * Returns information about last transfer - * - * @return array associative array as returned by curl_getinfo() - */ - public function getInfo() - { - return $this->lastInfo; - } - - /** - * Creates a new cURL handle and populates it with data from the request - * - * @return resource a cURL handle, as created by curl_init() - * @throws HTTP_Request2_Exception - */ - protected function createCurlHandle() - { - $ch = curl_init(); - - curl_setopt_array($ch, array( - // setup write callbacks - CURLOPT_HEADERFUNCTION => array($this, 'callbackWriteHeader'), - CURLOPT_WRITEFUNCTION => array($this, 'callbackWriteBody'), - // buffer size - CURLOPT_BUFFERSIZE => $this->request->getConfig('buffer_size'), - // connection timeout - CURLOPT_CONNECTTIMEOUT => $this->request->getConfig('connect_timeout'), - // save full outgoing headers, in case someone is interested - CURLINFO_HEADER_OUT => true, - // request url - CURLOPT_URL => $this->request->getUrl()->getUrl() - )); - - // set up redirects - if (!$this->request->getConfig('follow_redirects')) { - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); - } else { - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_MAXREDIRS, $this->request->getConfig('max_redirects')); - // limit redirects to http(s), works in 5.2.10+ - if (defined('CURLOPT_REDIR_PROTOCOLS')) { - curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); - } - // works sometime after 5.3.0, http://bugs.php.net/bug.php?id=49571 - if ($this->request->getConfig('strict_redirects') && defined('CURLOPT_POSTREDIR ')) { - curl_setopt($ch, CURLOPT_POSTREDIR, 3); - } - } - - // request timeout - if ($timeout = $this->request->getConfig('timeout')) { - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); - } - - // set HTTP version - switch ($this->request->getConfig('protocol_version')) { - case '1.0': - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); - break; - case '1.1': - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); - } - - // set request method - switch ($this->request->getMethod()) { - case HTTP_Request2::METHOD_GET: - curl_setopt($ch, CURLOPT_HTTPGET, true); - break; - case HTTP_Request2::METHOD_POST: - curl_setopt($ch, CURLOPT_POST, true); - break; - case HTTP_Request2::METHOD_HEAD: - curl_setopt($ch, CURLOPT_NOBODY, true); - break; - default: - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->request->getMethod()); - } - - // set proxy, if needed - if ($host = $this->request->getConfig('proxy_host')) { - if (!($port = $this->request->getConfig('proxy_port'))) { - throw new HTTP_Request2_Exception('Proxy port not provided'); - } - curl_setopt($ch, CURLOPT_PROXY, $host . ':' . $port); - if ($user = $this->request->getConfig('proxy_user')) { - curl_setopt($ch, CURLOPT_PROXYUSERPWD, $user . ':' . - $this->request->getConfig('proxy_password')); - switch ($this->request->getConfig('proxy_auth_scheme')) { - case HTTP_Request2::AUTH_BASIC: - curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); - break; - case HTTP_Request2::AUTH_DIGEST: - curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST); - } - } - } - - // set authentication data - if ($auth = $this->request->getAuth()) { - curl_setopt($ch, CURLOPT_USERPWD, $auth['user'] . ':' . $auth['password']); - switch ($auth['scheme']) { - case HTTP_Request2::AUTH_BASIC: - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - break; - case HTTP_Request2::AUTH_DIGEST: - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); - } - } - - // set SSL options - if (0 == strcasecmp($this->request->getUrl()->getScheme(), 'https')) { - foreach ($this->request->getConfig() as $name => $value) { - if ('ssl_verify_host' == $name && null !== $value) { - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $value? 2: 0); - } elseif (isset(self::$sslContextMap[$name]) && null !== $value) { - curl_setopt($ch, self::$sslContextMap[$name], $value); - } - } - } - - $headers = $this->request->getHeaders(); - // make cURL automagically send proper header - if (!isset($headers['accept-encoding'])) { - $headers['accept-encoding'] = ''; - } - - // set headers having special cURL keys - foreach (self::$headerMap as $name => $option) { - if (isset($headers[$name])) { - curl_setopt($ch, $option, $headers[$name]); - unset($headers[$name]); - } - } - - $this->calculateRequestLength($headers); - if (isset($headers['content-length'])) { - $this->workaroundPhpBug47204($ch, $headers); - } - - // set headers not having special keys - $headersFmt = array(); - foreach ($headers as $name => $value) { - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - $headersFmt[] = $canonicalName . ': ' . $value; - } - curl_setopt($ch, CURLOPT_HTTPHEADER, $headersFmt); - - return $ch; - } - - /** - * Workaround for PHP bug #47204 that prevents rewinding request body - * - * The workaround consists of reading the entire request body into memory - * and setting it as CURLOPT_POSTFIELDS, so it isn't recommended for large - * file uploads, use Socket adapter instead. - * - * @param resource cURL handle - * @param array Request headers - */ - protected function workaroundPhpBug47204($ch, &$headers) - { - // no redirects, no digest auth -> probably no rewind needed - if (!$this->request->getConfig('follow_redirects') - && (!($auth = $this->request->getAuth()) - || HTTP_Request2::AUTH_DIGEST != $auth['scheme']) - ) { - curl_setopt($ch, CURLOPT_READFUNCTION, array($this, 'callbackReadBody')); - - // rewind may be needed, read the whole body into memory - } else { - if ($this->requestBody instanceof HTTP_Request2_MultipartBody) { - $this->requestBody = $this->requestBody->__toString(); - - } elseif (is_resource($this->requestBody)) { - $fp = $this->requestBody; - $this->requestBody = ''; - while (!feof($fp)) { - $this->requestBody .= fread($fp, 16384); - } - } - // curl hangs up if content-length is present - unset($headers['content-length']); - curl_setopt($ch, CURLOPT_POSTFIELDS, $this->requestBody); - } - } - - /** - * Callback function called by cURL for reading the request body - * - * @param resource cURL handle - * @param resource file descriptor (not used) - * @param integer maximum length of data to return - * @return string part of the request body, up to $length bytes - */ - protected function callbackReadBody($ch, $fd, $length) - { - if (!$this->eventSentHeaders) { - $this->request->setLastEvent( - 'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT) - ); - $this->eventSentHeaders = true; - } - if (in_array($this->request->getMethod(), self::$bodyDisallowed) || - 0 == $this->contentLength || $this->position >= $this->contentLength - ) { - return ''; - } - if (is_string($this->requestBody)) { - $string = substr($this->requestBody, $this->position, $length); - } elseif (is_resource($this->requestBody)) { - $string = fread($this->requestBody, $length); - } else { - $string = $this->requestBody->read($length); - } - $this->request->setLastEvent('sentBodyPart', strlen($string)); - $this->position += strlen($string); - return $string; - } - - /** - * Callback function called by cURL for saving the response headers - * - * @param resource cURL handle - * @param string response header (with trailing CRLF) - * @return integer number of bytes saved - * @see HTTP_Request2_Response::parseHeaderLine() - */ - protected function callbackWriteHeader($ch, $string) - { - // we may receive a second set of headers if doing e.g. digest auth - if ($this->eventReceivedHeaders || !$this->eventSentHeaders) { - // don't bother with 100-Continue responses (bug #15785) - if (!$this->eventSentHeaders || - $this->response->getStatus() >= 200 - ) { - $this->request->setLastEvent( - 'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT) - ); - } - $upload = curl_getinfo($ch, CURLINFO_SIZE_UPLOAD); - // if body wasn't read by a callback, send event with total body size - if ($upload > $this->position) { - $this->request->setLastEvent( - 'sentBodyPart', $upload - $this->position - ); - $this->position = $upload; - } - $this->eventSentHeaders = true; - // we'll need a new response object - if ($this->eventReceivedHeaders) { - $this->eventReceivedHeaders = false; - $this->response = null; - } - } - if (empty($this->response)) { - $this->response = new HTTP_Request2_Response($string, false); - } else { - $this->response->parseHeaderLine($string); - if ('' == trim($string)) { - // don't bother with 100-Continue responses (bug #15785) - if (200 <= $this->response->getStatus()) { - $this->request->setLastEvent('receivedHeaders', $this->response); - } - // for versions lower than 5.2.10, check the redirection URL protocol - if ($this->request->getConfig('follow_redirects') && !defined('CURLOPT_REDIR_PROTOCOLS') - && $this->response->isRedirect() - ) { - $redirectUrl = new Net_URL2($this->response->getHeader('location')); - if ($redirectUrl->isAbsolute() - && !in_array($redirectUrl->getScheme(), array('http', 'https')) - ) { - return -1; - } - } - $this->eventReceivedHeaders = true; - } - } - return strlen($string); - } - - /** - * Callback function called by cURL for saving the response body - * - * @param resource cURL handle (not used) - * @param string part of the response body - * @return integer number of bytes saved - * @see HTTP_Request2_Response::appendBody() - */ - protected function callbackWriteBody($ch, $string) - { - // cURL calls WRITEFUNCTION callback without calling HEADERFUNCTION if - // response doesn't start with proper HTTP status line (see bug #15716) - if (empty($this->response)) { - throw new HTTP_Request2_Exception("Malformed response: {$string}"); - } - if ($this->request->getConfig('store_body')) { - $this->response->appendBody($string); - } - $this->request->setLastEvent('receivedBodyPart', $string); - return strlen($string); - } -} -?> diff --git a/libs/PEAR.1.9/HTTP/Request2/Adapter/Mock.php b/libs/PEAR.1.9/HTTP/Request2/Adapter/Mock.php deleted file mode 100644 index fdedccac0..000000000 --- a/libs/PEAR.1.9/HTTP/Request2/Adapter/Mock.php +++ /dev/null @@ -1,171 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: Mock.php 290192 2009-11-03 21:29:32Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for HTTP_Request2 adapters - */ -require_once 'HTTP/Request2/Adapter.php'; - -/** - * Mock adapter intended for testing - * - * Can be used to test applications depending on HTTP_Request2 package without - * actually performing any HTTP requests. This adapter will return responses - * previously added via addResponse() - * - * $mock = new HTTP_Request2_Adapter_Mock(); - * $mock->addResponse("HTTP/1.1 ... "); - * - * $request = new HTTP_Request2(); - * $request->setAdapter($mock); - * - * // This will return the response set above - * $response = $req->send(); - * - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @version Release: 0.5.2 - */ -class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter -{ - /** - * A queue of responses to be returned by sendRequest() - * @var array - */ - protected $responses = array(); - - /** - * Returns the next response from the queue built by addResponse() - * - * If the queue is empty it will return default empty response with status 400, - * if an Exception object was added to the queue it will be thrown. - * - * @param HTTP_Request2 - * @return HTTP_Request2_Response - * @throws Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - if (count($this->responses) > 0) { - $response = array_shift($this->responses); - if ($response instanceof HTTP_Request2_Response) { - return $response; - } else { - // rethrow the exception - $class = get_class($response); - $message = $response->getMessage(); - $code = $response->getCode(); - throw new $class($message, $code); - } - } else { - return self::createResponseFromString("HTTP/1.1 400 Bad Request\r\n\r\n"); - } - } - - /** - * Adds response to the queue - * - * @param mixed either a string, a pointer to an open file, - * an instance of HTTP_Request2_Response or Exception - * @throws HTTP_Request2_Exception - */ - public function addResponse($response) - { - if (is_string($response)) { - $response = self::createResponseFromString($response); - } elseif (is_resource($response)) { - $response = self::createResponseFromFile($response); - } elseif (!$response instanceof HTTP_Request2_Response && - !$response instanceof Exception - ) { - throw new HTTP_Request2_Exception('Parameter is not a valid response'); - } - $this->responses[] = $response; - } - - /** - * Creates a new HTTP_Request2_Response object from a string - * - * @param string - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public static function createResponseFromString($str) - { - $parts = preg_split('!(\r?\n){2}!m', $str, 2); - $headerLines = explode("\n", $parts[0]); - $response = new HTTP_Request2_Response(array_shift($headerLines)); - foreach ($headerLines as $headerLine) { - $response->parseHeaderLine($headerLine); - } - $response->parseHeaderLine(''); - if (isset($parts[1])) { - $response->appendBody($parts[1]); - } - return $response; - } - - /** - * Creates a new HTTP_Request2_Response object from a file - * - * @param resource file pointer returned by fopen() - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public static function createResponseFromFile($fp) - { - $response = new HTTP_Request2_Response(fgets($fp)); - do { - $headerLine = fgets($fp); - $response->parseHeaderLine($headerLine); - } while ('' != trim($headerLine)); - - while (!feof($fp)) { - $response->appendBody(fread($fp, 8192)); - } - return $response; - } -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9/HTTP/Request2/Adapter/Socket.php b/libs/PEAR.1.9/HTTP/Request2/Adapter/Socket.php deleted file mode 100644 index a9c9ea361..000000000 --- a/libs/PEAR.1.9/HTTP/Request2/Adapter/Socket.php +++ /dev/null @@ -1,1046 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: Socket.php 290921 2009-11-18 17:31:58Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for HTTP_Request2 adapters - */ -require_once 'HTTP/Request2/Adapter.php'; - -/** - * Socket-based adapter for HTTP_Request2 - * - * This adapter uses only PHP sockets and will work on almost any PHP - * environment. Code is based on original HTTP_Request PEAR package. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @version Release: 0.5.2 - */ -class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter -{ - /** - * Regular expression for 'token' rule from RFC 2616 - */ - const REGEXP_TOKEN = '[^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+'; - - /** - * Regular expression for 'quoted-string' rule from RFC 2616 - */ - const REGEXP_QUOTED_STRING = '"(?:\\\\.|[^\\\\"])*"'; - - /** - * Connected sockets, needed for Keep-Alive support - * @var array - * @see connect() - */ - protected static $sockets = array(); - - /** - * Data for digest authentication scheme - * - * The keys for the array are URL prefixes. - * - * The values are associative arrays with data (realm, nonce, nonce-count, - * opaque...) needed for digest authentication. Stored here to prevent making - * duplicate requests to digest-protected resources after we have already - * received the challenge. - * - * @var array - */ - protected static $challenges = array(); - - /** - * Connected socket - * @var resource - * @see connect() - */ - protected $socket; - - /** - * Challenge used for server digest authentication - * @var array - */ - protected $serverChallenge; - - /** - * Challenge used for proxy digest authentication - * @var array - */ - protected $proxyChallenge; - - /** - * Sum of start time and global timeout, exception will be thrown if request continues past this time - * @var integer - */ - protected $deadline = null; - - /** - * Remaining length of the current chunk, when reading chunked response - * @var integer - * @see readChunked() - */ - protected $chunkLength = 0; - - /** - * Remaining amount of redirections to follow - * - * Starts at 'max_redirects' configuration parameter and is reduced on each - * subsequent redirect. An Exception will be thrown once it reaches zero. - * - * @var integer - */ - protected $redirectCountdown = null; - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - $this->request = $request; - - // Use global request timeout if given, see feature requests #5735, #8964 - if ($timeout = $request->getConfig('timeout')) { - $this->deadline = time() + $timeout; - } else { - $this->deadline = null; - } - - try { - $keepAlive = $this->connect(); - $headers = $this->prepareHeaders(); - if (false === @fwrite($this->socket, $headers, strlen($headers))) { - throw new HTTP_Request2_Exception('Error writing request'); - } - // provide request headers to the observer, see request #7633 - $this->request->setLastEvent('sentHeaders', $headers); - $this->writeBody(); - - if ($this->deadline && time() > $this->deadline) { - throw new HTTP_Request2_Exception( - 'Request timed out after ' . - $request->getConfig('timeout') . ' second(s)' - ); - } - - $response = $this->readResponse(); - - if (!$this->canKeepAlive($keepAlive, $response)) { - $this->disconnect(); - } - - if ($this->shouldUseProxyDigestAuth($response)) { - return $this->sendRequest($request); - } - if ($this->shouldUseServerDigestAuth($response)) { - return $this->sendRequest($request); - } - if ($authInfo = $response->getHeader('authentication-info')) { - $this->updateChallenge($this->serverChallenge, $authInfo); - } - if ($proxyInfo = $response->getHeader('proxy-authentication-info')) { - $this->updateChallenge($this->proxyChallenge, $proxyInfo); - } - - } catch (Exception $e) { - $this->disconnect(); - } - - unset($this->request, $this->requestBody); - - if (!empty($e)) { - throw $e; - } - - if (!$request->getConfig('follow_redirects') || !$response->isRedirect()) { - return $response; - } else { - return $this->handleRedirect($request, $response); - } - } - - /** - * Connects to the remote server - * - * @return bool whether the connection can be persistent - * @throws HTTP_Request2_Exception - */ - protected function connect() - { - $secure = 0 == strcasecmp($this->request->getUrl()->getScheme(), 'https'); - $tunnel = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod(); - $headers = $this->request->getHeaders(); - $reqHost = $this->request->getUrl()->getHost(); - if (!($reqPort = $this->request->getUrl()->getPort())) { - $reqPort = $secure? 443: 80; - } - - if ($host = $this->request->getConfig('proxy_host')) { - if (!($port = $this->request->getConfig('proxy_port'))) { - throw new HTTP_Request2_Exception('Proxy port not provided'); - } - $proxy = true; - } else { - $host = $reqHost; - $port = $reqPort; - $proxy = false; - } - - if ($tunnel && !$proxy) { - throw new HTTP_Request2_Exception( - "Trying to perform CONNECT request without proxy" - ); - } - if ($secure && !in_array('ssl', stream_get_transports())) { - throw new HTTP_Request2_Exception( - 'Need OpenSSL support for https:// requests' - ); - } - - // RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive - // connection token to a proxy server... - if ($proxy && !$secure && - !empty($headers['connection']) && 'Keep-Alive' == $headers['connection'] - ) { - $this->request->setHeader('connection'); - } - - $keepAlive = ('1.1' == $this->request->getConfig('protocol_version') && - empty($headers['connection'])) || - (!empty($headers['connection']) && - 'Keep-Alive' == $headers['connection']); - $host = ((!$secure || $proxy)? 'tcp://': 'ssl://') . $host; - - $options = array(); - if ($secure || $tunnel) { - foreach ($this->request->getConfig() as $name => $value) { - if ('ssl_' == substr($name, 0, 4) && null !== $value) { - if ('ssl_verify_host' == $name) { - if ($value) { - $options['CN_match'] = $reqHost; - } - } else { - $options[substr($name, 4)] = $value; - } - } - } - ksort($options); - } - - // Changing SSL context options after connection is established does *not* - // work, we need a new connection if options change - $remote = $host . ':' . $port; - $socketKey = $remote . (($secure && $proxy)? "->{$reqHost}:{$reqPort}": '') . - (empty($options)? '': ':' . serialize($options)); - unset($this->socket); - - // We use persistent connections and have a connected socket? - // Ensure that the socket is still connected, see bug #16149 - if ($keepAlive && !empty(self::$sockets[$socketKey]) && - !feof(self::$sockets[$socketKey]) - ) { - $this->socket =& self::$sockets[$socketKey]; - - } elseif ($secure && $proxy && !$tunnel) { - $this->establishTunnel(); - $this->request->setLastEvent( - 'connect', "ssl://{$reqHost}:{$reqPort} via {$host}:{$port}" - ); - self::$sockets[$socketKey] =& $this->socket; - - } else { - // Set SSL context options if doing HTTPS request or creating a tunnel - $context = stream_context_create(); - foreach ($options as $name => $value) { - if (!stream_context_set_option($context, 'ssl', $name, $value)) { - throw new HTTP_Request2_Exception( - "Error setting SSL context option '{$name}'" - ); - } - } - $this->socket = @stream_socket_client( - $remote, $errno, $errstr, - $this->request->getConfig('connect_timeout'), - STREAM_CLIENT_CONNECT, $context - ); - if (!$this->socket) { - throw new HTTP_Request2_Exception( - "Unable to connect to {$remote}. Error #{$errno}: {$errstr}" - ); - } - $this->request->setLastEvent('connect', $remote); - self::$sockets[$socketKey] =& $this->socket; - } - return $keepAlive; - } - - /** - * Establishes a tunnel to a secure remote server via HTTP CONNECT request - * - * This method will fail if 'ssl_verify_peer' is enabled. Probably because PHP - * sees that we are connected to a proxy server (duh!) rather than the server - * that presents its certificate. - * - * @link http://tools.ietf.org/html/rfc2817#section-5.2 - * @throws HTTP_Request2_Exception - */ - protected function establishTunnel() - { - $donor = new self; - $connect = new HTTP_Request2( - $this->request->getUrl(), HTTP_Request2::METHOD_CONNECT, - array_merge($this->request->getConfig(), - array('adapter' => $donor)) - ); - $response = $connect->send(); - // Need any successful (2XX) response - if (200 > $response->getStatus() || 300 <= $response->getStatus()) { - throw new HTTP_Request2_Exception( - 'Failed to connect via HTTPS proxy. Proxy response: ' . - $response->getStatus() . ' ' . $response->getReasonPhrase() - ); - } - $this->socket = $donor->socket; - - $modes = array( - STREAM_CRYPTO_METHOD_TLS_CLIENT, - STREAM_CRYPTO_METHOD_SSLv3_CLIENT, - STREAM_CRYPTO_METHOD_SSLv23_CLIENT, - STREAM_CRYPTO_METHOD_SSLv2_CLIENT - ); - - foreach ($modes as $mode) { - if (stream_socket_enable_crypto($this->socket, true, $mode)) { - return; - } - } - throw new HTTP_Request2_Exception( - 'Failed to enable secure connection when connecting through proxy' - ); - } - - /** - * Checks whether current connection may be reused or should be closed - * - * @param boolean whether connection could be persistent - * in the first place - * @param HTTP_Request2_Response response object to check - * @return boolean - */ - protected function canKeepAlive($requestKeepAlive, HTTP_Request2_Response $response) - { - // Do not close socket on successful CONNECT request - if (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() && - 200 <= $response->getStatus() && 300 > $response->getStatus() - ) { - return true; - } - - $lengthKnown = 'chunked' == strtolower($response->getHeader('transfer-encoding')) || - null !== $response->getHeader('content-length'); - $persistent = 'keep-alive' == strtolower($response->getHeader('connection')) || - (null === $response->getHeader('connection') && - '1.1' == $response->getVersion()); - return $requestKeepAlive && $lengthKnown && $persistent; - } - - /** - * Disconnects from the remote server - */ - protected function disconnect() - { - if (is_resource($this->socket)) { - fclose($this->socket); - $this->socket = null; - $this->request->setLastEvent('disconnect'); - } - } - - /** - * Handles HTTP redirection - * - * This method will throw an Exception if redirect to a non-HTTP(S) location - * is attempted, also if number of redirects performed already is equal to - * 'max_redirects' configuration parameter. - * - * @param HTTP_Request2 Original request - * @param HTTP_Request2_Response Response containing redirect - * @return HTTP_Request2_Response Response from a new location - * @throws HTTP_Request2_Exception - */ - protected function handleRedirect(HTTP_Request2 $request, - HTTP_Request2_Response $response) - { - if (is_null($this->redirectCountdown)) { - $this->redirectCountdown = $request->getConfig('max_redirects'); - } - if (0 == $this->redirectCountdown) { - // Copying cURL behaviour - throw new HTTP_Request2_Exception( - 'Maximum (' . $request->getConfig('max_redirects') . ') redirects followed' - ); - } - $redirectUrl = new Net_URL2( - $response->getHeader('location'), - array(Net_URL2::OPTION_USE_BRACKETS => $request->getConfig('use_brackets')) - ); - // refuse non-HTTP redirect - if ($redirectUrl->isAbsolute() - && !in_array($redirectUrl->getScheme(), array('http', 'https')) - ) { - throw new HTTP_Request2_Exception( - 'Refusing to redirect to a non-HTTP URL ' . $redirectUrl->__toString() - ); - } - // Theoretically URL should be absolute (see http://tools.ietf.org/html/rfc2616#section-14.30), - // but in practice it is often not - if (!$redirectUrl->isAbsolute()) { - $redirectUrl = $request->getUrl()->resolve($redirectUrl); - } - $redirect = clone $request; - $redirect->setUrl($redirectUrl); - if (303 == $response->getStatus() || (!$request->getConfig('strict_redirects') - && in_array($response->getStatus(), array(301, 302))) - ) { - $redirect->setMethod(HTTP_Request2::METHOD_GET); - $redirect->setBody(''); - } - - if (0 < $this->redirectCountdown) { - $this->redirectCountdown--; - } - return $this->sendRequest($redirect); - } - - /** - * Checks whether another request should be performed with server digest auth - * - * Several conditions should be satisfied for it to return true: - * - response status should be 401 - * - auth credentials should be set in the request object - * - response should contain WWW-Authenticate header with digest challenge - * - there is either no challenge stored for this URL or new challenge - * contains stale=true parameter (in other case we probably just failed - * due to invalid username / password) - * - * The method stores challenge values in $challenges static property - * - * @param HTTP_Request2_Response response to check - * @return boolean whether another request should be performed - * @throws HTTP_Request2_Exception in case of unsupported challenge parameters - */ - protected function shouldUseServerDigestAuth(HTTP_Request2_Response $response) - { - // no sense repeating a request if we don't have credentials - if (401 != $response->getStatus() || !$this->request->getAuth()) { - return false; - } - if (!$challenge = $this->parseDigestChallenge($response->getHeader('www-authenticate'))) { - return false; - } - - $url = $this->request->getUrl(); - $scheme = $url->getScheme(); - $host = $scheme . '://' . $url->getHost(); - if ($port = $url->getPort()) { - if ((0 == strcasecmp($scheme, 'http') && 80 != $port) || - (0 == strcasecmp($scheme, 'https') && 443 != $port) - ) { - $host .= ':' . $port; - } - } - - if (!empty($challenge['domain'])) { - $prefixes = array(); - foreach (preg_split('/\\s+/', $challenge['domain']) as $prefix) { - // don't bother with different servers - if ('/' == substr($prefix, 0, 1)) { - $prefixes[] = $host . $prefix; - } - } - } - if (empty($prefixes)) { - $prefixes = array($host . '/'); - } - - $ret = true; - foreach ($prefixes as $prefix) { - if (!empty(self::$challenges[$prefix]) && - (empty($challenge['stale']) || strcasecmp('true', $challenge['stale'])) - ) { - // probably credentials are invalid - $ret = false; - } - self::$challenges[$prefix] =& $challenge; - } - return $ret; - } - - /** - * Checks whether another request should be performed with proxy digest auth - * - * Several conditions should be satisfied for it to return true: - * - response status should be 407 - * - proxy auth credentials should be set in the request object - * - response should contain Proxy-Authenticate header with digest challenge - * - there is either no challenge stored for this proxy or new challenge - * contains stale=true parameter (in other case we probably just failed - * due to invalid username / password) - * - * The method stores challenge values in $challenges static property - * - * @param HTTP_Request2_Response response to check - * @return boolean whether another request should be performed - * @throws HTTP_Request2_Exception in case of unsupported challenge parameters - */ - protected function shouldUseProxyDigestAuth(HTTP_Request2_Response $response) - { - if (407 != $response->getStatus() || !$this->request->getConfig('proxy_user')) { - return false; - } - if (!($challenge = $this->parseDigestChallenge($response->getHeader('proxy-authenticate')))) { - return false; - } - - $key = 'proxy://' . $this->request->getConfig('proxy_host') . - ':' . $this->request->getConfig('proxy_port'); - - if (!empty(self::$challenges[$key]) && - (empty($challenge['stale']) || strcasecmp('true', $challenge['stale'])) - ) { - $ret = false; - } else { - $ret = true; - } - self::$challenges[$key] = $challenge; - return $ret; - } - - /** - * Extracts digest method challenge from (WWW|Proxy)-Authenticate header value - * - * There is a problem with implementation of RFC 2617: several of the parameters - * are defined as quoted-string there and thus may contain backslash escaped - * double quotes (RFC 2616, section 2.2). However, RFC 2617 defines unq(X) as - * just value of quoted-string X without surrounding quotes, it doesn't speak - * about removing backslash escaping. - * - * Now realm parameter is user-defined and human-readable, strange things - * happen when it contains quotes: - * - Apache allows quotes in realm, but apparently uses realm value without - * backslashes for digest computation - * - Squid allows (manually escaped) quotes there, but it is impossible to - * authorize with either escaped or unescaped quotes used in digest, - * probably it can't parse the response (?) - * - Both IE and Firefox display realm value with backslashes in - * the password popup and apparently use the same value for digest - * - * HTTP_Request2 follows IE and Firefox (and hopefully RFC 2617) in - * quoted-string handling, unfortunately that means failure to authorize - * sometimes - * - * @param string value of WWW-Authenticate or Proxy-Authenticate header - * @return mixed associative array with challenge parameters, false if - * no challenge is present in header value - * @throws HTTP_Request2_Exception in case of unsupported challenge parameters - */ - protected function parseDigestChallenge($headerValue) - { - $authParam = '(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' . - self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')'; - $challenge = "!(?<=^|\\s|,)Digest ({$authParam}\\s*(,\\s*|$))+!"; - if (!preg_match($challenge, $headerValue, $matches)) { - return false; - } - - preg_match_all('!' . $authParam . '!', $matches[0], $params); - $paramsAry = array(); - $knownParams = array('realm', 'domain', 'nonce', 'opaque', 'stale', - 'algorithm', 'qop'); - for ($i = 0; $i < count($params[0]); $i++) { - // section 3.2.1: Any unrecognized directive MUST be ignored. - if (in_array($params[1][$i], $knownParams)) { - if ('"' == substr($params[2][$i], 0, 1)) { - $paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1); - } else { - $paramsAry[$params[1][$i]] = $params[2][$i]; - } - } - } - // we only support qop=auth - if (!empty($paramsAry['qop']) && - !in_array('auth', array_map('trim', explode(',', $paramsAry['qop']))) - ) { - throw new HTTP_Request2_Exception( - "Only 'auth' qop is currently supported in digest authentication, " . - "server requested '{$paramsAry['qop']}'" - ); - } - // we only support algorithm=MD5 - if (!empty($paramsAry['algorithm']) && 'MD5' != $paramsAry['algorithm']) { - throw new HTTP_Request2_Exception( - "Only 'MD5' algorithm is currently supported in digest authentication, " . - "server requested '{$paramsAry['algorithm']}'" - ); - } - - return $paramsAry; - } - - /** - * Parses [Proxy-]Authentication-Info header value and updates challenge - * - * @param array challenge to update - * @param string value of [Proxy-]Authentication-Info header - * @todo validate server rspauth response - */ - protected function updateChallenge(&$challenge, $headerValue) - { - $authParam = '!(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' . - self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')!'; - $paramsAry = array(); - - preg_match_all($authParam, $headerValue, $params); - for ($i = 0; $i < count($params[0]); $i++) { - if ('"' == substr($params[2][$i], 0, 1)) { - $paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1); - } else { - $paramsAry[$params[1][$i]] = $params[2][$i]; - } - } - // for now, just update the nonce value - if (!empty($paramsAry['nextnonce'])) { - $challenge['nonce'] = $paramsAry['nextnonce']; - $challenge['nc'] = 1; - } - } - - /** - * Creates a value for [Proxy-]Authorization header when using digest authentication - * - * @param string user name - * @param string password - * @param string request URL - * @param array digest challenge parameters - * @return string value of [Proxy-]Authorization request header - * @link http://tools.ietf.org/html/rfc2617#section-3.2.2 - */ - protected function createDigestResponse($user, $password, $url, &$challenge) - { - if (false !== ($q = strpos($url, '?')) && - $this->request->getConfig('digest_compat_ie') - ) { - $url = substr($url, 0, $q); - } - - $a1 = md5($user . ':' . $challenge['realm'] . ':' . $password); - $a2 = md5($this->request->getMethod() . ':' . $url); - - if (empty($challenge['qop'])) { - $digest = md5($a1 . ':' . $challenge['nonce'] . ':' . $a2); - } else { - $challenge['cnonce'] = 'Req2.' . rand(); - if (empty($challenge['nc'])) { - $challenge['nc'] = 1; - } - $nc = sprintf('%08x', $challenge['nc']++); - $digest = md5($a1 . ':' . $challenge['nonce'] . ':' . $nc . ':' . - $challenge['cnonce'] . ':auth:' . $a2); - } - return 'Digest username="' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $user) . '", ' . - 'realm="' . $challenge['realm'] . '", ' . - 'nonce="' . $challenge['nonce'] . '", ' . - 'uri="' . $url . '", ' . - 'response="' . $digest . '"' . - (!empty($challenge['opaque'])? - ', opaque="' . $challenge['opaque'] . '"': - '') . - (!empty($challenge['qop'])? - ', qop="auth", nc=' . $nc . ', cnonce="' . $challenge['cnonce'] . '"': - ''); - } - - /** - * Adds 'Authorization' header (if needed) to request headers array - * - * @param array request headers - * @param string request host (needed for digest authentication) - * @param string request URL (needed for digest authentication) - * @throws HTTP_Request2_Exception - */ - protected function addAuthorizationHeader(&$headers, $requestHost, $requestUrl) - { - if (!($auth = $this->request->getAuth())) { - return; - } - switch ($auth['scheme']) { - case HTTP_Request2::AUTH_BASIC: - $headers['authorization'] = - 'Basic ' . base64_encode($auth['user'] . ':' . $auth['password']); - break; - - case HTTP_Request2::AUTH_DIGEST: - unset($this->serverChallenge); - $fullUrl = ('/' == $requestUrl[0])? - $this->request->getUrl()->getScheme() . '://' . - $requestHost . $requestUrl: - $requestUrl; - foreach (array_keys(self::$challenges) as $key) { - if ($key == substr($fullUrl, 0, strlen($key))) { - $headers['authorization'] = $this->createDigestResponse( - $auth['user'], $auth['password'], - $requestUrl, self::$challenges[$key] - ); - $this->serverChallenge =& self::$challenges[$key]; - break; - } - } - break; - - default: - throw new HTTP_Request2_Exception( - "Unknown HTTP authentication scheme '{$auth['scheme']}'" - ); - } - } - - /** - * Adds 'Proxy-Authorization' header (if needed) to request headers array - * - * @param array request headers - * @param string request URL (needed for digest authentication) - * @throws HTTP_Request2_Exception - */ - protected function addProxyAuthorizationHeader(&$headers, $requestUrl) - { - if (!$this->request->getConfig('proxy_host') || - !($user = $this->request->getConfig('proxy_user')) || - (0 == strcasecmp('https', $this->request->getUrl()->getScheme()) && - HTTP_Request2::METHOD_CONNECT != $this->request->getMethod()) - ) { - return; - } - - $password = $this->request->getConfig('proxy_password'); - switch ($this->request->getConfig('proxy_auth_scheme')) { - case HTTP_Request2::AUTH_BASIC: - $headers['proxy-authorization'] = - 'Basic ' . base64_encode($user . ':' . $password); - break; - - case HTTP_Request2::AUTH_DIGEST: - unset($this->proxyChallenge); - $proxyUrl = 'proxy://' . $this->request->getConfig('proxy_host') . - ':' . $this->request->getConfig('proxy_port'); - if (!empty(self::$challenges[$proxyUrl])) { - $headers['proxy-authorization'] = $this->createDigestResponse( - $user, $password, - $requestUrl, self::$challenges[$proxyUrl] - ); - $this->proxyChallenge =& self::$challenges[$proxyUrl]; - } - break; - - default: - throw new HTTP_Request2_Exception( - "Unknown HTTP authentication scheme '" . - $this->request->getConfig('proxy_auth_scheme') . "'" - ); - } - } - - - /** - * Creates the string with the Request-Line and request headers - * - * @return string - * @throws HTTP_Request2_Exception - */ - protected function prepareHeaders() - { - $headers = $this->request->getHeaders(); - $url = $this->request->getUrl(); - $connect = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod(); - $host = $url->getHost(); - - $defaultPort = 0 == strcasecmp($url->getScheme(), 'https')? 443: 80; - if (($port = $url->getPort()) && $port != $defaultPort || $connect) { - $host .= ':' . (empty($port)? $defaultPort: $port); - } - // Do not overwrite explicitly set 'Host' header, see bug #16146 - if (!isset($headers['host'])) { - $headers['host'] = $host; - } - - if ($connect) { - $requestUrl = $host; - - } else { - if (!$this->request->getConfig('proxy_host') || - 0 == strcasecmp($url->getScheme(), 'https') - ) { - $requestUrl = ''; - } else { - $requestUrl = $url->getScheme() . '://' . $host; - } - $path = $url->getPath(); - $query = $url->getQuery(); - $requestUrl .= (empty($path)? '/': $path) . (empty($query)? '': '?' . $query); - } - - if ('1.1' == $this->request->getConfig('protocol_version') && - extension_loaded('zlib') && !isset($headers['accept-encoding']) - ) { - $headers['accept-encoding'] = 'gzip, deflate'; - } - - $this->addAuthorizationHeader($headers, $host, $requestUrl); - $this->addProxyAuthorizationHeader($headers, $requestUrl); - $this->calculateRequestLength($headers); - - $headersStr = $this->request->getMethod() . ' ' . $requestUrl . ' HTTP/' . - $this->request->getConfig('protocol_version') . "\r\n"; - foreach ($headers as $name => $value) { - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - $headersStr .= $canonicalName . ': ' . $value . "\r\n"; - } - return $headersStr . "\r\n"; - } - - /** - * Sends the request body - * - * @throws HTTP_Request2_Exception - */ - protected function writeBody() - { - if (in_array($this->request->getMethod(), self::$bodyDisallowed) || - 0 == $this->contentLength - ) { - return; - } - - $position = 0; - $bufferSize = $this->request->getConfig('buffer_size'); - while ($position < $this->contentLength) { - if (is_string($this->requestBody)) { - $str = substr($this->requestBody, $position, $bufferSize); - } elseif (is_resource($this->requestBody)) { - $str = fread($this->requestBody, $bufferSize); - } else { - $str = $this->requestBody->read($bufferSize); - } - if (false === @fwrite($this->socket, $str, strlen($str))) { - throw new HTTP_Request2_Exception('Error writing request'); - } - // Provide the length of written string to the observer, request #7630 - $this->request->setLastEvent('sentBodyPart', strlen($str)); - $position += strlen($str); - } - } - - /** - * Reads the remote server's response - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - protected function readResponse() - { - $bufferSize = $this->request->getConfig('buffer_size'); - - do { - $response = new HTTP_Request2_Response($this->readLine($bufferSize), true); - do { - $headerLine = $this->readLine($bufferSize); - $response->parseHeaderLine($headerLine); - } while ('' != $headerLine); - } while (in_array($response->getStatus(), array(100, 101))); - - $this->request->setLastEvent('receivedHeaders', $response); - - // No body possible in such responses - if (HTTP_Request2::METHOD_HEAD == $this->request->getMethod() || - (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() && - 200 <= $response->getStatus() && 300 > $response->getStatus()) || - in_array($response->getStatus(), array(204, 304)) - ) { - return $response; - } - - $chunked = 'chunked' == $response->getHeader('transfer-encoding'); - $length = $response->getHeader('content-length'); - $hasBody = false; - if ($chunked || null === $length || 0 < intval($length)) { - // RFC 2616, section 4.4: - // 3. ... If a message is received with both a - // Transfer-Encoding header field and a Content-Length header field, - // the latter MUST be ignored. - $toRead = ($chunked || null === $length)? null: $length; - $this->chunkLength = 0; - - while (!feof($this->socket) && (is_null($toRead) || 0 < $toRead)) { - if ($chunked) { - $data = $this->readChunked($bufferSize); - } elseif (is_null($toRead)) { - $data = $this->fread($bufferSize); - } else { - $data = $this->fread(min($toRead, $bufferSize)); - $toRead -= strlen($data); - } - if ('' == $data && (!$this->chunkLength || feof($this->socket))) { - break; - } - - $hasBody = true; - if ($this->request->getConfig('store_body')) { - $response->appendBody($data); - } - if (!in_array($response->getHeader('content-encoding'), array('identity', null))) { - $this->request->setLastEvent('receivedEncodedBodyPart', $data); - } else { - $this->request->setLastEvent('receivedBodyPart', $data); - } - } - } - - if ($hasBody) { - $this->request->setLastEvent('receivedBody', $response); - } - return $response; - } - - /** - * Reads until either the end of the socket or a newline, whichever comes first - * - * Strips the trailing newline from the returned data, handles global - * request timeout. Method idea borrowed from Net_Socket PEAR package. - * - * @param int buffer size to use for reading - * @return Available data up to the newline (not including newline) - * @throws HTTP_Request2_Exception In case of timeout - */ - protected function readLine($bufferSize) - { - $line = ''; - while (!feof($this->socket)) { - if ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - $line .= @fgets($this->socket, $bufferSize); - $info = stream_get_meta_data($this->socket); - if ($info['timed_out'] || $this->deadline && time() > $this->deadline) { - $reason = $this->deadline - ? 'after ' . $this->request->getConfig('timeout') . ' second(s)' - : 'due to default_socket_timeout php.ini setting'; - throw new HTTP_Request2_Exception("Request timed out {$reason}"); - } - if (substr($line, -1) == "\n") { - return rtrim($line, "\r\n"); - } - } - return $line; - } - - /** - * Wrapper around fread(), handles global request timeout - * - * @param int Reads up to this number of bytes - * @return Data read from socket - * @throws HTTP_Request2_Exception In case of timeout - */ - protected function fread($length) - { - if ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - $data = fread($this->socket, $length); - $info = stream_get_meta_data($this->socket); - if ($info['timed_out'] || $this->deadline && time() > $this->deadline) { - $reason = $this->deadline - ? 'after ' . $this->request->getConfig('timeout') . ' second(s)' - : 'due to default_socket_timeout php.ini setting'; - throw new HTTP_Request2_Exception("Request timed out {$reason}"); - } - return $data; - } - - /** - * Reads a part of response body encoded with chunked Transfer-Encoding - * - * @param int buffer size to use for reading - * @return string - * @throws HTTP_Request2_Exception - */ - protected function readChunked($bufferSize) - { - // at start of the next chunk? - if (0 == $this->chunkLength) { - $line = $this->readLine($bufferSize); - if (!preg_match('/^([0-9a-f]+)/i', $line, $matches)) { - throw new HTTP_Request2_Exception( - "Cannot decode chunked response, invalid chunk length '{$line}'" - ); - } else { - $this->chunkLength = hexdec($matches[1]); - // Chunk with zero length indicates the end - if (0 == $this->chunkLength) { - $this->readLine($bufferSize); - return ''; - } - } - } - $data = $this->fread(min($this->chunkLength, $bufferSize)); - $this->chunkLength -= strlen($data); - if (0 == $this->chunkLength) { - $this->readLine($bufferSize); // Trailing CRLF - } - return $data; - } -} - -?> \ No newline at end of file diff --git a/libs/PEAR.1.9/HTTP/Request2/Exception.php b/libs/PEAR.1.9/HTTP/Request2/Exception.php deleted file mode 100644 index 2b960fc20..000000000 --- a/libs/PEAR.1.9/HTTP/Request2/Exception.php +++ /dev/null @@ -1,62 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: Exception.php 290192 2009-11-03 21:29:32Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for exceptions in PEAR - */ -require_once 'PEAR/Exception.php'; - -/** - * Exception class for HTTP_Request2 package - * - * Such a class is required by the Exception RFC: - * http://pear.php.net/pepr/pepr-proposal-show.php?id=132 - * - * @category HTTP - * @package HTTP_Request2 - * @version Release: 0.5.2 - */ -class HTTP_Request2_Exception extends PEAR_Exception -{ -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9/HTTP/Request2/MultipartBody.php b/libs/PEAR.1.9/HTTP/Request2/MultipartBody.php deleted file mode 100644 index f640de3e7..000000000 --- a/libs/PEAR.1.9/HTTP/Request2/MultipartBody.php +++ /dev/null @@ -1,274 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: MultipartBody.php 290192 2009-11-03 21:29:32Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Class for building multipart/form-data request body - * - * The class helps to reduce memory consumption by streaming large file uploads - * from disk, it also allows monitoring of upload progress (see request #7630) - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @version Release: 0.5.2 - * @link http://tools.ietf.org/html/rfc1867 - */ -class HTTP_Request2_MultipartBody -{ - /** - * MIME boundary - * @var string - */ - private $_boundary; - - /** - * Form parameters added via {@link HTTP_Request2::addPostParameter()} - * @var array - */ - private $_params = array(); - - /** - * File uploads added via {@link HTTP_Request2::addUpload()} - * @var array - */ - private $_uploads = array(); - - /** - * Header for parts with parameters - * @var string - */ - private $_headerParam = "--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n"; - - /** - * Header for parts with uploads - * @var string - */ - private $_headerUpload = "--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\nContent-Type: %s\r\n\r\n"; - - /** - * Current position in parameter and upload arrays - * - * First number is index of "current" part, second number is position within - * "current" part - * - * @var array - */ - private $_pos = array(0, 0); - - - /** - * Constructor. Sets the arrays with POST data. - * - * @param array values of form fields set via {@link HTTP_Request2::addPostParameter()} - * @param array file uploads set via {@link HTTP_Request2::addUpload()} - * @param bool whether to append brackets to array variable names - */ - public function __construct(array $params, array $uploads, $useBrackets = true) - { - $this->_params = self::_flattenArray('', $params, $useBrackets); - foreach ($uploads as $fieldName => $f) { - if (!is_array($f['fp'])) { - $this->_uploads[] = $f + array('name' => $fieldName); - } else { - for ($i = 0; $i < count($f['fp']); $i++) { - $upload = array( - 'name' => ($useBrackets? $fieldName . '[' . $i . ']': $fieldName) - ); - foreach (array('fp', 'filename', 'size', 'type') as $key) { - $upload[$key] = $f[$key][$i]; - } - $this->_uploads[] = $upload; - } - } - } - } - - /** - * Returns the length of the body to use in Content-Length header - * - * @return integer - */ - public function getLength() - { - $boundaryLength = strlen($this->getBoundary()); - $headerParamLength = strlen($this->_headerParam) - 4 + $boundaryLength; - $headerUploadLength = strlen($this->_headerUpload) - 8 + $boundaryLength; - $length = $boundaryLength + 6; - foreach ($this->_params as $p) { - $length += $headerParamLength + strlen($p[0]) + strlen($p[1]) + 2; - } - foreach ($this->_uploads as $u) { - $length += $headerUploadLength + strlen($u['name']) + strlen($u['type']) + - strlen($u['filename']) + $u['size'] + 2; - } - return $length; - } - - /** - * Returns the boundary to use in Content-Type header - * - * @return string - */ - public function getBoundary() - { - if (empty($this->_boundary)) { - $this->_boundary = '--' . md5('PEAR-HTTP_Request2-' . microtime()); - } - return $this->_boundary; - } - - /** - * Returns next chunk of request body - * - * @param integer Amount of bytes to read - * @return string Up to $length bytes of data, empty string if at end - */ - public function read($length) - { - $ret = ''; - $boundary = $this->getBoundary(); - $paramCount = count($this->_params); - $uploadCount = count($this->_uploads); - while ($length > 0 && $this->_pos[0] <= $paramCount + $uploadCount) { - $oldLength = $length; - if ($this->_pos[0] < $paramCount) { - $param = sprintf($this->_headerParam, $boundary, - $this->_params[$this->_pos[0]][0]) . - $this->_params[$this->_pos[0]][1] . "\r\n"; - $ret .= substr($param, $this->_pos[1], $length); - $length -= min(strlen($param) - $this->_pos[1], $length); - - } elseif ($this->_pos[0] < $paramCount + $uploadCount) { - $pos = $this->_pos[0] - $paramCount; - $header = sprintf($this->_headerUpload, $boundary, - $this->_uploads[$pos]['name'], - $this->_uploads[$pos]['filename'], - $this->_uploads[$pos]['type']); - if ($this->_pos[1] < strlen($header)) { - $ret .= substr($header, $this->_pos[1], $length); - $length -= min(strlen($header) - $this->_pos[1], $length); - } - $filePos = max(0, $this->_pos[1] - strlen($header)); - if ($length > 0 && $filePos < $this->_uploads[$pos]['size']) { - $ret .= fread($this->_uploads[$pos]['fp'], $length); - $length -= min($length, $this->_uploads[$pos]['size'] - $filePos); - } - if ($length > 0) { - $start = $this->_pos[1] + ($oldLength - $length) - - strlen($header) - $this->_uploads[$pos]['size']; - $ret .= substr("\r\n", $start, $length); - $length -= min(2 - $start, $length); - } - - } else { - $closing = '--' . $boundary . "--\r\n"; - $ret .= substr($closing, $this->_pos[1], $length); - $length -= min(strlen($closing) - $this->_pos[1], $length); - } - if ($length > 0) { - $this->_pos = array($this->_pos[0] + 1, 0); - } else { - $this->_pos[1] += $oldLength; - } - } - return $ret; - } - - /** - * Sets the current position to the start of the body - * - * This allows reusing the same body in another request - */ - public function rewind() - { - $this->_pos = array(0, 0); - foreach ($this->_uploads as $u) { - rewind($u['fp']); - } - } - - /** - * Returns the body as string - * - * Note that it reads all file uploads into memory so it is a good idea not - * to use this method with large file uploads and rely on read() instead. - * - * @return string - */ - public function __toString() - { - $this->rewind(); - return $this->read($this->getLength()); - } - - - /** - * Helper function to change the (probably multidimensional) associative array - * into the simple one. - * - * @param string name for item - * @param mixed item's values - * @param bool whether to append [] to array variables' names - * @return array array with the following items: array('item name', 'item value'); - */ - private static function _flattenArray($name, $values, $useBrackets) - { - if (!is_array($values)) { - return array(array($name, $values)); - } else { - $ret = array(); - foreach ($values as $k => $v) { - if (empty($name)) { - $newName = $k; - } elseif ($useBrackets) { - $newName = $name . '[' . $k . ']'; - } else { - $newName = $name; - } - $ret = array_merge($ret, self::_flattenArray($newName, $v, $useBrackets)); - } - return $ret; - } - } -} -?> diff --git a/libs/PEAR.1.9/HTTP/Request2/Observer/Log.php b/libs/PEAR.1.9/HTTP/Request2/Observer/Log.php deleted file mode 100644 index 7df821ef4..000000000 --- a/libs/PEAR.1.9/HTTP/Request2/Observer/Log.php +++ /dev/null @@ -1,215 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author David Jean Louis - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: Log.php 293416 2010-01-11 18:06:15Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * A debug observer useful for debugging / testing. - * - * This observer logs to a log target data corresponding to the various request - * and response events, it logs by default to php://output but can be configured - * to log to a file or via the PEAR Log package. - * - * A simple example: - * - * require_once 'HTTP/Request2.php'; - * require_once 'HTTP/Request2/Observer/Log.php'; - * - * $request = new HTTP_Request2('http://www.example.com'); - * $observer = new HTTP_Request2_Observer_Log(); - * $request->attach($observer); - * $request->send(); - * - * - * A more complex example with PEAR Log: - * - * require_once 'HTTP/Request2.php'; - * require_once 'HTTP/Request2/Observer/Log.php'; - * require_once 'Log.php'; - * - * $request = new HTTP_Request2('http://www.example.com'); - * // we want to log with PEAR log - * $observer = new HTTP_Request2_Observer_Log(Log::factory('console')); - * - * // we only want to log received headers - * $observer->events = array('receivedHeaders'); - * - * $request->attach($observer); - * $request->send(); - * - * - * @category HTTP - * @package HTTP_Request2 - * @author David Jean Louis - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 0.5.2 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Observer_Log implements SplObserver -{ - // properties {{{ - - /** - * The log target, it can be a a resource or a PEAR Log instance. - * - * @var resource|Log $target - */ - protected $target = null; - - /** - * The events to log. - * - * @var array $events - */ - public $events = array( - 'connect', - 'sentHeaders', - 'sentBodyPart', - 'receivedHeaders', - 'receivedBody', - 'disconnect', - ); - - // }}} - // __construct() {{{ - - /** - * Constructor. - * - * @param mixed $target Can be a file path (default: php://output), a resource, - * or an instance of the PEAR Log class. - * @param array $events Array of events to listen to (default: all events) - * - * @return void - */ - public function __construct($target = 'php://output', array $events = array()) - { - if (!empty($events)) { - $this->events = $events; - } - if (is_resource($target) || $target instanceof Log) { - $this->target = $target; - } elseif (false === ($this->target = @fopen($target, 'ab'))) { - throw new HTTP_Request2_Exception("Unable to open '{$target}'"); - } - } - - // }}} - // update() {{{ - - /** - * Called when the request notifies us of an event. - * - * @param HTTP_Request2 $subject The HTTP_Request2 instance - * - * @return void - */ - public function update(SplSubject $subject) - { - $event = $subject->getLastEvent(); - if (!in_array($event['name'], $this->events)) { - return; - } - - switch ($event['name']) { - case 'connect': - $this->log('* Connected to ' . $event['data']); - break; - case 'sentHeaders': - $headers = explode("\r\n", $event['data']); - array_pop($headers); - foreach ($headers as $header) { - $this->log('> ' . $header); - } - break; - case 'sentBodyPart': - $this->log('> ' . $event['data'] . ' byte(s) sent'); - break; - case 'receivedHeaders': - $this->log(sprintf('< HTTP/%s %s %s', - $event['data']->getVersion(), - $event['data']->getStatus(), - $event['data']->getReasonPhrase())); - $headers = $event['data']->getHeader(); - foreach ($headers as $key => $val) { - $this->log('< ' . $key . ': ' . $val); - } - $this->log('< '); - break; - case 'receivedBody': - $this->log($event['data']->getBody()); - break; - case 'disconnect': - $this->log('* Disconnected'); - break; - } - } - - // }}} - // log() {{{ - - /** - * Logs the given message to the configured target. - * - * @param string $message Message to display - * - * @return void - */ - protected function log($message) - { - if ($this->target instanceof Log) { - $this->target->debug($message); - } elseif (is_resource($this->target)) { - fwrite($this->target, $message . "\r\n"); - } - } - - // }}} -} - -?> \ No newline at end of file diff --git a/libs/PEAR.1.9/HTTP/Request2/Response.php b/libs/PEAR.1.9/HTTP/Request2/Response.php deleted file mode 100644 index f27ea51f4..000000000 --- a/libs/PEAR.1.9/HTTP/Request2/Response.php +++ /dev/null @@ -1,559 +0,0 @@ - - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * The names of the authors may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version SVN: $Id: Response.php 290520 2009-11-11 20:09:42Z avb $ - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class representing a HTTP response - * - * The class is designed to be used in "streaming" scenario, building the - * response as it is being received: - * - * $statusLine = read_status_line(); - * $response = new HTTP_Request2_Response($statusLine); - * do { - * $headerLine = read_header_line(); - * $response->parseHeaderLine($headerLine); - * } while ($headerLine != ''); - * - * while ($chunk = read_body()) { - * $response->appendBody($chunk); - * } - * - * var_dump($response->getHeader(), $response->getCookies(), $response->getBody()); - * - * - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @version Release: 0.5.2 - * @link http://tools.ietf.org/html/rfc2616#section-6 - */ -class HTTP_Request2_Response -{ - /** - * HTTP protocol version (e.g. 1.0, 1.1) - * @var string - */ - protected $version; - - /** - * Status code - * @var integer - * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 - */ - protected $code; - - /** - * Reason phrase - * @var string - * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 - */ - protected $reasonPhrase; - - /** - * Associative array of response headers - * @var array - */ - protected $headers = array(); - - /** - * Cookies set in the response - * @var array - */ - protected $cookies = array(); - - /** - * Name of last header processed by parseHederLine() - * - * Used to handle the headers that span multiple lines - * - * @var string - */ - protected $lastHeader = null; - - /** - * Response body - * @var string - */ - protected $body = ''; - - /** - * Whether the body is still encoded by Content-Encoding - * - * cURL provides the decoded body to the callback; if we are reading from - * socket the body is still gzipped / deflated - * - * @var bool - */ - protected $bodyEncoded; - - /** - * Associative array of HTTP status code / reason phrase. - * - * @var array - * @link http://tools.ietf.org/html/rfc2616#section-10 - */ - protected static $phrases = array( - - // 1xx: Informational - Request received, continuing process - 100 => 'Continue', - 101 => 'Switching Protocols', - - // 2xx: Success - The action was successfully received, understood and - // accepted - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - - // 3xx: Redirection - Further action must be taken in order to complete - // the request - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', // 1.1 - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 307 => 'Temporary Redirect', - - // 4xx: Client Error - The request contains bad syntax or cannot be - // fulfilled - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - - // 5xx: Server Error - The server failed to fulfill an apparently - // valid request - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 509 => 'Bandwidth Limit Exceeded', - - ); - - /** - * Constructor, parses the response status line - * - * @param string Response status line (e.g. "HTTP/1.1 200 OK") - * @param bool Whether body is still encoded by Content-Encoding - * @throws HTTP_Request2_Exception if status line is invalid according to spec - */ - public function __construct($statusLine, $bodyEncoded = true) - { - if (!preg_match('!^HTTP/(\d\.\d) (\d{3})(?: (.+))?!', $statusLine, $m)) { - throw new HTTP_Request2_Exception("Malformed response: {$statusLine}"); - } - $this->version = $m[1]; - $this->code = intval($m[2]); - if (!empty($m[3])) { - $this->reasonPhrase = trim($m[3]); - } elseif (!empty(self::$phrases[$this->code])) { - $this->reasonPhrase = self::$phrases[$this->code]; - } - $this->bodyEncoded = (bool)$bodyEncoded; - } - - /** - * Parses the line from HTTP response filling $headers array - * - * The method should be called after reading the line from socket or receiving - * it into cURL callback. Passing an empty string here indicates the end of - * response headers and triggers additional processing, so be sure to pass an - * empty string in the end. - * - * @param string Line from HTTP response - */ - public function parseHeaderLine($headerLine) - { - $headerLine = trim($headerLine, "\r\n"); - - // empty string signals the end of headers, process the received ones - if ('' == $headerLine) { - if (!empty($this->headers['set-cookie'])) { - $cookies = is_array($this->headers['set-cookie'])? - $this->headers['set-cookie']: - array($this->headers['set-cookie']); - foreach ($cookies as $cookieString) { - $this->parseCookie($cookieString); - } - unset($this->headers['set-cookie']); - } - foreach (array_keys($this->headers) as $k) { - if (is_array($this->headers[$k])) { - $this->headers[$k] = implode(', ', $this->headers[$k]); - } - } - - // string of the form header-name: header value - } elseif (preg_match('!^([^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+):(.+)$!', $headerLine, $m)) { - $name = strtolower($m[1]); - $value = trim($m[2]); - if (empty($this->headers[$name])) { - $this->headers[$name] = $value; - } else { - if (!is_array($this->headers[$name])) { - $this->headers[$name] = array($this->headers[$name]); - } - $this->headers[$name][] = $value; - } - $this->lastHeader = $name; - - // continuation of a previous header - } elseif (preg_match('!^\s+(.+)$!', $headerLine, $m) && $this->lastHeader) { - if (!is_array($this->headers[$this->lastHeader])) { - $this->headers[$this->lastHeader] .= ' ' . trim($m[1]); - } else { - $key = count($this->headers[$this->lastHeader]) - 1; - $this->headers[$this->lastHeader][$key] .= ' ' . trim($m[1]); - } - } - } - - /** - * Parses a Set-Cookie header to fill $cookies array - * - * @param string value of Set-Cookie header - * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html - */ - protected function parseCookie($cookieString) - { - $cookie = array( - 'expires' => null, - 'domain' => null, - 'path' => null, - 'secure' => false - ); - - // Only a name=value pair - if (!strpos($cookieString, ';')) { - $pos = strpos($cookieString, '='); - $cookie['name'] = trim(substr($cookieString, 0, $pos)); - $cookie['value'] = trim(substr($cookieString, $pos + 1)); - - // Some optional parameters are supplied - } else { - $elements = explode(';', $cookieString); - $pos = strpos($elements[0], '='); - $cookie['name'] = trim(substr($elements[0], 0, $pos)); - $cookie['value'] = trim(substr($elements[0], $pos + 1)); - - for ($i = 1; $i < count($elements); $i++) { - if (false === strpos($elements[$i], '=')) { - $elName = trim($elements[$i]); - $elValue = null; - } else { - list ($elName, $elValue) = array_map('trim', explode('=', $elements[$i])); - } - $elName = strtolower($elName); - if ('secure' == $elName) { - $cookie['secure'] = true; - } elseif ('expires' == $elName) { - $cookie['expires'] = str_replace('"', '', $elValue); - } elseif ('path' == $elName || 'domain' == $elName) { - $cookie[$elName] = urldecode($elValue); - } else { - $cookie[$elName] = $elValue; - } - } - } - $this->cookies[] = $cookie; - } - - /** - * Appends a string to the response body - * @param string - */ - public function appendBody($bodyChunk) - { - $this->body .= $bodyChunk; - } - - /** - * Returns the status code - * @return integer - */ - public function getStatus() - { - return $this->code; - } - - /** - * Returns the reason phrase - * @return string - */ - public function getReasonPhrase() - { - return $this->reasonPhrase; - } - - /** - * Whether response is a redirect that can be automatically handled by HTTP_Request2 - * @return bool - */ - public function isRedirect() - { - return in_array($this->code, array(300, 301, 302, 303, 307)) - && isset($this->headers['location']); - } - - /** - * Returns either the named header or all response headers - * - * @param string Name of header to return - * @return string|array Value of $headerName header (null if header is - * not present), array of all response headers if - * $headerName is null - */ - public function getHeader($headerName = null) - { - if (null === $headerName) { - return $this->headers; - } else { - $headerName = strtolower($headerName); - return isset($this->headers[$headerName])? $this->headers[$headerName]: null; - } - } - - /** - * Returns cookies set in response - * - * @return array - */ - public function getCookies() - { - return $this->cookies; - } - - /** - * Returns the body of the response - * - * @return string - * @throws HTTP_Request2_Exception if body cannot be decoded - */ - public function getBody() - { - if (!$this->bodyEncoded || - !in_array(strtolower($this->getHeader('content-encoding')), array('gzip', 'deflate')) - ) { - return $this->body; - - } else { - if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { - $oldEncoding = mb_internal_encoding(); - mb_internal_encoding('iso-8859-1'); - } - - try { - switch (strtolower($this->getHeader('content-encoding'))) { - case 'gzip': - $decoded = self::decodeGzip($this->body); - break; - case 'deflate': - $decoded = self::decodeDeflate($this->body); - } - } catch (Exception $e) { - } - - if (!empty($oldEncoding)) { - mb_internal_encoding($oldEncoding); - } - if (!empty($e)) { - throw $e; - } - return $decoded; - } - } - - /** - * Get the HTTP version of the response - * - * @return string - */ - public function getVersion() - { - return $this->version; - } - - /** - * Decodes the message-body encoded by gzip - * - * The real decoding work is done by gzinflate() built-in function, this - * method only parses the header and checks data for compliance with - * RFC 1952 - * - * @param string gzip-encoded data - * @return string decoded data - * @throws HTTP_Request2_Exception - * @link http://tools.ietf.org/html/rfc1952 - */ - public static function decodeGzip($data) - { - $length = strlen($data); - // If it doesn't look like gzip-encoded data, don't bother - if (18 > $length || strcmp(substr($data, 0, 2), "\x1f\x8b")) { - return $data; - } - if (!function_exists('gzinflate')) { - throw new HTTP_Request2_Exception('Unable to decode body: gzip extension not available'); - } - $method = ord(substr($data, 2, 1)); - if (8 != $method) { - throw new HTTP_Request2_Exception('Error parsing gzip header: unknown compression method'); - } - $flags = ord(substr($data, 3, 1)); - if ($flags & 224) { - throw new HTTP_Request2_Exception('Error parsing gzip header: reserved bits are set'); - } - - // header is 10 bytes minimum. may be longer, though. - $headerLength = 10; - // extra fields, need to skip 'em - if ($flags & 4) { - if ($length - $headerLength - 2 < 8) { - throw new HTTP_Request2_Exception('Error parsing gzip header: data too short'); - } - $extraLength = unpack('v', substr($data, 10, 2)); - if ($length - $headerLength - 2 - $extraLength[1] < 8) { - throw new HTTP_Request2_Exception('Error parsing gzip header: data too short'); - } - $headerLength += $extraLength[1] + 2; - } - // file name, need to skip that - if ($flags & 8) { - if ($length - $headerLength - 1 < 8) { - throw new HTTP_Request2_Exception('Error parsing gzip header: data too short'); - } - $filenameLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $filenameLength || $length - $headerLength - $filenameLength - 1 < 8) { - throw new HTTP_Request2_Exception('Error parsing gzip header: data too short'); - } - $headerLength += $filenameLength + 1; - } - // comment, need to skip that also - if ($flags & 16) { - if ($length - $headerLength - 1 < 8) { - throw new HTTP_Request2_Exception('Error parsing gzip header: data too short'); - } - $commentLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $commentLength || $length - $headerLength - $commentLength - 1 < 8) { - throw new HTTP_Request2_Exception('Error parsing gzip header: data too short'); - } - $headerLength += $commentLength + 1; - } - // have a CRC for header. let's check - if ($flags & 2) { - if ($length - $headerLength - 2 < 8) { - throw new HTTP_Request2_Exception('Error parsing gzip header: data too short'); - } - $crcReal = 0xffff & crc32(substr($data, 0, $headerLength)); - $crcStored = unpack('v', substr($data, $headerLength, 2)); - if ($crcReal != $crcStored[1]) { - throw new HTTP_Request2_Exception('Header CRC check failed'); - } - $headerLength += 2; - } - // unpacked data CRC and size at the end of encoded data - $tmp = unpack('V2', substr($data, -8)); - $dataCrc = $tmp[1]; - $dataSize = $tmp[2]; - - // finally, call the gzinflate() function - // don't pass $dataSize to gzinflate, see bugs #13135, #14370 - $unpacked = gzinflate(substr($data, $headerLength, -8)); - if (false === $unpacked) { - throw new HTTP_Request2_Exception('gzinflate() call failed'); - } elseif ($dataSize != strlen($unpacked)) { - throw new HTTP_Request2_Exception('Data size check failed'); - } elseif ((0xffffffff & $dataCrc) != (0xffffffff & crc32($unpacked))) { - throw new HTTP_Request2_Exception('Data CRC check failed'); - } - return $unpacked; - } - - /** - * Decodes the message-body encoded by deflate - * - * @param string deflate-encoded data - * @return string decoded data - * @throws HTTP_Request2_Exception - */ - public static function decodeDeflate($data) - { - if (!function_exists('gzuncompress')) { - throw new HTTP_Request2_Exception('Unable to decode body: gzip extension not available'); - } - // RFC 2616 defines 'deflate' encoding as zlib format from RFC 1950, - // while many applications send raw deflate stream from RFC 1951. - // We should check for presence of zlib header and use gzuncompress() or - // gzinflate() as needed. See bug #15305 - $header = unpack('n', substr($data, 0, 2)); - return (0 == $header[1] % 31)? gzuncompress($data): gzinflate($data); - } -} -?> \ No newline at end of file diff --git a/libs/PEAR.1.9/Net/URL2.php b/libs/PEAR.1.9/Net/URL2.php deleted file mode 100644 index bbc9f124d..000000000 --- a/libs/PEAR.1.9/Net/URL2.php +++ /dev/null @@ -1,894 +0,0 @@ - - * @copyright 2007-2009 Peytz & Co. A/S - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: URL2.php 290036 2009-10-28 19:52:49Z schmidt $ - * @link http://www.rfc-editor.org/rfc/rfc3986.txt - */ - -/** - * Represents a URL as per RFC 3986. - * - * @category Networking - * @package Net_URL2 - * @author Christian Schmidt - * @copyright 2007-2009 Peytz & Co. A/S - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/Net_URL2 - */ -class Net_URL2 -{ - /** - * Do strict parsing in resolve() (see RFC 3986, section 5.2.2). Default - * is true. - */ - const OPTION_STRICT = 'strict'; - - /** - * Represent arrays in query using PHP's [] notation. Default is true. - */ - const OPTION_USE_BRACKETS = 'use_brackets'; - - /** - * URL-encode query variable keys. Default is true. - */ - const OPTION_ENCODE_KEYS = 'encode_keys'; - - /** - * Query variable separators when parsing the query string. Every character - * is considered a separator. Default is "&". - */ - const OPTION_SEPARATOR_INPUT = 'input_separator'; - - /** - * Query variable separator used when generating the query string. Default - * is "&". - */ - const OPTION_SEPARATOR_OUTPUT = 'output_separator'; - - /** - * Default options corresponds to how PHP handles $_GET. - */ - private $_options = array( - self::OPTION_STRICT => true, - self::OPTION_USE_BRACKETS => true, - self::OPTION_ENCODE_KEYS => true, - self::OPTION_SEPARATOR_INPUT => '&', - self::OPTION_SEPARATOR_OUTPUT => '&', - ); - - /** - * @var string|bool - */ - private $_scheme = false; - - /** - * @var string|bool - */ - private $_userinfo = false; - - /** - * @var string|bool - */ - private $_host = false; - - /** - * @var string|bool - */ - private $_port = false; - - /** - * @var string - */ - private $_path = ''; - - /** - * @var string|bool - */ - private $_query = false; - - /** - * @var string|bool - */ - private $_fragment = false; - - /** - * Constructor. - * - * @param string $url an absolute or relative URL - * @param array $options an array of OPTION_xxx constants - */ - public function __construct($url, array $options = array()) - { - foreach ($options as $optionName => $value) { - if (array_key_exists($optionName, $this->_options)) { - $this->_options[$optionName] = $value; - } - } - - // The regular expression is copied verbatim from RFC 3986, appendix B. - // The expression does not validate the URL but matches any string. - preg_match('!^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?!', - $url, - $matches); - - // "path" is always present (possibly as an empty string); the rest - // are optional. - $this->_scheme = !empty($matches[1]) ? $matches[2] : false; - $this->setAuthority(!empty($matches[3]) ? $matches[4] : false); - $this->_path = $matches[5]; - $this->_query = !empty($matches[6]) ? $matches[7] : false; - $this->_fragment = !empty($matches[8]) ? $matches[9] : false; - } - - /** - * Magic Setter. - * - * This method will magically set the value of a private variable ($var) - * with the value passed as the args - * - * @param string $var The private variable to set. - * @param mixed $arg An argument of any type. - * @return void - */ - public function __set($var, $arg) - { - $method = 'set' . $var; - if (method_exists($this, $method)) { - $this->$method($arg); - } - } - - /** - * Magic Getter. - * - * This is the magic get method to retrieve the private variable - * that was set by either __set() or it's setter... - * - * @param string $var The property name to retrieve. - * @return mixed $this->$var Either a boolean false if the - * property is not set or the value - * of the private property. - */ - public function __get($var) - { - $method = 'get' . $var; - if (method_exists($this, $method)) { - return $this->$method(); - } - - return false; - } - - /** - * Returns the scheme, e.g. "http" or "urn", or false if there is no - * scheme specified, i.e. if this is a relative URL. - * - * @return string|bool - */ - public function getScheme() - { - return $this->_scheme; - } - - /** - * Sets the scheme, e.g. "http" or "urn". Specify false if there is no - * scheme specified, i.e. if this is a relative URL. - * - * @param string|bool $scheme e.g. "http" or "urn", or false if there is no - * scheme specified, i.e. if this is a relative - * URL - * - * @return void - * @see getScheme() - */ - public function setScheme($scheme) - { - $this->_scheme = $scheme; - } - - /** - * Returns the user part of the userinfo part (the part preceding the first - * ":"), or false if there is no userinfo part. - * - * @return string|bool - */ - public function getUser() - { - return $this->_userinfo !== false - ? preg_replace('@:.*$@', '', $this->_userinfo) - : false; - } - - /** - * Returns the password part of the userinfo part (the part after the first - * ":"), or false if there is no userinfo part (i.e. the URL does not - * contain "@" in front of the hostname) or the userinfo part does not - * contain ":". - * - * @return string|bool - */ - public function getPassword() - { - return $this->_userinfo !== false - ? substr(strstr($this->_userinfo, ':'), 1) - : false; - } - - /** - * Returns the userinfo part, or false if there is none, i.e. if the - * authority part does not contain "@". - * - * @return string|bool - */ - public function getUserinfo() - { - return $this->_userinfo; - } - - /** - * Sets the userinfo part. If two arguments are passed, they are combined - * in the userinfo part as username ":" password. - * - * @param string|bool $userinfo userinfo or username - * @param string|bool $password optional password, or false - * - * @return void - */ - public function setUserinfo($userinfo, $password = false) - { - $this->_userinfo = $userinfo; - if ($password !== false) { - $this->_userinfo .= ':' . $password; - } - } - - /** - * Returns the host part, or false if there is no authority part, e.g. - * relative URLs. - * - * @return string|bool a hostname, an IP address, or false - */ - public function getHost() - { - return $this->_host; - } - - /** - * Sets the host part. Specify false if there is no authority part, e.g. - * relative URLs. - * - * @param string|bool $host a hostname, an IP address, or false - * - * @return void - */ - public function setHost($host) - { - $this->_host = $host; - } - - /** - * Returns the port number, or false if there is no port number specified, - * i.e. if the default port is to be used. - * - * @return string|bool - */ - public function getPort() - { - return $this->_port; - } - - /** - * Sets the port number. Specify false if there is no port number specified, - * i.e. if the default port is to be used. - * - * @param string|bool $port a port number, or false - * - * @return void - */ - public function setPort($port) - { - $this->_port = $port; - } - - /** - * Returns the authority part, i.e. [ userinfo "@" ] host [ ":" port ], or - * false if there is no authority. - * - * @return string|bool - */ - public function getAuthority() - { - if (!$this->_host) { - return false; - } - - $authority = ''; - - if ($this->_userinfo !== false) { - $authority .= $this->_userinfo . '@'; - } - - $authority .= $this->_host; - - if ($this->_port !== false) { - $authority .= ':' . $this->_port; - } - - return $authority; - } - - /** - * Sets the authority part, i.e. [ userinfo "@" ] host [ ":" port ]. Specify - * false if there is no authority. - * - * @param string|false $authority a hostname or an IP addresse, possibly - * with userinfo prefixed and port number - * appended, e.g. "foo:bar@example.org:81". - * - * @return void - */ - public function setAuthority($authority) - { - $this->_userinfo = false; - $this->_host = false; - $this->_port = false; - if (preg_match('@^(([^\@]*)\@)?([^:]+)(:(\d*))?$@', $authority, $reg)) { - if ($reg[1]) { - $this->_userinfo = $reg[2]; - } - - $this->_host = $reg[3]; - if (isset($reg[5])) { - $this->_port = $reg[5]; - } - } - } - - /** - * Returns the path part (possibly an empty string). - * - * @return string - */ - public function getPath() - { - return $this->_path; - } - - /** - * Sets the path part (possibly an empty string). - * - * @param string $path a path - * - * @return void - */ - public function setPath($path) - { - $this->_path = $path; - } - - /** - * Returns the query string (excluding the leading "?"), or false if "?" - * is not present in the URL. - * - * @return string|bool - * @see self::getQueryVariables() - */ - public function getQuery() - { - return $this->_query; - } - - /** - * Sets the query string (excluding the leading "?"). Specify false if "?" - * is not present in the URL. - * - * @param string|bool $query a query string, e.g. "foo=1&bar=2" - * - * @return void - * @see self::setQueryVariables() - */ - public function setQuery($query) - { - $this->_query = $query; - } - - /** - * Returns the fragment name, or false if "#" is not present in the URL. - * - * @return string|bool - */ - public function getFragment() - { - return $this->_fragment; - } - - /** - * Sets the fragment name. Specify false if "#" is not present in the URL. - * - * @param string|bool $fragment a fragment excluding the leading "#", or - * false - * - * @return void - */ - public function setFragment($fragment) - { - $this->_fragment = $fragment; - } - - /** - * Returns the query string like an array as the variables would appear in - * $_GET in a PHP script. If the URL does not contain a "?", an empty array - * is returned. - * - * @return array - */ - public function getQueryVariables() - { - $pattern = '/[' . - preg_quote($this->getOption(self::OPTION_SEPARATOR_INPUT), '/') . - ']/'; - $parts = preg_split($pattern, $this->_query, -1, PREG_SPLIT_NO_EMPTY); - $return = array(); - - foreach ($parts as $part) { - if (strpos($part, '=') !== false) { - list($key, $value) = explode('=', $part, 2); - } else { - $key = $part; - $value = null; - } - - if ($this->getOption(self::OPTION_ENCODE_KEYS)) { - $key = rawurldecode($key); - } - $value = rawurldecode($value); - - if ($this->getOption(self::OPTION_USE_BRACKETS) && - preg_match('#^(.*)\[([0-9a-z_-]*)\]#i', $key, $matches)) { - - $key = $matches[1]; - $idx = $matches[2]; - - // Ensure is an array - if (empty($return[$key]) || !is_array($return[$key])) { - $return[$key] = array(); - } - - // Add data - if ($idx === '') { - $return[$key][] = $value; - } else { - $return[$key][$idx] = $value; - } - } elseif (!$this->getOption(self::OPTION_USE_BRACKETS) - && !empty($return[$key]) - ) { - $return[$key] = (array) $return[$key]; - $return[$key][] = $value; - } else { - $return[$key] = $value; - } - } - - return $return; - } - - /** - * Sets the query string to the specified variable in the query string. - * - * @param array $array (name => value) array - * - * @return void - */ - public function setQueryVariables(array $array) - { - if (!$array) { - $this->_query = false; - } else { - foreach ($array as $name => $value) { - if ($this->getOption(self::OPTION_ENCODE_KEYS)) { - $name = self::urlencode($name); - } - - if (is_array($value)) { - foreach ($value as $k => $v) { - $parts[] = $this->getOption(self::OPTION_USE_BRACKETS) - ? sprintf('%s[%s]=%s', $name, $k, $v) - : ($name . '=' . $v); - } - } elseif (!is_null($value)) { - $parts[] = $name . '=' . self::urlencode($value); - } else { - $parts[] = $name; - } - } - $this->_query = implode($this->getOption(self::OPTION_SEPARATOR_OUTPUT), - $parts); - } - } - - /** - * Sets the specified variable in the query string. - * - * @param string $name variable name - * @param mixed $value variable value - * - * @return array - */ - public function setQueryVariable($name, $value) - { - $array = $this->getQueryVariables(); - $array[$name] = $value; - $this->setQueryVariables($array); - } - - /** - * Removes the specifed variable from the query string. - * - * @param string $name a query string variable, e.g. "foo" in "?foo=1" - * - * @return void - */ - public function unsetQueryVariable($name) - { - $array = $this->getQueryVariables(); - unset($array[$name]); - $this->setQueryVariables($array); - } - - /** - * Returns a string representation of this URL. - * - * @return string - */ - public function getURL() - { - // See RFC 3986, section 5.3 - $url = ""; - - if ($this->_scheme !== false) { - $url .= $this->_scheme . ':'; - } - - $authority = $this->getAuthority(); - if ($authority !== false) { - $url .= '//' . $authority; - } - $url .= $this->_path; - - if ($this->_query !== false) { - $url .= '?' . $this->_query; - } - - if ($this->_fragment !== false) { - $url .= '#' . $this->_fragment; - } - - return $url; - } - - /** - * Returns a string representation of this URL. - * - * @return string - * @see toString() - */ - public function __toString() - { - return $this->getURL(); - } - - /** - * Returns a normalized string representation of this URL. This is useful - * for comparison of URLs. - * - * @return string - */ - public function getNormalizedURL() - { - $url = clone $this; - $url->normalize(); - return $url->getUrl(); - } - - /** - * Returns a normalized Net_URL2 instance. - * - * @return Net_URL2 - */ - public function normalize() - { - // See RFC 3886, section 6 - - // Schemes are case-insensitive - if ($this->_scheme) { - $this->_scheme = strtolower($this->_scheme); - } - - // Hostnames are case-insensitive - if ($this->_host) { - $this->_host = strtolower($this->_host); - } - - // Remove default port number for known schemes (RFC 3986, section 6.2.3) - if ($this->_port && - $this->_scheme && - $this->_port == getservbyname($this->_scheme, 'tcp')) { - - $this->_port = false; - } - - // Normalize case of %XX percentage-encodings (RFC 3986, section 6.2.2.1) - foreach (array('_userinfo', '_host', '_path') as $part) { - if ($this->$part) { - $this->$part = preg_replace('/%[0-9a-f]{2}/ie', - 'strtoupper("\0")', - $this->$part); - } - } - - // Path segment normalization (RFC 3986, section 6.2.2.3) - $this->_path = self::removeDotSegments($this->_path); - - // Scheme based normalization (RFC 3986, section 6.2.3) - if ($this->_host && !$this->_path) { - $this->_path = '/'; - } - } - - /** - * Returns whether this instance represents an absolute URL. - * - * @return bool - */ - public function isAbsolute() - { - return (bool) $this->_scheme; - } - - /** - * Returns an Net_URL2 instance representing an absolute URL relative to - * this URL. - * - * @param Net_URL2|string $reference relative URL - * - * @return Net_URL2 - */ - public function resolve($reference) - { - if (!$reference instanceof Net_URL2) { - $reference = new self($reference); - } - if (!$this->isAbsolute()) { - throw new Exception('Base-URL must be absolute'); - } - - // A non-strict parser may ignore a scheme in the reference if it is - // identical to the base URI's scheme. - if (!$this->getOption(self::OPTION_STRICT) && $reference->_scheme == $this->_scheme) { - $reference->_scheme = false; - } - - $target = new self(''); - if ($reference->_scheme !== false) { - $target->_scheme = $reference->_scheme; - $target->setAuthority($reference->getAuthority()); - $target->_path = self::removeDotSegments($reference->_path); - $target->_query = $reference->_query; - } else { - $authority = $reference->getAuthority(); - if ($authority !== false) { - $target->setAuthority($authority); - $target->_path = self::removeDotSegments($reference->_path); - $target->_query = $reference->_query; - } else { - if ($reference->_path == '') { - $target->_path = $this->_path; - if ($reference->_query !== false) { - $target->_query = $reference->_query; - } else { - $target->_query = $this->_query; - } - } else { - if (substr($reference->_path, 0, 1) == '/') { - $target->_path = self::removeDotSegments($reference->_path); - } else { - // Merge paths (RFC 3986, section 5.2.3) - if ($this->_host !== false && $this->_path == '') { - $target->_path = '/' . $this->_path; - } else { - $i = strrpos($this->_path, '/'); - if ($i !== false) { - $target->_path = substr($this->_path, 0, $i + 1); - } - $target->_path .= $reference->_path; - } - $target->_path = self::removeDotSegments($target->_path); - } - $target->_query = $reference->_query; - } - $target->setAuthority($this->getAuthority()); - } - $target->_scheme = $this->_scheme; - } - - $target->_fragment = $reference->_fragment; - - return $target; - } - - /** - * Removes dots as described in RFC 3986, section 5.2.4, e.g. - * "/foo/../bar/baz" => "/bar/baz" - * - * @param string $path a path - * - * @return string a path - */ - public static function removeDotSegments($path) - { - $output = ''; - - // Make sure not to be trapped in an infinite loop due to a bug in this - // method - $j = 0; - while ($path && $j++ < 100) { - if (substr($path, 0, 2) == './') { - // Step 2.A - $path = substr($path, 2); - } elseif (substr($path, 0, 3) == '../') { - // Step 2.A - $path = substr($path, 3); - } elseif (substr($path, 0, 3) == '/./' || $path == '/.') { - // Step 2.B - $path = '/' . substr($path, 3); - } elseif (substr($path, 0, 4) == '/../' || $path == '/..') { - // Step 2.C - $path = '/' . substr($path, 4); - $i = strrpos($output, '/'); - $output = $i === false ? '' : substr($output, 0, $i); - } elseif ($path == '.' || $path == '..') { - // Step 2.D - $path = ''; - } else { - // Step 2.E - $i = strpos($path, '/'); - if ($i === 0) { - $i = strpos($path, '/', 1); - } - if ($i === false) { - $i = strlen($path); - } - $output .= substr($path, 0, $i); - $path = substr($path, $i); - } - } - - return $output; - } - - /** - * Percent-encodes all non-alphanumeric characters except these: _ . - ~ - * Similar to PHP's rawurlencode(), except that it also encodes ~ in PHP - * 5.2.x and earlier. - * - * @param $raw the string to encode - * @return string - */ - public static function urlencode($string) - { - $encoded = rawurlencode($string); - // This is only necessary in PHP < 5.3. - $encoded = str_replace('%7E', '~', $encoded); - return $encoded; - } - - /** - * Returns a Net_URL2 instance representing the canonical URL of the - * currently executing PHP script. - * - * @return string - */ - public static function getCanonical() - { - if (!isset($_SERVER['REQUEST_METHOD'])) { - // ALERT - no current URL - throw new Exception('Script was not called through a webserver'); - } - - // Begin with a relative URL - $url = new self($_SERVER['PHP_SELF']); - $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; - $url->_host = $_SERVER['SERVER_NAME']; - $port = $_SERVER['SERVER_PORT']; - if ($url->_scheme == 'http' && $port != 80 || - $url->_scheme == 'https' && $port != 443) { - - $url->_port = $port; - } - return $url; - } - - /** - * Returns the URL used to retrieve the current request. - * - * @return string - */ - public static function getRequestedURL() - { - return self::getRequested()->getUrl(); - } - - /** - * Returns a Net_URL2 instance representing the URL used to retrieve the - * current request. - * - * @return Net_URL2 - */ - public static function getRequested() - { - if (!isset($_SERVER['REQUEST_METHOD'])) { - // ALERT - no current URL - throw new Exception('Script was not called through a webserver'); - } - - // Begin with a relative URL - $url = new self($_SERVER['REQUEST_URI']); - $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; - // Set host and possibly port - $url->setAuthority($_SERVER['HTTP_HOST']); - return $url; - } - - /** - * Returns the value of the specified option. - * - * @param string $optionName The name of the option to retrieve - * - * @return mixed - */ - function getOption($optionName) - { - return isset($this->_options[$optionName]) - ? $this->_options[$optionName] : false; - } -} diff --git a/libs/PEAR.1.9/PEAR.php b/libs/PEAR.1.9/PEAR.php deleted file mode 100644 index d48ee8282..000000000 --- a/libs/PEAR.1.9/PEAR.php +++ /dev/null @@ -1,1137 +0,0 @@ - - * @author Stig Bakken - * @author Tomas V.V.Cox - * @author Greg Beaver - * @copyright 1997-2009 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: PEAR.php 286670 2009-08-02 14:16:06Z dufuz $ - * @link http://pear.php.net/package/PEAR - * @since File available since Release 0.1 - */ - -/**#@+ - * ERROR constants - */ -define('PEAR_ERROR_RETURN', 1); -define('PEAR_ERROR_PRINT', 2); -define('PEAR_ERROR_TRIGGER', 4); -define('PEAR_ERROR_DIE', 8); -define('PEAR_ERROR_CALLBACK', 16); -/** - * WARNING: obsolete - * @deprecated - */ -define('PEAR_ERROR_EXCEPTION', 32); -/**#@-*/ -define('PEAR_ZE2', (function_exists('version_compare') && - version_compare(zend_version(), "2-dev", "ge"))); - -if (substr(PHP_OS, 0, 3) == 'WIN') { - define('OS_WINDOWS', true); - define('OS_UNIX', false); - define('PEAR_OS', 'Windows'); -} else { - define('OS_WINDOWS', false); - define('OS_UNIX', true); - define('PEAR_OS', 'Unix'); // blatant assumption -} - -$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN; -$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE; -$GLOBALS['_PEAR_destructor_object_list'] = array(); -$GLOBALS['_PEAR_shutdown_funcs'] = array(); -$GLOBALS['_PEAR_error_handler_stack'] = array(); - -@ini_set('track_errors', true); - -/** - * Base class for other PEAR classes. Provides rudimentary - * emulation of destructors. - * - * If you want a destructor in your class, inherit PEAR and make a - * destructor method called _yourclassname (same name as the - * constructor, but with a "_" prefix). Also, in your constructor you - * have to call the PEAR constructor: $this->PEAR();. - * The destructor method will be called without parameters. Note that - * at in some SAPI implementations (such as Apache), any output during - * the request shutdown (in which destructors are called) seems to be - * discarded. If you need to get any debug information from your - * destructor, use error_log(), syslog() or something similar. - * - * IMPORTANT! To use the emulated destructors you need to create the - * objects by reference: $obj =& new PEAR_child; - * - * @category pear - * @package PEAR - * @author Stig Bakken - * @author Tomas V.V. Cox - * @author Greg Beaver - * @copyright 1997-2006 The PHP Group - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.9.0 - * @link http://pear.php.net/package/PEAR - * @see PEAR_Error - * @since Class available since PHP 4.0.2 - * @link http://pear.php.net/manual/en/core.pear.php#core.pear.pear - */ -class PEAR -{ - // {{{ properties - - /** - * Whether to enable internal debug messages. - * - * @var bool - * @access private - */ - var $_debug = false; - - /** - * Default error mode for this object. - * - * @var int - * @access private - */ - var $_default_error_mode = null; - - /** - * Default error options used for this object when error mode - * is PEAR_ERROR_TRIGGER. - * - * @var int - * @access private - */ - var $_default_error_options = null; - - /** - * Default error handler (callback) for this object, if error mode is - * PEAR_ERROR_CALLBACK. - * - * @var string - * @access private - */ - var $_default_error_handler = ''; - - /** - * Which class to use for error objects. - * - * @var string - * @access private - */ - var $_error_class = 'PEAR_Error'; - - /** - * An array of expected errors. - * - * @var array - * @access private - */ - var $_expected_errors = array(); - - // }}} - - // {{{ constructor - - /** - * Constructor. Registers this object in - * $_PEAR_destructor_object_list for destructor emulation if a - * destructor object exists. - * - * @param string $error_class (optional) which class to use for - * error objects, defaults to PEAR_Error. - * @access public - * @return void - */ - function PEAR($error_class = null) - { - $classname = strtolower(get_class($this)); - if ($this->_debug) { - print "PEAR constructor called, class=$classname\n"; - } - if ($error_class !== null) { - $this->_error_class = $error_class; - } - while ($classname && strcasecmp($classname, "pear")) { - $destructor = "_$classname"; - if (method_exists($this, $destructor)) { - global $_PEAR_destructor_object_list; - $_PEAR_destructor_object_list[] = &$this; - if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { - register_shutdown_function("_PEAR_call_destructors"); - $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; - } - break; - } else { - $classname = get_parent_class($classname); - } - } - } - - // }}} - // {{{ destructor - - /** - * Destructor (the emulated type of...). Does nothing right now, - * but is included for forward compatibility, so subclass - * destructors should always call it. - * - * See the note in the class desciption about output from - * destructors. - * - * @access public - * @return void - */ - function _PEAR() { - if ($this->_debug) { - printf("PEAR destructor called, class=%s\n", strtolower(get_class($this))); - } - } - - // }}} - // {{{ getStaticProperty() - - /** - * If you have a class that's mostly/entirely static, and you need static - * properties, you can use this method to simulate them. Eg. in your method(s) - * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); - * You MUST use a reference, or they will not persist! - * - * @access public - * @param string $class The calling classname, to prevent clashes - * @param string $var The variable to retrieve. - * @return mixed A reference to the variable. If not set it will be - * auto initialised to NULL. - */ - function &getStaticProperty($class, $var) - { - static $properties; - if (!isset($properties[$class])) { - $properties[$class] = array(); - } - - if (!array_key_exists($var, $properties[$class])) { - $properties[$class][$var] = null; - } - - return $properties[$class][$var]; - } - - // }}} - // {{{ registerShutdownFunc() - - /** - * Use this function to register a shutdown method for static - * classes. - * - * @access public - * @param mixed $func The function name (or array of class/method) to call - * @param mixed $args The arguments to pass to the function - * @return void - */ - function registerShutdownFunc($func, $args = array()) - { - // if we are called statically, there is a potential - // that no shutdown func is registered. Bug #6445 - if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { - register_shutdown_function("_PEAR_call_destructors"); - $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; - } - $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args); - } - - // }}} - // {{{ isError() - - /** - * Tell whether a value is a PEAR error. - * - * @param mixed $data the value to test - * @param int $code if $data is an error object, return true - * only if $code is a string and - * $obj->getMessage() == $code or - * $code is an integer and $obj->getCode() == $code - * @access public - * @return bool true if parameter is an error - */ - function isError($data, $code = null) - { - if (!is_a($data, 'PEAR_Error')) { - return false; - } - - if (is_null($code)) { - return true; - } elseif (is_string($code)) { - return $data->getMessage() == $code; - } - - return $data->getCode() == $code; - } - - // }}} - // {{{ setErrorHandling() - - /** - * Sets how errors generated by this object should be handled. - * Can be invoked both in objects and statically. If called - * statically, setErrorHandling sets the default behaviour for all - * PEAR objects. If called in an object, setErrorHandling sets - * the default behaviour for that object. - * - * @param int $mode - * One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, - * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION. - * - * @param mixed $options - * When $mode is PEAR_ERROR_TRIGGER, this is the error level (one - * of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * - * When $mode is PEAR_ERROR_CALLBACK, this parameter is expected - * to be the callback function or method. A callback - * function is a string with the name of the function, a - * callback method is an array of two elements: the element - * at index 0 is the object, and the element at index 1 is - * the name of the method to call in the object. - * - * When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is - * a printf format string used when printing the error - * message. - * - * @access public - * @return void - * @see PEAR_ERROR_RETURN - * @see PEAR_ERROR_PRINT - * @see PEAR_ERROR_TRIGGER - * @see PEAR_ERROR_DIE - * @see PEAR_ERROR_CALLBACK - * @see PEAR_ERROR_EXCEPTION - * - * @since PHP 4.0.5 - */ - - function setErrorHandling($mode = null, $options = null) - { - if (isset($this) && is_a($this, 'PEAR')) { - $setmode = &$this->_default_error_mode; - $setoptions = &$this->_default_error_options; - } else { - $setmode = &$GLOBALS['_PEAR_default_error_mode']; - $setoptions = &$GLOBALS['_PEAR_default_error_options']; - } - - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $setmode = $mode; - $setoptions = $options; - break; - - case PEAR_ERROR_CALLBACK: - $setmode = $mode; - // class/object method callback - if (is_callable($options)) { - $setoptions = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - } - - // }}} - // {{{ expectError() - - /** - * This method is used to tell which errors you expect to get. - * Expected errors are always returned with error mode - * PEAR_ERROR_RETURN. Expected error codes are stored in a stack, - * and this method pushes a new element onto it. The list of - * expected errors are in effect until they are popped off the - * stack with the popExpect() method. - * - * Note that this method can not be called statically - * - * @param mixed $code a single error code or an array of error codes to expect - * - * @return int the new depth of the "expected errors" stack - * @access public - */ - function expectError($code = '*') - { - if (is_array($code)) { - array_push($this->_expected_errors, $code); - } else { - array_push($this->_expected_errors, array($code)); - } - return sizeof($this->_expected_errors); - } - - // }}} - // {{{ popExpect() - - /** - * This method pops one element off the expected error codes - * stack. - * - * @return array the list of error codes that were popped - */ - function popExpect() - { - return array_pop($this->_expected_errors); - } - - // }}} - // {{{ _checkDelExpect() - - /** - * This method checks unsets an error code if available - * - * @param mixed error code - * @return bool true if the error code was unset, false otherwise - * @access private - * @since PHP 4.3.0 - */ - function _checkDelExpect($error_code) - { - $deleted = false; - - foreach ($this->_expected_errors AS $key => $error_array) { - if (in_array($error_code, $error_array)) { - unset($this->_expected_errors[$key][array_search($error_code, $error_array)]); - $deleted = true; - } - - // clean up empty arrays - if (0 == count($this->_expected_errors[$key])) { - unset($this->_expected_errors[$key]); - } - } - return $deleted; - } - - // }}} - // {{{ delExpect() - - /** - * This method deletes all occurences of the specified element from - * the expected error codes stack. - * - * @param mixed $error_code error code that should be deleted - * @return mixed list of error codes that were deleted or error - * @access public - * @since PHP 4.3.0 - */ - function delExpect($error_code) - { - $deleted = false; - if ((is_array($error_code) && (0 != count($error_code)))) { - // $error_code is a non-empty array here; - // we walk through it trying to unset all - // values - foreach($error_code as $key => $error) { - if ($this->_checkDelExpect($error)) { - $deleted = true; - } else { - $deleted = false; - } - } - return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME - } elseif (!empty($error_code)) { - // $error_code comes alone, trying to unset it - if ($this->_checkDelExpect($error_code)) { - return true; - } else { - return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME - } - } - - // $error_code is empty - return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME - } - - // }}} - // {{{ raiseError() - - /** - * This method is a wrapper that returns an instance of the - * configured error class with this object's default error - * handling applied. If the $mode and $options parameters are not - * specified, the object's defaults are used. - * - * @param mixed $message a text error message or a PEAR error object - * - * @param int $code a numeric error code (it is up to your class - * to define these if you want to use codes) - * - * @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, - * PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION. - * - * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter - * specifies the PHP-internal error level (one of - * E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * If $mode is PEAR_ERROR_CALLBACK, this - * parameter specifies the callback function or - * method. In other error modes this parameter - * is ignored. - * - * @param string $userinfo If you need to pass along for example debug - * information, this parameter is meant for that. - * - * @param string $error_class The returned error object will be - * instantiated from this class, if specified. - * - * @param bool $skipmsg If true, raiseError will only pass error codes, - * the error message parameter will be dropped. - * - * @access public - * @return object a PEAR error object - * @see PEAR::setErrorHandling - * @since PHP 4.0.5 - */ - function &raiseError($message = null, - $code = null, - $mode = null, - $options = null, - $userinfo = null, - $error_class = null, - $skipmsg = false) - { - // The error is yet a PEAR error object - if (is_object($message)) { - $code = $message->getCode(); - $userinfo = $message->getUserInfo(); - $error_class = $message->getType(); - $message->error_message_prefix = ''; - $message = $message->getMessage(); - } - - if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) { - if ($exp[0] == "*" || - (is_int(reset($exp)) && in_array($code, $exp)) || - (is_string(reset($exp)) && in_array($message, $exp))) { - $mode = PEAR_ERROR_RETURN; - } - } - - // No mode given, try global ones - if ($mode === null) { - // Class error handler - if (isset($this) && isset($this->_default_error_mode)) { - $mode = $this->_default_error_mode; - $options = $this->_default_error_options; - // Global error handler - } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) { - $mode = $GLOBALS['_PEAR_default_error_mode']; - $options = $GLOBALS['_PEAR_default_error_options']; - } - } - - if ($error_class !== null) { - $ec = $error_class; - } elseif (isset($this) && isset($this->_error_class)) { - $ec = $this->_error_class; - } else { - $ec = 'PEAR_Error'; - } - - if (intval(PHP_VERSION) < 5) { - // little non-eval hack to fix bug #12147 - include 'PEAR/FixPHP5PEARWarnings.php'; - return $a; - } - - if ($skipmsg) { - $a = new $ec($code, $mode, $options, $userinfo); - } else { - $a = new $ec($message, $code, $mode, $options, $userinfo); - } - - return $a; - } - - // }}} - // {{{ throwError() - - /** - * Simpler form of raiseError with fewer options. In most cases - * message, code and userinfo are enough. - * - * @param string $message - * - */ - function &throwError($message = null, - $code = null, - $userinfo = null) - { - if (isset($this) && is_a($this, 'PEAR')) { - $a = &$this->raiseError($message, $code, null, null, $userinfo); - return $a; - } - - $a = &PEAR::raiseError($message, $code, null, null, $userinfo); - return $a; - } - - // }}} - function staticPushErrorHandling($mode, $options = null) - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - $def_mode = &$GLOBALS['_PEAR_default_error_mode']; - $def_options = &$GLOBALS['_PEAR_default_error_options']; - $stack[] = array($def_mode, $def_options); - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $def_mode = $mode; - $def_options = $options; - break; - - case PEAR_ERROR_CALLBACK: - $def_mode = $mode; - // class/object method callback - if (is_callable($options)) { - $def_options = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - $stack[] = array($mode, $options); - return true; - } - - function staticPopErrorHandling() - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - $setmode = &$GLOBALS['_PEAR_default_error_mode']; - $setoptions = &$GLOBALS['_PEAR_default_error_options']; - array_pop($stack); - list($mode, $options) = $stack[sizeof($stack) - 1]; - array_pop($stack); - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $setmode = $mode; - $setoptions = $options; - break; - - case PEAR_ERROR_CALLBACK: - $setmode = $mode; - // class/object method callback - if (is_callable($options)) { - $setoptions = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - return true; - } - - // {{{ pushErrorHandling() - - /** - * Push a new error handler on top of the error handler options stack. With this - * you can easily override the actual error handler for some code and restore - * it later with popErrorHandling. - * - * @param mixed $mode (same as setErrorHandling) - * @param mixed $options (same as setErrorHandling) - * - * @return bool Always true - * - * @see PEAR::setErrorHandling - */ - function pushErrorHandling($mode, $options = null) - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - if (isset($this) && is_a($this, 'PEAR')) { - $def_mode = &$this->_default_error_mode; - $def_options = &$this->_default_error_options; - } else { - $def_mode = &$GLOBALS['_PEAR_default_error_mode']; - $def_options = &$GLOBALS['_PEAR_default_error_options']; - } - $stack[] = array($def_mode, $def_options); - - if (isset($this) && is_a($this, 'PEAR')) { - $this->setErrorHandling($mode, $options); - } else { - PEAR::setErrorHandling($mode, $options); - } - $stack[] = array($mode, $options); - return true; - } - - // }}} - // {{{ popErrorHandling() - - /** - * Pop the last error handler used - * - * @return bool Always true - * - * @see PEAR::pushErrorHandling - */ - function popErrorHandling() - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - array_pop($stack); - list($mode, $options) = $stack[sizeof($stack) - 1]; - array_pop($stack); - if (isset($this) && is_a($this, 'PEAR')) { - $this->setErrorHandling($mode, $options); - } else { - PEAR::setErrorHandling($mode, $options); - } - return true; - } - - // }}} - // {{{ loadExtension() - - /** - * OS independant PHP extension load. Remember to take care - * on the correct extension name for case sensitive OSes. - * - * @param string $ext The extension name - * @return bool Success or not on the dl() call - */ - function loadExtension($ext) - { - if (!extension_loaded($ext)) { - // if either returns true dl() will produce a FATAL error, stop that - if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) { - return false; - } - - if (OS_WINDOWS) { - $suffix = '.dll'; - } elseif (PHP_OS == 'HP-UX') { - $suffix = '.sl'; - } elseif (PHP_OS == 'AIX') { - $suffix = '.a'; - } elseif (PHP_OS == 'OSX') { - $suffix = '.bundle'; - } else { - $suffix = '.so'; - } - - return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix); - } - - return true; - } - - // }}} -} - -if (PEAR_ZE2) { - include_once 'PEAR5.php'; -} - -// {{{ _PEAR_call_destructors() - -function _PEAR_call_destructors() -{ - global $_PEAR_destructor_object_list; - if (is_array($_PEAR_destructor_object_list) && - sizeof($_PEAR_destructor_object_list)) - { - reset($_PEAR_destructor_object_list); - if (PEAR_ZE2) { - $destructLifoExists = PEAR5::getStaticProperty('PEAR', 'destructlifo'); - } else { - $destructLifoExists = PEAR::getStaticProperty('PEAR', 'destructlifo'); - } - - if ($destructLifoExists) { - $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list); - } - - while (list($k, $objref) = each($_PEAR_destructor_object_list)) { - $classname = get_class($objref); - while ($classname) { - $destructor = "_$classname"; - if (method_exists($objref, $destructor)) { - $objref->$destructor(); - break; - } else { - $classname = get_parent_class($classname); - } - } - } - // Empty the object list to ensure that destructors are - // not called more than once. - $_PEAR_destructor_object_list = array(); - } - - // Now call the shutdown functions - if (isset($GLOBALS['_PEAR_shutdown_funcs']) AND is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) { - foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) { - call_user_func_array($value[0], $value[1]); - } - } -} - -// }}} -/** - * Standard PEAR error class for PHP 4 - * - * This class is supserseded by {@link PEAR_Exception} in PHP 5 - * - * @category pear - * @package PEAR - * @author Stig Bakken - * @author Tomas V.V. Cox - * @author Gregory Beaver - * @copyright 1997-2006 The PHP Group - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.9.0 - * @link http://pear.php.net/manual/en/core.pear.pear-error.php - * @see PEAR::raiseError(), PEAR::throwError() - * @since Class available since PHP 4.0.2 - */ -class PEAR_Error -{ - // {{{ properties - - var $error_message_prefix = ''; - var $mode = PEAR_ERROR_RETURN; - var $level = E_USER_NOTICE; - var $code = -1; - var $message = ''; - var $userinfo = ''; - var $backtrace = null; - - // }}} - // {{{ constructor - - /** - * PEAR_Error constructor - * - * @param string $message message - * - * @param int $code (optional) error code - * - * @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN, - * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER, - * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION - * - * @param mixed $options (optional) error level, _OR_ in the case of - * PEAR_ERROR_CALLBACK, the callback function or object/method - * tuple. - * - * @param string $userinfo (optional) additional user/debug info - * - * @access public - * - */ - function PEAR_Error($message = 'unknown error', $code = null, - $mode = null, $options = null, $userinfo = null) - { - if ($mode === null) { - $mode = PEAR_ERROR_RETURN; - } - $this->message = $message; - $this->code = $code; - $this->mode = $mode; - $this->userinfo = $userinfo; - - if (PEAR_ZE2) { - $skiptrace = PEAR5::getStaticProperty('PEAR_Error', 'skiptrace'); - } else { - $skiptrace = PEAR::getStaticProperty('PEAR_Error', 'skiptrace'); - } - - if (!$skiptrace) { - $this->backtrace = debug_backtrace(); - if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) { - unset($this->backtrace[0]['object']); - } - } - - if ($mode & PEAR_ERROR_CALLBACK) { - $this->level = E_USER_NOTICE; - $this->callback = $options; - } else { - if ($options === null) { - $options = E_USER_NOTICE; - } - - $this->level = $options; - $this->callback = null; - } - - if ($this->mode & PEAR_ERROR_PRINT) { - if (is_null($options) || is_int($options)) { - $format = "%s"; - } else { - $format = $options; - } - - printf($format, $this->getMessage()); - } - - if ($this->mode & PEAR_ERROR_TRIGGER) { - trigger_error($this->getMessage(), $this->level); - } - - if ($this->mode & PEAR_ERROR_DIE) { - $msg = $this->getMessage(); - if (is_null($options) || is_int($options)) { - $format = "%s"; - if (substr($msg, -1) != "\n") { - $msg .= "\n"; - } - } else { - $format = $options; - } - die(sprintf($format, $msg)); - } - - if ($this->mode & PEAR_ERROR_CALLBACK) { - if (is_callable($this->callback)) { - call_user_func($this->callback, $this); - } - } - - if ($this->mode & PEAR_ERROR_EXCEPTION) { - trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING); - eval('$e = new Exception($this->message, $this->code);throw($e);'); - } - } - - // }}} - // {{{ getMode() - - /** - * Get the error mode from an error object. - * - * @return int error mode - * @access public - */ - function getMode() { - return $this->mode; - } - - // }}} - // {{{ getCallback() - - /** - * Get the callback function/method from an error object. - * - * @return mixed callback function or object/method array - * @access public - */ - function getCallback() { - return $this->callback; - } - - // }}} - // {{{ getMessage() - - - /** - * Get the error message from an error object. - * - * @return string full error message - * @access public - */ - function getMessage() - { - return ($this->error_message_prefix . $this->message); - } - - - // }}} - // {{{ getCode() - - /** - * Get error code from an error object - * - * @return int error code - * @access public - */ - function getCode() - { - return $this->code; - } - - // }}} - // {{{ getType() - - /** - * Get the name of this error/exception. - * - * @return string error/exception name (type) - * @access public - */ - function getType() - { - return get_class($this); - } - - // }}} - // {{{ getUserInfo() - - /** - * Get additional user-supplied information. - * - * @return string user-supplied information - * @access public - */ - function getUserInfo() - { - return $this->userinfo; - } - - // }}} - // {{{ getDebugInfo() - - /** - * Get additional debug information supplied by the application. - * - * @return string debug information - * @access public - */ - function getDebugInfo() - { - return $this->getUserInfo(); - } - - // }}} - // {{{ getBacktrace() - - /** - * Get the call backtrace from where the error was generated. - * Supported with PHP 4.3.0 or newer. - * - * @param int $frame (optional) what frame to fetch - * @return array Backtrace, or NULL if not available. - * @access public - */ - function getBacktrace($frame = null) - { - if (defined('PEAR_IGNORE_BACKTRACE')) { - return null; - } - if ($frame === null) { - return $this->backtrace; - } - return $this->backtrace[$frame]; - } - - // }}} - // {{{ addUserInfo() - - function addUserInfo($info) - { - if (empty($this->userinfo)) { - $this->userinfo = $info; - } else { - $this->userinfo .= " ** $info"; - } - } - - // }}} - // {{{ toString() - function __toString() - { - return $this->getMessage(); - } - // }}} - // {{{ toString() - - /** - * Make a string representation of this object. - * - * @return string a string with an object summary - * @access public - */ - function toString() { - $modes = array(); - $levels = array(E_USER_NOTICE => 'notice', - E_USER_WARNING => 'warning', - E_USER_ERROR => 'error'); - if ($this->mode & PEAR_ERROR_CALLBACK) { - if (is_array($this->callback)) { - $callback = (is_object($this->callback[0]) ? - strtolower(get_class($this->callback[0])) : - $this->callback[0]) . '::' . - $this->callback[1]; - } else { - $callback = $this->callback; - } - return sprintf('[%s: message="%s" code=%d mode=callback '. - 'callback=%s prefix="%s" info="%s"]', - strtolower(get_class($this)), $this->message, $this->code, - $callback, $this->error_message_prefix, - $this->userinfo); - } - if ($this->mode & PEAR_ERROR_PRINT) { - $modes[] = 'print'; - } - if ($this->mode & PEAR_ERROR_TRIGGER) { - $modes[] = 'trigger'; - } - if ($this->mode & PEAR_ERROR_DIE) { - $modes[] = 'die'; - } - if ($this->mode & PEAR_ERROR_RETURN) { - $modes[] = 'return'; - } - return sprintf('[%s: message="%s" code=%d mode=%s level=%s '. - 'prefix="%s" info="%s"]', - strtolower(get_class($this)), $this->message, $this->code, - implode("|", $modes), $levels[$this->level], - $this->error_message_prefix, - $this->userinfo); - } - - // }}} -} - -/* - * Local Variables: - * mode: php - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/libs/PEAR.1.9/PEAR/Exception.php b/libs/PEAR.1.9/PEAR/Exception.php deleted file mode 100644 index 5e8489703..000000000 --- a/libs/PEAR.1.9/PEAR/Exception.php +++ /dev/null @@ -1,391 +0,0 @@ - - * @author Hans Lellelid - * @author Bertrand Mansion - * @author Greg Beaver - * @copyright 1997-2009 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Exception.php 276383 2009-02-24 23:39:37Z dufuz $ - * @link http://pear.php.net/package/PEAR - * @since File available since Release 1.3.3 - */ - - -/** - * Base PEAR_Exception Class - * - * 1) Features: - * - * - Nestable exceptions (throw new PEAR_Exception($msg, $prev_exception)) - * - Definable triggers, shot when exceptions occur - * - Pretty and informative error messages - * - Added more context info available (like class, method or cause) - * - cause can be a PEAR_Exception or an array of mixed - * PEAR_Exceptions/PEAR_ErrorStack warnings - * - callbacks for specific exception classes and their children - * - * 2) Ideas: - * - * - Maybe a way to define a 'template' for the output - * - * 3) Inherited properties from PHP Exception Class: - * - * protected $message - * protected $code - * protected $line - * protected $file - * private $trace - * - * 4) Inherited methods from PHP Exception Class: - * - * __clone - * __construct - * getMessage - * getCode - * getFile - * getLine - * getTraceSafe - * getTraceSafeAsString - * __toString - * - * 5) Usage example - * - * - * require_once 'PEAR/Exception.php'; - * - * class Test { - * function foo() { - * throw new PEAR_Exception('Error Message', ERROR_CODE); - * } - * } - * - * function myLogger($pear_exception) { - * echo $pear_exception->getMessage(); - * } - * // each time a exception is thrown the 'myLogger' will be called - * // (its use is completely optional) - * PEAR_Exception::addObserver('myLogger'); - * $test = new Test; - * try { - * $test->foo(); - * } catch (PEAR_Exception $e) { - * print $e; - * } - * - * - * @category pear - * @package PEAR - * @author Tomas V.V.Cox - * @author Hans Lellelid - * @author Bertrand Mansion - * @author Greg Beaver - * @copyright 1997-2009 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.9.0 - * @link http://pear.php.net/package/PEAR - * @since Class available since Release 1.3.3 - * - */ -class PEAR_Exception extends Exception -{ - const OBSERVER_PRINT = -2; - const OBSERVER_TRIGGER = -4; - const OBSERVER_DIE = -8; - protected $cause; - private static $_observers = array(); - private static $_uniqueid = 0; - private $_trace; - - /** - * Supported signatures: - * - PEAR_Exception(string $message); - * - PEAR_Exception(string $message, int $code); - * - PEAR_Exception(string $message, Exception $cause); - * - PEAR_Exception(string $message, Exception $cause, int $code); - * - PEAR_Exception(string $message, PEAR_Error $cause); - * - PEAR_Exception(string $message, PEAR_Error $cause, int $code); - * - PEAR_Exception(string $message, array $causes); - * - PEAR_Exception(string $message, array $causes, int $code); - * @param string exception message - * @param int|Exception|PEAR_Error|array|null exception cause - * @param int|null exception code or null - */ - public function __construct($message, $p2 = null, $p3 = null) - { - if (is_int($p2)) { - $code = $p2; - $this->cause = null; - } elseif (is_object($p2) || is_array($p2)) { - // using is_object allows both Exception and PEAR_Error - if (is_object($p2) && !($p2 instanceof Exception)) { - if (!class_exists('PEAR_Error') || !($p2 instanceof PEAR_Error)) { - throw new PEAR_Exception('exception cause must be Exception, ' . - 'array, or PEAR_Error'); - } - } - $code = $p3; - if (is_array($p2) && isset($p2['message'])) { - // fix potential problem of passing in a single warning - $p2 = array($p2); - } - $this->cause = $p2; - } else { - $code = null; - $this->cause = null; - } - parent::__construct($message, $code); - $this->signal(); - } - - /** - * @param mixed $callback - A valid php callback, see php func is_callable() - * - A PEAR_Exception::OBSERVER_* constant - * - An array(const PEAR_Exception::OBSERVER_*, - * mixed $options) - * @param string $label The name of the observer. Use this if you want - * to remove it later with removeObserver() - */ - public static function addObserver($callback, $label = 'default') - { - self::$_observers[$label] = $callback; - } - - public static function removeObserver($label = 'default') - { - unset(self::$_observers[$label]); - } - - /** - * @return int unique identifier for an observer - */ - public static function getUniqueId() - { - return self::$_uniqueid++; - } - - private function signal() - { - foreach (self::$_observers as $func) { - if (is_callable($func)) { - call_user_func($func, $this); - continue; - } - settype($func, 'array'); - switch ($func[0]) { - case self::OBSERVER_PRINT : - $f = (isset($func[1])) ? $func[1] : '%s'; - printf($f, $this->getMessage()); - break; - case self::OBSERVER_TRIGGER : - $f = (isset($func[1])) ? $func[1] : E_USER_NOTICE; - trigger_error($this->getMessage(), $f); - break; - case self::OBSERVER_DIE : - $f = (isset($func[1])) ? $func[1] : '%s'; - die(printf($f, $this->getMessage())); - break; - default: - trigger_error('invalid observer type', E_USER_WARNING); - } - } - } - - /** - * Return specific error information that can be used for more detailed - * error messages or translation. - * - * This method may be overridden in child exception classes in order - * to add functionality not present in PEAR_Exception and is a placeholder - * to define API - * - * The returned array must be an associative array of parameter => value like so: - *
-     * array('name' => $name, 'context' => array(...))
-     * 
- * @return array - */ - public function getErrorData() - { - return array(); - } - - /** - * Returns the exception that caused this exception to be thrown - * @access public - * @return Exception|array The context of the exception - */ - public function getCause() - { - return $this->cause; - } - - /** - * Function must be public to call on caused exceptions - * @param array - */ - public function getCauseMessage(&$causes) - { - $trace = $this->getTraceSafe(); - $cause = array('class' => get_class($this), - 'message' => $this->message, - 'file' => 'unknown', - 'line' => 'unknown'); - if (isset($trace[0])) { - if (isset($trace[0]['file'])) { - $cause['file'] = $trace[0]['file']; - $cause['line'] = $trace[0]['line']; - } - } - $causes[] = $cause; - if ($this->cause instanceof PEAR_Exception) { - $this->cause->getCauseMessage($causes); - } elseif ($this->cause instanceof Exception) { - $causes[] = array('class' => get_class($this->cause), - 'message' => $this->cause->getMessage(), - 'file' => $this->cause->getFile(), - 'line' => $this->cause->getLine()); - } elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) { - $causes[] = array('class' => get_class($this->cause), - 'message' => $this->cause->getMessage(), - 'file' => 'unknown', - 'line' => 'unknown'); - } elseif (is_array($this->cause)) { - foreach ($this->cause as $cause) { - if ($cause instanceof PEAR_Exception) { - $cause->getCauseMessage($causes); - } elseif ($cause instanceof Exception) { - $causes[] = array('class' => get_class($cause), - 'message' => $cause->getMessage(), - 'file' => $cause->getFile(), - 'line' => $cause->getLine()); - } elseif (class_exists('PEAR_Error') && $cause instanceof PEAR_Error) { - $causes[] = array('class' => get_class($cause), - 'message' => $cause->getMessage(), - 'file' => 'unknown', - 'line' => 'unknown'); - } elseif (is_array($cause) && isset($cause['message'])) { - // PEAR_ErrorStack warning - $causes[] = array( - 'class' => $cause['package'], - 'message' => $cause['message'], - 'file' => isset($cause['context']['file']) ? - $cause['context']['file'] : - 'unknown', - 'line' => isset($cause['context']['line']) ? - $cause['context']['line'] : - 'unknown', - ); - } - } - } - } - - public function getTraceSafe() - { - if (!isset($this->_trace)) { - $this->_trace = $this->getTrace(); - if (empty($this->_trace)) { - $backtrace = debug_backtrace(); - $this->_trace = array($backtrace[count($backtrace)-1]); - } - } - return $this->_trace; - } - - public function getErrorClass() - { - $trace = $this->getTraceSafe(); - return $trace[0]['class']; - } - - public function getErrorMethod() - { - $trace = $this->getTraceSafe(); - return $trace[0]['function']; - } - - public function __toString() - { - if (isset($_SERVER['REQUEST_URI'])) { - return $this->toHtml(); - } - return $this->toText(); - } - - public function toHtml() - { - $trace = $this->getTraceSafe(); - $causes = array(); - $this->getCauseMessage($causes); - $html = '' . "\n"; - foreach ($causes as $i => $cause) { - $html .= '\n"; - } - $html .= '' . "\n" - . '' - . '' - . '' . "\n"; - - foreach ($trace as $k => $v) { - $html .= '' - . '' - . '' . "\n"; - } - $html .= '' - . '' - . '' . "\n" - . '
' - . str_repeat('-', $i) . ' ' . $cause['class'] . ': ' - . htmlspecialchars($cause['message'], ENT_COMPAT | ENT_HTML401, 'UTF-8', false) . ' in ' . $cause['file'] . ' ' - . 'on line ' . $cause['line'] . '' - . "
Exception trace
#FunctionLocation
' . $k . ''; - if (!empty($v['class'])) { - $html .= $v['class'] . $v['type']; - } - $html .= $v['function']; - $args = array(); - if (!empty($v['args'])) { - foreach ($v['args'] as $arg) { - if (is_null($arg)) $args[] = 'null'; - elseif (is_array($arg)) $args[] = 'Array'; - elseif (is_object($arg)) $args[] = 'Object('.get_class($arg).')'; - elseif (is_bool($arg)) $args[] = $arg ? 'true' : 'false'; - elseif (is_int($arg) || is_double($arg)) $args[] = $arg; - else { - $arg = (string)$arg; - $str = htmlspecialchars(substr($arg, 0, 16), ENT_COMPAT | ENT_HTML401, 'UTF-8', false); - if (strlen($arg) > 16) $str .= '…'; - $args[] = "'" . $str . "'"; - } - } - } - $html .= '(' . implode(', ',$args) . ')' - . '' . (isset($v['file']) ? $v['file'] : 'unknown') - . ':' . (isset($v['line']) ? $v['line'] : 'unknown') - . '
' . ($k+1) . '{main} 
'; - return $html; - } - - public function toText() - { - $causes = array(); - $this->getCauseMessage($causes); - $causeMsg = ''; - foreach ($causes as $i => $cause) { - $causeMsg .= str_repeat(' ', $i) . $cause['class'] . ': ' - . $cause['message'] . ' in ' . $cause['file'] - . ' on line ' . $cause['line'] . "\n"; - } - return $causeMsg . $this->getTraceAsString(); - } -} - -?> diff --git a/libs/PEAR.1.9/PEAR5.php b/libs/PEAR.1.9/PEAR5.php deleted file mode 100644 index 428606780..000000000 --- a/libs/PEAR.1.9/PEAR5.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @author Alexey Borzov - * @copyright 2002-2007 Richard Heyes - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Request.php,v 1.55 2007/05/18 19:20:12 avb Exp $ - * @link http://pear.php.net/package/HTTP_Request/ - */ - -/** - * PEAR and PEAR_Error classes (for error handling) - */ -require_once 'PEAR.php'; -/** - * Socket class - */ -require_once 'Net/Socket.php'; -/** - * URL handling class - */ -require_once 'Net/URL.php'; - -/**#@+ - * Constants for HTTP request methods - */ -define('HTTP_REQUEST_METHOD_GET', 'GET', true); -define('HTTP_REQUEST_METHOD_HEAD', 'HEAD', true); -define('HTTP_REQUEST_METHOD_POST', 'POST', true); -define('HTTP_REQUEST_METHOD_PUT', 'PUT', true); -define('HTTP_REQUEST_METHOD_DELETE', 'DELETE', true); -define('HTTP_REQUEST_METHOD_OPTIONS', 'OPTIONS', true); -define('HTTP_REQUEST_METHOD_TRACE', 'TRACE', true); -/**#@-*/ - -/**#@+ - * Constants for HTTP protocol versions - */ -define('HTTP_REQUEST_HTTP_VER_1_0', '1.0', true); -define('HTTP_REQUEST_HTTP_VER_1_1', '1.1', true); -/**#@-*/ - -if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { - /** - * Whether string functions are overloaded by their mbstring equivalents - */ - define('HTTP_REQUEST_MBSTRING', true); -} else { - /** - * @ignore - */ - define('HTTP_REQUEST_MBSTRING', false); -} - -/** - * Class for performing HTTP requests - * - * Simple example (fetches yahoo.com and displays it): - * - * $a = &new HTTP_Request('http://www.yahoo.com/'); - * $a->sendRequest(); - * echo $a->getResponseBody(); - * - * - * @category HTTP - * @package HTTP_Request - * @author Richard Heyes - * @author Alexey Borzov - * @version Release: 1.4.1 - */ -class HTTP_Request -{ - /**#@+ - * @access private - */ - /** - * Instance of Net_URL - * @var Net_URL - */ - var $_url; - - /** - * Type of request - * @var string - */ - var $_method; - - /** - * HTTP Version - * @var string - */ - var $_http; - - /** - * Request headers - * @var array - */ - var $_requestHeaders; - - /** - * Basic Auth Username - * @var string - */ - var $_user; - - /** - * Basic Auth Password - * @var string - */ - var $_pass; - - /** - * Socket object - * @var Net_Socket - */ - var $_sock; - - /** - * Proxy server - * @var string - */ - var $_proxy_host; - - /** - * Proxy port - * @var integer - */ - var $_proxy_port; - - /** - * Proxy username - * @var string - */ - var $_proxy_user; - - /** - * Proxy password - * @var string - */ - var $_proxy_pass; - - /** - * Post data - * @var array - */ - var $_postData; - - /** - * Request body - * @var string - */ - var $_body; - - /** - * A list of methods that MUST NOT have a request body, per RFC 2616 - * @var array - */ - var $_bodyDisallowed = array('TRACE'); - - /** - * Files to post - * @var array - */ - var $_postFiles = array(); - - /** - * Connection timeout. - * @var float - */ - var $_timeout; - - /** - * HTTP_Response object - * @var HTTP_Response - */ - var $_response; - - /** - * Whether to allow redirects - * @var boolean - */ - var $_allowRedirects; - - /** - * Maximum redirects allowed - * @var integer - */ - var $_maxRedirects; - - /** - * Current number of redirects - * @var integer - */ - var $_redirects; - - /** - * Whether to append brackets [] to array variables - * @var bool - */ - var $_useBrackets = true; - - /** - * Attached listeners - * @var array - */ - var $_listeners = array(); - - /** - * Whether to save response body in response object property - * @var bool - */ - var $_saveBody = true; - - /** - * Timeout for reading from socket (array(seconds, microseconds)) - * @var array - */ - var $_readTimeout = null; - - /** - * Options to pass to Net_Socket::connect. See stream_context_create - * @var array - */ - var $_socketOptions = null; - /**#@-*/ - - /** - * Constructor - * - * Sets up the object - * @param string The url to fetch/access - * @param array Associative array of parameters which can have the following keys: - *
    - *
  • method - Method to use, GET, POST etc (string)
  • - *
  • http - HTTP Version to use, 1.0 or 1.1 (string)
  • - *
  • user - Basic Auth username (string)
  • - *
  • pass - Basic Auth password (string)
  • - *
  • proxy_host - Proxy server host (string)
  • - *
  • proxy_port - Proxy server port (integer)
  • - *
  • proxy_user - Proxy auth username (string)
  • - *
  • proxy_pass - Proxy auth password (string)
  • - *
  • timeout - Connection timeout in seconds (float)
  • - *
  • allowRedirects - Whether to follow redirects or not (bool)
  • - *
  • maxRedirects - Max number of redirects to follow (integer)
  • - *
  • useBrackets - Whether to append [] to array variable names (bool)
  • - *
  • saveBody - Whether to save response body in response object property (bool)
  • - *
  • readTimeout - Timeout for reading / writing data over the socket (array (seconds, microseconds))
  • - *
  • socketOptions - Options to pass to Net_Socket object (array)
  • - *
- * @access public - */ - function HTTP_Request($url = '', $params = array()) - { - $this->_method = HTTP_REQUEST_METHOD_GET; - $this->_http = HTTP_REQUEST_HTTP_VER_1_1; - $this->_requestHeaders = array(); - $this->_postData = array(); - $this->_body = null; - - $this->_user = null; - $this->_pass = null; - - $this->_proxy_host = null; - $this->_proxy_port = null; - $this->_proxy_user = null; - $this->_proxy_pass = null; - - $this->_allowRedirects = false; - $this->_maxRedirects = 3; - $this->_redirects = 0; - - $this->_timeout = null; - $this->_response = null; - - foreach ($params as $key => $value) { - $this->{'_' . $key} = $value; - } - - if (!empty($url)) { - $this->setURL($url); - } - - // Default useragent - $this->addHeader('User-Agent', 'PEAR HTTP_Request class ( http://pear.php.net/ )'); - - // We don't do keep-alives by default - $this->addHeader('Connection', 'close'); - - // Basic authentication - if (!empty($this->_user)) { - $this->addHeader('Authorization', 'Basic ' . base64_encode($this->_user . ':' . $this->_pass)); - } - - // Proxy authentication (see bug #5913) - if (!empty($this->_proxy_user)) { - $this->addHeader('Proxy-Authorization', 'Basic ' . base64_encode($this->_proxy_user . ':' . $this->_proxy_pass)); - } - - // Use gzip encoding if possible - if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && extension_loaded('zlib')) { - $this->addHeader('Accept-Encoding', 'gzip'); - } - } - - /** - * Generates a Host header for HTTP/1.1 requests - * - * @access private - * @return string - */ - function _generateHostHeader() - { - if ($this->_url->port != 80 AND strcasecmp($this->_url->protocol, 'http') == 0) { - $host = $this->_url->host . ':' . $this->_url->port; - - } elseif ($this->_url->port != 443 AND strcasecmp($this->_url->protocol, 'https') == 0) { - $host = $this->_url->host . ':' . $this->_url->port; - - } elseif ($this->_url->port == 443 AND strcasecmp($this->_url->protocol, 'https') == 0 AND strpos($this->_url->url, ':443') !== false) { - $host = $this->_url->host . ':' . $this->_url->port; - - } else { - $host = $this->_url->host; - } - - return $host; - } - - /** - * Resets the object to its initial state (DEPRECATED). - * Takes the same parameters as the constructor. - * - * @param string $url The url to be requested - * @param array $params Associative array of parameters - * (see constructor for details) - * @access public - * @deprecated deprecated since 1.2, call the constructor if this is necessary - */ - function reset($url, $params = array()) - { - $this->HTTP_Request($url, $params); - } - - /** - * Sets the URL to be requested - * - * @param string The url to be requested - * @access public - */ - function setURL($url) - { - $this->_url = &new Net_URL($url, $this->_useBrackets); - - if (!empty($this->_url->user) || !empty($this->_url->pass)) { - $this->setBasicAuth($this->_url->user, $this->_url->pass); - } - - if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http) { - $this->addHeader('Host', $this->_generateHostHeader()); - } - - // set '/' instead of empty path rather than check later (see bug #8662) - if (empty($this->_url->path)) { - $this->_url->path = '/'; - } - } - - /** - * Returns the current request URL - * - * @return string Current request URL - * @access public - */ - function getUrl() - { - return empty($this->_url)? '': $this->_url->getUrl(); - } - - /** - * Sets a proxy to be used - * - * @param string Proxy host - * @param int Proxy port - * @param string Proxy username - * @param string Proxy password - * @access public - */ - function setProxy($host, $port = 8080, $user = null, $pass = null) - { - $this->_proxy_host = $host; - $this->_proxy_port = $port; - $this->_proxy_user = $user; - $this->_proxy_pass = $pass; - - if (!empty($user)) { - $this->addHeader('Proxy-Authorization', 'Basic ' . base64_encode($user . ':' . $pass)); - } - } - - /** - * Sets basic authentication parameters - * - * @param string Username - * @param string Password - */ - function setBasicAuth($user, $pass) - { - $this->_user = $user; - $this->_pass = $pass; - - $this->addHeader('Authorization', 'Basic ' . base64_encode($user . ':' . $pass)); - } - - /** - * Sets the method to be used, GET, POST etc. - * - * @param string Method to use. Use the defined constants for this - * @access public - */ - function setMethod($method) - { - $this->_method = $method; - } - - /** - * Sets the HTTP version to use, 1.0 or 1.1 - * - * @param string Version to use. Use the defined constants for this - * @access public - */ - function setHttpVer($http) - { - $this->_http = $http; - } - - /** - * Adds a request header - * - * @param string Header name - * @param string Header value - * @access public - */ - function addHeader($name, $value) - { - $this->_requestHeaders[strtolower($name)] = $value; - } - - /** - * Removes a request header - * - * @param string Header name to remove - * @access public - */ - function removeHeader($name) - { - if (isset($this->_requestHeaders[strtolower($name)])) { - unset($this->_requestHeaders[strtolower($name)]); - } - } - - /** - * Adds a querystring parameter - * - * @param string Querystring parameter name - * @param string Querystring parameter value - * @param bool Whether the value is already urlencoded or not, default = not - * @access public - */ - function addQueryString($name, $value, $preencoded = false) - { - $this->_url->addQueryString($name, $value, $preencoded); - } - - /** - * Sets the querystring to literally what you supply - * - * @param string The querystring data. Should be of the format foo=bar&x=y etc - * @param bool Whether data is already urlencoded or not, default = already encoded - * @access public - */ - function addRawQueryString($querystring, $preencoded = true) - { - $this->_url->addRawQueryString($querystring, $preencoded); - } - - /** - * Adds postdata items - * - * @param string Post data name - * @param string Post data value - * @param bool Whether data is already urlencoded or not, default = not - * @access public - */ - function addPostData($name, $value, $preencoded = false) - { - if ($preencoded) { - $this->_postData[$name] = $value; - } else { - $this->_postData[$name] = $this->_arrayMapRecursive('urlencode', $value); - } - } - - /** - * Recursively applies the callback function to the value - * - * @param mixed Callback function - * @param mixed Value to process - * @access private - * @return mixed Processed value - */ - function _arrayMapRecursive($callback, $value) - { - if (!is_array($value)) { - return call_user_func($callback, $value); - } else { - $map = array(); - foreach ($value as $k => $v) { - $map[$k] = $this->_arrayMapRecursive($callback, $v); - } - return $map; - } - } - - /** - * Adds a file to upload - * - * This also changes content-type to 'multipart/form-data' for proper upload - * - * @access public - * @param string name of file-upload field - * @param mixed file name(s) - * @param mixed content-type(s) of file(s) being uploaded - * @return bool true on success - * @throws PEAR_Error - */ - function addFile($inputName, $fileName, $contentType = 'application/octet-stream') - { - if (!is_array($fileName) && !is_readable($fileName)) { - return PEAR::raiseError("File '{$fileName}' is not readable"); - } elseif (is_array($fileName)) { - foreach ($fileName as $name) { - if (!is_readable($name)) { - return PEAR::raiseError("File '{$name}' is not readable"); - } - } - } - $this->addHeader('Content-Type', 'multipart/form-data'); - $this->_postFiles[$inputName] = array( - 'name' => $fileName, - 'type' => $contentType - ); - return true; - } - - /** - * Adds raw postdata (DEPRECATED) - * - * @param string The data - * @param bool Whether data is preencoded or not, default = already encoded - * @access public - * @deprecated deprecated since 1.3.0, method setBody() should be used instead - */ - function addRawPostData($postdata, $preencoded = true) - { - $this->_body = $preencoded ? $postdata : urlencode($postdata); - } - - /** - * Sets the request body (for POST, PUT and similar requests) - * - * @param string Request body - * @access public - */ - function setBody($body) - { - $this->_body = $body; - } - - /** - * Clears any postdata that has been added (DEPRECATED). - * - * Useful for multiple request scenarios. - * - * @access public - * @deprecated deprecated since 1.2 - */ - function clearPostData() - { - $this->_postData = null; - } - - /** - * Appends a cookie to "Cookie:" header - * - * @param string $name cookie name - * @param string $value cookie value - * @access public - */ - function addCookie($name, $value) - { - $cookies = isset($this->_requestHeaders['cookie']) ? $this->_requestHeaders['cookie']. '; ' : ''; - $this->addHeader('Cookie', $cookies . $name . '=' . $value); - } - - /** - * Clears any cookies that have been added (DEPRECATED). - * - * Useful for multiple request scenarios - * - * @access public - * @deprecated deprecated since 1.2 - */ - function clearCookies() - { - $this->removeHeader('Cookie'); - } - - /** - * Sends the request - * - * @access public - * @param bool Whether to store response body in Response object property, - * set this to false if downloading a LARGE file and using a Listener - * @return mixed PEAR error on error, true otherwise - */ - function sendRequest($saveBody = true) - { - if (!is_a($this->_url, 'Net_URL')) { - return PEAR::raiseError('No URL given.'); - } - - $host = isset($this->_proxy_host) ? $this->_proxy_host : $this->_url->host; - $port = isset($this->_proxy_port) ? $this->_proxy_port : $this->_url->port; - - // 4.3.0 supports SSL connections using OpenSSL. The function test determines - // we running on at least 4.3.0 - if (strcasecmp($this->_url->protocol, 'https') == 0 AND function_exists('file_get_contents') AND extension_loaded('openssl')) { - if (isset($this->_proxy_host)) { - return PEAR::raiseError('HTTPS proxies are not supported.'); - } - $host = 'ssl://' . $host; - } - - // magic quotes may fuck up file uploads and chunked response processing - $magicQuotes = ini_get('magic_quotes_runtime'); - ini_set('magic_quotes_runtime', false); - - // RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive - // connection token to a proxy server... - if (isset($this->_proxy_host) && !empty($this->_requestHeaders['connection']) && - 'Keep-Alive' == $this->_requestHeaders['connection']) - { - $this->removeHeader('connection'); - } - - $keepAlive = (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && empty($this->_requestHeaders['connection'])) || - (!empty($this->_requestHeaders['connection']) && 'Keep-Alive' == $this->_requestHeaders['connection']); - $sockets = &PEAR::getStaticProperty('HTTP_Request', 'sockets'); - $sockKey = $host . ':' . $port; - unset($this->_sock); - - // There is a connected socket in the "static" property? - if ($keepAlive && !empty($sockets[$sockKey]) && - !empty($sockets[$sockKey]->fp)) - { - $this->_sock =& $sockets[$sockKey]; - $err = null; - } else { - $this->_notify('connect'); - $this->_sock =& new Net_Socket(); - $err = $this->_sock->connect($host, $port, null, $this->_timeout, $this->_socketOptions); - } - PEAR::isError($err) or $err = $this->_sock->write($this->_buildRequest()); - - if (!PEAR::isError($err)) { - if (!empty($this->_readTimeout)) { - $this->_sock->setTimeout($this->_readTimeout[0], $this->_readTimeout[1]); - } - - $this->_notify('sentRequest'); - - // Read the response - $this->_response = &new HTTP_Response($this->_sock, $this->_listeners); - $err = $this->_response->process( - $this->_saveBody && $saveBody, - HTTP_REQUEST_METHOD_HEAD != $this->_method - ); - - if ($keepAlive) { - $keepAlive = (isset($this->_response->_headers['content-length']) - || (isset($this->_response->_headers['transfer-encoding']) - && strtolower($this->_response->_headers['transfer-encoding']) == 'chunked')); - if ($keepAlive) { - if (isset($this->_response->_headers['connection'])) { - $keepAlive = strtolower($this->_response->_headers['connection']) == 'keep-alive'; - } else { - $keepAlive = 'HTTP/'.HTTP_REQUEST_HTTP_VER_1_1 == $this->_response->_protocol; - } - } - } - } - - ini_set('magic_quotes_runtime', $magicQuotes); - - if (PEAR::isError($err)) { - return $err; - } - - if (!$keepAlive) { - $this->disconnect(); - // Store the connected socket in "static" property - } elseif (empty($sockets[$sockKey]) || empty($sockets[$sockKey]->fp)) { - $sockets[$sockKey] =& $this->_sock; - } - - // Check for redirection - if ( $this->_allowRedirects - AND $this->_redirects <= $this->_maxRedirects - AND $this->getResponseCode() > 300 - AND $this->getResponseCode() < 399 - AND !empty($this->_response->_headers['location'])) { - - - $redirect = $this->_response->_headers['location']; - - // Absolute URL - if (preg_match('/^https?:\/\//i', $redirect)) { - $this->_url = &new Net_URL($redirect); - $this->addHeader('Host', $this->_generateHostHeader()); - // Absolute path - } elseif ($redirect{0} == '/') { - $this->_url->path = $redirect; - - // Relative path - } elseif (substr($redirect, 0, 3) == '../' OR substr($redirect, 0, 2) == './') { - if (substr($this->_url->path, -1) == '/') { - $redirect = $this->_url->path . $redirect; - } else { - $redirect = dirname($this->_url->path) . '/' . $redirect; - } - $redirect = Net_URL::resolvePath($redirect); - $this->_url->path = $redirect; - - // Filename, no path - } else { - if (substr($this->_url->path, -1) == '/') { - $redirect = $this->_url->path . $redirect; - } else { - $redirect = dirname($this->_url->path) . '/' . $redirect; - } - $this->_url->path = $redirect; - } - - $this->_redirects++; - return $this->sendRequest($saveBody); - - // Too many redirects - } elseif ($this->_allowRedirects AND $this->_redirects > $this->_maxRedirects) { - return PEAR::raiseError('Too many redirects'); - } - - return true; - } - - /** - * Disconnect the socket, if connected. Only useful if using Keep-Alive. - * - * @access public - */ - function disconnect() - { - if (!empty($this->_sock) && !empty($this->_sock->fp)) { - $this->_notify('disconnect'); - $this->_sock->disconnect(); - } - } - - /** - * Returns the response code - * - * @access public - * @return mixed Response code, false if not set - */ - function getResponseCode() - { - return isset($this->_response->_code) ? $this->_response->_code : false; - } - - /** - * Returns either the named header or all if no name given - * - * @access public - * @param string The header name to return, do not set to get all headers - * @return mixed either the value of $headername (false if header is not present) - * or an array of all headers - */ - function getResponseHeader($headername = null) - { - if (!isset($headername)) { - return isset($this->_response->_headers)? $this->_response->_headers: array(); - } else { - $headername = strtolower($headername); - return isset($this->_response->_headers[$headername]) ? $this->_response->_headers[$headername] : false; - } - } - - /** - * Returns the body of the response - * - * @access public - * @return mixed response body, false if not set - */ - function getResponseBody() - { - return isset($this->_response->_body) ? $this->_response->_body : false; - } - - /** - * Returns cookies set in response - * - * @access public - * @return mixed array of response cookies, false if none are present - */ - function getResponseCookies() - { - return isset($this->_response->_cookies) ? $this->_response->_cookies : false; - } - - /** - * Builds the request string - * - * @access private - * @return string The request string - */ - function _buildRequest() - { - $separator = ini_get('arg_separator.output'); - ini_set('arg_separator.output', '&'); - $querystring = ($querystring = $this->_url->getQueryString()) ? '?' . $querystring : ''; - ini_set('arg_separator.output', $separator); - - $host = isset($this->_proxy_host) ? $this->_url->protocol . '://' . $this->_url->host : ''; - $port = (isset($this->_proxy_host) AND $this->_url->port != 80) ? ':' . $this->_url->port : ''; - $path = $this->_url->path . $querystring; - $url = $host . $port . $path; - - $request = $this->_method . ' ' . $url . ' HTTP/' . $this->_http . "\r\n"; - - if (in_array($this->_method, $this->_bodyDisallowed) || - (empty($this->_body) && (HTTP_REQUEST_METHOD_POST != $this->_method || - (empty($this->_postData) && empty($this->_postFiles))))) - { - $this->removeHeader('Content-Type'); - } else { - if (empty($this->_requestHeaders['content-type'])) { - // Add default content-type - $this->addHeader('Content-Type', 'application/x-www-form-urlencoded'); - } elseif ('multipart/form-data' == $this->_requestHeaders['content-type']) { - $boundary = 'HTTP_Request_' . md5(uniqid('request') . microtime()); - $this->addHeader('Content-Type', 'multipart/form-data; boundary=' . $boundary); - } - } - - // Request Headers - if (!empty($this->_requestHeaders)) { - foreach ($this->_requestHeaders as $name => $value) { - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - $request .= $canonicalName . ': ' . $value . "\r\n"; - } - } - - // No post data or wrong method, so simply add a final CRLF - if (in_array($this->_method, $this->_bodyDisallowed) || - (HTTP_REQUEST_METHOD_POST != $this->_method && empty($this->_body))) { - - $request .= "\r\n"; - - // Post data if it's an array - } elseif (HTTP_REQUEST_METHOD_POST == $this->_method && - (!empty($this->_postData) || !empty($this->_postFiles))) { - - // "normal" POST request - if (!isset($boundary)) { - $postdata = implode('&', array_map( - create_function('$a', 'return $a[0] . \'=\' . $a[1];'), - $this->_flattenArray('', $this->_postData) - )); - - // multipart request, probably with file uploads - } else { - $postdata = ''; - if (!empty($this->_postData)) { - $flatData = $this->_flattenArray('', $this->_postData); - foreach ($flatData as $item) { - $postdata .= '--' . $boundary . "\r\n"; - $postdata .= 'Content-Disposition: form-data; name="' . $item[0] . '"'; - $postdata .= "\r\n\r\n" . urldecode($item[1]) . "\r\n"; - } - } - foreach ($this->_postFiles as $name => $value) { - if (is_array($value['name'])) { - $varname = $name . ($this->_useBrackets? '[]': ''); - } else { - $varname = $name; - $value['name'] = array($value['name']); - } - foreach ($value['name'] as $key => $filename) { - $fp = fopen($filename, 'r'); - $data = fread($fp, filesize($filename)); - fclose($fp); - $basename = basename($filename); - $type = is_array($value['type'])? @$value['type'][$key]: $value['type']; - - $postdata .= '--' . $boundary . "\r\n"; - $postdata .= 'Content-Disposition: form-data; name="' . $varname . '"; filename="' . $basename . '"'; - $postdata .= "\r\nContent-Type: " . $type; - $postdata .= "\r\n\r\n" . $data . "\r\n"; - } - } - $postdata .= '--' . $boundary . "--\r\n"; - } - $request .= 'Content-Length: ' . - (HTTP_REQUEST_MBSTRING? mb_strlen($postdata, 'iso-8859-1'): strlen($postdata)) . - "\r\n\r\n"; - $request .= $postdata; - - // Explicitly set request body - } elseif (!empty($this->_body)) { - - $request .= 'Content-Length: ' . - (HTTP_REQUEST_MBSTRING? mb_strlen($this->_body, 'iso-8859-1'): strlen($this->_body)) . - "\r\n\r\n"; - $request .= $this->_body; - } - - return $request; - } - - /** - * Helper function to change the (probably multidimensional) associative array - * into the simple one. - * - * @param string name for item - * @param mixed item's values - * @return array array with the following items: array('item name', 'item value'); - * @access private - */ - function _flattenArray($name, $values) - { - if (!is_array($values)) { - return array(array($name, $values)); - } else { - $ret = array(); - foreach ($values as $k => $v) { - if (empty($name)) { - $newName = $k; - } elseif ($this->_useBrackets) { - $newName = $name . '[' . $k . ']'; - } else { - $newName = $name; - } - $ret = array_merge($ret, $this->_flattenArray($newName, $v)); - } - return $ret; - } - } - - - /** - * Adds a Listener to the list of listeners that are notified of - * the object's events - * - * Events sent by HTTP_Request object - * - 'connect': on connection to server - * - 'sentRequest': after the request was sent - * - 'disconnect': on disconnection from server - * - * Events sent by HTTP_Response object - * - 'gotHeaders': after receiving response headers (headers are passed in $data) - * - 'tick': on receiving a part of response body (the part is passed in $data) - * - 'gzTick': on receiving a gzip-encoded part of response body (ditto) - * - 'gotBody': after receiving the response body (passes the decoded body in $data if it was gzipped) - * - * @param HTTP_Request_Listener listener to attach - * @return boolean whether the listener was successfully attached - * @access public - */ - function attach(&$listener) - { - if (!is_a($listener, 'HTTP_Request_Listener')) { - return false; - } - $this->_listeners[$listener->getId()] =& $listener; - return true; - } - - - /** - * Removes a Listener from the list of listeners - * - * @param HTTP_Request_Listener listener to detach - * @return boolean whether the listener was successfully detached - * @access public - */ - function detach(&$listener) - { - if (!is_a($listener, 'HTTP_Request_Listener') || - !isset($this->_listeners[$listener->getId()])) { - return false; - } - unset($this->_listeners[$listener->getId()]); - return true; - } - - - /** - * Notifies all registered listeners of an event. - * - * @param string Event name - * @param mixed Additional data - * @access private - * @see HTTP_Request::attach() - */ - function _notify($event, $data = null) - { - foreach (array_keys($this->_listeners) as $id) { - $this->_listeners[$id]->update($this, $event, $data); - } - } -} - - -/** - * Response class to complement the Request class - * - * @category HTTP - * @package HTTP_Request - * @author Richard Heyes - * @author Alexey Borzov - * @version Release: 1.4.1 - */ -class HTTP_Response -{ - /** - * Socket object - * @var Net_Socket - */ - var $_sock; - - /** - * Protocol - * @var string - */ - var $_protocol; - - /** - * Return code - * @var string - */ - var $_code; - - /** - * Response headers - * @var array - */ - var $_headers; - - /** - * Cookies set in response - * @var array - */ - var $_cookies; - - /** - * Response body - * @var string - */ - var $_body = ''; - - /** - * Used by _readChunked(): remaining length of the current chunk - * @var string - */ - var $_chunkLength = 0; - - /** - * Attached listeners - * @var array - */ - var $_listeners = array(); - - /** - * Bytes left to read from message-body - * @var null|int - */ - var $_toRead; - - /** - * Constructor - * - * @param Net_Socket socket to read the response from - * @param array listeners attached to request - */ - function HTTP_Response(&$sock, &$listeners) - { - $this->_sock =& $sock; - $this->_listeners =& $listeners; - } - - - /** - * Processes a HTTP response - * - * This extracts response code, headers, cookies and decodes body if it - * was encoded in some way - * - * @access public - * @param bool Whether to store response body in object property, set - * this to false if downloading a LARGE file and using a Listener. - * This is assumed to be true if body is gzip-encoded. - * @param bool Whether the response can actually have a message-body. - * Will be set to false for HEAD requests. - * @throws PEAR_Error - * @return mixed true on success, PEAR_Error in case of malformed response - */ - function process($saveBody = true, $canHaveBody = true) - { - do { - $line = $this->_sock->readLine(); - if (sscanf($line, 'HTTP/%s %s', $http_version, $returncode) != 2) { - return PEAR::raiseError('Malformed response.'); - } else { - $this->_protocol = 'HTTP/' . $http_version; - $this->_code = intval($returncode); - } - while ('' !== ($header = $this->_sock->readLine())) { - $this->_processHeader($header); - } - } while (100 == $this->_code); - - $this->_notify('gotHeaders', $this->_headers); - - // RFC 2616, section 4.4: - // 1. Any response message which "MUST NOT" include a message-body ... - // is always terminated by the first empty line after the header fields - // 3. ... If a message is received with both a - // Transfer-Encoding header field and a Content-Length header field, - // the latter MUST be ignored. - $canHaveBody = $canHaveBody && $this->_code >= 200 && - $this->_code != 204 && $this->_code != 304; - - // If response body is present, read it and decode - $chunked = isset($this->_headers['transfer-encoding']) && ('chunked' == $this->_headers['transfer-encoding']); - $gzipped = isset($this->_headers['content-encoding']) && ('gzip' == $this->_headers['content-encoding']); - $hasBody = false; - if ($canHaveBody && ($chunked || !isset($this->_headers['content-length']) || - 0 != $this->_headers['content-length'])) - { - if ($chunked || !isset($this->_headers['content-length'])) { - $this->_toRead = null; - } else { - $this->_toRead = $this->_headers['content-length']; - } - while (!$this->_sock->eof() && (is_null($this->_toRead) || 0 < $this->_toRead)) { - if ($chunked) { - $data = $this->_readChunked(); - } elseif (is_null($this->_toRead)) { - $data = $this->_sock->read(4096); - } else { - $data = $this->_sock->read(min(4096, $this->_toRead)); - $this->_toRead -= HTTP_REQUEST_MBSTRING? mb_strlen($data, 'iso-8859-1'): strlen($data); - } - if ('' == $data) { - break; - } else { - $hasBody = true; - if ($saveBody || $gzipped) { - $this->_body .= $data; - } - $this->_notify($gzipped? 'gzTick': 'tick', $data); - } - } - } - - if ($hasBody) { - // Uncompress the body if needed - if ($gzipped) { - $body = $this->_decodeGzip($this->_body); - if (PEAR::isError($body)) { - return $body; - } - $this->_body = $body; - $this->_notify('gotBody', $this->_body); - } else { - $this->_notify('gotBody'); - } - } - return true; - } - - - /** - * Processes the response header - * - * @access private - * @param string HTTP header - */ - function _processHeader($header) - { - if (false === strpos($header, ':')) { - return; - } - list($headername, $headervalue) = explode(':', $header, 2); - $headername = strtolower($headername); - $headervalue = ltrim($headervalue); - - if ('set-cookie' != $headername) { - if (isset($this->_headers[$headername])) { - $this->_headers[$headername] .= ',' . $headervalue; - } else { - $this->_headers[$headername] = $headervalue; - } - } else { - $this->_parseCookie($headervalue); - } - } - - - /** - * Parse a Set-Cookie header to fill $_cookies array - * - * @access private - * @param string value of Set-Cookie header - */ - function _parseCookie($headervalue) - { - $cookie = array( - 'expires' => null, - 'domain' => null, - 'path' => null, - 'secure' => false - ); - - // Only a name=value pair - if (!strpos($headervalue, ';')) { - $pos = strpos($headervalue, '='); - $cookie['name'] = trim(substr($headervalue, 0, $pos)); - $cookie['value'] = trim(substr($headervalue, $pos + 1)); - - // Some optional parameters are supplied - } else { - $elements = explode(';', $headervalue); - $pos = strpos($elements[0], '='); - $cookie['name'] = trim(substr($elements[0], 0, $pos)); - $cookie['value'] = trim(substr($elements[0], $pos + 1)); - - for ($i = 1; $i < count($elements); $i++) { - if (false === strpos($elements[$i], '=')) { - $elName = trim($elements[$i]); - $elValue = null; - } else { - list ($elName, $elValue) = array_map('trim', explode('=', $elements[$i])); - } - $elName = strtolower($elName); - if ('secure' == $elName) { - $cookie['secure'] = true; - } elseif ('expires' == $elName) { - $cookie['expires'] = str_replace('"', '', $elValue); - } elseif ('path' == $elName || 'domain' == $elName) { - $cookie[$elName] = urldecode($elValue); - } else { - $cookie[$elName] = $elValue; - } - } - } - $this->_cookies[] = $cookie; - } - - - /** - * Read a part of response body encoded with chunked Transfer-Encoding - * - * @access private - * @return string - */ - function _readChunked() - { - // at start of the next chunk? - if (0 == $this->_chunkLength) { - $line = $this->_sock->readLine(); - if (preg_match('/^([0-9a-f]+)/i', $line, $matches)) { - $this->_chunkLength = hexdec($matches[1]); - // Chunk with zero length indicates the end - if (0 == $this->_chunkLength) { - $this->_sock->readLine(); // make this an eof() - return ''; - } - } else { - return ''; - } - } - $data = $this->_sock->read($this->_chunkLength); - $this->_chunkLength -= HTTP_REQUEST_MBSTRING? mb_strlen($data, 'iso-8859-1'): strlen($data); - if (0 == $this->_chunkLength) { - $this->_sock->readLine(); // Trailing CRLF - } - return $data; - } - - - /** - * Notifies all registered listeners of an event. - * - * @param string Event name - * @param mixed Additional data - * @access private - * @see HTTP_Request::_notify() - */ - function _notify($event, $data = null) - { - foreach (array_keys($this->_listeners) as $id) { - $this->_listeners[$id]->update($this, $event, $data); - } - } - - - /** - * Decodes the message-body encoded by gzip - * - * The real decoding work is done by gzinflate() built-in function, this - * method only parses the header and checks data for compliance with - * RFC 1952 - * - * @access private - * @param string gzip-encoded data - * @return string decoded data - */ - function _decodeGzip($data) - { - if (HTTP_REQUEST_MBSTRING) { - $oldEncoding = mb_internal_encoding(); - mb_internal_encoding('iso-8859-1'); - } - $length = strlen($data); - // If it doesn't look like gzip-encoded data, don't bother - if (18 > $length || strcmp(substr($data, 0, 2), "\x1f\x8b")) { - return $data; - } - $method = ord(substr($data, 2, 1)); - if (8 != $method) { - return PEAR::raiseError('_decodeGzip(): unknown compression method'); - } - $flags = ord(substr($data, 3, 1)); - if ($flags & 224) { - return PEAR::raiseError('_decodeGzip(): reserved bits are set'); - } - - // header is 10 bytes minimum. may be longer, though. - $headerLength = 10; - // extra fields, need to skip 'em - if ($flags & 4) { - if ($length - $headerLength - 2 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short'); - } - $extraLength = unpack('v', substr($data, 10, 2)); - if ($length - $headerLength - 2 - $extraLength[1] < 8) { - return PEAR::raiseError('_decodeGzip(): data too short'); - } - $headerLength += $extraLength[1] + 2; - } - // file name, need to skip that - if ($flags & 8) { - if ($length - $headerLength - 1 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short'); - } - $filenameLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $filenameLength || $length - $headerLength - $filenameLength - 1 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short'); - } - $headerLength += $filenameLength + 1; - } - // comment, need to skip that also - if ($flags & 16) { - if ($length - $headerLength - 1 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short'); - } - $commentLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $commentLength || $length - $headerLength - $commentLength - 1 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short'); - } - $headerLength += $commentLength + 1; - } - // have a CRC for header. let's check - if ($flags & 1) { - if ($length - $headerLength - 2 < 8) { - return PEAR::raiseError('_decodeGzip(): data too short'); - } - $crcReal = 0xffff & crc32(substr($data, 0, $headerLength)); - $crcStored = unpack('v', substr($data, $headerLength, 2)); - if ($crcReal != $crcStored[1]) { - return PEAR::raiseError('_decodeGzip(): header CRC check failed'); - } - $headerLength += 2; - } - // unpacked data CRC and size at the end of encoded data - $tmp = unpack('V2', substr($data, -8)); - $dataCrc = $tmp[1]; - $dataSize = $tmp[2]; - - // finally, call the gzinflate() function - $unpacked = @gzinflate(substr($data, $headerLength, -8), $dataSize); - if (false === $unpacked) { - return PEAR::raiseError('_decodeGzip(): gzinflate() call failed'); - } elseif ($dataSize != strlen($unpacked)) { - return PEAR::raiseError('_decodeGzip(): data size check failed'); - } elseif ((0xffffffff & $dataCrc) != (0xffffffff & crc32($unpacked))) { - return PEAR::raiseError('_decodeGzip(): data CRC check failed'); - } - if (HTTP_REQUEST_MBSTRING) { - mb_internal_encoding($oldEncoding); - } - return $unpacked; - } -} // End class HTTP_Response -?> diff --git a/libs/PEAR/HTTP/Request/Listener.php b/libs/PEAR/HTTP/Request/Listener.php deleted file mode 100644 index 928ac5e68..000000000 --- a/libs/PEAR/HTTP/Request/Listener.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @copyright 2002-2007 Richard Heyes - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Listener.php,v 1.3 2007/05/18 10:33:31 avb Exp $ - * @link http://pear.php.net/package/HTTP_Request/ - */ - -/** - * Listener for HTTP_Request and HTTP_Response objects - * - * This class implements the Observer part of a Subject-Observer - * design pattern. - * - * @category HTTP - * @package HTTP_Request - * @author Alexey Borzov - * @version Release: 1.4.1 - */ -class HTTP_Request_Listener -{ - /** - * A listener's identifier - * @var string - */ - var $_id; - - /** - * Constructor, sets the object's identifier - * - * @access public - */ - function HTTP_Request_Listener() - { - $this->_id = md5(uniqid('http_request_', 1)); - } - - - /** - * Returns the listener's identifier - * - * @access public - * @return string - */ - function getId() - { - return $this->_id; - } - - - /** - * This method is called when Listener is notified of an event - * - * @access public - * @param object an object the listener is attached to - * @param string Event name - * @param mixed Additional data - * @abstract - */ - function update(&$subject, $event, $data = null) - { - echo "Notified of event: '$event'\n"; - if (null !== $data) { - echo "Additional data: "; - var_dump($data); - } - } -} -?> diff --git a/libs/PEAR/Net/Socket.php b/libs/PEAR/Net/Socket.php deleted file mode 100644 index 7c4ff1d4e..000000000 --- a/libs/PEAR/Net/Socket.php +++ /dev/null @@ -1,528 +0,0 @@ - | -// | Chuck Hagenbuch | -// +----------------------------------------------------------------------+ -// -// $Id: Socket.php,v 1.24 2005/02/03 20:40:16 chagenbu Exp $ - -require_once 'PEAR.php'; - -define('NET_SOCKET_READ', 1); -define('NET_SOCKET_WRITE', 2); -define('NET_SOCKET_ERROR', 3); - -/** - * Generalized Socket class. - * - * @version 1.1 - * @author Stig Bakken - * @author Chuck Hagenbuch - */ -class Net_Socket extends PEAR { - - /** - * Socket file pointer. - * @var resource $fp - */ - var $fp = null; - - /** - * Whether the socket is blocking. Defaults to true. - * @var boolean $blocking - */ - var $blocking = true; - - /** - * Whether the socket is persistent. Defaults to false. - * @var boolean $persistent - */ - var $persistent = false; - - /** - * The IP address to connect to. - * @var string $addr - */ - var $addr = ''; - - /** - * The port number to connect to. - * @var integer $port - */ - var $port = 0; - - /** - * Number of seconds to wait on socket connections before assuming - * there's no more data. Defaults to no timeout. - * @var integer $timeout - */ - var $timeout = false; - - /** - * Number of bytes to read at a time in readLine() and - * readAll(). Defaults to 2048. - * @var integer $lineLength - */ - var $lineLength = 2048; - - /** - * Connect to the specified port. If called when the socket is - * already connected, it disconnects and connects again. - * - * @param string $addr IP address or host name. - * @param integer $port TCP port number. - * @param boolean $persistent (optional) Whether the connection is - * persistent (kept open between requests - * by the web server). - * @param integer $timeout (optional) How long to wait for data. - * @param array $options See options for stream_context_create. - * - * @access public - * - * @return boolean | PEAR_Error True on success or a PEAR_Error on failure. - */ - function connect($addr, $port = 0, $persistent = null, $timeout = null, $options = null) - { - if (is_resource($this->fp)) { - @fclose($this->fp); - $this->fp = null; - } - - if (!$addr) { - return $this->raiseError('$addr cannot be empty'); - } elseif (strspn($addr, '.0123456789') == strlen($addr) || - strstr($addr, '/') !== false) { - $this->addr = $addr; - } else { - $this->addr = @gethostbyname($addr); - } - - $this->port = $port % 65536; - - if ($persistent !== null) { - $this->persistent = $persistent; - } - - if ($timeout !== null) { - $this->timeout = $timeout; - } - - $openfunc = $this->persistent ? 'pfsockopen' : 'fsockopen'; - $errno = 0; - $errstr = ''; - if ($options && function_exists('stream_context_create')) { - if ($this->timeout) { - $timeout = $this->timeout; - } else { - $timeout = 0; - } - $context = stream_context_create($options); - $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $timeout, $context); - } else { - if ($this->timeout) { - $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $this->timeout); - } else { - $fp = @$openfunc($this->addr, $this->port, $errno, $errstr); - } - } - - if (!$fp) { - return $this->raiseError($errstr, $errno); - } - - $this->fp = $fp; - - return $this->setBlocking($this->blocking); - } - - /** - * Disconnects from the peer, closes the socket. - * - * @access public - * @return mixed true on success or an error object otherwise - */ - function disconnect() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - @fclose($this->fp); - $this->fp = null; - return true; - } - - /** - * Find out if the socket is in blocking mode. - * - * @access public - * @return boolean The current blocking mode. - */ - function isBlocking() - { - return $this->blocking; - } - - /** - * Sets whether the socket connection should be blocking or - * not. A read call to a non-blocking socket will return immediately - * if there is no data available, whereas it will block until there - * is data for blocking sockets. - * - * @param boolean $mode True for blocking sockets, false for nonblocking. - * @access public - * @return mixed true on success or an error object otherwise - */ - function setBlocking($mode) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $this->blocking = $mode; - socket_set_blocking($this->fp, $this->blocking); - return true; - } - - /** - * Sets the timeout value on socket descriptor, - * expressed in the sum of seconds and microseconds - * - * @param integer $seconds Seconds. - * @param integer $microseconds Microseconds. - * @access public - * @return mixed true on success or an error object otherwise - */ - function setTimeout($seconds, $microseconds) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return socket_set_timeout($this->fp, $seconds, $microseconds); - } - - /** - * Returns information about an existing socket resource. - * Currently returns four entries in the result array: - * - *

- * timed_out (bool) - The socket timed out waiting for data
- * blocked (bool) - The socket was blocked
- * eof (bool) - Indicates EOF event
- * unread_bytes (int) - Number of bytes left in the socket buffer
- *

- * - * @access public - * @return mixed Array containing information about existing socket resource or an error object otherwise - */ - function getStatus() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return socket_get_status($this->fp); - } - - /** - * Get a specified line of data - * - * @access public - * @return $size bytes of data from the socket, or a PEAR_Error if - * not connected. - */ - function gets($size) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return @fgets($this->fp, $size); - } - - /** - * Read a specified amount of data. This is guaranteed to return, - * and has the added benefit of getting everything in one fread() - * chunk; if you know the size of the data you're getting - * beforehand, this is definitely the way to go. - * - * @param integer $size The number of bytes to read from the socket. - * @access public - * @return $size bytes of data from the socket, or a PEAR_Error if - * not connected. - */ - function read($size) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return @fread($this->fp, $size); - } - - /** - * Write a specified amount of data. - * - * @param string $data Data to write. - * @param integer $blocksize Amount of data to write at once. - * NULL means all at once. - * - * @access public - * @return mixed true on success or an error object otherwise - */ - function write($data, $blocksize = null) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - if (is_null($blocksize) && !OS_WINDOWS) { - return fwrite($this->fp, $data); - } else { - if (is_null($blocksize)) { - $blocksize = 1024; - } - - $pos = 0; - $size = strlen($data); - while ($pos < $size) { - $written = @fwrite($this->fp, substr($data, $pos, $blocksize)); - if ($written === false) { - return false; - } - $pos += $written; - } - - return $pos; - } - } - - /** - * Write a line of data to the socket, followed by a trailing "\r\n". - * - * @access public - * @return mixed fputs result, or an error - */ - function writeLine($data) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return fwrite($this->fp, $data . "\r\n"); - } - - /** - * Tests for end-of-file on a socket descriptor. - * - * @access public - * @return bool - */ - function eof() - { - return (is_resource($this->fp) && feof($this->fp)); - } - - /** - * Reads a byte of data - * - * @access public - * @return 1 byte of data from the socket, or a PEAR_Error if - * not connected. - */ - function readByte() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return ord(@fread($this->fp, 1)); - } - - /** - * Reads a word of data - * - * @access public - * @return 1 word of data from the socket, or a PEAR_Error if - * not connected. - */ - function readWord() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $buf = @fread($this->fp, 2); - return (ord($buf[0]) + (ord($buf[1]) << 8)); - } - - /** - * Reads an int of data - * - * @access public - * @return integer 1 int of data from the socket, or a PEAR_Error if - * not connected. - */ - function readInt() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $buf = @fread($this->fp, 4); - return (ord($buf[0]) + (ord($buf[1]) << 8) + - (ord($buf[2]) << 16) + (ord($buf[3]) << 24)); - } - - /** - * Reads a zero-terminated string of data - * - * @access public - * @return string, or a PEAR_Error if - * not connected. - */ - function readString() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $string = ''; - while (($char = @fread($this->fp, 1)) != "\x00") { - $string .= $char; - } - return $string; - } - - /** - * Reads an IP Address and returns it in a dot formated string - * - * @access public - * @return Dot formated string, or a PEAR_Error if - * not connected. - */ - function readIPAddress() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $buf = @fread($this->fp, 4); - return sprintf("%s.%s.%s.%s", ord($buf[0]), ord($buf[1]), - ord($buf[2]), ord($buf[3])); - } - - /** - * Read until either the end of the socket or a newline, whichever - * comes first. Strips the trailing newline from the returned data. - * - * @access public - * @return All available data up to a newline, without that - * newline, or until the end of the socket, or a PEAR_Error if - * not connected. - */ - function readLine() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $line = ''; - $timeout = time() + $this->timeout; - while (!feof($this->fp) && (!$this->timeout || time() < $timeout)) { - $line .= @fgets($this->fp, $this->lineLength); - if (substr($line, -1) == "\n") { - return rtrim($line, "\r\n"); - } - } - return $line; - } - - /** - * Read until the socket closes, or until there is no more data in - * the inner PHP buffer. If the inner buffer is empty, in blocking - * mode we wait for at least 1 byte of data. Therefore, in - * blocking mode, if there is no data at all to be read, this - * function will never exit (unless the socket is closed on the - * remote end). - * - * @access public - * - * @return string All data until the socket closes, or a PEAR_Error if - * not connected. - */ - function readAll() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $data = ''; - while (!feof($this->fp)) { - $data .= @fread($this->fp, $this->lineLength); - } - return $data; - } - - /** - * Runs the equivalent of the select() system call on the socket - * with a timeout specified by tv_sec and tv_usec. - * - * @param integer $state Which of read/write/error to check for. - * @param integer $tv_sec Number of seconds for timeout. - * @param integer $tv_usec Number of microseconds for timeout. - * - * @access public - * @return False if select fails, integer describing which of read/write/error - * are ready, or PEAR_Error if not connected. - */ - function select($state, $tv_sec, $tv_usec = 0) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $read = null; - $write = null; - $except = null; - if ($state & NET_SOCKET_READ) { - $read[] = $this->fp; - } - if ($state & NET_SOCKET_WRITE) { - $write[] = $this->fp; - } - if ($state & NET_SOCKET_ERROR) { - $except[] = $this->fp; - } - if (false === ($sr = stream_select($read, $write, $except, $tv_sec, $tv_usec))) { - return false; - } - - $result = 0; - if (count($read)) { - $result |= NET_SOCKET_READ; - } - if (count($write)) { - $result |= NET_SOCKET_WRITE; - } - if (count($except)) { - $result |= NET_SOCKET_ERROR; - } - return $result; - } - -} diff --git a/libs/PEAR/Net/URL.php b/libs/PEAR/Net/URL.php deleted file mode 100644 index 6331fc0ac..000000000 --- a/libs/PEAR/Net/URL.php +++ /dev/null @@ -1,410 +0,0 @@ - | -// +-----------------------------------------------------------------------+ -// -// $Id: URL.php,v 1.36 2004/06/19 18:58:50 richard Exp $ -// -// Net_URL Class - -class Net_URL -{ - /** - * Full url - * @var string - */ - var $url; - - /** - * Protocol - * @var string - */ - var $protocol; - - /** - * Username - * @var string - */ - var $username; - - /** - * Password - * @var string - */ - var $password; - - /** - * Host - * @var string - */ - var $host; - - /** - * Port - * @var integer - */ - var $port; - - /** - * Path - * @var string - */ - var $path; - - /** - * Query string - * @var array - */ - var $querystring; - - /** - * Anchor - * @var string - */ - var $anchor; - - /** - * Whether to use [] - * @var bool - */ - var $useBrackets; - - /** - * PHP4 Constructor - * - * @see __construct() - */ - function Net_URL($url = null, $useBrackets = true) - { - $this->__construct($url, $useBrackets); - } - - /** - * PHP5 Constructor - * - * Parses the given url and stores the various parts - * Defaults are used in certain cases - * - * @param string $url Optional URL - * @param bool $useBrackets Whether to use square brackets when - * multiple querystrings with the same name - * exist - */ - function __construct($url = null, $useBrackets = true) - { - $HTTP_SERVER_VARS = !empty($_SERVER) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS']; - - $this->useBrackets = $useBrackets; - $this->url = $url; - $this->user = ''; - $this->pass = ''; - $this->host = ''; - $this->port = 80; - $this->path = ''; - $this->querystring = array(); - $this->anchor = ''; - - // Only use defaults if not an absolute URL given - if (!preg_match('/^[a-z0-9]+:\/\//i', $url)) { - - $this->protocol = (@$HTTP_SERVER_VARS['HTTPS'] == 'on' ? 'https' : 'http'); - - /** - * Figure out host/port - */ - if (!empty($HTTP_SERVER_VARS['HTTP_HOST']) AND preg_match('/^(.*)(:([0-9]+))?$/U', $HTTP_SERVER_VARS['HTTP_HOST'], $matches)) { - $host = $matches[1]; - if (!empty($matches[3])) { - $port = $matches[3]; - } else { - $port = $this->getStandardPort($this->protocol); - } - } - - $this->user = ''; - $this->pass = ''; - $this->host = !empty($host) ? $host : (isset($HTTP_SERVER_VARS['SERVER_NAME']) ? $HTTP_SERVER_VARS['SERVER_NAME'] : 'localhost'); - $this->port = !empty($port) ? $port : (isset($HTTP_SERVER_VARS['SERVER_PORT']) ? $HTTP_SERVER_VARS['SERVER_PORT'] : $this->getStandardPort($this->protocol)); - $this->path = !empty($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : '/'; - $this->querystring = isset($HTTP_SERVER_VARS['QUERY_STRING']) ? $this->_parseRawQuerystring($HTTP_SERVER_VARS['QUERY_STRING']) : null; - $this->anchor = ''; - } - - // Parse the url and store the various parts - if (!empty($url)) { - $urlinfo = parse_url($url); - - // Default querystring - $this->querystring = array(); - - foreach ($urlinfo as $key => $value) { - switch ($key) { - case 'scheme': - $this->protocol = $value; - $this->port = $this->getStandardPort($value); - break; - - case 'user': - case 'pass': - case 'host': - case 'port': - $this->$key = $value; - break; - - case 'path': - if ($value{0} == '/') { - $this->path = $value; - } else { - $path = dirname($this->path) == DIRECTORY_SEPARATOR ? '' : dirname($this->path); - $this->path = sprintf('%s/%s', $path, $value); - } - break; - - case 'query': - $this->querystring = $this->_parseRawQueryString($value); - break; - - case 'fragment': - $this->anchor = $value; - break; - } - } - } - } - - /** - * Returns full url - * - * @return string Full url - * @access public - */ - function getURL() - { - $querystring = $this->getQueryString(); - - $this->url = $this->protocol . '://' - . $this->user . (!empty($this->pass) ? ':' : '') - . $this->pass . (!empty($this->user) ? '@' : '') - . $this->host . ($this->port == $this->getStandardPort($this->protocol) ? '' : ':' . $this->port) - . $this->path - . (!empty($querystring) ? '?' . $querystring : '') - . (!empty($this->anchor) ? '#' . $this->anchor : ''); - - return $this->url; - } - - /** - * Adds a querystring item - * - * @param string $name Name of item - * @param string $value Value of item - * @param bool $preencoded Whether value is urlencoded or not, default = not - * @access public - */ - function addQueryString($name, $value, $preencoded = false) - { - if ($preencoded) { - $this->querystring[$name] = $value; - } else { - $this->querystring[$name] = is_array($value) ? array_map('rawurlencode', $value): rawurlencode($value); - } - } - - /** - * Removes a querystring item - * - * @param string $name Name of item - * @access public - */ - function removeQueryString($name) - { - if (isset($this->querystring[$name])) { - unset($this->querystring[$name]); - } - } - - /** - * Sets the querystring to literally what you supply - * - * @param string $querystring The querystring data. Should be of the format foo=bar&x=y etc - * @access public - */ - function addRawQueryString($querystring) - { - $this->querystring = $this->_parseRawQueryString($querystring); - } - - /** - * Returns flat querystring - * - * @return string Querystring - * @access public - */ - function getQueryString() - { - if (!empty($this->querystring)) { - foreach ($this->querystring as $name => $value) { - if (is_array($value)) { - foreach ($value as $k => $v) { - $querystring[] = $this->useBrackets ? sprintf('%s[%s]=%s', $name, $k, $v) : ($name . '=' . $v); - } - } elseif (!is_null($value)) { - $querystring[] = $name . '=' . $value; - } else { - $querystring[] = $name; - } - } - $querystring = implode(ini_get('arg_separator.output'), $querystring); - } else { - $querystring = ''; - } - - return $querystring; - } - - /** - * Parses raw querystring and returns an array of it - * - * @param string $querystring The querystring to parse - * @return array An array of the querystring data - * @access private - */ - function _parseRawQuerystring($querystring) - { - $parts = preg_split('/[' . preg_quote(ini_get('arg_separator.input'), '/') . ']/', $querystring, -1, PREG_SPLIT_NO_EMPTY); - $return = array(); - - foreach ($parts as $part) { - if (strpos($part, '=') !== false) { - $value = substr($part, strpos($part, '=') + 1); - $key = substr($part, 0, strpos($part, '=')); - } else { - $value = null; - $key = $part; - } - if (substr($key, -2) == '[]') { - $key = substr($key, 0, -2); - if (@!is_array($return[$key])) { - $return[$key] = array(); - $return[$key][] = $value; - } else { - $return[$key][] = $value; - } - } elseif (!$this->useBrackets AND !empty($return[$key])) { - $return[$key] = (array)$return[$key]; - $return[$key][] = $value; - } else { - $return[$key] = $value; - } - } - - return $return; - } - - /** - * Resolves //, ../ and ./ from a path and returns - * the result. Eg: - * - * /foo/bar/../boo.php => /foo/boo.php - * /foo/bar/../../boo.php => /boo.php - * /foo/bar/.././/boo.php => /foo/boo.php - * - * This method can also be called statically. - * - * @param string $url URL path to resolve - * @return string The result - */ - function resolvePath($path) - { - $path = explode('/', str_replace('//', '/', $path)); - - for ($i=0; $i 1 OR ($i == 1 AND $path[0] != '') ) ) { - unset($path[$i]); - unset($path[$i-1]); - $path = array_values($path); - $i -= 2; - - } elseif ($path[$i] == '..' AND $i == 1 AND $path[0] == '') { - unset($path[$i]); - $path = array_values($path); - $i--; - - } else { - continue; - } - } - - return implode('/', $path); - } - - /** - * Returns the standard port number for a protocol - * - * @param string $scheme The protocol to lookup - * @return integer Port number or NULL if no scheme matches - * - * @author Philippe Jausions - */ - function getStandardPort($scheme) - { - switch (strtolower($scheme)) { - case 'http': return 80; - case 'https': return 443; - case 'ftp': return 21; - case 'imap': return 143; - case 'imaps': return 993; - case 'pop3': return 110; - case 'pop3s': return 995; - default: return null; - } - } - - /** - * Forces the URL to a particular protocol - * - * @param string $protocol Protocol to force the URL to - * @param integer $port Optional port (standard port is used by default) - */ - function setProtocol($protocol, $port = null) - { - $this->protocol = $protocol; - $this->port = is_null($port) ? $this->getStandardPort() : $port; - } - -} -?> diff --git a/libs/PEAR/PEAR.php b/libs/PEAR/PEAR.php deleted file mode 100644 index d2d41b274..000000000 --- a/libs/PEAR/PEAR.php +++ /dev/null @@ -1,1108 +0,0 @@ - - * @author Stig Bakken - * @author Tomas V.V.Cox - * @author Greg Beaver - * @copyright 1997-2006 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: PEAR.php,v 1.101 2006/04/25 02:41:03 cellog Exp $ - * @link http://pear.php.net/package/PEAR - * @since File available since Release 0.1 - */ - -/**#@+ - * ERROR constants - */ -define('PEAR_ERROR_RETURN', 1); -define('PEAR_ERROR_PRINT', 2); -define('PEAR_ERROR_TRIGGER', 4); -define('PEAR_ERROR_DIE', 8); -define('PEAR_ERROR_CALLBACK', 16); -/** - * WARNING: obsolete - * @deprecated - */ -define('PEAR_ERROR_EXCEPTION', 32); -/**#@-*/ -define('PEAR_ZE2', (function_exists('version_compare') && - version_compare(zend_version(), "2-dev", "ge"))); - -if (substr(PHP_OS, 0, 3) == 'WIN') { - define('OS_WINDOWS', true); - define('OS_UNIX', false); - define('PEAR_OS', 'Windows'); -} else { - define('OS_WINDOWS', false); - define('OS_UNIX', true); - define('PEAR_OS', 'Unix'); // blatant assumption -} - -// instant backwards compatibility -if (!defined('PATH_SEPARATOR')) { - if (OS_WINDOWS) { - define('PATH_SEPARATOR', ';'); - } else { - define('PATH_SEPARATOR', ':'); - } -} - -$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN; -$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE; -$GLOBALS['_PEAR_destructor_object_list'] = array(); -$GLOBALS['_PEAR_shutdown_funcs'] = array(); -$GLOBALS['_PEAR_error_handler_stack'] = array(); - -@ini_set('track_errors', true); - -/** - * Base class for other PEAR classes. Provides rudimentary - * emulation of destructors. - * - * If you want a destructor in your class, inherit PEAR and make a - * destructor method called _yourclassname (same name as the - * constructor, but with a "_" prefix). Also, in your constructor you - * have to call the PEAR constructor: $this->PEAR();. - * The destructor method will be called without parameters. Note that - * at in some SAPI implementations (such as Apache), any output during - * the request shutdown (in which destructors are called) seems to be - * discarded. If you need to get any debug information from your - * destructor, use error_log(), syslog() or something similar. - * - * IMPORTANT! To use the emulated destructors you need to create the - * objects by reference: $obj =& new PEAR_child; - * - * @category pear - * @package PEAR - * @author Stig Bakken - * @author Tomas V.V. Cox - * @author Greg Beaver - * @copyright 1997-2006 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version Release: 1.5.0 - * @link http://pear.php.net/package/PEAR - * @see PEAR_Error - * @since Class available since PHP 4.0.2 - * @link http://pear.php.net/manual/en/core.pear.php#core.pear.pear - */ -class PEAR -{ - // {{{ properties - - /** - * Whether to enable internal debug messages. - * - * @var bool - * @access private - */ - var $_debug = false; - - /** - * Default error mode for this object. - * - * @var int - * @access private - */ - var $_default_error_mode = null; - - /** - * Default error options used for this object when error mode - * is PEAR_ERROR_TRIGGER. - * - * @var int - * @access private - */ - var $_default_error_options = null; - - /** - * Default error handler (callback) for this object, if error mode is - * PEAR_ERROR_CALLBACK. - * - * @var string - * @access private - */ - var $_default_error_handler = ''; - - /** - * Which class to use for error objects. - * - * @var string - * @access private - */ - var $_error_class = 'PEAR_Error'; - - /** - * An array of expected errors. - * - * @var array - * @access private - */ - var $_expected_errors = array(); - - // }}} - - // {{{ constructor - - /** - * Constructor. Registers this object in - * $_PEAR_destructor_object_list for destructor emulation if a - * destructor object exists. - * - * @param string $error_class (optional) which class to use for - * error objects, defaults to PEAR_Error. - * @access public - * @return void - */ - function PEAR($error_class = null) - { - $classname = strtolower(get_class($this)); - if ($this->_debug) { - print "PEAR constructor called, class=$classname\n"; - } - if ($error_class !== null) { - $this->_error_class = $error_class; - } - while ($classname && strcasecmp($classname, "pear")) { - $destructor = "_$classname"; - if (method_exists($this, $destructor)) { - global $_PEAR_destructor_object_list; - $_PEAR_destructor_object_list[] = &$this; - if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { - register_shutdown_function("_PEAR_call_destructors"); - $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; - } - break; - } else { - $classname = get_parent_class($classname); - } - } - } - - // }}} - // {{{ destructor - - /** - * Destructor (the emulated type of...). Does nothing right now, - * but is included for forward compatibility, so subclass - * destructors should always call it. - * - * See the note in the class desciption about output from - * destructors. - * - * @access public - * @return void - */ - function _PEAR() { - if ($this->_debug) { - printf("PEAR destructor called, class=%s\n", strtolower(get_class($this))); - } - } - - // }}} - // {{{ getStaticProperty() - - /** - * If you have a class that's mostly/entirely static, and you need static - * properties, you can use this method to simulate them. Eg. in your method(s) - * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); - * You MUST use a reference, or they will not persist! - * - * @access public - * @param string $class The calling classname, to prevent clashes - * @param string $var The variable to retrieve. - * @return mixed A reference to the variable. If not set it will be - * auto initialised to NULL. - */ - function &getStaticProperty($class, $var) - { - static $properties; - if (!isset($properties[$class])) { - $properties[$class] = array(); - } - if (!array_key_exists($var, $properties[$class])) { - $properties[$class][$var] = null; - } - return $properties[$class][$var]; - } - - // }}} - // {{{ registerShutdownFunc() - - /** - * Use this function to register a shutdown method for static - * classes. - * - * @access public - * @param mixed $func The function name (or array of class/method) to call - * @param mixed $args The arguments to pass to the function - * @return void - */ - function registerShutdownFunc($func, $args = array()) - { - // if we are called statically, there is a potential - // that no shutdown func is registered. Bug #6445 - if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { - register_shutdown_function("_PEAR_call_destructors"); - $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; - } - $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args); - } - - // }}} - // {{{ isError() - - /** - * Tell whether a value is a PEAR error. - * - * @param mixed $data the value to test - * @param int $code if $data is an error object, return true - * only if $code is a string and - * $obj->getMessage() == $code or - * $code is an integer and $obj->getCode() == $code - * @access public - * @return bool true if parameter is an error - */ - function isError($data, $code = null) - { - if (is_a($data, 'PEAR_Error')) { - if (is_null($code)) { - return true; - } elseif (is_string($code)) { - return $data->getMessage() == $code; - } else { - return $data->getCode() == $code; - } - } - return false; - } - - // }}} - // {{{ setErrorHandling() - - /** - * Sets how errors generated by this object should be handled. - * Can be invoked both in objects and statically. If called - * statically, setErrorHandling sets the default behaviour for all - * PEAR objects. If called in an object, setErrorHandling sets - * the default behaviour for that object. - * - * @param int $mode - * One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, - * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION. - * - * @param mixed $options - * When $mode is PEAR_ERROR_TRIGGER, this is the error level (one - * of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * - * When $mode is PEAR_ERROR_CALLBACK, this parameter is expected - * to be the callback function or method. A callback - * function is a string with the name of the function, a - * callback method is an array of two elements: the element - * at index 0 is the object, and the element at index 1 is - * the name of the method to call in the object. - * - * When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is - * a printf format string used when printing the error - * message. - * - * @access public - * @return void - * @see PEAR_ERROR_RETURN - * @see PEAR_ERROR_PRINT - * @see PEAR_ERROR_TRIGGER - * @see PEAR_ERROR_DIE - * @see PEAR_ERROR_CALLBACK - * @see PEAR_ERROR_EXCEPTION - * - * @since PHP 4.0.5 - */ - - function setErrorHandling($mode = null, $options = null) - { - if (isset($this) && is_a($this, 'PEAR')) { - $setmode = &$this->_default_error_mode; - $setoptions = &$this->_default_error_options; - } else { - $setmode = &$GLOBALS['_PEAR_default_error_mode']; - $setoptions = &$GLOBALS['_PEAR_default_error_options']; - } - - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $setmode = $mode; - $setoptions = $options; - break; - - case PEAR_ERROR_CALLBACK: - $setmode = $mode; - // class/object method callback - if (is_callable($options)) { - $setoptions = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - } - - // }}} - // {{{ expectError() - - /** - * This method is used to tell which errors you expect to get. - * Expected errors are always returned with error mode - * PEAR_ERROR_RETURN. Expected error codes are stored in a stack, - * and this method pushes a new element onto it. The list of - * expected errors are in effect until they are popped off the - * stack with the popExpect() method. - * - * Note that this method can not be called statically - * - * @param mixed $code a single error code or an array of error codes to expect - * - * @return int the new depth of the "expected errors" stack - * @access public - */ - function expectError($code = '*') - { - if (is_array($code)) { - array_push($this->_expected_errors, $code); - } else { - array_push($this->_expected_errors, array($code)); - } - return sizeof($this->_expected_errors); - } - - // }}} - // {{{ popExpect() - - /** - * This method pops one element off the expected error codes - * stack. - * - * @return array the list of error codes that were popped - */ - function popExpect() - { - return array_pop($this->_expected_errors); - } - - // }}} - // {{{ _checkDelExpect() - - /** - * This method checks unsets an error code if available - * - * @param mixed error code - * @return bool true if the error code was unset, false otherwise - * @access private - * @since PHP 4.3.0 - */ - function _checkDelExpect($error_code) - { - $deleted = false; - - foreach ($this->_expected_errors AS $key => $error_array) { - if (in_array($error_code, $error_array)) { - unset($this->_expected_errors[$key][array_search($error_code, $error_array)]); - $deleted = true; - } - - // clean up empty arrays - if (0 == count($this->_expected_errors[$key])) { - unset($this->_expected_errors[$key]); - } - } - return $deleted; - } - - // }}} - // {{{ delExpect() - - /** - * This method deletes all occurences of the specified element from - * the expected error codes stack. - * - * @param mixed $error_code error code that should be deleted - * @return mixed list of error codes that were deleted or error - * @access public - * @since PHP 4.3.0 - */ - function delExpect($error_code) - { - $deleted = false; - - if ((is_array($error_code) && (0 != count($error_code)))) { - // $error_code is a non-empty array here; - // we walk through it trying to unset all - // values - foreach($error_code as $key => $error) { - if ($this->_checkDelExpect($error)) { - $deleted = true; - } else { - $deleted = false; - } - } - return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME - } elseif (!empty($error_code)) { - // $error_code comes alone, trying to unset it - if ($this->_checkDelExpect($error_code)) { - return true; - } else { - return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME - } - } else { - // $error_code is empty - return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME - } - } - - // }}} - // {{{ raiseError() - - /** - * This method is a wrapper that returns an instance of the - * configured error class with this object's default error - * handling applied. If the $mode and $options parameters are not - * specified, the object's defaults are used. - * - * @param mixed $message a text error message or a PEAR error object - * - * @param int $code a numeric error code (it is up to your class - * to define these if you want to use codes) - * - * @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, - * PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION. - * - * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter - * specifies the PHP-internal error level (one of - * E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * If $mode is PEAR_ERROR_CALLBACK, this - * parameter specifies the callback function or - * method. In other error modes this parameter - * is ignored. - * - * @param string $userinfo If you need to pass along for example debug - * information, this parameter is meant for that. - * - * @param string $error_class The returned error object will be - * instantiated from this class, if specified. - * - * @param bool $skipmsg If true, raiseError will only pass error codes, - * the error message parameter will be dropped. - * - * @access public - * @return object a PEAR error object - * @see PEAR::setErrorHandling - * @since PHP 4.0.5 - */ - function &raiseError($message = null, - $code = null, - $mode = null, - $options = null, - $userinfo = null, - $error_class = null, - $skipmsg = false) - { - // The error is yet a PEAR error object - if (is_object($message)) { - $code = $message->getCode(); - $userinfo = $message->getUserInfo(); - $error_class = $message->getType(); - $message->error_message_prefix = ''; - $message = $message->getMessage(); - } - - if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) { - if ($exp[0] == "*" || - (is_int(reset($exp)) && in_array($code, $exp)) || - (is_string(reset($exp)) && in_array($message, $exp))) { - $mode = PEAR_ERROR_RETURN; - } - } - // No mode given, try global ones - if ($mode === null) { - // Class error handler - if (isset($this) && isset($this->_default_error_mode)) { - $mode = $this->_default_error_mode; - $options = $this->_default_error_options; - // Global error handler - } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) { - $mode = $GLOBALS['_PEAR_default_error_mode']; - $options = $GLOBALS['_PEAR_default_error_options']; - } - } - - if ($error_class !== null) { - $ec = $error_class; - } elseif (isset($this) && isset($this->_error_class)) { - $ec = $this->_error_class; - } else { - $ec = 'PEAR_Error'; - } - if ($skipmsg) { - $a = &new $ec($code, $mode, $options, $userinfo); - return $a; - } else { - $a = &new $ec($message, $code, $mode, $options, $userinfo); - return $a; - } - } - - // }}} - // {{{ throwError() - - /** - * Simpler form of raiseError with fewer options. In most cases - * message, code and userinfo are enough. - * - * @param string $message - * - */ - function &throwError($message = null, - $code = null, - $userinfo = null) - { - if (isset($this) && is_a($this, 'PEAR')) { - $a = &$this->raiseError($message, $code, null, null, $userinfo); - return $a; - } else { - $a = &PEAR::raiseError($message, $code, null, null, $userinfo); - return $a; - } - } - - // }}} - function staticPushErrorHandling($mode, $options = null) - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - $def_mode = &$GLOBALS['_PEAR_default_error_mode']; - $def_options = &$GLOBALS['_PEAR_default_error_options']; - $stack[] = array($def_mode, $def_options); - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $def_mode = $mode; - $def_options = $options; - break; - - case PEAR_ERROR_CALLBACK: - $def_mode = $mode; - // class/object method callback - if (is_callable($options)) { - $def_options = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - $stack[] = array($mode, $options); - return true; - } - - function staticPopErrorHandling() - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - $setmode = &$GLOBALS['_PEAR_default_error_mode']; - $setoptions = &$GLOBALS['_PEAR_default_error_options']; - array_pop($stack); - list($mode, $options) = $stack[sizeof($stack) - 1]; - array_pop($stack); - switch ($mode) { - case PEAR_ERROR_EXCEPTION: - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $setmode = $mode; - $setoptions = $options; - break; - - case PEAR_ERROR_CALLBACK: - $setmode = $mode; - // class/object method callback - if (is_callable($options)) { - $setoptions = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - return true; - } - - // {{{ pushErrorHandling() - - /** - * Push a new error handler on top of the error handler options stack. With this - * you can easily override the actual error handler for some code and restore - * it later with popErrorHandling. - * - * @param mixed $mode (same as setErrorHandling) - * @param mixed $options (same as setErrorHandling) - * - * @return bool Always true - * - * @see PEAR::setErrorHandling - */ - function pushErrorHandling($mode, $options = null) - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - if (isset($this) && is_a($this, 'PEAR')) { - $def_mode = &$this->_default_error_mode; - $def_options = &$this->_default_error_options; - } else { - $def_mode = &$GLOBALS['_PEAR_default_error_mode']; - $def_options = &$GLOBALS['_PEAR_default_error_options']; - } - $stack[] = array($def_mode, $def_options); - - if (isset($this) && is_a($this, 'PEAR')) { - $this->setErrorHandling($mode, $options); - } else { - PEAR::setErrorHandling($mode, $options); - } - $stack[] = array($mode, $options); - return true; - } - - // }}} - // {{{ popErrorHandling() - - /** - * Pop the last error handler used - * - * @return bool Always true - * - * @see PEAR::pushErrorHandling - */ - function popErrorHandling() - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - array_pop($stack); - list($mode, $options) = $stack[sizeof($stack) - 1]; - array_pop($stack); - if (isset($this) && is_a($this, 'PEAR')) { - $this->setErrorHandling($mode, $options); - } else { - PEAR::setErrorHandling($mode, $options); - } - return true; - } - - // }}} - // {{{ loadExtension() - - /** - * OS independant PHP extension load. Remember to take care - * on the correct extension name for case sensitive OSes. - * - * @param string $ext The extension name - * @return bool Success or not on the dl() call - */ - function loadExtension($ext) - { - if (!extension_loaded($ext)) { - // if either returns true dl() will produce a FATAL error, stop that - if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) { - return false; - } - if (OS_WINDOWS) { - $suffix = '.dll'; - } elseif (PHP_OS == 'HP-UX') { - $suffix = '.sl'; - } elseif (PHP_OS == 'AIX') { - $suffix = '.a'; - } elseif (PHP_OS == 'OSX') { - $suffix = '.bundle'; - } else { - $suffix = '.so'; - } - return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix); - } - return true; - } - - // }}} -} - -// {{{ _PEAR_call_destructors() - -function _PEAR_call_destructors() -{ - global $_PEAR_destructor_object_list; - if (is_array($_PEAR_destructor_object_list) && - sizeof($_PEAR_destructor_object_list)) - { - reset($_PEAR_destructor_object_list); - if (PEAR::getStaticProperty('PEAR', 'destructlifo')) { - $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list); - } - while (list($k, $objref) = each($_PEAR_destructor_object_list)) { - $classname = get_class($objref); - while ($classname) { - $destructor = "_$classname"; - if (method_exists($objref, $destructor)) { - $objref->$destructor(); - break; - } else { - $classname = get_parent_class($classname); - } - } - } - // Empty the object list to ensure that destructors are - // not called more than once. - $_PEAR_destructor_object_list = array(); - } - - // Now call the shutdown functions - if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) { - foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) { - call_user_func_array($value[0], $value[1]); - } - } -} - -// }}} -/** - * Standard PEAR error class for PHP 4 - * - * This class is supserseded by {@link PEAR_Exception} in PHP 5 - * - * @category pear - * @package PEAR - * @author Stig Bakken - * @author Tomas V.V. Cox - * @author Gregory Beaver - * @copyright 1997-2006 The PHP Group - * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version Release: 1.5.0 - * @link http://pear.php.net/manual/en/core.pear.pear-error.php - * @see PEAR::raiseError(), PEAR::throwError() - * @since Class available since PHP 4.0.2 - */ -class PEAR_Error -{ - // {{{ properties - - var $error_message_prefix = ''; - var $mode = PEAR_ERROR_RETURN; - var $level = E_USER_NOTICE; - var $code = -1; - var $message = ''; - var $userinfo = ''; - var $backtrace = null; - - // }}} - // {{{ constructor - - /** - * PEAR_Error constructor - * - * @param string $message message - * - * @param int $code (optional) error code - * - * @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN, - * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER, - * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION - * - * @param mixed $options (optional) error level, _OR_ in the case of - * PEAR_ERROR_CALLBACK, the callback function or object/method - * tuple. - * - * @param string $userinfo (optional) additional user/debug info - * - * @access public - * - */ - function PEAR_Error($message = 'unknown error', $code = null, - $mode = null, $options = null, $userinfo = null) - { - if ($mode === null) { - $mode = PEAR_ERROR_RETURN; - } - $this->message = $message; - $this->code = $code; - $this->mode = $mode; - $this->userinfo = $userinfo; - if (!PEAR::getStaticProperty('PEAR_Error', 'skiptrace')) { - $this->backtrace = debug_backtrace(); - if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) { - unset($this->backtrace[0]['object']); - } - } - if ($mode & PEAR_ERROR_CALLBACK) { - $this->level = E_USER_NOTICE; - $this->callback = $options; - } else { - if ($options === null) { - $options = E_USER_NOTICE; - } - $this->level = $options; - $this->callback = null; - } - if ($this->mode & PEAR_ERROR_PRINT) { - if (is_null($options) || is_int($options)) { - $format = "%s"; - } else { - $format = $options; - } - printf($format, $this->getMessage()); - } - if ($this->mode & PEAR_ERROR_TRIGGER) { - trigger_error($this->getMessage(), $this->level); - } - if ($this->mode & PEAR_ERROR_DIE) { - $msg = $this->getMessage(); - if (is_null($options) || is_int($options)) { - $format = "%s"; - if (substr($msg, -1) != "\n") { - $msg .= "\n"; - } - } else { - $format = $options; - } - die(sprintf($format, $msg)); - } - if ($this->mode & PEAR_ERROR_CALLBACK) { - if (is_callable($this->callback)) { - call_user_func($this->callback, $this); - } - } - if ($this->mode & PEAR_ERROR_EXCEPTION) { - trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING); - eval('$e = new Exception($this->message, $this->code);throw($e);'); - } - } - - // }}} - // {{{ getMode() - - /** - * Get the error mode from an error object. - * - * @return int error mode - * @access public - */ - function getMode() { - return $this->mode; - } - - // }}} - // {{{ getCallback() - - /** - * Get the callback function/method from an error object. - * - * @return mixed callback function or object/method array - * @access public - */ - function getCallback() { - return $this->callback; - } - - // }}} - // {{{ getMessage() - - - /** - * Get the error message from an error object. - * - * @return string full error message - * @access public - */ - function getMessage() - { - return ($this->error_message_prefix . $this->message); - } - - - // }}} - // {{{ getCode() - - /** - * Get error code from an error object - * - * @return int error code - * @access public - */ - function getCode() - { - return $this->code; - } - - // }}} - // {{{ getType() - - /** - * Get the name of this error/exception. - * - * @return string error/exception name (type) - * @access public - */ - function getType() - { - return get_class($this); - } - - // }}} - // {{{ getUserInfo() - - /** - * Get additional user-supplied information. - * - * @return string user-supplied information - * @access public - */ - function getUserInfo() - { - return $this->userinfo; - } - - // }}} - // {{{ getDebugInfo() - - /** - * Get additional debug information supplied by the application. - * - * @return string debug information - * @access public - */ - function getDebugInfo() - { - return $this->getUserInfo(); - } - - // }}} - // {{{ getBacktrace() - - /** - * Get the call backtrace from where the error was generated. - * Supported with PHP 4.3.0 or newer. - * - * @param int $frame (optional) what frame to fetch - * @return array Backtrace, or NULL if not available. - * @access public - */ - function getBacktrace($frame = null) - { - if (defined('PEAR_IGNORE_BACKTRACE')) { - return null; - } - if ($frame === null) { - return $this->backtrace; - } - return $this->backtrace[$frame]; - } - - // }}} - // {{{ addUserInfo() - - function addUserInfo($info) - { - if (empty($this->userinfo)) { - $this->userinfo = $info; - } else { - $this->userinfo .= " ** $info"; - } - } - - // }}} - // {{{ toString() - - /** - * Make a string representation of this object. - * - * @return string a string with an object summary - * @access public - */ - function toString() { - $modes = array(); - $levels = array(E_USER_NOTICE => 'notice', - E_USER_WARNING => 'warning', - E_USER_ERROR => 'error'); - if ($this->mode & PEAR_ERROR_CALLBACK) { - if (is_array($this->callback)) { - $callback = (is_object($this->callback[0]) ? - strtolower(get_class($this->callback[0])) : - $this->callback[0]) . '::' . - $this->callback[1]; - } else { - $callback = $this->callback; - } - return sprintf('[%s: message="%s" code=%d mode=callback '. - 'callback=%s prefix="%s" info="%s"]', - strtolower(get_class($this)), $this->message, $this->code, - $callback, $this->error_message_prefix, - $this->userinfo); - } - if ($this->mode & PEAR_ERROR_PRINT) { - $modes[] = 'print'; - } - if ($this->mode & PEAR_ERROR_TRIGGER) { - $modes[] = 'trigger'; - } - if ($this->mode & PEAR_ERROR_DIE) { - $modes[] = 'die'; - } - if ($this->mode & PEAR_ERROR_RETURN) { - $modes[] = 'return'; - } - return sprintf('[%s: message="%s" code=%d mode=%s level=%s '. - 'prefix="%s" info="%s"]', - strtolower(get_class($this)), $this->message, $this->code, - implode("|", $modes), $levels[$this->level], - $this->error_message_prefix, - $this->userinfo); - } - - // }}} -} - -/* - * Local Variables: - * mode: php - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ -?> diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 2e26eea08..9a99b797a 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -237,37 +237,6 @@ return array( 'HTMLPurifier_VarParser_Flexible' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/VarParser/Flexible.php', 'HTMLPurifier_VarParser_Native' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/VarParser/Native.php', 'HTMLPurifier_Zipper' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/Zipper.php', - 'HTTP_Request2' => $vendorDir . '/pear/http_request2/HTTP/Request2.php', - 'HTTP_Request2Test' => $vendorDir . '/pear/http_request2/tests/Request2Test.php', - 'HTTP_Request2_Adapter' => $vendorDir . '/pear/http_request2/HTTP/Request2/Adapter.php', - 'HTTP_Request2_Adapter_CommonNetworkTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/CommonNetworkTest.php', - 'HTTP_Request2_Adapter_Curl' => $vendorDir . '/pear/http_request2/HTTP/Request2/Adapter/Curl.php', - 'HTTP_Request2_Adapter_CurlTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/CurlTest.php', - 'HTTP_Request2_Adapter_Mock' => $vendorDir . '/pear/http_request2/HTTP/Request2/Adapter/Mock.php', - 'HTTP_Request2_Adapter_MockTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/MockTest.php', - 'HTTP_Request2_Adapter_Skip_CurlTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/SkippedTests.php', - 'HTTP_Request2_Adapter_Skip_SocketProxyTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/SkippedTests.php', - 'HTTP_Request2_Adapter_Skip_SocketTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/SkippedTests.php', - 'HTTP_Request2_Adapter_Socket' => $vendorDir . '/pear/http_request2/HTTP/Request2/Adapter/Socket.php', - 'HTTP_Request2_Adapter_SocketProxyTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/SocketProxyTest.php', - 'HTTP_Request2_Adapter_SocketTest' => $vendorDir . '/pear/http_request2/tests/Request2/Adapter/SocketTest.php', - 'HTTP_Request2_AllTests' => $vendorDir . '/pear/http_request2/tests/AllTests.php', - 'HTTP_Request2_ConnectionException' => $vendorDir . '/pear/http_request2/HTTP/Request2/Exception.php', - 'HTTP_Request2_CookieJar' => $vendorDir . '/pear/http_request2/HTTP/Request2/CookieJar.php', - 'HTTP_Request2_CookieJarTest' => $vendorDir . '/pear/http_request2/tests/Request2/CookieJarTest.php', - 'HTTP_Request2_Exception' => $vendorDir . '/pear/http_request2/HTTP/Request2/Exception.php', - 'HTTP_Request2_LogicException' => $vendorDir . '/pear/http_request2/HTTP/Request2/Exception.php', - 'HTTP_Request2_MessageException' => $vendorDir . '/pear/http_request2/HTTP/Request2/Exception.php', - 'HTTP_Request2_MockObserver' => $vendorDir . '/pear/http_request2/tests/ObserverTest.php', - 'HTTP_Request2_MultipartBody' => $vendorDir . '/pear/http_request2/HTTP/Request2/MultipartBody.php', - 'HTTP_Request2_MultipartBodyTest' => $vendorDir . '/pear/http_request2/tests/Request2/MultipartBodyTest.php', - 'HTTP_Request2_NotImplementedException' => $vendorDir . '/pear/http_request2/HTTP/Request2/Exception.php', - 'HTTP_Request2_ObserverTest' => $vendorDir . '/pear/http_request2/tests/ObserverTest.php', - 'HTTP_Request2_Observer_Log' => $vendorDir . '/pear/http_request2/HTTP/Request2/Observer/Log.php', - 'HTTP_Request2_Response' => $vendorDir . '/pear/http_request2/HTTP/Request2/Response.php', - 'HTTP_Request2_ResponseTest' => $vendorDir . '/pear/http_request2/tests/Request2/ResponseTest.php', - 'HTTP_Request2_SOCKS5' => $vendorDir . '/pear/http_request2/HTTP/Request2/SOCKS5.php', - 'HTTP_Request2_SocketWrapper' => $vendorDir . '/pear/http_request2/HTTP/Request2/SocketWrapper.php', 'MatthiasMullie\\Minify\\CSS' => $vendorDir . '/matthiasmullie/minify/src/CSS.php', 'MatthiasMullie\\Minify\\Exception' => $vendorDir . '/matthiasmullie/minify/src/Exception.php', 'MatthiasMullie\\Minify\\JS' => $vendorDir . '/matthiasmullie/minify/src/JS.php', @@ -276,9 +245,6 @@ return array( 'Michelf\\Markdown' => $vendorDir . '/michelf/php-markdown/Michelf/Markdown.php', 'Michelf\\MarkdownExtra' => $vendorDir . '/michelf/php-markdown/Michelf/MarkdownExtra.php', 'Michelf\\MarkdownInterface' => $vendorDir . '/michelf/php-markdown/Michelf/MarkdownInterface.php', - 'Net_URL2' => $vendorDir . '/pear/net_url2/Net/URL2.php', - 'PEAR_Exception' => $vendorDir . '/pear/pear_exception/PEAR/Exception.php', - 'PEAR_ExceptionTest' => $vendorDir . '/pear/pear_exception/tests/PEAR/ExceptionTest.php', 'Requests' => $vendorDir . '/rmccue/requests/library/Requests.php', 'Requests_Auth' => $vendorDir . '/rmccue/requests/library/Requests/Auth.php', 'Requests_Auth_Basic' => $vendorDir . '/rmccue/requests/library/Requests/Auth/Basic.php', diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index 44320b577..0ba8d72dc 100644 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -8,8 +8,6 @@ $baseDir = dirname($vendorDir); return array( 'Sunra\\PhpSimple\\HtmlDomParser' => array($vendorDir . '/sunra/php-simple-html-dom-parser/Src'), 'Requests' => array($vendorDir . '/rmccue/requests/library'), - 'PEAR' => array($vendorDir . '/pear/pear_exception'), 'Michelf' => array($vendorDir . '/michelf/php-markdown'), - 'HTTP_Request2' => array($vendorDir . '/pear/http_request2'), 'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'), ); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 4ad2a5c88..d8899d992 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -23,10 +23,6 @@ class ComposerAutoloaderInit1e37ff09eb6590c7436f139ffd9070de self::$loader = $loader = new \Composer\Autoload\ClassLoader(); spl_autoload_unregister(array('ComposerAutoloaderInit1e37ff09eb6590c7436f139ffd9070de', 'loadClassLoader')); - $includePaths = require __DIR__ . '/include_paths.php'; - array_push($includePaths, get_include_path()); - set_include_path(join(PATH_SEPARATOR, $includePaths)); - $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { $loader->set($namespace, $path); diff --git a/vendor/composer/include_paths.php b/vendor/composer/include_paths.php deleted file mode 100644 index 98c3d1374..000000000 --- a/vendor/composer/include_paths.php +++ /dev/null @@ -1,10 +0,0 @@ -=4.4.0" - }, - "require-dev": { - "phpunit/phpunit": "*" - }, - "time": "2015-02-10 20:07:52", - "type": "class", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "PEAR": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "." - ], - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Helgi Thormar", - "email": "dufuz@php.net" - }, - { - "name": "Greg Beaver", - "email": "cellog@php.net" - } - ], - "description": "The PEAR Exception base class.", - "homepage": "https://github.com/pear/PEAR_Exception", - "keywords": [ - "exception" - ] - }, - { - "name": "pear/net_url2", - "version": "v2.2.0", - "version_normalized": "2.2.0.0", - "source": { - "type": "git", - "url": "https://github.com/pear/Net_URL2.git", - "reference": "fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/pear/Net_URL2/zipball/fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e", - "reference": "fa9b1ecb3c3e640d4a54d58d681a4cb7524f209e", - "shasum": "" - }, - "require": { - "php": ">=5.1.4" - }, - "require-dev": { - "phpunit/phpunit": ">=3.3.0" - }, - "time": "2015-04-18 17:36:57", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "classmap": [ - "Net/URL2.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "David Coallier", - "email": "davidc@php.net" - }, - { - "name": "Tom Klingenberg", - "email": "tkli@php.net" - }, - { - "name": "Christian Schmidt", - "email": "chmidt@php.net" - } - ], - "description": "Class for parsing and handling URL. Provides parsing of URLs into their constituent parts (scheme, host, path etc.), URL generation, and resolving of relative URLs.", - "homepage": "https://github.com/pear/Net_URL2", - "keywords": [ - "PEAR", - "net", - "networking", - "rfc3986", - "uri", - "url" - ] - }, - { - "name": "pear/http_request2", - "version": "v2.2.1", - "version_normalized": "2.2.1.0", - "source": { - "type": "git", - "url": "https://github.com/pear/HTTP_Request2.git", - "reference": "d6c81670c504045248c1afdf896bb9a3288158de" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/pear/HTTP_Request2/zipball/d6c81670c504045248c1afdf896bb9a3288158de", - "reference": "d6c81670c504045248c1afdf896bb9a3288158de", - "shasum": "" - }, - "require": { - "pear/net_url2": ">=2.0.0", - "pear/pear_exception": "*", - "php": ">=5.2.0" - }, - "suggest": { - "ext-fileinfo": "Adds support for looking up mime-types using finfo.", - "ext-zlib": "Allows handling gzip compressed responses.", - "lib-curl": "Allows using cURL as a request backend.", - "lib-openssl": "Allows handling SSL requests when not using cURL." - }, - "time": "2014-01-16 17:27:21", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "HTTP_Request2": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Alexey Borzov", - "email": "avb@php.net", - "role": "Developer HTML_Common2" - } - ], - "description": "Provides an easy way to perform HTTP requests.", - "homepage": "http://pear.php.net/package/HTTP_Request2", - "keywords": [ - "PEAR", - "curl", - "http", - "request" - ] - }, { "name": "swiftmailer/swiftmailer", "version": "v5.4.1", diff --git a/vendor/pear/http_request2/HTTP/Request2.php b/vendor/pear/http_request2/HTTP/Request2.php deleted file mode 100644 index 42156f1d6..000000000 --- a/vendor/pear/http_request2/HTTP/Request2.php +++ /dev/null @@ -1,1030 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * A class representing an URL as per RFC 3986. - */ -require_once 'Net/URL2.php'; - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class representing a HTTP request message - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://tools.ietf.org/html/rfc2616#section-5 - */ -class HTTP_Request2 implements SplSubject -{ - /**#@+ - * Constants for HTTP request methods - * - * @link http://tools.ietf.org/html/rfc2616#section-5.1.1 - */ - const METHOD_OPTIONS = 'OPTIONS'; - const METHOD_GET = 'GET'; - const METHOD_HEAD = 'HEAD'; - const METHOD_POST = 'POST'; - const METHOD_PUT = 'PUT'; - const METHOD_DELETE = 'DELETE'; - const METHOD_TRACE = 'TRACE'; - const METHOD_CONNECT = 'CONNECT'; - /**#@-*/ - - /**#@+ - * Constants for HTTP authentication schemes - * - * @link http://tools.ietf.org/html/rfc2617 - */ - const AUTH_BASIC = 'basic'; - const AUTH_DIGEST = 'digest'; - /**#@-*/ - - /** - * Regular expression used to check for invalid symbols in RFC 2616 tokens - * @link http://pear.php.net/bugs/bug.php?id=15630 - */ - const REGEXP_INVALID_TOKEN = '![\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]!'; - - /** - * Regular expression used to check for invalid symbols in cookie strings - * @link http://pear.php.net/bugs/bug.php?id=15630 - * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html - */ - const REGEXP_INVALID_COOKIE = '/[\s,;]/'; - - /** - * Fileinfo magic database resource - * @var resource - * @see detectMimeType() - */ - private static $_fileinfoDb; - - /** - * Observers attached to the request (instances of SplObserver) - * @var array - */ - protected $observers = array(); - - /** - * Request URL - * @var Net_URL2 - */ - protected $url; - - /** - * Request method - * @var string - */ - protected $method = self::METHOD_GET; - - /** - * Authentication data - * @var array - * @see getAuth() - */ - protected $auth; - - /** - * Request headers - * @var array - */ - protected $headers = array(); - - /** - * Configuration parameters - * @var array - * @see setConfig() - */ - protected $config = array( - 'adapter' => 'HTTP_Request2_Adapter_Socket', - 'connect_timeout' => 10, - 'timeout' => 0, - 'use_brackets' => true, - 'protocol_version' => '1.1', - 'buffer_size' => 16384, - 'store_body' => true, - 'local_ip' => null, - - 'proxy_host' => '', - 'proxy_port' => '', - 'proxy_user' => '', - 'proxy_password' => '', - 'proxy_auth_scheme' => self::AUTH_BASIC, - 'proxy_type' => 'http', - - 'ssl_verify_peer' => true, - 'ssl_verify_host' => true, - 'ssl_cafile' => null, - 'ssl_capath' => null, - 'ssl_local_cert' => null, - 'ssl_passphrase' => null, - - 'digest_compat_ie' => false, - - 'follow_redirects' => false, - 'max_redirects' => 5, - 'strict_redirects' => false - ); - - /** - * Last event in request / response handling, intended for observers - * @var array - * @see getLastEvent() - */ - protected $lastEvent = array( - 'name' => 'start', - 'data' => null - ); - - /** - * Request body - * @var string|resource - * @see setBody() - */ - protected $body = ''; - - /** - * Array of POST parameters - * @var array - */ - protected $postParams = array(); - - /** - * Array of file uploads (for multipart/form-data POST requests) - * @var array - */ - protected $uploads = array(); - - /** - * Adapter used to perform actual HTTP request - * @var HTTP_Request2_Adapter - */ - protected $adapter; - - /** - * Cookie jar to persist cookies between requests - * @var HTTP_Request2_CookieJar - */ - protected $cookieJar = null; - - /** - * Constructor. Can set request URL, method and configuration array. - * - * Also sets a default value for User-Agent header. - * - * @param string|Net_Url2 $url Request URL - * @param string $method Request method - * @param array $config Configuration for this Request instance - */ - public function __construct( - $url = null, $method = self::METHOD_GET, array $config = array() - ) { - $this->setConfig($config); - if (!empty($url)) { - $this->setUrl($url); - } - if (!empty($method)) { - $this->setMethod($method); - } - $this->setHeader( - 'user-agent', 'HTTP_Request2/@package_version@ ' . - '(http://pear.php.net/package/http_request2) PHP/' . phpversion() - ); - } - - /** - * Sets the URL for this request - * - * If the URL has userinfo part (username & password) these will be removed - * and converted to auth data. If the URL does not have a path component, - * that will be set to '/'. - * - * @param string|Net_URL2 $url Request URL - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setUrl($url) - { - if (is_string($url)) { - $url = new Net_URL2( - $url, array(Net_URL2::OPTION_USE_BRACKETS => $this->config['use_brackets']) - ); - } - if (!$url instanceof Net_URL2) { - throw new HTTP_Request2_LogicException( - 'Parameter is not a valid HTTP URL', - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - // URL contains username / password? - if ($url->getUserinfo()) { - $username = $url->getUser(); - $password = $url->getPassword(); - $this->setAuth(rawurldecode($username), $password? rawurldecode($password): ''); - $url->setUserinfo(''); - } - if ('' == $url->getPath()) { - $url->setPath('/'); - } - $this->url = $url; - - return $this; - } - - /** - * Returns the request URL - * - * @return Net_URL2 - */ - public function getUrl() - { - return $this->url; - } - - /** - * Sets the request method - * - * @param string $method one of the methods defined in RFC 2616 - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException if the method name is invalid - */ - public function setMethod($method) - { - // Method name should be a token: http://tools.ietf.org/html/rfc2616#section-5.1.1 - if (preg_match(self::REGEXP_INVALID_TOKEN, $method)) { - throw new HTTP_Request2_LogicException( - "Invalid request method '{$method}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $this->method = $method; - - return $this; - } - - /** - * Returns the request method - * - * @return string - */ - public function getMethod() - { - return $this->method; - } - - /** - * Sets the configuration parameter(s) - * - * The following parameters are available: - *
    - *
  • 'adapter' - adapter to use (string)
  • - *
  • 'connect_timeout' - Connection timeout in seconds (integer)
  • - *
  • 'timeout' - Total number of seconds a request can take. - * Use 0 for no limit, should be greater than - * 'connect_timeout' if set (integer)
  • - *
  • 'use_brackets' - Whether to append [] to array variable names (bool)
  • - *
  • 'protocol_version' - HTTP Version to use, '1.0' or '1.1' (string)
  • - *
  • 'buffer_size' - Buffer size to use for reading and writing (int)
  • - *
  • 'store_body' - Whether to store response body in response object. - * Set to false if receiving a huge response and - * using an Observer to save it (boolean)
  • - *
  • 'local_ip' - Specifies the IP address that will be used for accessing - * the network (string)
  • - *
  • 'proxy_type' - Proxy type, 'http' or 'socks5' (string)
  • - *
  • 'proxy_host' - Proxy server host (string)
  • - *
  • 'proxy_port' - Proxy server port (integer)
  • - *
  • 'proxy_user' - Proxy auth username (string)
  • - *
  • 'proxy_password' - Proxy auth password (string)
  • - *
  • 'proxy_auth_scheme' - Proxy auth scheme, one of HTTP_Request2::AUTH_* constants (string)
  • - *
  • 'proxy' - Shorthand for proxy_* parameters, proxy given as URL, - * e.g. 'socks5://localhost:1080/' (string)
  • - *
  • 'ssl_verify_peer' - Whether to verify peer's SSL certificate (bool)
  • - *
  • 'ssl_verify_host' - Whether to check that Common Name in SSL - * certificate matches host name (bool)
  • - *
  • 'ssl_cafile' - Cerificate Authority file to verify the peer - * with (use with 'ssl_verify_peer') (string)
  • - *
  • 'ssl_capath' - Directory holding multiple Certificate - * Authority files (string)
  • - *
  • 'ssl_local_cert' - Name of a file containing local cerificate (string)
  • - *
  • 'ssl_passphrase' - Passphrase with which local certificate - * was encoded (string)
  • - *
  • 'digest_compat_ie' - Whether to imitate behaviour of MSIE 5 and 6 - * in using URL without query string in digest - * authentication (boolean)
  • - *
  • 'follow_redirects' - Whether to automatically follow HTTP Redirects (boolean)
  • - *
  • 'max_redirects' - Maximum number of redirects to follow (integer)
  • - *
  • 'strict_redirects' - Whether to keep request method on redirects via status 301 and - * 302 (true, needed for compatibility with RFC 2616) - * or switch to GET (false, needed for compatibility with most - * browsers) (boolean)
  • - *
- * - * @param string|array $nameOrConfig configuration parameter name or array - * ('parameter name' => 'parameter value') - * @param mixed $value parameter value if $nameOrConfig is not an array - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException If the parameter is unknown - */ - public function setConfig($nameOrConfig, $value = null) - { - if (is_array($nameOrConfig)) { - foreach ($nameOrConfig as $name => $value) { - $this->setConfig($name, $value); - } - - } elseif ('proxy' == $nameOrConfig) { - $url = new Net_URL2($value); - $this->setConfig(array( - 'proxy_type' => $url->getScheme(), - 'proxy_host' => $url->getHost(), - 'proxy_port' => $url->getPort(), - 'proxy_user' => rawurldecode($url->getUser()), - 'proxy_password' => rawurldecode($url->getPassword()) - )); - - } else { - if (!array_key_exists($nameOrConfig, $this->config)) { - throw new HTTP_Request2_LogicException( - "Unknown configuration parameter '{$nameOrConfig}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $this->config[$nameOrConfig] = $value; - } - - return $this; - } - - /** - * Returns the value(s) of the configuration parameter(s) - * - * @param string $name parameter name - * - * @return mixed value of $name parameter, array of all configuration - * parameters if $name is not given - * @throws HTTP_Request2_LogicException If the parameter is unknown - */ - public function getConfig($name = null) - { - if (null === $name) { - return $this->config; - } elseif (!array_key_exists($name, $this->config)) { - throw new HTTP_Request2_LogicException( - "Unknown configuration parameter '{$name}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - return $this->config[$name]; - } - - /** - * Sets the autentification data - * - * @param string $user user name - * @param string $password password - * @param string $scheme authentication scheme - * - * @return HTTP_Request2 - */ - public function setAuth($user, $password = '', $scheme = self::AUTH_BASIC) - { - if (empty($user)) { - $this->auth = null; - } else { - $this->auth = array( - 'user' => (string)$user, - 'password' => (string)$password, - 'scheme' => $scheme - ); - } - - return $this; - } - - /** - * Returns the authentication data - * - * The array has the keys 'user', 'password' and 'scheme', where 'scheme' - * is one of the HTTP_Request2::AUTH_* constants. - * - * @return array - */ - public function getAuth() - { - return $this->auth; - } - - /** - * Sets request header(s) - * - * The first parameter may be either a full header string 'header: value' or - * header name. In the former case $value parameter is ignored, in the latter - * the header's value will either be set to $value or the header will be - * removed if $value is null. The first parameter can also be an array of - * headers, in that case method will be called recursively. - * - * Note that headers are treated case insensitively as per RFC 2616. - * - * - * $req->setHeader('Foo: Bar'); // sets the value of 'Foo' header to 'Bar' - * $req->setHeader('FoO', 'Baz'); // sets the value of 'Foo' header to 'Baz' - * $req->setHeader(array('foo' => 'Quux')); // sets the value of 'Foo' header to 'Quux' - * $req->setHeader('FOO'); // removes 'Foo' header from request - * - * - * @param string|array $name header name, header string ('Header: value') - * or an array of headers - * @param string|array|null $value header value if $name is not an array, - * header will be removed if value is null - * @param bool $replace whether to replace previous header with the - * same name or append to its value - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setHeader($name, $value = null, $replace = true) - { - if (is_array($name)) { - foreach ($name as $k => $v) { - if (is_string($k)) { - $this->setHeader($k, $v, $replace); - } else { - $this->setHeader($v, null, $replace); - } - } - } else { - if (null === $value && strpos($name, ':')) { - list($name, $value) = array_map('trim', explode(':', $name, 2)); - } - // Header name should be a token: http://tools.ietf.org/html/rfc2616#section-4.2 - if (preg_match(self::REGEXP_INVALID_TOKEN, $name)) { - throw new HTTP_Request2_LogicException( - "Invalid header name '{$name}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - // Header names are case insensitive anyway - $name = strtolower($name); - if (null === $value) { - unset($this->headers[$name]); - - } else { - if (is_array($value)) { - $value = implode(', ', array_map('trim', $value)); - } elseif (is_string($value)) { - $value = trim($value); - } - if (!isset($this->headers[$name]) || $replace) { - $this->headers[$name] = $value; - } else { - $this->headers[$name] .= ', ' . $value; - } - } - } - - return $this; - } - - /** - * Returns the request headers - * - * The array is of the form ('header name' => 'header value'), header names - * are lowercased - * - * @return array - */ - public function getHeaders() - { - return $this->headers; - } - - /** - * Adds a cookie to the request - * - * If the request does not have a CookieJar object set, this method simply - * appends a cookie to "Cookie:" header. - * - * If a CookieJar object is available, the cookie is stored in that object. - * Data from request URL will be used for setting its 'domain' and 'path' - * parameters, 'expires' and 'secure' will be set to null and false, - * respectively. If you need further control, use CookieJar's methods. - * - * @param string $name cookie name - * @param string $value cookie value - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - * @see setCookieJar() - */ - public function addCookie($name, $value) - { - if (!empty($this->cookieJar)) { - $this->cookieJar->store( - array('name' => $name, 'value' => $value), $this->url - ); - - } else { - $cookie = $name . '=' . $value; - if (preg_match(self::REGEXP_INVALID_COOKIE, $cookie)) { - throw new HTTP_Request2_LogicException( - "Invalid cookie: '{$cookie}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $cookies = empty($this->headers['cookie'])? '': $this->headers['cookie'] . '; '; - $this->setHeader('cookie', $cookies . $cookie); - } - - return $this; - } - - /** - * Sets the request body - * - * If you provide file pointer rather than file name, it should support - * fstat() and rewind() operations. - * - * @param string|resource|HTTP_Request2_MultipartBody $body Either a - * string with the body or filename containing body or - * pointer to an open file or object with multipart body data - * @param bool $isFilename Whether - * first parameter is a filename - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setBody($body, $isFilename = false) - { - if (!$isFilename && !is_resource($body)) { - if (!$body instanceof HTTP_Request2_MultipartBody) { - $this->body = (string)$body; - } else { - $this->body = $body; - } - } else { - $fileData = $this->fopenWrapper($body, empty($this->headers['content-type'])); - $this->body = $fileData['fp']; - if (empty($this->headers['content-type'])) { - $this->setHeader('content-type', $fileData['type']); - } - } - $this->postParams = $this->uploads = array(); - - return $this; - } - - /** - * Returns the request body - * - * @return string|resource|HTTP_Request2_MultipartBody - */ - public function getBody() - { - if (self::METHOD_POST == $this->method - && (!empty($this->postParams) || !empty($this->uploads)) - ) { - if (0 === strpos($this->headers['content-type'], 'application/x-www-form-urlencoded')) { - $body = http_build_query($this->postParams, '', '&'); - if (!$this->getConfig('use_brackets')) { - $body = preg_replace('/%5B\d+%5D=/', '=', $body); - } - // support RFC 3986 by not encoding '~' symbol (request #15368) - return str_replace('%7E', '~', $body); - - } elseif (0 === strpos($this->headers['content-type'], 'multipart/form-data')) { - require_once 'HTTP/Request2/MultipartBody.php'; - return new HTTP_Request2_MultipartBody( - $this->postParams, $this->uploads, $this->getConfig('use_brackets') - ); - } - } - return $this->body; - } - - /** - * Adds a file to form-based file upload - * - * Used to emulate file upload via a HTML form. The method also sets - * Content-Type of HTTP request to 'multipart/form-data'. - * - * If you just want to send the contents of a file as the body of HTTP - * request you should use setBody() method. - * - * If you provide file pointers rather than file names, they should support - * fstat() and rewind() operations. - * - * @param string $fieldName name of file-upload field - * @param string|resource|array $filename full name of local file, - * pointer to open file or an array of files - * @param string $sendFilename filename to send in the request - * @param string $contentType content-type of file being uploaded - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function addUpload( - $fieldName, $filename, $sendFilename = null, $contentType = null - ) { - if (!is_array($filename)) { - $fileData = $this->fopenWrapper($filename, empty($contentType)); - $this->uploads[$fieldName] = array( - 'fp' => $fileData['fp'], - 'filename' => !empty($sendFilename)? $sendFilename - :(is_string($filename)? basename($filename): 'anonymous.blob') , - 'size' => $fileData['size'], - 'type' => empty($contentType)? $fileData['type']: $contentType - ); - } else { - $fps = $names = $sizes = $types = array(); - foreach ($filename as $f) { - if (!is_array($f)) { - $f = array($f); - } - $fileData = $this->fopenWrapper($f[0], empty($f[2])); - $fps[] = $fileData['fp']; - $names[] = !empty($f[1])? $f[1] - :(is_string($f[0])? basename($f[0]): 'anonymous.blob'); - $sizes[] = $fileData['size']; - $types[] = empty($f[2])? $fileData['type']: $f[2]; - } - $this->uploads[$fieldName] = array( - 'fp' => $fps, 'filename' => $names, 'size' => $sizes, 'type' => $types - ); - } - if (empty($this->headers['content-type']) - || 'application/x-www-form-urlencoded' == $this->headers['content-type'] - ) { - $this->setHeader('content-type', 'multipart/form-data'); - } - - return $this; - } - - /** - * Adds POST parameter(s) to the request. - * - * @param string|array $name parameter name or array ('name' => 'value') - * @param mixed $value parameter value (can be an array) - * - * @return HTTP_Request2 - */ - public function addPostParameter($name, $value = null) - { - if (!is_array($name)) { - $this->postParams[$name] = $value; - } else { - foreach ($name as $k => $v) { - $this->addPostParameter($k, $v); - } - } - if (empty($this->headers['content-type'])) { - $this->setHeader('content-type', 'application/x-www-form-urlencoded'); - } - - return $this; - } - - /** - * Attaches a new observer - * - * @param SplObserver $observer any object implementing SplObserver - */ - public function attach(SplObserver $observer) - { - foreach ($this->observers as $attached) { - if ($attached === $observer) { - return; - } - } - $this->observers[] = $observer; - } - - /** - * Detaches an existing observer - * - * @param SplObserver $observer any object implementing SplObserver - */ - public function detach(SplObserver $observer) - { - foreach ($this->observers as $key => $attached) { - if ($attached === $observer) { - unset($this->observers[$key]); - return; - } - } - } - - /** - * Notifies all observers - */ - public function notify() - { - foreach ($this->observers as $observer) { - $observer->update($this); - } - } - - /** - * Sets the last event - * - * Adapters should use this method to set the current state of the request - * and notify the observers. - * - * @param string $name event name - * @param mixed $data event data - */ - public function setLastEvent($name, $data = null) - { - $this->lastEvent = array( - 'name' => $name, - 'data' => $data - ); - $this->notify(); - } - - /** - * Returns the last event - * - * Observers should use this method to access the last change in request. - * The following event names are possible: - *
    - *
  • 'connect' - after connection to remote server, - * data is the destination (string)
  • - *
  • 'disconnect' - after disconnection from server
  • - *
  • 'sentHeaders' - after sending the request headers, - * data is the headers sent (string)
  • - *
  • 'sentBodyPart' - after sending a part of the request body, - * data is the length of that part (int)
  • - *
  • 'sentBody' - after sending the whole request body, - * data is request body length (int)
  • - *
  • 'receivedHeaders' - after receiving the response headers, - * data is HTTP_Request2_Response object
  • - *
  • 'receivedBodyPart' - after receiving a part of the response - * body, data is that part (string)
  • - *
  • 'receivedEncodedBodyPart' - as 'receivedBodyPart', but data is still - * encoded by Content-Encoding
  • - *
  • 'receivedBody' - after receiving the complete response - * body, data is HTTP_Request2_Response object
  • - *
- * Different adapters may not send all the event types. Mock adapter does - * not send any events to the observers. - * - * @return array The array has two keys: 'name' and 'data' - */ - public function getLastEvent() - { - return $this->lastEvent; - } - - /** - * Sets the adapter used to actually perform the request - * - * You can pass either an instance of a class implementing HTTP_Request2_Adapter - * or a class name. The method will only try to include a file if the class - * name starts with HTTP_Request2_Adapter_, it will also try to prepend this - * prefix to the class name if it doesn't contain any underscores, so that - * - * $request->setAdapter('curl'); - * - * will work. - * - * @param string|HTTP_Request2_Adapter $adapter Adapter to use - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setAdapter($adapter) - { - if (is_string($adapter)) { - if (!class_exists($adapter, false)) { - if (false === strpos($adapter, '_')) { - $adapter = 'HTTP_Request2_Adapter_' . ucfirst($adapter); - } - if (!class_exists($adapter, false) - && preg_match('/^HTTP_Request2_Adapter_([a-zA-Z0-9]+)$/', $adapter) - ) { - include_once str_replace('_', DIRECTORY_SEPARATOR, $adapter) . '.php'; - } - if (!class_exists($adapter, false)) { - throw new HTTP_Request2_LogicException( - "Class {$adapter} not found", - HTTP_Request2_Exception::MISSING_VALUE - ); - } - } - $adapter = new $adapter; - } - if (!$adapter instanceof HTTP_Request2_Adapter) { - throw new HTTP_Request2_LogicException( - 'Parameter is not a HTTP request adapter', - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $this->adapter = $adapter; - - return $this; - } - - /** - * Sets the cookie jar - * - * A cookie jar is used to maintain cookies across HTTP requests and - * responses. Cookies from jar will be automatically added to the request - * headers based on request URL. - * - * @param HTTP_Request2_CookieJar|bool $jar Existing CookieJar object, true to - * create a new one, false to remove - * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - */ - public function setCookieJar($jar = true) - { - if (!class_exists('HTTP_Request2_CookieJar', false)) { - require_once 'HTTP/Request2/CookieJar.php'; - } - - if ($jar instanceof HTTP_Request2_CookieJar) { - $this->cookieJar = $jar; - } elseif (true === $jar) { - $this->cookieJar = new HTTP_Request2_CookieJar(); - } elseif (!$jar) { - $this->cookieJar = null; - } else { - throw new HTTP_Request2_LogicException( - 'Invalid parameter passed to setCookieJar()', - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - - return $this; - } - - /** - * Returns current CookieJar object or null if none - * - * @return HTTP_Request2_CookieJar|null - */ - public function getCookieJar() - { - return $this->cookieJar; - } - - /** - * Sends the request and returns the response - * - * @throws HTTP_Request2_Exception - * @return HTTP_Request2_Response - */ - public function send() - { - // Sanity check for URL - if (!$this->url instanceof Net_URL2 - || !$this->url->isAbsolute() - || !in_array(strtolower($this->url->getScheme()), array('https', 'http')) - ) { - throw new HTTP_Request2_LogicException( - 'HTTP_Request2 needs an absolute HTTP(S) request URL, ' - . ($this->url instanceof Net_URL2 - ? "'" . $this->url->__toString() . "'" : 'none') - . ' given', - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - if (empty($this->adapter)) { - $this->setAdapter($this->getConfig('adapter')); - } - // magic_quotes_runtime may break file uploads and chunked response - // processing; see bug #4543. Don't use ini_get() here; see bug #16440. - if ($magicQuotes = get_magic_quotes_runtime()) { - set_magic_quotes_runtime(false); - } - // force using single byte encoding if mbstring extension overloads - // strlen() and substr(); see bug #1781, bug #10605 - if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { - $oldEncoding = mb_internal_encoding(); - mb_internal_encoding('8bit'); - } - - try { - $response = $this->adapter->sendRequest($this); - } catch (Exception $e) { - } - // cleanup in either case (poor man's "finally" clause) - if ($magicQuotes) { - set_magic_quotes_runtime(true); - } - if (!empty($oldEncoding)) { - mb_internal_encoding($oldEncoding); - } - // rethrow the exception - if (!empty($e)) { - throw $e; - } - return $response; - } - - /** - * Wrapper around fopen()/fstat() used by setBody() and addUpload() - * - * @param string|resource $file file name or pointer to open file - * @param bool $detectType whether to try autodetecting MIME - * type of file, will only work if $file is a - * filename, not pointer - * - * @return array array('fp' => file pointer, 'size' => file size, 'type' => MIME type) - * @throws HTTP_Request2_LogicException - */ - protected function fopenWrapper($file, $detectType = false) - { - if (!is_string($file) && !is_resource($file)) { - throw new HTTP_Request2_LogicException( - "Filename or file pointer resource expected", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $fileData = array( - 'fp' => is_string($file)? null: $file, - 'type' => 'application/octet-stream', - 'size' => 0 - ); - if (is_string($file)) { - if (!($fileData['fp'] = @fopen($file, 'rb'))) { - $error = error_get_last(); - throw new HTTP_Request2_LogicException( - $error['message'], HTTP_Request2_Exception::READ_ERROR - ); - } - if ($detectType) { - $fileData['type'] = self::detectMimeType($file); - } - } - if (!($stat = fstat($fileData['fp']))) { - throw new HTTP_Request2_LogicException( - "fstat() call failed", HTTP_Request2_Exception::READ_ERROR - ); - } - $fileData['size'] = $stat['size']; - - return $fileData; - } - - /** - * Tries to detect MIME type of a file - * - * The method will try to use fileinfo extension if it is available, - * deprecated mime_content_type() function in the other case. If neither - * works, default 'application/octet-stream' MIME type is returned - * - * @param string $filename file name - * - * @return string file MIME type - */ - protected static function detectMimeType($filename) - { - // finfo extension from PECL available - if (function_exists('finfo_open')) { - if (!isset(self::$_fileinfoDb)) { - self::$_fileinfoDb = @finfo_open(FILEINFO_MIME); - } - if (self::$_fileinfoDb) { - $info = finfo_file(self::$_fileinfoDb, $filename); - } - } - // (deprecated) mime_content_type function available - if (empty($info) && function_exists('mime_content_type')) { - return mime_content_type($filename); - } - return empty($info)? 'application/octet-stream': $info; - } -} -?> diff --git a/vendor/pear/http_request2/HTTP/Request2/Adapter.php b/vendor/pear/http_request2/HTTP/Request2/Adapter.php deleted file mode 100644 index 01c796a06..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/Adapter.php +++ /dev/null @@ -1,137 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Class representing a HTTP response - */ -require_once 'HTTP/Request2/Response.php'; - -/** - * Base class for HTTP_Request2 adapters - * - * HTTP_Request2 class itself only defines methods for aggregating the request - * data, all actual work of sending the request to the remote server and - * receiving its response is performed by adapters. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -abstract class HTTP_Request2_Adapter -{ - /** - * A list of methods that MUST NOT have a request body, per RFC 2616 - * @var array - */ - protected static $bodyDisallowed = array('TRACE'); - - /** - * Methods having defined semantics for request body - * - * Content-Length header (indicating that the body follows, section 4.3 of - * RFC 2616) will be sent for these methods even if no body was added - * - * @var array - * @link http://pear.php.net/bugs/bug.php?id=12900 - * @link http://pear.php.net/bugs/bug.php?id=14740 - */ - protected static $bodyRequired = array('POST', 'PUT'); - - /** - * Request being sent - * @var HTTP_Request2 - */ - protected $request; - - /** - * Request body - * @var string|resource|HTTP_Request2_MultipartBody - * @see HTTP_Request2::getBody() - */ - protected $requestBody; - - /** - * Length of the request body - * @var integer - */ - protected $contentLength; - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - abstract public function sendRequest(HTTP_Request2 $request); - - /** - * Calculates length of the request body, adds proper headers - * - * @param array &$headers associative array of request headers, this method - * will add proper 'Content-Length' and 'Content-Type' - * headers to this array (or remove them if not needed) - */ - protected function calculateRequestLength(&$headers) - { - $this->requestBody = $this->request->getBody(); - - if (is_string($this->requestBody)) { - $this->contentLength = strlen($this->requestBody); - } elseif (is_resource($this->requestBody)) { - $stat = fstat($this->requestBody); - $this->contentLength = $stat['size']; - rewind($this->requestBody); - } else { - $this->contentLength = $this->requestBody->getLength(); - $headers['content-type'] = 'multipart/form-data; boundary=' . - $this->requestBody->getBoundary(); - $this->requestBody->rewind(); - } - - if (in_array($this->request->getMethod(), self::$bodyDisallowed) - || 0 == $this->contentLength - ) { - // No body: send a Content-Length header nonetheless (request #12900), - // but do that only for methods that require a body (bug #14740) - if (in_array($this->request->getMethod(), self::$bodyRequired)) { - $headers['content-length'] = 0; - } else { - unset($headers['content-length']); - // if the method doesn't require a body and doesn't have a - // body, don't send a Content-Type header. (request #16799) - unset($headers['content-type']); - } - } else { - if (empty($headers['content-type'])) { - $headers['content-type'] = 'application/x-www-form-urlencoded'; - } - // Content-Length should not be sent for chunked Transfer-Encoding (bug #20125) - if (!isset($headers['transfer-encoding'])) { - $headers['content-length'] = $this->contentLength; - } - } - } -} -?> diff --git a/vendor/pear/http_request2/HTTP/Request2/Adapter/Curl.php b/vendor/pear/http_request2/HTTP/Request2/Adapter/Curl.php deleted file mode 100644 index 777135921..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/Adapter/Curl.php +++ /dev/null @@ -1,567 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for HTTP_Request2 adapters - */ -require_once 'HTTP/Request2/Adapter.php'; - -/** - * Adapter for HTTP_Request2 wrapping around cURL extension - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter -{ - /** - * Mapping of header names to cURL options - * @var array - */ - protected static $headerMap = array( - 'accept-encoding' => CURLOPT_ENCODING, - 'cookie' => CURLOPT_COOKIE, - 'referer' => CURLOPT_REFERER, - 'user-agent' => CURLOPT_USERAGENT - ); - - /** - * Mapping of SSL context options to cURL options - * @var array - */ - protected static $sslContextMap = array( - 'ssl_verify_peer' => CURLOPT_SSL_VERIFYPEER, - 'ssl_cafile' => CURLOPT_CAINFO, - 'ssl_capath' => CURLOPT_CAPATH, - 'ssl_local_cert' => CURLOPT_SSLCERT, - 'ssl_passphrase' => CURLOPT_SSLCERTPASSWD - ); - - /** - * Mapping of CURLE_* constants to Exception subclasses and error codes - * @var array - */ - protected static $errorMap = array( - CURLE_UNSUPPORTED_PROTOCOL => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::NON_HTTP_REDIRECT), - CURLE_COULDNT_RESOLVE_PROXY => array('HTTP_Request2_ConnectionException'), - CURLE_COULDNT_RESOLVE_HOST => array('HTTP_Request2_ConnectionException'), - CURLE_COULDNT_CONNECT => array('HTTP_Request2_ConnectionException'), - // error returned from write callback - CURLE_WRITE_ERROR => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::NON_HTTP_REDIRECT), - CURLE_OPERATION_TIMEOUTED => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::TIMEOUT), - CURLE_HTTP_RANGE_ERROR => array('HTTP_Request2_MessageException'), - CURLE_SSL_CONNECT_ERROR => array('HTTP_Request2_ConnectionException'), - CURLE_LIBRARY_NOT_FOUND => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_FUNCTION_NOT_FOUND => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_ABORTED_BY_CALLBACK => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::NON_HTTP_REDIRECT), - CURLE_TOO_MANY_REDIRECTS => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::TOO_MANY_REDIRECTS), - CURLE_SSL_PEER_CERTIFICATE => array('HTTP_Request2_ConnectionException'), - CURLE_GOT_NOTHING => array('HTTP_Request2_MessageException'), - CURLE_SSL_ENGINE_NOTFOUND => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_SSL_ENGINE_SETFAILED => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_SEND_ERROR => array('HTTP_Request2_MessageException'), - CURLE_RECV_ERROR => array('HTTP_Request2_MessageException'), - CURLE_SSL_CERTPROBLEM => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::INVALID_ARGUMENT), - CURLE_SSL_CIPHER => array('HTTP_Request2_ConnectionException'), - CURLE_SSL_CACERT => array('HTTP_Request2_ConnectionException'), - CURLE_BAD_CONTENT_ENCODING => array('HTTP_Request2_MessageException'), - ); - - /** - * Response being received - * @var HTTP_Request2_Response - */ - protected $response; - - /** - * Whether 'sentHeaders' event was sent to observers - * @var boolean - */ - protected $eventSentHeaders = false; - - /** - * Whether 'receivedHeaders' event was sent to observers - * @var boolean - */ - protected $eventReceivedHeaders = false; - - /** - * Position within request body - * @var integer - * @see callbackReadBody() - */ - protected $position = 0; - - /** - * Information about last transfer, as returned by curl_getinfo() - * @var array - */ - protected $lastInfo; - - /** - * Creates a subclass of HTTP_Request2_Exception from curl error data - * - * @param resource $ch curl handle - * - * @return HTTP_Request2_Exception - */ - protected static function wrapCurlError($ch) - { - $nativeCode = curl_errno($ch); - $message = 'Curl error: ' . curl_error($ch); - if (!isset(self::$errorMap[$nativeCode])) { - return new HTTP_Request2_Exception($message, 0, $nativeCode); - } else { - $class = self::$errorMap[$nativeCode][0]; - $code = empty(self::$errorMap[$nativeCode][1]) - ? 0 : self::$errorMap[$nativeCode][1]; - return new $class($message, $code, $nativeCode); - } - } - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - if (!extension_loaded('curl')) { - throw new HTTP_Request2_LogicException( - 'cURL extension not available', HTTP_Request2_Exception::MISCONFIGURATION - ); - } - - $this->request = $request; - $this->response = null; - $this->position = 0; - $this->eventSentHeaders = false; - $this->eventReceivedHeaders = false; - - try { - if (false === curl_exec($ch = $this->createCurlHandle())) { - $e = self::wrapCurlError($ch); - } - } catch (Exception $e) { - } - if (isset($ch)) { - $this->lastInfo = curl_getinfo($ch); - curl_close($ch); - } - - $response = $this->response; - unset($this->request, $this->requestBody, $this->response); - - if (!empty($e)) { - throw $e; - } - - if ($jar = $request->getCookieJar()) { - $jar->addCookiesFromResponse($response, $request->getUrl()); - } - - if (0 < $this->lastInfo['size_download']) { - $request->setLastEvent('receivedBody', $response); - } - return $response; - } - - /** - * Returns information about last transfer - * - * @return array associative array as returned by curl_getinfo() - */ - public function getInfo() - { - return $this->lastInfo; - } - - /** - * Creates a new cURL handle and populates it with data from the request - * - * @return resource a cURL handle, as created by curl_init() - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_NotImplementedException - */ - protected function createCurlHandle() - { - $ch = curl_init(); - - curl_setopt_array($ch, array( - // setup write callbacks - CURLOPT_HEADERFUNCTION => array($this, 'callbackWriteHeader'), - CURLOPT_WRITEFUNCTION => array($this, 'callbackWriteBody'), - // buffer size - CURLOPT_BUFFERSIZE => $this->request->getConfig('buffer_size'), - // connection timeout - CURLOPT_CONNECTTIMEOUT => $this->request->getConfig('connect_timeout'), - // save full outgoing headers, in case someone is interested - CURLINFO_HEADER_OUT => true, - // request url - CURLOPT_URL => $this->request->getUrl()->getUrl() - )); - - // set up redirects - if (!$this->request->getConfig('follow_redirects')) { - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); - } else { - if (!@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true)) { - throw new HTTP_Request2_LogicException( - 'Redirect support in curl is unavailable due to open_basedir or safe_mode setting', - HTTP_Request2_Exception::MISCONFIGURATION - ); - } - curl_setopt($ch, CURLOPT_MAXREDIRS, $this->request->getConfig('max_redirects')); - // limit redirects to http(s), works in 5.2.10+ - if (defined('CURLOPT_REDIR_PROTOCOLS')) { - curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); - } - // works in 5.3.2+, http://bugs.php.net/bug.php?id=49571 - if ($this->request->getConfig('strict_redirects') && defined('CURLOPT_POSTREDIR')) { - curl_setopt($ch, CURLOPT_POSTREDIR, 3); - } - } - - // set local IP via CURLOPT_INTERFACE (request #19515) - if ($ip = $this->request->getConfig('local_ip')) { - curl_setopt($ch, CURLOPT_INTERFACE, $ip); - } - - // request timeout - if ($timeout = $this->request->getConfig('timeout')) { - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); - } - - // set HTTP version - switch ($this->request->getConfig('protocol_version')) { - case '1.0': - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); - break; - case '1.1': - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); - } - - // set request method - switch ($this->request->getMethod()) { - case HTTP_Request2::METHOD_GET: - curl_setopt($ch, CURLOPT_HTTPGET, true); - break; - case HTTP_Request2::METHOD_POST: - curl_setopt($ch, CURLOPT_POST, true); - break; - case HTTP_Request2::METHOD_HEAD: - curl_setopt($ch, CURLOPT_NOBODY, true); - break; - case HTTP_Request2::METHOD_PUT: - curl_setopt($ch, CURLOPT_UPLOAD, true); - break; - default: - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->request->getMethod()); - } - - // set proxy, if needed - if ($host = $this->request->getConfig('proxy_host')) { - if (!($port = $this->request->getConfig('proxy_port'))) { - throw new HTTP_Request2_LogicException( - 'Proxy port not provided', HTTP_Request2_Exception::MISSING_VALUE - ); - } - curl_setopt($ch, CURLOPT_PROXY, $host . ':' . $port); - if ($user = $this->request->getConfig('proxy_user')) { - curl_setopt( - $ch, CURLOPT_PROXYUSERPWD, - $user . ':' . $this->request->getConfig('proxy_password') - ); - switch ($this->request->getConfig('proxy_auth_scheme')) { - case HTTP_Request2::AUTH_BASIC: - curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); - break; - case HTTP_Request2::AUTH_DIGEST: - curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST); - } - } - if ($type = $this->request->getConfig('proxy_type')) { - switch ($type) { - case 'http': - curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); - break; - case 'socks5': - curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); - break; - default: - throw new HTTP_Request2_NotImplementedException( - "Proxy type '{$type}' is not supported" - ); - } - } - } - - // set authentication data - if ($auth = $this->request->getAuth()) { - curl_setopt($ch, CURLOPT_USERPWD, $auth['user'] . ':' . $auth['password']); - switch ($auth['scheme']) { - case HTTP_Request2::AUTH_BASIC: - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - break; - case HTTP_Request2::AUTH_DIGEST: - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); - } - } - - // set SSL options - foreach ($this->request->getConfig() as $name => $value) { - if ('ssl_verify_host' == $name && null !== $value) { - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $value? 2: 0); - } elseif (isset(self::$sslContextMap[$name]) && null !== $value) { - curl_setopt($ch, self::$sslContextMap[$name], $value); - } - } - - $headers = $this->request->getHeaders(); - // make cURL automagically send proper header - if (!isset($headers['accept-encoding'])) { - $headers['accept-encoding'] = ''; - } - - if (($jar = $this->request->getCookieJar()) - && ($cookies = $jar->getMatching($this->request->getUrl(), true)) - ) { - $headers['cookie'] = (empty($headers['cookie'])? '': $headers['cookie'] . '; ') . $cookies; - } - - // set headers having special cURL keys - foreach (self::$headerMap as $name => $option) { - if (isset($headers[$name])) { - curl_setopt($ch, $option, $headers[$name]); - unset($headers[$name]); - } - } - - $this->calculateRequestLength($headers); - if (isset($headers['content-length']) || isset($headers['transfer-encoding'])) { - $this->workaroundPhpBug47204($ch, $headers); - } - - // set headers not having special keys - $headersFmt = array(); - foreach ($headers as $name => $value) { - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - $headersFmt[] = $canonicalName . ': ' . $value; - } - curl_setopt($ch, CURLOPT_HTTPHEADER, $headersFmt); - - return $ch; - } - - /** - * Workaround for PHP bug #47204 that prevents rewinding request body - * - * The workaround consists of reading the entire request body into memory - * and setting it as CURLOPT_POSTFIELDS, so it isn't recommended for large - * file uploads, use Socket adapter instead. - * - * @param resource $ch cURL handle - * @param array &$headers Request headers - */ - protected function workaroundPhpBug47204($ch, &$headers) - { - // no redirects, no digest auth -> probably no rewind needed - if (!$this->request->getConfig('follow_redirects') - && (!($auth = $this->request->getAuth()) - || HTTP_Request2::AUTH_DIGEST != $auth['scheme']) - ) { - curl_setopt($ch, CURLOPT_READFUNCTION, array($this, 'callbackReadBody')); - - } else { - // rewind may be needed, read the whole body into memory - if ($this->requestBody instanceof HTTP_Request2_MultipartBody) { - $this->requestBody = $this->requestBody->__toString(); - - } elseif (is_resource($this->requestBody)) { - $fp = $this->requestBody; - $this->requestBody = ''; - while (!feof($fp)) { - $this->requestBody .= fread($fp, 16384); - } - } - // curl hangs up if content-length is present - unset($headers['content-length']); - curl_setopt($ch, CURLOPT_POSTFIELDS, $this->requestBody); - } - } - - /** - * Callback function called by cURL for reading the request body - * - * @param resource $ch cURL handle - * @param resource $fd file descriptor (not used) - * @param integer $length maximum length of data to return - * - * @return string part of the request body, up to $length bytes - */ - protected function callbackReadBody($ch, $fd, $length) - { - if (!$this->eventSentHeaders) { - $this->request->setLastEvent( - 'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT) - ); - $this->eventSentHeaders = true; - } - if (in_array($this->request->getMethod(), self::$bodyDisallowed) - || 0 == $this->contentLength || $this->position >= $this->contentLength - ) { - return ''; - } - if (is_string($this->requestBody)) { - $string = substr($this->requestBody, $this->position, $length); - } elseif (is_resource($this->requestBody)) { - $string = fread($this->requestBody, $length); - } else { - $string = $this->requestBody->read($length); - } - $this->request->setLastEvent('sentBodyPart', strlen($string)); - $this->position += strlen($string); - return $string; - } - - /** - * Callback function called by cURL for saving the response headers - * - * @param resource $ch cURL handle - * @param string $string response header (with trailing CRLF) - * - * @return integer number of bytes saved - * @see HTTP_Request2_Response::parseHeaderLine() - */ - protected function callbackWriteHeader($ch, $string) - { - // we may receive a second set of headers if doing e.g. digest auth - if ($this->eventReceivedHeaders || !$this->eventSentHeaders) { - // don't bother with 100-Continue responses (bug #15785) - if (!$this->eventSentHeaders - || $this->response->getStatus() >= 200 - ) { - $this->request->setLastEvent( - 'sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT) - ); - } - $upload = curl_getinfo($ch, CURLINFO_SIZE_UPLOAD); - // if body wasn't read by a callback, send event with total body size - if ($upload > $this->position) { - $this->request->setLastEvent( - 'sentBodyPart', $upload - $this->position - ); - $this->position = $upload; - } - if ($upload && (!$this->eventSentHeaders - || $this->response->getStatus() >= 200) - ) { - $this->request->setLastEvent('sentBody', $upload); - } - $this->eventSentHeaders = true; - // we'll need a new response object - if ($this->eventReceivedHeaders) { - $this->eventReceivedHeaders = false; - $this->response = null; - } - } - if (empty($this->response)) { - $this->response = new HTTP_Request2_Response( - $string, false, curl_getinfo($ch, CURLINFO_EFFECTIVE_URL) - ); - } else { - $this->response->parseHeaderLine($string); - if ('' == trim($string)) { - // don't bother with 100-Continue responses (bug #15785) - if (200 <= $this->response->getStatus()) { - $this->request->setLastEvent('receivedHeaders', $this->response); - } - - if ($this->request->getConfig('follow_redirects') && $this->response->isRedirect()) { - $redirectUrl = new Net_URL2($this->response->getHeader('location')); - - // for versions lower than 5.2.10, check the redirection URL protocol - if (!defined('CURLOPT_REDIR_PROTOCOLS') && $redirectUrl->isAbsolute() - && !in_array($redirectUrl->getScheme(), array('http', 'https')) - ) { - return -1; - } - - if ($jar = $this->request->getCookieJar()) { - $jar->addCookiesFromResponse($this->response, $this->request->getUrl()); - if (!$redirectUrl->isAbsolute()) { - $redirectUrl = $this->request->getUrl()->resolve($redirectUrl); - } - if ($cookies = $jar->getMatching($redirectUrl, true)) { - curl_setopt($ch, CURLOPT_COOKIE, $cookies); - } - } - } - $this->eventReceivedHeaders = true; - } - } - return strlen($string); - } - - /** - * Callback function called by cURL for saving the response body - * - * @param resource $ch cURL handle (not used) - * @param string $string part of the response body - * - * @return integer number of bytes saved - * @throws HTTP_Request2_MessageException - * @see HTTP_Request2_Response::appendBody() - */ - protected function callbackWriteBody($ch, $string) - { - // cURL calls WRITEFUNCTION callback without calling HEADERFUNCTION if - // response doesn't start with proper HTTP status line (see bug #15716) - if (empty($this->response)) { - throw new HTTP_Request2_MessageException( - "Malformed response: {$string}", - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } - if ($this->request->getConfig('store_body')) { - $this->response->appendBody($string); - } - $this->request->setLastEvent('receivedBodyPart', $string); - return strlen($string); - } -} -?> diff --git a/vendor/pear/http_request2/HTTP/Request2/Adapter/Mock.php b/vendor/pear/http_request2/HTTP/Request2/Adapter/Mock.php deleted file mode 100644 index aeaf3eeb7..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/Adapter/Mock.php +++ /dev/null @@ -1,166 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for HTTP_Request2 adapters - */ -require_once 'HTTP/Request2/Adapter.php'; - -/** - * Mock adapter intended for testing - * - * Can be used to test applications depending on HTTP_Request2 package without - * actually performing any HTTP requests. This adapter will return responses - * previously added via addResponse() - * - * $mock = new HTTP_Request2_Adapter_Mock(); - * $mock->addResponse("HTTP/1.1 ... "); - * - * $request = new HTTP_Request2(); - * $request->setAdapter($mock); - * - * // This will return the response set above - * $response = $req->send(); - * - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter -{ - /** - * A queue of responses to be returned by sendRequest() - * @var array - */ - protected $responses = array(); - - /** - * Returns the next response from the queue built by addResponse() - * - * Only responses without explicit URLs or with URLs equal to request URL - * will be considered. If matching response is not found or the queue is - * empty then default empty response with status 400 will be returned, - * if an Exception object was added to the queue it will be thrown. - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - $requestUrl = (string)$request->getUrl(); - $response = null; - foreach ($this->responses as $k => $v) { - if (!$v[1] || $requestUrl == $v[1]) { - $response = $v[0]; - array_splice($this->responses, $k, 1); - break; - } - } - if (!$response) { - return self::createResponseFromString("HTTP/1.1 400 Bad Request\r\n\r\n"); - - } elseif ($response instanceof HTTP_Request2_Response) { - return $response; - - } else { - // rethrow the exception - $class = get_class($response); - $message = $response->getMessage(); - $code = $response->getCode(); - throw new $class($message, $code); - } - } - - /** - * Adds response to the queue - * - * @param mixed $response either a string, a pointer to an open file, - * an instance of HTTP_Request2_Response or Exception - * @param string $url A request URL this response should be valid for - * (see {@link http://pear.php.net/bugs/bug.php?id=19276}) - * - * @throws HTTP_Request2_Exception - */ - public function addResponse($response, $url = null) - { - if (is_string($response)) { - $response = self::createResponseFromString($response); - } elseif (is_resource($response)) { - $response = self::createResponseFromFile($response); - } elseif (!$response instanceof HTTP_Request2_Response && - !$response instanceof Exception - ) { - throw new HTTP_Request2_Exception('Parameter is not a valid response'); - } - $this->responses[] = array($response, $url); - } - - /** - * Creates a new HTTP_Request2_Response object from a string - * - * @param string $str string containing HTTP response message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public static function createResponseFromString($str) - { - $parts = preg_split('!(\r?\n){2}!m', $str, 2); - $headerLines = explode("\n", $parts[0]); - $response = new HTTP_Request2_Response(array_shift($headerLines)); - foreach ($headerLines as $headerLine) { - $response->parseHeaderLine($headerLine); - } - $response->parseHeaderLine(''); - if (isset($parts[1])) { - $response->appendBody($parts[1]); - } - return $response; - } - - /** - * Creates a new HTTP_Request2_Response object from a file - * - * @param resource $fp file pointer returned by fopen() - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public static function createResponseFromFile($fp) - { - $response = new HTTP_Request2_Response(fgets($fp)); - do { - $headerLine = fgets($fp); - $response->parseHeaderLine($headerLine); - } while ('' != trim($headerLine)); - - while (!feof($fp)) { - $response->appendBody(fread($fp, 8192)); - } - return $response; - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/Adapter/Socket.php b/vendor/pear/http_request2/HTTP/Request2/Adapter/Socket.php deleted file mode 100644 index f18c4f5b3..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/Adapter/Socket.php +++ /dev/null @@ -1,1121 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Base class for HTTP_Request2 adapters */ -require_once 'HTTP/Request2/Adapter.php'; - -/** Socket wrapper class */ -require_once 'HTTP/Request2/SocketWrapper.php'; - -/** - * Socket-based adapter for HTTP_Request2 - * - * This adapter uses only PHP sockets and will work on almost any PHP - * environment. Code is based on original HTTP_Request PEAR package. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter -{ - /** - * Regular expression for 'token' rule from RFC 2616 - */ - const REGEXP_TOKEN = '[^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+'; - - /** - * Regular expression for 'quoted-string' rule from RFC 2616 - */ - const REGEXP_QUOTED_STRING = '"(?>[^"\\\\]+|\\\\.)*"'; - - /** - * Connected sockets, needed for Keep-Alive support - * @var array - * @see connect() - */ - protected static $sockets = array(); - - /** - * Data for digest authentication scheme - * - * The keys for the array are URL prefixes. - * - * The values are associative arrays with data (realm, nonce, nonce-count, - * opaque...) needed for digest authentication. Stored here to prevent making - * duplicate requests to digest-protected resources after we have already - * received the challenge. - * - * @var array - */ - protected static $challenges = array(); - - /** - * Connected socket - * @var HTTP_Request2_SocketWrapper - * @see connect() - */ - protected $socket; - - /** - * Challenge used for server digest authentication - * @var array - */ - protected $serverChallenge; - - /** - * Challenge used for proxy digest authentication - * @var array - */ - protected $proxyChallenge; - - /** - * Remaining length of the current chunk, when reading chunked response - * @var integer - * @see readChunked() - */ - protected $chunkLength = 0; - - /** - * Remaining amount of redirections to follow - * - * Starts at 'max_redirects' configuration parameter and is reduced on each - * subsequent redirect. An Exception will be thrown once it reaches zero. - * - * @var integer - */ - protected $redirectCountdown = null; - - /** - * Whether to wait for "100 Continue" response before sending request body - * @var bool - */ - protected $expect100Continue = false; - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - $this->request = $request; - - try { - $keepAlive = $this->connect(); - $headers = $this->prepareHeaders(); - $this->socket->write($headers); - // provide request headers to the observer, see request #7633 - $this->request->setLastEvent('sentHeaders', $headers); - - if (!$this->expect100Continue) { - $this->writeBody(); - $response = $this->readResponse(); - - } else { - $response = $this->readResponse(); - if (!$response || 100 == $response->getStatus()) { - $this->expect100Continue = false; - // either got "100 Continue" or timed out -> send body - $this->writeBody(); - $response = $this->readResponse(); - } - } - - - if ($jar = $request->getCookieJar()) { - $jar->addCookiesFromResponse($response, $request->getUrl()); - } - - if (!$this->canKeepAlive($keepAlive, $response)) { - $this->disconnect(); - } - - if ($this->shouldUseProxyDigestAuth($response)) { - return $this->sendRequest($request); - } - if ($this->shouldUseServerDigestAuth($response)) { - return $this->sendRequest($request); - } - if ($authInfo = $response->getHeader('authentication-info')) { - $this->updateChallenge($this->serverChallenge, $authInfo); - } - if ($proxyInfo = $response->getHeader('proxy-authentication-info')) { - $this->updateChallenge($this->proxyChallenge, $proxyInfo); - } - - } catch (Exception $e) { - $this->disconnect(); - } - - unset($this->request, $this->requestBody); - - if (!empty($e)) { - $this->redirectCountdown = null; - throw $e; - } - - if (!$request->getConfig('follow_redirects') || !$response->isRedirect()) { - $this->redirectCountdown = null; - return $response; - } else { - return $this->handleRedirect($request, $response); - } - } - - /** - * Connects to the remote server - * - * @return bool whether the connection can be persistent - * @throws HTTP_Request2_Exception - */ - protected function connect() - { - $secure = 0 == strcasecmp($this->request->getUrl()->getScheme(), 'https'); - $tunnel = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod(); - $headers = $this->request->getHeaders(); - $reqHost = $this->request->getUrl()->getHost(); - if (!($reqPort = $this->request->getUrl()->getPort())) { - $reqPort = $secure? 443: 80; - } - - $httpProxy = $socksProxy = false; - if (!($host = $this->request->getConfig('proxy_host'))) { - $host = $reqHost; - $port = $reqPort; - } else { - if (!($port = $this->request->getConfig('proxy_port'))) { - throw new HTTP_Request2_LogicException( - 'Proxy port not provided', - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if ('http' == ($type = $this->request->getConfig('proxy_type'))) { - $httpProxy = true; - } elseif ('socks5' == $type) { - $socksProxy = true; - } else { - throw new HTTP_Request2_NotImplementedException( - "Proxy type '{$type}' is not supported" - ); - } - } - - if ($tunnel && !$httpProxy) { - throw new HTTP_Request2_LogicException( - "Trying to perform CONNECT request without proxy", - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if ($secure && !in_array('ssl', stream_get_transports())) { - throw new HTTP_Request2_LogicException( - 'Need OpenSSL support for https:// requests', - HTTP_Request2_Exception::MISCONFIGURATION - ); - } - - // RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive - // connection token to a proxy server... - if ($httpProxy && !$secure && !empty($headers['connection']) - && 'Keep-Alive' == $headers['connection'] - ) { - $this->request->setHeader('connection'); - } - - $keepAlive = ('1.1' == $this->request->getConfig('protocol_version') && - empty($headers['connection'])) || - (!empty($headers['connection']) && - 'Keep-Alive' == $headers['connection']); - - $options = array(); - if ($ip = $this->request->getConfig('local_ip')) { - $options['socket'] = array( - 'bindto' => (false === strpos($ip, ':') ? $ip : '[' . $ip . ']') . ':0' - ); - } - if ($secure || $tunnel) { - $options['ssl'] = array(); - foreach ($this->request->getConfig() as $name => $value) { - if ('ssl_' == substr($name, 0, 4) && null !== $value) { - if ('ssl_verify_host' == $name) { - if ($value) { - $options['ssl']['CN_match'] = $reqHost; - } - } else { - $options['ssl'][substr($name, 4)] = $value; - } - } - } - ksort($options['ssl']); - } - - // Use global request timeout if given, see feature requests #5735, #8964 - if ($timeout = $this->request->getConfig('timeout')) { - $deadline = time() + $timeout; - } else { - $deadline = null; - } - - // Changing SSL context options after connection is established does *not* - // work, we need a new connection if options change - $remote = ((!$secure || $httpProxy || $socksProxy)? 'tcp://': 'ssl://') - . $host . ':' . $port; - $socketKey = $remote . ( - ($secure && $httpProxy || $socksProxy) - ? "->{$reqHost}:{$reqPort}" : '' - ) . (empty($options)? '': ':' . serialize($options)); - unset($this->socket); - - // We use persistent connections and have a connected socket? - // Ensure that the socket is still connected, see bug #16149 - if ($keepAlive && !empty(self::$sockets[$socketKey]) - && !self::$sockets[$socketKey]->eof() - ) { - $this->socket =& self::$sockets[$socketKey]; - - } else { - if ($socksProxy) { - require_once 'HTTP/Request2/SOCKS5.php'; - - $this->socket = new HTTP_Request2_SOCKS5( - $remote, $this->request->getConfig('connect_timeout'), - $options, $this->request->getConfig('proxy_user'), - $this->request->getConfig('proxy_password') - ); - // handle request timeouts ASAP - $this->socket->setDeadline($deadline, $this->request->getConfig('timeout')); - $this->socket->connect($reqHost, $reqPort); - if (!$secure) { - $conninfo = "tcp://{$reqHost}:{$reqPort} via {$remote}"; - } else { - $this->socket->enableCrypto(); - $conninfo = "ssl://{$reqHost}:{$reqPort} via {$remote}"; - } - - } elseif ($secure && $httpProxy && !$tunnel) { - $this->establishTunnel(); - $conninfo = "ssl://{$reqHost}:{$reqPort} via {$remote}"; - - } else { - $this->socket = new HTTP_Request2_SocketWrapper( - $remote, $this->request->getConfig('connect_timeout'), $options - ); - } - $this->request->setLastEvent('connect', empty($conninfo)? $remote: $conninfo); - self::$sockets[$socketKey] =& $this->socket; - } - $this->socket->setDeadline($deadline, $this->request->getConfig('timeout')); - return $keepAlive; - } - - /** - * Establishes a tunnel to a secure remote server via HTTP CONNECT request - * - * This method will fail if 'ssl_verify_peer' is enabled. Probably because PHP - * sees that we are connected to a proxy server (duh!) rather than the server - * that presents its certificate. - * - * @link http://tools.ietf.org/html/rfc2817#section-5.2 - * @throws HTTP_Request2_Exception - */ - protected function establishTunnel() - { - $donor = new self; - $connect = new HTTP_Request2( - $this->request->getUrl(), HTTP_Request2::METHOD_CONNECT, - array_merge($this->request->getConfig(), array('adapter' => $donor)) - ); - $response = $connect->send(); - // Need any successful (2XX) response - if (200 > $response->getStatus() || 300 <= $response->getStatus()) { - throw new HTTP_Request2_ConnectionException( - 'Failed to connect via HTTPS proxy. Proxy response: ' . - $response->getStatus() . ' ' . $response->getReasonPhrase() - ); - } - $this->socket = $donor->socket; - $this->socket->enableCrypto(); - } - - /** - * Checks whether current connection may be reused or should be closed - * - * @param boolean $requestKeepAlive whether connection could - * be persistent in the first place - * @param HTTP_Request2_Response $response response object to check - * - * @return boolean - */ - protected function canKeepAlive($requestKeepAlive, HTTP_Request2_Response $response) - { - // Do not close socket on successful CONNECT request - if (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() - && 200 <= $response->getStatus() && 300 > $response->getStatus() - ) { - return true; - } - - $lengthKnown = 'chunked' == strtolower($response->getHeader('transfer-encoding')) - || null !== $response->getHeader('content-length') - // no body possible for such responses, see also request #17031 - || HTTP_Request2::METHOD_HEAD == $this->request->getMethod() - || in_array($response->getStatus(), array(204, 304)); - $persistent = 'keep-alive' == strtolower($response->getHeader('connection')) || - (null === $response->getHeader('connection') && - '1.1' == $response->getVersion()); - return $requestKeepAlive && $lengthKnown && $persistent; - } - - /** - * Disconnects from the remote server - */ - protected function disconnect() - { - if (!empty($this->socket)) { - $this->socket = null; - $this->request->setLastEvent('disconnect'); - } - } - - /** - * Handles HTTP redirection - * - * This method will throw an Exception if redirect to a non-HTTP(S) location - * is attempted, also if number of redirects performed already is equal to - * 'max_redirects' configuration parameter. - * - * @param HTTP_Request2 $request Original request - * @param HTTP_Request2_Response $response Response containing redirect - * - * @return HTTP_Request2_Response Response from a new location - * @throws HTTP_Request2_Exception - */ - protected function handleRedirect( - HTTP_Request2 $request, HTTP_Request2_Response $response - ) { - if (is_null($this->redirectCountdown)) { - $this->redirectCountdown = $request->getConfig('max_redirects'); - } - if (0 == $this->redirectCountdown) { - $this->redirectCountdown = null; - // Copying cURL behaviour - throw new HTTP_Request2_MessageException( - 'Maximum (' . $request->getConfig('max_redirects') . ') redirects followed', - HTTP_Request2_Exception::TOO_MANY_REDIRECTS - ); - } - $redirectUrl = new Net_URL2( - $response->getHeader('location'), - array(Net_URL2::OPTION_USE_BRACKETS => $request->getConfig('use_brackets')) - ); - // refuse non-HTTP redirect - if ($redirectUrl->isAbsolute() - && !in_array($redirectUrl->getScheme(), array('http', 'https')) - ) { - $this->redirectCountdown = null; - throw new HTTP_Request2_MessageException( - 'Refusing to redirect to a non-HTTP URL ' . $redirectUrl->__toString(), - HTTP_Request2_Exception::NON_HTTP_REDIRECT - ); - } - // Theoretically URL should be absolute (see http://tools.ietf.org/html/rfc2616#section-14.30), - // but in practice it is often not - if (!$redirectUrl->isAbsolute()) { - $redirectUrl = $request->getUrl()->resolve($redirectUrl); - } - $redirect = clone $request; - $redirect->setUrl($redirectUrl); - if (303 == $response->getStatus() - || (!$request->getConfig('strict_redirects') - && in_array($response->getStatus(), array(301, 302))) - ) { - $redirect->setMethod(HTTP_Request2::METHOD_GET); - $redirect->setBody(''); - } - - if (0 < $this->redirectCountdown) { - $this->redirectCountdown--; - } - return $this->sendRequest($redirect); - } - - /** - * Checks whether another request should be performed with server digest auth - * - * Several conditions should be satisfied for it to return true: - * - response status should be 401 - * - auth credentials should be set in the request object - * - response should contain WWW-Authenticate header with digest challenge - * - there is either no challenge stored for this URL or new challenge - * contains stale=true parameter (in other case we probably just failed - * due to invalid username / password) - * - * The method stores challenge values in $challenges static property - * - * @param HTTP_Request2_Response $response response to check - * - * @return boolean whether another request should be performed - * @throws HTTP_Request2_Exception in case of unsupported challenge parameters - */ - protected function shouldUseServerDigestAuth(HTTP_Request2_Response $response) - { - // no sense repeating a request if we don't have credentials - if (401 != $response->getStatus() || !$this->request->getAuth()) { - return false; - } - if (!$challenge = $this->parseDigestChallenge($response->getHeader('www-authenticate'))) { - return false; - } - - $url = $this->request->getUrl(); - $scheme = $url->getScheme(); - $host = $scheme . '://' . $url->getHost(); - if ($port = $url->getPort()) { - if ((0 == strcasecmp($scheme, 'http') && 80 != $port) - || (0 == strcasecmp($scheme, 'https') && 443 != $port) - ) { - $host .= ':' . $port; - } - } - - if (!empty($challenge['domain'])) { - $prefixes = array(); - foreach (preg_split('/\\s+/', $challenge['domain']) as $prefix) { - // don't bother with different servers - if ('/' == substr($prefix, 0, 1)) { - $prefixes[] = $host . $prefix; - } - } - } - if (empty($prefixes)) { - $prefixes = array($host . '/'); - } - - $ret = true; - foreach ($prefixes as $prefix) { - if (!empty(self::$challenges[$prefix]) - && (empty($challenge['stale']) || strcasecmp('true', $challenge['stale'])) - ) { - // probably credentials are invalid - $ret = false; - } - self::$challenges[$prefix] =& $challenge; - } - return $ret; - } - - /** - * Checks whether another request should be performed with proxy digest auth - * - * Several conditions should be satisfied for it to return true: - * - response status should be 407 - * - proxy auth credentials should be set in the request object - * - response should contain Proxy-Authenticate header with digest challenge - * - there is either no challenge stored for this proxy or new challenge - * contains stale=true parameter (in other case we probably just failed - * due to invalid username / password) - * - * The method stores challenge values in $challenges static property - * - * @param HTTP_Request2_Response $response response to check - * - * @return boolean whether another request should be performed - * @throws HTTP_Request2_Exception in case of unsupported challenge parameters - */ - protected function shouldUseProxyDigestAuth(HTTP_Request2_Response $response) - { - if (407 != $response->getStatus() || !$this->request->getConfig('proxy_user')) { - return false; - } - if (!($challenge = $this->parseDigestChallenge($response->getHeader('proxy-authenticate')))) { - return false; - } - - $key = 'proxy://' . $this->request->getConfig('proxy_host') . - ':' . $this->request->getConfig('proxy_port'); - - if (!empty(self::$challenges[$key]) - && (empty($challenge['stale']) || strcasecmp('true', $challenge['stale'])) - ) { - $ret = false; - } else { - $ret = true; - } - self::$challenges[$key] = $challenge; - return $ret; - } - - /** - * Extracts digest method challenge from (WWW|Proxy)-Authenticate header value - * - * There is a problem with implementation of RFC 2617: several of the parameters - * are defined as quoted-string there and thus may contain backslash escaped - * double quotes (RFC 2616, section 2.2). However, RFC 2617 defines unq(X) as - * just value of quoted-string X without surrounding quotes, it doesn't speak - * about removing backslash escaping. - * - * Now realm parameter is user-defined and human-readable, strange things - * happen when it contains quotes: - * - Apache allows quotes in realm, but apparently uses realm value without - * backslashes for digest computation - * - Squid allows (manually escaped) quotes there, but it is impossible to - * authorize with either escaped or unescaped quotes used in digest, - * probably it can't parse the response (?) - * - Both IE and Firefox display realm value with backslashes in - * the password popup and apparently use the same value for digest - * - * HTTP_Request2 follows IE and Firefox (and hopefully RFC 2617) in - * quoted-string handling, unfortunately that means failure to authorize - * sometimes - * - * @param string $headerValue value of WWW-Authenticate or Proxy-Authenticate header - * - * @return mixed associative array with challenge parameters, false if - * no challenge is present in header value - * @throws HTTP_Request2_NotImplementedException in case of unsupported challenge parameters - */ - protected function parseDigestChallenge($headerValue) - { - $authParam = '(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' . - self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')'; - $challenge = "!(?<=^|\\s|,)Digest ({$authParam}\\s*(,\\s*|$))+!"; - if (!preg_match($challenge, $headerValue, $matches)) { - return false; - } - - preg_match_all('!' . $authParam . '!', $matches[0], $params); - $paramsAry = array(); - $knownParams = array('realm', 'domain', 'nonce', 'opaque', 'stale', - 'algorithm', 'qop'); - for ($i = 0; $i < count($params[0]); $i++) { - // section 3.2.1: Any unrecognized directive MUST be ignored. - if (in_array($params[1][$i], $knownParams)) { - if ('"' == substr($params[2][$i], 0, 1)) { - $paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1); - } else { - $paramsAry[$params[1][$i]] = $params[2][$i]; - } - } - } - // we only support qop=auth - if (!empty($paramsAry['qop']) - && !in_array('auth', array_map('trim', explode(',', $paramsAry['qop']))) - ) { - throw new HTTP_Request2_NotImplementedException( - "Only 'auth' qop is currently supported in digest authentication, " . - "server requested '{$paramsAry['qop']}'" - ); - } - // we only support algorithm=MD5 - if (!empty($paramsAry['algorithm']) && 'MD5' != $paramsAry['algorithm']) { - throw new HTTP_Request2_NotImplementedException( - "Only 'MD5' algorithm is currently supported in digest authentication, " . - "server requested '{$paramsAry['algorithm']}'" - ); - } - - return $paramsAry; - } - - /** - * Parses [Proxy-]Authentication-Info header value and updates challenge - * - * @param array &$challenge challenge to update - * @param string $headerValue value of [Proxy-]Authentication-Info header - * - * @todo validate server rspauth response - */ - protected function updateChallenge(&$challenge, $headerValue) - { - $authParam = '!(' . self::REGEXP_TOKEN . ')\\s*=\\s*(' . - self::REGEXP_TOKEN . '|' . self::REGEXP_QUOTED_STRING . ')!'; - $paramsAry = array(); - - preg_match_all($authParam, $headerValue, $params); - for ($i = 0; $i < count($params[0]); $i++) { - if ('"' == substr($params[2][$i], 0, 1)) { - $paramsAry[$params[1][$i]] = substr($params[2][$i], 1, -1); - } else { - $paramsAry[$params[1][$i]] = $params[2][$i]; - } - } - // for now, just update the nonce value - if (!empty($paramsAry['nextnonce'])) { - $challenge['nonce'] = $paramsAry['nextnonce']; - $challenge['nc'] = 1; - } - } - - /** - * Creates a value for [Proxy-]Authorization header when using digest authentication - * - * @param string $user user name - * @param string $password password - * @param string $url request URL - * @param array &$challenge digest challenge parameters - * - * @return string value of [Proxy-]Authorization request header - * @link http://tools.ietf.org/html/rfc2617#section-3.2.2 - */ - protected function createDigestResponse($user, $password, $url, &$challenge) - { - if (false !== ($q = strpos($url, '?')) - && $this->request->getConfig('digest_compat_ie') - ) { - $url = substr($url, 0, $q); - } - - $a1 = md5($user . ':' . $challenge['realm'] . ':' . $password); - $a2 = md5($this->request->getMethod() . ':' . $url); - - if (empty($challenge['qop'])) { - $digest = md5($a1 . ':' . $challenge['nonce'] . ':' . $a2); - } else { - $challenge['cnonce'] = 'Req2.' . rand(); - if (empty($challenge['nc'])) { - $challenge['nc'] = 1; - } - $nc = sprintf('%08x', $challenge['nc']++); - $digest = md5( - $a1 . ':' . $challenge['nonce'] . ':' . $nc . ':' . - $challenge['cnonce'] . ':auth:' . $a2 - ); - } - return 'Digest username="' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $user) . '", ' . - 'realm="' . $challenge['realm'] . '", ' . - 'nonce="' . $challenge['nonce'] . '", ' . - 'uri="' . $url . '", ' . - 'response="' . $digest . '"' . - (!empty($challenge['opaque'])? - ', opaque="' . $challenge['opaque'] . '"': - '') . - (!empty($challenge['qop'])? - ', qop="auth", nc=' . $nc . ', cnonce="' . $challenge['cnonce'] . '"': - ''); - } - - /** - * Adds 'Authorization' header (if needed) to request headers array - * - * @param array &$headers request headers - * @param string $requestHost request host (needed for digest authentication) - * @param string $requestUrl request URL (needed for digest authentication) - * - * @throws HTTP_Request2_NotImplementedException - */ - protected function addAuthorizationHeader(&$headers, $requestHost, $requestUrl) - { - if (!($auth = $this->request->getAuth())) { - return; - } - switch ($auth['scheme']) { - case HTTP_Request2::AUTH_BASIC: - $headers['authorization'] = 'Basic ' . base64_encode( - $auth['user'] . ':' . $auth['password'] - ); - break; - - case HTTP_Request2::AUTH_DIGEST: - unset($this->serverChallenge); - $fullUrl = ('/' == $requestUrl[0])? - $this->request->getUrl()->getScheme() . '://' . - $requestHost . $requestUrl: - $requestUrl; - foreach (array_keys(self::$challenges) as $key) { - if ($key == substr($fullUrl, 0, strlen($key))) { - $headers['authorization'] = $this->createDigestResponse( - $auth['user'], $auth['password'], - $requestUrl, self::$challenges[$key] - ); - $this->serverChallenge =& self::$challenges[$key]; - break; - } - } - break; - - default: - throw new HTTP_Request2_NotImplementedException( - "Unknown HTTP authentication scheme '{$auth['scheme']}'" - ); - } - } - - /** - * Adds 'Proxy-Authorization' header (if needed) to request headers array - * - * @param array &$headers request headers - * @param string $requestUrl request URL (needed for digest authentication) - * - * @throws HTTP_Request2_NotImplementedException - */ - protected function addProxyAuthorizationHeader(&$headers, $requestUrl) - { - if (!$this->request->getConfig('proxy_host') - || !($user = $this->request->getConfig('proxy_user')) - || (0 == strcasecmp('https', $this->request->getUrl()->getScheme()) - && HTTP_Request2::METHOD_CONNECT != $this->request->getMethod()) - ) { - return; - } - - $password = $this->request->getConfig('proxy_password'); - switch ($this->request->getConfig('proxy_auth_scheme')) { - case HTTP_Request2::AUTH_BASIC: - $headers['proxy-authorization'] = 'Basic ' . base64_encode( - $user . ':' . $password - ); - break; - - case HTTP_Request2::AUTH_DIGEST: - unset($this->proxyChallenge); - $proxyUrl = 'proxy://' . $this->request->getConfig('proxy_host') . - ':' . $this->request->getConfig('proxy_port'); - if (!empty(self::$challenges[$proxyUrl])) { - $headers['proxy-authorization'] = $this->createDigestResponse( - $user, $password, - $requestUrl, self::$challenges[$proxyUrl] - ); - $this->proxyChallenge =& self::$challenges[$proxyUrl]; - } - break; - - default: - throw new HTTP_Request2_NotImplementedException( - "Unknown HTTP authentication scheme '" . - $this->request->getConfig('proxy_auth_scheme') . "'" - ); - } - } - - - /** - * Creates the string with the Request-Line and request headers - * - * @return string - * @throws HTTP_Request2_Exception - */ - protected function prepareHeaders() - { - $headers = $this->request->getHeaders(); - $url = $this->request->getUrl(); - $connect = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod(); - $host = $url->getHost(); - - $defaultPort = 0 == strcasecmp($url->getScheme(), 'https')? 443: 80; - if (($port = $url->getPort()) && $port != $defaultPort || $connect) { - $host .= ':' . (empty($port)? $defaultPort: $port); - } - // Do not overwrite explicitly set 'Host' header, see bug #16146 - if (!isset($headers['host'])) { - $headers['host'] = $host; - } - - if ($connect) { - $requestUrl = $host; - - } else { - if (!$this->request->getConfig('proxy_host') - || 'http' != $this->request->getConfig('proxy_type') - || 0 == strcasecmp($url->getScheme(), 'https') - ) { - $requestUrl = ''; - } else { - $requestUrl = $url->getScheme() . '://' . $host; - } - $path = $url->getPath(); - $query = $url->getQuery(); - $requestUrl .= (empty($path)? '/': $path) . (empty($query)? '': '?' . $query); - } - - if ('1.1' == $this->request->getConfig('protocol_version') - && extension_loaded('zlib') && !isset($headers['accept-encoding']) - ) { - $headers['accept-encoding'] = 'gzip, deflate'; - } - if (($jar = $this->request->getCookieJar()) - && ($cookies = $jar->getMatching($this->request->getUrl(), true)) - ) { - $headers['cookie'] = (empty($headers['cookie'])? '': $headers['cookie'] . '; ') . $cookies; - } - - $this->addAuthorizationHeader($headers, $host, $requestUrl); - $this->addProxyAuthorizationHeader($headers, $requestUrl); - $this->calculateRequestLength($headers); - if ('1.1' == $this->request->getConfig('protocol_version')) { - $this->updateExpectHeader($headers); - } else { - $this->expect100Continue = false; - } - - $headersStr = $this->request->getMethod() . ' ' . $requestUrl . ' HTTP/' . - $this->request->getConfig('protocol_version') . "\r\n"; - foreach ($headers as $name => $value) { - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - $headersStr .= $canonicalName . ': ' . $value . "\r\n"; - } - return $headersStr . "\r\n"; - } - - /** - * Adds or removes 'Expect: 100-continue' header from request headers - * - * Also sets the $expect100Continue property. Parsing of existing header - * is somewhat needed due to its complex structure and due to the - * requirement in section 8.2.3 of RFC 2616: - * > A client MUST NOT send an Expect request-header field (section - * > 14.20) with the "100-continue" expectation if it does not intend - * > to send a request body. - * - * @param array &$headers Array of headers prepared for the request - * - * @throws HTTP_Request2_LogicException - * @link http://pear.php.net/bugs/bug.php?id=19233 - * @link http://tools.ietf.org/html/rfc2616#section-8.2.3 - */ - protected function updateExpectHeader(&$headers) - { - $this->expect100Continue = false; - $expectations = array(); - if (isset($headers['expect'])) { - if ('' === $headers['expect']) { - // empty 'Expect' header is technically invalid, so just get rid of it - unset($headers['expect']); - return; - } - // build regexp to parse the value of existing Expect header - $expectParam = ';\s*' . self::REGEXP_TOKEN . '(?:\s*=\s*(?:' - . self::REGEXP_TOKEN . '|' - . self::REGEXP_QUOTED_STRING . '))?\s*'; - $expectExtension = self::REGEXP_TOKEN . '(?:\s*=\s*(?:' - . self::REGEXP_TOKEN . '|' - . self::REGEXP_QUOTED_STRING . ')\s*(?:' - . $expectParam . ')*)?'; - $expectItem = '!(100-continue|' . $expectExtension . ')!A'; - - $pos = 0; - $length = strlen($headers['expect']); - - while ($pos < $length) { - $pos += strspn($headers['expect'], " \t", $pos); - if (',' === substr($headers['expect'], $pos, 1)) { - $pos++; - continue; - - } elseif (!preg_match($expectItem, $headers['expect'], $m, 0, $pos)) { - throw new HTTP_Request2_LogicException( - "Cannot parse value '{$headers['expect']}' of Expect header", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - - } else { - $pos += strlen($m[0]); - if (strcasecmp('100-continue', $m[0])) { - $expectations[] = $m[0]; - } - } - } - } - - if (1024 < $this->contentLength) { - $expectations[] = '100-continue'; - $this->expect100Continue = true; - } - - if (empty($expectations)) { - unset($headers['expect']); - } else { - $headers['expect'] = implode(',', $expectations); - } - } - - /** - * Sends the request body - * - * @throws HTTP_Request2_MessageException - */ - protected function writeBody() - { - if (in_array($this->request->getMethod(), self::$bodyDisallowed) - || 0 == $this->contentLength - ) { - return; - } - - $position = 0; - $bufferSize = $this->request->getConfig('buffer_size'); - $headers = $this->request->getHeaders(); - $chunked = isset($headers['transfer-encoding']); - while ($position < $this->contentLength) { - if (is_string($this->requestBody)) { - $str = substr($this->requestBody, $position, $bufferSize); - } elseif (is_resource($this->requestBody)) { - $str = fread($this->requestBody, $bufferSize); - } else { - $str = $this->requestBody->read($bufferSize); - } - if (!$chunked) { - $this->socket->write($str); - } else { - $this->socket->write(dechex(strlen($str)) . "\r\n{$str}\r\n"); - } - // Provide the length of written string to the observer, request #7630 - $this->request->setLastEvent('sentBodyPart', strlen($str)); - $position += strlen($str); - } - - // write zero-length chunk - if ($chunked) { - $this->socket->write("0\r\n\r\n"); - } - $this->request->setLastEvent('sentBody', $this->contentLength); - } - - /** - * Reads the remote server's response - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - protected function readResponse() - { - $bufferSize = $this->request->getConfig('buffer_size'); - // http://tools.ietf.org/html/rfc2616#section-8.2.3 - // ...the client SHOULD NOT wait for an indefinite period before sending the request body - $timeout = $this->expect100Continue ? 1 : null; - - do { - try { - $response = new HTTP_Request2_Response( - $this->socket->readLine($bufferSize, $timeout), true, $this->request->getUrl() - ); - do { - $headerLine = $this->socket->readLine($bufferSize); - $response->parseHeaderLine($headerLine); - } while ('' != $headerLine); - - } catch (HTTP_Request2_MessageException $e) { - if (HTTP_Request2_Exception::TIMEOUT === $e->getCode() - && $this->expect100Continue - ) { - return null; - } - throw $e; - } - if ($this->expect100Continue && 100 == $response->getStatus()) { - return $response; - } - } while (in_array($response->getStatus(), array(100, 101))); - - $this->request->setLastEvent('receivedHeaders', $response); - - // No body possible in such responses - if (HTTP_Request2::METHOD_HEAD == $this->request->getMethod() - || (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() - && 200 <= $response->getStatus() && 300 > $response->getStatus()) - || in_array($response->getStatus(), array(204, 304)) - ) { - return $response; - } - - $chunked = 'chunked' == $response->getHeader('transfer-encoding'); - $length = $response->getHeader('content-length'); - $hasBody = false; - if ($chunked || null === $length || 0 < intval($length)) { - // RFC 2616, section 4.4: - // 3. ... If a message is received with both a - // Transfer-Encoding header field and a Content-Length header field, - // the latter MUST be ignored. - $toRead = ($chunked || null === $length)? null: $length; - $this->chunkLength = 0; - - while (!$this->socket->eof() && (is_null($toRead) || 0 < $toRead)) { - if ($chunked) { - $data = $this->readChunked($bufferSize); - } elseif (is_null($toRead)) { - $data = $this->socket->read($bufferSize); - } else { - $data = $this->socket->read(min($toRead, $bufferSize)); - $toRead -= strlen($data); - } - if ('' == $data && (!$this->chunkLength || $this->socket->eof())) { - break; - } - - $hasBody = true; - if ($this->request->getConfig('store_body')) { - $response->appendBody($data); - } - if (!in_array($response->getHeader('content-encoding'), array('identity', null))) { - $this->request->setLastEvent('receivedEncodedBodyPart', $data); - } else { - $this->request->setLastEvent('receivedBodyPart', $data); - } - } - } - - if ($hasBody) { - $this->request->setLastEvent('receivedBody', $response); - } - return $response; - } - - /** - * Reads a part of response body encoded with chunked Transfer-Encoding - * - * @param int $bufferSize buffer size to use for reading - * - * @return string - * @throws HTTP_Request2_MessageException - */ - protected function readChunked($bufferSize) - { - // at start of the next chunk? - if (0 == $this->chunkLength) { - $line = $this->socket->readLine($bufferSize); - if (!preg_match('/^([0-9a-f]+)/i', $line, $matches)) { - throw new HTTP_Request2_MessageException( - "Cannot decode chunked response, invalid chunk length '{$line}'", - HTTP_Request2_Exception::DECODE_ERROR - ); - } else { - $this->chunkLength = hexdec($matches[1]); - // Chunk with zero length indicates the end - if (0 == $this->chunkLength) { - $this->socket->readLine($bufferSize); - return ''; - } - } - } - $data = $this->socket->read(min($this->chunkLength, $bufferSize)); - $this->chunkLength -= strlen($data); - if (0 == $this->chunkLength) { - $this->socket->readLine($bufferSize); // Trailing CRLF - } - return $data; - } -} - -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/CookieJar.php b/vendor/pear/http_request2/HTTP/Request2/CookieJar.php deleted file mode 100644 index ed6352ebe..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/CookieJar.php +++ /dev/null @@ -1,494 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Class representing a HTTP request message */ -require_once 'HTTP/Request2.php'; - -/** - * Stores cookies and passes them between HTTP requests - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_CookieJar implements Serializable -{ - /** - * Array of stored cookies - * - * The array is indexed by domain, path and cookie name - * .example.com - * / - * some_cookie => cookie data - * /subdir - * other_cookie => cookie data - * .example.org - * ... - * - * @var array - */ - protected $cookies = array(); - - /** - * Whether session cookies should be serialized when serializing the jar - * @var bool - */ - protected $serializeSession = false; - - /** - * Whether Public Suffix List should be used for domain matching - * @var bool - */ - protected $useList = true; - - /** - * Array with Public Suffix List data - * @var array - * @link http://publicsuffix.org/ - */ - protected static $psl = array(); - - /** - * Class constructor, sets various options - * - * @param bool $serializeSessionCookies Controls serializing session cookies, - * see {@link serializeSessionCookies()} - * @param bool $usePublicSuffixList Controls using Public Suffix List, - * see {@link usePublicSuffixList()} - */ - public function __construct( - $serializeSessionCookies = false, $usePublicSuffixList = true - ) { - $this->serializeSessionCookies($serializeSessionCookies); - $this->usePublicSuffixList($usePublicSuffixList); - } - - /** - * Returns current time formatted in ISO-8601 at UTC timezone - * - * @return string - */ - protected function now() - { - $dt = new DateTime(); - $dt->setTimezone(new DateTimeZone('UTC')); - return $dt->format(DateTime::ISO8601); - } - - /** - * Checks cookie array for correctness, possibly updating its 'domain', 'path' and 'expires' fields - * - * The checks are as follows: - * - cookie array should contain 'name' and 'value' fields; - * - name and value should not contain disallowed symbols; - * - 'expires' should be either empty parseable by DateTime; - * - 'domain' and 'path' should be either not empty or an URL where - * cookie was set should be provided. - * - if $setter is provided, then document at that URL should be allowed - * to set a cookie for that 'domain'. If $setter is not provided, - * then no domain checks will be made. - * - * 'expires' field will be converted to ISO8601 format from COOKIE format, - * 'domain' and 'path' will be set from setter URL if empty. - * - * @param array $cookie cookie data, as returned by - * {@link HTTP_Request2_Response::getCookies()} - * @param Net_URL2 $setter URL of the document that sent Set-Cookie header - * - * @return array Updated cookie array - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_MessageException - */ - protected function checkAndUpdateFields(array $cookie, Net_URL2 $setter = null) - { - if ($missing = array_diff(array('name', 'value'), array_keys($cookie))) { - throw new HTTP_Request2_LogicException( - "Cookie array should contain 'name' and 'value' fields", - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if (preg_match(HTTP_Request2::REGEXP_INVALID_COOKIE, $cookie['name'])) { - throw new HTTP_Request2_LogicException( - "Invalid cookie name: '{$cookie['name']}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - if (preg_match(HTTP_Request2::REGEXP_INVALID_COOKIE, $cookie['value'])) { - throw new HTTP_Request2_LogicException( - "Invalid cookie value: '{$cookie['value']}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $cookie += array('domain' => '', 'path' => '', 'expires' => null, 'secure' => false); - - // Need ISO-8601 date @ UTC timezone - if (!empty($cookie['expires']) - && !preg_match('/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+0000$/', $cookie['expires']) - ) { - try { - $dt = new DateTime($cookie['expires']); - $dt->setTimezone(new DateTimeZone('UTC')); - $cookie['expires'] = $dt->format(DateTime::ISO8601); - } catch (Exception $e) { - throw new HTTP_Request2_LogicException($e->getMessage()); - } - } - - if (empty($cookie['domain']) || empty($cookie['path'])) { - if (!$setter) { - throw new HTTP_Request2_LogicException( - 'Cookie misses domain and/or path component, cookie setter URL needed', - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if (empty($cookie['domain'])) { - if ($host = $setter->getHost()) { - $cookie['domain'] = $host; - } else { - throw new HTTP_Request2_LogicException( - 'Setter URL does not contain host part, can\'t set cookie domain', - HTTP_Request2_Exception::MISSING_VALUE - ); - } - } - if (empty($cookie['path'])) { - $path = $setter->getPath(); - $cookie['path'] = empty($path)? '/': substr($path, 0, strrpos($path, '/') + 1); - } - } - - if ($setter && !$this->domainMatch($setter->getHost(), $cookie['domain'])) { - throw new HTTP_Request2_MessageException( - "Domain " . $setter->getHost() . " cannot set cookies for " - . $cookie['domain'] - ); - } - - return $cookie; - } - - /** - * Stores a cookie in the jar - * - * @param array $cookie cookie data, as returned by - * {@link HTTP_Request2_Response::getCookies()} - * @param Net_URL2 $setter URL of the document that sent Set-Cookie header - * - * @throws HTTP_Request2_Exception - */ - public function store(array $cookie, Net_URL2 $setter = null) - { - $cookie = $this->checkAndUpdateFields($cookie, $setter); - - if (strlen($cookie['value']) - && (is_null($cookie['expires']) || $cookie['expires'] > $this->now()) - ) { - if (!isset($this->cookies[$cookie['domain']])) { - $this->cookies[$cookie['domain']] = array(); - } - if (!isset($this->cookies[$cookie['domain']][$cookie['path']])) { - $this->cookies[$cookie['domain']][$cookie['path']] = array(); - } - $this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']] = $cookie; - - } elseif (isset($this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']])) { - unset($this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']]); - } - } - - /** - * Adds cookies set in HTTP response to the jar - * - * @param HTTP_Request2_Response $response HTTP response message - * @param Net_URL2 $setter original request URL, needed for - * setting default domain/path - */ - public function addCookiesFromResponse(HTTP_Request2_Response $response, Net_URL2 $setter) - { - foreach ($response->getCookies() as $cookie) { - $this->store($cookie, $setter); - } - } - - /** - * Returns all cookies matching a given request URL - * - * The following checks are made: - * - cookie domain should match request host - * - cookie path should be a prefix for request path - * - 'secure' cookies will only be sent for HTTPS requests - * - * @param Net_URL2 $url Request url - * @param bool $asString Whether to return cookies as string for "Cookie: " header - * - * @return array|string Matching cookies - */ - public function getMatching(Net_URL2 $url, $asString = false) - { - $host = $url->getHost(); - $path = $url->getPath(); - $secure = 0 == strcasecmp($url->getScheme(), 'https'); - - $matched = $ret = array(); - foreach (array_keys($this->cookies) as $domain) { - if ($this->domainMatch($host, $domain)) { - foreach (array_keys($this->cookies[$domain]) as $cPath) { - if (0 === strpos($path, $cPath)) { - foreach ($this->cookies[$domain][$cPath] as $name => $cookie) { - if (!$cookie['secure'] || $secure) { - $matched[$name][strlen($cookie['path'])] = $cookie; - } - } - } - } - } - } - foreach ($matched as $cookies) { - krsort($cookies); - $ret = array_merge($ret, $cookies); - } - if (!$asString) { - return $ret; - } else { - $str = ''; - foreach ($ret as $c) { - $str .= (empty($str)? '': '; ') . $c['name'] . '=' . $c['value']; - } - return $str; - } - } - - /** - * Returns all cookies stored in a jar - * - * @return array - */ - public function getAll() - { - $cookies = array(); - foreach (array_keys($this->cookies) as $domain) { - foreach (array_keys($this->cookies[$domain]) as $path) { - foreach ($this->cookies[$domain][$path] as $name => $cookie) { - $cookies[] = $cookie; - } - } - } - return $cookies; - } - - /** - * Sets whether session cookies should be serialized when serializing the jar - * - * @param boolean $serialize serialize? - */ - public function serializeSessionCookies($serialize) - { - $this->serializeSession = (bool)$serialize; - } - - /** - * Sets whether Public Suffix List should be used for restricting cookie-setting - * - * Without PSL {@link domainMatch()} will only prevent setting cookies for - * top-level domains like '.com' or '.org'. However, it will not prevent - * setting a cookie for '.co.uk' even though only third-level registrations - * are possible in .uk domain. - * - * With the List it is possible to find the highest level at which a domain - * may be registered for a particular top-level domain and consequently - * prevent cookies set for '.co.uk' or '.msk.ru'. The same list is used by - * Firefox, Chrome and Opera browsers to restrict cookie setting. - * - * Note that PSL is licensed differently to HTTP_Request2 package (refer to - * the license information in public-suffix-list.php), so you can disable - * its use if this is an issue for you. - * - * @param boolean $useList use the list? - * - * @link http://publicsuffix.org/learn/ - */ - public function usePublicSuffixList($useList) - { - $this->useList = (bool)$useList; - } - - /** - * Returns string representation of object - * - * @return string - * - * @see Serializable::serialize() - */ - public function serialize() - { - $cookies = $this->getAll(); - if (!$this->serializeSession) { - for ($i = count($cookies) - 1; $i >= 0; $i--) { - if (empty($cookies[$i]['expires'])) { - unset($cookies[$i]); - } - } - } - return serialize(array( - 'cookies' => $cookies, - 'serializeSession' => $this->serializeSession, - 'useList' => $this->useList - )); - } - - /** - * Constructs the object from serialized string - * - * @param string $serialized string representation - * - * @see Serializable::unserialize() - */ - public function unserialize($serialized) - { - $data = unserialize($serialized); - $now = $this->now(); - $this->serializeSessionCookies($data['serializeSession']); - $this->usePublicSuffixList($data['useList']); - foreach ($data['cookies'] as $cookie) { - if (!empty($cookie['expires']) && $cookie['expires'] <= $now) { - continue; - } - if (!isset($this->cookies[$cookie['domain']])) { - $this->cookies[$cookie['domain']] = array(); - } - if (!isset($this->cookies[$cookie['domain']][$cookie['path']])) { - $this->cookies[$cookie['domain']][$cookie['path']] = array(); - } - $this->cookies[$cookie['domain']][$cookie['path']][$cookie['name']] = $cookie; - } - } - - /** - * Checks whether a cookie domain matches a request host. - * - * The method is used by {@link store()} to check for whether a document - * at given URL can set a cookie with a given domain attribute and by - * {@link getMatching()} to find cookies matching the request URL. - * - * @param string $requestHost request host - * @param string $cookieDomain cookie domain - * - * @return bool match success - */ - public function domainMatch($requestHost, $cookieDomain) - { - if ($requestHost == $cookieDomain) { - return true; - } - // IP address, we require exact match - if (preg_match('/^(?:\d{1,3}\.){3}\d{1,3}$/', $requestHost)) { - return false; - } - if ('.' != $cookieDomain[0]) { - $cookieDomain = '.' . $cookieDomain; - } - // prevents setting cookies for '.com' and similar domains - if (!$this->useList && substr_count($cookieDomain, '.') < 2 - || $this->useList && !self::getRegisteredDomain($cookieDomain) - ) { - return false; - } - return substr('.' . $requestHost, -strlen($cookieDomain)) == $cookieDomain; - } - - /** - * Removes subdomains to get the registered domain (the first after top-level) - * - * The method will check Public Suffix List to find out where top-level - * domain ends and registered domain starts. It will remove domain parts - * to the left of registered one. - * - * @param string $domain domain name - * - * @return string|bool registered domain, will return false if $domain is - * either invalid or a TLD itself - */ - public static function getRegisteredDomain($domain) - { - $domainParts = explode('.', ltrim($domain, '.')); - - // load the list if needed - if (empty(self::$psl)) { - $path = '@data_dir@' . DIRECTORY_SEPARATOR . 'HTTP_Request2'; - if (0 === strpos($path, '@' . 'data_dir@')) { - $path = realpath( - dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' - . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' - ); - } - self::$psl = include_once $path . DIRECTORY_SEPARATOR . 'public-suffix-list.php'; - } - - if (!($result = self::checkDomainsList($domainParts, self::$psl))) { - // known TLD, invalid domain name - return false; - } - - // unknown TLD - if (!strpos($result, '.')) { - // fallback to checking that domain "has at least two dots" - if (2 > ($count = count($domainParts))) { - return false; - } - return $domainParts[$count - 2] . '.' . $domainParts[$count - 1]; - } - return $result; - } - - /** - * Recursive helper method for {@link getRegisteredDomain()} - * - * @param array $domainParts remaining domain parts - * @param mixed $listNode node in {@link HTTP_Request2_CookieJar::$psl} to check - * - * @return string|null concatenated domain parts, null in case of error - */ - protected static function checkDomainsList(array $domainParts, $listNode) - { - $sub = array_pop($domainParts); - $result = null; - - if (!is_array($listNode) || is_null($sub) - || array_key_exists('!' . $sub, $listNode) - ) { - return $sub; - - } elseif (array_key_exists($sub, $listNode)) { - $result = self::checkDomainsList($domainParts, $listNode[$sub]); - - } elseif (array_key_exists('*', $listNode)) { - $result = self::checkDomainsList($domainParts, $listNode['*']); - - } else { - return $sub; - } - - return (strlen($result) > 0) ? ($result . '.' . $sub) : null; - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/Exception.php b/vendor/pear/http_request2/HTTP/Request2/Exception.php deleted file mode 100644 index d331372bf..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/Exception.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Base class for exceptions in PEAR - */ -require_once 'PEAR/Exception.php'; - -/** - * Base exception class for HTTP_Request2 package - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=132 - */ -class HTTP_Request2_Exception extends PEAR_Exception -{ - /** An invalid argument was passed to a method */ - const INVALID_ARGUMENT = 1; - /** Some required value was not available */ - const MISSING_VALUE = 2; - /** Request cannot be processed due to errors in PHP configuration */ - const MISCONFIGURATION = 3; - /** Error reading the local file */ - const READ_ERROR = 4; - - /** Server returned a response that does not conform to HTTP protocol */ - const MALFORMED_RESPONSE = 10; - /** Failure decoding Content-Encoding or Transfer-Encoding of response */ - const DECODE_ERROR = 20; - /** Operation timed out */ - const TIMEOUT = 30; - /** Number of redirects exceeded 'max_redirects' configuration parameter */ - const TOO_MANY_REDIRECTS = 40; - /** Redirect to a protocol other than http(s):// */ - const NON_HTTP_REDIRECT = 50; - - /** - * Native error code - * @var int - */ - private $_nativeCode; - - /** - * Constructor, can set package error code and native error code - * - * @param string $message exception message - * @param int $code package error code, one of class constants - * @param int $nativeCode error code from underlying PHP extension - */ - public function __construct($message = null, $code = null, $nativeCode = null) - { - parent::__construct($message, $code); - $this->_nativeCode = $nativeCode; - } - - /** - * Returns error code produced by underlying PHP extension - * - * For Socket Adapter this may contain error number returned by - * stream_socket_client(), for Curl Adapter this will contain error number - * returned by curl_errno() - * - * @return integer - */ - public function getNativeCode() - { - return $this->_nativeCode; - } -} - -/** - * Exception thrown in case of missing features - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_NotImplementedException extends HTTP_Request2_Exception -{ -} - -/** - * Exception that represents error in the program logic - * - * This exception usually implies a programmer's error, like passing invalid - * data to methods or trying to use PHP extensions that weren't installed or - * enabled. Usually exceptions of this kind will be thrown before request even - * starts. - * - * The exception will usually contain a package error code. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_LogicException extends HTTP_Request2_Exception -{ -} - -/** - * Exception thrown when connection to a web or proxy server fails - * - * The exception will not contain a package error code, but will contain - * native error code, as returned by stream_socket_client() or curl_errno(). - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_ConnectionException extends HTTP_Request2_Exception -{ -} - -/** - * Exception thrown when sending or receiving HTTP message fails - * - * The exception may contain both package error code and native error code. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_MessageException extends HTTP_Request2_Exception -{ -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/MultipartBody.php b/vendor/pear/http_request2/HTTP/Request2/MultipartBody.php deleted file mode 100644 index 54d23ec1a..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/MultipartBody.php +++ /dev/null @@ -1,268 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Exception class for HTTP_Request2 package */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class for building multipart/form-data request body - * - * The class helps to reduce memory consumption by streaming large file uploads - * from disk, it also allows monitoring of upload progress (see request #7630) - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://tools.ietf.org/html/rfc1867 - */ -class HTTP_Request2_MultipartBody -{ - /** - * MIME boundary - * @var string - */ - private $_boundary; - - /** - * Form parameters added via {@link HTTP_Request2::addPostParameter()} - * @var array - */ - private $_params = array(); - - /** - * File uploads added via {@link HTTP_Request2::addUpload()} - * @var array - */ - private $_uploads = array(); - - /** - * Header for parts with parameters - * @var string - */ - private $_headerParam = "--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n"; - - /** - * Header for parts with uploads - * @var string - */ - private $_headerUpload = "--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\nContent-Type: %s\r\n\r\n"; - - /** - * Current position in parameter and upload arrays - * - * First number is index of "current" part, second number is position within - * "current" part - * - * @var array - */ - private $_pos = array(0, 0); - - - /** - * Constructor. Sets the arrays with POST data. - * - * @param array $params values of form fields set via - * {@link HTTP_Request2::addPostParameter()} - * @param array $uploads file uploads set via - * {@link HTTP_Request2::addUpload()} - * @param bool $useBrackets whether to append brackets to array variable names - */ - public function __construct(array $params, array $uploads, $useBrackets = true) - { - $this->_params = self::_flattenArray('', $params, $useBrackets); - foreach ($uploads as $fieldName => $f) { - if (!is_array($f['fp'])) { - $this->_uploads[] = $f + array('name' => $fieldName); - } else { - for ($i = 0; $i < count($f['fp']); $i++) { - $upload = array( - 'name' => ($useBrackets? $fieldName . '[' . $i . ']': $fieldName) - ); - foreach (array('fp', 'filename', 'size', 'type') as $key) { - $upload[$key] = $f[$key][$i]; - } - $this->_uploads[] = $upload; - } - } - } - } - - /** - * Returns the length of the body to use in Content-Length header - * - * @return integer - */ - public function getLength() - { - $boundaryLength = strlen($this->getBoundary()); - $headerParamLength = strlen($this->_headerParam) - 4 + $boundaryLength; - $headerUploadLength = strlen($this->_headerUpload) - 8 + $boundaryLength; - $length = $boundaryLength + 6; - foreach ($this->_params as $p) { - $length += $headerParamLength + strlen($p[0]) + strlen($p[1]) + 2; - } - foreach ($this->_uploads as $u) { - $length += $headerUploadLength + strlen($u['name']) + strlen($u['type']) + - strlen($u['filename']) + $u['size'] + 2; - } - return $length; - } - - /** - * Returns the boundary to use in Content-Type header - * - * @return string - */ - public function getBoundary() - { - if (empty($this->_boundary)) { - $this->_boundary = '--' . md5('PEAR-HTTP_Request2-' . microtime()); - } - return $this->_boundary; - } - - /** - * Returns next chunk of request body - * - * @param integer $length Number of bytes to read - * - * @return string Up to $length bytes of data, empty string if at end - * @throws HTTP_Request2_LogicException - */ - public function read($length) - { - $ret = ''; - $boundary = $this->getBoundary(); - $paramCount = count($this->_params); - $uploadCount = count($this->_uploads); - while ($length > 0 && $this->_pos[0] <= $paramCount + $uploadCount) { - $oldLength = $length; - if ($this->_pos[0] < $paramCount) { - $param = sprintf( - $this->_headerParam, $boundary, $this->_params[$this->_pos[0]][0] - ) . $this->_params[$this->_pos[0]][1] . "\r\n"; - $ret .= substr($param, $this->_pos[1], $length); - $length -= min(strlen($param) - $this->_pos[1], $length); - - } elseif ($this->_pos[0] < $paramCount + $uploadCount) { - $pos = $this->_pos[0] - $paramCount; - $header = sprintf( - $this->_headerUpload, $boundary, $this->_uploads[$pos]['name'], - $this->_uploads[$pos]['filename'], $this->_uploads[$pos]['type'] - ); - if ($this->_pos[1] < strlen($header)) { - $ret .= substr($header, $this->_pos[1], $length); - $length -= min(strlen($header) - $this->_pos[1], $length); - } - $filePos = max(0, $this->_pos[1] - strlen($header)); - if ($filePos < $this->_uploads[$pos]['size']) { - while ($length > 0 && !feof($this->_uploads[$pos]['fp'])) { - if (false === ($chunk = fread($this->_uploads[$pos]['fp'], $length))) { - throw new HTTP_Request2_LogicException( - 'Failed reading file upload', HTTP_Request2_Exception::READ_ERROR - ); - } - $ret .= $chunk; - $length -= strlen($chunk); - } - } - if ($length > 0) { - $start = $this->_pos[1] + ($oldLength - $length) - - strlen($header) - $this->_uploads[$pos]['size']; - $ret .= substr("\r\n", $start, $length); - $length -= min(2 - $start, $length); - } - - } else { - $closing = '--' . $boundary . "--\r\n"; - $ret .= substr($closing, $this->_pos[1], $length); - $length -= min(strlen($closing) - $this->_pos[1], $length); - } - if ($length > 0) { - $this->_pos = array($this->_pos[0] + 1, 0); - } else { - $this->_pos[1] += $oldLength; - } - } - return $ret; - } - - /** - * Sets the current position to the start of the body - * - * This allows reusing the same body in another request - */ - public function rewind() - { - $this->_pos = array(0, 0); - foreach ($this->_uploads as $u) { - rewind($u['fp']); - } - } - - /** - * Returns the body as string - * - * Note that it reads all file uploads into memory so it is a good idea not - * to use this method with large file uploads and rely on read() instead. - * - * @return string - */ - public function __toString() - { - $this->rewind(); - return $this->read($this->getLength()); - } - - - /** - * Helper function to change the (probably multidimensional) associative array - * into the simple one. - * - * @param string $name name for item - * @param mixed $values item's values - * @param bool $useBrackets whether to append [] to array variables' names - * - * @return array array with the following items: array('item name', 'item value'); - */ - private static function _flattenArray($name, $values, $useBrackets) - { - if (!is_array($values)) { - return array(array($name, $values)); - } else { - $ret = array(); - foreach ($values as $k => $v) { - if (empty($name)) { - $newName = $k; - } elseif ($useBrackets) { - $newName = $name . '[' . $k . ']'; - } else { - $newName = $name; - } - $ret = array_merge($ret, self::_flattenArray($newName, $v, $useBrackets)); - } - return $ret; - } - } -} -?> diff --git a/vendor/pear/http_request2/HTTP/Request2/Observer/Log.php b/vendor/pear/http_request2/HTTP/Request2/Observer/Log.php deleted file mode 100644 index 2ba9f59df..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/Observer/Log.php +++ /dev/null @@ -1,192 +0,0 @@ - - * @author Alexey Borzov - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * A debug observer useful for debugging / testing. - * - * This observer logs to a log target data corresponding to the various request - * and response events, it logs by default to php://output but can be configured - * to log to a file or via the PEAR Log package. - * - * A simple example: - * - * require_once 'HTTP/Request2.php'; - * require_once 'HTTP/Request2/Observer/Log.php'; - * - * $request = new HTTP_Request2('http://www.example.com'); - * $observer = new HTTP_Request2_Observer_Log(); - * $request->attach($observer); - * $request->send(); - * - * - * A more complex example with PEAR Log: - * - * require_once 'HTTP/Request2.php'; - * require_once 'HTTP/Request2/Observer/Log.php'; - * require_once 'Log.php'; - * - * $request = new HTTP_Request2('http://www.example.com'); - * // we want to log with PEAR log - * $observer = new HTTP_Request2_Observer_Log(Log::factory('console')); - * - * // we only want to log received headers - * $observer->events = array('receivedHeaders'); - * - * $request->attach($observer); - * $request->send(); - * - * - * @category HTTP - * @package HTTP_Request2 - * @author David Jean Louis - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Observer_Log implements SplObserver -{ - // properties {{{ - - /** - * The log target, it can be a a resource or a PEAR Log instance. - * - * @var resource|Log $target - */ - protected $target = null; - - /** - * The events to log. - * - * @var array $events - */ - public $events = array( - 'connect', - 'sentHeaders', - 'sentBody', - 'receivedHeaders', - 'receivedBody', - 'disconnect', - ); - - // }}} - // __construct() {{{ - - /** - * Constructor. - * - * @param mixed $target Can be a file path (default: php://output), a resource, - * or an instance of the PEAR Log class. - * @param array $events Array of events to listen to (default: all events) - * - * @return void - */ - public function __construct($target = 'php://output', array $events = array()) - { - if (!empty($events)) { - $this->events = $events; - } - if (is_resource($target) || $target instanceof Log) { - $this->target = $target; - } elseif (false === ($this->target = @fopen($target, 'ab'))) { - throw new HTTP_Request2_Exception("Unable to open '{$target}'"); - } - } - - // }}} - // update() {{{ - - /** - * Called when the request notifies us of an event. - * - * @param HTTP_Request2 $subject The HTTP_Request2 instance - * - * @return void - */ - public function update(SplSubject $subject) - { - $event = $subject->getLastEvent(); - if (!in_array($event['name'], $this->events)) { - return; - } - - switch ($event['name']) { - case 'connect': - $this->log('* Connected to ' . $event['data']); - break; - case 'sentHeaders': - $headers = explode("\r\n", $event['data']); - array_pop($headers); - foreach ($headers as $header) { - $this->log('> ' . $header); - } - break; - case 'sentBody': - $this->log('> ' . $event['data'] . ' byte(s) sent'); - break; - case 'receivedHeaders': - $this->log(sprintf( - '< HTTP/%s %s %s', $event['data']->getVersion(), - $event['data']->getStatus(), $event['data']->getReasonPhrase() - )); - $headers = $event['data']->getHeader(); - foreach ($headers as $key => $val) { - $this->log('< ' . $key . ': ' . $val); - } - $this->log('< '); - break; - case 'receivedBody': - $this->log($event['data']->getBody()); - break; - case 'disconnect': - $this->log('* Disconnected'); - break; - } - } - - // }}} - // log() {{{ - - /** - * Logs the given message to the configured target. - * - * @param string $message Message to display - * - * @return void - */ - protected function log($message) - { - if ($this->target instanceof Log) { - $this->target->debug($message); - } elseif (is_resource($this->target)) { - fwrite($this->target, $message . "\r\n"); - } - } - - // }}} -} - -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/Response.php b/vendor/pear/http_request2/HTTP/Request2/Response.php deleted file mode 100644 index 56ee6c689..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/Response.php +++ /dev/null @@ -1,631 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class representing a HTTP response - * - * The class is designed to be used in "streaming" scenario, building the - * response as it is being received: - * - * $statusLine = read_status_line(); - * $response = new HTTP_Request2_Response($statusLine); - * do { - * $headerLine = read_header_line(); - * $response->parseHeaderLine($headerLine); - * } while ($headerLine != ''); - * - * while ($chunk = read_body()) { - * $response->appendBody($chunk); - * } - * - * var_dump($response->getHeader(), $response->getCookies(), $response->getBody()); - * - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://tools.ietf.org/html/rfc2616#section-6 - */ -class HTTP_Request2_Response -{ - /** - * HTTP protocol version (e.g. 1.0, 1.1) - * @var string - */ - protected $version; - - /** - * Status code - * @var integer - * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 - */ - protected $code; - - /** - * Reason phrase - * @var string - * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 - */ - protected $reasonPhrase; - - /** - * Effective URL (may be different from original request URL in case of redirects) - * @var string - */ - protected $effectiveUrl; - - /** - * Associative array of response headers - * @var array - */ - protected $headers = array(); - - /** - * Cookies set in the response - * @var array - */ - protected $cookies = array(); - - /** - * Name of last header processed by parseHederLine() - * - * Used to handle the headers that span multiple lines - * - * @var string - */ - protected $lastHeader = null; - - /** - * Response body - * @var string - */ - protected $body = ''; - - /** - * Whether the body is still encoded by Content-Encoding - * - * cURL provides the decoded body to the callback; if we are reading from - * socket the body is still gzipped / deflated - * - * @var bool - */ - protected $bodyEncoded; - - /** - * Associative array of HTTP status code / reason phrase. - * - * @var array - * @link http://tools.ietf.org/html/rfc2616#section-10 - */ - protected static $phrases = array( - - // 1xx: Informational - Request received, continuing process - 100 => 'Continue', - 101 => 'Switching Protocols', - - // 2xx: Success - The action was successfully received, understood and - // accepted - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - - // 3xx: Redirection - Further action must be taken in order to complete - // the request - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', // 1.1 - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 307 => 'Temporary Redirect', - - // 4xx: Client Error - The request contains bad syntax or cannot be - // fulfilled - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - - // 5xx: Server Error - The server failed to fulfill an apparently - // valid request - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 509 => 'Bandwidth Limit Exceeded', - - ); - - /** - * Returns the default reason phrase for the given code or all reason phrases - * - * @param int $code Response code - * - * @return string|array|null Default reason phrase for $code if $code is given - * (null if no phrase is available), array of all - * reason phrases if $code is null - * @link http://pear.php.net/bugs/18716 - */ - public static function getDefaultReasonPhrase($code = null) - { - if (null === $code) { - return self::$phrases; - } else { - return isset(self::$phrases[$code]) ? self::$phrases[$code] : null; - } - } - - /** - * Constructor, parses the response status line - * - * @param string $statusLine Response status line (e.g. "HTTP/1.1 200 OK") - * @param bool $bodyEncoded Whether body is still encoded by Content-Encoding - * @param string $effectiveUrl Effective URL of the response - * - * @throws HTTP_Request2_MessageException if status line is invalid according to spec - */ - public function __construct($statusLine, $bodyEncoded = true, $effectiveUrl = null) - { - if (!preg_match('!^HTTP/(\d\.\d) (\d{3})(?: (.+))?!', $statusLine, $m)) { - throw new HTTP_Request2_MessageException( - "Malformed response: {$statusLine}", - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } - $this->version = $m[1]; - $this->code = intval($m[2]); - $this->reasonPhrase = !empty($m[3]) ? trim($m[3]) : self::getDefaultReasonPhrase($this->code); - $this->bodyEncoded = (bool)$bodyEncoded; - $this->effectiveUrl = (string)$effectiveUrl; - } - - /** - * Parses the line from HTTP response filling $headers array - * - * The method should be called after reading the line from socket or receiving - * it into cURL callback. Passing an empty string here indicates the end of - * response headers and triggers additional processing, so be sure to pass an - * empty string in the end. - * - * @param string $headerLine Line from HTTP response - */ - public function parseHeaderLine($headerLine) - { - $headerLine = trim($headerLine, "\r\n"); - - if ('' == $headerLine) { - // empty string signals the end of headers, process the received ones - if (!empty($this->headers['set-cookie'])) { - $cookies = is_array($this->headers['set-cookie'])? - $this->headers['set-cookie']: - array($this->headers['set-cookie']); - foreach ($cookies as $cookieString) { - $this->parseCookie($cookieString); - } - unset($this->headers['set-cookie']); - } - foreach (array_keys($this->headers) as $k) { - if (is_array($this->headers[$k])) { - $this->headers[$k] = implode(', ', $this->headers[$k]); - } - } - - } elseif (preg_match('!^([^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+):(.+)$!', $headerLine, $m)) { - // string of the form header-name: header value - $name = strtolower($m[1]); - $value = trim($m[2]); - if (empty($this->headers[$name])) { - $this->headers[$name] = $value; - } else { - if (!is_array($this->headers[$name])) { - $this->headers[$name] = array($this->headers[$name]); - } - $this->headers[$name][] = $value; - } - $this->lastHeader = $name; - - } elseif (preg_match('!^\s+(.+)$!', $headerLine, $m) && $this->lastHeader) { - // continuation of a previous header - if (!is_array($this->headers[$this->lastHeader])) { - $this->headers[$this->lastHeader] .= ' ' . trim($m[1]); - } else { - $key = count($this->headers[$this->lastHeader]) - 1; - $this->headers[$this->lastHeader][$key] .= ' ' . trim($m[1]); - } - } - } - - /** - * Parses a Set-Cookie header to fill $cookies array - * - * @param string $cookieString value of Set-Cookie header - * - * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html - */ - protected function parseCookie($cookieString) - { - $cookie = array( - 'expires' => null, - 'domain' => null, - 'path' => null, - 'secure' => false - ); - - if (!strpos($cookieString, ';')) { - // Only a name=value pair - $pos = strpos($cookieString, '='); - $cookie['name'] = trim(substr($cookieString, 0, $pos)); - $cookie['value'] = trim(substr($cookieString, $pos + 1)); - - } else { - // Some optional parameters are supplied - $elements = explode(';', $cookieString); - $pos = strpos($elements[0], '='); - $cookie['name'] = trim(substr($elements[0], 0, $pos)); - $cookie['value'] = trim(substr($elements[0], $pos + 1)); - - for ($i = 1; $i < count($elements); $i++) { - if (false === strpos($elements[$i], '=')) { - $elName = trim($elements[$i]); - $elValue = null; - } else { - list ($elName, $elValue) = array_map('trim', explode('=', $elements[$i])); - } - $elName = strtolower($elName); - if ('secure' == $elName) { - $cookie['secure'] = true; - } elseif ('expires' == $elName) { - $cookie['expires'] = str_replace('"', '', $elValue); - } elseif ('path' == $elName || 'domain' == $elName) { - $cookie[$elName] = urldecode($elValue); - } else { - $cookie[$elName] = $elValue; - } - } - } - $this->cookies[] = $cookie; - } - - /** - * Appends a string to the response body - * - * @param string $bodyChunk part of response body - */ - public function appendBody($bodyChunk) - { - $this->body .= $bodyChunk; - } - - /** - * Returns the effective URL of the response - * - * This may be different from the request URL if redirects were followed. - * - * @return string - * @link http://pear.php.net/bugs/bug.php?id=18412 - */ - public function getEffectiveUrl() - { - return $this->effectiveUrl; - } - - /** - * Returns the status code - * - * @return integer - */ - public function getStatus() - { - return $this->code; - } - - /** - * Returns the reason phrase - * - * @return string - */ - public function getReasonPhrase() - { - return $this->reasonPhrase; - } - - /** - * Whether response is a redirect that can be automatically handled by HTTP_Request2 - * - * @return bool - */ - public function isRedirect() - { - return in_array($this->code, array(300, 301, 302, 303, 307)) - && isset($this->headers['location']); - } - - /** - * Returns either the named header or all response headers - * - * @param string $headerName Name of header to return - * - * @return string|array Value of $headerName header (null if header is - * not present), array of all response headers if - * $headerName is null - */ - public function getHeader($headerName = null) - { - if (null === $headerName) { - return $this->headers; - } else { - $headerName = strtolower($headerName); - return isset($this->headers[$headerName])? $this->headers[$headerName]: null; - } - } - - /** - * Returns cookies set in response - * - * @return array - */ - public function getCookies() - { - return $this->cookies; - } - - /** - * Returns the body of the response - * - * @return string - * @throws HTTP_Request2_Exception if body cannot be decoded - */ - public function getBody() - { - if (0 == strlen($this->body) || !$this->bodyEncoded - || !in_array(strtolower($this->getHeader('content-encoding')), array('gzip', 'deflate')) - ) { - return $this->body; - - } else { - if (extension_loaded('mbstring') && (2 & ini_get('mbstring.func_overload'))) { - $oldEncoding = mb_internal_encoding(); - mb_internal_encoding('8bit'); - } - - try { - switch (strtolower($this->getHeader('content-encoding'))) { - case 'gzip': - $decoded = self::decodeGzip($this->body); - break; - case 'deflate': - $decoded = self::decodeDeflate($this->body); - } - } catch (Exception $e) { - } - - if (!empty($oldEncoding)) { - mb_internal_encoding($oldEncoding); - } - if (!empty($e)) { - throw $e; - } - return $decoded; - } - } - - /** - * Get the HTTP version of the response - * - * @return string - */ - public function getVersion() - { - return $this->version; - } - - /** - * Decodes the message-body encoded by gzip - * - * The real decoding work is done by gzinflate() built-in function, this - * method only parses the header and checks data for compliance with - * RFC 1952 - * - * @param string $data gzip-encoded data - * - * @return string decoded data - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_MessageException - * @link http://tools.ietf.org/html/rfc1952 - */ - public static function decodeGzip($data) - { - $length = strlen($data); - // If it doesn't look like gzip-encoded data, don't bother - if (18 > $length || strcmp(substr($data, 0, 2), "\x1f\x8b")) { - return $data; - } - if (!function_exists('gzinflate')) { - throw new HTTP_Request2_LogicException( - 'Unable to decode body: gzip extension not available', - HTTP_Request2_Exception::MISCONFIGURATION - ); - } - $method = ord(substr($data, 2, 1)); - if (8 != $method) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: unknown compression method', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $flags = ord(substr($data, 3, 1)); - if ($flags & 224) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: reserved bits are set', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - - // header is 10 bytes minimum. may be longer, though. - $headerLength = 10; - // extra fields, need to skip 'em - if ($flags & 4) { - if ($length - $headerLength - 2 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $extraLength = unpack('v', substr($data, 10, 2)); - if ($length - $headerLength - 2 - $extraLength[1] < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $headerLength += $extraLength[1] + 2; - } - // file name, need to skip that - if ($flags & 8) { - if ($length - $headerLength - 1 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $filenameLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $filenameLength || $length - $headerLength - $filenameLength - 1 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $headerLength += $filenameLength + 1; - } - // comment, need to skip that also - if ($flags & 16) { - if ($length - $headerLength - 1 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $commentLength = strpos(substr($data, $headerLength), chr(0)); - if (false === $commentLength || $length - $headerLength - $commentLength - 1 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $headerLength += $commentLength + 1; - } - // have a CRC for header. let's check - if ($flags & 2) { - if ($length - $headerLength - 2 < 8) { - throw new HTTP_Request2_MessageException( - 'Error parsing gzip header: data too short', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $crcReal = 0xffff & crc32(substr($data, 0, $headerLength)); - $crcStored = unpack('v', substr($data, $headerLength, 2)); - if ($crcReal != $crcStored[1]) { - throw new HTTP_Request2_MessageException( - 'Header CRC check failed', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - $headerLength += 2; - } - // unpacked data CRC and size at the end of encoded data - $tmp = unpack('V2', substr($data, -8)); - $dataCrc = $tmp[1]; - $dataSize = $tmp[2]; - - // finally, call the gzinflate() function - // don't pass $dataSize to gzinflate, see bugs #13135, #14370 - $unpacked = gzinflate(substr($data, $headerLength, -8)); - if (false === $unpacked) { - throw new HTTP_Request2_MessageException( - 'gzinflate() call failed', - HTTP_Request2_Exception::DECODE_ERROR - ); - } elseif ($dataSize != strlen($unpacked)) { - throw new HTTP_Request2_MessageException( - 'Data size check failed', - HTTP_Request2_Exception::DECODE_ERROR - ); - } elseif ((0xffffffff & $dataCrc) != (0xffffffff & crc32($unpacked))) { - throw new HTTP_Request2_Exception( - 'Data CRC check failed', - HTTP_Request2_Exception::DECODE_ERROR - ); - } - return $unpacked; - } - - /** - * Decodes the message-body encoded by deflate - * - * @param string $data deflate-encoded data - * - * @return string decoded data - * @throws HTTP_Request2_LogicException - */ - public static function decodeDeflate($data) - { - if (!function_exists('gzuncompress')) { - throw new HTTP_Request2_LogicException( - 'Unable to decode body: gzip extension not available', - HTTP_Request2_Exception::MISCONFIGURATION - ); - } - // RFC 2616 defines 'deflate' encoding as zlib format from RFC 1950, - // while many applications send raw deflate stream from RFC 1951. - // We should check for presence of zlib header and use gzuncompress() or - // gzinflate() as needed. See bug #15305 - $header = unpack('n', substr($data, 0, 2)); - return (0 == $header[1] % 31)? gzuncompress($data): gzinflate($data); - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/SOCKS5.php b/vendor/pear/http_request2/HTTP/Request2/SOCKS5.php deleted file mode 100644 index a801c17e8..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/SOCKS5.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Socket wrapper class used by Socket Adapter */ -require_once 'HTTP/Request2/SocketWrapper.php'; - -/** - * SOCKS5 proxy connection class (used by Socket Adapter) - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://pear.php.net/bugs/bug.php?id=19332 - * @link http://tools.ietf.org/html/rfc1928 - */ -class HTTP_Request2_SOCKS5 extends HTTP_Request2_SocketWrapper -{ - /** - * Constructor, tries to connect and authenticate to a SOCKS5 proxy - * - * @param string $address Proxy address, e.g. 'tcp://localhost:1080' - * @param int $timeout Connection timeout (seconds) - * @param array $contextOptions Stream context options - * @param string $username Proxy user name - * @param string $password Proxy password - * - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_ConnectionException - * @throws HTTP_Request2_MessageException - */ - public function __construct( - $address, $timeout = 10, array $contextOptions = array(), - $username = null, $password = null - ) { - parent::__construct($address, $timeout, $contextOptions); - - if (strlen($username)) { - $request = pack('C4', 5, 2, 0, 2); - } else { - $request = pack('C3', 5, 1, 0); - } - $this->write($request); - $response = unpack('Cversion/Cmethod', $this->read(3)); - if (5 != $response['version']) { - throw new HTTP_Request2_MessageException( - 'Invalid version received from SOCKS5 proxy: ' . $response['version'], - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } - switch ($response['method']) { - case 2: - $this->performAuthentication($username, $password); - case 0: - break; - default: - throw new HTTP_Request2_ConnectionException( - "Connection rejected by proxy due to unsupported auth method" - ); - } - } - - /** - * Performs username/password authentication for SOCKS5 - * - * @param string $username Proxy user name - * @param string $password Proxy password - * - * @throws HTTP_Request2_ConnectionException - * @throws HTTP_Request2_MessageException - * @link http://tools.ietf.org/html/rfc1929 - */ - protected function performAuthentication($username, $password) - { - $request = pack('C2', 1, strlen($username)) . $username - . pack('C', strlen($password)) . $password; - - $this->write($request); - $response = unpack('Cvn/Cstatus', $this->read(3)); - if (1 != $response['vn'] || 0 != $response['status']) { - throw new HTTP_Request2_ConnectionException( - 'Connection rejected by proxy due to invalid username and/or password' - ); - } - } - - /** - * Connects to a remote host via proxy - * - * @param string $remoteHost Remote host - * @param int $remotePort Remote port - * - * @throws HTTP_Request2_ConnectionException - * @throws HTTP_Request2_MessageException - */ - public function connect($remoteHost, $remotePort) - { - $request = pack('C5', 0x05, 0x01, 0x00, 0x03, strlen($remoteHost)) - . $remoteHost . pack('n', $remotePort); - - $this->write($request); - $response = unpack('Cversion/Creply/Creserved', $this->read(1024)); - if (5 != $response['version'] || 0 != $response['reserved']) { - throw new HTTP_Request2_MessageException( - 'Invalid response received from SOCKS5 proxy', - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } elseif (0 != $response['reply']) { - throw new HTTP_Request2_ConnectionException( - "Unable to connect to {$remoteHost}:{$remotePort} through SOCKS5 proxy", - 0, $response['reply'] - ); - } - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/HTTP/Request2/SocketWrapper.php b/vendor/pear/http_request2/HTTP/Request2/SocketWrapper.php deleted file mode 100644 index 41497ba96..000000000 --- a/vendor/pear/http_request2/HTTP/Request2/SocketWrapper.php +++ /dev/null @@ -1,297 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Exception classes for HTTP_Request2 package */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Socket wrapper class used by Socket Adapter - * - * Needed to properly handle connection errors, global timeout support and - * similar things. Loosely based on Net_Socket used by older HTTP_Request. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://pear.php.net/bugs/bug.php?id=19332 - * @link http://tools.ietf.org/html/rfc1928 - */ -class HTTP_Request2_SocketWrapper -{ - /** - * PHP warning messages raised during stream_socket_client() call - * @var array - */ - protected $connectionWarnings = array(); - - /** - * Connected socket - * @var resource - */ - protected $socket; - - /** - * Sum of start time and global timeout, exception will be thrown if request continues past this time - * @var integer - */ - protected $deadline; - - /** - * Global timeout value, mostly for exception messages - * @var integer - */ - protected $timeout; - - /** - * Class constructor, tries to establish connection - * - * @param string $address Address for stream_socket_client() call, - * e.g. 'tcp://localhost:80' - * @param int $timeout Connection timeout (seconds) - * @param array $contextOptions Context options - * - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_ConnectionException - */ - public function __construct($address, $timeout, array $contextOptions = array()) - { - if (!empty($contextOptions) - && !isset($contextOptions['socket']) && !isset($contextOptions['ssl']) - ) { - // Backwards compatibility with 2.1.0 and 2.1.1 releases - $contextOptions = array('ssl' => $contextOptions); - } - $context = stream_context_create(); - foreach ($contextOptions as $wrapper => $options) { - foreach ($options as $name => $value) { - if (!stream_context_set_option($context, $wrapper, $name, $value)) { - throw new HTTP_Request2_LogicException( - "Error setting '{$wrapper}' wrapper context option '{$name}'" - ); - } - } - } - set_error_handler(array($this, 'connectionWarningsHandler')); - $this->socket = stream_socket_client( - $address, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context - ); - restore_error_handler(); - // if we fail to bind to a specified local address (see request #19515), - // connection still succeeds, albeit with a warning. Throw an Exception - // with the warning text in this case as that connection is unlikely - // to be what user wants and as Curl throws an error in similar case. - if ($this->connectionWarnings) { - if ($this->socket) { - fclose($this->socket); - } - $error = $errstr ? $errstr : implode("\n", $this->connectionWarnings); - throw new HTTP_Request2_ConnectionException( - "Unable to connect to {$address}. Error: {$error}", 0, $errno - ); - } - } - - /** - * Destructor, disconnects socket - */ - public function __destruct() - { - fclose($this->socket); - } - - /** - * Wrapper around fread(), handles global request timeout - * - * @param int $length Reads up to this number of bytes - * - * @return string Data read from socket - * @throws HTTP_Request2_MessageException In case of timeout - */ - public function read($length) - { - if ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - $data = fread($this->socket, $length); - $this->checkTimeout(); - return $data; - } - - /** - * Reads until either the end of the socket or a newline, whichever comes first - * - * Strips the trailing newline from the returned data, handles global - * request timeout. Method idea borrowed from Net_Socket PEAR package. - * - * @param int $bufferSize buffer size to use for reading - * @param int $localTimeout timeout value to use just for this call - * (used when waiting for "100 Continue" response) - * - * @return string Available data up to the newline (not including newline) - * @throws HTTP_Request2_MessageException In case of timeout - */ - public function readLine($bufferSize, $localTimeout = null) - { - $line = ''; - while (!feof($this->socket)) { - if (null !== $localTimeout) { - stream_set_timeout($this->socket, $localTimeout); - } elseif ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - - $line .= @fgets($this->socket, $bufferSize); - - if (null === $localTimeout) { - $this->checkTimeout(); - - } else { - $info = stream_get_meta_data($this->socket); - // reset socket timeout if we don't have request timeout specified, - // prevents further calls failing with a bogus Exception - if (!$this->deadline) { - $default = (int)@ini_get('default_socket_timeout'); - stream_set_timeout($this->socket, $default > 0 ? $default : PHP_INT_MAX); - } - if ($info['timed_out']) { - throw new HTTP_Request2_MessageException( - "readLine() call timed out", HTTP_Request2_Exception::TIMEOUT - ); - } - } - if (substr($line, -1) == "\n") { - return rtrim($line, "\r\n"); - } - } - return $line; - } - - /** - * Wrapper around fwrite(), handles global request timeout - * - * @param string $data String to be written - * - * @return int - * @throws HTTP_Request2_MessageException - */ - public function write($data) - { - if ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - $written = fwrite($this->socket, $data); - $this->checkTimeout(); - // http://www.php.net/manual/en/function.fwrite.php#96951 - if ($written < strlen($data)) { - throw new HTTP_Request2_MessageException('Error writing request'); - } - return $written; - } - - /** - * Tests for end-of-file on a socket - * - * @return bool - */ - public function eof() - { - return feof($this->socket); - } - - /** - * Sets request deadline - * - * @param int $deadline Exception will be thrown if request continues - * past this time - * @param int $timeout Original request timeout value, to use in - * Exception message - */ - public function setDeadline($deadline, $timeout) - { - $this->deadline = $deadline; - $this->timeout = $timeout; - } - - /** - * Turns on encryption on a socket - * - * @throws HTTP_Request2_ConnectionException - */ - public function enableCrypto() - { - $modes = array( - STREAM_CRYPTO_METHOD_TLS_CLIENT, - STREAM_CRYPTO_METHOD_SSLv3_CLIENT, - STREAM_CRYPTO_METHOD_SSLv23_CLIENT, - STREAM_CRYPTO_METHOD_SSLv2_CLIENT - ); - - foreach ($modes as $mode) { - if (stream_socket_enable_crypto($this->socket, true, $mode)) { - return; - } - } - throw new HTTP_Request2_ConnectionException( - 'Failed to enable secure connection when connecting through proxy' - ); - } - - /** - * Throws an Exception if stream timed out - * - * @throws HTTP_Request2_MessageException - */ - protected function checkTimeout() - { - $info = stream_get_meta_data($this->socket); - if ($info['timed_out'] || $this->deadline && time() > $this->deadline) { - $reason = $this->deadline - ? "after {$this->timeout} second(s)" - : 'due to default_socket_timeout php.ini setting'; - throw new HTTP_Request2_MessageException( - "Request timed out {$reason}", HTTP_Request2_Exception::TIMEOUT - ); - } - } - - /** - * Error handler to use during stream_socket_client() call - * - * One stream_socket_client() call may produce *multiple* PHP warnings - * (especially OpenSSL-related), we keep them in an array to later use for - * the message of HTTP_Request2_ConnectionException - * - * @param int $errno error level - * @param string $errstr error message - * - * @return bool - */ - protected function connectionWarningsHandler($errno, $errstr) - { - if ($errno & E_WARNING) { - array_unshift($this->connectionWarnings, $errstr); - } - return true; - } -} -?> diff --git a/vendor/pear/http_request2/README.md b/vendor/pear/http_request2/README.md deleted file mode 100644 index eef00606b..000000000 --- a/vendor/pear/http_request2/README.md +++ /dev/null @@ -1,80 +0,0 @@ - -# HTTP_Request2 - -Provides an easy way to perform HTTP requests, uses pluggable adapters - -* Socket: pure PHP implementation of HTTP protocol (does *not* use http stream wrapper), based on older [PEAR HTTP_Request] package -* Curl: wrapper around PHP's cURL extension -* Mock: used for testing packages depending on HTTP_Request2, returns predefined responses without network interaction - -Both Socket and Curl adapters support POST requests with data and file uploads, basic and digest -authentication, cookies, managing cookies across requests, HTTP and SOCKS5 proxies, gzip and -deflate encodings, redirects, monitoring the request progress with Observers... - -This package is [PEAR HTTP_Request2] and has been migrated from [PEAR SVN] - -Please report all issues via the [PEAR bug tracker]. - -Pull requests are welcome. - -[PEAR HTTP_Request]: http://pear.php.net/package/HTTP_Request/ -[PEAR HTTP_Request2]: http://pear.php.net/package/HTTP_Request2/ -[PEAR SVN]: https://svn.php.net/repository/pear/packages/HTTP_Request2 -[PEAR bug tracker]: http://pear.php.net/bugs/search.php?cmd=display&package_name[]=HTTP_Request2 - -## Basic usage - -```PHP -require_once 'HTTP/Request2.php'; - -$request = new HTTP_Request2('http://pear.php.net/', HTTP_Request2::METHOD_GET); -try { - $response = $request->send(); - if (200 == $response->getStatus()) { - echo $response->getBody(); - } else { - echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' . - $response->getReasonPhrase(); - } -} catch (HTTP_Request2_Exception $e) { - echo 'Error: ' . $e->getMessage(); -} -``` - -## Documentation - -...is available on PEAR website - - * Numerous [configuration options](http://pear.php.net/manual/en/package.http.http-request2.config.php) - * How to populate [the request object](http://pear.php.net/manual/en/package.http.http-request2.request.php) - * Description of [available adapters](http://pear.php.net/manual/en/package.http.http-request2.adapters.php) - * Processing of [HTTP response](http://pear.php.net/manual/en/package.http.http-request2.response.php) - * Monitoring the progress of request with [observers](http://pear.php.net/manual/en/package.http.http-request2.observers.php) - * Possible [exceptions](http://pear.php.net/manual/en/package.http.http-request2.exceptions.php) - -[Generated API documentation](http://pear.php.net/package/HTTP_Request2/docs/latest/) for the current release is also there. - -## Testing, Packaging and Installing (Pear) - -To test, run either - - $ phpunit tests/ - -or - - $ pear run-tests -r - -You may need to set up the NetworkConfig.php file if you want to perform tests that interact with a web server. -Its template is NetworkConfig.php.dist file, consult it for the details. - -To build, simply - - $ pear package - -To install from scratch - - $ pear install package.xml - -To upgrade - - $ pear upgrade -f package.xml diff --git a/vendor/pear/http_request2/composer.json b/vendor/pear/http_request2/composer.json deleted file mode 100644 index 92c6ca0fc..000000000 --- a/vendor/pear/http_request2/composer.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name" : "pear/http_request2", - "description" : "Provides an easy way to perform HTTP requests.", - "type" : "library", - "keywords" : [ "http", "request", "pear", "curl" ], - "homepage" : "http://pear.php.net/package/HTTP_Request2", - "license" : "BSD-3-Clause", - "authors" : [ - { - "name" : "Alexey Borzov", - "email" : "avb@php.net" - } - ], - "support": { - "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=HTTP_Request2", - "source": "https://github.com/pear/HTTP_Request2" - }, - "require" : { - "php" : ">=5.2.0", - "pear/net_url2" : ">=2.0.0", - "pear/pear_exception" : "*" - }, - "suggest" : { - "ext-fileinfo" : "Adds support for looking up mime-types using finfo.", - "ext-zlib" : "Allows handling gzip compressed responses.", - "lib-curl" : "Allows using cURL as a request backend.", - "lib-openssl" : "Allows handling SSL requests when not using cURL." - }, - "autoload": { - "psr-0": { - "HTTP_Request2" : "" - } - } -} diff --git a/vendor/pear/http_request2/data/generate-list.php b/vendor/pear/http_request2/data/generate-list.php deleted file mode 100644 index 895247f4e..000000000 --- a/vendor/pear/http_request2/data/generate-list.php +++ /dev/null @@ -1,96 +0,0 @@ - "); - } - - if (0 == ($count = count($valueTree))) { - fwrite($fp, 'true'); - } else { - fwrite($fp, "array(\n"); - for ($keys = array_keys($valueTree), $i = 0; $i < $count; $i++) { - writeNode($fp, $valueTree[$keys[$i]], $keys[$i], $indent + 1); - if ($i + 1 != $count) { - fwrite($fp, ",\n"); - } else { - fwrite($fp, "\n"); - } - } - fwrite($fp, str_repeat(' ', $indent) . ")"); - } -} - - -try { - $request = new HTTP_Request2(LIST_URL); - $response = $request->send(); - if (200 != $response->getStatus()) { - throw new Exception("List download URL returned status: " . - $response->getStatus() . ' ' . $response->getReasonPhrase()); - } - $list = $response->getBody(); - if (false === strpos($list, '// ===BEGIN ICANN DOMAINS===')) { - throw new Exception("List download URL does not contain expected phrase"); - } - if (!($fp = @fopen(OUTPUT_FILE, 'wt'))) { - throw new Exception("Unable to open " . OUTPUT_FILE); - } - -} catch (Exception $e) { - die($e->getMessage()); -} - -$tldTree = array(); -$license = true; - -fwrite($fp, ""); -fclose($fp); -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/data/public-suffix-list.php b/vendor/pear/http_request2/data/public-suffix-list.php deleted file mode 100644 index af9273301..000000000 --- a/vendor/pear/http_request2/data/public-suffix-list.php +++ /dev/null @@ -1,6701 +0,0 @@ - array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'net' => true, - 'mil' => true, - 'org' => true - ), - 'ad' => array( - 'nom' => true - ), - 'ae' => array( - 'co' => true, - 'net' => true, - 'org' => true, - 'sch' => true, - 'ac' => true, - 'gov' => true, - 'mil' => true - ), - 'aero' => array( - 'accident-investigation' => true, - 'accident-prevention' => true, - 'aerobatic' => true, - 'aeroclub' => true, - 'aerodrome' => true, - 'agents' => true, - 'aircraft' => true, - 'airline' => true, - 'airport' => true, - 'air-surveillance' => true, - 'airtraffic' => true, - 'air-traffic-control' => true, - 'ambulance' => true, - 'amusement' => true, - 'association' => true, - 'author' => true, - 'ballooning' => true, - 'broker' => true, - 'caa' => true, - 'cargo' => true, - 'catering' => true, - 'certification' => true, - 'championship' => true, - 'charter' => true, - 'civilaviation' => true, - 'club' => true, - 'conference' => true, - 'consultant' => true, - 'consulting' => true, - 'control' => true, - 'council' => true, - 'crew' => true, - 'design' => true, - 'dgca' => true, - 'educator' => true, - 'emergency' => true, - 'engine' => true, - 'engineer' => true, - 'entertainment' => true, - 'equipment' => true, - 'exchange' => true, - 'express' => true, - 'federation' => true, - 'flight' => true, - 'freight' => true, - 'fuel' => true, - 'gliding' => true, - 'government' => true, - 'groundhandling' => true, - 'group' => true, - 'hanggliding' => true, - 'homebuilt' => true, - 'insurance' => true, - 'journal' => true, - 'journalist' => true, - 'leasing' => true, - 'logistics' => true, - 'magazine' => true, - 'maintenance' => true, - 'marketplace' => true, - 'media' => true, - 'microlight' => true, - 'modelling' => true, - 'navigation' => true, - 'parachuting' => true, - 'paragliding' => true, - 'passenger-association' => true, - 'pilot' => true, - 'press' => true, - 'production' => true, - 'recreation' => true, - 'repbody' => true, - 'res' => true, - 'research' => true, - 'rotorcraft' => true, - 'safety' => true, - 'scientist' => true, - 'services' => true, - 'show' => true, - 'skydiving' => true, - 'software' => true, - 'student' => true, - 'taxi' => true, - 'trader' => true, - 'trading' => true, - 'trainer' => true, - 'union' => true, - 'workinggroup' => true, - 'works' => true - ), - 'af' => array( - 'gov' => true, - 'com' => true, - 'org' => true, - 'net' => true, - 'edu' => true - ), - 'ag' => array( - 'com' => true, - 'org' => true, - 'net' => true, - 'co' => true, - 'nom' => true - ), - 'ai' => array( - 'off' => true, - 'com' => true, - 'net' => true, - 'org' => true - ), - 'al' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'mil' => true, - 'net' => true, - 'org' => true - ), - 'am' => true, - 'an' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'edu' => true - ), - 'ao' => array( - 'ed' => true, - 'gv' => true, - 'og' => true, - 'co' => true, - 'pb' => true, - 'it' => true - ), - 'aq' => true, - 'ar' => array( - 'com' => array( - 'blogspot' => true - ), - 'edu' => true, - 'gob' => true, - 'int' => true, - 'mil' => true, - 'net' => true, - 'org' => true, - 'tur' => true - ), - 'arpa' => array( - 'e164' => true, - 'in-addr' => true, - 'ip6' => true, - 'iris' => true, - 'uri' => true, - 'urn' => true - ), - 'as' => array( - 'gov' => true - ), - 'asia' => true, - 'at' => array( - 'ac' => true, - 'co' => array( - 'blogspot' => true - ), - 'gv' => true, - 'or' => true, - 'biz' => true, - 'info' => true, - 'priv' => true - ), - 'au' => array( - 'com' => array( - 'blogspot' => true - ), - 'net' => true, - 'org' => true, - 'edu' => array( - 'act' => true, - 'nsw' => true, - 'nt' => true, - 'qld' => true, - 'sa' => true, - 'tas' => true, - 'vic' => true, - 'wa' => true - ), - 'gov' => array( - 'act' => true, - 'qld' => true, - 'sa' => true, - 'tas' => true, - 'vic' => true, - 'wa' => true - ), - 'asn' => true, - 'id' => true, - 'csiro' => true, - 'info' => true, - 'conf' => true, - 'oz' => true, - 'act' => true, - 'nsw' => true, - 'nt' => true, - 'qld' => true, - 'sa' => true, - 'tas' => true, - 'vic' => true, - 'wa' => true - ), - 'aw' => array( - 'com' => true - ), - 'ax' => true, - 'az' => array( - 'com' => true, - 'net' => true, - 'int' => true, - 'gov' => true, - 'org' => true, - 'edu' => true, - 'info' => true, - 'pp' => true, - 'mil' => true, - 'name' => true, - 'pro' => true, - 'biz' => true - ), - 'ba' => array( - 'org' => true, - 'net' => true, - 'edu' => true, - 'gov' => true, - 'mil' => true, - 'unsa' => true, - 'unbi' => true, - 'co' => true, - 'com' => true, - 'rs' => true - ), - 'bb' => array( - 'biz' => true, - 'com' => true, - 'edu' => true, - 'gov' => true, - 'info' => true, - 'net' => true, - 'org' => true, - 'store' => true - ), - 'bd' => array( - '*' => true - ), - 'be' => array( - 'ac' => true, - 'blogspot' => true - ), - 'bf' => array( - 'gov' => true - ), - 'bg' => array( - 'a' => true, - 'b' => true, - 'c' => true, - 'd' => true, - 'e' => true, - 'f' => true, - 'g' => true, - 'h' => true, - 'i' => true, - 'j' => true, - 'k' => true, - 'l' => true, - 'm' => true, - 'n' => true, - 'o' => true, - 'p' => true, - 'q' => true, - 'r' => true, - 's' => true, - 't' => true, - 'u' => true, - 'v' => true, - 'w' => true, - 'x' => true, - 'y' => true, - 'z' => true, - '0' => true, - '1' => true, - '2' => true, - '3' => true, - '4' => true, - '5' => true, - '6' => true, - '7' => true, - '8' => true, - '9' => true - ), - 'bh' => array( - 'com' => true, - 'edu' => true, - 'net' => true, - 'org' => true, - 'gov' => true - ), - 'bi' => array( - 'co' => true, - 'com' => true, - 'edu' => true, - 'or' => true, - 'org' => true - ), - 'biz' => array( - 'dyndns' => true, - 'for-better' => true, - 'for-more' => true, - 'for-some' => true, - 'for-the' => true, - 'selfip' => true, - 'webhop' => true - ), - 'bj' => array( - 'asso' => true, - 'barreau' => true, - 'gouv' => true, - 'blogspot' => true - ), - 'bm' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'net' => true, - 'org' => true - ), - 'bn' => array( - '*' => true - ), - 'bo' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'gob' => true, - 'int' => true, - 'org' => true, - 'net' => true, - 'mil' => true, - 'tv' => true - ), - 'br' => array( - 'adm' => true, - 'adv' => true, - 'agr' => true, - 'am' => true, - 'arq' => true, - 'art' => true, - 'ato' => true, - 'b' => true, - 'bio' => true, - 'blog' => true, - 'bmd' => true, - 'cim' => true, - 'cng' => true, - 'cnt' => true, - 'com' => array( - 'blogspot' => true - ), - 'coop' => true, - 'ecn' => true, - 'eco' => true, - 'edu' => true, - 'emp' => true, - 'eng' => true, - 'esp' => true, - 'etc' => true, - 'eti' => true, - 'far' => true, - 'flog' => true, - 'fm' => true, - 'fnd' => true, - 'fot' => true, - 'fst' => true, - 'g12' => true, - 'ggf' => true, - 'gov' => true, - 'imb' => true, - 'ind' => true, - 'inf' => true, - 'jor' => true, - 'jus' => true, - 'leg' => true, - 'lel' => true, - 'mat' => true, - 'med' => true, - 'mil' => true, - 'mus' => true, - 'net' => true, - 'nom' => true, - 'not' => true, - 'ntr' => true, - 'odo' => true, - 'org' => true, - 'ppg' => true, - 'pro' => true, - 'psc' => true, - 'psi' => true, - 'qsl' => true, - 'radio' => true, - 'rec' => true, - 'slg' => true, - 'srv' => true, - 'taxi' => true, - 'teo' => true, - 'tmp' => true, - 'trd' => true, - 'tur' => true, - 'tv' => true, - 'vet' => true, - 'vlog' => true, - 'wiki' => true, - 'zlg' => true - ), - 'bs' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'edu' => true, - 'gov' => true - ), - 'bt' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'net' => true, - 'org' => true - ), - 'bv' => true, - 'bw' => array( - 'co' => true, - 'org' => true - ), - 'by' => array( - 'gov' => true, - 'mil' => true, - 'com' => true, - 'of' => true - ), - 'bz' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'edu' => true, - 'gov' => true - ), - 'ca' => array( - 'ab' => true, - 'bc' => true, - 'mb' => true, - 'nb' => true, - 'nf' => true, - 'nl' => true, - 'ns' => true, - 'nt' => true, - 'nu' => true, - 'on' => true, - 'pe' => true, - 'qc' => true, - 'sk' => true, - 'yk' => true, - 'gc' => true, - 'co' => true, - 'blogspot' => true - ), - 'cat' => true, - 'cc' => array( - 'ftpaccess' => true, - 'game-server' => true, - 'myphotos' => true, - 'scrapping' => true - ), - 'cd' => array( - 'gov' => true - ), - 'cf' => array( - 'blogspot' => true - ), - 'cg' => true, - 'ch' => array( - 'blogspot' => true - ), - 'ci' => array( - 'org' => true, - 'or' => true, - 'com' => true, - 'co' => true, - 'edu' => true, - 'ed' => true, - 'ac' => true, - 'net' => true, - 'go' => true, - 'asso' => true, - 'aéroport' => true, - 'int' => true, - 'presse' => true, - 'md' => true, - 'gouv' => true - ), - 'ck' => array( - '*' => true, - '!www' => true - ), - 'cl' => array( - 'gov' => true, - 'gob' => true, - 'co' => true, - 'mil' => true - ), - 'cm' => array( - 'gov' => true - ), - 'cn' => array( - 'ac' => true, - 'com' => true, - 'edu' => true, - 'gov' => true, - 'net' => true, - 'org' => true, - 'mil' => true, - '公司' => true, - '网络' => true, - '網絡' => true, - 'ah' => true, - 'bj' => true, - 'cq' => true, - 'fj' => true, - 'gd' => true, - 'gs' => true, - 'gz' => true, - 'gx' => true, - 'ha' => true, - 'hb' => true, - 'he' => true, - 'hi' => true, - 'hl' => true, - 'hn' => true, - 'jl' => true, - 'js' => true, - 'jx' => true, - 'ln' => true, - 'nm' => true, - 'nx' => true, - 'qh' => true, - 'sc' => true, - 'sd' => true, - 'sh' => true, - 'sn' => true, - 'sx' => true, - 'tj' => true, - 'xj' => true, - 'xz' => true, - 'yn' => true, - 'zj' => true, - 'hk' => true, - 'mo' => true, - 'tw' => true - ), - 'co' => array( - 'arts' => true, - 'com' => true, - 'edu' => true, - 'firm' => true, - 'gov' => true, - 'info' => true, - 'int' => true, - 'mil' => true, - 'net' => true, - 'nom' => true, - 'org' => true, - 'rec' => true, - 'web' => true - ), - 'com' => array( - 'amazonaws' => array( - 'compute' => array( - 'ap-northeast-1' => true, - 'ap-southeast-1' => true, - 'ap-southeast-2' => true, - 'eu-west-1' => true, - 'sa-east-1' => true, - 'us-gov-west-1' => true, - 'us-west-1' => true, - 'us-west-2' => true - ), - 'us-east-1' => true, - 'compute-1' => array( - 'z-1' => true, - 'z-2' => true - ), - 'elb' => true, - 's3' => true, - 's3-us-west-2' => true, - 's3-us-west-1' => true, - 's3-eu-west-1' => true, - 's3-ap-southeast-1' => true, - 's3-ap-southeast-2' => true, - 's3-ap-northeast-1' => true, - 's3-sa-east-1' => true, - 's3-us-gov-west-1' => true, - 's3-fips-us-gov-west-1' => true, - 's3-website-us-east-1' => true, - 's3-website-us-west-2' => true, - 's3-website-us-west-1' => true, - 's3-website-eu-west-1' => true, - 's3-website-ap-southeast-1' => true, - 's3-website-ap-southeast-2' => true, - 's3-website-ap-northeast-1' => true, - 's3-website-sa-east-1' => true, - 's3-website-us-gov-west-1' => true - ), - 'elasticbeanstalk' => true, - 'betainabox' => true, - 'ar' => true, - 'br' => true, - 'cn' => true, - 'de' => true, - 'eu' => true, - 'gb' => true, - 'gr' => true, - 'hu' => true, - 'jpn' => true, - 'kr' => true, - 'no' => true, - 'qc' => true, - 'ru' => true, - 'sa' => true, - 'se' => true, - 'uk' => true, - 'us' => true, - 'uy' => true, - 'za' => true, - 'cloudcontrolled' => true, - 'cloudcontrolapp' => true, - 'dreamhosters' => true, - 'dyndns-at-home' => true, - 'dyndns-at-work' => true, - 'dyndns-blog' => true, - 'dyndns-free' => true, - 'dyndns-home' => true, - 'dyndns-ip' => true, - 'dyndns-mail' => true, - 'dyndns-office' => true, - 'dyndns-pics' => true, - 'dyndns-remote' => true, - 'dyndns-server' => true, - 'dyndns-web' => true, - 'dyndns-wiki' => true, - 'dyndns-work' => true, - 'blogdns' => true, - 'cechire' => true, - 'dnsalias' => true, - 'dnsdojo' => true, - 'doesntexist' => true, - 'dontexist' => true, - 'doomdns' => true, - 'dyn-o-saur' => true, - 'dynalias' => true, - 'est-a-la-maison' => true, - 'est-a-la-masion' => true, - 'est-le-patron' => true, - 'est-mon-blogueur' => true, - 'from-ak' => true, - 'from-al' => true, - 'from-ar' => true, - 'from-ca' => true, - 'from-ct' => true, - 'from-dc' => true, - 'from-de' => true, - 'from-fl' => true, - 'from-ga' => true, - 'from-hi' => true, - 'from-ia' => true, - 'from-id' => true, - 'from-il' => true, - 'from-in' => true, - 'from-ks' => true, - 'from-ky' => true, - 'from-ma' => true, - 'from-md' => true, - 'from-mi' => true, - 'from-mn' => true, - 'from-mo' => true, - 'from-ms' => true, - 'from-mt' => true, - 'from-nc' => true, - 'from-nd' => true, - 'from-ne' => true, - 'from-nh' => true, - 'from-nj' => true, - 'from-nm' => true, - 'from-nv' => true, - 'from-oh' => true, - 'from-ok' => true, - 'from-or' => true, - 'from-pa' => true, - 'from-pr' => true, - 'from-ri' => true, - 'from-sc' => true, - 'from-sd' => true, - 'from-tn' => true, - 'from-tx' => true, - 'from-ut' => true, - 'from-va' => true, - 'from-vt' => true, - 'from-wa' => true, - 'from-wi' => true, - 'from-wv' => true, - 'from-wy' => true, - 'getmyip' => true, - 'gotdns' => true, - 'hobby-site' => true, - 'homelinux' => true, - 'homeunix' => true, - 'iamallama' => true, - 'is-a-anarchist' => true, - 'is-a-blogger' => true, - 'is-a-bookkeeper' => true, - 'is-a-bulls-fan' => true, - 'is-a-caterer' => true, - 'is-a-chef' => true, - 'is-a-conservative' => true, - 'is-a-cpa' => true, - 'is-a-cubicle-slave' => true, - 'is-a-democrat' => true, - 'is-a-designer' => true, - 'is-a-doctor' => true, - 'is-a-financialadvisor' => true, - 'is-a-geek' => true, - 'is-a-green' => true, - 'is-a-guru' => true, - 'is-a-hard-worker' => true, - 'is-a-hunter' => true, - 'is-a-landscaper' => true, - 'is-a-lawyer' => true, - 'is-a-liberal' => true, - 'is-a-libertarian' => true, - 'is-a-llama' => true, - 'is-a-musician' => true, - 'is-a-nascarfan' => true, - 'is-a-nurse' => true, - 'is-a-painter' => true, - 'is-a-personaltrainer' => true, - 'is-a-photographer' => true, - 'is-a-player' => true, - 'is-a-republican' => true, - 'is-a-rockstar' => true, - 'is-a-socialist' => true, - 'is-a-student' => true, - 'is-a-teacher' => true, - 'is-a-techie' => true, - 'is-a-therapist' => true, - 'is-an-accountant' => true, - 'is-an-actor' => true, - 'is-an-actress' => true, - 'is-an-anarchist' => true, - 'is-an-artist' => true, - 'is-an-engineer' => true, - 'is-an-entertainer' => true, - 'is-certified' => true, - 'is-gone' => true, - 'is-into-anime' => true, - 'is-into-cars' => true, - 'is-into-cartoons' => true, - 'is-into-games' => true, - 'is-leet' => true, - 'is-not-certified' => true, - 'is-slick' => true, - 'is-uberleet' => true, - 'is-with-theband' => true, - 'isa-geek' => true, - 'isa-hockeynut' => true, - 'issmarterthanyou' => true, - 'likes-pie' => true, - 'likescandy' => true, - 'neat-url' => true, - 'saves-the-whales' => true, - 'selfip' => true, - 'sells-for-less' => true, - 'sells-for-u' => true, - 'servebbs' => true, - 'simple-url' => true, - 'space-to-rent' => true, - 'teaches-yoga' => true, - 'writesthisblog' => true, - 'ro' => true, - 'appspot' => true, - 'blogspot' => true, - 'codespot' => true, - 'googleapis' => true, - 'googlecode' => true, - 'herokuapp' => true, - 'herokussl' => true, - 'operaunite' => true, - 'rhcloud' => true - ), - 'coop' => true, - 'cr' => array( - 'ac' => true, - 'co' => true, - 'ed' => true, - 'fi' => true, - 'go' => true, - 'or' => true, - 'sa' => true - ), - 'cu' => array( - 'com' => true, - 'edu' => true, - 'org' => true, - 'net' => true, - 'gov' => true, - 'inf' => true - ), - 'cv' => array( - 'blogspot' => true - ), - 'cw' => array( - 'com' => true, - 'edu' => true, - 'net' => true, - 'org' => true - ), - 'cx' => array( - 'gov' => true, - 'ath' => true - ), - 'cy' => array( - '*' => true - ), - 'cz' => array( - 'blogspot' => true - ), - 'de' => array( - 'com' => true, - 'fuettertdasnetz' => true, - 'isteingeek' => true, - 'istmein' => true, - 'lebtimnetz' => true, - 'leitungsen' => true, - 'traeumtgerade' => true, - 'blogspot' => true - ), - 'dj' => true, - 'dk' => array( - 'blogspot' => true - ), - 'dm' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'edu' => true, - 'gov' => true - ), - 'do' => array( - 'art' => true, - 'com' => true, - 'edu' => true, - 'gob' => true, - 'gov' => true, - 'mil' => true, - 'net' => true, - 'org' => true, - 'sld' => true, - 'web' => true - ), - 'dz' => array( - 'com' => true, - 'org' => true, - 'net' => true, - 'gov' => true, - 'edu' => true, - 'asso' => true, - 'pol' => true, - 'art' => true - ), - 'ec' => array( - 'com' => true, - 'info' => true, - 'net' => true, - 'fin' => true, - 'k12' => true, - 'med' => true, - 'pro' => true, - 'org' => true, - 'edu' => true, - 'gov' => true, - 'gob' => true, - 'mil' => true - ), - 'edu' => true, - 'ee' => array( - 'edu' => true, - 'gov' => true, - 'riik' => true, - 'lib' => true, - 'med' => true, - 'com' => true, - 'pri' => true, - 'aip' => true, - 'org' => true, - 'fie' => true - ), - 'eg' => array( - 'com' => true, - 'edu' => true, - 'eun' => true, - 'gov' => true, - 'mil' => true, - 'name' => true, - 'net' => true, - 'org' => true, - 'sci' => true - ), - 'er' => array( - '*' => true - ), - 'es' => array( - 'com' => array( - 'blogspot' => true - ), - 'nom' => true, - 'org' => true, - 'gob' => true, - 'edu' => true - ), - 'et' => array( - '*' => true - ), - 'eu' => true, - 'fi' => array( - 'aland' => true, - 'blogspot' => true, - 'iki' => true - ), - 'fj' => array( - '*' => true - ), - 'fk' => array( - '*' => true - ), - 'fm' => true, - 'fo' => true, - 'fr' => array( - 'com' => true, - 'asso' => true, - 'nom' => true, - 'prd' => true, - 'presse' => true, - 'tm' => true, - 'aeroport' => true, - 'assedic' => true, - 'avocat' => true, - 'avoues' => true, - 'cci' => true, - 'chambagri' => true, - 'chirurgiens-dentistes' => true, - 'experts-comptables' => true, - 'geometre-expert' => true, - 'gouv' => true, - 'greta' => true, - 'huissier-justice' => true, - 'medecin' => true, - 'notaires' => true, - 'pharmacien' => true, - 'port' => true, - 'veterinaire' => true, - 'blogspot' => true - ), - 'ga' => true, - 'gb' => true, - 'gd' => true, - 'ge' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'org' => true, - 'mil' => true, - 'net' => true, - 'pvt' => true - ), - 'gf' => true, - 'gg' => array( - 'co' => true, - 'net' => true, - 'org' => true - ), - 'gh' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'org' => true, - 'mil' => true - ), - 'gi' => array( - 'com' => true, - 'ltd' => true, - 'gov' => true, - 'mod' => true, - 'edu' => true, - 'org' => true - ), - 'gl' => true, - 'gm' => true, - 'gn' => array( - 'ac' => true, - 'com' => true, - 'edu' => true, - 'gov' => true, - 'org' => true, - 'net' => true - ), - 'gov' => true, - 'gp' => array( - 'com' => true, - 'net' => true, - 'mobi' => true, - 'edu' => true, - 'org' => true, - 'asso' => true - ), - 'gq' => true, - 'gr' => array( - 'com' => true, - 'edu' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'blogspot' => true - ), - 'gs' => true, - 'gt' => array( - 'com' => true, - 'edu' => true, - 'gob' => true, - 'ind' => true, - 'mil' => true, - 'net' => true, - 'org' => true - ), - 'gu' => array( - '*' => true - ), - 'gw' => true, - 'gy' => array( - 'co' => true, - 'com' => true, - 'net' => true - ), - 'hk' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'idv' => true, - 'net' => true, - 'org' => true, - '公司' => true, - '教育' => true, - '敎育' => true, - '政府' => true, - '個人' => true, - '个人' => true, - '箇人' => true, - '網络' => true, - '网络' => true, - '组織' => true, - '網絡' => true, - '网絡' => true, - '组织' => true, - '組織' => true, - '組织' => true, - 'blogspot' => true - ), - 'hm' => true, - 'hn' => array( - 'com' => true, - 'edu' => true, - 'org' => true, - 'net' => true, - 'mil' => true, - 'gob' => true - ), - 'hr' => array( - 'iz' => true, - 'from' => true, - 'name' => true, - 'com' => true - ), - 'ht' => array( - 'com' => true, - 'shop' => true, - 'firm' => true, - 'info' => true, - 'adult' => true, - 'net' => true, - 'pro' => true, - 'org' => true, - 'med' => true, - 'art' => true, - 'coop' => true, - 'pol' => true, - 'asso' => true, - 'edu' => true, - 'rel' => true, - 'gouv' => true, - 'perso' => true - ), - 'hu' => array( - 'co' => true, - 'info' => true, - 'org' => true, - 'priv' => true, - 'sport' => true, - 'tm' => true, - '2000' => true, - 'agrar' => true, - 'bolt' => true, - 'casino' => true, - 'city' => true, - 'erotica' => true, - 'erotika' => true, - 'film' => true, - 'forum' => true, - 'games' => true, - 'hotel' => true, - 'ingatlan' => true, - 'jogasz' => true, - 'konyvelo' => true, - 'lakas' => true, - 'media' => true, - 'news' => true, - 'reklam' => true, - 'sex' => true, - 'shop' => true, - 'suli' => true, - 'szex' => true, - 'tozsde' => true, - 'utazas' => true, - 'video' => true, - 'blogspot' => true - ), - 'id' => array( - 'ac' => true, - 'biz' => true, - 'co' => true, - 'go' => true, - 'mil' => true, - 'my' => true, - 'net' => true, - 'or' => true, - 'sch' => true, - 'web' => true - ), - 'ie' => array( - 'gov' => true, - 'blogspot' => true - ), - 'il' => array( - '*' => true, - 'co' => array( - 'blogspot' => true - ) - ), - 'im' => array( - 'ac' => true, - 'co' => array( - 'ltd' => true, - 'plc' => true - ), - 'com' => true, - 'net' => true, - 'org' => true, - 'tt' => true, - 'tv' => true - ), - 'in' => array( - 'co' => true, - 'firm' => true, - 'net' => true, - 'org' => true, - 'gen' => true, - 'ind' => true, - 'nic' => true, - 'ac' => true, - 'edu' => true, - 'res' => true, - 'gov' => true, - 'mil' => true, - 'blogspot' => true - ), - 'info' => array( - 'dyndns' => true, - 'barrel-of-knowledge' => true, - 'barrell-of-knowledge' => true, - 'for-our' => true, - 'groks-the' => true, - 'groks-this' => true, - 'here-for-more' => true, - 'knowsitall' => true, - 'selfip' => true, - 'webhop' => true - ), - 'int' => array( - 'eu' => true - ), - 'io' => array( - 'com' => true, - 'github' => true - ), - 'iq' => array( - 'gov' => true, - 'edu' => true, - 'mil' => true, - 'com' => true, - 'org' => true, - 'net' => true - ), - 'ir' => array( - 'ac' => true, - 'co' => true, - 'gov' => true, - 'id' => true, - 'net' => true, - 'org' => true, - 'sch' => true, - 'ایران' => true, - 'ايران' => true - ), - 'is' => array( - 'net' => true, - 'com' => true, - 'edu' => true, - 'gov' => true, - 'org' => true, - 'int' => true, - 'cupcake' => true - ), - 'it' => array( - 'gov' => true, - 'edu' => true, - 'agrigento' => true, - 'ag' => true, - 'alessandria' => true, - 'al' => true, - 'ancona' => true, - 'an' => true, - 'aosta' => true, - 'aoste' => true, - 'ao' => true, - 'arezzo' => true, - 'ar' => true, - 'ascoli-piceno' => true, - 'ascolipiceno' => true, - 'ap' => true, - 'asti' => true, - 'at' => true, - 'avellino' => true, - 'av' => true, - 'bari' => true, - 'ba' => true, - 'andria-barletta-trani' => true, - 'andriabarlettatrani' => true, - 'trani-barletta-andria' => true, - 'tranibarlettaandria' => true, - 'barletta-trani-andria' => true, - 'barlettatraniandria' => true, - 'andria-trani-barletta' => true, - 'andriatranibarletta' => true, - 'trani-andria-barletta' => true, - 'traniandriabarletta' => true, - 'bt' => true, - 'belluno' => true, - 'bl' => true, - 'benevento' => true, - 'bn' => true, - 'bergamo' => true, - 'bg' => true, - 'biella' => true, - 'bi' => true, - 'bologna' => true, - 'bo' => true, - 'bolzano' => true, - 'bozen' => true, - 'balsan' => true, - 'alto-adige' => true, - 'altoadige' => true, - 'suedtirol' => true, - 'bz' => true, - 'brescia' => true, - 'bs' => true, - 'brindisi' => true, - 'br' => true, - 'cagliari' => true, - 'ca' => true, - 'caltanissetta' => true, - 'cl' => true, - 'campobasso' => true, - 'cb' => true, - 'carboniaiglesias' => true, - 'carbonia-iglesias' => true, - 'iglesias-carbonia' => true, - 'iglesiascarbonia' => true, - 'ci' => true, - 'caserta' => true, - 'ce' => true, - 'catania' => true, - 'ct' => true, - 'catanzaro' => true, - 'cz' => true, - 'chieti' => true, - 'ch' => true, - 'como' => true, - 'co' => true, - 'cosenza' => true, - 'cs' => true, - 'cremona' => true, - 'cr' => true, - 'crotone' => true, - 'kr' => true, - 'cuneo' => true, - 'cn' => true, - 'dell-ogliastra' => true, - 'dellogliastra' => true, - 'ogliastra' => true, - 'og' => true, - 'enna' => true, - 'en' => true, - 'ferrara' => true, - 'fe' => true, - 'fermo' => true, - 'fm' => true, - 'firenze' => true, - 'florence' => true, - 'fi' => true, - 'foggia' => true, - 'fg' => true, - 'forli-cesena' => true, - 'forlicesena' => true, - 'cesena-forli' => true, - 'cesenaforli' => true, - 'fc' => true, - 'frosinone' => true, - 'fr' => true, - 'genova' => true, - 'genoa' => true, - 'ge' => true, - 'gorizia' => true, - 'go' => true, - 'grosseto' => true, - 'gr' => true, - 'imperia' => true, - 'im' => true, - 'isernia' => true, - 'is' => true, - 'laquila' => true, - 'aquila' => true, - 'aq' => true, - 'la-spezia' => true, - 'laspezia' => true, - 'sp' => true, - 'latina' => true, - 'lt' => true, - 'lecce' => true, - 'le' => true, - 'lecco' => true, - 'lc' => true, - 'livorno' => true, - 'li' => true, - 'lodi' => true, - 'lo' => true, - 'lucca' => true, - 'lu' => true, - 'macerata' => true, - 'mc' => true, - 'mantova' => true, - 'mn' => true, - 'massa-carrara' => true, - 'massacarrara' => true, - 'carrara-massa' => true, - 'carraramassa' => true, - 'ms' => true, - 'matera' => true, - 'mt' => true, - 'medio-campidano' => true, - 'mediocampidano' => true, - 'campidano-medio' => true, - 'campidanomedio' => true, - 'vs' => true, - 'messina' => true, - 'me' => true, - 'milano' => true, - 'milan' => true, - 'mi' => true, - 'modena' => true, - 'mo' => true, - 'monza' => true, - 'monza-brianza' => true, - 'monzabrianza' => true, - 'monzaebrianza' => true, - 'monzaedellabrianza' => true, - 'monza-e-della-brianza' => true, - 'mb' => true, - 'napoli' => true, - 'naples' => true, - 'na' => true, - 'novara' => true, - 'no' => true, - 'nuoro' => true, - 'nu' => true, - 'oristano' => true, - 'or' => true, - 'padova' => true, - 'padua' => true, - 'pd' => true, - 'palermo' => true, - 'pa' => true, - 'parma' => true, - 'pr' => true, - 'pavia' => true, - 'pv' => true, - 'perugia' => true, - 'pg' => true, - 'pescara' => true, - 'pe' => true, - 'pesaro-urbino' => true, - 'pesarourbino' => true, - 'urbino-pesaro' => true, - 'urbinopesaro' => true, - 'pu' => true, - 'piacenza' => true, - 'pc' => true, - 'pisa' => true, - 'pi' => true, - 'pistoia' => true, - 'pt' => true, - 'pordenone' => true, - 'pn' => true, - 'potenza' => true, - 'pz' => true, - 'prato' => true, - 'po' => true, - 'ragusa' => true, - 'rg' => true, - 'ravenna' => true, - 'ra' => true, - 'reggio-calabria' => true, - 'reggiocalabria' => true, - 'rc' => true, - 'reggio-emilia' => true, - 'reggioemilia' => true, - 're' => true, - 'rieti' => true, - 'ri' => true, - 'rimini' => true, - 'rn' => true, - 'roma' => true, - 'rome' => true, - 'rm' => true, - 'rovigo' => true, - 'ro' => true, - 'salerno' => true, - 'sa' => true, - 'sassari' => true, - 'ss' => true, - 'savona' => true, - 'sv' => true, - 'siena' => true, - 'si' => true, - 'siracusa' => true, - 'sr' => true, - 'sondrio' => true, - 'so' => true, - 'taranto' => true, - 'ta' => true, - 'tempio-olbia' => true, - 'tempioolbia' => true, - 'olbia-tempio' => true, - 'olbiatempio' => true, - 'ot' => true, - 'teramo' => true, - 'te' => true, - 'terni' => true, - 'tr' => true, - 'torino' => true, - 'turin' => true, - 'to' => true, - 'trapani' => true, - 'tp' => true, - 'trento' => true, - 'trentino' => true, - 'tn' => true, - 'treviso' => true, - 'tv' => true, - 'trieste' => true, - 'ts' => true, - 'udine' => true, - 'ud' => true, - 'varese' => true, - 'va' => true, - 'venezia' => true, - 'venice' => true, - 've' => true, - 'verbania' => true, - 'vb' => true, - 'vercelli' => true, - 'vc' => true, - 'verona' => true, - 'vr' => true, - 'vibo-valentia' => true, - 'vibovalentia' => true, - 'vv' => true, - 'vicenza' => true, - 'vi' => true, - 'viterbo' => true, - 'vt' => true, - 'blogspot' => true - ), - 'je' => array( - 'co' => true, - 'net' => true, - 'org' => true - ), - 'jm' => array( - '*' => true - ), - 'jo' => array( - 'com' => true, - 'org' => true, - 'net' => true, - 'edu' => true, - 'sch' => true, - 'gov' => true, - 'mil' => true, - 'name' => true - ), - 'jobs' => true, - 'jp' => array( - 'ac' => true, - 'ad' => true, - 'co' => true, - 'ed' => true, - 'go' => true, - 'gr' => true, - 'lg' => true, - 'ne' => true, - 'or' => true, - 'aichi' => array( - 'aisai' => true, - 'ama' => true, - 'anjo' => true, - 'asuke' => true, - 'chiryu' => true, - 'chita' => true, - 'fuso' => true, - 'gamagori' => true, - 'handa' => true, - 'hazu' => true, - 'hekinan' => true, - 'higashiura' => true, - 'ichinomiya' => true, - 'inazawa' => true, - 'inuyama' => true, - 'isshiki' => true, - 'iwakura' => true, - 'kanie' => true, - 'kariya' => true, - 'kasugai' => true, - 'kira' => true, - 'kiyosu' => true, - 'komaki' => true, - 'konan' => true, - 'kota' => true, - 'mihama' => true, - 'miyoshi' => true, - 'nagakute' => true, - 'nishio' => true, - 'nisshin' => true, - 'obu' => true, - 'oguchi' => true, - 'oharu' => true, - 'okazaki' => true, - 'owariasahi' => true, - 'seto' => true, - 'shikatsu' => true, - 'shinshiro' => true, - 'shitara' => true, - 'tahara' => true, - 'takahama' => true, - 'tobishima' => true, - 'toei' => true, - 'togo' => true, - 'tokai' => true, - 'tokoname' => true, - 'toyoake' => true, - 'toyohashi' => true, - 'toyokawa' => true, - 'toyone' => true, - 'toyota' => true, - 'tsushima' => true, - 'yatomi' => true - ), - 'akita' => array( - 'akita' => true, - 'daisen' => true, - 'fujisato' => true, - 'gojome' => true, - 'hachirogata' => true, - 'happou' => true, - 'higashinaruse' => true, - 'honjo' => true, - 'honjyo' => true, - 'ikawa' => true, - 'kamikoani' => true, - 'kamioka' => true, - 'katagami' => true, - 'kazuno' => true, - 'kitaakita' => true, - 'kosaka' => true, - 'kyowa' => true, - 'misato' => true, - 'mitane' => true, - 'moriyoshi' => true, - 'nikaho' => true, - 'noshiro' => true, - 'odate' => true, - 'oga' => true, - 'ogata' => true, - 'semboku' => true, - 'yokote' => true, - 'yurihonjo' => true - ), - 'aomori' => array( - 'aomori' => true, - 'gonohe' => true, - 'hachinohe' => true, - 'hashikami' => true, - 'hiranai' => true, - 'hirosaki' => true, - 'itayanagi' => true, - 'kuroishi' => true, - 'misawa' => true, - 'mutsu' => true, - 'nakadomari' => true, - 'noheji' => true, - 'oirase' => true, - 'owani' => true, - 'rokunohe' => true, - 'sannohe' => true, - 'shichinohe' => true, - 'shingo' => true, - 'takko' => true, - 'towada' => true, - 'tsugaru' => true, - 'tsuruta' => true - ), - 'chiba' => array( - 'abiko' => true, - 'asahi' => true, - 'chonan' => true, - 'chosei' => true, - 'choshi' => true, - 'chuo' => true, - 'funabashi' => true, - 'futtsu' => true, - 'hanamigawa' => true, - 'ichihara' => true, - 'ichikawa' => true, - 'ichinomiya' => true, - 'inzai' => true, - 'isumi' => true, - 'kamagaya' => true, - 'kamogawa' => true, - 'kashiwa' => true, - 'katori' => true, - 'katsuura' => true, - 'kimitsu' => true, - 'kisarazu' => true, - 'kozaki' => true, - 'kujukuri' => true, - 'kyonan' => true, - 'matsudo' => true, - 'midori' => true, - 'mihama' => true, - 'minamiboso' => true, - 'mobara' => true, - 'mutsuzawa' => true, - 'nagara' => true, - 'nagareyama' => true, - 'narashino' => true, - 'narita' => true, - 'noda' => true, - 'oamishirasato' => true, - 'omigawa' => true, - 'onjuku' => true, - 'otaki' => true, - 'sakae' => true, - 'sakura' => true, - 'shimofusa' => true, - 'shirako' => true, - 'shiroi' => true, - 'shisui' => true, - 'sodegaura' => true, - 'sosa' => true, - 'tako' => true, - 'tateyama' => true, - 'togane' => true, - 'tohnosho' => true, - 'tomisato' => true, - 'urayasu' => true, - 'yachimata' => true, - 'yachiyo' => true, - 'yokaichiba' => true, - 'yokoshibahikari' => true, - 'yotsukaido' => true - ), - 'ehime' => array( - 'ainan' => true, - 'honai' => true, - 'ikata' => true, - 'imabari' => true, - 'iyo' => true, - 'kamijima' => true, - 'kihoku' => true, - 'kumakogen' => true, - 'masaki' => true, - 'matsuno' => true, - 'matsuyama' => true, - 'namikata' => true, - 'niihama' => true, - 'ozu' => true, - 'saijo' => true, - 'seiyo' => true, - 'shikokuchuo' => true, - 'tobe' => true, - 'toon' => true, - 'uchiko' => true, - 'uwajima' => true, - 'yawatahama' => true - ), - 'fukui' => array( - 'echizen' => true, - 'eiheiji' => true, - 'fukui' => true, - 'ikeda' => true, - 'katsuyama' => true, - 'mihama' => true, - 'minamiechizen' => true, - 'obama' => true, - 'ohi' => true, - 'ono' => true, - 'sabae' => true, - 'sakai' => true, - 'takahama' => true, - 'tsuruga' => true, - 'wakasa' => true - ), - 'fukuoka' => array( - 'ashiya' => true, - 'buzen' => true, - 'chikugo' => true, - 'chikuho' => true, - 'chikujo' => true, - 'chikushino' => true, - 'chikuzen' => true, - 'chuo' => true, - 'dazaifu' => true, - 'fukuchi' => true, - 'hakata' => true, - 'higashi' => true, - 'hirokawa' => true, - 'hisayama' => true, - 'iizuka' => true, - 'inatsuki' => true, - 'kaho' => true, - 'kasuga' => true, - 'kasuya' => true, - 'kawara' => true, - 'keisen' => true, - 'koga' => true, - 'kurate' => true, - 'kurogi' => true, - 'kurume' => true, - 'minami' => true, - 'miyako' => true, - 'miyama' => true, - 'miyawaka' => true, - 'mizumaki' => true, - 'munakata' => true, - 'nakagawa' => true, - 'nakama' => true, - 'nishi' => true, - 'nogata' => true, - 'ogori' => true, - 'okagaki' => true, - 'okawa' => true, - 'oki' => true, - 'omuta' => true, - 'onga' => true, - 'onojo' => true, - 'oto' => true, - 'saigawa' => true, - 'sasaguri' => true, - 'shingu' => true, - 'shinyoshitomi' => true, - 'shonai' => true, - 'soeda' => true, - 'sue' => true, - 'tachiarai' => true, - 'tagawa' => true, - 'takata' => true, - 'toho' => true, - 'toyotsu' => true, - 'tsuiki' => true, - 'ukiha' => true, - 'umi' => true, - 'usui' => true, - 'yamada' => true, - 'yame' => true, - 'yanagawa' => true, - 'yukuhashi' => true - ), - 'fukushima' => array( - 'aizubange' => true, - 'aizumisato' => true, - 'aizuwakamatsu' => true, - 'asakawa' => true, - 'bandai' => true, - 'date' => true, - 'fukushima' => true, - 'furudono' => true, - 'futaba' => true, - 'hanawa' => true, - 'higashi' => true, - 'hirata' => true, - 'hirono' => true, - 'iitate' => true, - 'inawashiro' => true, - 'ishikawa' => true, - 'iwaki' => true, - 'izumizaki' => true, - 'kagamiishi' => true, - 'kaneyama' => true, - 'kawamata' => true, - 'kitakata' => true, - 'kitashiobara' => true, - 'koori' => true, - 'koriyama' => true, - 'kunimi' => true, - 'miharu' => true, - 'mishima' => true, - 'namie' => true, - 'nango' => true, - 'nishiaizu' => true, - 'nishigo' => true, - 'okuma' => true, - 'omotego' => true, - 'ono' => true, - 'otama' => true, - 'samegawa' => true, - 'shimogo' => true, - 'shirakawa' => true, - 'showa' => true, - 'soma' => true, - 'sukagawa' => true, - 'taishin' => true, - 'tamakawa' => true, - 'tanagura' => true, - 'tenei' => true, - 'yabuki' => true, - 'yamato' => true, - 'yamatsuri' => true, - 'yanaizu' => true, - 'yugawa' => true - ), - 'gifu' => array( - 'anpachi' => true, - 'ena' => true, - 'gifu' => true, - 'ginan' => true, - 'godo' => true, - 'gujo' => true, - 'hashima' => true, - 'hichiso' => true, - 'hida' => true, - 'higashishirakawa' => true, - 'ibigawa' => true, - 'ikeda' => true, - 'kakamigahara' => true, - 'kani' => true, - 'kasahara' => true, - 'kasamatsu' => true, - 'kawaue' => true, - 'kitagata' => true, - 'mino' => true, - 'minokamo' => true, - 'mitake' => true, - 'mizunami' => true, - 'motosu' => true, - 'nakatsugawa' => true, - 'ogaki' => true, - 'sakahogi' => true, - 'seki' => true, - 'sekigahara' => true, - 'shirakawa' => true, - 'tajimi' => true, - 'takayama' => true, - 'tarui' => true, - 'toki' => true, - 'tomika' => true, - 'wanouchi' => true, - 'yamagata' => true, - 'yaotsu' => true, - 'yoro' => true - ), - 'gunma' => array( - 'annaka' => true, - 'chiyoda' => true, - 'fujioka' => true, - 'higashiagatsuma' => true, - 'isesaki' => true, - 'itakura' => true, - 'kanna' => true, - 'kanra' => true, - 'katashina' => true, - 'kawaba' => true, - 'kiryu' => true, - 'kusatsu' => true, - 'maebashi' => true, - 'meiwa' => true, - 'midori' => true, - 'minakami' => true, - 'naganohara' => true, - 'nakanojo' => true, - 'nanmoku' => true, - 'numata' => true, - 'oizumi' => true, - 'ora' => true, - 'ota' => true, - 'shibukawa' => true, - 'shimonita' => true, - 'shinto' => true, - 'showa' => true, - 'takasaki' => true, - 'takayama' => true, - 'tamamura' => true, - 'tatebayashi' => true, - 'tomioka' => true, - 'tsukiyono' => true, - 'tsumagoi' => true, - 'ueno' => true, - 'yoshioka' => true - ), - 'hiroshima' => array( - 'asaminami' => true, - 'daiwa' => true, - 'etajima' => true, - 'fuchu' => true, - 'fukuyama' => true, - 'hatsukaichi' => true, - 'higashihiroshima' => true, - 'hongo' => true, - 'jinsekikogen' => true, - 'kaita' => true, - 'kui' => true, - 'kumano' => true, - 'kure' => true, - 'mihara' => true, - 'miyoshi' => true, - 'naka' => true, - 'onomichi' => true, - 'osakikamijima' => true, - 'otake' => true, - 'saka' => true, - 'sera' => true, - 'seranishi' => true, - 'shinichi' => true, - 'shobara' => true, - 'takehara' => true - ), - 'hokkaido' => array( - 'abashiri' => true, - 'abira' => true, - 'aibetsu' => true, - 'akabira' => true, - 'akkeshi' => true, - 'asahikawa' => true, - 'ashibetsu' => true, - 'ashoro' => true, - 'assabu' => true, - 'atsuma' => true, - 'bibai' => true, - 'biei' => true, - 'bifuka' => true, - 'bihoro' => true, - 'biratori' => true, - 'chippubetsu' => true, - 'chitose' => true, - 'date' => true, - 'ebetsu' => true, - 'embetsu' => true, - 'eniwa' => true, - 'erimo' => true, - 'esan' => true, - 'esashi' => true, - 'fukagawa' => true, - 'fukushima' => true, - 'furano' => true, - 'furubira' => true, - 'haboro' => true, - 'hakodate' => true, - 'hamatonbetsu' => true, - 'hidaka' => true, - 'higashikagura' => true, - 'higashikawa' => true, - 'hiroo' => true, - 'hokuryu' => true, - 'hokuto' => true, - 'honbetsu' => true, - 'horokanai' => true, - 'horonobe' => true, - 'ikeda' => true, - 'imakane' => true, - 'ishikari' => true, - 'iwamizawa' => true, - 'iwanai' => true, - 'kamifurano' => true, - 'kamikawa' => true, - 'kamishihoro' => true, - 'kamisunagawa' => true, - 'kamoenai' => true, - 'kayabe' => true, - 'kembuchi' => true, - 'kikonai' => true, - 'kimobetsu' => true, - 'kitahiroshima' => true, - 'kitami' => true, - 'kiyosato' => true, - 'koshimizu' => true, - 'kunneppu' => true, - 'kuriyama' => true, - 'kuromatsunai' => true, - 'kushiro' => true, - 'kutchan' => true, - 'kyowa' => true, - 'mashike' => true, - 'matsumae' => true, - 'mikasa' => true, - 'minamifurano' => true, - 'mombetsu' => true, - 'moseushi' => true, - 'mukawa' => true, - 'muroran' => true, - 'naie' => true, - 'nakagawa' => true, - 'nakasatsunai' => true, - 'nakatombetsu' => true, - 'nanae' => true, - 'nanporo' => true, - 'nayoro' => true, - 'nemuro' => true, - 'niikappu' => true, - 'niki' => true, - 'nishiokoppe' => true, - 'noboribetsu' => true, - 'numata' => true, - 'obihiro' => true, - 'obira' => true, - 'oketo' => true, - 'okoppe' => true, - 'otaru' => true, - 'otobe' => true, - 'otofuke' => true, - 'otoineppu' => true, - 'oumu' => true, - 'ozora' => true, - 'pippu' => true, - 'rankoshi' => true, - 'rebun' => true, - 'rikubetsu' => true, - 'rishiri' => true, - 'rishirifuji' => true, - 'saroma' => true, - 'sarufutsu' => true, - 'shakotan' => true, - 'shari' => true, - 'shibecha' => true, - 'shibetsu' => true, - 'shikabe' => true, - 'shikaoi' => true, - 'shimamaki' => true, - 'shimizu' => true, - 'shimokawa' => true, - 'shinshinotsu' => true, - 'shintoku' => true, - 'shiranuka' => true, - 'shiraoi' => true, - 'shiriuchi' => true, - 'sobetsu' => true, - 'sunagawa' => true, - 'taiki' => true, - 'takasu' => true, - 'takikawa' => true, - 'takinoue' => true, - 'teshikaga' => true, - 'tobetsu' => true, - 'tohma' => true, - 'tomakomai' => true, - 'tomari' => true, - 'toya' => true, - 'toyako' => true, - 'toyotomi' => true, - 'toyoura' => true, - 'tsubetsu' => true, - 'tsukigata' => true, - 'urakawa' => true, - 'urausu' => true, - 'uryu' => true, - 'utashinai' => true, - 'wakkanai' => true, - 'wassamu' => true, - 'yakumo' => true, - 'yoichi' => true - ), - 'hyogo' => array( - 'aioi' => true, - 'akashi' => true, - 'ako' => true, - 'amagasaki' => true, - 'aogaki' => true, - 'asago' => true, - 'ashiya' => true, - 'awaji' => true, - 'fukusaki' => true, - 'goshiki' => true, - 'harima' => true, - 'himeji' => true, - 'ichikawa' => true, - 'inagawa' => true, - 'itami' => true, - 'kakogawa' => true, - 'kamigori' => true, - 'kamikawa' => true, - 'kasai' => true, - 'kasuga' => true, - 'kawanishi' => true, - 'miki' => true, - 'minamiawaji' => true, - 'nishinomiya' => true, - 'nishiwaki' => true, - 'ono' => true, - 'sanda' => true, - 'sannan' => true, - 'sasayama' => true, - 'sayo' => true, - 'shingu' => true, - 'shinonsen' => true, - 'shiso' => true, - 'sumoto' => true, - 'taishi' => true, - 'taka' => true, - 'takarazuka' => true, - 'takasago' => true, - 'takino' => true, - 'tamba' => true, - 'tatsuno' => true, - 'toyooka' => true, - 'yabu' => true, - 'yashiro' => true, - 'yoka' => true, - 'yokawa' => true - ), - 'ibaraki' => array( - 'ami' => true, - 'asahi' => true, - 'bando' => true, - 'chikusei' => true, - 'daigo' => true, - 'fujishiro' => true, - 'hitachi' => true, - 'hitachinaka' => true, - 'hitachiomiya' => true, - 'hitachiota' => true, - 'ibaraki' => true, - 'ina' => true, - 'inashiki' => true, - 'itako' => true, - 'iwama' => true, - 'joso' => true, - 'kamisu' => true, - 'kasama' => true, - 'kashima' => true, - 'kasumigaura' => true, - 'koga' => true, - 'miho' => true, - 'mito' => true, - 'moriya' => true, - 'naka' => true, - 'namegata' => true, - 'oarai' => true, - 'ogawa' => true, - 'omitama' => true, - 'ryugasaki' => true, - 'sakai' => true, - 'sakuragawa' => true, - 'shimodate' => true, - 'shimotsuma' => true, - 'shirosato' => true, - 'sowa' => true, - 'suifu' => true, - 'takahagi' => true, - 'tamatsukuri' => true, - 'tokai' => true, - 'tomobe' => true, - 'tone' => true, - 'toride' => true, - 'tsuchiura' => true, - 'tsukuba' => true, - 'uchihara' => true, - 'ushiku' => true, - 'yachiyo' => true, - 'yamagata' => true, - 'yawara' => true, - 'yuki' => true - ), - 'ishikawa' => array( - 'anamizu' => true, - 'hakui' => true, - 'hakusan' => true, - 'kaga' => true, - 'kahoku' => true, - 'kanazawa' => true, - 'kawakita' => true, - 'komatsu' => true, - 'nakanoto' => true, - 'nanao' => true, - 'nomi' => true, - 'nonoichi' => true, - 'noto' => true, - 'shika' => true, - 'suzu' => true, - 'tsubata' => true, - 'tsurugi' => true, - 'uchinada' => true, - 'wajima' => true - ), - 'iwate' => array( - 'fudai' => true, - 'fujisawa' => true, - 'hanamaki' => true, - 'hiraizumi' => true, - 'hirono' => true, - 'ichinohe' => true, - 'ichinoseki' => true, - 'iwaizumi' => true, - 'iwate' => true, - 'joboji' => true, - 'kamaishi' => true, - 'kanegasaki' => true, - 'karumai' => true, - 'kawai' => true, - 'kitakami' => true, - 'kuji' => true, - 'kunohe' => true, - 'kuzumaki' => true, - 'miyako' => true, - 'mizusawa' => true, - 'morioka' => true, - 'ninohe' => true, - 'noda' => true, - 'ofunato' => true, - 'oshu' => true, - 'otsuchi' => true, - 'rikuzentakata' => true, - 'shiwa' => true, - 'shizukuishi' => true, - 'sumita' => true, - 'takizawa' => true, - 'tanohata' => true, - 'tono' => true, - 'yahaba' => true, - 'yamada' => true - ), - 'kagawa' => array( - 'ayagawa' => true, - 'higashikagawa' => true, - 'kanonji' => true, - 'kotohira' => true, - 'manno' => true, - 'marugame' => true, - 'mitoyo' => true, - 'naoshima' => true, - 'sanuki' => true, - 'tadotsu' => true, - 'takamatsu' => true, - 'tonosho' => true, - 'uchinomi' => true, - 'utazu' => true, - 'zentsuji' => true - ), - 'kagoshima' => array( - 'akune' => true, - 'amami' => true, - 'hioki' => true, - 'isa' => true, - 'isen' => true, - 'izumi' => true, - 'kagoshima' => true, - 'kanoya' => true, - 'kawanabe' => true, - 'kinko' => true, - 'kouyama' => true, - 'makurazaki' => true, - 'matsumoto' => true, - 'minamitane' => true, - 'nakatane' => true, - 'nishinoomote' => true, - 'satsumasendai' => true, - 'soo' => true, - 'tarumizu' => true, - 'yusui' => true - ), - 'kanagawa' => array( - 'aikawa' => true, - 'atsugi' => true, - 'ayase' => true, - 'chigasaki' => true, - 'ebina' => true, - 'fujisawa' => true, - 'hadano' => true, - 'hakone' => true, - 'hiratsuka' => true, - 'isehara' => true, - 'kaisei' => true, - 'kamakura' => true, - 'kiyokawa' => true, - 'matsuda' => true, - 'minamiashigara' => true, - 'miura' => true, - 'nakai' => true, - 'ninomiya' => true, - 'odawara' => true, - 'oi' => true, - 'oiso' => true, - 'sagamihara' => true, - 'samukawa' => true, - 'tsukui' => true, - 'yamakita' => true, - 'yamato' => true, - 'yokosuka' => true, - 'yugawara' => true, - 'zama' => true, - 'zushi' => true - ), - 'kochi' => array( - 'aki' => true, - 'geisei' => true, - 'hidaka' => true, - 'higashitsuno' => true, - 'ino' => true, - 'kagami' => true, - 'kami' => true, - 'kitagawa' => true, - 'kochi' => true, - 'mihara' => true, - 'motoyama' => true, - 'muroto' => true, - 'nahari' => true, - 'nakamura' => true, - 'nankoku' => true, - 'nishitosa' => true, - 'niyodogawa' => true, - 'ochi' => true, - 'okawa' => true, - 'otoyo' => true, - 'otsuki' => true, - 'sakawa' => true, - 'sukumo' => true, - 'susaki' => true, - 'tosa' => true, - 'tosashimizu' => true, - 'toyo' => true, - 'tsuno' => true, - 'umaji' => true, - 'yasuda' => true, - 'yusuhara' => true - ), - 'kumamoto' => array( - 'amakusa' => true, - 'arao' => true, - 'aso' => true, - 'choyo' => true, - 'gyokuto' => true, - 'hitoyoshi' => true, - 'kamiamakusa' => true, - 'kashima' => true, - 'kikuchi' => true, - 'kosa' => true, - 'kumamoto' => true, - 'mashiki' => true, - 'mifune' => true, - 'minamata' => true, - 'minamioguni' => true, - 'nagasu' => true, - 'nishihara' => true, - 'oguni' => true, - 'ozu' => true, - 'sumoto' => true, - 'takamori' => true, - 'uki' => true, - 'uto' => true, - 'yamaga' => true, - 'yamato' => true, - 'yatsushiro' => true - ), - 'kyoto' => array( - 'ayabe' => true, - 'fukuchiyama' => true, - 'higashiyama' => true, - 'ide' => true, - 'ine' => true, - 'joyo' => true, - 'kameoka' => true, - 'kamo' => true, - 'kita' => true, - 'kizu' => true, - 'kumiyama' => true, - 'kyotamba' => true, - 'kyotanabe' => true, - 'kyotango' => true, - 'maizuru' => true, - 'minami' => true, - 'minamiyamashiro' => true, - 'miyazu' => true, - 'muko' => true, - 'nagaokakyo' => true, - 'nakagyo' => true, - 'nantan' => true, - 'oyamazaki' => true, - 'sakyo' => true, - 'seika' => true, - 'tanabe' => true, - 'uji' => true, - 'ujitawara' => true, - 'wazuka' => true, - 'yamashina' => true, - 'yawata' => true - ), - 'mie' => array( - 'asahi' => true, - 'inabe' => true, - 'ise' => true, - 'kameyama' => true, - 'kawagoe' => true, - 'kiho' => true, - 'kisosaki' => true, - 'kiwa' => true, - 'komono' => true, - 'kumano' => true, - 'kuwana' => true, - 'matsusaka' => true, - 'meiwa' => true, - 'mihama' => true, - 'minamiise' => true, - 'misugi' => true, - 'miyama' => true, - 'nabari' => true, - 'shima' => true, - 'suzuka' => true, - 'tado' => true, - 'taiki' => true, - 'taki' => true, - 'tamaki' => true, - 'toba' => true, - 'tsu' => true, - 'udono' => true, - 'ureshino' => true, - 'watarai' => true, - 'yokkaichi' => true - ), - 'miyagi' => array( - 'furukawa' => true, - 'higashimatsushima' => true, - 'ishinomaki' => true, - 'iwanuma' => true, - 'kakuda' => true, - 'kami' => true, - 'kawasaki' => true, - 'kesennuma' => true, - 'marumori' => true, - 'matsushima' => true, - 'minamisanriku' => true, - 'misato' => true, - 'murata' => true, - 'natori' => true, - 'ogawara' => true, - 'ohira' => true, - 'onagawa' => true, - 'osaki' => true, - 'rifu' => true, - 'semine' => true, - 'shibata' => true, - 'shichikashuku' => true, - 'shikama' => true, - 'shiogama' => true, - 'shiroishi' => true, - 'tagajo' => true, - 'taiwa' => true, - 'tome' => true, - 'tomiya' => true, - 'wakuya' => true, - 'watari' => true, - 'yamamoto' => true, - 'zao' => true - ), - 'miyazaki' => array( - 'aya' => true, - 'ebino' => true, - 'gokase' => true, - 'hyuga' => true, - 'kadogawa' => true, - 'kawaminami' => true, - 'kijo' => true, - 'kitagawa' => true, - 'kitakata' => true, - 'kitaura' => true, - 'kobayashi' => true, - 'kunitomi' => true, - 'kushima' => true, - 'mimata' => true, - 'miyakonojo' => true, - 'miyazaki' => true, - 'morotsuka' => true, - 'nichinan' => true, - 'nishimera' => true, - 'nobeoka' => true, - 'saito' => true, - 'shiiba' => true, - 'shintomi' => true, - 'takaharu' => true, - 'takanabe' => true, - 'takazaki' => true, - 'tsuno' => true - ), - 'nagano' => array( - 'achi' => true, - 'agematsu' => true, - 'anan' => true, - 'aoki' => true, - 'asahi' => true, - 'azumino' => true, - 'chikuhoku' => true, - 'chikuma' => true, - 'chino' => true, - 'fujimi' => true, - 'hakuba' => true, - 'hara' => true, - 'hiraya' => true, - 'iida' => true, - 'iijima' => true, - 'iiyama' => true, - 'iizuna' => true, - 'ikeda' => true, - 'ikusaka' => true, - 'ina' => true, - 'karuizawa' => true, - 'kawakami' => true, - 'kiso' => true, - 'kisofukushima' => true, - 'kitaaiki' => true, - 'komagane' => true, - 'komoro' => true, - 'matsukawa' => true, - 'matsumoto' => true, - 'miasa' => true, - 'minamiaiki' => true, - 'minamimaki' => true, - 'minamiminowa' => true, - 'minowa' => true, - 'miyada' => true, - 'miyota' => true, - 'mochizuki' => true, - 'nagano' => true, - 'nagawa' => true, - 'nagiso' => true, - 'nakagawa' => true, - 'nakano' => true, - 'nozawaonsen' => true, - 'obuse' => true, - 'ogawa' => true, - 'okaya' => true, - 'omachi' => true, - 'omi' => true, - 'ookuwa' => true, - 'ooshika' => true, - 'otaki' => true, - 'otari' => true, - 'sakae' => true, - 'sakaki' => true, - 'saku' => true, - 'sakuho' => true, - 'shimosuwa' => true, - 'shinanomachi' => true, - 'shiojiri' => true, - 'suwa' => true, - 'suzaka' => true, - 'takagi' => true, - 'takamori' => true, - 'takayama' => true, - 'tateshina' => true, - 'tatsuno' => true, - 'togakushi' => true, - 'togura' => true, - 'tomi' => true, - 'ueda' => true, - 'wada' => true, - 'yamagata' => true, - 'yamanouchi' => true, - 'yasaka' => true, - 'yasuoka' => true - ), - 'nagasaki' => array( - 'chijiwa' => true, - 'futsu' => true, - 'goto' => true, - 'hasami' => true, - 'hirado' => true, - 'iki' => true, - 'isahaya' => true, - 'kawatana' => true, - 'kuchinotsu' => true, - 'matsuura' => true, - 'nagasaki' => true, - 'obama' => true, - 'omura' => true, - 'oseto' => true, - 'saikai' => true, - 'sasebo' => true, - 'seihi' => true, - 'shimabara' => true, - 'shinkamigoto' => true, - 'togitsu' => true, - 'tsushima' => true, - 'unzen' => true - ), - 'nara' => array( - 'ando' => true, - 'gose' => true, - 'heguri' => true, - 'higashiyoshino' => true, - 'ikaruga' => true, - 'ikoma' => true, - 'kamikitayama' => true, - 'kanmaki' => true, - 'kashiba' => true, - 'kashihara' => true, - 'katsuragi' => true, - 'kawai' => true, - 'kawakami' => true, - 'kawanishi' => true, - 'koryo' => true, - 'kurotaki' => true, - 'mitsue' => true, - 'miyake' => true, - 'nara' => true, - 'nosegawa' => true, - 'oji' => true, - 'ouda' => true, - 'oyodo' => true, - 'sakurai' => true, - 'sango' => true, - 'shimoichi' => true, - 'shimokitayama' => true, - 'shinjo' => true, - 'soni' => true, - 'takatori' => true, - 'tawaramoto' => true, - 'tenkawa' => true, - 'tenri' => true, - 'uda' => true, - 'yamatokoriyama' => true, - 'yamatotakada' => true, - 'yamazoe' => true, - 'yoshino' => true - ), - 'niigata' => array( - 'aga' => true, - 'agano' => true, - 'gosen' => true, - 'itoigawa' => true, - 'izumozaki' => true, - 'joetsu' => true, - 'kamo' => true, - 'kariwa' => true, - 'kashiwazaki' => true, - 'minamiuonuma' => true, - 'mitsuke' => true, - 'muika' => true, - 'murakami' => true, - 'myoko' => true, - 'nagaoka' => true, - 'niigata' => true, - 'ojiya' => true, - 'omi' => true, - 'sado' => true, - 'sanjo' => true, - 'seiro' => true, - 'seirou' => true, - 'sekikawa' => true, - 'shibata' => true, - 'tagami' => true, - 'tainai' => true, - 'tochio' => true, - 'tokamachi' => true, - 'tsubame' => true, - 'tsunan' => true, - 'uonuma' => true, - 'yahiko' => true, - 'yoita' => true, - 'yuzawa' => true - ), - 'oita' => array( - 'beppu' => true, - 'bungoono' => true, - 'bungotakada' => true, - 'hasama' => true, - 'hiji' => true, - 'himeshima' => true, - 'hita' => true, - 'kamitsue' => true, - 'kokonoe' => true, - 'kuju' => true, - 'kunisaki' => true, - 'kusu' => true, - 'oita' => true, - 'saiki' => true, - 'taketa' => true, - 'tsukumi' => true, - 'usa' => true, - 'usuki' => true, - 'yufu' => true - ), - 'okayama' => array( - 'akaiwa' => true, - 'asakuchi' => true, - 'bizen' => true, - 'hayashima' => true, - 'ibara' => true, - 'kagamino' => true, - 'kasaoka' => true, - 'kibichuo' => true, - 'kumenan' => true, - 'kurashiki' => true, - 'maniwa' => true, - 'misaki' => true, - 'nagi' => true, - 'niimi' => true, - 'nishiawakura' => true, - 'okayama' => true, - 'satosho' => true, - 'setouchi' => true, - 'shinjo' => true, - 'shoo' => true, - 'soja' => true, - 'takahashi' => true, - 'tamano' => true, - 'tsuyama' => true, - 'wake' => true, - 'yakage' => true - ), - 'okinawa' => array( - 'aguni' => true, - 'ginowan' => true, - 'ginoza' => true, - 'gushikami' => true, - 'haebaru' => true, - 'higashi' => true, - 'hirara' => true, - 'iheya' => true, - 'ishigaki' => true, - 'ishikawa' => true, - 'itoman' => true, - 'izena' => true, - 'kadena' => true, - 'kin' => true, - 'kitadaito' => true, - 'kitanakagusuku' => true, - 'kumejima' => true, - 'kunigami' => true, - 'minamidaito' => true, - 'motobu' => true, - 'nago' => true, - 'naha' => true, - 'nakagusuku' => true, - 'nakijin' => true, - 'nanjo' => true, - 'nishihara' => true, - 'ogimi' => true, - 'okinawa' => true, - 'onna' => true, - 'shimoji' => true, - 'taketomi' => true, - 'tarama' => true, - 'tokashiki' => true, - 'tomigusuku' => true, - 'tonaki' => true, - 'urasoe' => true, - 'uruma' => true, - 'yaese' => true, - 'yomitan' => true, - 'yonabaru' => true, - 'yonaguni' => true, - 'zamami' => true - ), - 'osaka' => array( - 'abeno' => true, - 'chihayaakasaka' => true, - 'chuo' => true, - 'daito' => true, - 'fujiidera' => true, - 'habikino' => true, - 'hannan' => true, - 'higashiosaka' => true, - 'higashisumiyoshi' => true, - 'higashiyodogawa' => true, - 'hirakata' => true, - 'ibaraki' => true, - 'ikeda' => true, - 'izumi' => true, - 'izumiotsu' => true, - 'izumisano' => true, - 'kadoma' => true, - 'kaizuka' => true, - 'kanan' => true, - 'kashiwara' => true, - 'katano' => true, - 'kawachinagano' => true, - 'kishiwada' => true, - 'kita' => true, - 'kumatori' => true, - 'matsubara' => true, - 'minato' => true, - 'minoh' => true, - 'misaki' => true, - 'moriguchi' => true, - 'neyagawa' => true, - 'nishi' => true, - 'nose' => true, - 'osakasayama' => true, - 'sakai' => true, - 'sayama' => true, - 'sennan' => true, - 'settsu' => true, - 'shijonawate' => true, - 'shimamoto' => true, - 'suita' => true, - 'tadaoka' => true, - 'taishi' => true, - 'tajiri' => true, - 'takaishi' => true, - 'takatsuki' => true, - 'tondabayashi' => true, - 'toyonaka' => true, - 'toyono' => true, - 'yao' => true - ), - 'saga' => array( - 'ariake' => true, - 'arita' => true, - 'fukudomi' => true, - 'genkai' => true, - 'hamatama' => true, - 'hizen' => true, - 'imari' => true, - 'kamimine' => true, - 'kanzaki' => true, - 'karatsu' => true, - 'kashima' => true, - 'kitagata' => true, - 'kitahata' => true, - 'kiyama' => true, - 'kouhoku' => true, - 'kyuragi' => true, - 'nishiarita' => true, - 'ogi' => true, - 'omachi' => true, - 'ouchi' => true, - 'saga' => true, - 'shiroishi' => true, - 'taku' => true, - 'tara' => true, - 'tosu' => true, - 'yoshinogari' => true - ), - 'saitama' => array( - 'arakawa' => true, - 'asaka' => true, - 'chichibu' => true, - 'fujimi' => true, - 'fujimino' => true, - 'fukaya' => true, - 'hanno' => true, - 'hanyu' => true, - 'hasuda' => true, - 'hatogaya' => true, - 'hatoyama' => true, - 'hidaka' => true, - 'higashichichibu' => true, - 'higashimatsuyama' => true, - 'honjo' => true, - 'ina' => true, - 'iruma' => true, - 'iwatsuki' => true, - 'kamiizumi' => true, - 'kamikawa' => true, - 'kamisato' => true, - 'kasukabe' => true, - 'kawagoe' => true, - 'kawaguchi' => true, - 'kawajima' => true, - 'kazo' => true, - 'kitamoto' => true, - 'koshigaya' => true, - 'kounosu' => true, - 'kuki' => true, - 'kumagaya' => true, - 'matsubushi' => true, - 'minano' => true, - 'misato' => true, - 'miyashiro' => true, - 'miyoshi' => true, - 'moroyama' => true, - 'nagatoro' => true, - 'namegawa' => true, - 'niiza' => true, - 'ogano' => true, - 'ogawa' => true, - 'ogose' => true, - 'okegawa' => true, - 'omiya' => true, - 'otaki' => true, - 'ranzan' => true, - 'ryokami' => true, - 'saitama' => true, - 'sakado' => true, - 'satte' => true, - 'sayama' => true, - 'shiki' => true, - 'shiraoka' => true, - 'soka' => true, - 'sugito' => true, - 'toda' => true, - 'tokigawa' => true, - 'tokorozawa' => true, - 'tsurugashima' => true, - 'urawa' => true, - 'warabi' => true, - 'yashio' => true, - 'yokoze' => true, - 'yono' => true, - 'yorii' => true, - 'yoshida' => true, - 'yoshikawa' => true, - 'yoshimi' => true - ), - 'shiga' => array( - 'aisho' => true, - 'gamo' => true, - 'higashiomi' => true, - 'hikone' => true, - 'koka' => true, - 'konan' => true, - 'kosei' => true, - 'koto' => true, - 'kusatsu' => true, - 'maibara' => true, - 'moriyama' => true, - 'nagahama' => true, - 'nishiazai' => true, - 'notogawa' => true, - 'omihachiman' => true, - 'otsu' => true, - 'ritto' => true, - 'ryuoh' => true, - 'takashima' => true, - 'takatsuki' => true, - 'torahime' => true, - 'toyosato' => true, - 'yasu' => true - ), - 'shimane' => array( - 'akagi' => true, - 'ama' => true, - 'gotsu' => true, - 'hamada' => true, - 'higashiizumo' => true, - 'hikawa' => true, - 'hikimi' => true, - 'izumo' => true, - 'kakinoki' => true, - 'masuda' => true, - 'matsue' => true, - 'misato' => true, - 'nishinoshima' => true, - 'ohda' => true, - 'okinoshima' => true, - 'okuizumo' => true, - 'shimane' => true, - 'tamayu' => true, - 'tsuwano' => true, - 'unnan' => true, - 'yakumo' => true, - 'yasugi' => true, - 'yatsuka' => true - ), - 'shizuoka' => array( - 'arai' => true, - 'atami' => true, - 'fuji' => true, - 'fujieda' => true, - 'fujikawa' => true, - 'fujinomiya' => true, - 'fukuroi' => true, - 'gotemba' => true, - 'haibara' => true, - 'hamamatsu' => true, - 'higashiizu' => true, - 'ito' => true, - 'iwata' => true, - 'izu' => true, - 'izunokuni' => true, - 'kakegawa' => true, - 'kannami' => true, - 'kawanehon' => true, - 'kawazu' => true, - 'kikugawa' => true, - 'kosai' => true, - 'makinohara' => true, - 'matsuzaki' => true, - 'minamiizu' => true, - 'mishima' => true, - 'morimachi' => true, - 'nishiizu' => true, - 'numazu' => true, - 'omaezaki' => true, - 'shimada' => true, - 'shimizu' => true, - 'shimoda' => true, - 'shizuoka' => true, - 'susono' => true, - 'yaizu' => true, - 'yoshida' => true - ), - 'tochigi' => array( - 'ashikaga' => true, - 'bato' => true, - 'haga' => true, - 'ichikai' => true, - 'iwafune' => true, - 'kaminokawa' => true, - 'kanuma' => true, - 'karasuyama' => true, - 'kuroiso' => true, - 'mashiko' => true, - 'mibu' => true, - 'moka' => true, - 'motegi' => true, - 'nasu' => true, - 'nasushiobara' => true, - 'nikko' => true, - 'nishikata' => true, - 'nogi' => true, - 'ohira' => true, - 'ohtawara' => true, - 'oyama' => true, - 'sakura' => true, - 'sano' => true, - 'shimotsuke' => true, - 'shioya' => true, - 'takanezawa' => true, - 'tochigi' => true, - 'tsuga' => true, - 'ujiie' => true, - 'utsunomiya' => true, - 'yaita' => true - ), - 'tokushima' => array( - 'aizumi' => true, - 'anan' => true, - 'ichiba' => true, - 'itano' => true, - 'kainan' => true, - 'komatsushima' => true, - 'matsushige' => true, - 'mima' => true, - 'minami' => true, - 'miyoshi' => true, - 'mugi' => true, - 'nakagawa' => true, - 'naruto' => true, - 'sanagochi' => true, - 'shishikui' => true, - 'tokushima' => true, - 'wajiki' => true - ), - 'tokyo' => array( - 'adachi' => true, - 'akiruno' => true, - 'akishima' => true, - 'aogashima' => true, - 'arakawa' => true, - 'bunkyo' => true, - 'chiyoda' => true, - 'chofu' => true, - 'chuo' => true, - 'edogawa' => true, - 'fuchu' => true, - 'fussa' => true, - 'hachijo' => true, - 'hachioji' => true, - 'hamura' => true, - 'higashikurume' => true, - 'higashimurayama' => true, - 'higashiyamato' => true, - 'hino' => true, - 'hinode' => true, - 'hinohara' => true, - 'inagi' => true, - 'itabashi' => true, - 'katsushika' => true, - 'kita' => true, - 'kiyose' => true, - 'kodaira' => true, - 'koganei' => true, - 'kokubunji' => true, - 'komae' => true, - 'koto' => true, - 'kouzushima' => true, - 'kunitachi' => true, - 'machida' => true, - 'meguro' => true, - 'minato' => true, - 'mitaka' => true, - 'mizuho' => true, - 'musashimurayama' => true, - 'musashino' => true, - 'nakano' => true, - 'nerima' => true, - 'ogasawara' => true, - 'okutama' => true, - 'ome' => true, - 'oshima' => true, - 'ota' => true, - 'setagaya' => true, - 'shibuya' => true, - 'shinagawa' => true, - 'shinjuku' => true, - 'suginami' => true, - 'sumida' => true, - 'tachikawa' => true, - 'taito' => true, - 'tama' => true, - 'toshima' => true - ), - 'tottori' => array( - 'chizu' => true, - 'hino' => true, - 'kawahara' => true, - 'koge' => true, - 'kotoura' => true, - 'misasa' => true, - 'nanbu' => true, - 'nichinan' => true, - 'sakaiminato' => true, - 'tottori' => true, - 'wakasa' => true, - 'yazu' => true, - 'yonago' => true - ), - 'toyama' => array( - 'asahi' => true, - 'fuchu' => true, - 'fukumitsu' => true, - 'funahashi' => true, - 'himi' => true, - 'imizu' => true, - 'inami' => true, - 'johana' => true, - 'kamiichi' => true, - 'kurobe' => true, - 'nakaniikawa' => true, - 'namerikawa' => true, - 'nanto' => true, - 'nyuzen' => true, - 'oyabe' => true, - 'taira' => true, - 'takaoka' => true, - 'tateyama' => true, - 'toga' => true, - 'tonami' => true, - 'toyama' => true, - 'unazuki' => true, - 'uozu' => true, - 'yamada' => true - ), - 'wakayama' => array( - 'arida' => true, - 'aridagawa' => true, - 'gobo' => true, - 'hashimoto' => true, - 'hidaka' => true, - 'hirogawa' => true, - 'inami' => true, - 'iwade' => true, - 'kainan' => true, - 'kamitonda' => true, - 'katsuragi' => true, - 'kimino' => true, - 'kinokawa' => true, - 'kitayama' => true, - 'koya' => true, - 'koza' => true, - 'kozagawa' => true, - 'kudoyama' => true, - 'kushimoto' => true, - 'mihama' => true, - 'misato' => true, - 'nachikatsuura' => true, - 'shingu' => true, - 'shirahama' => true, - 'taiji' => true, - 'tanabe' => true, - 'wakayama' => true, - 'yuasa' => true, - 'yura' => true - ), - 'yamagata' => array( - 'asahi' => true, - 'funagata' => true, - 'higashine' => true, - 'iide' => true, - 'kahoku' => true, - 'kaminoyama' => true, - 'kaneyama' => true, - 'kawanishi' => true, - 'mamurogawa' => true, - 'mikawa' => true, - 'murayama' => true, - 'nagai' => true, - 'nakayama' => true, - 'nanyo' => true, - 'nishikawa' => true, - 'obanazawa' => true, - 'oe' => true, - 'oguni' => true, - 'ohkura' => true, - 'oishida' => true, - 'sagae' => true, - 'sakata' => true, - 'sakegawa' => true, - 'shinjo' => true, - 'shirataka' => true, - 'shonai' => true, - 'takahata' => true, - 'tendo' => true, - 'tozawa' => true, - 'tsuruoka' => true, - 'yamagata' => true, - 'yamanobe' => true, - 'yonezawa' => true, - 'yuza' => true - ), - 'yamaguchi' => array( - 'abu' => true, - 'hagi' => true, - 'hikari' => true, - 'hofu' => true, - 'iwakuni' => true, - 'kudamatsu' => true, - 'mitou' => true, - 'nagato' => true, - 'oshima' => true, - 'shimonoseki' => true, - 'shunan' => true, - 'tabuse' => true, - 'tokuyama' => true, - 'toyota' => true, - 'ube' => true, - 'yuu' => true - ), - 'yamanashi' => array( - 'chuo' => true, - 'doshi' => true, - 'fuefuki' => true, - 'fujikawa' => true, - 'fujikawaguchiko' => true, - 'fujiyoshida' => true, - 'hayakawa' => true, - 'hokuto' => true, - 'ichikawamisato' => true, - 'kai' => true, - 'kofu' => true, - 'koshu' => true, - 'kosuge' => true, - 'minami-alps' => true, - 'minobu' => true, - 'nakamichi' => true, - 'nanbu' => true, - 'narusawa' => true, - 'nirasaki' => true, - 'nishikatsura' => true, - 'oshino' => true, - 'otsuki' => true, - 'showa' => true, - 'tabayama' => true, - 'tsuru' => true, - 'uenohara' => true, - 'yamanakako' => true, - 'yamanashi' => true - ), - 'kawasaki' => array( - '*' => true, - '!city' => true - ), - 'kitakyushu' => array( - '*' => true, - '!city' => true - ), - 'kobe' => array( - '*' => true, - '!city' => true - ), - 'nagoya' => array( - '*' => true, - '!city' => true - ), - 'sapporo' => array( - '*' => true, - '!city' => true - ), - 'sendai' => array( - '*' => true, - '!city' => true - ), - 'yokohama' => array( - '*' => true, - '!city' => true - ), - 'blogspot' => true - ), - 'ke' => array( - '*' => true - ), - 'kg' => array( - 'org' => true, - 'net' => true, - 'com' => true, - 'edu' => true, - 'gov' => true, - 'mil' => true - ), - 'kh' => array( - '*' => true - ), - 'ki' => array( - 'edu' => true, - 'biz' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'info' => true, - 'com' => true - ), - 'km' => array( - 'org' => true, - 'nom' => true, - 'gov' => true, - 'prd' => true, - 'tm' => true, - 'edu' => true, - 'mil' => true, - 'ass' => true, - 'com' => true, - 'coop' => true, - 'asso' => true, - 'presse' => true, - 'medecin' => true, - 'notaires' => true, - 'pharmaciens' => true, - 'veterinaire' => true, - 'gouv' => true - ), - 'kn' => array( - 'net' => true, - 'org' => true, - 'edu' => true, - 'gov' => true - ), - 'kp' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'org' => true, - 'rep' => true, - 'tra' => true - ), - 'kr' => array( - 'ac' => true, - 'co' => true, - 'es' => true, - 'go' => true, - 'hs' => true, - 'kg' => true, - 'mil' => true, - 'ms' => true, - 'ne' => true, - 'or' => true, - 'pe' => true, - 're' => true, - 'sc' => true, - 'busan' => true, - 'chungbuk' => true, - 'chungnam' => true, - 'daegu' => true, - 'daejeon' => true, - 'gangwon' => true, - 'gwangju' => true, - 'gyeongbuk' => true, - 'gyeonggi' => true, - 'gyeongnam' => true, - 'incheon' => true, - 'jeju' => true, - 'jeonbuk' => true, - 'jeonnam' => true, - 'seoul' => true, - 'ulsan' => true, - 'blogspot' => true - ), - 'kw' => array( - '*' => true - ), - 'ky' => array( - 'edu' => true, - 'gov' => true, - 'com' => true, - 'org' => true, - 'net' => true - ), - 'kz' => array( - 'org' => true, - 'edu' => true, - 'net' => true, - 'gov' => true, - 'mil' => true, - 'com' => true - ), - 'la' => array( - 'int' => true, - 'net' => true, - 'info' => true, - 'edu' => true, - 'gov' => true, - 'per' => true, - 'com' => true, - 'org' => true, - 'c' => true - ), - 'lb' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'net' => true, - 'org' => true - ), - 'lc' => array( - 'com' => true, - 'net' => true, - 'co' => true, - 'org' => true, - 'edu' => true, - 'gov' => true - ), - 'li' => true, - 'lk' => array( - 'gov' => true, - 'sch' => true, - 'net' => true, - 'int' => true, - 'com' => true, - 'org' => true, - 'edu' => true, - 'ngo' => true, - 'soc' => true, - 'web' => true, - 'ltd' => true, - 'assn' => true, - 'grp' => true, - 'hotel' => true - ), - 'lr' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'org' => true, - 'net' => true - ), - 'ls' => array( - 'co' => true, - 'org' => true - ), - 'lt' => array( - 'gov' => true - ), - 'lu' => true, - 'lv' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'org' => true, - 'mil' => true, - 'id' => true, - 'net' => true, - 'asn' => true, - 'conf' => true - ), - 'ly' => array( - 'com' => true, - 'net' => true, - 'gov' => true, - 'plc' => true, - 'edu' => true, - 'sch' => true, - 'med' => true, - 'org' => true, - 'id' => true - ), - 'ma' => array( - 'co' => true, - 'net' => true, - 'gov' => true, - 'org' => true, - 'ac' => true, - 'press' => true - ), - 'mc' => array( - 'tm' => true, - 'asso' => true - ), - 'md' => true, - 'me' => array( - 'co' => true, - 'net' => true, - 'org' => true, - 'edu' => true, - 'ac' => true, - 'gov' => true, - 'its' => true, - 'priv' => true - ), - 'mg' => array( - 'org' => true, - 'nom' => true, - 'gov' => true, - 'prd' => true, - 'tm' => true, - 'edu' => true, - 'mil' => true, - 'com' => true - ), - 'mh' => true, - 'mil' => true, - 'mk' => array( - 'com' => true, - 'org' => true, - 'net' => true, - 'edu' => true, - 'gov' => true, - 'inf' => true, - 'name' => true - ), - 'ml' => array( - 'com' => true, - 'edu' => true, - 'gouv' => true, - 'gov' => true, - 'net' => true, - 'org' => true, - 'presse' => true - ), - 'mm' => array( - '*' => true - ), - 'mn' => array( - 'gov' => true, - 'edu' => true, - 'org' => true, - 'nyc' => true - ), - 'mo' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'edu' => true, - 'gov' => true - ), - 'mobi' => true, - 'mp' => true, - 'mq' => true, - 'mr' => array( - 'gov' => true, - 'blogspot' => true - ), - 'ms' => true, - 'mt' => array( - 'com' => true, - 'edu' => true, - 'net' => true, - 'org' => true - ), - 'mu' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'ac' => true, - 'co' => true, - 'or' => true - ), - 'museum' => array( - 'academy' => true, - 'agriculture' => true, - 'air' => true, - 'airguard' => true, - 'alabama' => true, - 'alaska' => true, - 'amber' => true, - 'ambulance' => true, - 'american' => true, - 'americana' => true, - 'americanantiques' => true, - 'americanart' => true, - 'amsterdam' => true, - 'and' => true, - 'annefrank' => true, - 'anthro' => true, - 'anthropology' => true, - 'antiques' => true, - 'aquarium' => true, - 'arboretum' => true, - 'archaeological' => true, - 'archaeology' => true, - 'architecture' => true, - 'art' => true, - 'artanddesign' => true, - 'artcenter' => true, - 'artdeco' => true, - 'arteducation' => true, - 'artgallery' => true, - 'arts' => true, - 'artsandcrafts' => true, - 'asmatart' => true, - 'assassination' => true, - 'assisi' => true, - 'association' => true, - 'astronomy' => true, - 'atlanta' => true, - 'austin' => true, - 'australia' => true, - 'automotive' => true, - 'aviation' => true, - 'axis' => true, - 'badajoz' => true, - 'baghdad' => true, - 'bahn' => true, - 'bale' => true, - 'baltimore' => true, - 'barcelona' => true, - 'baseball' => true, - 'basel' => true, - 'baths' => true, - 'bauern' => true, - 'beauxarts' => true, - 'beeldengeluid' => true, - 'bellevue' => true, - 'bergbau' => true, - 'berkeley' => true, - 'berlin' => true, - 'bern' => true, - 'bible' => true, - 'bilbao' => true, - 'bill' => true, - 'birdart' => true, - 'birthplace' => true, - 'bonn' => true, - 'boston' => true, - 'botanical' => true, - 'botanicalgarden' => true, - 'botanicgarden' => true, - 'botany' => true, - 'brandywinevalley' => true, - 'brasil' => true, - 'bristol' => true, - 'british' => true, - 'britishcolumbia' => true, - 'broadcast' => true, - 'brunel' => true, - 'brussel' => true, - 'brussels' => true, - 'bruxelles' => true, - 'building' => true, - 'burghof' => true, - 'bus' => true, - 'bushey' => true, - 'cadaques' => true, - 'california' => true, - 'cambridge' => true, - 'can' => true, - 'canada' => true, - 'capebreton' => true, - 'carrier' => true, - 'cartoonart' => true, - 'casadelamoneda' => true, - 'castle' => true, - 'castres' => true, - 'celtic' => true, - 'center' => true, - 'chattanooga' => true, - 'cheltenham' => true, - 'chesapeakebay' => true, - 'chicago' => true, - 'children' => true, - 'childrens' => true, - 'childrensgarden' => true, - 'chiropractic' => true, - 'chocolate' => true, - 'christiansburg' => true, - 'cincinnati' => true, - 'cinema' => true, - 'circus' => true, - 'civilisation' => true, - 'civilization' => true, - 'civilwar' => true, - 'clinton' => true, - 'clock' => true, - 'coal' => true, - 'coastaldefence' => true, - 'cody' => true, - 'coldwar' => true, - 'collection' => true, - 'colonialwilliamsburg' => true, - 'coloradoplateau' => true, - 'columbia' => true, - 'columbus' => true, - 'communication' => true, - 'communications' => true, - 'community' => true, - 'computer' => true, - 'computerhistory' => true, - 'comunicações' => true, - 'contemporary' => true, - 'contemporaryart' => true, - 'convent' => true, - 'copenhagen' => true, - 'corporation' => true, - 'correios-e-telecomunicações' => true, - 'corvette' => true, - 'costume' => true, - 'countryestate' => true, - 'county' => true, - 'crafts' => true, - 'cranbrook' => true, - 'creation' => true, - 'cultural' => true, - 'culturalcenter' => true, - 'culture' => true, - 'cyber' => true, - 'cymru' => true, - 'dali' => true, - 'dallas' => true, - 'database' => true, - 'ddr' => true, - 'decorativearts' => true, - 'delaware' => true, - 'delmenhorst' => true, - 'denmark' => true, - 'depot' => true, - 'design' => true, - 'detroit' => true, - 'dinosaur' => true, - 'discovery' => true, - 'dolls' => true, - 'donostia' => true, - 'durham' => true, - 'eastafrica' => true, - 'eastcoast' => true, - 'education' => true, - 'educational' => true, - 'egyptian' => true, - 'eisenbahn' => true, - 'elburg' => true, - 'elvendrell' => true, - 'embroidery' => true, - 'encyclopedic' => true, - 'england' => true, - 'entomology' => true, - 'environment' => true, - 'environmentalconservation' => true, - 'epilepsy' => true, - 'essex' => true, - 'estate' => true, - 'ethnology' => true, - 'exeter' => true, - 'exhibition' => true, - 'family' => true, - 'farm' => true, - 'farmequipment' => true, - 'farmers' => true, - 'farmstead' => true, - 'field' => true, - 'figueres' => true, - 'filatelia' => true, - 'film' => true, - 'fineart' => true, - 'finearts' => true, - 'finland' => true, - 'flanders' => true, - 'florida' => true, - 'force' => true, - 'fortmissoula' => true, - 'fortworth' => true, - 'foundation' => true, - 'francaise' => true, - 'frankfurt' => true, - 'franziskaner' => true, - 'freemasonry' => true, - 'freiburg' => true, - 'fribourg' => true, - 'frog' => true, - 'fundacio' => true, - 'furniture' => true, - 'gallery' => true, - 'garden' => true, - 'gateway' => true, - 'geelvinck' => true, - 'gemological' => true, - 'geology' => true, - 'georgia' => true, - 'giessen' => true, - 'glas' => true, - 'glass' => true, - 'gorge' => true, - 'grandrapids' => true, - 'graz' => true, - 'guernsey' => true, - 'halloffame' => true, - 'hamburg' => true, - 'handson' => true, - 'harvestcelebration' => true, - 'hawaii' => true, - 'health' => true, - 'heimatunduhren' => true, - 'hellas' => true, - 'helsinki' => true, - 'hembygdsforbund' => true, - 'heritage' => true, - 'histoire' => true, - 'historical' => true, - 'historicalsociety' => true, - 'historichouses' => true, - 'historisch' => true, - 'historisches' => true, - 'history' => true, - 'historyofscience' => true, - 'horology' => true, - 'house' => true, - 'humanities' => true, - 'illustration' => true, - 'imageandsound' => true, - 'indian' => true, - 'indiana' => true, - 'indianapolis' => true, - 'indianmarket' => true, - 'intelligence' => true, - 'interactive' => true, - 'iraq' => true, - 'iron' => true, - 'isleofman' => true, - 'jamison' => true, - 'jefferson' => true, - 'jerusalem' => true, - 'jewelry' => true, - 'jewish' => true, - 'jewishart' => true, - 'jfk' => true, - 'journalism' => true, - 'judaica' => true, - 'judygarland' => true, - 'juedisches' => true, - 'juif' => true, - 'karate' => true, - 'karikatur' => true, - 'kids' => true, - 'koebenhavn' => true, - 'koeln' => true, - 'kunst' => true, - 'kunstsammlung' => true, - 'kunstunddesign' => true, - 'labor' => true, - 'labour' => true, - 'lajolla' => true, - 'lancashire' => true, - 'landes' => true, - 'lans' => true, - 'läns' => true, - 'larsson' => true, - 'lewismiller' => true, - 'lincoln' => true, - 'linz' => true, - 'living' => true, - 'livinghistory' => true, - 'localhistory' => true, - 'london' => true, - 'losangeles' => true, - 'louvre' => true, - 'loyalist' => true, - 'lucerne' => true, - 'luxembourg' => true, - 'luzern' => true, - 'mad' => true, - 'madrid' => true, - 'mallorca' => true, - 'manchester' => true, - 'mansion' => true, - 'mansions' => true, - 'manx' => true, - 'marburg' => true, - 'maritime' => true, - 'maritimo' => true, - 'maryland' => true, - 'marylhurst' => true, - 'media' => true, - 'medical' => true, - 'medizinhistorisches' => true, - 'meeres' => true, - 'memorial' => true, - 'mesaverde' => true, - 'michigan' => true, - 'midatlantic' => true, - 'military' => true, - 'mill' => true, - 'miners' => true, - 'mining' => true, - 'minnesota' => true, - 'missile' => true, - 'missoula' => true, - 'modern' => true, - 'moma' => true, - 'money' => true, - 'monmouth' => true, - 'monticello' => true, - 'montreal' => true, - 'moscow' => true, - 'motorcycle' => true, - 'muenchen' => true, - 'muenster' => true, - 'mulhouse' => true, - 'muncie' => true, - 'museet' => true, - 'museumcenter' => true, - 'museumvereniging' => true, - 'music' => true, - 'national' => true, - 'nationalfirearms' => true, - 'nationalheritage' => true, - 'nativeamerican' => true, - 'naturalhistory' => true, - 'naturalhistorymuseum' => true, - 'naturalsciences' => true, - 'nature' => true, - 'naturhistorisches' => true, - 'natuurwetenschappen' => true, - 'naumburg' => true, - 'naval' => true, - 'nebraska' => true, - 'neues' => true, - 'newhampshire' => true, - 'newjersey' => true, - 'newmexico' => true, - 'newport' => true, - 'newspaper' => true, - 'newyork' => true, - 'niepce' => true, - 'norfolk' => true, - 'north' => true, - 'nrw' => true, - 'nuernberg' => true, - 'nuremberg' => true, - 'nyc' => true, - 'nyny' => true, - 'oceanographic' => true, - 'oceanographique' => true, - 'omaha' => true, - 'online' => true, - 'ontario' => true, - 'openair' => true, - 'oregon' => true, - 'oregontrail' => true, - 'otago' => true, - 'oxford' => true, - 'pacific' => true, - 'paderborn' => true, - 'palace' => true, - 'paleo' => true, - 'palmsprings' => true, - 'panama' => true, - 'paris' => true, - 'pasadena' => true, - 'pharmacy' => true, - 'philadelphia' => true, - 'philadelphiaarea' => true, - 'philately' => true, - 'phoenix' => true, - 'photography' => true, - 'pilots' => true, - 'pittsburgh' => true, - 'planetarium' => true, - 'plantation' => true, - 'plants' => true, - 'plaza' => true, - 'portal' => true, - 'portland' => true, - 'portlligat' => true, - 'posts-and-telecommunications' => true, - 'preservation' => true, - 'presidio' => true, - 'press' => true, - 'project' => true, - 'public' => true, - 'pubol' => true, - 'quebec' => true, - 'railroad' => true, - 'railway' => true, - 'research' => true, - 'resistance' => true, - 'riodejaneiro' => true, - 'rochester' => true, - 'rockart' => true, - 'roma' => true, - 'russia' => true, - 'saintlouis' => true, - 'salem' => true, - 'salvadordali' => true, - 'salzburg' => true, - 'sandiego' => true, - 'sanfrancisco' => true, - 'santabarbara' => true, - 'santacruz' => true, - 'santafe' => true, - 'saskatchewan' => true, - 'satx' => true, - 'savannahga' => true, - 'schlesisches' => true, - 'schoenbrunn' => true, - 'schokoladen' => true, - 'school' => true, - 'schweiz' => true, - 'science' => true, - 'scienceandhistory' => true, - 'scienceandindustry' => true, - 'sciencecenter' => true, - 'sciencecenters' => true, - 'science-fiction' => true, - 'sciencehistory' => true, - 'sciences' => true, - 'sciencesnaturelles' => true, - 'scotland' => true, - 'seaport' => true, - 'settlement' => true, - 'settlers' => true, - 'shell' => true, - 'sherbrooke' => true, - 'sibenik' => true, - 'silk' => true, - 'ski' => true, - 'skole' => true, - 'society' => true, - 'sologne' => true, - 'soundandvision' => true, - 'southcarolina' => true, - 'southwest' => true, - 'space' => true, - 'spy' => true, - 'square' => true, - 'stadt' => true, - 'stalbans' => true, - 'starnberg' => true, - 'state' => true, - 'stateofdelaware' => true, - 'station' => true, - 'steam' => true, - 'steiermark' => true, - 'stjohn' => true, - 'stockholm' => true, - 'stpetersburg' => true, - 'stuttgart' => true, - 'suisse' => true, - 'surgeonshall' => true, - 'surrey' => true, - 'svizzera' => true, - 'sweden' => true, - 'sydney' => true, - 'tank' => true, - 'tcm' => true, - 'technology' => true, - 'telekommunikation' => true, - 'television' => true, - 'texas' => true, - 'textile' => true, - 'theater' => true, - 'time' => true, - 'timekeeping' => true, - 'topology' => true, - 'torino' => true, - 'touch' => true, - 'town' => true, - 'transport' => true, - 'tree' => true, - 'trolley' => true, - 'trust' => true, - 'trustee' => true, - 'uhren' => true, - 'ulm' => true, - 'undersea' => true, - 'university' => true, - 'usa' => true, - 'usantiques' => true, - 'usarts' => true, - 'uscountryestate' => true, - 'usculture' => true, - 'usdecorativearts' => true, - 'usgarden' => true, - 'ushistory' => true, - 'ushuaia' => true, - 'uslivinghistory' => true, - 'utah' => true, - 'uvic' => true, - 'valley' => true, - 'vantaa' => true, - 'versailles' => true, - 'viking' => true, - 'village' => true, - 'virginia' => true, - 'virtual' => true, - 'virtuel' => true, - 'vlaanderen' => true, - 'volkenkunde' => true, - 'wales' => true, - 'wallonie' => true, - 'war' => true, - 'washingtondc' => true, - 'watchandclock' => true, - 'watch-and-clock' => true, - 'western' => true, - 'westfalen' => true, - 'whaling' => true, - 'wildlife' => true, - 'williamsburg' => true, - 'windmill' => true, - 'workshop' => true, - 'york' => true, - 'yorkshire' => true, - 'yosemite' => true, - 'youth' => true, - 'zoological' => true, - 'zoology' => true, - 'ירושלים' => true, - 'иком' => true - ), - 'mv' => array( - 'aero' => true, - 'biz' => true, - 'com' => true, - 'coop' => true, - 'edu' => true, - 'gov' => true, - 'info' => true, - 'int' => true, - 'mil' => true, - 'museum' => true, - 'name' => true, - 'net' => true, - 'org' => true, - 'pro' => true - ), - 'mw' => array( - 'ac' => true, - 'biz' => true, - 'co' => true, - 'com' => true, - 'coop' => true, - 'edu' => true, - 'gov' => true, - 'int' => true, - 'museum' => true, - 'net' => true, - 'org' => true - ), - 'mx' => array( - 'com' => true, - 'org' => true, - 'gob' => true, - 'edu' => true, - 'net' => true, - 'blogspot' => true - ), - 'my' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'edu' => true, - 'mil' => true, - 'name' => true - ), - 'mz' => array( - '*' => true, - '!teledata' => true - ), - 'na' => array( - 'info' => true, - 'pro' => true, - 'name' => true, - 'school' => true, - 'or' => true, - 'dr' => true, - 'us' => true, - 'mx' => true, - 'ca' => true, - 'in' => true, - 'cc' => true, - 'tv' => true, - 'ws' => true, - 'mobi' => true, - 'co' => true, - 'com' => true, - 'org' => true - ), - 'name' => array( - 'her' => array( - 'forgot' => true - ), - 'his' => array( - 'forgot' => true - ) - ), - 'nc' => array( - 'asso' => true - ), - 'ne' => true, - 'net' => array( - 'cloudfront' => true, - 'gb' => true, - 'hu' => true, - 'jp' => true, - 'se' => true, - 'uk' => true, - 'at-band-camp' => true, - 'blogdns' => true, - 'broke-it' => true, - 'buyshouses' => true, - 'dnsalias' => true, - 'dnsdojo' => true, - 'does-it' => true, - 'dontexist' => true, - 'dynalias' => true, - 'dynathome' => true, - 'endofinternet' => true, - 'from-az' => true, - 'from-co' => true, - 'from-la' => true, - 'from-ny' => true, - 'gets-it' => true, - 'ham-radio-op' => true, - 'homeftp' => true, - 'homeip' => true, - 'homelinux' => true, - 'homeunix' => true, - 'in-the-band' => true, - 'is-a-chef' => true, - 'is-a-geek' => true, - 'isa-geek' => true, - 'kicks-ass' => true, - 'office-on-the' => true, - 'podzone' => true, - 'scrapper-site' => true, - 'selfip' => true, - 'sells-it' => true, - 'servebbs' => true, - 'serveftp' => true, - 'thruhere' => true, - 'webhop' => true, - 'fastly' => array( - 'ssl' => array( - 'a' => true, - 'b' => true, - 'global' => true - ), - 'prod' => array( - 'a' => true, - 'global' => true - ) - ), - 'za' => true - ), - 'nf' => array( - 'com' => true, - 'net' => true, - 'per' => true, - 'rec' => true, - 'web' => true, - 'arts' => true, - 'firm' => true, - 'info' => true, - 'other' => true, - 'store' => true - ), - 'ng' => array( - 'com' => true, - 'edu' => true, - 'name' => true, - 'net' => true, - 'org' => true, - 'sch' => true, - 'gov' => true, - 'mil' => true, - 'mobi' => true - ), - 'ni' => array( - '*' => true - ), - 'nl' => array( - 'bv' => true, - 'co' => true, - 'blogspot' => true - ), - 'no' => array( - 'fhs' => true, - 'vgs' => true, - 'fylkesbibl' => true, - 'folkebibl' => true, - 'museum' => true, - 'idrett' => true, - 'priv' => true, - 'mil' => true, - 'stat' => true, - 'dep' => true, - 'kommune' => true, - 'herad' => true, - 'aa' => array( - 'gs' => true - ), - 'ah' => array( - 'gs' => true - ), - 'bu' => array( - 'gs' => true - ), - 'fm' => array( - 'gs' => true - ), - 'hl' => array( - 'gs' => true - ), - 'hm' => array( - 'gs' => true - ), - 'jan-mayen' => array( - 'gs' => true - ), - 'mr' => array( - 'gs' => true - ), - 'nl' => array( - 'gs' => true - ), - 'nt' => array( - 'gs' => true - ), - 'of' => array( - 'gs' => true - ), - 'ol' => array( - 'gs' => true - ), - 'oslo' => array( - 'gs' => true - ), - 'rl' => array( - 'gs' => true - ), - 'sf' => array( - 'gs' => true - ), - 'st' => array( - 'gs' => true - ), - 'svalbard' => array( - 'gs' => true - ), - 'tm' => array( - 'gs' => true - ), - 'tr' => array( - 'gs' => true - ), - 'va' => array( - 'gs' => true - ), - 'vf' => array( - 'gs' => true - ), - 'akrehamn' => true, - 'åkrehamn' => true, - 'algard' => true, - 'ålgård' => true, - 'arna' => true, - 'brumunddal' => true, - 'bryne' => true, - 'bronnoysund' => true, - 'brønnøysund' => true, - 'drobak' => true, - 'drøbak' => true, - 'egersund' => true, - 'fetsund' => true, - 'floro' => true, - 'florø' => true, - 'fredrikstad' => true, - 'hokksund' => true, - 'honefoss' => true, - 'hønefoss' => true, - 'jessheim' => true, - 'jorpeland' => true, - 'jørpeland' => true, - 'kirkenes' => true, - 'kopervik' => true, - 'krokstadelva' => true, - 'langevag' => true, - 'langevåg' => true, - 'leirvik' => true, - 'mjondalen' => true, - 'mjøndalen' => true, - 'mo-i-rana' => true, - 'mosjoen' => true, - 'mosjøen' => true, - 'nesoddtangen' => true, - 'orkanger' => true, - 'osoyro' => true, - 'osøyro' => true, - 'raholt' => true, - 'råholt' => true, - 'sandnessjoen' => true, - 'sandnessjøen' => true, - 'skedsmokorset' => true, - 'slattum' => true, - 'spjelkavik' => true, - 'stathelle' => true, - 'stavern' => true, - 'stjordalshalsen' => true, - 'stjørdalshalsen' => true, - 'tananger' => true, - 'tranby' => true, - 'vossevangen' => true, - 'afjord' => true, - 'åfjord' => true, - 'agdenes' => true, - 'al' => true, - 'ål' => true, - 'alesund' => true, - 'ålesund' => true, - 'alstahaug' => true, - 'alta' => true, - 'áltá' => true, - 'alaheadju' => true, - 'álaheadju' => true, - 'alvdal' => true, - 'amli' => true, - 'åmli' => true, - 'amot' => true, - 'åmot' => true, - 'andebu' => true, - 'andoy' => true, - 'andøy' => true, - 'andasuolo' => true, - 'ardal' => true, - 'årdal' => true, - 'aremark' => true, - 'arendal' => true, - 'ås' => true, - 'aseral' => true, - 'åseral' => true, - 'asker' => true, - 'askim' => true, - 'askvoll' => true, - 'askoy' => true, - 'askøy' => true, - 'asnes' => true, - 'åsnes' => true, - 'audnedaln' => true, - 'aukra' => true, - 'aure' => true, - 'aurland' => true, - 'aurskog-holand' => true, - 'aurskog-høland' => true, - 'austevoll' => true, - 'austrheim' => true, - 'averoy' => true, - 'averøy' => true, - 'balestrand' => true, - 'ballangen' => true, - 'balat' => true, - 'bálát' => true, - 'balsfjord' => true, - 'bahccavuotna' => true, - 'báhccavuotna' => true, - 'bamble' => true, - 'bardu' => true, - 'beardu' => true, - 'beiarn' => true, - 'bajddar' => true, - 'bájddar' => true, - 'baidar' => true, - 'báidár' => true, - 'berg' => true, - 'bergen' => true, - 'berlevag' => true, - 'berlevåg' => true, - 'bearalvahki' => true, - 'bearalváhki' => true, - 'bindal' => true, - 'birkenes' => true, - 'bjarkoy' => true, - 'bjarkøy' => true, - 'bjerkreim' => true, - 'bjugn' => true, - 'bodo' => true, - 'bodø' => true, - 'badaddja' => true, - 'bådåddjå' => true, - 'budejju' => true, - 'bokn' => true, - 'bremanger' => true, - 'bronnoy' => true, - 'brønnøy' => true, - 'bygland' => true, - 'bykle' => true, - 'barum' => true, - 'bærum' => true, - 'telemark' => array( - 'bo' => true, - 'bø' => true - ), - 'nordland' => array( - 'bo' => true, - 'bø' => true, - 'heroy' => true, - 'herøy' => true - ), - 'bievat' => true, - 'bievát' => true, - 'bomlo' => true, - 'bømlo' => true, - 'batsfjord' => true, - 'båtsfjord' => true, - 'bahcavuotna' => true, - 'báhcavuotna' => true, - 'dovre' => true, - 'drammen' => true, - 'drangedal' => true, - 'dyroy' => true, - 'dyrøy' => true, - 'donna' => true, - 'dønna' => true, - 'eid' => true, - 'eidfjord' => true, - 'eidsberg' => true, - 'eidskog' => true, - 'eidsvoll' => true, - 'eigersund' => true, - 'elverum' => true, - 'enebakk' => true, - 'engerdal' => true, - 'etne' => true, - 'etnedal' => true, - 'evenes' => true, - 'evenassi' => true, - 'evenášši' => true, - 'evje-og-hornnes' => true, - 'farsund' => true, - 'fauske' => true, - 'fuossko' => true, - 'fuoisku' => true, - 'fedje' => true, - 'fet' => true, - 'finnoy' => true, - 'finnøy' => true, - 'fitjar' => true, - 'fjaler' => true, - 'fjell' => true, - 'flakstad' => true, - 'flatanger' => true, - 'flekkefjord' => true, - 'flesberg' => true, - 'flora' => true, - 'fla' => true, - 'flå' => true, - 'folldal' => true, - 'forsand' => true, - 'fosnes' => true, - 'frei' => true, - 'frogn' => true, - 'froland' => true, - 'frosta' => true, - 'frana' => true, - 'fræna' => true, - 'froya' => true, - 'frøya' => true, - 'fusa' => true, - 'fyresdal' => true, - 'forde' => true, - 'førde' => true, - 'gamvik' => true, - 'gangaviika' => true, - 'gáŋgaviika' => true, - 'gaular' => true, - 'gausdal' => true, - 'gildeskal' => true, - 'gildeskål' => true, - 'giske' => true, - 'gjemnes' => true, - 'gjerdrum' => true, - 'gjerstad' => true, - 'gjesdal' => true, - 'gjovik' => true, - 'gjøvik' => true, - 'gloppen' => true, - 'gol' => true, - 'gran' => true, - 'grane' => true, - 'granvin' => true, - 'gratangen' => true, - 'grimstad' => true, - 'grong' => true, - 'kraanghke' => true, - 'kråanghke' => true, - 'grue' => true, - 'gulen' => true, - 'hadsel' => true, - 'halden' => true, - 'halsa' => true, - 'hamar' => true, - 'hamaroy' => true, - 'habmer' => true, - 'hábmer' => true, - 'hapmir' => true, - 'hápmir' => true, - 'hammerfest' => true, - 'hammarfeasta' => true, - 'hámmárfeasta' => true, - 'haram' => true, - 'hareid' => true, - 'harstad' => true, - 'hasvik' => true, - 'aknoluokta' => true, - 'ákŋoluokta' => true, - 'hattfjelldal' => true, - 'aarborte' => true, - 'haugesund' => true, - 'hemne' => true, - 'hemnes' => true, - 'hemsedal' => true, - 'more-og-romsdal' => array( - 'heroy' => true, - 'sande' => true - ), - 'møre-og-romsdal' => array( - 'herøy' => true, - 'sande' => true - ), - 'hitra' => true, - 'hjartdal' => true, - 'hjelmeland' => true, - 'hobol' => true, - 'hobøl' => true, - 'hof' => true, - 'hol' => true, - 'hole' => true, - 'holmestrand' => true, - 'holtalen' => true, - 'holtålen' => true, - 'hornindal' => true, - 'horten' => true, - 'hurdal' => true, - 'hurum' => true, - 'hvaler' => true, - 'hyllestad' => true, - 'hagebostad' => true, - 'hægebostad' => true, - 'hoyanger' => true, - 'høyanger' => true, - 'hoylandet' => true, - 'høylandet' => true, - 'ha' => true, - 'hå' => true, - 'ibestad' => true, - 'inderoy' => true, - 'inderøy' => true, - 'iveland' => true, - 'jevnaker' => true, - 'jondal' => true, - 'jolster' => true, - 'jølster' => true, - 'karasjok' => true, - 'karasjohka' => true, - 'kárášjohka' => true, - 'karlsoy' => true, - 'galsa' => true, - 'gálsá' => true, - 'karmoy' => true, - 'karmøy' => true, - 'kautokeino' => true, - 'guovdageaidnu' => true, - 'klepp' => true, - 'klabu' => true, - 'klæbu' => true, - 'kongsberg' => true, - 'kongsvinger' => true, - 'kragero' => true, - 'kragerø' => true, - 'kristiansand' => true, - 'kristiansund' => true, - 'krodsherad' => true, - 'krødsherad' => true, - 'kvalsund' => true, - 'rahkkeravju' => true, - 'ráhkkerávju' => true, - 'kvam' => true, - 'kvinesdal' => true, - 'kvinnherad' => true, - 'kviteseid' => true, - 'kvitsoy' => true, - 'kvitsøy' => true, - 'kvafjord' => true, - 'kvæfjord' => true, - 'giehtavuoatna' => true, - 'kvanangen' => true, - 'kvænangen' => true, - 'navuotna' => true, - 'návuotna' => true, - 'kafjord' => true, - 'kåfjord' => true, - 'gaivuotna' => true, - 'gáivuotna' => true, - 'larvik' => true, - 'lavangen' => true, - 'lavagis' => true, - 'loabat' => true, - 'loabát' => true, - 'lebesby' => true, - 'davvesiida' => true, - 'leikanger' => true, - 'leirfjord' => true, - 'leka' => true, - 'leksvik' => true, - 'lenvik' => true, - 'leangaviika' => true, - 'leaŋgaviika' => true, - 'lesja' => true, - 'levanger' => true, - 'lier' => true, - 'lierne' => true, - 'lillehammer' => true, - 'lillesand' => true, - 'lindesnes' => true, - 'lindas' => true, - 'lindås' => true, - 'lom' => true, - 'loppa' => true, - 'lahppi' => true, - 'láhppi' => true, - 'lund' => true, - 'lunner' => true, - 'luroy' => true, - 'lurøy' => true, - 'luster' => true, - 'lyngdal' => true, - 'lyngen' => true, - 'ivgu' => true, - 'lardal' => true, - 'lerdal' => true, - 'lærdal' => true, - 'lodingen' => true, - 'lødingen' => true, - 'lorenskog' => true, - 'lørenskog' => true, - 'loten' => true, - 'løten' => true, - 'malvik' => true, - 'masoy' => true, - 'måsøy' => true, - 'muosat' => true, - 'muosát' => true, - 'mandal' => true, - 'marker' => true, - 'marnardal' => true, - 'masfjorden' => true, - 'meland' => true, - 'meldal' => true, - 'melhus' => true, - 'meloy' => true, - 'meløy' => true, - 'meraker' => true, - 'meråker' => true, - 'moareke' => true, - 'moåreke' => true, - 'midsund' => true, - 'midtre-gauldal' => true, - 'modalen' => true, - 'modum' => true, - 'molde' => true, - 'moskenes' => true, - 'moss' => true, - 'mosvik' => true, - 'malselv' => true, - 'målselv' => true, - 'malatvuopmi' => true, - 'málatvuopmi' => true, - 'namdalseid' => true, - 'aejrie' => true, - 'namsos' => true, - 'namsskogan' => true, - 'naamesjevuemie' => true, - 'nååmesjevuemie' => true, - 'laakesvuemie' => true, - 'nannestad' => true, - 'narvik' => true, - 'narviika' => true, - 'naustdal' => true, - 'nedre-eiker' => true, - 'akershus' => array( - 'nes' => true - ), - 'buskerud' => array( - 'nes' => true - ), - 'nesna' => true, - 'nesodden' => true, - 'nesseby' => true, - 'unjarga' => true, - 'unjárga' => true, - 'nesset' => true, - 'nissedal' => true, - 'nittedal' => true, - 'nord-aurdal' => true, - 'nord-fron' => true, - 'nord-odal' => true, - 'norddal' => true, - 'nordkapp' => true, - 'davvenjarga' => true, - 'davvenjárga' => true, - 'nordre-land' => true, - 'nordreisa' => true, - 'raisa' => true, - 'ráisa' => true, - 'nore-og-uvdal' => true, - 'notodden' => true, - 'naroy' => true, - 'nærøy' => true, - 'notteroy' => true, - 'nøtterøy' => true, - 'odda' => true, - 'oksnes' => true, - 'øksnes' => true, - 'oppdal' => true, - 'oppegard' => true, - 'oppegård' => true, - 'orkdal' => true, - 'orland' => true, - 'ørland' => true, - 'orskog' => true, - 'ørskog' => true, - 'orsta' => true, - 'ørsta' => true, - 'hedmark' => array( - 'os' => true, - 'valer' => true, - 'våler' => true - ), - 'hordaland' => array( - 'os' => true - ), - 'osen' => true, - 'osteroy' => true, - 'osterøy' => true, - 'ostre-toten' => true, - 'østre-toten' => true, - 'overhalla' => true, - 'ovre-eiker' => true, - 'øvre-eiker' => true, - 'oyer' => true, - 'øyer' => true, - 'oygarden' => true, - 'øygarden' => true, - 'oystre-slidre' => true, - 'øystre-slidre' => true, - 'porsanger' => true, - 'porsangu' => true, - 'porsáŋgu' => true, - 'porsgrunn' => true, - 'radoy' => true, - 'radøy' => true, - 'rakkestad' => true, - 'rana' => true, - 'ruovat' => true, - 'randaberg' => true, - 'rauma' => true, - 'rendalen' => true, - 'rennebu' => true, - 'rennesoy' => true, - 'rennesøy' => true, - 'rindal' => true, - 'ringebu' => true, - 'ringerike' => true, - 'ringsaker' => true, - 'rissa' => true, - 'risor' => true, - 'risør' => true, - 'roan' => true, - 'rollag' => true, - 'rygge' => true, - 'ralingen' => true, - 'rælingen' => true, - 'rodoy' => true, - 'rødøy' => true, - 'romskog' => true, - 'rømskog' => true, - 'roros' => true, - 'røros' => true, - 'rost' => true, - 'røst' => true, - 'royken' => true, - 'røyken' => true, - 'royrvik' => true, - 'røyrvik' => true, - 'rade' => true, - 'råde' => true, - 'salangen' => true, - 'siellak' => true, - 'saltdal' => true, - 'salat' => true, - 'sálát' => true, - 'sálat' => true, - 'samnanger' => true, - 'vestfold' => array( - 'sande' => true - ), - 'sandefjord' => true, - 'sandnes' => true, - 'sandoy' => true, - 'sandøy' => true, - 'sarpsborg' => true, - 'sauda' => true, - 'sauherad' => true, - 'sel' => true, - 'selbu' => true, - 'selje' => true, - 'seljord' => true, - 'sigdal' => true, - 'siljan' => true, - 'sirdal' => true, - 'skaun' => true, - 'skedsmo' => true, - 'ski' => true, - 'skien' => true, - 'skiptvet' => true, - 'skjervoy' => true, - 'skjervøy' => true, - 'skierva' => true, - 'skiervá' => true, - 'skjak' => true, - 'skjåk' => true, - 'skodje' => true, - 'skanland' => true, - 'skånland' => true, - 'skanit' => true, - 'skánit' => true, - 'smola' => true, - 'smøla' => true, - 'snillfjord' => true, - 'snasa' => true, - 'snåsa' => true, - 'snoasa' => true, - 'snaase' => true, - 'snåase' => true, - 'sogndal' => true, - 'sokndal' => true, - 'sola' => true, - 'solund' => true, - 'songdalen' => true, - 'sortland' => true, - 'spydeberg' => true, - 'stange' => true, - 'stavanger' => true, - 'steigen' => true, - 'steinkjer' => true, - 'stjordal' => true, - 'stjørdal' => true, - 'stokke' => true, - 'stor-elvdal' => true, - 'stord' => true, - 'stordal' => true, - 'storfjord' => true, - 'omasvuotna' => true, - 'strand' => true, - 'stranda' => true, - 'stryn' => true, - 'sula' => true, - 'suldal' => true, - 'sund' => true, - 'sunndal' => true, - 'surnadal' => true, - 'sveio' => true, - 'svelvik' => true, - 'sykkylven' => true, - 'sogne' => true, - 'søgne' => true, - 'somna' => true, - 'sømna' => true, - 'sondre-land' => true, - 'søndre-land' => true, - 'sor-aurdal' => true, - 'sør-aurdal' => true, - 'sor-fron' => true, - 'sør-fron' => true, - 'sor-odal' => true, - 'sør-odal' => true, - 'sor-varanger' => true, - 'sør-varanger' => true, - 'matta-varjjat' => true, - 'mátta-várjjat' => true, - 'sorfold' => true, - 'sørfold' => true, - 'sorreisa' => true, - 'sørreisa' => true, - 'sorum' => true, - 'sørum' => true, - 'tana' => true, - 'deatnu' => true, - 'time' => true, - 'tingvoll' => true, - 'tinn' => true, - 'tjeldsund' => true, - 'dielddanuorri' => true, - 'tjome' => true, - 'tjøme' => true, - 'tokke' => true, - 'tolga' => true, - 'torsken' => true, - 'tranoy' => true, - 'tranøy' => true, - 'tromso' => true, - 'tromsø' => true, - 'tromsa' => true, - 'romsa' => true, - 'trondheim' => true, - 'troandin' => true, - 'trysil' => true, - 'trana' => true, - 'træna' => true, - 'trogstad' => true, - 'trøgstad' => true, - 'tvedestrand' => true, - 'tydal' => true, - 'tynset' => true, - 'tysfjord' => true, - 'divtasvuodna' => true, - 'divttasvuotna' => true, - 'tysnes' => true, - 'tysvar' => true, - 'tysvær' => true, - 'tonsberg' => true, - 'tønsberg' => true, - 'ullensaker' => true, - 'ullensvang' => true, - 'ulvik' => true, - 'utsira' => true, - 'vadso' => true, - 'vadsø' => true, - 'cahcesuolo' => true, - 'čáhcesuolo' => true, - 'vaksdal' => true, - 'valle' => true, - 'vang' => true, - 'vanylven' => true, - 'vardo' => true, - 'vardø' => true, - 'varggat' => true, - 'várggát' => true, - 'vefsn' => true, - 'vaapste' => true, - 'vega' => true, - 'vegarshei' => true, - 'vegårshei' => true, - 'vennesla' => true, - 'verdal' => true, - 'verran' => true, - 'vestby' => true, - 'vestnes' => true, - 'vestre-slidre' => true, - 'vestre-toten' => true, - 'vestvagoy' => true, - 'vestvågøy' => true, - 'vevelstad' => true, - 'vik' => true, - 'vikna' => true, - 'vindafjord' => true, - 'volda' => true, - 'voss' => true, - 'varoy' => true, - 'værøy' => true, - 'vagan' => true, - 'vågan' => true, - 'voagat' => true, - 'vagsoy' => true, - 'vågsøy' => true, - 'vaga' => true, - 'vågå' => true, - 'ostfold' => array( - 'valer' => true - ), - 'østfold' => array( - 'våler' => true - ), - 'co' => true, - 'blogspot' => true - ), - 'np' => array( - '*' => true - ), - 'nr' => array( - 'biz' => true, - 'info' => true, - 'gov' => true, - 'edu' => true, - 'org' => true, - 'net' => true, - 'com' => true - ), - 'nu' => array( - 'merseine' => true, - 'mine' => true, - 'shacknet' => true - ), - 'nz' => array( - '*' => true, - 'co' => array( - 'blogspot' => true - ) - ), - 'om' => array( - 'co' => true, - 'com' => true, - 'edu' => true, - 'gov' => true, - 'med' => true, - 'museum' => true, - 'net' => true, - 'org' => true, - 'pro' => true - ), - 'org' => array( - 'ae' => true, - 'us' => true, - 'dyndns' => array( - 'go' => true, - 'home' => true - ), - 'blogdns' => true, - 'blogsite' => true, - 'boldlygoingnowhere' => true, - 'dnsalias' => true, - 'dnsdojo' => true, - 'doesntexist' => true, - 'dontexist' => true, - 'doomdns' => true, - 'dvrdns' => true, - 'dynalias' => true, - 'endofinternet' => true, - 'endoftheinternet' => true, - 'from-me' => true, - 'game-host' => true, - 'gotdns' => true, - 'hobby-site' => true, - 'homedns' => true, - 'homeftp' => true, - 'homelinux' => true, - 'homeunix' => true, - 'is-a-bruinsfan' => true, - 'is-a-candidate' => true, - 'is-a-celticsfan' => true, - 'is-a-chef' => true, - 'is-a-geek' => true, - 'is-a-knight' => true, - 'is-a-linux-user' => true, - 'is-a-patsfan' => true, - 'is-a-soxfan' => true, - 'is-found' => true, - 'is-lost' => true, - 'is-saved' => true, - 'is-very-bad' => true, - 'is-very-evil' => true, - 'is-very-good' => true, - 'is-very-nice' => true, - 'is-very-sweet' => true, - 'isa-geek' => true, - 'kicks-ass' => true, - 'misconfused' => true, - 'podzone' => true, - 'readmyblog' => true, - 'selfip' => true, - 'sellsyourhome' => true, - 'servebbs' => true, - 'serveftp' => true, - 'servegame' => true, - 'stuff-4-sale' => true, - 'webhop' => true, - 'za' => true - ), - 'pa' => array( - 'ac' => true, - 'gob' => true, - 'com' => true, - 'org' => true, - 'sld' => true, - 'edu' => true, - 'net' => true, - 'ing' => true, - 'abo' => true, - 'med' => true, - 'nom' => true - ), - 'pe' => array( - 'edu' => true, - 'gob' => true, - 'nom' => true, - 'mil' => true, - 'org' => true, - 'com' => true, - 'net' => true - ), - 'pf' => array( - 'com' => true, - 'org' => true, - 'edu' => true - ), - 'pg' => array( - '*' => true - ), - 'ph' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'edu' => true, - 'ngo' => true, - 'mil' => true, - 'i' => true - ), - 'pk' => array( - 'com' => true, - 'net' => true, - 'edu' => true, - 'org' => true, - 'fam' => true, - 'biz' => true, - 'web' => true, - 'gov' => true, - 'gob' => true, - 'gok' => true, - 'gon' => true, - 'gop' => true, - 'gos' => true, - 'info' => true - ), - 'pl' => array( - 'aid' => true, - 'agro' => true, - 'atm' => true, - 'auto' => true, - 'biz' => true, - 'com' => true, - 'edu' => true, - 'gmina' => true, - 'gsm' => true, - 'info' => true, - 'mail' => true, - 'miasta' => true, - 'media' => true, - 'mil' => true, - 'net' => true, - 'nieruchomosci' => true, - 'nom' => true, - 'org' => true, - 'pc' => true, - 'powiat' => true, - 'priv' => true, - 'realestate' => true, - 'rel' => true, - 'sex' => true, - 'shop' => true, - 'sklep' => true, - 'sos' => true, - 'szkola' => true, - 'targi' => true, - 'tm' => true, - 'tourism' => true, - 'travel' => true, - 'turystyka' => true, - '6bone' => true, - 'art' => true, - 'mbone' => true, - 'gov' => array( - 'uw' => true, - 'um' => true, - 'ug' => true, - 'upow' => true, - 'starostwo' => true, - 'so' => true, - 'sr' => true, - 'po' => true, - 'pa' => true - ), - 'ngo' => true, - 'irc' => true, - 'usenet' => true, - 'augustow' => true, - 'babia-gora' => true, - 'bedzin' => true, - 'beskidy' => true, - 'bialowieza' => true, - 'bialystok' => true, - 'bielawa' => true, - 'bieszczady' => true, - 'boleslawiec' => true, - 'bydgoszcz' => true, - 'bytom' => true, - 'cieszyn' => true, - 'czeladz' => true, - 'czest' => true, - 'dlugoleka' => true, - 'elblag' => true, - 'elk' => true, - 'glogow' => true, - 'gniezno' => true, - 'gorlice' => true, - 'grajewo' => true, - 'ilawa' => true, - 'jaworzno' => true, - 'jelenia-gora' => true, - 'jgora' => true, - 'kalisz' => true, - 'kazimierz-dolny' => true, - 'karpacz' => true, - 'kartuzy' => true, - 'kaszuby' => true, - 'katowice' => true, - 'kepno' => true, - 'ketrzyn' => true, - 'klodzko' => true, - 'kobierzyce' => true, - 'kolobrzeg' => true, - 'konin' => true, - 'konskowola' => true, - 'kutno' => true, - 'lapy' => true, - 'lebork' => true, - 'legnica' => true, - 'lezajsk' => true, - 'limanowa' => true, - 'lomza' => true, - 'lowicz' => true, - 'lubin' => true, - 'lukow' => true, - 'malbork' => true, - 'malopolska' => true, - 'mazowsze' => true, - 'mazury' => true, - 'mielec' => true, - 'mielno' => true, - 'mragowo' => true, - 'naklo' => true, - 'nowaruda' => true, - 'nysa' => true, - 'olawa' => true, - 'olecko' => true, - 'olkusz' => true, - 'olsztyn' => true, - 'opoczno' => true, - 'opole' => true, - 'ostroda' => true, - 'ostroleka' => true, - 'ostrowiec' => true, - 'ostrowwlkp' => true, - 'pila' => true, - 'pisz' => true, - 'podhale' => true, - 'podlasie' => true, - 'polkowice' => true, - 'pomorze' => true, - 'pomorskie' => true, - 'prochowice' => true, - 'pruszkow' => true, - 'przeworsk' => true, - 'pulawy' => true, - 'radom' => true, - 'rawa-maz' => true, - 'rybnik' => true, - 'rzeszow' => true, - 'sanok' => true, - 'sejny' => true, - 'siedlce' => true, - 'slask' => true, - 'slupsk' => true, - 'sosnowiec' => true, - 'stalowa-wola' => true, - 'skoczow' => true, - 'starachowice' => true, - 'stargard' => true, - 'suwalki' => true, - 'swidnica' => true, - 'swiebodzin' => true, - 'swinoujscie' => true, - 'szczecin' => true, - 'szczytno' => true, - 'tarnobrzeg' => true, - 'tgory' => true, - 'turek' => true, - 'tychy' => true, - 'ustka' => true, - 'walbrzych' => true, - 'warmia' => true, - 'warszawa' => true, - 'waw' => true, - 'wegrow' => true, - 'wielun' => true, - 'wlocl' => true, - 'wloclawek' => true, - 'wodzislaw' => true, - 'wolomin' => true, - 'wroclaw' => true, - 'zachpomor' => true, - 'zagan' => true, - 'zarow' => true, - 'zgora' => true, - 'zgorzelec' => true, - 'gda' => true, - 'gdansk' => true, - 'gdynia' => true, - 'med' => true, - 'sopot' => true, - 'gliwice' => true, - 'krakow' => true, - 'poznan' => true, - 'wroc' => true, - 'zakopane' => true, - 'co' => true - ), - 'pm' => true, - 'pn' => array( - 'gov' => true, - 'co' => true, - 'org' => true, - 'edu' => true, - 'net' => true - ), - 'post' => true, - 'pr' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'edu' => true, - 'isla' => true, - 'pro' => true, - 'biz' => true, - 'info' => true, - 'name' => true, - 'est' => true, - 'prof' => true, - 'ac' => true - ), - 'pro' => array( - 'aca' => true, - 'bar' => true, - 'cpa' => true, - 'jur' => true, - 'law' => true, - 'med' => true, - 'eng' => true - ), - 'ps' => array( - 'edu' => true, - 'gov' => true, - 'sec' => true, - 'plo' => true, - 'com' => true, - 'org' => true, - 'net' => true - ), - 'pt' => array( - 'net' => true, - 'gov' => true, - 'org' => true, - 'edu' => true, - 'int' => true, - 'publ' => true, - 'com' => true, - 'nome' => true, - 'blogspot' => true - ), - 'pw' => array( - 'co' => true, - 'ne' => true, - 'or' => true, - 'ed' => true, - 'go' => true, - 'belau' => true - ), - 'py' => array( - 'com' => true, - 'coop' => true, - 'edu' => true, - 'gov' => true, - 'mil' => true, - 'net' => true, - 'org' => true - ), - 'qa' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'mil' => true, - 'name' => true, - 'net' => true, - 'org' => true, - 'sch' => true - ), - 're' => array( - 'com' => true, - 'asso' => true, - 'nom' => true, - 'blogspot' => true - ), - 'ro' => array( - 'com' => true, - 'org' => true, - 'tm' => true, - 'nt' => true, - 'nom' => true, - 'info' => true, - 'rec' => true, - 'arts' => true, - 'firm' => true, - 'store' => true, - 'www' => true, - 'blogspot' => true - ), - 'rs' => array( - 'co' => true, - 'org' => true, - 'edu' => true, - 'ac' => true, - 'gov' => true, - 'in' => true - ), - 'ru' => array( - 'ac' => true, - 'com' => true, - 'edu' => true, - 'int' => true, - 'net' => true, - 'org' => true, - 'pp' => true, - 'adygeya' => true, - 'altai' => true, - 'amur' => true, - 'arkhangelsk' => true, - 'astrakhan' => true, - 'bashkiria' => true, - 'belgorod' => true, - 'bir' => true, - 'bryansk' => true, - 'buryatia' => true, - 'cbg' => true, - 'chel' => true, - 'chelyabinsk' => true, - 'chita' => true, - 'chukotka' => true, - 'chuvashia' => true, - 'dagestan' => true, - 'dudinka' => true, - 'e-burg' => true, - 'grozny' => true, - 'irkutsk' => true, - 'ivanovo' => true, - 'izhevsk' => true, - 'jar' => true, - 'joshkar-ola' => true, - 'kalmykia' => true, - 'kaluga' => true, - 'kamchatka' => true, - 'karelia' => true, - 'kazan' => true, - 'kchr' => true, - 'kemerovo' => true, - 'khabarovsk' => true, - 'khakassia' => true, - 'khv' => true, - 'kirov' => true, - 'koenig' => true, - 'komi' => true, - 'kostroma' => true, - 'krasnoyarsk' => true, - 'kuban' => true, - 'kurgan' => true, - 'kursk' => true, - 'lipetsk' => true, - 'magadan' => true, - 'mari' => true, - 'mari-el' => true, - 'marine' => true, - 'mordovia' => true, - 'mosreg' => true, - 'msk' => true, - 'murmansk' => true, - 'nalchik' => true, - 'nnov' => true, - 'nov' => true, - 'novosibirsk' => true, - 'nsk' => true, - 'omsk' => true, - 'orenburg' => true, - 'oryol' => true, - 'palana' => true, - 'penza' => true, - 'perm' => true, - 'pskov' => true, - 'ptz' => true, - 'rnd' => true, - 'ryazan' => true, - 'sakhalin' => true, - 'samara' => true, - 'saratov' => true, - 'simbirsk' => true, - 'smolensk' => true, - 'spb' => true, - 'stavropol' => true, - 'stv' => true, - 'surgut' => true, - 'tambov' => true, - 'tatarstan' => true, - 'tom' => true, - 'tomsk' => true, - 'tsaritsyn' => true, - 'tsk' => true, - 'tula' => true, - 'tuva' => true, - 'tver' => true, - 'tyumen' => true, - 'udm' => true, - 'udmurtia' => true, - 'ulan-ude' => true, - 'vladikavkaz' => true, - 'vladimir' => true, - 'vladivostok' => true, - 'volgograd' => true, - 'vologda' => true, - 'voronezh' => true, - 'vrn' => true, - 'vyatka' => true, - 'yakutia' => true, - 'yamal' => true, - 'yaroslavl' => true, - 'yekaterinburg' => true, - 'yuzhno-sakhalinsk' => true, - 'amursk' => true, - 'baikal' => true, - 'cmw' => true, - 'fareast' => true, - 'jamal' => true, - 'kms' => true, - 'k-uralsk' => true, - 'kustanai' => true, - 'kuzbass' => true, - 'magnitka' => true, - 'mytis' => true, - 'nakhodka' => true, - 'nkz' => true, - 'norilsk' => true, - 'oskol' => true, - 'pyatigorsk' => true, - 'rubtsovsk' => true, - 'snz' => true, - 'syzran' => true, - 'vdonsk' => true, - 'zgrad' => true, - 'gov' => true, - 'mil' => true, - 'test' => true - ), - 'rw' => array( - 'gov' => true, - 'net' => true, - 'edu' => true, - 'ac' => true, - 'com' => true, - 'co' => true, - 'int' => true, - 'mil' => true, - 'gouv' => true - ), - 'sa' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'med' => true, - 'pub' => true, - 'edu' => true, - 'sch' => true - ), - 'sb' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'net' => true, - 'org' => true - ), - 'sc' => array( - 'com' => true, - 'gov' => true, - 'net' => true, - 'org' => true, - 'edu' => true - ), - 'sd' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'edu' => true, - 'med' => true, - 'tv' => true, - 'gov' => true, - 'info' => true - ), - 'se' => array( - 'a' => true, - 'ac' => true, - 'b' => true, - 'bd' => true, - 'brand' => true, - 'c' => true, - 'd' => true, - 'e' => true, - 'f' => true, - 'fh' => true, - 'fhsk' => true, - 'fhv' => true, - 'g' => true, - 'h' => true, - 'i' => true, - 'k' => true, - 'komforb' => true, - 'kommunalforbund' => true, - 'komvux' => true, - 'l' => true, - 'lanbib' => true, - 'm' => true, - 'n' => true, - 'naturbruksgymn' => true, - 'o' => true, - 'org' => true, - 'p' => true, - 'parti' => true, - 'pp' => true, - 'press' => true, - 'r' => true, - 's' => true, - 'sshn' => true, - 't' => true, - 'tm' => true, - 'u' => true, - 'w' => true, - 'x' => true, - 'y' => true, - 'z' => true, - 'blogspot' => true - ), - 'sg' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'edu' => true, - 'per' => true, - 'blogspot' => true - ), - 'sh' => array( - 'com' => true, - 'net' => true, - 'gov' => true, - 'org' => true, - 'mil' => true - ), - 'si' => true, - 'sj' => true, - 'sk' => array( - 'blogspot' => true - ), - 'sl' => array( - 'com' => true, - 'net' => true, - 'edu' => true, - 'gov' => true, - 'org' => true - ), - 'sm' => true, - 'sn' => array( - 'art' => true, - 'com' => true, - 'edu' => true, - 'gouv' => true, - 'org' => true, - 'perso' => true, - 'univ' => true - ), - 'so' => array( - 'com' => true, - 'net' => true, - 'org' => true - ), - 'sr' => true, - 'st' => array( - 'co' => true, - 'com' => true, - 'consulado' => true, - 'edu' => true, - 'embaixada' => true, - 'gov' => true, - 'mil' => true, - 'net' => true, - 'org' => true, - 'principe' => true, - 'saotome' => true, - 'store' => true - ), - 'su' => true, - 'sv' => array( - 'com' => true, - 'edu' => true, - 'gob' => true, - 'org' => true, - 'red' => true - ), - 'sx' => array( - 'gov' => true - ), - 'sy' => array( - 'edu' => true, - 'gov' => true, - 'net' => true, - 'mil' => true, - 'com' => true, - 'org' => true - ), - 'sz' => array( - 'co' => true, - 'ac' => true, - 'org' => true - ), - 'tc' => true, - 'td' => array( - 'blogspot' => true - ), - 'tel' => true, - 'tf' => true, - 'tg' => true, - 'th' => array( - 'ac' => true, - 'co' => true, - 'go' => true, - 'in' => true, - 'mi' => true, - 'net' => true, - 'or' => true - ), - 'tj' => array( - 'ac' => true, - 'biz' => true, - 'co' => true, - 'com' => true, - 'edu' => true, - 'go' => true, - 'gov' => true, - 'int' => true, - 'mil' => true, - 'name' => true, - 'net' => true, - 'nic' => true, - 'org' => true, - 'test' => true, - 'web' => true - ), - 'tk' => true, - 'tl' => array( - 'gov' => true - ), - 'tm' => array( - 'com' => true, - 'co' => true, - 'org' => true, - 'net' => true, - 'nom' => true, - 'gov' => true, - 'mil' => true, - 'edu' => true - ), - 'tn' => array( - 'com' => true, - 'ens' => true, - 'fin' => true, - 'gov' => true, - 'ind' => true, - 'intl' => true, - 'nat' => true, - 'net' => true, - 'org' => true, - 'info' => true, - 'perso' => true, - 'tourism' => true, - 'edunet' => true, - 'rnrt' => true, - 'rns' => true, - 'rnu' => true, - 'mincom' => true, - 'agrinet' => true, - 'defense' => true, - 'turen' => true - ), - 'to' => array( - 'com' => true, - 'gov' => true, - 'net' => true, - 'org' => true, - 'edu' => true, - 'mil' => true - ), - 'tp' => true, - 'tr' => array( - '*' => true, - '!nic' => true, - 'nc' => array( - 'gov' => true - ) - ), - 'travel' => true, - 'tt' => array( - 'co' => true, - 'com' => true, - 'org' => true, - 'net' => true, - 'biz' => true, - 'info' => true, - 'pro' => true, - 'int' => true, - 'coop' => true, - 'jobs' => true, - 'mobi' => true, - 'travel' => true, - 'museum' => true, - 'aero' => true, - 'name' => true, - 'gov' => true, - 'edu' => true - ), - 'tv' => array( - 'dyndns' => true, - 'better-than' => true, - 'on-the-web' => true, - 'worse-than' => true - ), - 'tw' => array( - 'edu' => true, - 'gov' => true, - 'mil' => true, - 'com' => true, - 'net' => true, - 'org' => true, - 'idv' => true, - 'game' => true, - 'ebiz' => true, - 'club' => true, - '網路' => true, - '組織' => true, - '商業' => true, - 'blogspot' => true - ), - 'tz' => array( - 'ac' => true, - 'co' => true, - 'go' => true, - 'hotel' => true, - 'info' => true, - 'me' => true, - 'mil' => true, - 'mobi' => true, - 'ne' => true, - 'or' => true, - 'sc' => true, - 'tv' => true - ), - 'ua' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'in' => true, - 'net' => true, - 'org' => true, - 'cherkassy' => true, - 'cherkasy' => true, - 'chernigov' => true, - 'chernihiv' => true, - 'chernivtsi' => true, - 'chernovtsy' => true, - 'ck' => true, - 'cn' => true, - 'cr' => true, - 'crimea' => true, - 'cv' => true, - 'dn' => true, - 'dnepropetrovsk' => true, - 'dnipropetrovsk' => true, - 'dominic' => true, - 'donetsk' => true, - 'dp' => true, - 'if' => true, - 'ivano-frankivsk' => true, - 'kh' => true, - 'kharkiv' => true, - 'kharkov' => true, - 'kherson' => true, - 'khmelnitskiy' => true, - 'khmelnytskyi' => true, - 'kiev' => true, - 'kirovograd' => true, - 'km' => true, - 'kr' => true, - 'krym' => true, - 'ks' => true, - 'kv' => true, - 'kyiv' => true, - 'lg' => true, - 'lt' => true, - 'lugansk' => true, - 'lutsk' => true, - 'lv' => true, - 'lviv' => true, - 'mk' => true, - 'mykolaiv' => true, - 'nikolaev' => true, - 'od' => true, - 'odesa' => true, - 'odessa' => true, - 'pl' => true, - 'poltava' => true, - 'rivne' => true, - 'rovno' => true, - 'rv' => true, - 'sb' => true, - 'sebastopol' => true, - 'sevastopol' => true, - 'sm' => true, - 'sumy' => true, - 'te' => true, - 'ternopil' => true, - 'uz' => true, - 'uzhgorod' => true, - 'vinnica' => true, - 'vinnytsia' => true, - 'vn' => true, - 'volyn' => true, - 'yalta' => true, - 'zaporizhzhe' => true, - 'zaporizhzhia' => true, - 'zhitomir' => true, - 'zhytomyr' => true, - 'zp' => true, - 'zt' => true, - 'co' => true, - 'pp' => true - ), - 'ug' => array( - 'co' => true, - 'or' => true, - 'ac' => true, - 'sc' => true, - 'go' => true, - 'ne' => true, - 'com' => true, - 'org' => true - ), - 'uk' => array( - '*' => true, - 'sch' => array( - '*' => true - ), - '!bl' => true, - '!british-library' => true, - '!jet' => true, - '!mod' => true, - '!national-library-scotland' => true, - '!nel' => true, - '!nic' => true, - '!nls' => true, - '!parliament' => true, - 'co' => array( - 'blogspot' => true - ) - ), - 'us' => array( - 'dni' => true, - 'fed' => true, - 'isa' => true, - 'kids' => true, - 'nsn' => true, - 'ak' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'al' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ar' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'as' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'az' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ca' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'co' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ct' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'dc' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'de' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'fl' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ga' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'gu' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'hi' => array( - 'cc' => true, - 'lib' => true - ), - 'ia' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'id' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'il' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'in' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ks' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ky' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'la' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ma' => array( - 'k12' => array( - 'pvt' => true, - 'chtr' => true, - 'paroch' => true - ), - 'cc' => true, - 'lib' => true - ), - 'md' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'me' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'mi' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'mn' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'mo' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ms' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'mt' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'nc' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'nd' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ne' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'nh' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'nj' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'nm' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'nv' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ny' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'oh' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ok' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'or' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'pa' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'pr' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ri' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'sc' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'sd' => array( - 'cc' => true, - 'lib' => true - ), - 'tn' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'tx' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'ut' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'vi' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'vt' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'va' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'wa' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'wi' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'wv' => array( - 'cc' => true - ), - 'wy' => array( - 'k12' => true, - 'cc' => true, - 'lib' => true - ), - 'is-by' => true, - 'land-4-sale' => true, - 'stuff-4-sale' => true - ), - 'uy' => array( - 'com' => true, - 'edu' => true, - 'gub' => true, - 'mil' => true, - 'net' => true, - 'org' => true - ), - 'uz' => array( - 'co' => true, - 'com' => true, - 'net' => true, - 'org' => true - ), - 'va' => true, - 'vc' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'mil' => true, - 'edu' => true - ), - 've' => array( - 'co' => true, - 'com' => true, - 'e12' => true, - 'edu' => true, - 'gov' => true, - 'info' => true, - 'mil' => true, - 'net' => true, - 'org' => true, - 'web' => true - ), - 'vg' => true, - 'vi' => array( - 'co' => true, - 'com' => true, - 'k12' => true, - 'net' => true, - 'org' => true - ), - 'vn' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'edu' => true, - 'gov' => true, - 'int' => true, - 'ac' => true, - 'biz' => true, - 'info' => true, - 'name' => true, - 'pro' => true, - 'health' => true - ), - 'vu' => true, - 'wf' => true, - 'ws' => array( - 'com' => true, - 'net' => true, - 'org' => true, - 'gov' => true, - 'edu' => true, - 'dyndns' => true, - 'mypets' => true - ), - 'yt' => true, - 'امارات' => true, - 'বাংলা' => true, - '中国' => true, - '中國' => true, - 'الجزائر' => true, - 'مصر' => true, - 'გე' => true, - '香港' => true, - 'भारत' => true, - 'بھارت' => true, - 'భారత్' => true, - 'ભારત' => true, - 'ਭਾਰਤ' => true, - 'ভারত' => true, - 'இந்தியா' => true, - 'ایران' => true, - 'ايران' => true, - 'الاردن' => true, - '한국' => true, - 'қаз' => true, - 'ලංකා' => true, - 'இலங்கை' => true, - 'المغرب' => true, - 'мон' => true, - 'مليسيا' => true, - 'عمان' => true, - 'فلسطين' => true, - 'срб' => true, - 'рф' => true, - 'قطر' => true, - 'السعودية' => true, - 'السعودیة' => true, - 'السعودیۃ' => true, - 'السعوديه' => true, - 'سورية' => true, - 'سوريا' => true, - '新加坡' => true, - 'சிங்கப்பூர்' => true, - 'ไทย' => true, - 'تونس' => true, - '台灣' => true, - '台湾' => true, - '臺灣' => true, - 'укр' => true, - 'اليمن' => true, - 'xxx' => true, - 'ye' => array( - '*' => true - ), - 'za' => array( - '*' => true - ), - 'zm' => array( - '*' => true - ), - 'zw' => array( - '*' => true - ), - 'онлайн' => true, - 'сайт' => true, - 'شبكة' => true, - '游戏' => true, - '企业' => true, - 'camera' => true, - 'clothing' => true, - 'lighting' => true, - 'singles' => true, - 'ventures' => true, - 'voyage' => true, - 'guru' => true, - 'holdings' => true, - 'equipment' => true, - 'bike' => true, - 'estate' => true, - 'tattoo' => true, - '在线' => true, - '中文网' => true, - 'land' => true, - 'plumbing' => true, - 'contractors' => true, - 'sexy' => true, - 'menu' => true, - '世界' => true, - 'uno' => true, - 'gallery' => true, - 'technology' => true, - '集团' => true, - 'reviews' => true, - 'guide' => true, - '我爱你' => true, - 'graphics' => true, - 'construction' => true, - 'onl' => true, - 'みんな' => true, - 'diamonds' => true, - 'kiwi' => true, - 'enterprises' => true, - 'today' => true, - 'futbol' => true, - 'photography' => true, - 'tips' => true, - 'directory' => true, - 'kitchen' => true, - '移动' => true, - 'kim' => true, - '삼성' => true, - 'monash' => true, - 'wed' => true, - 'pink' => true, - 'ruhr' => true, - 'buzz' => true, - 'careers' => true, - 'shoes' => true, - 'موقع' => true, - 'career' => true, - 'otsuka' => true, - '中信' => true, - 'gift' => true, - 'recipes' => true, - 'coffee' => true, - 'luxury' => true, - 'domains' => true, - 'photos' => true, - 'limo' => true, - 'viajes' => true, - 'wang' => true, - 'democrat' => true, - 'mango' => true, - 'cab' => true, - 'support' => true, - 'dance' => true, - 'nagoya' => true, - 'computer' => true, - 'wien' => true, - 'berlin' => true, - 'codes' => true, - 'email' => true, - 'بازار' => true, - 'repair' => true, - 'holiday' => true, - 'center' => true, - 'systems' => true, - 'wiki' => true, - 'ceo' => true, - 'international' => true, - 'solar' => true, - 'company' => true, - 'education' => true, - 'training' => true, - 'academy' => true, - 'marketing' => true, - 'florist' => true, - 'solutions' => true, - 'build' => true, - 'institute' => true, - 'builders' => true, - 'red' => true, - 'blue' => true, - 'ninja' => true, - 'business' => true, - 'gal' => true, - 'social' => true, - 'house' => true, - 'camp' => true, - 'immobilien' => true, - 'moda' => true, - 'glass' => true, - 'management' => true, - 'kaufen' => true, - 'farm' => true, - '公益' => true, - '政务' => true, - 'club' => true, - 'voting' => true, - 'TOKYO' => true, - 'moe' => true -); -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/docs/LICENSE b/vendor/pear/http_request2/docs/LICENSE deleted file mode 100644 index fe4ae1a47..000000000 --- a/vendor/pear/http_request2/docs/LICENSE +++ /dev/null @@ -1,31 +0,0 @@ -HTTP_Request2 - -Copyright (c) 2008-2014, Alexey Borzov -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of Alexey Borzov nor the names of his contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/pear/http_request2/docs/examples/upload-rapidshare.php b/vendor/pear/http_request2/docs/examples/upload-rapidshare.php deleted file mode 100644 index 8773d1597..000000000 --- a/vendor/pear/http_request2/docs/examples/upload-rapidshare.php +++ /dev/null @@ -1,58 +0,0 @@ -send()->getBody(); - if (!preg_match('/^(\\d+)$/', $server)) { - throw new Exception("Invalid upload server: {$server}"); - } - - // Calculate file hash, we'll use it later to check upload - if (false === ($hash = @md5_file($filename))) { - throw new Exception("Cannot calculate MD5 hash of '{$filename}'"); - } - - // Second step: upload a file to the available server - $uploader = new HTTP_Request2( - "http://rs{$server}l3.rapidshare.com/cgi-bin/upload.cgi", - HTTP_Request2::METHOD_POST - ); - // Adding the file - $uploader->addUpload('filecontent', $filename); - // This will tell server to return program-friendly output - $uploader->addPostParameter('rsapi_v1', '1'); - - $response = $uploader->send()->getBody(); - if (!preg_match_all('/^(File[^=]+)=(.+)$/m', $response, $m, PREG_SET_ORDER)) { - throw new Exception("Invalid response: {$response}"); - } - $rspAry = array(); - foreach ($m as $item) { - $rspAry[$item[1]] = $item[2]; - } - // Check that uploaded file has the same hash - if (empty($rspAry['File1.4'])) { - throw new Exception("MD5 hash data not found in response"); - } elseif ($hash != strtolower($rspAry['File1.4'])) { - throw new Exception("Upload failed, local MD5 is {$hash}, uploaded MD5 is {$rspAry['File1.4']}"); - } - echo "Upload succeeded\nDownload link: {$rspAry['File1.1']}\nDelete link: {$rspAry['File1.2']}\n"; - -} catch (Exception $e) { - echo "Error: " . $e->getMessage(); -} -?> diff --git a/vendor/pear/http_request2/package.xml b/vendor/pear/http_request2/package.xml deleted file mode 100644 index b648a16f8..000000000 --- a/vendor/pear/http_request2/package.xml +++ /dev/null @@ -1,646 +0,0 @@ - - - - HTTP_Request2 - pear.php.net - HTTP_Request - Provides an easy way to perform HTTP requests. - -PHP5 rewrite of HTTP_Request package (with parts of HTTP_Client). Provides -cleaner API and pluggable Adapters: - * Socket adapter, based on old HTTP_Request code, - * Curl adapter, wraps around PHP's cURL extension, - * Mock adapter, to use for testing packages dependent on HTTP_Request2. -Supports POST requests with data and file uploads, basic and digest -authentication, cookies, managing cookies across requests, proxies, gzip and -deflate encodings, redirects, monitoring the request progress with Observers... - - - Alexey Borzov - avb - avb@php.net - yes - - 2014-01-16 - - 2.2.1 - 2.2.0 - - - stable - stable - - BSD 3-Clause License - - * Fixed a bogus timeout Exception in Socket adapter after waiting for - "100 Continue" response: the same one second timeout was used - for further socket operations if explicit 'timeout' parameter was not set. - Thanks to Andrea Brancatelli (abrancatelli as schema31 dot it) for the report. - * Bundled a separate LICENSE file (request #20175). Updated phrasing and links - to mention 3-Clause BSD license the package actually uses. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5.2.0 - - - 1.9.2 - - - Net_URL2 - pear.php.net - 2.0.0 - - - PEAR - pear.php.net - 1.9.2 - - - - - curl - - - fileinfo - - - zlib - - - openssl - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2014-01-12 - - 2.2.0 - 2.2.0 - - - stable - stable - - BSD License - -New features - * Socket adapter will send "Expect: 100-continue" header and wait for - "100 Continue" response by default before sending large request body - (request #19233). This can be disabled by setting an empty "Expect" - header, the same way as done with Curl adapter (see bug #15937) - * It is possible to specify a local IP address to bind to using 'local_ip' - configuration parameter (request #19515) - -Other changes and fixes - * An infinite loop was possible when using a stream wrapper instead of - a regular file with MultipartBody (bug #19934) - * Socket adapter will properly send chunked request body if - "Transfer-Encoding: chunked" header is set for the request (bug #20125) - * Updated Public Suffix List to the latest version and updated its download script - * Unit tests fixes - - - - 2012-04-08 - - 2.1.1 - 2.1.0 - - - stable - stable - - BSD License - -Fixes for SOCKS5 proxies support in Socket adapter - - - - 2012-04-07 - - 2.1.0 - 2.1.0 - - - stable - stable - - BSD License - -New features: - * Mock adapter can return responses based on request URL (request #19276) - * Support for SOCKS5 proxies, added 'proxy_type' configuration parameter - (request #19332) - * Proxy configuration may be given as an URL, e.g. - $request->setConfig('proxy', 'socks5://localhost:1080'); - -Other changes and fixes: - * Coding standards fixes (request #14990) - * Unit tests now run from SVN checkout and under PHPUnit 3.6.x - * Explicit dependency on PEAR (until PEAR_Exception is a separate package) - * Get rid of track_errors, use a more robust solution (bug #19337) - * Additional class_exists() check in setAdapter() (request #19344) - * Public suffix list updated to current version - - - - 2011-10-20 - - 2.0.0 - 2.0.0 - - - stable - stable - - BSD License - -2.0.0RC2 repackaged as stable and depending on stable Net_URL2. No code changes. - - - - 2011-10-01 - - 2.0.0RC2 - 2.0.0 - - - beta - stable - - BSD License - - * Added an accessor method for HTTP_Request2_Response::$phrases (request #18716) - * HTTP_Request2::send() throws an exception if URL is not provided - rather than dies with a fatal error (bug #18755) - * Public Suffix List updated to current version - - - - 2011-05-06 - - 2.0.0RC1 - 2.0.0 - - - beta - stable - - BSD License - -SSL options for Curl Adapter are always set, this prevents errors when -redirecting from HTTP to HTTPS (bug #18443) - - - - - 2.0.0beta3 - 2.0.0 - - - beta - beta - - 2011-04-03 - BSD License - - * Added getEffectiveUrl() method to Response object, it returns the URL - response was received from, possibly after redirects (request #18412) - * Curl Adapter didn't send body for PUT requests sometimes (bug #18421) - - - - - 2.0.0beta2 - 2.0.0 - - - beta - beta - - 2011-03-25 - BSD License - - * Unit tests can now be run under recent PHPUnit versions (3.5+) - * Public Suffix List updated to current version - * PHP warning produced by stream_socket_client() in Socket adapter is now - added to Exception message (bug #18331) - - - - - 2.0.0beta1 - 2.0.0 - - - beta - beta - - 2011-02-27 - BSD License - -Additions and changes: - * Implemented cookie jar that allows to store and pass cookies across HTTP - requests (see request #18225) - * Added several specialized subclasses of HTTP_Request2_Exception, they are - now thrown instead of the parent. Also added error codes and possibility - to get native error code (as returned by stream_socket_client() and - curl_errno()) (request #16762) - * An additional 'sentBody' event is now sent to Observers (request #16828) - * setBody() and addUpload() can now accept file pointers (request #16863) - -Bugfixes: - * Incorrect check in Socket Adapter prevented Keep-alive from working in - some cases (bug #17031) - - - - - 0.6.0 - 0.6.0 - - - alpha - alpha - - 2011-02-14 - BSD License - -Additions and changes: - * Added test suite that interacts with a webserver. Please refer to - tests/NetworkConfig.php.dist for instructions. - * Packaging changes: docs/ and tests/ contents are installed without - redundant subdirectories. - * Added a $replace parameter to HTTP_Request2::setHeader() that controls - whether new header value will overwrite previous one or be appended - to it (request #17507) - -Bugfixes: - * Fixed a typo in Curl Adapter that prevented 'strict_redirects' from working - * Curl Adapter will throw an exception if CURLOPT_FOLLOWLOCATION can not be - enabled due to PHP setup (bug #17450) - * Allow parameters in manually set Content-Type headers (bug #17460) - * Properly reset redirect limit if multiple requests are performed with the - same instance of Socket Adapter (bug #17826) - * Response::getBody() no longer tries to decode empty strings (bug #18169) - - - - - 0.5.2 - 0.5.0 - - - alpha - alpha - - 2010-04-21 - BSD License - - * magic_quotes_runtime PHP setting could be incorrectly enabled after - performing the request (bug #16440) - * Unit tests fixes (bugs #17079, #17106, #17326) - * Observer_Log now appends to the log file rather than rewrites it (thanks to - troelskn at gmail dot com for reporting) - - - - - 0.5.1 - 0.5.0 - - - alpha - alpha - - 2009-11-21 - BSD License - - * Content-Type request header is no longer removed for POST and PUT requests - with empty request body (request #16799). - * CURLOPT_NOBODY option is now set when doing HEAD requests with Curl adapter. - - - - - 0.5.0 - 0.5.0 - - - alpha - alpha - - 2009-11-18 - BSD License - - * Redirect support added, new configuration parameters 'follow_redirects', - 'max_redirects' and 'strict_redirects' available - - * Implemented workaround for PHP bug #47204, Curl Adapter can now handle - Digest authentication and redirects when doing POST requests, unfortunately - this requires loading the entire request body into memory. - * Config parameter 'use_brackets' is propagated to created instances of Net_URL2 - * Prevent memory leaks due to circular references (request #16646) - * Fixed a misleading error message when timing out due to default_socket_timeout - * HTTP_Request2::setBody() can now accept an instance of HTTP_Request2_MultipartBody - without trying to convert it to string - * Calling HTTP_Request2::setBody() now clears post parameters and uploads - - - - - 0.4.1 - 0.4.0 - - - alpha - alpha - - 2009-09-14 - BSD License - - * Decoding of gzipped responses failed if mbstring.func_overload was enabled - (bug #16555) - * Changed boundary generation in multipart bodies to work correctly with - rapidshare.com, added first usage example: file uploading to rapidshare.com - * Added forgotten optional dependency on OpenSSL PHP extension - - - - - 0.4.0 - 0.4.0 - - - alpha - alpha - - 2009-05-03 - BSD License - - * Added 'store_body' config parameter, if set to false it will prevent storing - the response body in Response object (request #15881) - * HTTP_Request2::setHeader() method now works as documented, setHeader('name') - will remove the 'name' header, while setHeader('name', '') will set 'name' - header to empty value (bug #15937) - * Custom 'Host' header will not be overwritten by generated one (bug #16146) - * When trying to reuse the connected socket in Socket adapter, make sure that - it is still connected (bug #16149) - - - - - 0.3.0 - 0.3.0 - - - alpha - alpha - - 2009-01-28 - BSD License - - API changes: - * Removed HTTP_Request2::getConfigValue() method - - Feature additions: - * Added digest authentication (RFC 2617) support to Socket adapter. Thanks - to Tom Snyder (tomsn at inetoffice dot com) who sent me a prototype - implementation for HTTP_Request a couple of years ago. - * Added HTTPS proxy support to Socket adapter, this works through CONNECT - request described in RFC 2817. - * Mock adapter can now throw an Exception instead of returning a response - if Exception object is added via its addResponse() method (request #15629) - - Other changes and fixes: - * Support RFC 3986 by not encoding '~' in POST body (request #15368) - * Prevent an error with particular versions of PHP and Curl (bug #15617) - * Regular expressions used in HTTP_Request2 are now class constants - (request #15630) - * Curl adapter now throws an exception in case of malformed (non-HTTP) - response rather than dies with a fatal error (bug #15716) - * Curl handle wasn't closed in Curl adapter in case of error (bug #15721) - * Curl adapter sent an extra 'sentHeaders' event and returned bogus - response status when server returned 100-Continue response (bug #15785) - - - - - 0.2.0 - 0.2.0 - - - alpha - alpha - - 2009-01-07 - BSD License - - API changes: - * HTTP_Request2::getConfigValue() is deprecated and will be removed in next - release. Use HTTP_Request2::getConfig(). - * Changed HTTP_Request2::setConfig() to accept a pair of parameter name and - parameter value in addition to array('parameter name' => 'value') - * Added HTTP_Request2::getConfig() method that can return a single - configuration parameter or the whole configuration array - -Other additions and changes: - * Added a debug Observer that can log request progress to a file or an - instance of PEAR::Log (thanks to David Jean Louis, request #15424) - * Added a new 'timeout' parameter that limits total number of seconds - a request can take (see requests #5735 and #8964) - * Added various SSL protocol options: 'ssl_verify_peer', 'ssl_verify_host', - 'ssl_cafile', 'ssl_capath', 'ssl_local_cert', 'ssl_passphrase'. Note that - 'ssl_verify_host' option behaves differently in Socket and Curl Adapters: - http://bugs.php.net/bug.php?id=47030 - -Fixes: - * Fixed 'data error' when processing response encoded by 'deflate' - encoding (bug #15305) - * Curl Adapter now passes full request headers in 'sentHeaders' event - - - - - 0.1.0 - 0.1.0 - - - alpha - alpha - - 2008-11-17 - BSD License - -Initial release. The features supported are mostly the same as those of -HTTP_Request, with the following additional feature requests implemented: - * cURL extension support (request #5463) - * It is now possible to monitor the file upload progress with Observers - (request #7630) - * Added 'sentHeaders' notification providing the request headers to the - Observers (request #7633) - * Added support for 'deflate' encoding (request #11246) - - - - \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/AllTests.php b/vendor/pear/http_request2/tests/AllTests.php deleted file mode 100644 index a311ca2f9..000000000 --- a/vendor/pear/http_request2/tests/AllTests.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'HTTP_Request2_AllTests::main'); -} - -require_once dirname(__FILE__) . '/Request2Test.php'; -require_once dirname(__FILE__) . '/ObserverTest.php'; -require_once dirname(__FILE__) . '/Request2/AllTests.php'; - -class HTTP_Request2_AllTests -{ - public static function main() - { - if (!function_exists('phpunit_autoload')) { - require_once 'PHPUnit/TextUI/TestRunner.php'; - } - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('HTTP_Request2 package'); - - $suite->addTest(Request2_AllTests::suite()); - $suite->addTestSuite('HTTP_Request2Test'); - $suite->addTestSuite('HTTP_Request2_ObserverTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'HTTP_Request2_AllTests::main') { - HTTP_Request2_AllTests::main(); -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/NetworkConfig.php.dist b/vendor/pear/http_request2/tests/NetworkConfig.php.dist deleted file mode 100644 index c50609bb7..000000000 --- a/vendor/pear/http_request2/tests/NetworkConfig.php.dist +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * This file contains configuration needed for running HTTP_Request2 tests - * that interact with the network. Do not edit this file, copy it to - * NetworkConfig.php and edit the copy instead. - */ - -/** - * Base URL for HTTP_Request2 Adapters tests - * - * To enable the tests that actually perform network interaction, you should - * copy the contents of _network directory to a directory under your web - * server's document root or create a symbolic link to _network directory - * there. Set this constant to point to the URL of that directory. - */ -define('HTTP_REQUEST2_TESTS_BASE_URL', null); - -/** - * URL that is protected by server digest authentication - * - * This is needed for testing of 100 Continue handling, we can't implement - * digest in PHP since it will kick in a bit later - */ -define('HTTP_REQUEST2_TESTS_DIGEST_URL', null); - -/**#@+ - * Proxy setup for Socket Adapter tests - * - * Set these constants to run additional tests for Socket Adapter using a HTTP - * proxy. If proxy host is not set then the tests will not be run. - */ -define('HTTP_REQUEST2_TESTS_PROXY_HOST', null); -define('HTTP_REQUEST2_TESTS_PROXY_PORT', 8080); -define('HTTP_REQUEST2_TESTS_PROXY_USER', ''); -define('HTTP_REQUEST2_TESTS_PROXY_PASSWORD', ''); -define('HTTP_REQUEST2_TESTS_PROXY_AUTH_SCHEME', 'basic'); -define('HTTP_REQUEST2_TESTS_PROXY_TYPE', 'http'); -/**#@-*/ -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/ObserverTest.php b/vendor/pear/http_request2/tests/ObserverTest.php deleted file mode 100644 index 9361e8f66..000000000 --- a/vendor/pear/http_request2/tests/ObserverTest.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Sets up includes */ -require_once dirname(__FILE__) . '/TestHelper.php'; - -/** - * Class representing a HTTP request - */ -require_once 'HTTP/Request2.php'; - -/** - * Mock observer - */ -class HTTP_Request2_MockObserver implements SplObserver -{ - public $calls = 0; - - public $event; - - public function update (SplSubject $subject) - { - $this->calls++; - $this->event = $subject->getLastEvent(); - } -} - -/** - * Unit test for subject-observer pattern implementation in HTTP_Request2 - */ -class HTTP_Request2_ObserverTest extends PHPUnit_Framework_TestCase -{ - public function testSetLastEvent() - { - $request = new HTTP_Request2(); - $observer = new HTTP_Request2_MockObserver(); - $request->attach($observer); - - $request->setLastEvent('foo', 'bar'); - $this->assertEquals(1, $observer->calls); - $this->assertEquals(array('name' => 'foo', 'data' => 'bar'), $observer->event); - - $request->setLastEvent('baz'); - $this->assertEquals(2, $observer->calls); - $this->assertEquals(array('name' => 'baz', 'data' => null), $observer->event); - } - - public function testAttachOnlyOnce() - { - $request = new HTTP_Request2(); - $observer = new HTTP_Request2_MockObserver(); - $observer2 = new HTTP_Request2_MockObserver(); - $request->attach($observer); - $request->attach($observer2); - $request->attach($observer); - - $request->setLastEvent('event', 'data'); - $this->assertEquals(1, $observer->calls); - $this->assertEquals(1, $observer2->calls); - } - - public function testDetach() - { - $request = new HTTP_Request2(); - $observer = new HTTP_Request2_MockObserver(); - $observer2 = new HTTP_Request2_MockObserver(); - - $request->attach($observer); - $request->detach($observer2); // should not be a error - $request->setLastEvent('first'); - - $request->detach($observer); - $request->setLastEvent('second'); - $this->assertEquals(1, $observer->calls); - $this->assertEquals(array('name' => 'first', 'data' => null), $observer->event); - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/AllTests.php b/vendor/pear/http_request2/tests/Request2/Adapter/AllTests.php deleted file mode 100644 index 491d9c7f9..000000000 --- a/vendor/pear/http_request2/tests/Request2/Adapter/AllTests.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Request2_Adapter_AllTests::main'); -} - -require_once dirname(__FILE__) . '/MockTest.php'; -require_once dirname(__FILE__) . '/SkippedTests.php'; -require_once dirname(__FILE__) . '/SocketTest.php'; -require_once dirname(__FILE__) . '/SocketProxyTest.php'; -require_once dirname(__FILE__) . '/CurlTest.php'; - -class Request2_Adapter_AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('HTTP_Request2 package - Request2 - Adapter'); - - $suite->addTestSuite('HTTP_Request2_Adapter_MockTest'); - if (defined('HTTP_REQUEST2_TESTS_BASE_URL') && HTTP_REQUEST2_TESTS_BASE_URL) { - $suite->addTestSuite('HTTP_Request2_Adapter_SocketTest'); - } else { - $suite->addTestSuite('HTTP_Request2_Adapter_Skip_SocketTest'); - } - if (defined('HTTP_REQUEST2_TESTS_PROXY_HOST') && HTTP_REQUEST2_TESTS_PROXY_HOST - && defined('HTTP_REQUEST2_TESTS_BASE_URL') && HTTP_REQUEST2_TESTS_BASE_URL - ) { - $suite->addTestSuite('HTTP_Request2_Adapter_SocketProxyTest'); - } else { - $suite->addTestSuite('HTTP_Request2_Adapter_Skip_SocketProxyTest'); - } - if (defined('HTTP_REQUEST2_TESTS_BASE_URL') && HTTP_REQUEST2_TESTS_BASE_URL - && extension_loaded('curl') - ) { - $suite->addTestSuite('HTTP_Request2_Adapter_CurlTest'); - } else { - $suite->addTestSuite('HTTP_Request2_Adapter_Skip_CurlTest'); - } - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Request2_Adapter_AllTests::main') { - Request2_Adapter_AllTests::main(); -} -?> diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/CommonNetworkTest.php b/vendor/pear/http_request2/tests/Request2/Adapter/CommonNetworkTest.php deleted file mode 100644 index 2e20a8156..000000000 --- a/vendor/pear/http_request2/tests/Request2/Adapter/CommonNetworkTest.php +++ /dev/null @@ -1,387 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Sets up includes */ -require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - -/** Class representing a HTTP request */ -require_once 'HTTP/Request2.php'; -/** Class for building multipart/form-data request body */ -require_once 'HTTP/Request2/MultipartBody.php'; - -class SlowpokeBody extends HTTP_Request2_MultipartBody -{ - protected $doSleep; - - public function rewind() - { - $this->doSleep = true; - parent::rewind(); - } - - public function read($length) - { - if ($this->doSleep) { - sleep(3); - $this->doSleep = false; - } - return parent::read($length); - } -} - -class HeaderObserver implements SplObserver -{ - public $headers; - - public function update(SplSubject $subject) - { - $event = $subject->getLastEvent(); - - // force a timeout when writing request body - if ('sentHeaders' == $event['name']) { - $this->headers = $event['data']; - } - } -} - -/** - * Tests for HTTP_Request2 package that require a working webserver - * - * The class contains some common tests that should be run for all Adapters, - * it is extended by their unit tests. - * - * You need to properly set up this test suite, refer to NetworkConfig.php.dist - */ -abstract class HTTP_Request2_Adapter_CommonNetworkTest extends PHPUnit_Framework_TestCase -{ - /** - * HTTP Request object - * @var HTTP_Request2 - */ - protected $request; - - /** - * Base URL for remote test files - * @var string - */ - protected $baseUrl; - - /** - * Configuration for HTTP Request object - * @var array - */ - protected $config = array(); - - protected function setUp() - { - if (!defined('HTTP_REQUEST2_TESTS_BASE_URL') || !HTTP_REQUEST2_TESTS_BASE_URL) { - $this->markTestSkipped('Base URL is not configured'); - - } else { - $this->baseUrl = rtrim(HTTP_REQUEST2_TESTS_BASE_URL, '/') . '/'; - $name = strtolower(preg_replace('/^test/i', '', $this->getName())) . '.php'; - - $this->request = new HTTP_Request2( - $this->baseUrl . $name, HTTP_Request2::METHOD_GET, $this->config - ); - } - } - - /** - * Tests possibility to send GET parameters - * - * NB: Currently there are problems with Net_URL2::setQueryVariables(), thus - * array structure is simple: http://pear.php.net/bugs/bug.php?id=18267 - */ - public function testGetParameters() - { - $data = array( - 'bar' => array( - 'key' => 'value' - ), - 'foo' => 'some value', - 'numbered' => array('first', 'second') - ); - - $this->request->getUrl()->setQueryVariables($data); - $response = $this->request->send(); - $this->assertEquals(serialize($data), $response->getBody()); - } - - public function testPostParameters() - { - $data = array( - 'bar' => array( - 'key' => 'some other value' - ), - 'baz' => array( - 'key1' => array( - 'key2' => 'yet another value' - ) - ), - 'foo' => 'some value', - 'indexed' => array('first', 'second') - ); - - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->addPostParameter($data); - - $response = $this->request->send(); - $this->assertEquals(serialize($data), $response->getBody()); - } - - public function testUploads() - { - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->addUpload('foo', dirname(dirname(dirname(__FILE__))) . '/_files/empty.gif', 'picture.gif', 'image/gif') - ->addUpload('bar', array( - array(dirname(dirname(dirname(__FILE__))) . '/_files/empty.gif', null, 'image/gif'), - array(dirname(dirname(dirname(__FILE__))) . '/_files/plaintext.txt', 'secret.txt', 'text/x-whatever') - )); - - $response = $this->request->send(); - $this->assertContains("foo picture.gif image/gif 43", $response->getBody()); - $this->assertContains("bar[0] empty.gif image/gif 43", $response->getBody()); - $this->assertContains("bar[1] secret.txt text/x-whatever 15", $response->getBody()); - } - - public function testRawPostData() - { - $data = 'Nothing to see here, move along'; - - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->setBody($data); - $response = $this->request->send(); - $this->assertEquals($data, $response->getBody()); - } - - public function testCookies() - { - $cookies = array( - 'CUSTOMER' => 'WILE_E_COYOTE', - 'PART_NUMBER' => 'ROCKET_LAUNCHER_0001' - ); - - foreach ($cookies as $k => $v) { - $this->request->addCookie($k, $v); - } - $response = $this->request->send(); - $this->assertEquals(serialize($cookies), $response->getBody()); - } - - public function testTimeout() - { - $this->request->setConfig('timeout', 2); - try { - $this->request->send(); - $this->fail('Expected HTTP_Request2_Exception was not thrown'); - } catch (HTTP_Request2_MessageException $e) { - $this->assertEquals(HTTP_Request2_Exception::TIMEOUT, $e->getCode()); - } - } - - public function testTimeoutInRequest() - { - $this->request->setConfig('timeout', 2) - ->setUrl($this->baseUrl . 'postparameters.php') - ->setBody(new SlowpokeBody(array('foo' => 'some value'), array())); - try { - $this->request->send(); - $this->fail('Expected HTTP_Request2_MessageException was not thrown'); - } catch (HTTP_Request2_MessageException $e) { - $this->assertEquals(HTTP_Request2_Exception::TIMEOUT, $e->getCode()); - } - } - - public function testBasicAuth() - { - $this->request->getUrl()->setQueryVariables(array( - 'user' => 'luser', - 'pass' => 'qwerty' - )); - $wrong = clone $this->request; - - $this->request->setAuth('luser', 'qwerty'); - $response = $this->request->send(); - $this->assertEquals(200, $response->getStatus()); - - $wrong->setAuth('luser', 'password'); - $response = $wrong->send(); - $this->assertEquals(401, $response->getStatus()); - } - - public function testDigestAuth() - { - $this->request->getUrl()->setQueryVariables(array( - 'user' => 'luser', - 'pass' => 'qwerty' - )); - $wrong = clone $this->request; - - $this->request->setAuth('luser', 'qwerty', HTTP_Request2::AUTH_DIGEST); - $response = $this->request->send(); - $this->assertEquals(200, $response->getStatus()); - - $wrong->setAuth('luser', 'password', HTTP_Request2::AUTH_DIGEST); - $response = $wrong->send(); - $this->assertEquals(401, $response->getStatus()); - } - - public function testRedirectsDefault() - { - $this->request->setUrl($this->baseUrl . 'redirects.php') - ->setConfig(array('follow_redirects' => true, 'strict_redirects' => false)) - ->setMethod(HTTP_Request2::METHOD_POST) - ->addPostParameter('foo', 'foo value'); - - $response = $this->request->send(); - $this->assertContains('Method=GET', $response->getBody()); - $this->assertNotContains('foo', $response->getBody()); - $this->assertEquals($this->baseUrl . 'redirects.php?redirects=0', $response->getEffectiveUrl()); - } - - public function testRedirectsStrict() - { - $this->request->setUrl($this->baseUrl . 'redirects.php') - ->setConfig(array('follow_redirects' => true, 'strict_redirects' => true)) - ->setMethod(HTTP_Request2::METHOD_POST) - ->addPostParameter('foo', 'foo value'); - - $response = $this->request->send(); - $this->assertContains('Method=POST', $response->getBody()); - $this->assertContains('foo', $response->getBody()); - } - - public function testRedirectsLimit() - { - $this->request->setUrl($this->baseUrl . 'redirects.php?redirects=4') - ->setConfig(array('follow_redirects' => true, 'max_redirects' => 2)); - - try { - $this->request->send(); - $this->fail('Expected HTTP_Request2_Exception was not thrown'); - } catch (HTTP_Request2_MessageException $e) { - $this->assertEquals(HTTP_Request2_Exception::TOO_MANY_REDIRECTS, $e->getCode()); - } - } - - public function testRedirectsRelative() - { - $this->request->setUrl($this->baseUrl . 'redirects.php?special=relative') - ->setConfig(array('follow_redirects' => true)); - - $response = $this->request->send(); - $this->assertContains('did relative', $response->getBody()); - } - - public function testRedirectsNonHTTP() - { - $this->request->setUrl($this->baseUrl . 'redirects.php?special=ftp') - ->setConfig(array('follow_redirects' => true)); - - try { - $this->request->send(); - $this->fail('Expected HTTP_Request2_Exception was not thrown'); - } catch (HTTP_Request2_MessageException $e) { - $this->assertEquals(HTTP_Request2_Exception::NON_HTTP_REDIRECT, $e->getCode()); - } - } - - public function testCookieJar() - { - $this->request->setUrl($this->baseUrl . 'setcookie.php?name=cookie_name&value=cookie_value'); - $req2 = clone $this->request; - - $this->request->setCookieJar()->send(); - $jar = $this->request->getCookieJar(); - $jar->store( - array('name' => 'foo', 'value' => 'bar'), - $this->request->getUrl() - ); - - $response = $req2->setUrl($this->baseUrl . 'cookies.php')->setCookieJar($jar)->send(); - $this->assertEquals( - serialize(array('cookie_name' => 'cookie_value', 'foo' => 'bar')), - $response->getBody() - ); - } - - public function testCookieJarAndRedirect() - { - $this->request->setUrl($this->baseUrl . 'redirects.php?special=cookie') - ->setConfig('follow_redirects', true) - ->setCookieJar(); - - $response = $this->request->send(); - $this->assertEquals(serialize(array('cookie_on_redirect' => 'success')), $response->getBody()); - } - - /** - * @link http://pear.php.net/bugs/bug.php?id=20125 - */ - public function testChunkedRequest() - { - $data = array( - 'long' => str_repeat('a', 1000), - 'very_long' => str_repeat('b', 2000) - ); - - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->setUrl($this->baseUrl . 'postparameters.php') - ->setConfig('buffer_size', 512) - ->setHeader('Transfer-Encoding', 'chunked') - ->addPostParameter($data); - - $response = $this->request->send(); - $this->assertEquals(serialize($data), $response->getBody()); - } - - /** - * @link http://pear.php.net/bugs/bug.php?id=19233 - * @link http://pear.php.net/bugs/bug.php?id=15937 - */ - public function testPreventExpectHeader() - { - $fp = fopen(dirname(dirname(dirname(__FILE__))) . '/_files/bug_15305', 'rb'); - $observer = new HeaderObserver(); - $body = new HTTP_Request2_MultipartBody( - array(), - array( - 'upload' => array( - 'fp' => $fp, - 'filename' => 'bug_15305', - 'type' => 'application/octet-stream', - 'size' => 16338 - ) - ) - ); - - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->setUrl($this->baseUrl . 'uploads.php') - ->setHeader('Expect', '') - ->setBody($body) - ->attach($observer); - - $response = $this->request->send(); - $this->assertNotContains('Expect:', $observer->headers); - $this->assertContains('upload bug_15305 application/octet-stream 16338', $response->getBody()); - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/CurlTest.php b/vendor/pear/http_request2/tests/Request2/Adapter/CurlTest.php deleted file mode 100644 index 28722e739..000000000 --- a/vendor/pear/http_request2/tests/Request2/Adapter/CurlTest.php +++ /dev/null @@ -1,120 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Tests for HTTP_Request2 package that require a working webserver */ -require_once dirname(__FILE__) . '/CommonNetworkTest.php'; - -/** Adapter for HTTP_Request2 wrapping around cURL extension */ - -/** - * Unit test for Curl Adapter of HTTP_Request2 - */ -class HTTP_Request2_Adapter_CurlTest extends HTTP_Request2_Adapter_CommonNetworkTest -{ - /** - * Configuration for HTTP Request object - * @var array - */ - protected $config = array( - 'adapter' => 'HTTP_Request2_Adapter_Curl' - ); - - /** - * Checks whether redirect support in cURL is disabled by safe_mode or open_basedir - * @return bool - */ - protected function isRedirectSupportDisabled() - { - return ini_get('safe_mode') || ini_get('open_basedir'); - } - - public function testRedirectsDefault() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testRedirectsDefault(); - } - } - - public function testRedirectsStrict() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testRedirectsStrict(); - } - } - - public function testRedirectsLimit() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testRedirectsLimit(); - } - } - - public function testRedirectsRelative() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testRedirectsRelative(); - } - } - - public function testRedirectsNonHTTP() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testRedirectsNonHTTP(); - } - } - - public function testCookieJarAndRedirect() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testCookieJarAndRedirect(); - } - } - - public function testBug17450() - { - if (!$this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Neither safe_mode nor open_basedir is enabled'); - } - - $this->request->setUrl($this->baseUrl . 'redirects.php') - ->setConfig(array('follow_redirects' => true)); - - try { - $this->request->send(); - $this->fail('Expected HTTP_Request2_Exception was not thrown'); - - } catch (HTTP_Request2_LogicException $e) { - $this->assertEquals(HTTP_Request2_Exception::MISCONFIGURATION, $e->getCode()); - } - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/MockTest.php b/vendor/pear/http_request2/tests/Request2/Adapter/MockTest.php deleted file mode 100644 index 3a27e0c25..000000000 --- a/vendor/pear/http_request2/tests/Request2/Adapter/MockTest.php +++ /dev/null @@ -1,157 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Sets up includes */ -require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - -/** - * Class representing a HTTP request - */ -require_once 'HTTP/Request2.php'; - -/** - * Mock adapter intended for testing - */ -require_once 'HTTP/Request2/Adapter/Mock.php'; - -/** - * Unit test for HTTP_Request2_Response class - */ -class HTTP_Request2_Adapter_MockTest extends PHPUnit_Framework_TestCase -{ - public function testDefaultResponse() - { - $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_GET, - array('adapter' => 'mock')); - $response = $req->send(); - $this->assertEquals(400, $response->getStatus()); - $this->assertEquals(0, count($response->getHeader())); - $this->assertEquals('', $response->getBody()); - } - - public function testResponseFromString() - { - $mock = new HTTP_Request2_Adapter_Mock(); - $mock->addResponse( - "HTTP/1.1 200 OK\r\n" . - "Content-Type: text/plain; charset=iso-8859-1\r\n" . - "\r\n" . - "This is a string" - ); - $req = new HTTP_Request2('http://www.example.com/'); - $req->setAdapter($mock); - - $response = $req->send(); - $this->assertEquals(200, $response->getStatus()); - $this->assertEquals(1, count($response->getHeader())); - $this->assertEquals('This is a string', $response->getBody()); - } - - public function testResponseFromFile() - { - $mock = new HTTP_Request2_Adapter_Mock(); - $mock->addResponse(fopen(dirname(dirname(dirname(__FILE__))) . - '/_files/response_headers', 'rb')); - - $req = new HTTP_Request2('http://www.example.com/'); - $req->setAdapter($mock); - - $response = $req->send(); - $this->assertEquals(200, $response->getStatus()); - $this->assertEquals(7, count($response->getHeader())); - $this->assertEquals('Nothing to see here, move along.', $response->getBody()); - } - - public function testResponsesQueue() - { - $mock = new HTTP_Request2_Adapter_Mock(); - $mock->addResponse( - "HTTP/1.1 301 Over there\r\n" . - "Location: http://www.example.com/newpage.html\r\n" . - "\r\n" . - "The document is over there" - ); - $mock->addResponse( - "HTTP/1.1 200 OK\r\n" . - "Content-Type: text/plain; charset=iso-8859-1\r\n" . - "\r\n" . - "This is a string" - ); - - $req = new HTTP_Request2('http://www.example.com/'); - $req->setAdapter($mock); - $this->assertEquals(301, $req->send()->getStatus()); - $this->assertEquals(200, $req->send()->getStatus()); - $this->assertEquals(400, $req->send()->getStatus()); - } - - /** - * Returning URL-specific responses - * @link http://pear.php.net/bugs/bug.php?id=19276 - */ - public function testRequest19276() - { - $mock = new HTTP_Request2_Adapter_Mock(); - $mock->addResponse( - "HTTP/1.1 200 OK\r\n" . - "Content-Type: text/plain; charset=iso-8859-1\r\n" . - "\r\n" . - "This is a response from example.org", - 'http://example.org/' - ); - $mock->addResponse( - "HTTP/1.1 200 OK\r\n" . - "Content-Type: text/plain; charset=iso-8859-1\r\n" . - "\r\n" . - "This is a response from example.com", - 'http://example.com/' - ); - - $req1 = new HTTP_Request2('http://localhost/'); - $req1->setAdapter($mock); - $this->assertEquals(400, $req1->send()->getStatus()); - - $req2 = new HTTP_Request2('http://example.com/'); - $req2->setAdapter($mock); - $this->assertContains('example.com', $req2->send()->getBody()); - - $req3 = new HTTP_Request2('http://example.org'); - $req3->setAdapter($mock); - $this->assertContains('example.org', $req3->send()->getBody()); - } - - public function testResponseException() - { - $mock = new HTTP_Request2_Adapter_Mock(); - $mock->addResponse( - new HTTP_Request2_Exception('Shit happens') - ); - $req = new HTTP_Request2('http://www.example.com/'); - $req->setAdapter($mock); - try { - $req->send(); - } catch (Exception $e) { - $this->assertEquals('Shit happens', $e->getMessage()); - return; - } - $this->fail('Expected HTTP_Request2_Exception was not thrown'); - } -} -?> diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/SkippedTests.php b/vendor/pear/http_request2/tests/Request2/Adapter/SkippedTests.php deleted file mode 100644 index a998f67dd..000000000 --- a/vendor/pear/http_request2/tests/Request2/Adapter/SkippedTests.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Sets up includes */ -require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - -/** - * Shows a skipped test if networked tests are not configured - */ -class HTTP_Request2_Adapter_Skip_SocketTest extends PHPUnit_Framework_TestCase -{ - public function testSocketAdapter() - { - $this->markTestSkipped('Socket Adapter tests need base URL configured.'); - } -} - -/** - * Shows a skipped test if proxy is not configured - */ -class HTTP_Request2_Adapter_Skip_SocketProxyTest extends PHPUnit_Framework_TestCase -{ - public function testSocketAdapterWithProxy() - { - $this->markTestSkipped('Socket Adapter proxy tests need base URL and proxy configured'); - } -} - -/** - * Shows a skipped test if networked tests are not configured or cURL extension is unavailable - */ -class HTTP_Request2_Adapter_Skip_CurlTest extends PHPUnit_Framework_TestCase -{ - public function testCurlAdapter() - { - $this->markTestSkipped('Curl Adapter tests need base URL configured and curl extension available'); - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/SocketProxyTest.php b/vendor/pear/http_request2/tests/Request2/Adapter/SocketProxyTest.php deleted file mode 100644 index 78c4d4f3a..000000000 --- a/vendor/pear/http_request2/tests/Request2/Adapter/SocketProxyTest.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Tests for HTTP_Request2 package that require a working webserver */ -require_once dirname(__FILE__) . '/CommonNetworkTest.php'; - -/** - * Unit test for Socket Adapter of HTTP_Request2 working through proxy - */ -class HTTP_Request2_Adapter_SocketProxyTest extends HTTP_Request2_Adapter_CommonNetworkTest -{ - /** - * Configuration for HTTP Request object - * @var array - */ - protected $config = array( - 'adapter' => 'HTTP_Request2_Adapter_Socket' - ); - - protected function setUp() - { - if (!defined('HTTP_REQUEST2_TESTS_PROXY_HOST') || !HTTP_REQUEST2_TESTS_PROXY_HOST) { - $this->markTestSkipped('Proxy is not configured'); - - } else { - $this->config += array( - 'proxy_host' => HTTP_REQUEST2_TESTS_PROXY_HOST, - 'proxy_port' => HTTP_REQUEST2_TESTS_PROXY_PORT, - 'proxy_user' => HTTP_REQUEST2_TESTS_PROXY_USER, - 'proxy_password' => HTTP_REQUEST2_TESTS_PROXY_PASSWORD, - 'proxy_auth_scheme' => HTTP_REQUEST2_TESTS_PROXY_AUTH_SCHEME, - 'proxy_type' => HTTP_REQUEST2_TESTS_PROXY_TYPE - ); - parent::setUp(); - } - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/Adapter/SocketTest.php b/vendor/pear/http_request2/tests/Request2/Adapter/SocketTest.php deleted file mode 100644 index 1400238ce..000000000 --- a/vendor/pear/http_request2/tests/Request2/Adapter/SocketTest.php +++ /dev/null @@ -1,159 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Tests for HTTP_Request2 package that require a working webserver */ -require_once dirname(__FILE__) . '/CommonNetworkTest.php'; - -/** Socket-based adapter for HTTP_Request2 */ -require_once 'HTTP/Request2/Adapter/Socket.php'; - -/** - * Unit test for Socket Adapter of HTTP_Request2 - */ -class HTTP_Request2_Adapter_SocketTest extends HTTP_Request2_Adapter_CommonNetworkTest -{ - /** - * Configuration for HTTP Request object - * @var array - */ - protected $config = array( - 'adapter' => 'HTTP_Request2_Adapter_Socket' - ); - - public function testBug17826() - { - $adapter = new HTTP_Request2_Adapter_Socket(); - - $request1 = new HTTP_Request2($this->baseUrl . 'redirects.php?redirects=2'); - $request1->setConfig(array('follow_redirects' => true, 'max_redirects' => 3)) - ->setAdapter($adapter) - ->send(); - - $request2 = new HTTP_Request2($this->baseUrl . 'redirects.php?redirects=2'); - $request2->setConfig(array('follow_redirects' => true, 'max_redirects' => 3)) - ->setAdapter($adapter) - ->send(); - } - - - /** - * Infinite loop with stream wrapper passed as upload - * - * Dunno how the original reporter managed to pass a file pointer - * that doesn't support fstat() to MultipartBody, maybe he didn't use - * addUpload(). So we don't use it, either. - * - * @link http://pear.php.net/bugs/bug.php?id=19934 - */ - public function testBug19934() - { - if (!in_array('http', stream_get_wrappers())) { - $this->markTestSkipped("This test requires an HTTP fopen wrapper enabled"); - } - - $fp = fopen($this->baseUrl . '/bug19934.php', 'rb'); - $body = new HTTP_Request2_MultipartBody( - array(), - array( - 'upload' => array( - 'fp' => $fp, - 'filename' => 'foo.txt', - 'type' => 'text/plain', - 'size' => 20000 - ) - ) - ); - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->setUrl($this->baseUrl . 'uploads.php') - ->setBody($body); - - set_error_handler(array($this, 'rewindWarningsHandler')); - $response = $this->request->send(); - restore_error_handler(); - - $this->assertContains("upload foo.txt text/plain 20000", $response->getBody()); - } - - public function rewindWarningsHandler($errno, $errstr) - { - if (($errno & E_WARNING) && false !== strpos($errstr, 'rewind')) { - return true; - } - return false; - } - - /** - * Do not send request body twice to URLs protected by digest auth - * - * @link http://pear.php.net/bugs/bug.php?id=19233 - */ - public function test100ContinueHandling() - { - if (!defined('HTTP_REQUEST2_TESTS_DIGEST_URL') || !HTTP_REQUEST2_TESTS_DIGEST_URL) { - $this->markTestSkipped('This test requires an URL protected by server digest auth'); - } - - $fp = fopen(dirname(dirname(dirname(__FILE__))) . '/_files/bug_15305', 'rb'); - $body = $this->getMock( - 'HTTP_Request2_MultipartBody', array('read'), array( - array(), - array( - 'upload' => array( - 'fp' => $fp, - 'filename' => 'bug_15305', - 'type' => 'application/octet-stream', - 'size' => 16338 - ) - ) - ) - ); - $body->expects($this->never())->method('read'); - - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->setUrl(HTTP_REQUEST2_TESTS_DIGEST_URL) - ->setBody($body); - - $this->assertEquals(401, $this->request->send()->getStatus()); - } - - public function test100ContinueTimeoutBug() - { - $fp = fopen(dirname(dirname(dirname(__FILE__))) . '/_files/bug_15305', 'rb'); - $body = new HTTP_Request2_MultipartBody( - array(), - array( - 'upload' => array( - 'fp' => $fp, - 'filename' => 'bug_15305', - 'type' => 'application/octet-stream', - 'size' => 16338 - ) - ) - ); - - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->setUrl($this->baseUrl . 'uploads.php?slowpoke') - ->setBody($body); - - $response = $this->request->send(); - $this->assertContains('upload bug_15305 application/octet-stream 16338', $response->getBody()); - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/AllTests.php b/vendor/pear/http_request2/tests/Request2/AllTests.php deleted file mode 100644 index 1b8bc6bb9..000000000 --- a/vendor/pear/http_request2/tests/Request2/AllTests.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'Request2_AllTests::main'); -} - -require_once dirname(__FILE__) . '/CookieJarTest.php'; -require_once dirname(__FILE__) . '/MultipartBodyTest.php'; -require_once dirname(__FILE__) . '/ResponseTest.php'; -require_once dirname(__FILE__) . '/Adapter/AllTests.php'; - -class Request2_AllTests -{ - public static function main() - { - if (!function_exists('phpunit_autoload')) { - require_once 'PHPUnit/TextUI/TestRunner.php'; - } - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('HTTP_Request2 package - Request2'); - - $suite->addTestSuite('HTTP_Request2_CookieJarTest'); - $suite->addTestSuite('HTTP_Request2_MultipartBodyTest'); - $suite->addTestSuite('HTTP_Request2_ResponseTest'); - $suite->addTest(Request2_Adapter_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Request2_AllTests::main') { - Request2_AllTests::main(); -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/CookieJarTest.php b/vendor/pear/http_request2/tests/Request2/CookieJarTest.php deleted file mode 100644 index 5f1de4290..000000000 --- a/vendor/pear/http_request2/tests/Request2/CookieJarTest.php +++ /dev/null @@ -1,370 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Sets up includes */ -require_once dirname(dirname(__FILE__)) . '/TestHelper.php'; -/** Stores cookies and passes them between HTTP requests */ -require_once 'HTTP/Request2/CookieJar.php'; - -/** - * Unit test for HTTP_Request2_CookieJar class - */ -class HTTP_Request2_CookieJarTest extends PHPUnit_Framework_TestCase -{ - /** - * Cookie jar instance being tested - * @var HTTP_Request2_CookieJar - */ - protected $jar; - - protected function setUp() - { - $this->jar = new HTTP_Request2_CookieJar(); - } - - /** - * Test that we can't store junk "cookies" in jar - * - * @dataProvider invalidCookieProvider - * @expectedException HTTP_Request2_LogicException - */ - public function testStoreInvalid($cookie) - { - $this->jar->store($cookie); - } - - /** - * - * @dataProvider noPSLDomainsProvider - */ - public function testDomainMatchNoPSL($requestHost, $cookieDomain, $expected) - { - $this->jar->usePublicSuffixList(false); - $this->assertEquals($expected, $this->jar->domainMatch($requestHost, $cookieDomain)); - } - - /** - * - * @dataProvider PSLDomainsProvider - */ - public function testDomainMatchPSL($requestHost, $cookieDomain, $expected) - { - $this->jar->usePublicSuffixList(true); - $this->assertEquals($expected, $this->jar->domainMatch($requestHost, $cookieDomain)); - } - - public function testConvertExpiresToISO8601() - { - $dt = new DateTime(); - $dt->setTimezone(new DateTimeZone('UTC')); - $dt->modify('+1 day'); - - $this->jar->store(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - 'expires' => $dt->format(DateTime::COOKIE), - 'secure' => false - )); - $cookies = $this->jar->getAll(); - $this->assertEquals($cookies[0]['expires'], $dt->format(DateTime::ISO8601)); - } - - public function testProblem2038() - { - $this->jar->store(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - 'expires' => 'Sun, 01 Jan 2040 03:04:05 GMT', - 'secure' => false - )); - $cookies = $this->jar->getAll(); - $this->assertEquals(array(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - 'expires' => '2040-01-01T03:04:05+0000', - 'secure' => false - )), $cookies); - } - - public function testStoreExpired() - { - $base = array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - 'secure' => false - ); - - $dt = new DateTime(); - $dt->setTimezone(new DateTimeZone('UTC')); - $dt->modify('-1 day'); - $yesterday = $dt->format(DateTime::COOKIE); - - $dt->modify('+2 days'); - $tomorrow = $dt->format(DateTime::COOKIE); - - $this->jar->store($base + array('expires' => $yesterday)); - $this->assertEquals(0, count($this->jar->getAll())); - - $this->jar->store($base + array('expires' => $tomorrow)); - $this->assertEquals(1, count($this->jar->getAll())); - $this->jar->store($base + array('expires' => $yesterday)); - $this->assertEquals(0, count($this->jar->getAll())); - } - - /** - * - * @dataProvider cookieAndSetterProvider - */ - public function testGetDomainAndPathFromSetter($cookie, $setter, $expected) - { - $this->jar->store($cookie, $setter); - $expected = array_merge($cookie, $expected); - $cookies = $this->jar->getAll(); - $this->assertEquals($expected, $cookies[0]); - } - - /** - * - * @dataProvider cookieMatchProvider - */ - public function testGetMatchingCookies($url, $expectedCount) - { - $cookies = array( - array('domain' => '.example.com', 'path' => '/', 'secure' => false), - array('domain' => '.example.com', 'path' => '/', 'secure' => true), - array('domain' => '.example.com', 'path' => '/path', 'secure' => false), - array('domain' => '.example.com', 'path' => '/other', 'secure' => false), - array('domain' => 'example.com', 'path' => '/', 'secure' => false), - array('domain' => 'www.example.com', 'path' => '/', 'secure' => false), - array('domain' => 'specific.example.com', 'path' => '/path', 'secure' => false), - array('domain' => 'nowww.example.com', 'path' => '/', 'secure' => false), - ); - - for ($i = 0; $i < count($cookies); $i++) { - $this->jar->store($cookies[$i] + array('expires' => null, 'name' => "cookie{$i}", 'value' => "cookie_{$i}_value")); - } - - $this->assertEquals($expectedCount, count($this->jar->getMatching(new Net_URL2($url)))); - } - - public function testLongestPathFirst() - { - $cookie = array( - 'name' => 'foo', - 'domain' => '.example.com', - ); - foreach (array('/', '/specific/path/', '/specific/') as $path) { - $this->jar->store($cookie + array('path' => $path, 'value' => str_replace('/', '_', $path))); - } - $this->assertEquals( - 'foo=_specific_path_; foo=_specific_; foo=_', - $this->jar->getMatching(new Net_URL2('http://example.com/specific/path/file.php'), true) - ); - } - - public function testSerializable() - { - $dt = new DateTime(); - $dt->setTimezone(new DateTimeZone('UTC')); - $dt->modify('+1 day'); - $cookie = array('domain' => '.example.com', 'path' => '/', 'secure' => false, 'value' => 'foo'); - - $this->jar->store($cookie + array('name' => 'session', 'expires' => null)); - $this->jar->store($cookie + array('name' => 'long', 'expires' => $dt->format(DateTime::COOKIE))); - - $newJar = unserialize(serialize($this->jar)); - $cookies = $newJar->getAll(); - $this->assertEquals(1, count($cookies)); - $this->assertEquals('long', $cookies[0]['name']); - - $this->jar->serializeSessionCookies(true); - $newJar = unserialize(serialize($this->jar)); - $this->assertEquals($this->jar->getAll(), $newJar->getAll()); - } - - public function testRemoveExpiredOnUnserialize() - { - $dt = new DateTime(); - $dt->setTimezone(new DateTimeZone('UTC')); - $dt->modify('+2 seconds'); - - $this->jar->store(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - 'expires' => $dt->format(DateTime::COOKIE), - )); - - $serialized = serialize($this->jar); - sleep(2); - $newJar = unserialize($serialized); - $this->assertEquals(array(), $newJar->getAll()); - } - - public static function invalidCookieProvider() - { - return array( - array(array()), - array(array('name' => 'foo')), - array(array( - 'name' => 'a name', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - )), - array(array( - 'name' => 'foo', - 'value' => 'a value', - 'domain' => '.example.com', - 'path' => '/', - )), - array(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => null, - )), - array(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => null, - 'path' => '/', - )), - array(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - 'expires' => 'invalid date', - )), - ); - } - - public static function noPSLdomainsProvider() - { - return array( - array('localhost', 'localhost', true), - array('www.example.com', 'www.example.com', true), - array('127.0.0.1', '127.0.0.1', true), - array('127.0.0.1', '.0.0.1', false), - array('www.example.com', '.example.com', true), - array('deep.within.example.com', '.example.com', true), - array('example.com', '.com', false), - array('anotherexample.com', 'example.com', false), - array('whatever.msk.ru', '.msk.ru', true), - array('whatever.co.uk', '.co.uk', true), - array('whatever.uk', '.whatever.uk', true), - array('whatever.tokyo.jp', '.whatever.tokyo.jp', true), - array('metro.tokyo.jp', '.metro.tokyo.jp', true), - array('foo.bar', '.foo.bar', true) - ); - } - - public static function PSLdomainsProvider() - { - return array( - array('localhost', 'localhost', true), - array('www.example.com', 'www.example.com', true), - array('127.0.0.1', '127.0.0.1', true), - array('127.0.0.1', '.0.0.1', false), - array('www.example.com', '.example.com', true), - array('deep.within.example.com', '.example.com', true), - array('example.com', '.com', false), - array('anotherexample.com', 'example.com', false), - array('whatever.msk.ru', '.msk.ru', false), - array('whatever.co.uk', '.co.uk', false), - array('whatever.uk', '.whatever.uk', false), - array('whatever.tr', '.whatever.tr', false), - array('nic.tr', '.nic.tr', true), - array('foo.bar', '.foo.bar', true) - ); - } - - public static function cookieAndSetterProvider() - { - return array( - array( - array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => null, - 'path' => null, - 'expires' => null, - 'secure' => false - ), - new Net_Url2('http://example.com/directory/file.php'), - array( - 'domain' => 'example.com', - 'path' => '/directory/' - ) - ), - array( - array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => null, - 'expires' => null, - 'secure' => false - ), - new Net_Url2('http://example.com/path/to/file.php'), - array( - 'path' => '/path/to/' - ) - ), - array( - array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => null, - 'path' => '/', - 'expires' => null, - 'secure' => false - ), - new Net_Url2('http://example.com/another/file.php'), - array( - 'domain' => 'example.com' - ) - ) - ); - } - - public static function cookieMatchProvider() - { - return array( - array('http://www.example.com/path/file.php', 4), - array('https://www.example.com/path/file.php', 5), - array('http://example.com/path/file.php', 3), - array('http://specific.example.com/path/file.php', 4), - array('http://specific.example.com/other/file.php', 3), - array('http://another.example.com/another', 2) - ); - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/MultipartBodyTest.php b/vendor/pear/http_request2/tests/Request2/MultipartBodyTest.php deleted file mode 100644 index 8543b9e56..000000000 --- a/vendor/pear/http_request2/tests/Request2/MultipartBodyTest.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Sets up includes */ -require_once dirname(dirname(__FILE__)) . '/TestHelper.php'; - -/** - * Class representing a HTTP request - */ -require_once 'HTTP/Request2.php'; - -/** - * Unit test for HTTP_Request2_MultipartBody class - */ -class HTTP_Request2_MultipartBodyTest extends PHPUnit_Framework_TestCase -{ - public function testUploadSimple() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $body = $req->addPostParameter('foo', 'I am a parameter') - ->addUpload('upload', dirname(dirname(__FILE__)) . '/_files/plaintext.txt') - ->getBody(); - - $this->assertTrue($body instanceof HTTP_Request2_MultipartBody); - $asString = $body->__toString(); - $boundary = $body->getBoundary(); - $this->assertEquals($body->getLength(), strlen($asString)); - $this->assertContains('This is a test.', $asString); - $this->assertContains('I am a parameter', $asString); - $this->assertRegexp("!--{$boundary}--\r\n$!", $asString); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testRequest16863() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $fp = fopen(dirname(dirname(__FILE__)) . '/_files/plaintext.txt', 'rb'); - $body = $req->addUpload('upload', $fp) - ->getBody(); - - $asString = $body->__toString(); - $this->assertContains('name="upload"; filename="anonymous.blob"', $asString); - $this->assertContains('This is a test.', $asString); - - $req->addUpload('bad_upload', fopen('php://input', 'rb')); - } - - public function testStreaming() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $body = $req->addPostParameter('foo', 'I am a parameter') - ->addUpload('upload', dirname(dirname(__FILE__)) . '/_files/plaintext.txt') - ->getBody(); - $asString = ''; - while ($part = $body->read(10)) { - $asString .= $part; - } - $this->assertEquals($body->getLength(), strlen($asString)); - $this->assertContains('This is a test.', $asString); - $this->assertContains('I am a parameter', $asString); - } - - public function testUploadArray() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $body = $req->addUpload('upload', array( - array(dirname(dirname(__FILE__)) . '/_files/plaintext.txt', 'bio.txt', 'text/plain'), - array(fopen(dirname(dirname(__FILE__)) . '/_files/empty.gif', 'rb'), 'photo.gif', 'image/gif') - )) - ->getBody(); - $asString = $body->__toString(); - $this->assertContains(file_get_contents(dirname(dirname(__FILE__)) . '/_files/empty.gif'), $asString); - $this->assertContains('name="upload[0]"; filename="bio.txt"', $asString); - $this->assertContains('name="upload[1]"; filename="photo.gif"', $asString); - - $body2 = $req->setConfig(array('use_brackets' => false))->getBody(); - $asString = $body2->__toString(); - $this->assertContains('name="upload"; filename="bio.txt"', $asString); - $this->assertContains('name="upload"; filename="photo.gif"', $asString); - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2/ResponseTest.php b/vendor/pear/http_request2/tests/Request2/ResponseTest.php deleted file mode 100644 index c757d7327..000000000 --- a/vendor/pear/http_request2/tests/Request2/ResponseTest.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Sets up includes */ -require_once dirname(dirname(__FILE__)) . '/TestHelper.php'; - -/** - * Class representing a HTTP response - */ -require_once 'HTTP/Request2/Response.php'; - -/** - * Unit test for HTTP_Request2_Response class - */ -class HTTP_Request2_ResponseTest extends PHPUnit_Framework_TestCase -{ - /** - * - * @expectedException HTTP_Request2_MessageException - */ - public function testParseStatusLine() - { - $response = new HTTP_Request2_Response('HTTP/1.1 200 OK'); - $this->assertEquals('1.1', $response->getVersion()); - $this->assertEquals(200, $response->getStatus()); - $this->assertEquals('OK', $response->getReasonPhrase()); - - $response2 = new HTTP_Request2_Response('HTTP/1.2 222 Nishtyak!'); - $this->assertEquals('1.2', $response2->getVersion()); - $this->assertEquals(222, $response2->getStatus()); - $this->assertEquals('Nishtyak!', $response2->getReasonPhrase()); - - $response3 = new HTTP_Request2_Response('Invalid status line'); - } - - public function testParseHeaders() - { - $response = $this->readResponseFromFile('response_headers'); - $this->assertEquals(7, count($response->getHeader())); - $this->assertEquals('PHP/6.2.2', $response->getHeader('X-POWERED-BY')); - $this->assertEquals('text/html; charset=windows-1251', $response->getHeader('cOnTeNt-TyPe')); - $this->assertEquals('accept-charset, user-agent', $response->getHeader('vary')); - } - - public function testParseCookies() - { - $response = $this->readResponseFromFile('response_cookies'); - $cookies = $response->getCookies(); - $this->assertEquals(4, count($cookies)); - $expected = array( - array('name' => 'foo', 'value' => 'bar', 'expires' => null, - 'domain' => null, 'path' => null, 'secure' => false), - array('name' => 'PHPSESSID', 'value' => '1234567890abcdef1234567890abcdef', - 'expires' => null, 'domain' => null, 'path' => '/', 'secure' => true), - array('name' => 'A', 'value' => 'B=C', 'expires' => null, - 'domain' => null, 'path' => null, 'secure' => false), - array('name' => 'baz', 'value' => '%20a%20value', 'expires' => 'Sun, 03 Jan 2010 03:04:05 GMT', - 'domain' => 'pear.php.net', 'path' => null, 'secure' => false), - ); - foreach ($cookies as $k => $cookie) { - $this->assertEquals($expected[$k], $cookie); - } - } - - /** - * - * @expectedException HTTP_Request2_MessageException - */ - public function testGzipEncoding() - { - $response = $this->readResponseFromFile('response_gzip'); - $this->assertEquals('0e964e9273c606c46afbd311b5ad4d77', md5($response->getBody())); - - $response = $this->readResponseFromFile('response_gzip_broken'); - $body = $response->getBody(); - } - - public function testDeflateEncoding() - { - $response = $this->readResponseFromFile('response_deflate'); - $this->assertEquals('0e964e9273c606c46afbd311b5ad4d77', md5($response->getBody())); - } - - public function testBug15305() - { - $response = $this->readResponseFromFile('bug_15305'); - $this->assertEquals('c8c5088fc8a7652afef380f086c010a6', md5($response->getBody())); - } - - public function testBug18169() - { - $response = $this->readResponseFromFile('bug_18169'); - $this->assertEquals('', $response->getBody()); - } - - protected function readResponseFromFile($filename) - { - $fp = fopen(dirname(dirname(__FILE__)) . '/_files/' . $filename, 'rb'); - $response = new HTTP_Request2_Response(fgets($fp)); - do { - $headerLine = fgets($fp); - $response->parseHeaderLine($headerLine); - } while ('' != trim($headerLine)); - - while (!feof($fp)) { - $response->appendBody(fread($fp, 1024)); - } - return $response; - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/Request2Test.php b/vendor/pear/http_request2/tests/Request2Test.php deleted file mode 100644 index 70516d647..000000000 --- a/vendor/pear/http_request2/tests/Request2Test.php +++ /dev/null @@ -1,391 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Sets up includes */ -require_once dirname(__FILE__) . '/TestHelper.php'; - -/** - * Class representing a HTTP request - */ -require_once 'HTTP/Request2.php'; - -/** - * Unit test for HTTP_Request2 class - */ -class HTTP_Request2Test extends PHPUnit_Framework_TestCase -{ - public function testConstructorSetsDefaults() - { - $url = new Net_URL2('http://www.example.com/foo'); - $req = new HTTP_Request2($url, HTTP_Request2::METHOD_POST, array('connect_timeout' => 666)); - - $this->assertSame($url, $req->getUrl()); - $this->assertEquals(HTTP_Request2::METHOD_POST, $req->getMethod()); - $this->assertEquals(666, $req->getConfig('connect_timeout')); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testSetUrl() - { - $urlString = 'http://www.example.com/foo/bar.php'; - $url = new Net_URL2($urlString); - - $req1 = new HTTP_Request2(); - $req1->setUrl($url); - $this->assertSame($url, $req1->getUrl()); - - $req2 = new HTTP_Request2(); - $req2->setUrl($urlString); - $this->assertInstanceOf('Net_URL2', $req2->getUrl()); - $this->assertEquals($urlString, $req2->getUrl()->getUrl()); - - $req3 = new HTTP_Request2(); - $req3->setUrl(array('This will cause an error')); - } - - public function testConvertUserinfoToAuth() - { - $req = new HTTP_Request2(); - $req->setUrl('http://foo:b%40r@www.example.com/'); - - $this->assertEquals('', (string)$req->getUrl()->getUserinfo()); - $this->assertEquals( - array('user' => 'foo', 'password' => 'b@r', 'scheme' => HTTP_Request2::AUTH_BASIC), - $req->getAuth() - ); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testSetMethod() - { - $req = new HTTP_Request2(); - $req->setMethod(HTTP_Request2::METHOD_PUT); - $this->assertEquals(HTTP_Request2::METHOD_PUT, $req->getMethod()); - - $req->setMethod('Invalid method'); - } - - public function testSetAndGetConfig() - { - $req = new HTTP_Request2(); - $this->assertArrayHasKey('connect_timeout', $req->getConfig()); - - $req->setConfig(array('connect_timeout' => 123)); - $this->assertEquals(123, $req->getConfig('connect_timeout')); - try { - $req->setConfig(array('foo' => 'unknown parameter')); - $this->fail('Expected HTTP_Request2_LogicException was not thrown'); - } catch (HTTP_Request2_LogicException $e) {} - - try { - $req->getConfig('bar'); - $this->fail('Expected HTTP_Request2_LogicException was not thrown'); - } catch (HTTP_Request2_LogicException $e) {} - } - - public function testSetProxyAsUrl() - { - $req = new HTTP_Request2(); - $req->setConfig('proxy', 'socks5://foo:bar%25baz@localhost:1080/'); - - $this->assertEquals('socks5', $req->getConfig('proxy_type')); - $this->assertEquals('localhost', $req->getConfig('proxy_host')); - $this->assertEquals(1080, $req->getConfig('proxy_port')); - $this->assertEquals('foo', $req->getConfig('proxy_user')); - $this->assertEquals('bar%baz', $req->getConfig('proxy_password')); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testHeaders() - { - $req = new HTTP_Request2(); - $autoHeaders = $req->getHeaders(); - - $req->setHeader('Foo', 'Bar'); - $req->setHeader('Foo-Bar: value'); - $req->setHeader(array('Another-Header' => 'another value', 'Yet-Another: other_value')); - $this->assertEquals( - array('foo-bar' => 'value', 'another-header' => 'another value', - 'yet-another' => 'other_value', 'foo' => 'Bar') + $autoHeaders, - $req->getHeaders() - ); - - $req->setHeader('FOO-BAR'); - $req->setHeader(array('aNOTHER-hEADER')); - $this->assertEquals( - array('yet-another' => 'other_value', 'foo' => 'Bar') + $autoHeaders, - $req->getHeaders() - ); - - $req->setHeader('Invalid header', 'value'); - } - - public function testBug15937() - { - $req = new HTTP_Request2(); - $autoHeaders = $req->getHeaders(); - - $req->setHeader('Expect: '); - $req->setHeader('Foo', ''); - $this->assertEquals( - array('expect' => '', 'foo' => '') + $autoHeaders, - $req->getHeaders() - ); - } - - public function testRequest17507() - { - $req = new HTTP_Request2(); - - $req->setHeader('accept-charset', 'iso-8859-1'); - $req->setHeader('accept-charset', array('windows-1251', 'utf-8'), false); - - $req->setHeader(array('accept' => 'text/html')); - $req->setHeader(array('accept' => 'image/gif'), null, false); - - $headers = $req->getHeaders(); - - $this->assertEquals('iso-8859-1, windows-1251, utf-8', $headers['accept-charset']); - $this->assertEquals('text/html, image/gif', $headers['accept']); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testCookies() - { - $req = new HTTP_Request2(); - $req->addCookie('name', 'value'); - $req->addCookie('foo', 'bar'); - $headers = $req->getHeaders(); - $this->assertEquals('name=value; foo=bar', $headers['cookie']); - - $req->addCookie('invalid cookie', 'value'); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testPlainBody() - { - $req = new HTTP_Request2(); - $req->setBody('A string'); - $this->assertEquals('A string', $req->getBody()); - - $req->setBody(dirname(__FILE__) . '/_files/plaintext.txt', true); - $headers = $req->getHeaders(); - $this->assertRegexp( - '!^(text/plain|application/octet-stream)!', - $headers['content-type'] - ); - $this->assertEquals('This is a test.', fread($req->getBody(), 1024)); - - $req->setBody('missing file', true); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testRequest16863() - { - $req = new HTTP_Request2(); - $req->setBody(fopen(dirname(__FILE__) . '/_files/plaintext.txt', 'rb')); - $headers = $req->getHeaders(); - $this->assertEquals('application/octet-stream', $headers['content-type']); - - $req->setBody(fopen('php://input', 'rb')); - } - - public function testUrlencodedBody() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $req->addPostParameter('foo', 'bar'); - $req->addPostParameter(array('baz' => 'quux')); - $req->addPostParameter('foobar', array('one', 'two')); - $this->assertEquals( - 'foo=bar&baz=quux&foobar%5B0%5D=one&foobar%5B1%5D=two', - $req->getBody() - ); - - $req->setConfig(array('use_brackets' => false)); - $this->assertEquals( - 'foo=bar&baz=quux&foobar=one&foobar=two', - $req->getBody() - ); - } - - public function testRequest15368() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $req->addPostParameter('foo', 'te~st'); - $this->assertContains('~', $req->getBody()); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - * @expectedExceptionMessage missing file - */ - public function testUpload() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $req->addUpload('upload', dirname(__FILE__) . '/_files/plaintext.txt'); - - $headers = $req->getHeaders(); - $this->assertEquals('multipart/form-data', $headers['content-type']); - - $req->addUpload('upload_2', 'missing file'); - } - - public function testPropagateUseBracketsToNetURL2() - { - $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_GET, - array('use_brackets' => false)); - $req->getUrl()->setQueryVariable('foo', array('bar', 'baz')); - $this->assertEquals('http://www.example.com/?foo=bar&foo=baz', $req->getUrl()->__toString()); - - $req->setConfig('use_brackets', true)->setUrl('http://php.example.com/'); - $req->getUrl()->setQueryVariable('foo', array('bar', 'baz')); - $this->assertEquals('http://php.example.com/?foo[0]=bar&foo[1]=baz', $req->getUrl()->__toString()); - } - - public function testSetBodyRemovesPostParameters() - { - $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_POST); - $req->addPostParameter('foo', 'bar'); - $req->setBody(''); - $this->assertEquals('', $req->getBody()); - } - - public function testPostParametersPrecedeSetBodyForPost() - { - $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_POST); - $req->setBody('Request body'); - $req->addPostParameter('foo', 'bar'); - - $this->assertEquals('foo=bar', $req->getBody()); - - $req->setMethod(HTTP_Request2::METHOD_PUT); - $this->assertEquals('Request body', $req->getBody()); - } - - public function testSetMultipartBody() - { - require_once 'HTTP/Request2/MultipartBody.php'; - - $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_POST); - $body = new HTTP_Request2_MultipartBody(array('foo' => 'bar'), array()); - $req->setBody($body); - $this->assertSame($body, $req->getBody()); - } - - public function testBug17460() - { - $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_POST); - $req->addPostParameter('foo', 'bar') - ->setHeader('content-type', 'application/x-www-form-urlencoded; charset=UTF-8'); - - $this->assertEquals('foo=bar', $req->getBody()); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testCookieJar() - { - $req = new HTTP_Request2(); - $this->assertNull($req->getCookieJar()); - - $req->setCookieJar(); - $jar = $req->getCookieJar(); - $this->assertInstanceOf('HTTP_Request2_CookieJar', $jar); - - $req2 = new HTTP_Request2(); - $req2->setCookieJar($jar); - $this->assertSame($jar, $req2->getCookieJar()); - - $req2->setCookieJar(null); - $this->assertNull($req2->getCookieJar()); - - $req2->setCookieJar('foo'); - } - - public function testAddCookieToJar() - { - $req = new HTTP_Request2(); - $req->setCookieJar(); - - try { - $req->addCookie('foo', 'bar'); - $this->fail('Expected HTTP_Request2_Exception was not thrown'); - } catch (HTTP_Request2_LogicException $e) { } - - $req->setUrl('http://example.com/path/file.php'); - $req->addCookie('foo', 'bar'); - - $this->assertArrayNotHasKey('cookie', $req->getHeaders()); - $cookies = $req->getCookieJar()->getAll(); - $this->assertEquals( - array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => 'example.com', - 'path' => '/path/', - 'expires' => null, - 'secure' => false - ), - $cookies[0] - ); - } - - /** - * @expectedException HTTP_Request2_LogicException - * @expectedExceptionMessage none - */ - public function testDisallowEmptyUrls() - { - $req = new HTTP_Request2(); - $req->send(); - } - - /** - * @expectedException HTTP_Request2_LogicException - * @expectedExceptionMessage '/foo/bar.php' - */ - public function testDisallowRelativeUrls() - { - $req = new HTTP_Request2('/foo/bar.php'); - $req->send(); - } -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/TestHelper.php b/vendor/pear/http_request2/tests/TestHelper.php deleted file mode 100644 index 512f6a9e6..000000000 --- a/vendor/pear/http_request2/tests/TestHelper.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** Include PHPUnit dependencies based on version */ -require_once 'PHPUnit/Runner/Version.php'; - -// If running from SVN checkout, update include_path -if ('@' . 'package_version@' == '@package_version@') { - $classPath = realpath(dirname(dirname(__FILE__))); - $includePath = array_map('realpath', explode(PATH_SEPARATOR, get_include_path())); - if (0 !== ($key = array_search($classPath, $includePath))) { - if (false !== $key) { - unset($includePath[$key]); - } - set_include_path($classPath . PATH_SEPARATOR . implode(PATH_SEPARATOR, $includePath)); - } -} - -$phpunitVersion = PHPUnit_Runner_Version::id(); -if ($phpunitVersion == '@' . 'package_version@' || !version_compare($phpunitVersion, '3.8', '<=')) { - echo "This version of PHPUnit is not supported."; - exit(1); -} elseif (version_compare($phpunitVersion, '3.5.0', '>=')) { - require_once 'PHPUnit/Autoload.php'; -} else { - require_once 'PHPUnit/Framework.php'; -} - -if (!defined('HTTP_REQUEST2_TESTS_BASE_URL') - && is_readable(dirname(__FILE__) . '/NetworkConfig.php') -) { - require_once dirname(__FILE__) . '/NetworkConfig.php'; -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_files/bug_15305 b/vendor/pear/http_request2/tests/_files/bug_15305 deleted file mode 100644 index bbf6c70006b8062fd656063ee9cbbff16edf7f04..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16338 zcmV;@KP|vWR8&weF)lG6GB7Y8PiqYdL}7GgIv`YaWh@{tHXur2ZXhx+FgYMHFgi6e zIx;dKM@>`>3R7irc4cxpAWdmwa&L2QW^^q{NmDO2E-(!WP&05kAVW|+B0^PDAVXDB zAVW`1Zy-iVP9RBEL~kHZPD~(ARZ<{ONLe6LK}~NUR7Fg0A`J>tIv`X_GEh`ZQbkTe zFfk1ZSS?U*cV%*AWGzB@Iv_z)P%chIR1FGPEkSc|Ze?^WR%LQ?X>V>iATlm6E;TSW zGB*thP;y~sZDBefZf`APVPj}z4GKeHV`yb9LvL<$a&K%pAZ~9hV_{=xWeo~LZ*FvD zZgeeFd2nSqAarGTbT4RhZEQOrV`yP=b7gcrb#!JeI1LIzZ*FvDZgee0Zewp`X>Mma zAY^4`Y+-a|4GKeVZggdCbS+F}ZfA68Iv_DMIXO5D3JnVFz3Fz_NVX>WDv`|2lvLsX zfHP%EmxE*}k7cVYIbC^NZm$3kBw>L75&$JDoxZCd;{LfW&}*Ha{R(~FY!2?-VE8_ z&TlSXFukm?>o|0*xKcTNSzv`p90#3B<^KM@d|xg5;ka`1y7Gyj=u|DaEJdWagjbqH1-5X5w_em;16^;o+X^TF65Kw1HWe`k-f>V8zs{VyZeiei zvGC&3%|jpx%u;vVLM%ST6{>l}tO*Yz5qD?tsMIR3${HYlE4}HJ2L3eQv17V_!Mxjs2o$YrlWG~$h;JIyE)f~p{M*;sfi4rhXm z{BX7UH1f)pKTS%9Y~T8g>CB}ckA8gmxx>%F7C?UpkSI2vg3VS))*sWaDE{~qKnrz= zxM9St#j(-9X>2^Eu?YX}@Xux1!4pPg_o{2hVY&KKssE(v*>;6mGY0 zeg5k8&EU-qyBNHJN|}UWlu7<1Na0n+u5WU;V&U1Hu2n|-&Vh_UhWrAHA?e+MGv#AZ z`Bb9ka{=}E6z^WY>c6_V&WYvASFeUwOPEB0ht?zo$AiFiER4SIRs2AB>a8szD|7;S zdI&9r!cOd>^b6-su8}6D2v$U8p)x2dHs?(5xa!i@FRZ| z??o)|!RtMtcqp2~o44wFajr}Ncf+D*YJf4UU04IJBP%GTC+0+jO8;5w8VpwE6LSfgXzi%DS z_U|Jm=@N+$qa`91&8!K%J@?}&cTf<3E=3dxZ!E&HB!i^qF>oe&J*%kOXNn%l$Vg58 zk>7Fkv~XPc%d_v^4Tim&-n+k4E+en|`3kJi`F!n+Jz-yXoxL;eMq;n{Q`Ff@h9$l= z%EYfxDdjLT1aDPzy&{cJuZ&mSMySZ1iI(x6*?0qQ?c|c%O zF5`BjXK-D|40-rav3URt3RL#B7N{=RO89f;UPaTyJk5Qfy*ti?}>W`Y)(G~`-Q*%{d3`vAL8$qLa{I|92B$a z@A&(Jqfo@N&|~J8qqC&l97f!>FGW1@?Kx6r(NcJEiPyaFku%!=j=wYCAJ9+NN+DCJ z^}wS!RHyhc?d`o}>!RptMP3{gt)g8VcbyZb96?#c`-O7hp!4p1anc>9-ABWdQt9Bc zB#(GD`SHhn-W|Ua=-uI=IKXRu@R_hPsmJuw{ru$!1jE%ARr1J^cSj@nr~C1QNJyA> z=!aUc4hX!>9FJK9lDgoJ*yx@8zS}L#JX?$$NJ8O2KC$rg*IQ6$=zW*YijTk|BCZX6RkwCEy1=`IcXG$Cv zK^&S2)1{)iENVl6$3haBm?mGKYkpD9Q0K%PF!gFq*mnkQ)3F+1g!Z$MP{SZ38bzlI zWdZiLeM?q^7Wn+7Xb~ARe##B&PuIC26~&K5UqN#ev;ZPA7V)VoBoh6H8$NysbG2VM zKkW?*2k*4^ME67zr(F}5^uXSq9zePvq|;1aIA6XHaaB>bOX4!w|5$X;Bvs)gee|OS z);&0)@%T(ny6@cgk{c|bW07?e2}a;cWo-_QtTIW+svW`$-$NbyA&OBEQ3lLf*OQM$ z82VwCu3Vqn-CI12LaQr|f-)Qp;n{#p(%}UcLRq89Yid#w3`&IBg9iEice;U*2?%!K z063j zg3($~@R0mOsHkD{;4@E5!_hs)QS6VNnLqw$gK!}JyV2p{`}YS2M=7EB7g2sL;#Ve6 zpZ5p&7Xioyv?VoUrA_g}!vhOKjUoWiv+W^<|MU*rxuC0oQDOjStkO4y155Ec&r=aN z9(+#qa#HELyvaaA1Ma#e{GXi~;b4d_2QVM|1$biRUi9EukeOv2!l5QW#jHp|5U3AL z@xsub4iYZQvqXZb^+lBe4d!nJtnsKgRt;D*Fk|onj3-pV0eWv@gh1p`%1??MpXqT& z6eHnwZ1O*%4wT*ki2#y-!LE#t2=)jK!39XhT1gv5PDvfC^u8_Il1w>*a!Oh*qluzj zrX~)Kxa27KLxL9J8|cB&>Z8@zt2eepsHtd+#CUi)DAdvkuHeAoH++!%x>>i*!`xg91tw$Dlb; z(1J`H%&RFb!Y?likDIRO4f-gr5phDOM6^rerRoz?Q4_@iyxPlgSSV(ACt{qaaez!1 z69vJ_X>$dMxRTN`UV-om?tG+C;B#ut%J&F@#Qxs)(1Vc@FYLjG-76eFtLz;nR^qs@ zAO)Z-1|#vQb2br7Kk)rqC-3d3fik7ln)}IS;gCp6u5$F3F8%Dk`|n5Z|8fAo*&)9f z9=05~41Y@k&TJz8@kgHMkz@UYzti7$3I%BFRiv)hAT^e*uAp&Dq?fQM7P^JvSlZ=8 zV=A;s^&XjEccpvHxfVXO{?cmHWUxb{ECsM|Bt8XBD55TClsq%bvH#{~ppe@?I3Rlt zS1GGu`-mUCTm@SefxXF!1c+L51%xaxI>_Ef!kUG!V1Ttiu`Vxv^c`=%fFWEIAjN@m zwxgJE@zGDwL8bEkJvbp@gJ)6v;KCW3GmjNTh2#InnNo1hW}&;EMsO;qgrV6KRHCMg zNXrD`;OMJi_;(0R>j@NKN*EqL`>s@a=Zx6JDX{;8k#@v~)=G2lAmGmEeW{c+?Z#-G zHUEtE8y^}wBhdIW5U77xC3p^jc@B!Zu?RiL&$={J7)1+7r=A=640`MGdO2~H&oZD^ zg`=eJ(Gwm8pO*4oPipf@_%O;8X~q*FGfj^)9s5B&Np*c|+ZPeLh}lgz6DRDERxhH9 zmyE_B(~|b>3{4&BB)=0T{y+5P;{Q5FV2_t%Weo zLufR3(}0UCA^0Je5MG58qisRL&x5erP2H#`AVT=t1md-@x6}{w_04M4s2WLq_@lD^ z+X-BkEfDVW5QIIdk)JOi1db;mTuIK^2q4G<7-=(66&3m}jN=vvw|NNg1`1!^ ze>qyRofS2~XZrR7vs@m*L4cEGJ9m<0{i){^*ke4m#@i&$leU}u9ymL*VE=RAbqa5; z+4C74>HIiZ$fvoJ0^V^!4+)V-OB z$mS14_7nGJJbYkUqsR-$6Bv4+!E<#ZoYZfiDDxmxa*{EQZg?gmgl(>Ip;4T z=!C-YDF))-|CjG7JX|LaD`|EK6pY?l_AMO0zP_G=sm$Efj-_0+z;!u3Y9xH5CDf+! zXv_7-bH-cYs2s&0G^9!LW?YWLdQ6fTw#g!lz~v9XFJCyNt@{A=fjd8f=01Kl^1~_P zQq6S>-{ZmR0FgMY4h}JY`b=V4IKFlrThLVBJ&OV%>{LQh;(wp@$rh9#jc9E|(rM2M z84S2BNH7SLe=o-&hq`=Coyt7}j%awbn-lmmgwg`dR`H-_7w{m&@_3wqee!Gto#q9S zezG|HGz&7ML|WdMKK!RU4qu{M(3E3CH0aG@zceB8V6@m1e2ByFXL*EFe-=j* z&mQn(S?(3JGJ$n{i@Q=>PwP`nhbP;;fxD4(olzXp{pOWMz=h-3OCDXS#>atXrS4F(NRt1A`T(FMR z6H8;VWXVGjL4~T2<>c(u>r1j%=eqJ5e(e^H-wJb4jMl@;7CS5ej4U5~hqffR4E&Wc zhXfwCyMRy8mCHTg4X?#I19~A#Jqc~OI^r?7KU1M6f%On7FG3}uT7*jBbRK9n#A^-U zln2oq{u*$XC@=??GlVJcL1-qUaJpm(!7_yUIP_-$vD&1%(lnXztmVA%ont{B+zS** zB4>pMfm*Ou>&G@vrUIL)S^mP9qSXY)$f3D`hH`9@ZYW6s-Dn9O=~ajTkWlS+Km>Z8 zYDKDtw>eL)kgUG>6$Eg8!$q@>w)rQOH0>6QI&1;AED=Sw;sH7n?NubO6sCd&3tb2lvI zz2rrX_j2ZT0}DFS`M6Khg=ctLnSipDlgOWimLT7s=IfgF&LiKv|7K`KRd-} z)rOi;J+0RaLu=`$+76v~P#Ni!9?0k0(0@d517SJbokxA#4JOd(Y1p?@|C+5zb8uR3 zwrbUOtu@3b>DAL_yJw)!r+R&`L-*j74;?t|u^-MI#d$CDuQzvg$r>+;Evf4KQ-l}H z^5Qxk?;6@I(Jl_*;ky~-7USif6S5n}x)pI$xse68@)SoLv?=ta7-_q^WkH#VFsolU z9;gRN`0@Y>f#eL&7N3+2NHca9!){$~=#8qx ztj|49g!HUdt=4r`I36Nq@x}?>SLlN8fjgIm_$$YYkh2AfE9?-&`o5hsb(${QMeAEh zC71iosq~y~w^yL-cdmj=hQo<_tRXm%Zk)Mqu#56OLHEpwJ?O682L=yA--5+MyeO|- zf1If?qD*Bdg81AIeHm1!L3=w9URR|)d!ufN*0IW)pW&uuMgOS5q1DucV2Btt#mn&! z$3f<$DN#5%7R-k%`~h$2IRX+{>@kA6&IqL*T#jwG1B3-P{oV<>h9uBk z@;8iw?*A*VvS>#|5Xmqqokl_W_BPkiCM5{~((Bz>Vd~#Ga~6geT*?Q3&@j#-C(ED% zG~I6PTavsq=V|xVkZq+>2wA{b@i-gH!trZ7W2f?A-zT!OoqZQ^5HV5tzpAr@R01jKy&F6gp4Jw+l3oS_QNNi?GgFp1X`QRQ-be_0 z7Q)$I9Jk!00Znx~qV+-McL_kE5f$wutQ2#~$ieBFCx#c|s3xL(Z|n+fA%9QxY?%*E z>MRCQOum~Jja)?YNlA&(y2*fG;>SJ-LnPL{QFN4-6Yf&RVuf#4^p0a!j8Bl zX%&o?>4t}Trq|v6Q2S&q><{58us0_ z;s#3A+Vw`WR>`+M@Le$lx7^XjGMC>+GbbkMT{`g0BR}RT-A2T&k1A8*D<#9mq6`B^ z3f9tRkSRD)iEzy#pb&Hm-$(d^daJ_r*jlhkOd;m?TLiRvT4~lGoPC7by+N-zY#NP5 zb6D3}wc(&%9kdrDwAxrJp>JsYEEtHr_2m_VU?#RE=7?INduJLkPw$Am?5NdBjhenaQ9g|1N)fZrtj zu*CV*70#!3$)iW?7MsF*E{+AN=och`mfCvb((=7IBZn`2tSH;uX4<}8 z+KfS^+U)h}jn-+i+0d%3W~+5-^lHuFS${A%)B6k3X6PWZEU2eT@7HiXxt3?D_}tk0b>xD?SW(dQAfN7SZ_ero&@a>G7dzIuJiUcFSgHL_Rh z>;#HFY9LmFPWWVMUKZRK!BE7G<%-Z$cEJit>C$Nu*@mIFjk*du#I|xIN6e;MsQo1{eTugK3aG%g-kC*!)p*;OwA;>rP!xoNP9ye z$y%hK(~NdoYtOOL5qq-2aSuKVR2Gzg2Zxvi-0^m|_)CkE=-v}C#DLb4QPWWcrXH?^ zsGKAic87>^22kw6OS~$!r7vixdK3Ir zuc$rBILU>5OO#9x4ao#KNkijBP&o-=FO=4=CTT*qHjjC?s?`h~{ig=?DP>u zfQhky9m%Df)K2OEBb8ji;P1R-cV25@&FL0)`5Ck+t7if3JPQR!6dj{(|Wu^aL(USGA~RHT4G~} z?z}6HB%R>Ts||VURdjt(MU%2yCdKk%i0lD5VkDZ`-oUjAb2nALY9i)}b_J!ap++P= z&A1EKj2>3t2PcSM_GS*B{h| zwT50t*uNO$uXTgq?XYMnTo8axz+%4I=S9v>&y6v5w$IdR)5>!Z!^u@Q%VGW32Iv1E z;wI*&nH=>s@_jp^urKiM!TA#>Vy0Bqi@A(HSzHP%TOZS3@a)SWK+x$BCvOU!(~d%vD(qP zCJ|C=)YQ%^NlJ>+3dc82fDj(4PlV8V;Guh^JrD~AB8J7JAmvfwMJ^PWVroQyhSscV z4M~h@OA_On-gg)+OoSgkHbGcMne?owOxf#43igeb#UEn|jkQ z>b1sj(ANjmMq|*^n~PI~YqjN>;|iwI#E84E`INoJctIeQoW5{8JK_)Qg-_Feq(iR+ z3B$jHd@909@9K|Io4ZqH0i_PxdkYuKvDwR4H_QZs-LhHm-Ch!WY!T44jaBP7dF*PPL8H7b(OxhAi89Fn5EzUL3W2_}!U zM4w2R_c`MFkh8ZKx-2KOq0yxkIqJ5OrFKfD6UGypKSZj(MoX`1h2wtuRH~m4u`bPv zT*u-by0nN3DD{Lj`u@GM;KpVHzg9WTmw({0@&F%(UL z7BTgn){+5?D!6nYCRJlpZQFY8Rl&|ON2KnSH##hlPpw5)Pb=GYI*{nf_HvsWB0M|; z*D?jPNNvHDmD|g38PbAb4CczV2h>}$?IEJsGP&=8R=wu-J-|80kU@-s3dzQVN88SJ zF2D($uUaJ9qBrZdPHf)@@tmUhEqfmpH9S{}l;}&CBp{cx{I4@^>l#$;Mn9XE2u?O& zaIEEnWLHZX<33fzZ%HC9HMp>951xkVk&I<-AhREx9}MlPjGuGJGl;dDh9A}{gQ0PD zc4`d!{aQ^oprd+yLp#%I+F5V-xPDh{v#T;w?IwP(i6QpcX&LIw4xRB#{It+*r|OOV z{()FC(d-c^}0XV=7;MOB+9dj}B=mzVF6dwlem+tF2KnmKMvm zmksz@o4E^pUkmuy7C(ILPo0msj>;VNB`slK0Qd8O{r4T~kL69!?i!xT zphGrh*Ll55#@l{;%|<^YL7SFxs@`!O9ih0aT~ z7ni3lrwHmWxz%K6wcN)ncb_CnxEJlt4@UFl;Nlv8&^;a=+D_!(d%`|6A27Pn;YhAv zUg-42#f_X(vLh94=4wM^YXbD4d563qJlb8}ofMsJsUKINCKu1p{z5muEC9o^O z%$0ueXQdvxNTW;yk_&^A008e4Qh$Ejyg0>-n9M~e!(D6U%A+q8W;;1ly;fzY_0MWr zyKfjhy?u73*Xu0=8r617Yo9Hxs$J_+J(piNU~=M)_K}*>r;?5nyOtXhD+9`@{9!4@ z-FlxmP=n-!pxv$^Lr?;@hcayBm?gXXO5@ z6QQ^7MrRDo@*isr=SvW&G|ZdX7W1lEp7{w596v81yE6Dg`6i zoXU-9#3x3qwbZ^ei^nk5at{f`w2)2^g20|6F^Y6Uxm*a6HIm0GW1hA8czLnTuQTVj z4~U>EBR=(K(Fgj@hoC>sZ}I~vbleKPKxjoT@W=TLB!Zh8afgmIdun#E7= z-7&Y}i%vNXL6N6mxuy4;kE z;}c7t0D5$P9=kVx`v@1yX0+jh)|BMb*@iwZ4Rm697SY*eA`(YE7%P`?cX|{q%8D_R8c_ z-eE6ko+y+%9HQ8n&RnPk({Ww4|6GI|T|XBgWeol^^1Z76k03?}u;1BkKmo8;uW6OL zpeq}wR+UHpeR{XcDKQ)H1+g2|X5siv`DMAosv4z)6}F*sE7aQY=lnMg12=)){uaFT zR#i=JOT6iBSG-AJ?uEEbA?q;6v^;_Mot}5t0CBe@IfF5VO=jn~j*9Fe_R@ zwPvji%@IJ$Giw${%(CpFw%7^M zXKGo(H)u3!bM5}m%a^e7ul~laT=W2}CD46vP zlJ6^*NwylbT7|&EeV*CT$r)HrMdh;Tv*%rK(T6K15J~H@*jBx;+TzqT=PklewJQH2 z9!gi>KUyu|Iy8Y(dJUcr{ZceT;DJ!vF4eV?JRKqBX!KuJp>3$LN)g^OdGItbj~kPF zv|+EVsc)z~5ywTU7>!ot8a{p;?Uninb)wQef{D_r(MWg^QR_;c{8;iwC0Y)cLy;D+ zX2qB)M)Ru_gHcfiEd7~h(XowRPsDn=+Nh|AGwPIjd-PFD#O%)I*;*DB;EaCNg;*S?npyC9WhGC2pW-qnLX-!}z3)YG+84&F=enh9Fu)w!Cu(yblWFs9d;!c`Kt3bo zW6E7_KiM{`RacswnIqC62nebCdNoh4b~>@)&)4y$>yJ0=t%>~rq_S?K%E>73x^xK5 z4~FJ=_6$zZ11`s*e;-e9!DIY@F>U;Tw4;?>bbrgJ4E5Ssy*KFB&U&@lsnI_j_M5%o zuzJ=qPIvHnd+hloy8=Ht++ufPLTiLzXW@+`X%ZJ+1AQ=uJr^E1!0Zyd8Afd2hu{gh z(@HL55g~23lBT0i?()?P#N?j;rz|Y{b4X6-0739oNv6utk_IY6TZgvlr;RR{UTZfH zR>8i~HV{Tk3Iz>XquhQjh;ztY2JH#M@Q-_evqLdjB~71eiLL(f9NBj1Z~ zbw8o*TOrt(dJdhYo`*9!nnqLCD5$iCzK7`PKmN!6 zPx+<*+~WKO3WOqdLK)qI7<_RpS;iV`HSE(!aqovPj5N~RgjH3z&K&&3It7zs;}43$ARYE*<}p| zI!RV$b@|1bKH4JYj#R|ft;%OTbtMK$sd_Rq_*c3Fs>|yxvQleSUtB*-P2b(L0;2{M zlOUm1VC0UW{B^!Q0&S-asC5_g1ZEO8SmH$Kp+A1v#oB2;>hCO);`#H3qEsDV;WK!XtNsQ$@ zdUD`0q8v*d*F5!QK^l98(U9REKQxo4FWmuDzV z-$aN*x=eBAVF;EmO>iPE{d<+Lj3@GNmv|zJs@E4Z&y>CfC(HY+Ogc`p5blJ9fm4-U zkkUx%K(Ofcu__3I(8IJ6MqE8m)hdKNu2fIx^A6OZ6jW-aVjC8g_7ve6btQf8%mPLo zCJJ6h+)`+O|XkR`jnkLT` zA@y>tx}K0JQ2hSi!?B?0wY0BSPh#3?wOp%xJxS~3cAF^LHk##HowyVa_UVV{sh*~M z*{H80XC=`D6{%|RcY|rqCgl?V>QAoRhPfL_Nx4*PYuI)P8t12Ol4=VxHa6?j2vBP6A+*eN~XLzY2 z>a?4RUauL|T7B&qb;-MwsMqILH-A$^r4_nWwX@^K52SlU=ew|Eri9zoZrO+?JfOO zd!@Frh)l^{Q+WC`cKAg#U)MG_Usp#gY!)4no~^KJqyL&Ts&8pj-EVA^_N6|lQN*(f z@cM%+lXu%2?FFPmpYYwF6(sZoiRu<4)LM&;NF-ZZ*K+GF%OHVe?&%XI^1)dfXYv=@ zShtw%E3EJngWvP$24})Y>59jwHHj!FHwIl9u zJ$6`hwSrnTL2ZkPuIEkkb#GWWej~RG{Wlmn;9>eSRg@&Sq~RH)JAs~tN-aTUi&3uU zjj}|A=3-eyXH>($6<%}1)xu@3>6o69B3K;4;yn$MdV8OUs@ z9Azn4==)Pj4A9?iP*sftxh)2`o;Sd2kh=oQlqk)Vx(2Ynw6K~y8Q1seNTM}LY+1KR zXLc5@_hTFB?n(40r%_gX%}uH*+d=h27as`S$ytu4x%f%71sDJN&1-o_EU5&a;j4ILH9*pZNa?{Mc_WDuSEV}oZ;Z5>CYj8M~uNss|u;hr2MQqijf zBf*n9-cunWwD_&~1yXr_MXMFT3-k>cJfDjy)yUzyJfM#aT8g_b6L$0E7mMh#fK`KOof1!T+9i ze*o7IR!GI5Yhw!3izk%Qkm9QnfOI6AA7;V-N`(o1qw?i!YN~l{$~vIW@Shiw`RWsg zN}a3Eo24L7{{yLn<7bNgX$~6%)1Ot;v*mZtQpTotaLlTk-qi}nwN393!`C;xgB#J< z^sZSrZf<(lDjc^qy=xba5pu47r-LnZZT_~RNS2JtX?|Pg(!i{vF1Y2N)XlxyPF-l0 zYys$_q>TcaX;}jQPts;@7fE~Of65l1JxbcC+$6dL{-31H-Y#)1#dcksUL>D+J@dW!2HnLSA?=n1BBuq}2qoo&>K2bSHP`p# zS8dA5W@{z!P@ZwOCOu0o(nNicj1ZQa71ig-sO>cCN=;3s)191}?O6ahD>?P;nM)R2 z*b(~)F79>W`1;JGT{)CVw<$Q19)%hD_Yv)VU7Imjq=)g6_JRn-~D_(X5Zy8qI zv`bdgsFiBEFiK|CYL!~H-EQ%^W?Po>o9Tk*}tyFDmc8NCV1DiG~Xw}-N*)WARQi1uLyz(~YW_Mau5h2BVHH7I^6(C7k0dWv$ zr{z#*6+<4u-#QyM`t53KFw|@H)|t^7v|5e9U~xkmnwe)_5L6_om$#skoY#hMh3v00 z?y-R%Aq-B|EZ&GuJYp|=Z#?noOm~c{O!k9+>9z1|_8TQTXeHFppN(l{EeWFtE6=wq zh01XZ4Hxlg?VoJ1!WPG84%~Q7C$6}xCw=QgB0()l$bXV-nPhY2rHiSaKxrKjUXo#)(j zMflK}-gahDCmMB#1MUQ^c8!O0h}d1!QQcodnMlzrN0=KB;#FkA&d_cQwQP&*&?BE@ zdbHC`vtfuf2M;w(vs7!;&}m)Q!40Oawd$g7*(w{ijipBQy4kjBqGXyiy;N(O;F_9f zmMmQ~o0e!aY`qFz(d$icsa-7@BMt0pS4SvTw@dA+R?{`xY*jf&F%6v9(0RMm99eCk zq!CML?Gm?|t&yl}x)>>x*0GeXx7rQ8Uai;LMy+t%gHcr{cDsB$gRzEkG?NAQUr#j1 zhyiXeN^QFZRyTDJt!>vzx>+;OZ=s2iIzW9J(OS)s-fU>CQd=8A4o8+&YU_qsYB%g= z+ithpqbd>2Fio(ZIV#mHP_)(@nI%4Im?g7W*9{HA31LJryHRh{8m3;-+f4!5js!-u zUMmTRHaF_}sMg#c!=g=5(z+%rsdAun3Tzf;fe-G?> z;@|IWMMRz~PdF?s`E2N|TC1&B?gCo;3ck_Wv`0%``BPDL3_!KZ01aH{@yNjY_Ax&9Xj)&$nA~*CV8Q~8=wm=K@JaTF0A6*id0vxFWhx++x!EN#!B{K`YE^5u zs`XZd)-hY$&F%NyAnSGGy@$V_FU$lXN zONIn6Q>Jk}aKjEflOLH4arhHP=n28+KQtbPY~(&lxS2ZZiSh)7`>#R}1dRTM&8<5S zY&2AKt_i9<8cObPvJZn(H{hX(Cex#RXku=z`d5Hr1j6|_ zFfZkHHSU(43x6E)VB%P%D@wqXr1g&C(p&m0W0)S9gYqcJWD%CU+S=R*L?!;oX1wL` zXgpwNN&LOF_R4D6#Na^dxenZI`p894g1^`*1@H(<*<)I*S3x9flcQZpx0e$8b(3pa zk=oe>j8qPrz9B%`Lu(X{uc+F&s`2w>Grl$aPwPQkfuRMWo?OY)Zayl73XL3It`%&Zsz*{#7GWKq%A+Z^gPi({ zCu~prd;0D{1cWZ>6}zFkJc#Y;Vr43lyTOE;BGnj|loa`o|M5TP5Vxv{>=Z2-uqxVZ zRu{XdiZM{hs7^_(NRG_nvM^{0yrDBKWQ$uVI5(QQ1^+LK-S7jtLtllb=zNH)(hPQ( z7Fgaqy1G4ev6OIbh(ub+s{J$ z`ORw~p1;PRpTX0dAB4C8*xEdf<5`tnjGz-7jW(og({u#X{Z$ByM+wrWk@tS`aPPRZ zLY2M}i(o#r=;RbFku}fYe()eCU;tG*VE_Byqq z?*_x(P4C@bD*L0EC$-)_Kltp7==T!DIln3^VJ@5S(e?}9t8DQxfyY0YDA(D{EfhaT zqmEu2nfM`%cSD*W>J;R3#P5_W{QZ&#QQ^zMQ3Ce{`1Jix=MLOd1zhT0sWHm(hz3=3 z&0I%;o~QnE`3%)4cb~+Tq*ZaR(PHzYDPoK=jb_>l7`#a0Z|T6?@@>&6To#J6(CrlX zNB*gDjuMJJi%_KUY#j0nyB5I)MF%v`wWiN0g5Q+wVWX>!;M8q zAmbsnUw_^|D5{xLjKhqg)FK@^>cWG916?i@C#Dla@$gwZ=}>!Dv}J)dP6+$L1LwN@ z0k7q3Vn@rVAlQ;inFmd=O2XmdXHsmPcb^@*lgz3V1NbFDY;+3OT@(nZ;8doFFR9Rd6&m6164G<84Vo!ULJC>yFY zf${(fo(ES|P+M9l*u&4-mqIc6X4r|-D=WD+J(fPPgl;=gK=hn&4=N6HVe+vBP8f|k zS}~xhTB$FJ6gPrHpg{0nG4Np$E{jItOHqVztHRyCsKS#Fm~Qn6HlGkd5Rwk4DHPd(*GnD9W;4>V=`?{X{dTEzlJXx6 zV1^>g2{PPrpVl$M$|R`hdJ_9tQB=9tE5N24c;mvC_r+WB&?&shsYsH8S3zoDQ-KG2 zkDN}yhuqAjslLaUOIp!GP)0qR8?4C;7D7FoTbl_6HhGwti=5Sw`*X^x3J2{IJ^WnR zr28-VU0ODw7U@Ge29Pwd8qqFQ>7x)l6Pm?DS*4~Eb9Qh9_hnxEV1D^ddtX)w)7THX z1+9>_{#x8!1OONRs}l?$!UOu2rr7spt}CH^w-1-~;`Hy)Vf|hCy{1* zjOBE|ED~Xlz6^12kieAZ(>d0SW8J!Q6@DM`ARr$29D`X09lcZ4ejmeWs+Zs`=|*W3 zcJwL;^X1Dy`KRlB0w$H&Pf;;tl|{&fVpfK-GN8C3>XO?;7yJ4_rSkqgyhG&z9@A+f z@0<~HV|H=Mns~F_W1KsQ2cH#wDVM6{uOD;EUzeEmV^nd()bXT|_+XSjf(x`&)N`o4 UqXW}M?@J}%n;dIGhvOgrAChp`>3R7irc4cxpAVF|pV`ybBGcGVLF(4>aZfSTa4GLH-P;Yl-a%E&KLU}qM zP)JZOHZC$QG7SntZ*FvDZgeeFd2nSqAarGTbT4phVQFqVAY*7@a&u*LJ!x}qEjTze zIV~{_3PW#hbY*UIEk$l)Z)9n1XF4EcWoB$)bY%?+LvLy2Ixyzc-Rn7vppbKBJUqHP$M zs+QDRO?gGuv~{N4n?+u!dPfhYF0D`7yjhW{-Cxr-UTK#3L!K#4;8SjCt?M#x8oi`- zZ8rH556wz7_(vm0QJ8IBJyK?>WzKu7r)o{5Zr*#)@b!SsF6 zU$CHNmxKeBCTmMwHEQ3hOSHjYrKVCfy3SQ$kD9waVX@nP%A_OscHjoBQl+K~jN3&= z2xw`cc?y8akgk@d#zdeJGMA>&)DdoMpBQy9k@SGoj-oXW&6a!GPY5>TJTEm5Mb(Xm z<#RBgYg2bwo-X>dF0`_&CKzW8J@RSzZM|9#D&2qrbNFFEvmVX2fRt*t=as3VK#(Ks z<7Ho;BRUb(daV`f&f4X*)5rf;DqR*=`Wz?Gy=h(g91X`Q(cNL#VWLlzGWDPK&}%UM z+*XxIAbP;F>-~>| zbCYoZ*X;t+xxz?qa_)XVV3pqPjmw?I!$=jKt@VOqT6tdh?|_8LRtLA+<}ffw|A_Wr zY>)E@tSt&Mr+sYImJ4?R`4?60%wr8`+}U3#i%hJ1hZXPJ3XLa4YgOZzwFP?DC+m`Q zi1%Q97T&Q{#a8XCo36ZS9d_q@O`nlB;Y^kGBn|r3=N=r|iZf>@TNz^yIcy8|r?|Tm zU*zSKszO)Wh1GwxIM)Xi&M|kpkBl)1&G{E1G-N8>TLEBJ=K(C+(M7s%4xl>Y-kku# z=%b`s6pqQ6@L8=fy32DSIAZ;$ZNS$3(^svVDLT8{LOyHshTZB53qLqtmtSRnR%VN1 z`p9ngzI%C*a=qSrF!fo{F12+e_s7V`C~94xCmWR)jt9?XxBu5w)2!cLUT(MBL4PC;Xf_pLN~s8@^yyQOAo$rc z3c?Y2L3mH%<17|Qf{js3aypwxJR)fvgsBvXPcj@%<|7&2_;fW-DU4E@$f-;bmPWqE zwVrOH=$fV?9**(f;7U$pdhbeJ%QQqax<;{pyjc*ZayXv^G0o=jEJ_41osmq2lR!?z z2$m#6)FdzgiDVp1CVP6`6MD=bO=uW}X)FOYiW9mLfE!#*L{}4xM=}<})F)4d`$uqu zc7QtZDVd3(h-Jb7vMYNRpyu3h=5_&9_joe3zH2JUYYIlU$T9NzV9Y@x`=N1~ z4adFU82s;amrT#TxiD4>FK`~PF-41yI4(|Xw?}&@6|4nzR>CAa{yyU7(()w+9=Ome zRXpsi@Mv~i=hWLWRk`nacT0d@ZE{7TgaMFxa%u2z;ehYee8Xi^>TXizOTXOT$oLH$ z=d;cl%yxetv08u4OgLR8&weF)lG6GB7Y8PfHC7L}7GgIv_@JX)GWxF(67|ZXhx+F)$!7GCD9b zIxsXKM@>`>3R7irc4cxpAVF|pV`ybBGcGVLF(4>aZfSTa4GLH-P;Yl-a%E&KLU}qM zP)JZOHZC$QG7SntZ*FvDZgeeFd2nSqAarGTbT4phVQFqVAY*7@a&u*LJ!x}qEjTze zIV~{_3PW#hbY*UIEk$l)Z)9n1XF4EfdTDSC3PW#hZe?S1X>V>iAY*KAb7c(*4GJHN z2nc&(dPe{QGhZ+_>yFXk@L}ZnzWNCEx{IMBvK_QJMJkE z1zSu>LM2FP)L-AXAoUez(nC`nVuo1kzV~+Vh?g(_`;R<&@=I5mX5$%6@=RA&`?S%u z%}qsb2d`dxL$lu1`Qxgg=h+K-{qEg6dP#3yz54mE@1{2GdO$%@kPEa_Ypd&xUJktP z02!FQSTA$i)cK-q7?`S-)LKn>Mb@-+rrn!GUa5LV52h}yPusj%k*VEZ(>7jdmia@T zDNf*1ZfULSGH)8aq;+jJ`4SJ!N;UXLBS%q~ZC*W6W~yb*d#tBwO{H$$d(iOpfX*>l zG7oz&nOP#TwGD)56hLxHwJ;lA>ecM}P?-jz`v?G_0_ix*v81DQjt4cfLgl5d2Oc-` z%~K#Kcp}9f2uLnlfcsytpk|kZ1C}OhOIXZs!C5HRbh{syFOvD+keWW zBlvdU2CY)1rVEVQMMnr|X`y)vfXa}rmZru;pb|2drqR?9Zfu_zbup3jfYpwoH4n{} zd)iM3Hsm}nH4jDAjfdrPFraHwcUhh;`m`>zvaBW;XAM2_Y4~luS`RASfC6*)VL-DU z&9{J*YPaW=siHuTBkbd4U!Nm75!8CE73 zVc21!Pn0tCpZ3seF#g&ISKEcvf3-N*2NljSce{^_F$vB27a}xdD&1QFU{>b= zEZfmVx^E7kI^*7*0K({_q*@e?$(it3tueaGb0Rom{ikif*8S60t(z%2yWB!PYxIWQ z>I(}$IA51vWq(#?i(~r8Zuh=>d69Cx-g_|hSK{}QRCDCvp0XB*gx)OjJTunq* z6O2bP7Q@shPlo$PaD;Y%I`Ju)iJ{~N@lk+R5a0Wp7)cZH`y4@7q){*pZa~v}{%v`< zEyH;%97br8%&(GErt?(LO%#n1&g>;3zLi6f{6do`anj8b;iEI<^oiitjlo%iucU)7@C$eazZAu>y$TB@k_x zo`#_wG)(D8l0tDakvAe73SNyk%biTb3onRe!U3`?dl#VQ+;Qf10af>SGPS;ID#>dK zMz_c@^7>%RK_dI1aheUsz2F%9?{t?;&%U`ZRtqn19IQszs)+~3If4IJmQ&Kk^ie;=`0f6YujAUnq&oQV_sf$I~A>M^grW=^W{P80o& S;6Y|eWcmj?o~>Y#3;+OD2L>Ae diff --git a/vendor/pear/http_request2/tests/_files/response_gzip_broken b/vendor/pear/http_request2/tests/_files/response_gzip_broken deleted file mode 100644 index 0df0d1522f8a377ac905b20db95eb29dc1428493..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 221 zcmYL?%}N6?6h;efN+8eRT~;ueWJaY%T=?6flnywGJBjI~4V0T9bJ1yi1fR$Eb8zGK zJBRblo2D+Twon=a%SS10J)?vB9FM_Rcbtr`thu`Dz*ZY1pI;h@^)!g&w=VkE=MxZ~{ diff --git a/vendor/pear/http_request2/tests/_files/response_headers b/vendor/pear/http_request2/tests/_files/response_headers deleted file mode 100644 index f60787bd5..000000000 --- a/vendor/pear/http_request2/tests/_files/response_headers +++ /dev/null @@ -1,12 +0,0 @@ -HTTP/1.1 200 OK -Date: Fri, 01 Jan 2010 02:03:04 GMT -Vary: accept-charset -Server: Apache/3.0.1 (Unix) -X-Powered-By: PHP/6.2.2 -Vary: user-agent -Content-Type: text/html; - charset=windows-1251 -Content-Length: 32 -Connection: close - -Nothing to see here, move along. \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/basicauth.php b/vendor/pear/http_request2/tests/_network/basicauth.php deleted file mode 100644 index 740df638c..000000000 --- a/vendor/pear/http_request2/tests/_network/basicauth.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -$user = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : null; -$pass = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null; -$wantedUser = isset($_GET['user']) ? $_GET['user'] : null; -$wantedPass = isset($_GET['pass']) ? $_GET['pass'] : null; - -if (!$user || !$pass || $user != $wantedUser || $pass != $wantedPass) { - header('WWW-Authenticate: Basic realm="HTTP_Request2 tests"', true, 401); - echo "Login required"; -} else { - echo "Username={$user};Password={$pass}"; -} - -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/bug19934.php b/vendor/pear/http_request2/tests/_network/bug19934.php deleted file mode 100644 index 059387107..000000000 --- a/vendor/pear/http_request2/tests/_network/bug19934.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -for ($i = 0; $i < 20; $i++) { - for ($j = 0; $j < 10; $j++) { - echo str_repeat((string)$j, 98) . "\r\n"; - } - flush(); - usleep(50000); -} \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/cookies.php b/vendor/pear/http_request2/tests/_network/cookies.php deleted file mode 100644 index 821b1b19f..000000000 --- a/vendor/pear/http_request2/tests/_network/cookies.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -ksort($_COOKIE); -echo serialize($_COOKIE); - -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/digestauth.php b/vendor/pear/http_request2/tests/_network/digestauth.php deleted file mode 100644 index 30c4e0d81..000000000 --- a/vendor/pear/http_request2/tests/_network/digestauth.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -/** - * Mostly borrowed from PHP manual and Socket Adapter implementation - * - * @link http://php.net/manual/en/features.http-auth.php - */ - -/** - * Parses the Digest auth header - * - * @param string $txt - */ -function http_digest_parse($txt) -{ - $token = '[^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\[\]?={}\s]+'; - $quoted = '"(?:\\\\.|[^\\\\"])*"'; - - // protect against missing data - $needed_parts = array_flip(array('nonce', 'nc', 'cnonce', 'qop', 'username', 'uri', 'response')); - $data = array(); - - preg_match_all("!({$token})\\s*=\\s*({$token}|{$quoted})!", $txt, $matches); - for ($i = 0; $i < count($matches[0]); $i++) { - // ignore unneeded parameters - if (isset($needed_parts[$matches[1][$i]])) { - unset($needed_parts[$matches[1][$i]]); - if ('"' == substr($matches[2][$i], 0, 1)) { - $data[$matches[1][$i]] = substr($matches[2][$i], 1, -1); - } else { - $data[$matches[1][$i]] = $matches[2][$i]; - } - } - } - - return !empty($needed_parts) ? false : $data; -} - -$realm = 'HTTP_Request2 tests'; -$wantedUser = isset($_GET['user']) ? $_GET['user'] : null; -$wantedPass = isset($_GET['pass']) ? $_GET['pass'] : null; -$validAuth = false; - -if (!empty($_SERVER['PHP_AUTH_DIGEST']) - && ($data = http_digest_parse($_SERVER['PHP_AUTH_DIGEST'])) - && $wantedUser == $data['username'] -) { - // generate the valid response - $a1 = md5($data['username'] . ':' . $realm . ':' . $wantedPass); - $a2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']); - $response = md5($a1. ':' . $data['nonce'] . ':' . $data['nc'] . ':' - . $data['cnonce'] . ':' . $data['qop'] . ':' . $a2); - - // check valid response against existing one - $validAuth = ($data['response'] == $response); -} - -if (!$validAuth || empty($_SERVER['PHP_AUTH_DIGEST'])) { - header('WWW-Authenticate: Digest realm="' . $realm . - '",qop="auth",nonce="' . uniqid() . '"', true, 401); - echo "Login required"; -} else { - echo "Username={$user}"; -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/getparameters.php b/vendor/pear/http_request2/tests/_network/getparameters.php deleted file mode 100644 index 7c92f7036..000000000 --- a/vendor/pear/http_request2/tests/_network/getparameters.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -ksort($_GET); -echo serialize($_GET); - -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/postparameters.php b/vendor/pear/http_request2/tests/_network/postparameters.php deleted file mode 100644 index ce67cbc4c..000000000 --- a/vendor/pear/http_request2/tests/_network/postparameters.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -ksort($_POST); -echo serialize($_POST); - -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/rawpostdata.php b/vendor/pear/http_request2/tests/_network/rawpostdata.php deleted file mode 100644 index 8a39c2f57..000000000 --- a/vendor/pear/http_request2/tests/_network/rawpostdata.php +++ /dev/null @@ -1,22 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -readfile('php://input'); -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/redirects.php b/vendor/pear/http_request2/tests/_network/redirects.php deleted file mode 100644 index 4af8c0841..000000000 --- a/vendor/pear/http_request2/tests/_network/redirects.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -$redirects = isset($_GET['redirects'])? $_GET['redirects']: 1; -$https = !empty($_SERVER['HTTPS']) && ('off' != strtolower($_SERVER['HTTPS'])); -$special = isset($_GET['special'])? $_GET['special']: null; - -if ('ftp' == $special) { - header('Location: ftp://localhost/pub/exploit.exe', true, 301); - -} elseif ('relative' == $special) { - header('Location: ./getparameters.php?msg=did%20relative%20redirect', true, 302); - -} elseif ('cookie' == $special) { - setcookie('cookie_on_redirect', 'success'); - header('Location: ./cookies.php', true, 302); - -} elseif ($redirects > 0) { - $url = ($https? 'https': 'http') . '://' . $_SERVER['SERVER_NAME'] - . (($https && 443 == $_SERVER['SERVER_PORT'] || !$https && 80 == $_SERVER['SERVER_PORT']) - ? '' : ':' . $_SERVER['SERVER_PORT']) - . $_SERVER['PHP_SELF'] . '?redirects=' . (--$redirects); - header('Location: ' . $url, true, 302); - -} else { - echo "Method=" . $_SERVER['REQUEST_METHOD'] . ';'; - var_dump($_POST); - var_dump($_GET); -} -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/setcookie.php b/vendor/pear/http_request2/tests/_network/setcookie.php deleted file mode 100644 index 0af79dfb6..000000000 --- a/vendor/pear/http_request2/tests/_network/setcookie.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -$name = empty($_GET['name'])? 'foo': $_GET['name']; -$value = empty($_GET['value'])? 'bar': $_GET['value']; - -setcookie($name, $value); - -echo "Cookie set!"; -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/timeout.php b/vendor/pear/http_request2/tests/_network/timeout.php deleted file mode 100644 index 03bba7415..000000000 --- a/vendor/pear/http_request2/tests/_network/timeout.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -sleep(5); - -?> \ No newline at end of file diff --git a/vendor/pear/http_request2/tests/_network/uploads.php b/vendor/pear/http_request2/tests/_network/uploads.php deleted file mode 100644 index 28c0f299c..000000000 --- a/vendor/pear/http_request2/tests/_network/uploads.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright 2008-2014 Alexey Borzov - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @link http://pear.php.net/package/HTTP_Request2 - */ - -if (isset($_GET['slowpoke'])) { - sleep(3); -} - -if (!empty($_FILES)) { - foreach ($_FILES as $name => $file) { - if (is_array($file['name'])) { - foreach($file['name'] as $k => $v) { - echo "{$name}[{$k}] {$v} {$file['type'][$k]} {$file['size'][$k]}\n"; - } - } else { - echo "{$name} {$file['name']} {$file['type']} {$file['size']}\n"; - } - } -} -?> \ No newline at end of file diff --git a/vendor/pear/net_url2/.gitignore b/vendor/pear/net_url2/.gitignore deleted file mode 100644 index 0e7f38ac3..000000000 --- a/vendor/pear/net_url2/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -# pear related -/Net_URL2-*.tgz - -# composer related -vendor/ -/composer.lock -/composer.phar diff --git a/vendor/pear/net_url2/.scrutinizer.yml b/vendor/pear/net_url2/.scrutinizer.yml deleted file mode 100644 index bfdb37388..000000000 --- a/vendor/pear/net_url2/.scrutinizer.yml +++ /dev/null @@ -1,38 +0,0 @@ -filter: - excluded_paths: - - 'docs/*' -tools: - php_code_coverage: - enabled: true - test_command: phpunit - php_cpd: - excluded_dirs: - - tests - filter: - excluded_paths: [] - php_pdepend: - excluded_dirs: - - tests - php_hhvm: - filter: - excluded_paths: [] - php_mess_detector: - filter: - excluded_paths: [] - php_analyzer: - enabled: true - filter: - excluded_paths: ['docs/*'] - php_code_sniffer: - enabled: true - filter: - excluded_paths: ['docs/*'] - config: - tab_width: 4 - encoding: utf8 - ruleset: ~ - standard: PEAR - php_loc: - excluded_dirs: - - tests - - docs diff --git a/vendor/pear/net_url2/.travis.yml b/vendor/pear/net_url2/.travis.yml deleted file mode 100644 index a3e7bdc49..000000000 --- a/vendor/pear/net_url2/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: php - -php: - - 5.2 - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - hhvm - - hhvm-nightly - -matrix: - allow_failures: - - php: hhvm-nightly - -script: phpunit --coverage-text tests/Net diff --git a/vendor/pear/net_url2/Net/URL2.php b/vendor/pear/net_url2/Net/URL2.php deleted file mode 100755 index dba48ce04..000000000 --- a/vendor/pear/net_url2/Net/URL2.php +++ /dev/null @@ -1,1219 +0,0 @@ - - * @copyright 2007-2009 Peytz & Co. A/S - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @version CVS: $Id$ - * @link https://tools.ietf.org/html/rfc3986 - */ - -/** - * Represents a URL as per RFC 3986. - * - * @category Networking - * @package Net_URL2 - * @author Christian Schmidt - * @copyright 2007-2009 Peytz & Co. A/S - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @version Release: @package_version@ - * @link https://pear.php.net/package/Net_URL2 - */ -class Net_URL2 -{ - /** - * Do strict parsing in resolve() (see RFC 3986, section 5.2.2). Default - * is true. - */ - const OPTION_STRICT = 'strict'; - - /** - * Represent arrays in query using PHP's [] notation. Default is true. - */ - const OPTION_USE_BRACKETS = 'use_brackets'; - - /** - * Drop zero-based integer sequences in query using PHP's [] notation. Default - * is true. - */ - const OPTION_DROP_SEQUENCE = 'drop_sequence'; - - /** - * URL-encode query variable keys. Default is true. - */ - const OPTION_ENCODE_KEYS = 'encode_keys'; - - /** - * Query variable separators when parsing the query string. Every character - * is considered a separator. Default is "&". - */ - const OPTION_SEPARATOR_INPUT = 'input_separator'; - - /** - * Query variable separator used when generating the query string. Default - * is "&". - */ - const OPTION_SEPARATOR_OUTPUT = 'output_separator'; - - /** - * Default options corresponds to how PHP handles $_GET. - */ - private $_options = array( - self::OPTION_STRICT => true, - self::OPTION_USE_BRACKETS => true, - self::OPTION_DROP_SEQUENCE => true, - self::OPTION_ENCODE_KEYS => true, - self::OPTION_SEPARATOR_INPUT => '&', - self::OPTION_SEPARATOR_OUTPUT => '&', - ); - - /** - * @var string|bool - */ - private $_scheme = false; - - /** - * @var string|bool - */ - private $_userinfo = false; - - /** - * @var string|bool - */ - private $_host = false; - - /** - * @var string|bool - */ - private $_port = false; - - /** - * @var string - */ - private $_path = ''; - - /** - * @var string|bool - */ - private $_query = false; - - /** - * @var string|bool - */ - private $_fragment = false; - - /** - * Constructor. - * - * @param string $url an absolute or relative URL - * @param array $options an array of OPTION_xxx constants - * - * @uses self::parseUrl() - */ - public function __construct($url, array $options = array()) - { - foreach ($options as $optionName => $value) { - if (array_key_exists($optionName, $this->_options)) { - $this->_options[$optionName] = $value; - } - } - - $this->parseUrl($url); - } - - /** - * Magic Setter. - * - * This method will magically set the value of a private variable ($var) - * with the value passed as the args - * - * @param string $var The private variable to set. - * @param mixed $arg An argument of any type. - * - * @return void - */ - public function __set($var, $arg) - { - $method = 'set' . $var; - if (method_exists($this, $method)) { - $this->$method($arg); - } - } - - /** - * Magic Getter. - * - * This is the magic get method to retrieve the private variable - * that was set by either __set() or it's setter... - * - * @param string $var The property name to retrieve. - * - * @return mixed $this->$var Either a boolean false if the - * property is not set or the value - * of the private property. - */ - public function __get($var) - { - $method = 'get' . $var; - if (method_exists($this, $method)) { - return $this->$method(); - } - - return false; - } - - /** - * Returns the scheme, e.g. "http" or "urn", or false if there is no - * scheme specified, i.e. if this is a relative URL. - * - * @return string|bool - */ - public function getScheme() - { - return $this->_scheme; - } - - /** - * Sets the scheme, e.g. "http" or "urn". Specify false if there is no - * scheme specified, i.e. if this is a relative URL. - * - * @param string|bool $scheme e.g. "http" or "urn", or false if there is no - * scheme specified, i.e. if this is a relative - * URL - * - * @return $this - * @see getScheme - */ - public function setScheme($scheme) - { - $this->_scheme = $scheme; - return $this; - } - - /** - * Returns the user part of the userinfo part (the part preceding the first - * ":"), or false if there is no userinfo part. - * - * @return string|bool - */ - public function getUser() - { - return $this->_userinfo !== false - ? preg_replace('(:.*$)', '', $this->_userinfo) - : false; - } - - /** - * Returns the password part of the userinfo part (the part after the first - * ":"), or false if there is no userinfo part (i.e. the URL does not - * contain "@" in front of the hostname) or the userinfo part does not - * contain ":". - * - * @return string|bool - */ - public function getPassword() - { - return $this->_userinfo !== false - ? substr(strstr($this->_userinfo, ':'), 1) - : false; - } - - /** - * Returns the userinfo part, or false if there is none, i.e. if the - * authority part does not contain "@". - * - * @return string|bool - */ - public function getUserinfo() - { - return $this->_userinfo; - } - - /** - * Sets the userinfo part. If two arguments are passed, they are combined - * in the userinfo part as username ":" password. - * - * @param string|bool $userinfo userinfo or username - * @param string|bool $password optional password, or false - * - * @return $this - */ - public function setUserinfo($userinfo, $password = false) - { - if ($password !== false) { - $userinfo .= ':' . $password; - } - - if ($userinfo !== false) { - $userinfo = $this->_encodeData($userinfo); - } - - $this->_userinfo = $userinfo; - return $this; - } - - /** - * Returns the host part, or false if there is no authority part, e.g. - * relative URLs. - * - * @return string|bool a hostname, an IP address, or false - */ - public function getHost() - { - return $this->_host; - } - - /** - * Sets the host part. Specify false if there is no authority part, e.g. - * relative URLs. - * - * @param string|bool $host a hostname, an IP address, or false - * - * @return $this - */ - public function setHost($host) - { - $this->_host = $host; - return $this; - } - - /** - * Returns the port number, or false if there is no port number specified, - * i.e. if the default port is to be used. - * - * @return string|bool - */ - public function getPort() - { - return $this->_port; - } - - /** - * Sets the port number. Specify false if there is no port number specified, - * i.e. if the default port is to be used. - * - * @param string|bool $port a port number, or false - * - * @return $this - */ - public function setPort($port) - { - $this->_port = $port; - return $this; - } - - /** - * Returns the authority part, i.e. [ userinfo "@" ] host [ ":" port ], or - * false if there is no authority. - * - * @return string|bool - */ - public function getAuthority() - { - if (false === $this->_host) { - return false; - } - - $authority = ''; - - if (strlen($this->_userinfo)) { - $authority .= $this->_userinfo . '@'; - } - - $authority .= $this->_host; - - if ($this->_port !== false) { - $authority .= ':' . $this->_port; - } - - return $authority; - } - - /** - * Sets the authority part, i.e. [ userinfo "@" ] host [ ":" port ]. Specify - * false if there is no authority. - * - * @param string|bool $authority a hostname or an IP address, possibly - * with userinfo prefixed and port number - * appended, e.g. "foo:bar@example.org:81". - * - * @return $this - */ - public function setAuthority($authority) - { - $this->_userinfo = false; - $this->_host = false; - $this->_port = false; - - if ('' === $authority) { - $this->_host = $authority; - return $this; - } - - if (!preg_match('(^(([^\@]*)\@)?(.+?)(:(\d*))?$)', $authority, $matches)) { - return $this; - } - - if ($matches[1]) { - $this->_userinfo = $this->_encodeData($matches[2]); - } - - $this->_host = $matches[3]; - - if (isset($matches[5]) && strlen($matches[5])) { - $this->_port = $matches[5]; - } - return $this; - } - - /** - * Returns the path part (possibly an empty string). - * - * @return string - */ - public function getPath() - { - return $this->_path; - } - - /** - * Sets the path part (possibly an empty string). - * - * @param string $path a path - * - * @return $this - */ - public function setPath($path) - { - $this->_path = $path; - return $this; - } - - /** - * Returns the query string (excluding the leading "?"), or false if "?" - * is not present in the URL. - * - * @return string|bool - * @see getQueryVariables - */ - public function getQuery() - { - return $this->_query; - } - - /** - * Sets the query string (excluding the leading "?"). Specify false if "?" - * is not present in the URL. - * - * @param string|bool $query a query string, e.g. "foo=1&bar=2" - * - * @return $this - * @see setQueryVariables - */ - public function setQuery($query) - { - $this->_query = $query; - return $this; - } - - /** - * Returns the fragment name, or false if "#" is not present in the URL. - * - * @return string|bool - */ - public function getFragment() - { - return $this->_fragment; - } - - /** - * Sets the fragment name. Specify false if "#" is not present in the URL. - * - * @param string|bool $fragment a fragment excluding the leading "#", or - * false - * - * @return $this - */ - public function setFragment($fragment) - { - $this->_fragment = $fragment; - return $this; - } - - /** - * Returns the query string like an array as the variables would appear in - * $_GET in a PHP script. If the URL does not contain a "?", an empty array - * is returned. - * - * @return array - */ - public function getQueryVariables() - { - $separator = $this->getOption(self::OPTION_SEPARATOR_INPUT); - $encodeKeys = $this->getOption(self::OPTION_ENCODE_KEYS); - $useBrackets = $this->getOption(self::OPTION_USE_BRACKETS); - - $return = array(); - - for ($part = strtok($this->_query, $separator); - strlen($part); - $part = strtok($separator) - ) { - list($key, $value) = explode('=', $part, 2) + array(1 => ''); - - if ($encodeKeys) { - $key = rawurldecode($key); - } - $value = rawurldecode($value); - - if ($useBrackets) { - $return = $this->_queryArrayByKey($key, $value, $return); - } else { - if (isset($return[$key])) { - $return[$key] = (array) $return[$key]; - $return[$key][] = $value; - } else { - $return[$key] = $value; - } - } - } - - return $return; - } - - /** - * Parse a single query key=value pair into an existing php array - * - * @param string $key query-key - * @param string $value query-value - * @param array $array of existing query variables (if any) - * - * @return mixed - */ - private function _queryArrayByKey($key, $value, array $array = array()) - { - if (!strlen($key)) { - return $array; - } - - $offset = $this->_queryKeyBracketOffset($key); - if ($offset === false) { - $name = $key; - } else { - $name = substr($key, 0, $offset); - } - - if (!strlen($name)) { - return $array; - } - - if (!$offset) { - // named value - $array[$name] = $value; - } else { - // array - $brackets = substr($key, $offset); - if (!isset($array[$name])) { - $array[$name] = null; - } - $array[$name] = $this->_queryArrayByBrackets( - $brackets, $value, $array[$name] - ); - } - - return $array; - } - - /** - * Parse a key-buffer to place value in array - * - * @param string $buffer to consume all keys from - * @param string $value to be set/add - * @param array $array to traverse and set/add value in - * - * @throws Exception - * @return array - */ - private function _queryArrayByBrackets($buffer, $value, array $array = null) - { - $entry = &$array; - - for ($iteration = 0; strlen($buffer); $iteration++) { - $open = $this->_queryKeyBracketOffset($buffer); - if ($open !== 0) { - // Opening bracket [ must exist at offset 0, if not, there is - // no bracket to parse and the value dropped. - // if this happens in the first iteration, this is flawed, see - // as well the second exception below. - if ($iteration) { - break; - } - // @codeCoverageIgnoreStart - throw new Exception( - 'Net_URL2 Internal Error: '. __METHOD__ .'(): ' . - 'Opening bracket [ must exist at offset 0' - ); - // @codeCoverageIgnoreEnd - } - - $close = strpos($buffer, ']', 1); - if (!$close) { - // this error condition should never be reached as this is a - // private method and bracket pairs are checked beforehand. - // See as well the first exception for the opening bracket. - // @codeCoverageIgnoreStart - throw new Exception( - 'Net_URL2 Internal Error: '. __METHOD__ .'(): ' . - 'Closing bracket ] must exist, not found' - ); - // @codeCoverageIgnoreEnd - } - - $index = substr($buffer, 1, $close - 1); - if (strlen($index)) { - $entry = &$entry[$index]; - } else { - if (!is_array($entry)) { - $entry = array(); - } - $entry[] = &$new; - $entry = &$new; - unset($new); - } - $buffer = substr($buffer, $close + 1); - } - - $entry = $value; - - return $array; - } - - /** - * Query-key has brackets ("...[]") - * - * @param string $key query-key - * - * @return bool|int offset of opening bracket, false if no brackets - */ - private function _queryKeyBracketOffset($key) - { - if (false !== $open = strpos($key, '[') - and false === strpos($key, ']', $open + 1) - ) { - $open = false; - } - - return $open; - } - - /** - * Sets the query string to the specified variable in the query string. - * - * @param array $array (name => value) array - * - * @return $this - */ - public function setQueryVariables(array $array) - { - if (!$array) { - $this->_query = false; - } else { - $this->_query = $this->buildQuery( - $array, - $this->getOption(self::OPTION_SEPARATOR_OUTPUT) - ); - } - return $this; - } - - /** - * Sets the specified variable in the query string. - * - * @param string $name variable name - * @param mixed $value variable value - * - * @return $this - */ - public function setQueryVariable($name, $value) - { - $array = $this->getQueryVariables(); - $array[$name] = $value; - $this->setQueryVariables($array); - return $this; - } - - /** - * Removes the specified variable from the query string. - * - * @param string $name a query string variable, e.g. "foo" in "?foo=1" - * - * @return void - */ - public function unsetQueryVariable($name) - { - $array = $this->getQueryVariables(); - unset($array[$name]); - $this->setQueryVariables($array); - } - - /** - * Returns a string representation of this URL. - * - * @return string - */ - public function getURL() - { - // See RFC 3986, section 5.3 - $url = ''; - - if ($this->_scheme !== false) { - $url .= $this->_scheme . ':'; - } - - $authority = $this->getAuthority(); - if ($authority === false && strtolower($this->_scheme) === 'file') { - $authority = ''; - } - - $url .= $this->_buildAuthorityAndPath($authority, $this->_path); - - if ($this->_query !== false) { - $url .= '?' . $this->_query; - } - - if ($this->_fragment !== false) { - $url .= '#' . $this->_fragment; - } - - return $url; - } - - /** - * Put authority and path together, wrapping authority - * into proper separators/terminators. - * - * @param string|bool $authority authority - * @param string $path path - * - * @return string - */ - private function _buildAuthorityAndPath($authority, $path) - { - if ($authority === false) { - return $path; - } - - $terminator = ($path !== '' && $path[0] !== '/') ? '/' : ''; - - return '//' . $authority . $terminator . $path; - } - - /** - * Returns a string representation of this URL. - * - * @return string - * @link https://php.net/language.oop5.magic#object.tostring - */ - public function __toString() - { - return $this->getURL(); - } - - /** - * Returns a normalized string representation of this URL. This is useful - * for comparison of URLs. - * - * @return string - */ - public function getNormalizedURL() - { - $url = clone $this; - $url->normalize(); - return $url->getUrl(); - } - - /** - * Normalizes the URL - * - * See RFC 3986, Section 6. Normalization and Comparison - * - * @link https://tools.ietf.org/html/rfc3986#section-6 - * - * @return void - */ - public function normalize() - { - // See RFC 3986, section 6 - - // Scheme is case-insensitive - if ($this->_scheme) { - $this->_scheme = strtolower($this->_scheme); - } - - // Hostname is case-insensitive - if ($this->_host) { - $this->_host = strtolower($this->_host); - } - - // Remove default port number for known schemes (RFC 3986, section 6.2.3) - if ('' === $this->_port - || $this->_port - && $this->_scheme - && $this->_port == getservbyname($this->_scheme, 'tcp') - ) { - $this->_port = false; - } - - // Normalize case of %XX percentage-encodings (RFC 3986, section 6.2.2.1) - // Normalize percentage-encoded unreserved characters (section 6.2.2.2) - $fields = array(&$this->_userinfo, &$this->_host, &$this->_path, - &$this->_query, &$this->_fragment); - foreach ($fields as &$field) { - if ($field !== false) { - $field = $this->_normalize("$field"); - } - } - unset($field); - - // Path segment normalization (RFC 3986, section 6.2.2.3) - $this->_path = self::removeDotSegments($this->_path); - - // Scheme based normalization (RFC 3986, section 6.2.3) - if (false !== $this->_host && '' === $this->_path) { - $this->_path = '/'; - } - - // path should start with '/' if there is authority (section 3.3.) - if (strlen($this->getAuthority()) - && strlen($this->_path) - && $this->_path[0] !== '/' - ) { - $this->_path = '/' . $this->_path; - } - } - - /** - * Normalize case of %XX percentage-encodings (RFC 3986, section 6.2.2.1) - * Normalize percentage-encoded unreserved characters (section 6.2.2.2) - * - * @param string|array $mixed string or array of strings to normalize - * - * @return string|array - * @see normalize - * @see _normalizeCallback() - */ - private function _normalize($mixed) - { - return preg_replace_callback( - '((?:%[0-9a-fA-Z]{2})+)', array($this, '_normalizeCallback'), - $mixed - ); - } - - /** - * Callback for _normalize() of %XX percentage-encodings - * - * @param array $matches as by preg_replace_callback - * - * @return string - * @see normalize - * @see _normalize - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) - */ - private function _normalizeCallback($matches) - { - return self::urlencode(urldecode($matches[0])); - } - - /** - * Returns whether this instance represents an absolute URL. - * - * @return bool - */ - public function isAbsolute() - { - return (bool) $this->_scheme; - } - - /** - * Returns an Net_URL2 instance representing an absolute URL relative to - * this URL. - * - * @param Net_URL2|string $reference relative URL - * - * @throws Exception - * @return $this - */ - public function resolve($reference) - { - if (!$reference instanceof Net_URL2) { - $reference = new self($reference); - } - if (!$reference->_isFragmentOnly() && !$this->isAbsolute()) { - throw new Exception( - 'Base-URL must be absolute if reference is not fragment-only' - ); - } - - // A non-strict parser may ignore a scheme in the reference if it is - // identical to the base URI's scheme. - if (!$this->getOption(self::OPTION_STRICT) - && $reference->_scheme == $this->_scheme - ) { - $reference->_scheme = false; - } - - $target = new self(''); - if ($reference->_scheme !== false) { - $target->_scheme = $reference->_scheme; - $target->setAuthority($reference->getAuthority()); - $target->_path = self::removeDotSegments($reference->_path); - $target->_query = $reference->_query; - } else { - $authority = $reference->getAuthority(); - if ($authority !== false) { - $target->setAuthority($authority); - $target->_path = self::removeDotSegments($reference->_path); - $target->_query = $reference->_query; - } else { - if ($reference->_path == '') { - $target->_path = $this->_path; - if ($reference->_query !== false) { - $target->_query = $reference->_query; - } else { - $target->_query = $this->_query; - } - } else { - if (substr($reference->_path, 0, 1) == '/') { - $target->_path = self::removeDotSegments($reference->_path); - } else { - // Merge paths (RFC 3986, section 5.2.3) - if ($this->_host !== false && $this->_path == '') { - $target->_path = '/' . $reference->_path; - } else { - $i = strrpos($this->_path, '/'); - if ($i !== false) { - $target->_path = substr($this->_path, 0, $i + 1); - } - $target->_path .= $reference->_path; - } - $target->_path = self::removeDotSegments($target->_path); - } - $target->_query = $reference->_query; - } - $target->setAuthority($this->getAuthority()); - } - $target->_scheme = $this->_scheme; - } - - $target->_fragment = $reference->_fragment; - - return $target; - } - - /** - * URL is fragment-only - * - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) - * @return bool - */ - private function _isFragmentOnly() - { - return ( - $this->_fragment !== false - && $this->_query === false - && $this->_path === '' - && $this->_port === false - && $this->_host === false - && $this->_userinfo === false - && $this->_scheme === false - ); - } - - /** - * Removes dots as described in RFC 3986, section 5.2.4, e.g. - * "/foo/../bar/baz" => "/bar/baz" - * - * @param string $path a path - * - * @return string a path - */ - public static function removeDotSegments($path) - { - $path = (string) $path; - $output = ''; - - // Make sure not to be trapped in an infinite loop due to a bug in this - // method - $loopLimit = 256; - $j = 0; - while ('' !== $path && $j++ < $loopLimit) { - if (substr($path, 0, 2) === './') { - // Step 2.A - $path = substr($path, 2); - } elseif (substr($path, 0, 3) === '../') { - // Step 2.A - $path = substr($path, 3); - } elseif (substr($path, 0, 3) === '/./' || $path === '/.') { - // Step 2.B - $path = '/' . substr($path, 3); - } elseif (substr($path, 0, 4) === '/../' || $path === '/..') { - // Step 2.C - $path = '/' . substr($path, 4); - $i = strrpos($output, '/'); - $output = $i === false ? '' : substr($output, 0, $i); - } elseif ($path === '.' || $path === '..') { - // Step 2.D - $path = ''; - } else { - // Step 2.E - $i = strpos($path, '/', $path[0] === '/'); - if ($i === false) { - $output .= $path; - $path = ''; - break; - } - $output .= substr($path, 0, $i); - $path = substr($path, $i); - } - } - - if ($path !== '') { - $message = sprintf( - 'Unable to remove dot segments; hit loop limit %d (left: %s)', - $j, var_export($path, true) - ); - trigger_error($message, E_USER_WARNING); - } - - return $output; - } - - /** - * Percent-encodes all non-alphanumeric characters except these: _ . - ~ - * Similar to PHP's rawurlencode(), except that it also encodes ~ in PHP - * 5.2.x and earlier. - * - * @param string $string string to encode - * - * @return string - */ - public static function urlencode($string) - { - $encoded = rawurlencode($string); - - // This is only necessary in PHP < 5.3. - $encoded = str_replace('%7E', '~', $encoded); - return $encoded; - } - - /** - * Returns a Net_URL2 instance representing the canonical URL of the - * currently executing PHP script. - * - * @throws Exception - * @return string - */ - public static function getCanonical() - { - if (!isset($_SERVER['REQUEST_METHOD'])) { - // ALERT - no current URL - throw new Exception('Script was not called through a webserver'); - } - - // Begin with a relative URL - $url = new self($_SERVER['PHP_SELF']); - $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; - $url->_host = $_SERVER['SERVER_NAME']; - $port = $_SERVER['SERVER_PORT']; - if ($url->_scheme == 'http' && $port != 80 - || $url->_scheme == 'https' && $port != 443 - ) { - $url->_port = $port; - } - return $url; - } - - /** - * Returns the URL used to retrieve the current request. - * - * @return string - */ - public static function getRequestedURL() - { - return self::getRequested()->getUrl(); - } - - /** - * Returns a Net_URL2 instance representing the URL used to retrieve the - * current request. - * - * @throws Exception - * @return $this - */ - public static function getRequested() - { - if (!isset($_SERVER['REQUEST_METHOD'])) { - // ALERT - no current URL - throw new Exception('Script was not called through a webserver'); - } - - // Begin with a relative URL - $url = new self($_SERVER['REQUEST_URI']); - $url->_scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http'; - // Set host and possibly port - $url->setAuthority($_SERVER['HTTP_HOST']); - return $url; - } - - /** - * Returns the value of the specified option. - * - * @param string $optionName The name of the option to retrieve - * - * @return mixed - */ - public function getOption($optionName) - { - return isset($this->_options[$optionName]) - ? $this->_options[$optionName] : false; - } - - /** - * A simple version of http_build_query in userland. The encoded string is - * percentage encoded according to RFC 3986. - * - * @param array $data An array, which has to be converted into - * QUERY_STRING. Anything is possible. - * @param string $separator Separator {@link self::OPTION_SEPARATOR_OUTPUT} - * @param string $key For stacked values (arrays in an array). - * - * @return string - */ - protected function buildQuery(array $data, $separator, $key = null) - { - $query = array(); - $drop_names = ( - $this->_options[self::OPTION_DROP_SEQUENCE] === true - && array_keys($data) === array_keys(array_values($data)) - ); - foreach ($data as $name => $value) { - if ($this->getOption(self::OPTION_ENCODE_KEYS) === true) { - $name = rawurlencode($name); - } - if ($key !== null) { - if ($this->getOption(self::OPTION_USE_BRACKETS) === true) { - $drop_names && $name = ''; - $name = $key . '[' . $name . ']'; - } else { - $name = $key; - } - } - if (is_array($value)) { - $query[] = $this->buildQuery($value, $separator, $name); - } else { - $query[] = $name . '=' . rawurlencode($value); - } - } - return implode($separator, $query); - } - - /** - * This method uses a regex to parse the url into the designated parts. - * - * @param string $url URL - * - * @return void - * @uses self::$_scheme, self::setAuthority(), self::$_path, self::$_query, - * self::$_fragment - * @see __construct - */ - protected function parseUrl($url) - { - // The regular expression is copied verbatim from RFC 3986, appendix B. - // The expression does not validate the URL but matches any string. - preg_match( - '(^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)', - $url, $matches - ); - - // "path" is always present (possibly as an empty string); the rest - // are optional. - $this->_scheme = !empty($matches[1]) ? $matches[2] : false; - $this->setAuthority(!empty($matches[3]) ? $matches[4] : false); - $this->_path = $this->_encodeData($matches[5]); - $this->_query = !empty($matches[6]) - ? $this->_encodeData($matches[7]) - : false - ; - $this->_fragment = !empty($matches[8]) ? $matches[9] : false; - } - - /** - * Encode characters that might have been forgotten to encode when passing - * in an URL. Applied onto Userinfo, Path and Query. - * - * @param string $url URL - * - * @return string - * @see parseUrl - * @see setAuthority - * @link https://pear.php.net/bugs/bug.php?id=20425 - */ - private function _encodeData($url) - { - return preg_replace_callback( - '([\x-\x20\x22\x3C\x3E\x7F-\xFF]+)', - array($this, '_encodeCallback'), $url - ); - } - - /** - * callback for encoding character data - * - * @param array $matches Matches - * - * @return string - * @see _encodeData - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) - */ - private function _encodeCallback(array $matches) - { - return rawurlencode($matches[0]); - } -} diff --git a/vendor/pear/net_url2/README.md b/vendor/pear/net_url2/README.md deleted file mode 100644 index bc98d3aec..000000000 --- a/vendor/pear/net_url2/README.md +++ /dev/null @@ -1,43 +0,0 @@ -[![Net_URL2 on Packagist](https://poser.pugx.org/pear/net_url2/v/stable.png)][pear/net_url2] -[![Build Status](https://travis-ci.org/pear/Net_URL2.png)][Travis CI] -[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/pear/Net_URL2/badges/quality-score.png?s=23b0d3f0ed58ee865317c500ee2cbe94517438ec)](https://scrutinizer-ci.com/g/pear/Net_URL2/) -[![Code Coverage](https://scrutinizer-ci.com/g/pear/Net_URL2/badges/coverage.png?s=44d3682d7cdef471570d80dd8a7290a1e23fdfee)](https://scrutinizer-ci.com/g/pear/Net_URL2/) - -# Net_URL2 - -Class for parsing and handling URL. Provides parsing of URLs into their constituent parts (scheme, host, path etc.), -URL generation, and resolving of relative URLs. - -This package is [Pear Net_URL2] and has been migrated from [Pear SVN] - -Please report all new issues via the [PEAR bug tracker]. - -On Packagist as [pear/net_url2]. - -[Pear Net_URL2]: https://pear.php.net/package/Net_URL2 -[Pear SVN]: https://svn.php.net/repository/pear/packages/Net_URL2 -[PEAR bug tracker]: https://pear.php.net/bugs/search.php?cmd=display&package_name%5B%5D=Net_URL2 -[pear/net_url2]: https://packagist.org/packages/pear/net_url2 -[Travis CI]: https://travis-ci.org/pear/Net_URL2 - -## Testing, Packaging and Installing (Pear) - -To test, run either - - $ phpunit tests/ - - or - - $ pear run-tests -r - -To build, simply - - $ pear package - -To install from scratch - - $ pear install package.xml - -To upgrade - - $ pear upgrade -f package.xml diff --git a/vendor/pear/net_url2/composer.json b/vendor/pear/net_url2/composer.json deleted file mode 100644 index b33698e5d..000000000 --- a/vendor/pear/net_url2/composer.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "pear/net_url2", - "description": "Class for parsing and handling URL. Provides parsing of URLs into their constituent parts (scheme, host, path etc.), URL generation, and resolving of relative URLs.", - "type": "library", - "keywords": [ - "pear", - "net", - "url", - "uri", - "networking", - "rfc3986" - ], - "homepage": "https://github.com/pear/Net_URL2", - "license": "BSD-3-Clause", - "authors": [ - { - "name": "Tom Klingenberg", - "email": "tkli@php.net" - }, - { - "name": "David Coallier", - "email": "davidc@php.net" - }, - { - "name": "Christian Schmidt", - "email": "chmidt@php.net" - } - ], - "support": { - "issues": "https://pear.php.net/bugs/search.php?cmd=display&package_name[]=Net_URL2", - "source": "https://github.com/pear/Net_URL2" - }, - "require": { - "php": ">=5.1.4" - }, - "autoload": { - "classmap": ["Net/URL2.php"] - }, - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "require-dev": { - "phpunit/phpunit": ">=3.3.0" - } -} diff --git a/vendor/pear/net_url2/docs/6470.php b/vendor/pear/net_url2/docs/6470.php deleted file mode 100755 index 8ef0ff046..000000000 --- a/vendor/pear/net_url2/docs/6470.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * @category Networking - * @package Net_URL2 - * @author Some Pear Developers - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @link https://tools.ietf.org/html/rfc3986 - */ - -/** -* This example will decode the url given and display its -* constituent parts. -*/ - error_reporting(E_ALL | E_STRICT); - - require_once 'Net/URL2.php'; - - $url = new Net_URL2('https://www.example.com/foo/bar/index.php?foo=bar'); - -?> - - - -
-Protocol...: protocol; ?>
-
-Username...: user; ?>
-
-Password...: pass; ?>
-
-Server.....: host; ?>
-
-Port.......: port; ?>
-
-File/path..: path; ?>
-
-Querystring: querystring); ?>
-
-Anchor.....: anchor;?>
-
-Full URL...: getUrl(); ?>
-
-Resolve path (/.././/foo/bar/joe/./././../jabba): resolve('/.././/foo/bar/joe/./././../jabba'); ?>
-
- - - diff --git a/vendor/pear/net_url2/docs/BSD-3-CLAUSE-Heyes b/vendor/pear/net_url2/docs/BSD-3-CLAUSE-Heyes deleted file mode 100644 index b45ca8e94..000000000 --- a/vendor/pear/net_url2/docs/BSD-3-CLAUSE-Heyes +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2002-2003, Richard Heyes -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3) Neither the name of the Richard Heyes nor the names of his - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/pear/net_url2/docs/example.php b/vendor/pear/net_url2/docs/example.php deleted file mode 100755 index 351be68b8..000000000 --- a/vendor/pear/net_url2/docs/example.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * @category Networking - * @package Net_URL2 - * @author Some Pear Developers - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @link https://tools.ietf.org/html/rfc3986 - */ - -/** -* This example will decode the url given and display its -* constituent parts. -*/ - -error_reporting(E_ALL | E_STRICT); - -require 'Net/URL2.php'; - -$url = new Net_URL2( - 'https://example.com/pls/portal30/PORTAL30.wwpob_page.changetabs?' - .'p_back_url=http%3A%2F%2Fexample.com%2Fservlet%2Fpage%3F_pageid%3D360' - .'%2C366%2C368%2C382%26_dad%3Dportal30%26_schema%3DPORTAL30&foo=bar' -); - -?> - - - -
-Protocol...: protocol; ?>
-
-Username...: user; ?>
-
-Password...: pass; ?>
-
-Server.....: host; ?>
-
-Port.......: port; ?>
-
-File/path..: path; ?>
-
-Querystring: querystring); ?>
-
-Anchor.....: anchor;?>
-
-Full URL...: getUrl(); ?>
-
-
-Resolve path (.././/foo/bar/joe/./././../jabba): resolve('.././/foo/bar/joe/./././../jabba'); ?>
-
- - - diff --git a/vendor/pear/net_url2/package.xml b/vendor/pear/net_url2/package.xml deleted file mode 100644 index 7f0b42ae4..000000000 --- a/vendor/pear/net_url2/package.xml +++ /dev/null @@ -1,469 +0,0 @@ - - - Net_URL2 - pear.php.net - Net_URL - Class for parsing and handling URL. - - Provides parsing of URLs into their constituent parts (scheme, host, path etc.), URL generation, and resolving of - relative URLs. - - - Tom Klingenberg - tkli - tkli@php.net - yes - - - David Coallier - davidc - davidc@php.net - no - - - Christian Schmidt - schmidt - schmidt@php.net - no - - - 2015-04-18 - - - 2.2.0 - 2.1.0 - - - stable - stable - - BSD-3-Clause - - * Changed composer autoloader to classmap, fixes include path pollution - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5.1.4 - - - 1.4.0b1 - - - - - - - 2015-04-18 - - - 2.2.0 - 2.1.0 - - - stable - stable - - BSD-3-Clause - - * Changed composer autoloader to classmap, fixes include path pollution - - - - 2014-12-27 - - - 2.1.1 - 2.1.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #20473: Normalize query and fragment broken - - - - 2014-10-21 - - - 2.1.0 - 2.1.0 - - - stable - stable - - BSD-3-Clause - - * New: OPTION_DROP_SEQUENCE - - - - 2014-10-21 - - - 2.0.12 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Removed: OPTION_DROP_SEQUENCE - - - - - 2014-10-18 - - - 2.0.11 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * New: OPTION_DROP_SEQUENCE - - - - - 2014-10-09 - - - 2.0.10 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Imp: composer for pear - * Fix: Documentation problem - - - - - 2014-10-08 - - - 2.0.9 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #20418: Incorrect normalization of URI with missing authority - * Upd: Test for RFC 3986 Section 1.1.2 Examples - * Upd: Travis CI - PHP 5.6 added - - - - - 2014-10-07 - - - 2.0.8 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #20420: Inconsistent setAuthority and getAuthority - * Fixed #20423: URI with IPv6 or IPvFuture not parsed - * Imp: Test for RFC 3986 Section 1.1.2 Examples - - - - - 2014-09-07 - - - 2.0.7 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #20385: Incorrect normalization of userinfo - * Fixed #20399: Setting userinfo to FALSE not transparent - - - - - 2014-07-21 - - - 2.0.6 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #20304: file:// URI gets crippled - - - - - 2014-01-01 - - - 2.0.5 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #17036: Brackets broken for query variables - * Fixed diverse coding style violations and misc. minor issues - * Increased code coverage - - - - - 2013-12-31 - - - 2.0.4 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #20161: URLs with "0" as host fail to normalize with empty path - * A flaw in NetURL2::removeDotSegments() introduced in 2.0.1 has been fixed - * New: NetURL2::removeDotSegments() emits a warning on loop limit reach - * Url-segment maximum count raised from 100 to 256 (loop limit) - - - - - 2013-12-30 - - - 2.0.3 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #20156: setAuthority() flaw with "0" as host - * Fixed #20157: normalize() flaw with "0" as path - * Fixed #20158: Fragment-only references are not resolved to non-absolute base URI - * Fixed #20159: Authority not terminated by slash - * Fixed diverse coding style violations and misc. minor issues - * Increased code coverage - * Added support for Scrutinizer CI - - - - - 2013-12-27 - - - 2.0.2 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed #19684: Redirects containing spaces do not work - * Fixed diverse coding style violations and misc. minor issues - * Improved source package distribution - * Added support for Travis CI - - - - - 2013-12-24 - - - 2.0.1 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed Bug #20013: getNormalizedURL() adds leading "@" chars in the Authority - * Fixed Bug #20016: Wrong data in 6d4f4dd "Package.xml preparation." - * Fixed Bug #19176: resolve() does not merge the path if the base path is empty - * Fixed Bug #19315: removeDotSegments("0") not working - - - - - 2011-10-20 - - - 2.0.0 - 2.0.0 - - - stable - stable - - BSD-3-Clause - - * Fixed the version of the release. Follow the convention for Package2. - * Fixed Bug #18917: URL2.php moved to ./Net/Net (davidc) - - - - - - 1.0.0 - 1.0.0 - - - stable - stable - - 2011-10-20 - BSD-3-Clause - - * Fixed Bug #17036: Problem with parsed query string - * Fixed Bug #17087: setOption() function is gone - * Fixed #17166: Fluent Interface - * Fixed #17167: Refactor __construct - * Fixed Bug #18267: setQueryVariables() fails to encode array values - * Fixed Bug #14399: Fixed multiple bugs in Net_URL2 (Missing setOption value, unused properties, etc.) - - - - - - 0.3.1 - 0.3.0 - - - beta - beta - - 2011-02-22 - BSD-3-Clause - - * BC break: Removed setOption() to avoid undefined behaviour (bug #16674) - * Fixed Bug #16854: Invalid package.xml making it impossible to install with Pyrus - * Fixed Bug #16651: Port may be an empty string - * Fixed Bug #16653: Don't make OPTION_SEPARATOR_(IN|OUT)PUT default to arg_separator.(in|out)put - - - - - 0.3.0 - 0.3.0 - - - beta - beta - - 2009-09-05 - BSD-3-Clause - - * Fixed #14399 (Errors in URL parsing (items #1 and #3)) - * Fixed #14735 (Encode query string values) - * Fixed #15546 (Add adding __toString()) - * Fixed #15367 (Use RFC 3986-compliant version of rawurlencode() in PHP < 5.2) - * Fixed #14289 (Add __get() and __set()) - - - - - 0.2.0 - 0.2.0 - - - beta - beta - - 2008-06-18 - BSD-3-Clause - - * Major rewrite to comply with RFC3986 (bug #11574). - * Much better support for resolving relative URLs. - * WARNING: Method and property names has changed to reflect the terminology used in the RFC - THIS RELEASE IS - NOT BACKWARDS COMPATIBLE WITH VERSION 0.1.0. - - - - - 0.1.0 - 0.1.0 - - - beta - beta - - 2007-05-08 - BSD-3-Clause - Convert to PHP5 only. PHP4 users should continue with version 1.0.15 - - - diff --git a/vendor/pear/net_url2/phpunit.xml.dist b/vendor/pear/net_url2/phpunit.xml.dist deleted file mode 100644 index 2fee31891..000000000 --- a/vendor/pear/net_url2/phpunit.xml.dist +++ /dev/null @@ -1,17 +0,0 @@ - - - - tests - - - - - Net/URL2.php - - - diff --git a/vendor/pear/net_url2/tests/AllTests.php b/vendor/pear/net_url2/tests/AllTests.php deleted file mode 100644 index 65492fe36..000000000 --- a/vendor/pear/net_url2/tests/AllTests.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @link https://tools.ietf.org/html/rfc3986 - */ - -require_once 'PHPUnit/Autoload.php'; - -chdir(dirname(__FILE__) . '/../'); - -require_once 'Net/URL2Test.php'; -require_once 'Net/URL2.php'; - -/** - * Test class for Net_URL2. - * - * @category Networking - * @package Net_URL2 - * @author Some Pear Developers - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @version Release: @package_version@ - * @link https://pear.php.net/package/Net_URL2 - */ -class Net_URL2_AllTests -{ - /** - * main() - * - * @return void - */ - public static function main() - { - - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - /** - * suite() - * - * @return PHPUnit_Framework_TestSuite - */ - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Net_URL2 tests'); - /** Add testsuites, if there is. */ - $suite->addTestSuite('Net_URL2Test'); - - return $suite; - } -} - -Net_URL2_AllTests::main(); diff --git a/vendor/pear/net_url2/tests/Net/URL2Test.php b/vendor/pear/net_url2/tests/Net/URL2Test.php deleted file mode 100644 index a17d0c5f6..000000000 --- a/vendor/pear/net_url2/tests/Net/URL2Test.php +++ /dev/null @@ -1,1088 +0,0 @@ - - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @link https://tools.ietf.org/html/rfc3986 - */ - -/** - * Test class for Net_URL2. - * - * @category Networking - * @package Net_URL2 - * @author Some Pear Developers - * @license https://spdx.org/licenses/BSD-3-Clause BSD-3-Clause - * @version Release: @package_version@ - * @link https://pear.php.net/package/Net_URL2 - */ -class Net_URL2Test extends PHPUnit_Framework_TestCase -{ - /** - * Tests setting a zero-length string and false as authority - * Also: Regression test for Bug #20420 - * - * @covers Net_URL2::setAuthority - * @return void - * @link https://pear.php.net/bugs/bug.php?id=20420 - */ - public function testSetEmptyAuthority() - { - $url = new Net_URL2('http://www.example.com/'); - $url->setAuthority(''); - $this->assertSame('', $url->getAuthority()); - $this->assertSame('', $url->getHost()); - $this->assertSame(false, $url->getPort()); - $this->assertSame(false, $url->getUserinfo()); - $this->assertSame(false, $url->getUser()); - - $url->setAuthority(false); - $this->assertSame(false, $url->getAuthority()); - } - - /** - * Tests setting an empty userinfo part - * Also: Regression test for Bug #20013 and Bug #20399 - * - * @covers Net_URL2::setUserinfo - * @covers Net_URL2::getUserinfo - * @covers Net_URL2::getURL - * @return void - * @link https://pear.php.net/bugs/bug.php?id=20013 - * @link https://pear.php.net/bugs/bug.php?id=20399 - */ - public function testSetEmptyUserinfo() - { - $url = new Net_URL2('http://@www.example.com/'); - $this->assertSame('http://www.example.com/', $url->getURL()); - - $url = new Net_URL2('http://www.example.com/'); - $this->assertSame('http://www.example.com/', $url->getURL()); - $url->setUserinfo(''); - $this->assertSame('http://www.example.com/', $url->getURL()); - $this->assertSame('', $url->getUserinfo()); - $url->setUserinfo(false); - $this->assertSame('http://www.example.com/', $url->getURL()); - $this->assertFalse($url->getUserinfo()); - } - - /** - * Tests an URL with no userinfo and normalization - * - * Also: Regression test for Bug #20385 - * - * @covers Net_URL2::getUserinfo - * @covers Net_URL2::normalize - * @covers Net_URL2::getNormalizedURL - * @return void - * @link https://pear.php.net/bugs/bug.php?id=20385 - */ - public function testNoUserinfoAndNormalize() - { - $testUrl = 'http://www.example.com/'; - - $url = new Net_URL2($testUrl); - $this->assertFalse($url->getUserinfo()); - - $url->normalize(); - $this->assertFalse($url->getUserinfo()); - - $this->assertEquals($testUrl, $url->getURL()); - $this->assertEquals($testUrl, $url->getNormalizedURL()); - } - - /** - * Tests setQueryVariable(). - * - * @return void - */ - public function testSetQueryVariable() - { - - $url = new Net_URL2('http://www.example.com/'); - $url->setQueryVariable('pear', 'fun'); - $this->assertEquals($url->getURL(), 'http://www.example.com/?pear=fun'); - } - - /** - * Tests setQueryVariables(). - * - * @return void - */ - public function testSetQueryVariables() - { - - $url = new Net_URL2('http://www.example.com/'); - $url->setQueryVariables(array('pear' => 'fun')); - $this->assertEquals('http://www.example.com/?pear=fun', $url->getURL()); - $url->setQueryVariables(array('pear' => 'fun for sure')); - $this->assertEquals( - 'http://www.example.com/?pear=fun%20for%20sure', $url->getURL() - ); - } - - /** - * Tests unsetQueryVariable() - * - * @return void - */ - public function testUnsetQueryVariable() - { - $url = new Net_URL2( - 'http://www.example.com/?name=david&pear=fun&fish=slippery' - ); - - $removes = array( - 'pear' => 'http://www.example.com/?name=david&fish=slippery', - 'name' => 'http://www.example.com/?fish=slippery', - 'fish' => 'http://www.example.com/', - ); - - foreach ($removes as $name => $expected) { - $url->unsetQueryVariable($name); - $this->assertEquals($expected, $url); - } - } - - /** - * Tests setQuery(). - * - * @return void - */ - public function testSetQuery() - { - - $url = new Net_URL2('http://www.example.com/'); - $url->setQuery('flapdoodle&dilly%20all%20day'); - $this->assertEquals( - $url->getURL(), 'http://www.example.com/?flapdoodle&dilly%20all%20day' - ); - } - - /** - * Tests getQuery(). - * - * @return void - */ - public function testGetQuery() - { - - $url = new Net_URL2('http://www.example.com/?foo'); - $this->assertEquals($url->getQuery(), 'foo'); - $url = new Net_URL2('http://www.example.com/?pear=fun&fruit=fruity'); - $this->assertEquals($url->getQuery(), 'pear=fun&fruit=fruity'); - } - - /** - * Tests setScheme(). - * - * @return void - */ - public function testSetScheme() - { - - $url = new Net_URL2('http://www.example.com/'); - $url->setScheme('ftp'); - $this->assertEquals($url->getURL(), 'ftp://www.example.com/'); - $url->setScheme('gopher'); - $this->assertEquals($url->getURL(), 'gopher://www.example.com/'); - } - - /** - * Tests setting the fragment. - * - * @return void - */ - public function testSetFragment() - { - - $url = new Net_URL2('http://www.example.com/'); - $url->setFragment('pear'); - $this->assertEquals('http://www.example.com/#pear', $url->getURL()); - } - - /** - * A dataProvider for paths that are solved to a base URI. - * - * @see testResolveUrls - * @return array - */ - public function provideResolveUrls() - { - return array( - array( - // Examples from RFC 3986, section 5.4. - // relative base-URI, (URL => absolute URL), [(options)] - 'http://a/b/c/d;p?q', - array( - 'g:h' => 'g:h', - 'g' => 'http://a/b/c/g', - './g' => 'http://a/b/c/g', - 'g/' => 'http://a/b/c/g/', - '/g' => 'http://a/g', - '//g' => 'http://g', - '?y' => 'http://a/b/c/d;p?y', - 'g?y' => 'http://a/b/c/g?y', - '#s' => 'http://a/b/c/d;p?q#s', - 'g#s' => 'http://a/b/c/g#s', - 'g?y#s' => 'http://a/b/c/g?y#s', - ';x' => 'http://a/b/c/;x', - 'g;x' => 'http://a/b/c/g;x', - 'g;x?y#s' => 'http://a/b/c/g;x?y#s', - '' => 'http://a/b/c/d;p?q', - '.' => 'http://a/b/c/', - './' => 'http://a/b/c/', - '..' => 'http://a/b/', - '../' => 'http://a/b/', - '../g' => 'http://a/b/g', - '../..' => 'http://a/', - '../../' => 'http://a/', - '../../g' => 'http://a/g', - '../../../g' => 'http://a/g', - '../../../../g' => 'http://a/g', - '/./g' => 'http://a/g', - '/../g' => 'http://a/g', - 'g.' => 'http://a/b/c/g.', - '.g' => 'http://a/b/c/.g', - 'g..' => 'http://a/b/c/g..', - '..g' => 'http://a/b/c/..g', - './../g' => 'http://a/b/g', - './g/.' => 'http://a/b/c/g/', - 'g/./h' => 'http://a/b/c/g/h', - 'g/../h' => 'http://a/b/c/h', - 'g;x=1/./y' => 'http://a/b/c/g;x=1/y', - 'g;x=1/../y' => 'http://a/b/c/y', - 'g?y/./x' => 'http://a/b/c/g?y/./x', - 'g?y/../x' => 'http://a/b/c/g?y/../x', - 'g#s/./x' => 'http://a/b/c/g#s/./x', - 'g#s/../x' => 'http://a/b/c/g#s/../x', - 'http:g' => 'http:g', - ), - ), - array( - 'http://a/b/c/d;p?q', - array('http:g' => 'http://a/b/c/g'), - array('::OPTION_STRICT' => false) - ), - ); - } - - /** - * Test the resolve() function to resolve URLs to each other. - * - * @param string $baseURL base-URI - * @param array $relativeAbsolutePairs url-pairs, relative => resolved - * @param array $options Net_URL2 options - * - * @dataProvider provideResolveUrls - * @covers Net_URL2::resolve - * @return void - */ - public function testResolveUrls($baseURL, array $relativeAbsolutePairs, - array $options = array() - ) { - $options = $this->_translateOptionData($options); - $base = new Net_URL2($baseURL, $options); - $count = count($relativeAbsolutePairs); - $this->assertGreaterThan(0, $count, 'relative-absolute-pairs data is empty'); - foreach ($relativeAbsolutePairs as $relativeURL => $absoluteURL) { - $this->assertSame($absoluteURL, (string) $base->resolve($relativeURL)); - } - } - - /** - * Helper method to turn options with strings as the constant names - * (to allow to externalize the fixtures) into a concrete options - * array that uses the values from the Net_URL2 class constants. - * - * @param array $options options - * - * @return array - */ - private function _translateOptionData(array $options) - { - // translate string option-names to class constant starting with a colon. - foreach ($options as $name => $value) { - if ($name[0] === ':') { - unset($options[$name]); - $options[constant("Net_URL2$name")] = $value; - } - } - return $options; - } - - /** - * Test the resolve() function throwing an exception with invalid data. - * - * @covers Net_URL2::resolve - * @return void - */ - public function testResolveException() - { - // resolving a relative to a relative URL throws an exception - $base = new Net_URL2('news.html?category=arts'); - $this->addToAssertionCount(1); - try { - $base->resolve('../arts.html#section-2.4'); - } catch (Exception $e) { - $expected = 'Base-URL must be absolute if reference is not fragment-onl'; - $this->assertStringStartsWith($expected, $e->getMessage()); - return; - } - $this->fail('Expected exception not thrown.'); - } - - /** - * Assert that there is a last error message and it contains needle. - * - * @param string $needle needle - * - * @return void - */ - private function _assertLastErrorContains($needle) - { - $error = error_get_last(); - $this->assertArrayHasKey('message', $error, 'there was an error previously'); - $pos = strpos($error['message'], $needle); - - $this->assertTrue( - false !== $pos, - sprintf( - 'Last error message "%s" contains "%s"', $error['message'], $needle - ) - ); - } - - /** - * Test UrlEncoding - * - * @return void - * @link https://pear.php.net/bugs/bug.php?id=18267 - */ - public function testUrlEncoding() - { - $options = array(Net_URL2::OPTION_DROP_SEQUENCE => false); - $url = new Net_URL2('http://localhost/bug.php', $options); - $url->setQueryVariables( - array( - 'indexed' => array( - 'first value', 'second value', array('foo', 'bar'), - ) - ) - ); - $this->assertEquals( - 'http://localhost/bug.php?indexed[0]=first%20value&indexed[1]' . - '=second%20value&indexed[2][0]=foo&indexed[2][1]=bar', - strval($url) - ); - } - - /** - * A test to verify that keys in QUERY_STRING are encoded by default. - * - * @return void - * @see Net_URL2::OPTION_ENCODE_KEYS - * @see Net_URL2::buildQuery() - */ - public function testEncodeKeys() - { - $url = new Net_URL2('http://example.org'); - $url->setQueryVariables(array('helgi rulez' => 'till too')); - $this->assertEquals( - 'http://example.org?helgi%20rulez=till%20too', - strval($url) - ); - } - - /** - * A test to verify that keys in QUERY_STRING are not encoded when we supply - * 'false' via {@link Net_URL2::__construct()}. - * - * @return void - * @see Net_URL2::OPTION_ENCODE_KEYS - * @see Net_URL2::buildQuery() - */ - public function testDontEncodeKeys() - { - $url = new Net_URL2( - 'http://example.org', - array(Net_URL2::OPTION_ENCODE_KEYS => false) - ); - $url->setQueryVariables(array('till rulez' => 'helgi too')); - $this->assertEquals( - 'http://example.org?till rulez=helgi%20too', - strval($url) - ); - } - - /** - * Brackets for array query variables - * - * Also text to not encode zero based integer sequence into brackets - * - * @return void - * - * @link https://pear.php.net/bugs/bug.php?id=20427 - */ - public function testUseBrackets() - { - $url = new Net_URL2('http://example.org/'); - $url->setQueryVariables(array('foo' => array('bar', 'baz'))); - $expected = 'http://example.org/?foo[]=bar&foo[]=baz'; - $this->assertEquals($expected, $url->getURL()); - - $options = array(Net_URL2::OPTION_DROP_SEQUENCE => false); - $url = new Net_URL2('http://example.org/', $options); - $url->setQueryVariables(array('foo' => array('bar', 'foobar'))); - $expected = 'http://example.org/?foo[0]=bar&foo[1]=foobar'; - $this->assertEquals($expected, $url->getURL()); - } - - /** - * Do not use brackets for query variables passed as array - * - * @return void - */ - public function testDontUseBrackets() - { - $url = new Net_URL2( - 'http://example.org/', - array(Net_URL2::OPTION_USE_BRACKETS => false) - ); - $url->setQueryVariables(array('foo' => array('bar', 'foobar'))); - $this->assertEquals( - 'http://example.org/?foo=bar&foo=foobar', - strval($url) - ); - } - - /** - * A dataProvider for example URIs from RFC 3986 Section 1.1.2 - * - * @return array - * @link http://tools.ietf.org/html/rfc3986#section-1.1.2 - * @see testExampleUri - */ - public function provideExampleUri() - { - return array( - array('ftp://ftp.is.co.za/rfc/rfc1808.txt'), - array('http://www.ietf.org/rfc/rfc2396.txt'), - array('ldap://[2001:db8::7]/c=GB?objectClass?one'), - array('mailto:John.Doe@example.com'), - array('news:comp.infosystems.www.servers.unix'), - array('tel:+1-816-555-1212'), - array('telnet://192.0.2.16:80/'), - array('urn:oasis:names:specification:docbook:dtd:xml:4.1.2'), - ); - } - - /** - * test that Net_URL2 works with the example URIs from RFC 3986 Section 1.1.2 - * - * @param string $uri example URI - * - * @return void - * @dataProvider provideExampleUri - * @link http://tools.ietf.org/html/rfc3986#section-1.1.2 - * @see testComponentRecompositionAndNormalization - */ - public function testExampleUri($uri) - { - $url = new Net_URL2($uri); - $this->assertSame($uri, $url->__toString()); - $url->normalize(); - $this->assertSame($uri, $url->__toString()); - } - - /** - * A dataProvider for pairs of paths with dot segments and - * their form when removed. - * - * @see testRemoveDotSegments - * @return array - */ - public function providePath() - { - // The numbers behind are in reference to sections - // in RFC 3986 5.2.4. Remove Dot Segments - return array( - array('../', ''), // 2. A. - array('./', ''), // 2. A. - array('/./', '/'), // 2. B. - array('/.', '/'), // 2. B. - array('/../', '/'), // 2. C. - array('/..', '/'), // 2. C. - array('..', ''), // 2. D. - array('.', ''), // 2. D. - array('a', 'a'), // 2. E. - array('/a', '/a'), // 2. E. - array('/a/b/c/./../../g', '/a/g'), // 3. - array('mid/content=5/../6', 'mid/6'), // 3. - array('../foo/bar.php', 'foo/bar.php'), - array('/foo/../bar/boo.php', '/bar/boo.php'), - array('/boo/..//foo//bar.php', '//foo//bar.php'), - array('/./foo/././bar.php', '/foo/bar.php'), - array('./.', ''), - ); - } - - /** - * Test removal of dot segments - * - * @param string $path Path - * @param string $assertion Assertion - * - * @dataProvider providePath - * @covers Net_URL2::removeDotSegments - * @return void - */ - public function testRemoveDotSegments($path, $assertion) - { - $this->assertEquals($assertion, Net_URL2::removeDotSegments($path)); - } - - /** - * Test removeDotSegments() loop limit warning - * - * @covers Net_URL2::removeDotSegments - * @return void - */ - public function testRemoveDotSegmentsLoopLimit() - { - $loopLimit = 256; - $segments = str_repeat('a/', $loopLimit); - - @Net_URL2::removeDotSegments($segments . 'b/'); - - $this->_assertLastErrorContains(sprintf(' loop limit %d ', $loopLimit + 1)); - $this->_assertLastErrorContains(" (left: '/b/')"); - } - - /** - * A dataProvider for query strings and their array representation - * - * @see testGetQueryVariables - * @return array - */ - public function provideQueryStrings() - { - // If the second (expected) value is set or not null, parse_str() differs. - // Notes on PHP differences with each entry/block - return array( - // Net_URL2::getQueryVariables() non-bracket mode - array('test=1&t%65st=%41&extra=', - array('test' => array('1', 'A'), 'extra' => ''), - array('::OPTION_USE_BRACKETS' => false)), - array(''), - array('='), - array('key'), - array('key='), - array('=value'), - array('k=v'), - // no space as var-name in PHP (array()): - array(' ', array(' ' => '' )), - array(' =v', array(' ' => 'v')), - array('key=value'), - // PHP replaces ".", " " and "[" in name replaced by "_": - array('key.=value' , array('key.' => 'value')), - array('key =value' , array('key ' => 'value')), - array('key[=value' , array('key[' => 'value')), - array("key\0=value", array("key\0" => 'value')), - array('key]=value'), - array('key[]=value'), - array('[]=value'), - array(']=value'), - array(']]=value'), - // PHP drops variables that are an open bracket only - array('[=value', array('[' => 'value')), - // PHP drops spaces in brackets: - array('key[ ]=value', array('key' => array(' ' => 'value'))), - // PHP replaces space " " in name by "_" - array('key []=1' , array('key ' => array('1' ))) , - // PHP does not support "\0" in var-names: - array("key[\0]=value" , array('key' => array("\0" => 'value' ))), - array("key[a\0]=value" , array('key' => array("a\0" => 'value' ))), - array("key[a\0b]=value" , array('key' => array("a\0b" => 'value'))), - array('var[]=1&var[0][]=2'), - array('key[] []=1'), - array('key[] [] []=1'), - array('key[] [] []'), - array('key[] [] []=[] []'), - array('[] [] []=[] []'), - ); - } - - /** - * Test parsing of query variables - * - * @param string $query string - * @param mixed $expected null to test against parse_str() behavior - * @param array $options Net_URL2 options - * - * @dataProvider provideQueryStrings - * @covers Net_URL2::getQueryVariables - * @covers Net_URL2::_queryArrayByKey - * @covers Net_URL2::_queryArrayByBrackets - * @covers Net_URL2::_queryKeyBracketOffset - * @return void - */ - public function testGetQueryVariables($query, $expected = null, - array $options = array() - ) { - $options = $this->_translateOptionData($options); - - $url = new Net_URL2('', $options); - - if ($expected === null) { - // parse_str() is in PHP before copy on write, therefore - // it uses pass-by-reference for $expected to return - // the array - parse_str($query, $expected); - } - - // Xdebug: If breakpoints are ignored, see Xdebug Issue 0000924 - $url->setQuery($query); - $actual = $url->getQueryVariables(); - - // Do two assertions, because the first one shows a more nice diff in case - // it fails and the second one is actually strict which is what has to be - // tested. - $this->assertEquals($expected, $actual); - $this->assertSame($expected, $actual); - } - - /** - * data provider of host and port - * - * @return array - * @see testHostAndPort - */ - public function provideHostAndPort() - { - return array( - array('[::1]', '[::1]', false), - array('[::1]:', '[::1]', false), - array('[::1]:128', '[::1]', '128'), - array('127.0.0.1', '127.0.0.1', false), - array('127.0.0.1:', '127.0.0.1', false), - array('127.0.0.1:128', '127.0.0.1', '128'), - array('localhost', 'localhost', false), - array('localhost:', 'localhost', false), - array('localhost:128', 'localhost', '128'), - ); - } - - /** - * test that an authority containing host and port maps to expected host and port - * - * This is also a regression test to test that using ip-literals works along- - * side ipv4 and reg-name hosts incl. port numbers - * - * It was reported as Bug #20423 on 2014-10-06 18:25 UTC that - * http://[::1]// URI drops the host - * - * @param string $authority string - * @param string $expectedHost string - * @param string|bool $expectedPort string or FALSE - * - * @return void - * @dataProvider provideHostAndPort - * @covers Net_URL2::setAuthority() - * @link https://pear.php.net/bugs/bug.php?id=20423 - * @link http://tools.ietf.org/html/rfc3986#section-3.2.2 - * @link http://tools.ietf.org/html/rfc3986#section-3.2 - * @link http://tools.ietf.org/html/rfc3986#section-3.2.3 - */ - public function testHostAndPort($authority, $expectedHost, $expectedPort) - { - $uri = "http://{$authority}"; - $url = new Net_URL2($uri); - $this->assertSame($expectedHost, $url->getHost()); - $this->assertSame($expectedPort, $url->getPort()); - } - - /** - * This is a regression test to test that Net_URL2::getQueryVariables() does - * not have a problem with nested array values in form of stacked brackets and - * was reported as Bug #17036 on 2010-01-26 15:48 UTC that there would be - * a problem with parsed query string. - * - * @link https://pear.php.net/bugs/bug.php?id=17036 - * @covers Net_URL2::getQueryVariables - * @return void - */ - public function test17036() - { - $queryString = 'start=10&test[0][first][1.1][20]=coucou'; - $url = new Net_URL2('?' . $queryString); - $vars = $url->getQueryVariables(); - - $expected = array(); - $expected['start'] = '10'; - $expected['test'][0]['first']['1.1'][20] = 'coucou'; - - $this->assertEquals($expected, $vars); // give nice diff in case of failuer - $this->assertSame($expected, $vars); // strictly assert the premise - } - - /** - * This is a regression test to test that resolve() does - * merge the path if the base path is empty as the opposite - * was reported as Bug #19176 on 2011-12-31 02:07 UTC - * - * @return void - */ - public function test19176() - { - $foo = new Net_URL2('http://www.example.com'); - $test = $foo->resolve('test.html')->getURL(); - $this->assertEquals('http://www.example.com/test.html', $test); - } - - /** - * This is a regression test that removeDotSegments('0') is - * working as it was reported as not-working in Bug #19315 - * on 2012-03-04 04:18 UTC. - * - * @return void - */ - public function test19315() - { - $actual = Net_URL2::removeDotSegments('0'); - $this->assertSame('0', $actual); - - $nonStringObject = (object)array(); - try { - Net_URL2::removeDotSegments($nonStringObject); - } catch (PHPUnit_Framework_Error $error) { - $this->addToAssertionCount(1); - } - - if (!isset($error)) { - $this->fail('Failed to verify that error was given.'); - } - unset($error); - } - - /** - * This is a regression test to test that recovering from - * a wrongly encoded URL is possible. - * - * It was requested as Request #19684 on 2011-12-31 02:07 UTC - * that redirects containing spaces should work. - * - * @return void - */ - public function test19684() - { - // Location: URL obtained Thu, 25 Apr 2013 20:51:31 GMT - $urlWithSpace = 'http://www.sigmaaldrich.com/catalog/search?interface=CAS N' - . 'o.&term=108-88-3&lang=en®ion=US&mode=match+partialmax&N=0+2200030' - . '48+219853269+219853286'; - - $urlCorrect = 'http://www.sigmaaldrich.com/catalog/search?interface=CAS%20N' - . 'o.&term=108-88-3&lang=en®ion=US&mode=match+partialmax&N=0+2200030' - . '48+219853269+219853286'; - - $url = new Net_URL2($urlWithSpace); - - $this->assertTrue($url->isAbsolute()); - - $urlPart = parse_url($urlCorrect, PHP_URL_PATH); - $this->assertSame($urlPart, $url->getPath()); - - $urlPart = parse_url($urlCorrect, PHP_URL_QUERY); - $this->assertSame($urlPart, $url->getQuery()); - - $this->assertSame($urlCorrect, (string)$url); - - $input = 'http://example.com/get + + to my nose/'; - $expected = 'http://example.com/get%20+%20+%20to%20my%20nose/'; - $actual = new Net_URL2($input); - $this->assertEquals($expected, $actual); - $actual->normalize(); - } - - /** - * data provider of list of equivalent URLs. - * - * @see testNormalize - * @see testConstructSelf - * @return array - */ - public function provideEquivalentUrlLists() - { - return array( - // String equivalence: - array('http://example.com/', 'http://example.com/'), - - // Originally first dataset: - array('http://www.example.com/%9a', 'http://www.example.com/%9A'), - - // Example from RFC 3986 6.2.2.: - array('example://a/b/c/%7Bfoo%7D', 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d'), - - // Example from RFC 3986 6.2.2.1.: - array('HTTP://www.EXAMPLE.com/', 'http://www.example.com/'), - - // Example from RFC 3986 6.2.3.: - array( - 'http://example.com', 'http://example.com/', - 'http://example.com:/', 'http://example.com:80/' - ), - - // Bug #20161: URLs with "0" as host fail to normalize with empty path - array('http://0/', 'http://0'), - - // Bug #20473: Normalize query and fragment broken - array('foo:///?%66%6f%6f#%62%61%72', 'foo:///?foo#bar'), - ); - } - - /** - * This is a coverage test to invoke the normalize() - * method. - * - * @return void - * - * @dataProvider provideEquivalentUrlLists - */ - public function testNormalize() - { - $urls = func_get_args(); - - $this->assertGreaterThanOrEqual(2, count($urls)); - - $last = null; - - foreach ($urls as $index => $url) { - $url = new Net_Url2($url); - $url->normalize(); - if ($index) { - $this->assertSame((string)$last, (string)$url); - } - $last = $url; - } - } - - /** - * This is a coverage test to invoke __get and __set - * - * @covers Net_URL2::__get - * @covers Net_URL2::__set - * @return void - */ - public function testMagicSetGet() - { - $url = new Net_URL2(''); - - $property = 'authority'; - $url->$property = $value = 'value'; - $this->assertEquals($value, $url->$property); - - $property = 'unsetProperty'; - $url->$property = $value; - $this->assertEquals(false, $url->$property); - } - - /** - * data provider of uri and normal URIs - * - * @return array - * @see testComponentRecompositionAndNormalization - */ - public function provideComposedAndNormalized() - { - return array( - array(''), - array('http:g'), - array('user@host'), - array('mailto:user@host'), - ); - } - - /** - * Tests Net_URL2 RFC 3986 5.3. Component Recomposition in the light - * of normalization - * - * This is also a regression test to test that a missing authority works well - * with normalization - * - * It was reported as Bug #20418 on 2014-10-02 22:10 UTC that there is an - * Incorrect normalization of URI with missing authority - * - * @param string $uri URI - * - * @return void - * @covers Net_URL2::getUrl() - * @covers Net_URL2::normalize() - * @dataProvider provideComposedAndNormalized - * @link https://pear.php.net/bugs/bug.php?id=20418 - * @see testExampleUri - */ - public function testComponentRecompositionAndNormalization($uri) - { - $url = new Net_URL2($uri); - $this->assertSame($uri, $url->getURL()); - $url->normalize(); - $this->assertSame($uri, $url->getURL()); - } - - /** - * Tests Net_URL2 ctors URL parameter works with objects implementing - * __toString(). - * - * @dataProvider provideEquivalentUrlLists - * @coversNothing - * @return void - */ - public function testConstructSelf() - { - $urls = func_get_args(); - foreach ($urls as $url) { - $urlA = new Net_URL2($url); - $urlB = new Net_URL2($urlA); - $this->assertSame((string)$urlA, (string)$urlB); - } - } - - /** - * This is a feature test to see that the userinfo's data is getting - * encoded as outlined in #19684. - * - * @covers Net_URL2::setAuthority - * @covers Net_URL2::setUserinfo - * @return void - */ - public function testEncodeDataUserinfoAuthority() - { - $url = new Net_URL2('http://john doe:secret@example.com/'); - $this->assertSame('http://john%20doe:secret@example.com/', (string)$url); - - $url->setUserinfo('john doe'); - $this->assertSame('http://john%20doe@example.com/', (string)$url); - - $url->setUserinfo('john doe', 'pa wd'); - $this->assertSame('http://john%20doe:pa%20wd@example.com/', (string)$url); - } - - /** - * This is a regression test to test that using the - * host-name "0" does work with getAuthority() - * - * It was reported as Bug #20156 on 2013-12-27 22:56 UTC - * that setAuthority() with "0" as host would not work - * - * @covers Net_URL2::setAuthority - * @covers Net_URL2::getAuthority - * @covers Net_URL2::setHost - * @return void - */ - public function test20156() - { - $url = new Net_URL2('http://user:pass@example.com:127/'); - $host = '0'; - $url->setHost($host); - $this->assertSame('user:pass@0:127', $url->getAuthority()); - - $url->setHost(false); - $this->assertSame(false, $url->getAuthority()); - - $url->setAuthority($host); - $this->assertSame($host, $url->getAuthority()); - } - - /** - * This is a regression test to test that setting "0" as path - * does not break normalize(). - * - * It was reported as Bug #20157 on 2013-12-27 23:42 UTC that - * normalize() with "0" as path would not work. - * - * @covers Net_URL2::normalize - * @return void - */ - public function test20157() - { - $subject = 'http://example.com'; - $url = new Net_URL2($subject); - $url->setPath('0'); - $url->normalize(); - $this->assertSame("$subject/0", (string)$url); - } - - /** - * This is a regression test to ensure that fragment-only references can be - * resolved to a non-absolute Base-URI. - * - * It was reported as Bug #20158 2013-12-28 14:49 UTC that fragment-only - * references would not be resolved to non-absolute base URI - * - * @covers Net_URL2::resolve - * @covers Net_URL2::_isFragmentOnly - * @return void - */ - public function test20158() - { - $base = new Net_URL2('myfile.html'); - $resolved = $base->resolve('#world'); - $this->assertSame('myfile.html#world', (string)$resolved); - } - - /** - * This is a regression test to ensure that authority and path are properly - * combined when the path does not start with a slash which is the separator - * character between authority and path. - * - * It was reported as Bug #20159 2013-12-28 17:18 UTC that authority - * would not be terminated by slash - * - * @covers Net_URL2::getUrl - * @return void - */ - public function test20159() - { - $url = new Net_URL2('index.html'); - $url->setHost('example.com'); - $this->assertSame('//example.com/index.html', (string)$url); - } - - /** - * This is a regression test to test that using the file:// URI scheme with - * an empty (default) hostname has the empty authority preserved when the - * full URL is build. - * - * It was reported as Bug #20304 on 2014-06-21 00:06 UTC - * that file:// URI are crippled. - * - * Tests with a default authority for the "file" URI scheme - * - * @covers Net_URL2::getURL - * @return void - * @link https://pear.php.net/bugs/bug.php?id=20304 - */ - public function test20304() - { - $file = 'file:///path/to/file'; - $url = new Net_URL2($file); - $this->assertSame($file, (string) $url); - - $file = 'file://localhost/path/to/file'; - $url = new Net_URL2($file); - $this->assertSame($file, (string) $url); - - $file = 'file://user@/path/to/file'; - $url = new Net_URL2($file); - $this->assertSame($file, (string) $url); - - $file = 'FILE:///path/to/file'; - $url = new Net_URL2($file); - $this->assertSame($file, (string) $url); - } -} diff --git a/vendor/pear/pear_exception/.gitignore b/vendor/pear/pear_exception/.gitignore deleted file mode 100644 index 479265b07..000000000 --- a/vendor/pear/pear_exception/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -PEAR_Exception*.tgz - -# composer related -composer.lock -composer.phar -vendor diff --git a/vendor/pear/pear_exception/.travis.yml b/vendor/pear/pear_exception/.travis.yml deleted file mode 100644 index 18875d993..000000000 --- a/vendor/pear/pear_exception/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: php -php: - - 5.6 - - 5.5 - - 5.4 -script: - - cd tests && phpunit --coverage-text . diff --git a/vendor/pear/pear_exception/LICENSE b/vendor/pear/pear_exception/LICENSE deleted file mode 100644 index a00a2421f..000000000 --- a/vendor/pear/pear_exception/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 1997-2009, - Stig Bakken , - Gregory Beaver , - Helgi Þormar Þorbjörnsson , - Tomas V.V.Cox , - Martin Jansen . -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/pear/pear_exception/PEAR/Exception.php b/vendor/pear/pear_exception/PEAR/Exception.php deleted file mode 100644 index 5abf4f84a..000000000 --- a/vendor/pear/pear_exception/PEAR/Exception.php +++ /dev/null @@ -1,456 +0,0 @@ - - * @author Hans Lellelid - * @author Bertrand Mansion - * @author Greg Beaver - * @copyright 1997-2009 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @link http://pear.php.net/package/PEAR_Exception - * @since File available since Release 1.0.0 - */ - - -/** - * Base PEAR_Exception Class - * - * 1) Features: - * - * - Nestable exceptions (throw new PEAR_Exception($msg, $prev_exception)) - * - Definable triggers, shot when exceptions occur - * - Pretty and informative error messages - * - Added more context info available (like class, method or cause) - * - cause can be a PEAR_Exception or an array of mixed - * PEAR_Exceptions/PEAR_ErrorStack warnings - * - callbacks for specific exception classes and their children - * - * 2) Ideas: - * - * - Maybe a way to define a 'template' for the output - * - * 3) Inherited properties from PHP Exception Class: - * - * protected $message - * protected $code - * protected $line - * protected $file - * private $trace - * - * 4) Inherited methods from PHP Exception Class: - * - * __clone - * __construct - * getMessage - * getCode - * getFile - * getLine - * getTraceSafe - * getTraceSafeAsString - * __toString - * - * 5) Usage example - * - * - * require_once 'PEAR/Exception.php'; - * - * class Test { - * function foo() { - * throw new PEAR_Exception('Error Message', ERROR_CODE); - * } - * } - * - * function myLogger($pear_exception) { - * echo $pear_exception->getMessage(); - * } - * // each time a exception is thrown the 'myLogger' will be called - * // (its use is completely optional) - * PEAR_Exception::addObserver('myLogger'); - * $test = new Test; - * try { - * $test->foo(); - * } catch (PEAR_Exception $e) { - * print $e; - * } - * - * - * @category PEAR - * @package PEAR_Exception - * @author Tomas V.V.Cox - * @author Hans Lellelid - * @author Bertrand Mansion - * @author Greg Beaver - * @copyright 1997-2009 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: @package_version@ - * @link http://pear.php.net/package/PEAR_Exception - * @since Class available since Release 1.0.0 - */ -class PEAR_Exception extends Exception -{ - const OBSERVER_PRINT = -2; - const OBSERVER_TRIGGER = -4; - const OBSERVER_DIE = -8; - protected $cause; - private static $_observers = array(); - private static $_uniqueid = 0; - private $_trace; - - /** - * Supported signatures: - * - PEAR_Exception(string $message); - * - PEAR_Exception(string $message, int $code); - * - PEAR_Exception(string $message, Exception $cause); - * - PEAR_Exception(string $message, Exception $cause, int $code); - * - PEAR_Exception(string $message, PEAR_Error $cause); - * - PEAR_Exception(string $message, PEAR_Error $cause, int $code); - * - PEAR_Exception(string $message, array $causes); - * - PEAR_Exception(string $message, array $causes, int $code); - * - * @param string $message exception message - * @param int|Exception|PEAR_Error|array|null $p2 exception cause - * @param int|null $p3 exception code or null - */ - public function __construct($message, $p2 = null, $p3 = null) - { - if (is_int($p2)) { - $code = $p2; - $this->cause = null; - } elseif (is_object($p2) || is_array($p2)) { - // using is_object allows both Exception and PEAR_Error - if (is_object($p2) && !($p2 instanceof Exception)) { - if (!class_exists('PEAR_Error') || !($p2 instanceof PEAR_Error)) { - throw new PEAR_Exception( - 'exception cause must be Exception, ' . - 'array, or PEAR_Error' - ); - } - } - $code = $p3; - if (is_array($p2) && isset($p2['message'])) { - // fix potential problem of passing in a single warning - $p2 = array($p2); - } - $this->cause = $p2; - } else { - $code = null; - $this->cause = null; - } - parent::__construct($message, $code); - $this->signal(); - } - - /** - * Add an exception observer - * - * @param mixed $callback - A valid php callback, see php func is_callable() - * - A PEAR_Exception::OBSERVER_* constant - * - An array(const PEAR_Exception::OBSERVER_*, - * mixed $options) - * @param string $label The name of the observer. Use this if you want - * to remove it later with removeObserver() - * - * @return void - */ - public static function addObserver($callback, $label = 'default') - { - self::$_observers[$label] = $callback; - } - - /** - * Remove an exception observer - * - * @param string $label Name of the observer - * - * @return void - */ - public static function removeObserver($label = 'default') - { - unset(self::$_observers[$label]); - } - - /** - * Generate a unique ID for an observer - * - * @return int unique identifier for an observer - */ - public static function getUniqueId() - { - return self::$_uniqueid++; - } - - /** - * Send a signal to all observers - * - * @return void - */ - protected function signal() - { - foreach (self::$_observers as $func) { - if (is_callable($func)) { - call_user_func($func, $this); - continue; - } - settype($func, 'array'); - switch ($func[0]) { - case self::OBSERVER_PRINT : - $f = (isset($func[1])) ? $func[1] : '%s'; - printf($f, $this->getMessage()); - break; - case self::OBSERVER_TRIGGER : - $f = (isset($func[1])) ? $func[1] : E_USER_NOTICE; - trigger_error($this->getMessage(), $f); - break; - case self::OBSERVER_DIE : - $f = (isset($func[1])) ? $func[1] : '%s'; - die(printf($f, $this->getMessage())); - break; - default: - trigger_error('invalid observer type', E_USER_WARNING); - } - } - } - - /** - * Return specific error information that can be used for more detailed - * error messages or translation. - * - * This method may be overridden in child exception classes in order - * to add functionality not present in PEAR_Exception and is a placeholder - * to define API - * - * The returned array must be an associative array of parameter => value like so: - *
-     * array('name' => $name, 'context' => array(...))
-     * 
- * - * @return array - */ - public function getErrorData() - { - return array(); - } - - /** - * Returns the exception that caused this exception to be thrown - * - * @return Exception|array The context of the exception - */ - public function getCause() - { - return $this->cause; - } - - /** - * Function must be public to call on caused exceptions - * - * @param array $causes Array that gets filled. - * - * @return void - */ - public function getCauseMessage(&$causes) - { - $trace = $this->getTraceSafe(); - $cause = array('class' => get_class($this), - 'message' => $this->message, - 'file' => 'unknown', - 'line' => 'unknown'); - if (isset($trace[0])) { - if (isset($trace[0]['file'])) { - $cause['file'] = $trace[0]['file']; - $cause['line'] = $trace[0]['line']; - } - } - $causes[] = $cause; - if ($this->cause instanceof PEAR_Exception) { - $this->cause->getCauseMessage($causes); - } elseif ($this->cause instanceof Exception) { - $causes[] = array('class' => get_class($this->cause), - 'message' => $this->cause->getMessage(), - 'file' => $this->cause->getFile(), - 'line' => $this->cause->getLine()); - } elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) { - $causes[] = array('class' => get_class($this->cause), - 'message' => $this->cause->getMessage(), - 'file' => 'unknown', - 'line' => 'unknown'); - } elseif (is_array($this->cause)) { - foreach ($this->cause as $cause) { - if ($cause instanceof PEAR_Exception) { - $cause->getCauseMessage($causes); - } elseif ($cause instanceof Exception) { - $causes[] = array('class' => get_class($cause), - 'message' => $cause->getMessage(), - 'file' => $cause->getFile(), - 'line' => $cause->getLine()); - } elseif (class_exists('PEAR_Error') - && $cause instanceof PEAR_Error - ) { - $causes[] = array('class' => get_class($cause), - 'message' => $cause->getMessage(), - 'file' => 'unknown', - 'line' => 'unknown'); - } elseif (is_array($cause) && isset($cause['message'])) { - // PEAR_ErrorStack warning - $causes[] = array( - 'class' => $cause['package'], - 'message' => $cause['message'], - 'file' => isset($cause['context']['file']) ? - $cause['context']['file'] : - 'unknown', - 'line' => isset($cause['context']['line']) ? - $cause['context']['line'] : - 'unknown', - ); - } - } - } - } - - /** - * Build a backtrace and return it - * - * @return array Backtrace - */ - public function getTraceSafe() - { - if (!isset($this->_trace)) { - $this->_trace = $this->getTrace(); - if (empty($this->_trace)) { - $backtrace = debug_backtrace(); - $this->_trace = array($backtrace[count($backtrace)-1]); - } - } - return $this->_trace; - } - - /** - * Gets the first class of the backtrace - * - * @return string Class name - */ - public function getErrorClass() - { - $trace = $this->getTraceSafe(); - return $trace[0]['class']; - } - - /** - * Gets the first method of the backtrace - * - * @return string Method/function name - */ - public function getErrorMethod() - { - $trace = $this->getTraceSafe(); - return $trace[0]['function']; - } - - /** - * Converts the exception to a string (HTML or plain text) - * - * @return string String representation - * - * @see toHtml() - * @see toText() - */ - public function __toString() - { - if (isset($_SERVER['REQUEST_URI'])) { - return $this->toHtml(); - } - return $this->toText(); - } - - /** - * Generates a HTML representation of the exception - * - * @return string HTML code - */ - public function toHtml() - { - $trace = $this->getTraceSafe(); - $causes = array(); - $this->getCauseMessage($causes); - $html = '' . "\n"; - foreach ($causes as $i => $cause) { - $html .= '\n"; - } - $html .= '' . "\n" - . '' - . '' - . '' . "\n"; - - foreach ($trace as $k => $v) { - $html .= '' - . '' - . '' . "\n"; - } - $html .= '' - . '' - . '' . "\n" - . '
' - . str_repeat('-', $i) . ' ' . $cause['class'] . ': ' - . htmlspecialchars($cause['message']) - . ' in ' . $cause['file'] . ' ' - . 'on line ' . $cause['line'] . '' - . "
Exception trace
#FunctionLocation
' . $k . ''; - if (!empty($v['class'])) { - $html .= $v['class'] . $v['type']; - } - $html .= $v['function']; - $args = array(); - if (!empty($v['args'])) { - foreach ($v['args'] as $arg) { - if (is_null($arg)) { - $args[] = 'null'; - } else if (is_array($arg)) { - $args[] = 'Array'; - } else if (is_object($arg)) { - $args[] = 'Object('.get_class($arg).')'; - } else if (is_bool($arg)) { - $args[] = $arg ? 'true' : 'false'; - } else if (is_int($arg) || is_double($arg)) { - $args[] = $arg; - } else { - $arg = (string)$arg; - $str = htmlspecialchars(substr($arg, 0, 16)); - if (strlen($arg) > 16) { - $str .= '…'; - } - $args[] = "'" . $str . "'"; - } - } - } - $html .= '(' . implode(', ', $args) . ')' - . '' . (isset($v['file']) ? $v['file'] : 'unknown') - . ':' . (isset($v['line']) ? $v['line'] : 'unknown') - . '
' . ($k+1) . '{main} 
'; - return $html; - } - - /** - * Generates text representation of the exception and stack trace - * - * @return string - */ - public function toText() - { - $causes = array(); - $this->getCauseMessage($causes); - $causeMsg = ''; - foreach ($causes as $i => $cause) { - $causeMsg .= str_repeat(' ', $i) . $cause['class'] . ': ' - . $cause['message'] . ' in ' . $cause['file'] - . ' on line ' . $cause['line'] . "\n"; - } - return $causeMsg . $this->getTraceAsString(); - } -} -?> diff --git a/vendor/pear/pear_exception/composer.json b/vendor/pear/pear_exception/composer.json deleted file mode 100644 index ce33ed1c8..000000000 --- a/vendor/pear/pear_exception/composer.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "pear/pear_exception", - "description": "The PEAR Exception base class.", - "type": "class", - "keywords": [ - "exception" - ], - "homepage": "https://github.com/pear/PEAR_Exception", - "license": "BSD-2-Clause", - "authors": [ - { - "name": "Helgi Thormar", - "email": "dufuz@php.net" - }, - { - "name": "Greg Beaver", - "email": "cellog@php.net" - } - ], - "require": { - "php": ">=4.4.0" - }, - "autoload": { - "psr-0": { - "PEAR": "" - } - }, - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "include-path": [ - "." - ], - "support": { - "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=PEAR_Exception", - "source": "https://github.com/pear/PEAR_Exception" - }, - "require-dev": { - "phpunit/phpunit": "*" - } -} diff --git a/vendor/pear/pear_exception/package.xml b/vendor/pear/pear_exception/package.xml deleted file mode 100644 index 98290c6a8..000000000 --- a/vendor/pear/pear_exception/package.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - PEAR_Exception - pear.php.net - The PEAR Exception base class - PEAR_Exception PHP5 error handling mechanism - - - Christian Weiske - cweiske - cweiske@php.net - yes - - - Helgi Thormar - dufuz - dufuz@php.net - no - - - Greg Beaver - cellog - cellog@php.net - no - - - 2015-02-10 - - - 1.0.0 - 1.0.0 - - - stable - stable - - New BSD License - - This package was split out from the PEAR package. - If you use PEAR_Exception in your package and use nothing from the PEAR package - then it's better to depend on just PEAR_Exception. - - - - - - - - - - - - - - - - - - 5.4.0 - - - 1.9.5 - - - - - - - - - - 1.0.0 - 1.0.0 - - - stable - stable - - 2015-02-10 - New BSD License - Release stable version - - - - - 1.0.0beta2 - 1.0.0 - - - beta - stable - - 2014-02-21 - New BSD License - Bump up PEAR dependency. - - - - - 1.0.0beta1 - 1.0.0 - - - beta - stable - - 2012-05-10 - New BSD License - -This packge was split out from the PEAR package. If you use PEAR_Exception in your package -and use nothing from the PEAR package then it's better to depend on just PEAR_Exception. - - - - diff --git a/vendor/pear/pear_exception/tests/PEAR/ExceptionTest.php b/vendor/pear/pear_exception/tests/PEAR/ExceptionTest.php deleted file mode 100644 index 61d2df4f1..000000000 --- a/vendor/pear/pear_exception/tests/PEAR/ExceptionTest.php +++ /dev/null @@ -1,78 +0,0 @@ -assertNull($e->getCause()); - } - - public function testGetCauseException() - { - $cause = new Exception('foo bar'); - $e = new PEAR_Exception('I caught an exception', $cause); - $this->assertNotNull($e->getCause()); - $this->assertInstanceOf('Exception', $e->getCause()); - $this->assertEquals($cause, $e->getCause()); - } - - public function testGetCauseMessage() - { - $cause = new Exception('foo bar'); - $e = new PEAR_Exception('I caught an exception', $cause); - - $e->getCauseMessage($causes); - $this->assertEquals('I caught an exception', $causes[0]['message']); - $this->assertEquals('foo bar', $causes[1]['message']); - } - - public function testGetTraceSafe() - { - $e = new PEAR_Exception('oops'); - $this->assertInternalType('array', $e->getTraceSafe()); - } - - public function testGetErrorClass() - { - $e = new PEAR_Exception('oops'); - $this->assertEquals('PEAR_ExceptionTest', $e->getErrorClass()); - } - - public function testGetErrorMethod() - { - $e = new PEAR_Exception('oops'); - $this->assertEquals('testGetErrorMethod', $e->getErrorMethod()); - } - - public function test__toString() - { - $e = new PEAR_Exception('oops'); - $this->assertInternalType('string', (string) $e); - $this->assertContains('oops', (string) $e); - } - - public function testToHtml() - { - $e = new PEAR_Exception('oops'); - $html = $e->toHtml(); - $this->assertInternalType('string', $html); - $this->assertContains('oops', $html); - } -} -?>