diff --git a/composer.json b/composer.json index 287c6171cd7404b15068f0ab5e379b2757923ff8..125c633d81a3f5a18d3e1cfdaf1b1656048bf6a1 100755 --- a/composer.json +++ b/composer.json @@ -8,7 +8,6 @@ "Docserver\\" : "src/app/docserver/", "Document\\" : "src/app/document/", "History\\" : "src/app/history/", - "Resource\\" : "src/app/resource/", "Status\\" : "src/app/status/", "User\\" : "src/app/user/" } @@ -16,11 +15,6 @@ "require": { "slim/slim": "^3.10", "respect/validation": "^1.1", - "php-http/curl-client": "^1.7", - "m4tthumphrey/php-gitlab-api": "9.5", - "jumbojett/openid-connect-php": "^0.3.0", - "zf1/zend-search-lucene": "~1.12", - "setasign/fpdi-tcpdf": "^2.0.0", - "php-http/guzzle6-adapter": "^1.1" + "setasign/fpdi-tcpdf": "^2.0.0" } } diff --git a/src/core/controllers/AuthenticationController.php b/src/core/controllers/AuthenticationController.php index 3a0ddeac0aa3fe20d85cd682ff6965dfd6272b60..c0b7f40c6650b9bca37fe002ce4a39fc50d0b4e6 100755 --- a/src/core/controllers/AuthenticationController.php +++ b/src/core/controllers/AuthenticationController.php @@ -54,14 +54,14 @@ class AuthenticationController return $response->withStatus(401)->withJson(['errors' => 'Authentication Failed']); } - $user = UserModel::getByEmail(['email' => $data['email'], 'select' => ['id', 'email', 'firstname', 'lastname', 'mode']]); + $user = UserModel::getByEmail(['email' => $data['email'], 'select' => ['mode']]); if ($user['mode'] != 'standard') { return $response->withStatus(403)->withJson(['errors' => 'Login unauthorized']); } AuthenticationModel::setCookieAuth(['email' => $data['email']]); - return $response->withJson(['user' => $user]); + return $response->withJson(['success' => 'success']); } public static function logout(Request $request, Response $response) diff --git a/vendor/autoload.php b/vendor/autoload.php old mode 100755 new mode 100644 index fe0dd20cce02d29f13f9a35368047581beaec531..ea2e3dbc68ab29f98adaaeaf6dd96062825bf990 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitf21aebccfa6df888200dcb099aa69fbd::getLoader(); +return ComposerAutoloaderInit637514d10f1ed5d4c55a005a428a3656::getLoader(); diff --git a/vendor/clue/stream-filter/.gitignore b/vendor/clue/stream-filter/.gitignore deleted file mode 100755 index de4a392c3313c89428ffe2a939f8744aae16b81b..0000000000000000000000000000000000000000 --- a/vendor/clue/stream-filter/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/vendor -/composer.lock diff --git a/vendor/clue/stream-filter/.travis.yml b/vendor/clue/stream-filter/.travis.yml deleted file mode 100755 index a71864a38ff9d7f8698624973048eb4cb57566a7..0000000000000000000000000000000000000000 --- a/vendor/clue/stream-filter/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: php - -php: -# - 5.3 # requires old distro, see below - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - hhvm # ignore errors, see below - -# lock distro so new future defaults will not break the build -dist: trusty - -matrix: - include: - - php: 5.3 - dist: precise - allow_failures: - - php: hhvm - -install: - - composer install --no-interaction - -script: - - vendor/bin/phpunit --coverage-text diff --git a/vendor/clue/stream-filter/CHANGELOG.md b/vendor/clue/stream-filter/CHANGELOG.md deleted file mode 100755 index 9d53cd83d45de899896e4ee3261c891c469e7394..0000000000000000000000000000000000000000 --- a/vendor/clue/stream-filter/CHANGELOG.md +++ /dev/null @@ -1,54 +0,0 @@ -# Changelog - -## 1.4.0 (2017-08-18) - -* Feature / Fix: The `fun()` function does not pass filter parameter `null` - to underlying `stream_filter_append()` by default - (#15 by @Nyholm) - - Certain filters (such as `convert.quoted-printable-encode`) do not accept - a filter parameter at all. If no explicit filter parameter is given, we no - longer pass a default `null` value. - - ```php - $encode = Filter\fun('convert.quoted-printable-encode'); - assert('t=C3=A4st' === $encode('täst')); - ``` - -* Add examples and improve documentation - (#13 and #20 by @clue and #18 by @Nyholm) - -* Improve test suite by adding PHPUnit to require-dev, - fix HHVM build for now again and ignore future HHVM build errors, - lock Travis distro so new future defaults will not break the build - and test on PHP 7.1 - (#12, #14 and #19 by @clue and #16 by @Nyholm) - -## 1.3.0 (2015-11-08) - -* Feature: Support accessing built-in filters as callbacks - (#5 by @clue) - - ```php - $fun = Filter\fun('zlib.deflate'); - - $ret = $fun('hello') . $fun('world') . $fun(); - assert('helloworld' === gzinflate($ret)); - ``` - -## 1.2.0 (2015-10-23) - -* Feature: Invoke close event when closing filter (flush buffer) - (#9 by @clue) - -## 1.1.0 (2015-10-22) - -* Feature: Abort filter operation when catching an Exception - (#10 by @clue) - -* Feature: Additional safeguards to prevent filter state corruption - (#7 by @clue) - -## 1.0.0 (2015-10-18) - -* First tagged release diff --git a/vendor/clue/stream-filter/LICENSE b/vendor/clue/stream-filter/LICENSE deleted file mode 100755 index dc09d1e6caf350c70107dc7680f65c41e852bfee..0000000000000000000000000000000000000000 --- a/vendor/clue/stream-filter/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Christian Lück - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/clue/stream-filter/README.md b/vendor/clue/stream-filter/README.md deleted file mode 100755 index d46c2b5714f10c360c6d92535c99069e61314350..0000000000000000000000000000000000000000 --- a/vendor/clue/stream-filter/README.md +++ /dev/null @@ -1,297 +0,0 @@ -# clue/stream-filter [](https://travis-ci.org/clue/php-stream-filter) - -A simple and modern approach to stream filtering in PHP - -**Table of contents** - -* [Why?](#why) -* [Usage](#usage) - * [append()](#append) - * [prepend()](#prepend) - * [fun()](#fun) - * [remove()](#remove) -* [Install](#install) -* [Tests](#tests) -* [License](#license) - -## Why? - -PHP's stream filtering system is great! - -It offers very powerful stream filtering options and comes with a useful set of built-in filters. -These filters can be used to easily and efficiently perform various transformations on-the-fly, such as: - -* read from a gzip'ed input file, -* transcode from ISO-8859-1 (Latin1) to UTF-8, -* write to a bzip output file -* and much more. - -But let's face it: -Its API is [*difficult to work with*](http://php.net/manual/en/php-user-filter.filter.php) -and its documentation is [*subpar*](http://stackoverflow.com/questions/27103269/what-is-a-bucket-brigade). -This combined means its powerful features are often neglected. - -This project aims to make these features more accessible to a broader audience. -* **Lightweight, SOLID design** - - Provides a thin abstraction that is [*just good enough*](http://en.wikipedia.org/wiki/Principle_of_good_enough) - and does not get in your way. - Custom filters require trivial effort. -* **Good test coverage** - - Comes with an automated tests suite and is regularly tested in the *real world* - -## Usage - -This lightweight library consists only of a few simple functions. -All functions reside under the `Clue\StreamFilter` namespace. - -The below examples assume you use an import statement similar to this: - -```php -use Clue\StreamFilter as Filter; - -Filter\append(…); -``` - -Alternatively, you can also refer to them with their fully-qualified name: - -```php -\Clue\StreamFilter\append(…); -``` - -### append() - -The `append($stream, $callback, $read_write = STREAM_FILTER_ALL)` function can be used to -append a filter callback to the given stream. - -Each stream can have a list of filters attached. -This function appends a filter to the end of this list. - -This function returns a filter resource which can be passed to [`remove()`](#remove). -If the given filter can not be added, it throws an `Exception`. - -The `$stream` can be any valid stream resource, such as: - -```php -$stream = fopen('demo.txt', 'w+'); -``` - -The `$callback` should be a valid callable function which accepts an individual chunk of data -and should return the updated chunk: - -```php -$filter = Filter\append($stream, function ($chunk) { - // will be called each time you read or write a $chunk to/from the stream - return $chunk; -}); -``` - -As such, you can also use native PHP functions or any other `callable`: - -```php -Filter\append($stream, 'strtoupper'); - -// will write "HELLO" to the underlying stream -fwrite($stream, 'hello'); -``` - -If the `$callback` accepts invocation without parameters, then this signature -will be invoked once ending (flushing) the filter: - -```php -Filter\append($stream, function ($chunk = null) { - if ($chunk === null) { - // will be called once ending the filter - return 'end'; - } - // will be called each time you read or write a $chunk to/from the stream - return $chunk; -}); - -fclose($stream); -``` - -> Note: Legacy PHP versions (PHP < 5.4) do not support passing additional data -from the end signal handler if the stream is being closed. - -If your callback throws an `Exception`, then the filter process will be aborted. -In order to play nice with PHP's stream handling, the `Exception` will be -transformed to a PHP warning instead: - -```php -Filter\append($stream, function ($chunk) { - throw new \RuntimeException('Unexpected chunk'); -}); - -// raises an E_USER_WARNING with "Error invoking filter: Unexpected chunk" -fwrite($stream, 'hello'); -``` - -The optional `$read_write` parameter can be used to only invoke the `$callback` when either writing to the stream or only when reading from the stream: - -```php -Filter\append($stream, function ($chunk) { - // will be called each time you write to the stream - return $chunk; -}, STREAM_FILTER_WRITE); - -Filter\append($stream, function ($chunk) { - // will be called each time you read from the stream - return $chunk; -}, STREAM_FILTER_READ); -``` - -> Note that once a filter has been added to stream, the stream can no longer be passed to -> [`stream_select()`](http://php.net/manual/en/function.stream-select.php) -> (and family). -> -> > Warning: stream_select(): cannot cast a filtered stream on this system in {file} on line {line} -> -> This is due to limitations of PHP's stream filter support, as it can no longer reliably -> tell when the underlying stream resource is actually ready. -> As an alternative, consider calling `stream_select()` on the unfiltered stream and -> then pass the unfiltered data through the [`fun()`](#fun) function. - -### prepend() - -The `prepend($stream, $callback, $read_write = STREAM_FILTER_ALL)` function can be used to -prepend a filter callback to the given stream. - -Each stream can have a list of filters attached. -This function prepends a filter to the start of this list. - -This function returns a filter resource which can be passed to [`remove()`](#remove). -If the given filter can not be added, it throws an `Exception`. - -```php -$filter = Filter\prepend($stream, function ($chunk) { - // will be called each time you read or write a $chunk to/from the stream - return $chunk; -}); -``` - -Except for the position in the list of filters, this function behaves exactly -like the [`append()`](#append) function. -For more details about its behavior, see also the [`append()`](#append) function. - -### fun() - -The `fun($filter, $parameters = null)` function can be used to -create a filter function which uses the given built-in `$filter`. - -PHP comes with a useful set of [built-in filters](http://php.net/manual/en/filters.php). -Using `fun()` makes accessing these as easy as passing an input string to filter -and getting the filtered output string. - -```php -$fun = Filter\fun('string.rot13'); - -assert('grfg' === $fun('test')); -assert('test' === $fun($fun('test')); -``` - -Please note that not all filter functions may be available depending on installed -PHP extensions and the PHP version in use. -In particular, [HHVM](http://hhvm.com/) may not offer the same filter functions -or parameters as Zend PHP. -Accessing an unknown filter function will result in a `RuntimeException`: - -```php -Filter\fun('unknown'); // throws RuntimeException -``` - -Some filters may accept or require additional filter parameters – most -filters do not require filter parameters. -If given, the optional `$parameters` argument will be passed to the -underlying filter handler as-is. -In particular, note how *not passing* this parameter at all differs from -explicitly passing a `null` value (which many filters do not accept). -Please refer to the individual filter definition for more details. -For example, the `string.strip_tags` filter can be invoked like this: - -```php -$fun = Filter\fun('string.strip_tags', '<a><b>'); - -$ret = $fun('<b>h<br>i</b>'); -assert('<b>hi</b>' === $ret); -``` - -Under the hood, this function allocates a temporary memory stream, so it's -recommended to clean up the filter function after use. -Also, some filter functions (in particular the -[zlib compression filters](http://php.net/manual/en/filters.compression.php)) -may use internal buffers and may emit a final data chunk on close. -The filter function can be closed by invoking without any arguments: - -```php -$fun = Filter\fun('zlib.deflate'); - -$ret = $fun('hello') . $fun('world') . $fun(); -assert('helloworld' === gzinflate($ret)); -``` - -The filter function must not be used anymore after it has been closed. -Doing so will result in a `RuntimeException`: - -```php -$fun = Filter\fun('string.rot13'); -$fun(); - -$fun('test'); // throws RuntimeException -``` - -> Note: If you're using the zlib compression filters, then you should be wary -about engine inconsistencies between different PHP versions and HHVM. -These inconsistencies exist in the underlying PHP engines and there's little we -can do about this in this library. -[Our test suite](tests/) contains several test cases that exhibit these issues. -If you feel some test case is missing or outdated, we're happy to accept PRs! :) - -### remove() - -The `remove($filter)` function can be used to -remove a filter previously added via [`append()`](#append) or [`prepend()`](#prepend). - -```php -$filter = Filter\append($stream, function () { - // … -}); -Filter\remove($filter); -``` - -## Install - -The recommended way to install this library is [through Composer](https://getcomposer.org). -[New to Composer?](https://getcomposer.org/doc/00-intro.md) - -This will install the latest supported version: - -```bash -$ composer require clue/stream-filter:^1.4 -``` - -See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades. - -This project aims to run on any platform and thus does not require any PHP -extensions and supports running on legacy PHP 5.3 through current PHP 7+ and -HHVM. -It's *highly recommended to use PHP 7+* for this project. -Older PHP versions may suffer from a number of inconsistencies documented above. - -## Tests - -To run the test suite, you first need to clone this repo and then install all -dependencies [through Composer](http://getcomposer.org): - -```bash -$ composer install -``` - -To run the test suite, go to the project root and run: - -```bash -$ php vendor/bin/phpunit -``` - -## License - -MIT diff --git a/vendor/clue/stream-filter/composer.json b/vendor/clue/stream-filter/composer.json deleted file mode 100755 index f8710531858e93b6994090f93815fb0bbc1d0b10..0000000000000000000000000000000000000000 --- a/vendor/clue/stream-filter/composer.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "clue/stream-filter", - "description": "A simple and modern approach to stream filtering in PHP", - "keywords": ["stream", "callback", "filter", "php_user_filter", "stream_filter_append", "stream_filter_register", "bucket brigade"], - "homepage": "https://github.com/clue/php-stream-filter", - "license": "MIT", - "authors": [ - { - "name": "Christian Lück", - "email": "christian@lueck.tv" - } - ], - "require": { - "php": ">=5.3" - }, - "require-dev": { - "phpunit/phpunit": "^5.0 || ^4.8" - }, - "autoload": { - "psr-4": { "Clue\\StreamFilter\\": "src/" }, - "files": [ "src/functions.php" ] - } -} diff --git a/vendor/clue/stream-filter/examples/base64_decode.php b/vendor/clue/stream-filter/examples/base64_decode.php deleted file mode 100755 index 2b49f1029d1f985ae8d9a1dc9cf9d723a57ff463..0000000000000000000000000000000000000000 --- a/vendor/clue/stream-filter/examples/base64_decode.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -// $ echo test | php examples/base64_encode.php | php examples/base64_decode.php - -require __DIR__ . '/../vendor/autoload.php'; - -// decoding requires buffering in chunks of 4 bytes each -$buffer = ''; -Clue\StreamFilter\append(STDIN, function ($chunk = null) use (&$buffer) { - if ($chunk === null) { - if (strlen($buffer) % 4 !== 0) { - throw new \UnexpectedValueException('Invalid length'); - } - $chunk = $buffer; - } else { - $buffer .= $chunk; - $len = strlen($buffer) - (strlen($buffer) % 4); - $chunk = (string)substr($buffer, 0, $len); - $buffer = (string)substr($buffer, $len); - } - - $ret = base64_decode($chunk, true); - if ($ret === false) { - throw new \UnexpectedValueException('Not a valid base64 encoded chunk'); - } - return $ret; -}, STREAM_FILTER_READ); - -fpassthru(STDIN); diff --git a/vendor/clue/stream-filter/examples/base64_encode.php b/vendor/clue/stream-filter/examples/base64_encode.php deleted file mode 100755 index fed78acb881f699b62387258dc6f0e97d4f465e4..0000000000000000000000000000000000000000 --- a/vendor/clue/stream-filter/examples/base64_encode.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -// $ echo test | php examples/base64_encode.php | base64 --decode - -require __DIR__ . '/../vendor/autoload.php'; - -// encoding requires buffering in chunks of 3 bytes each -$buffer = ''; -Clue\StreamFilter\append(STDIN, function ($chunk = null) use (&$buffer) { - if ($chunk === null) { - return base64_encode($buffer); - } - $buffer .= $chunk; - $len = strlen($buffer) - (strlen($buffer) % 3); - $chunk = substr($buffer, 0, $len); - $buffer = substr($buffer, $len); - - return base64_encode($chunk); -}, STREAM_FILTER_READ); - -fpassthru(STDIN); diff --git a/vendor/clue/stream-filter/examples/uppercase.php b/vendor/clue/stream-filter/examples/uppercase.php deleted file mode 100755 index 5a86f8e7fdcc9c32dbd1390c62f0f652a51af0bd..0000000000000000000000000000000000000000 --- a/vendor/clue/stream-filter/examples/uppercase.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -// $ echo test | php examples/uppercase.php - -require __DIR__ . '/../vendor/autoload.php'; - -Clue\StreamFilter\append(STDIN, 'strtoupper'); - -fpassthru(STDIN); diff --git a/vendor/clue/stream-filter/phpunit.xml.dist b/vendor/clue/stream-filter/phpunit.xml.dist deleted file mode 100755 index f3736981e38373cfd2df37f88b4bb911515d4cff..0000000000000000000000000000000000000000 --- a/vendor/clue/stream-filter/phpunit.xml.dist +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<phpunit bootstrap="vendor/autoload.php" - colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" -> - <testsuites> - <testsuite> - <directory>./tests/</directory> - </testsuite> - </testsuites> - <filter> - <whitelist> - <directory>./src/</directory> - </whitelist> - </filter> -</phpunit> \ No newline at end of file diff --git a/vendor/clue/stream-filter/src/CallbackFilter.php b/vendor/clue/stream-filter/src/CallbackFilter.php deleted file mode 100755 index 710940b6e6f8ec175adbdfe54afeb671dac64e19..0000000000000000000000000000000000000000 --- a/vendor/clue/stream-filter/src/CallbackFilter.php +++ /dev/null @@ -1,120 +0,0 @@ -<?php - -namespace Clue\StreamFilter; - -use php_user_filter; -use InvalidArgumentException; -use ReflectionFunction; -use Exception; - -/** - * - * @internal - * @see append() - * @see prepend() - */ -class CallbackFilter extends php_user_filter -{ - private $callback; - private $closed = true; - private $supportsClose = false; - - public function onCreate() - { - $this->closed = false; - - if (!is_callable($this->params)) { - throw new InvalidArgumentException('No valid callback parameter given to stream_filter_(append|prepend)'); - } - $this->callback = $this->params; - - // callback supports end event if it accepts invocation without arguments - $ref = new ReflectionFunction($this->callback); - $this->supportsClose = ($ref->getNumberOfRequiredParameters() === 0); - - return true; - } - - public function onClose() - { - $this->closed = true; - - // callback supports closing and is not already closed - if ($this->supportsClose) { - $this->supportsClose = false; - // invoke without argument to signal end and discard resulting buffer - try { - call_user_func($this->callback); - } catch (Exception $ignored) { - // this might be called during engine shutdown, so it's not safe - // to raise any errors or exceptions here - // trigger_error('Error closing filter: ' . $ignored->getMessage(), E_USER_WARNING); - } - } - - $this->callback = null; - } - - public function filter($in, $out, &$consumed, $closing) - { - // concatenate whole buffer from input brigade - $data = ''; - while ($bucket = stream_bucket_make_writeable($in)) { - $consumed += $bucket->datalen; - $data .= $bucket->data; - } - - // skip processing callback that already ended - if ($this->closed) { - return PSFS_FEED_ME; - } - - // only invoke filter function if buffer is not empty - // this may skip flushing a closing filter - if ($data !== '') { - try { - $data = call_user_func($this->callback, $data); - } catch (Exception $e) { - // exception should mark filter as closed - $this->onClose(); - trigger_error('Error invoking filter: ' . $e->getMessage(), E_USER_WARNING); - - return PSFS_ERR_FATAL; - } - } - - // mark filter as closed after processing closing chunk - if ($closing) { - $this->closed = true; - - // callback supports closing and is not already closed - if ($this->supportsClose) { - $this->supportsClose = false; - - // invoke without argument to signal end and append resulting buffer - try { - $data .= call_user_func($this->callback); - } catch (Exception $e) { - trigger_error('Error ending filter: ' . $e->getMessage(), E_USER_WARNING); - - return PSFS_ERR_FATAL; - } - } - } - - if ($data !== '') { - // create a new bucket for writing the resulting buffer to the output brigade - // reusing an existing bucket turned out to be bugged in some environments (ancient PHP versions and HHVM) - $bucket = @stream_bucket_new($this->stream, $data); - - // legacy PHP versions (PHP < 5.4) do not support passing data from the event signal handler - // because closing the stream invalidates the stream and its stream bucket brigade before - // invoking the filter close handler. - if ($bucket !== false) { - stream_bucket_append($out, $bucket); - } - } - - return PSFS_PASS_ON; - } -} diff --git a/vendor/clue/stream-filter/src/functions.php b/vendor/clue/stream-filter/src/functions.php deleted file mode 100755 index d1ca9dc01e13c609410afc4fa1ed23b5690e7527..0000000000000000000000000000000000000000 --- a/vendor/clue/stream-filter/src/functions.php +++ /dev/null @@ -1,146 +0,0 @@ -<?php - -namespace Clue\StreamFilter; - -use RuntimeException; - -/** - * append a callback filter to the given stream - * - * @param resource $stream - * @param callable $callback - * @param int $read_write - * @return resource filter resource which can be used for `remove()` - * @throws Exception on error - * @uses stream_filter_append() - */ -function append($stream, $callback, $read_write = STREAM_FILTER_ALL) -{ - $ret = @stream_filter_append($stream, register(), $read_write, $callback); - - if ($ret === false) { - $error = error_get_last() + array('message' => ''); - throw new RuntimeException('Unable to append filter: ' . $error['message']); - } - - return $ret; -} - -/** - * prepend a callback filter to the given stream - * - * @param resource $stream - * @param callable $callback - * @param int $read_write - * @return resource filter resource which can be used for `remove()` - * @throws Exception on error - * @uses stream_filter_prepend() - */ -function prepend($stream, $callback, $read_write = STREAM_FILTER_ALL) -{ - $ret = @stream_filter_prepend($stream, register(), $read_write, $callback); - - if ($ret === false) { - $error = error_get_last() + array('message' => ''); - throw new RuntimeException('Unable to prepend filter: ' . $error['message']); - } - - return $ret; -} - -/** - * Creates filter fun (function) which uses the given built-in $filter - * - * Some filters may accept or require additional filter parameters – most - * filters do not require filter parameters. - * If given, the optional `$parameters` argument will be passed to the - * underlying filter handler as-is. - * In particular, note how *not passing* this parameter at all differs from - * explicitly passing a `null` value (which many filters do not accept). - * Please refer to the individual filter definition for more details. - * - * @param string $filter built-in filter name. See stream_get_filters() or http://php.net/manual/en/filters.php - * @param mixed $parameters (optional) parameters to pass to the built-in filter as-is - * @return callable a filter callback which can be append()'ed or prepend()'ed - * @throws RuntimeException on error - * @link http://php.net/manual/en/filters.php - * @see stream_get_filters() - * @see append() - */ -function fun($filter, $parameters = null) -{ - $fp = fopen('php://memory', 'w'); - if (func_num_args() === 1) { - $filter = @stream_filter_append($fp, $filter, STREAM_FILTER_WRITE); - } else { - $filter = @stream_filter_append($fp, $filter, STREAM_FILTER_WRITE, $parameters); - } - - if ($filter === false) { - fclose($fp); - $error = error_get_last() + array('message' => ''); - throw new RuntimeException('Unable to access built-in filter: ' . $error['message']); - } - - // append filter function which buffers internally - $buffer = ''; - append($fp, function ($chunk) use (&$buffer) { - $buffer .= $chunk; - - // always return empty string in order to skip actually writing to stream resource - return ''; - }, STREAM_FILTER_WRITE); - - $closed = false; - - return function ($chunk = null) use ($fp, $filter, &$buffer, &$closed) { - if ($closed) { - throw new \RuntimeException('Unable to perform operation on closed stream'); - } - if ($chunk === null) { - $closed = true; - $buffer = ''; - fclose($fp); - return $buffer; - } - // initialize buffer and invoke filters by attempting to write to stream - $buffer = ''; - fwrite($fp, $chunk); - - // buffer now contains everything the filter function returned - return $buffer; - }; -} - -/** - * remove a callback filter from the given stream - * - * @param resource $filter - * @return boolean true on success or false on error - * @throws Exception on error - * @uses stream_filter_remove() - */ -function remove($filter) -{ - if (@stream_filter_remove($filter) === false) { - throw new RuntimeException('Unable to remove given filter'); - } -} - -/** - * registers the callback filter and returns the resulting filter name - * - * There should be little reason to call this function manually. - * - * @return string filter name - * @uses CallbackFilter - */ -function register() -{ - static $registered = null; - if ($registered === null) { - $registered = 'stream-callback'; - stream_filter_register($registered, __NAMESPACE__ . '\CallbackFilter'); - } - return $registered; -} diff --git a/vendor/clue/stream-filter/tests/FilterTest.php b/vendor/clue/stream-filter/tests/FilterTest.php deleted file mode 100755 index 02aa3a40777f746fc569a490a7f0e33a9e5820c1..0000000000000000000000000000000000000000 --- a/vendor/clue/stream-filter/tests/FilterTest.php +++ /dev/null @@ -1,386 +0,0 @@ -<?php - -use Clue\StreamFilter; - -class FilterTest extends PHPUnit_Framework_TestCase -{ - public function testAppendSimpleCallback() - { - $stream = $this->createStream(); - - StreamFilter\append($stream, function ($chunk) { - return strtoupper($chunk); - }); - - fwrite($stream, 'hello'); - fwrite($stream, 'world'); - rewind($stream); - - $this->assertEquals('HELLOWORLD', stream_get_contents($stream)); - - fclose($stream); - } - - public function testAppendNativePhpFunction() - { - $stream = $this->createStream(); - - StreamFilter\append($stream, 'strtoupper'); - - fwrite($stream, 'hello'); - fwrite($stream, 'world'); - rewind($stream); - - $this->assertEquals('HELLOWORLD', stream_get_contents($stream)); - - fclose($stream); - } - - public function testAppendChangingChunkSize() - { - $stream = $this->createStream(); - - StreamFilter\append($stream, function ($chunk) { - return str_replace(array('a','e','i','o','u'), '', $chunk); - }); - - fwrite($stream, 'hello'); - fwrite($stream, 'world'); - rewind($stream); - - $this->assertEquals('hllwrld', stream_get_contents($stream)); - - fclose($stream); - } - - public function testAppendReturningEmptyStringWillNotPassThrough() - { - $stream = $this->createStream(); - - StreamFilter\append($stream, function ($chunk) { - return ''; - }); - - fwrite($stream, 'hello'); - fwrite($stream, 'world'); - rewind($stream); - - $this->assertEquals('', stream_get_contents($stream)); - - fclose($stream); - } - - public function testAppendEndEventCanBeBufferedOnClose() - { - if (PHP_VERSION < 5.4) $this->markTestSkipped('Not supported on legacy PHP'); - - $stream = $this->createStream(); - - StreamFilter\append($stream, function ($chunk = null) { - if ($chunk === null) { - // this signals the end event - return '!'; - } - return $chunk . ' '; - }, STREAM_FILTER_WRITE); - - $buffered = ''; - StreamFilter\append($stream, function ($chunk) use (&$buffered) { - $buffered .= $chunk; - return ''; - }); - - fwrite($stream, 'hello'); - fwrite($stream, 'world'); - - fclose($stream); - - $this->assertEquals('hello world !', $buffered); - } - - public function testAppendEndEventWillBeCalledOnRemove() - { - $stream = $this->createStream(); - - $ended = false; - $filter = StreamFilter\append($stream, function ($chunk = null) use (&$ended) { - if ($chunk === null) { - $ended = true; - } - return $chunk; - }, STREAM_FILTER_WRITE); - - $this->assertEquals(0, $ended); - StreamFilter\remove($filter); - $this->assertEquals(1, $ended); - } - - public function testAppendEndEventWillBeCalledOnClose() - { - $stream = $this->createStream(); - - $ended = false; - StreamFilter\append($stream, function ($chunk = null) use (&$ended) { - if ($chunk === null) { - $ended = true; - } - return $chunk; - }, STREAM_FILTER_WRITE); - - $this->assertEquals(0, $ended); - fclose($stream); - $this->assertEquals(1, $ended); - } - - public function testAppendWriteOnly() - { - $stream = $this->createStream(); - - $invoked = 0; - - StreamFilter\append($stream, function ($chunk) use (&$invoked) { - ++$invoked; - - return $chunk; - }, STREAM_FILTER_WRITE); - - fwrite($stream, 'a'); - fwrite($stream, 'b'); - fwrite($stream, 'c'); - rewind($stream); - - $this->assertEquals(3, $invoked); - $this->assertEquals('abc', stream_get_contents($stream)); - - fclose($stream); - } - - public function testAppendReadOnly() - { - $stream = $this->createStream(); - - $invoked = 0; - - StreamFilter\append($stream, function ($chunk) use (&$invoked) { - ++$invoked; - - return $chunk; - }, STREAM_FILTER_READ); - - fwrite($stream, 'a'); - fwrite($stream, 'b'); - fwrite($stream, 'c'); - rewind($stream); - - $this->assertEquals(0, $invoked); - $this->assertEquals('abc', stream_get_contents($stream)); - $this->assertEquals(1, $invoked); - - fclose($stream); - } - - public function testOrderCallingAppendAfterPrepend() - { - $stream = $this->createStream(); - - StreamFilter\append($stream, function ($chunk) { - return '[' . $chunk . ']'; - }, STREAM_FILTER_WRITE); - - StreamFilter\prepend($stream, function ($chunk) { - return '(' . $chunk . ')'; - }, STREAM_FILTER_WRITE); - - fwrite($stream, 'hello'); - rewind($stream); - - $this->assertEquals('[(hello)]', stream_get_contents($stream)); - - fclose($stream); - } - - public function testRemoveFilter() - { - $stream = $this->createStream(); - - $first = StreamFilter\append($stream, function ($chunk) { - return $chunk . '?'; - }, STREAM_FILTER_WRITE); - - StreamFilter\append($stream, function ($chunk) { - return $chunk . '!'; - }, STREAM_FILTER_WRITE); - - StreamFilter\remove($first); - - fwrite($stream, 'hello'); - rewind($stream); - - $this->assertEquals('hello!', stream_get_contents($stream)); - - fclose($stream); - } - - public function testAppendFunDechunk() - { - if (defined('HHVM_VERSION')) $this->markTestSkipped('Not supported on HHVM (dechunk filter does not exist)'); - - $stream = $this->createStream(); - - StreamFilter\append($stream, StreamFilter\fun('dechunk'), STREAM_FILTER_WRITE); - - fwrite($stream, "2\r\nhe\r\n"); - fwrite($stream, "3\r\nllo\r\n"); - fwrite($stream, "0\r\n\r\n"); - rewind($stream); - - $this->assertEquals('hello', stream_get_contents($stream)); - - fclose($stream); - } - - public function testAppendThrows() - { - $this->createErrorHandler($errors); - - $stream = $this->createStream(); - $this->createErrorHandler($errors); - - StreamFilter\append($stream, function ($chunk) { - throw new \DomainException($chunk); - }); - - fwrite($stream, 'test'); - - $this->removeErrorHandler(); - $this->assertCount(1, $errors); - $this->assertContains('test', $errors[0]); - } - - public function testAppendThrowsDuringEnd() - { - $stream = $this->createStream(); - $this->createErrorHandler($errors); - - StreamFilter\append($stream, function ($chunk = null) { - if ($chunk === null) { - throw new \DomainException('end'); - } - return $chunk; - }); - - fclose($stream); - - $this->removeErrorHandler(); - - // We can only assert we're not seeing an exception here… - // * php 5.3-5.6 sees one error here - // * php 7 does not see any error here - // * hhvm sees the same error twice - // - // If you're curious: - // - // var_dump($errors); - // $this->assertCount(1, $errors); - // $this->assertContains('end', $errors[0]); - } - - public function testAppendThrowsShouldTriggerEnd() - { - $stream = $this->createStream(); - $this->createErrorHandler($errors); - - $ended = false; - StreamFilter\append($stream, function ($chunk = null) use (&$ended) { - if ($chunk === null) { - $ended = true; - return ''; - } - throw new \DomainException($chunk); - }); - - $this->assertEquals(false, $ended); - fwrite($stream, 'test'); - $this->assertEquals(true, $ended); - - $this->removeErrorHandler(); - $this->assertCount(1, $errors); - $this->assertContains('test', $errors[0]); - } - - public function testAppendThrowsShouldTriggerEndButIgnoreExceptionDuringEnd() - { - //$this->markTestIncomplete(); - $stream = $this->createStream(); - $this->createErrorHandler($errors); - - StreamFilter\append($stream, function ($chunk = null) { - if ($chunk === null) { - $chunk = 'end'; - //return ''; - } - throw new \DomainException($chunk); - }); - - fwrite($stream, 'test'); - - $this->removeErrorHandler(); - $this->assertCount(1, $errors); - $this->assertContains('test', $errors[0]); - } - - /** - * @expectedException RuntimeException - */ - public function testAppendInvalidStreamIsRuntimeError() - { - if (defined('HHVM_VERSION')) $this->markTestSkipped('Not supported on HHVM (does not reject invalid stream)'); - StreamFilter\append(false, function () { }); - } - - /** - * @expectedException RuntimeException - */ - public function testPrependInvalidStreamIsRuntimeError() - { - if (defined('HHVM_VERSION')) $this->markTestSkipped('Not supported on HHVM (does not reject invalid stream)'); - StreamFilter\prepend(false, function () { }); - } - - /** - * @expectedException RuntimeException - */ - public function testRemoveInvalidFilterIsRuntimeError() - { - if (defined('HHVM_VERSION')) $this->markTestSkipped('Not supported on HHVM (does not reject invalid filters)'); - StreamFilter\remove(false); - } - - /** - * @expectedException InvalidArgumentException - */ - public function testInvalidCallbackIsInvalidArgument() - { - $stream = $this->createStream(); - - StreamFilter\append($stream, 'a-b-c'); - } - - private function createStream() - { - return fopen('php://memory', 'r+'); - } - - private function createErrorHandler(&$errors) - { - $errors = array(); - set_error_handler(function ($_, $message) use (&$errors) { - $errors []= $message; - }); - } - - private function removeErrorHandler() - { - restore_error_handler(); - } -} diff --git a/vendor/clue/stream-filter/tests/FunTest.php b/vendor/clue/stream-filter/tests/FunTest.php deleted file mode 100755 index a52668c0e67945e0a9e9193754f37780f35a6ccb..0000000000000000000000000000000000000000 --- a/vendor/clue/stream-filter/tests/FunTest.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php - -use Clue\StreamFilter as Filter; - -class FunTest extends PHPUnit_Framework_TestCase -{ - public function testFunInRot13() - { - $rot = Filter\fun('string.rot13'); - - $this->assertEquals('grfg', $rot('test')); - $this->assertEquals('test', $rot($rot('test'))); - $this->assertEquals(null, $rot()); - } - - public function testFunInQuotedPrintable() - { - $encode = Filter\fun('convert.quoted-printable-encode'); - $decode = Filter\fun('convert.quoted-printable-decode'); - - $this->assertEquals('t=C3=A4st', $encode('täst')); - $this->assertEquals('täst', $decode($encode('täst'))); - $this->assertEquals(null, $encode()); - } - - /** - * @expectedException RuntimeException - */ - public function testFunWriteAfterCloseRot13() - { - $rot = Filter\fun('string.rot13'); - - $this->assertEquals(null, $rot()); - $rot('test'); - } - - /** - * @expectedException RuntimeException - */ - public function testFunInvalid() - { - Filter\fun('unknown'); - } -} diff --git a/vendor/clue/stream-filter/tests/FunZlibTest.php b/vendor/clue/stream-filter/tests/FunZlibTest.php deleted file mode 100755 index 752c8a2c831b54f0e522b2925eec5bb6f6b04351..0000000000000000000000000000000000000000 --- a/vendor/clue/stream-filter/tests/FunZlibTest.php +++ /dev/null @@ -1,79 +0,0 @@ -<?php - -use Clue\StreamFilter; - -class BuiltInZlibTest extends PHPUnit_Framework_TestCase -{ - public function testFunZlibDeflateHelloWorld() - { - $deflate = StreamFilter\fun('zlib.deflate'); - - $data = $deflate('hello') . $deflate(' ') . $deflate('world') . $deflate(); - - $this->assertEquals(gzdeflate('hello world'), $data); - } - - public function testFunZlibDeflateEmpty() - { - if (PHP_VERSION >= 7) $this->markTestSkipped('Not supported on PHP7 (empty string does not invoke filter)'); - - $deflate = StreamFilter\fun('zlib.deflate'); - - //$data = gzdeflate(''); - $data = $deflate(); - - $this->assertEquals("\x03\x00", $data); - } - - public function testFunZlibDeflateBig() - { - $deflate = StreamFilter\fun('zlib.deflate'); - - $n = 1000; - $expected = str_repeat('hello', $n); - - $bytes = ''; - for ($i = 0; $i < $n; ++$i) { - $bytes .= $deflate('hello'); - } - $bytes .= $deflate(); - - $this->assertEquals($expected, gzinflate($bytes)); - } - - public function testFunZlibInflateHelloWorld() - { - $inflate = StreamFilter\fun('zlib.inflate'); - - $data = $inflate(gzdeflate('hello world')) . $inflate(); - - $this->assertEquals('hello world', $data); - } - - public function testFunZlibInflateEmpty() - { - $inflate = StreamFilter\fun('zlib.inflate'); - - $data = $inflate("\x03\x00") . $inflate(); - - $this->assertEquals('', $data); - } - - public function testFunZlibInflateBig() - { - if (defined('HHVM_VERSION')) $this->markTestSkipped('Not supported on HHVM (final chunk will not be emitted)'); - - $inflate = StreamFilter\fun('zlib.inflate'); - - $expected = str_repeat('hello', 10); - $bytes = gzdeflate($expected); - - $ret = ''; - foreach (str_split($bytes, 2) as $chunk) { - $ret .= $inflate($chunk); - } - $ret .= $inflate(); - - $this->assertEquals($expected, $ret); - } -} diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php old mode 100755 new mode 100644 index 4626994fd4d8ac4c5489670d85b09af1b6d8aab0..2c72175e7723ad0c73fd3154eb0fecc420810448 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -374,9 +374,13 @@ class ClassLoader $first = $class[0]; if (isset($this->prefixLengthsPsr4[$first])) { - foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { - if (0 === strpos($class, $prefix)) { - foreach ($this->prefixDirsPsr4[$prefix] as $dir) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath.'\\'; + if (isset($this->prefixDirsPsr4[$search])) { + foreach ($this->prefixDirsPsr4[$search] as $dir) { + $length = $this->prefixLengthsPsr4[$first][$search]; if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { return $file; } diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE old mode 100755 new mode 100644 index 1a28124886db89f1ca3e4fa674cb69a9a17585b3..f27399a042d95c4708af3a8c74d35d338763cf8f --- a/vendor/composer/LICENSE +++ b/vendor/composer/LICENSE @@ -1,5 +1,5 @@ -Copyright (c) 2016 Nils Adermann, Jordi Boggiano +Copyright (c) Nils Adermann, Jordi Boggiano Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php old mode 100755 new mode 100644 index 4cafd885cf2699141073d3bfc53715f79439955f..2b89e59e2ec40957625501b69581560d109741ff --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -7,8 +7,6 @@ $baseDir = dirname($vendorDir); return array( 'Datamatrix' => $vendorDir . '/tecnickcom/tcpdf/include/barcodes/datamatrix.php', - 'OpenIDConnectClient' => $vendorDir . '/jumbojett/openid-connect-php/OpenIDConnectClient.php', - 'OpenIDConnectClientException' => $vendorDir . '/jumbojett/openid-connect-php/OpenIDConnectClient.php', 'PDF417' => $vendorDir . '/tecnickcom/tcpdf/include/barcodes/pdf417.php', 'QRcode' => $vendorDir . '/tecnickcom/tcpdf/include/barcodes/qrcode.php', 'TCPDF' => $vendorDir . '/tecnickcom/tcpdf/tcpdf.php', diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php old mode 100755 new mode 100644 index 9b45ff26b0f1e4c0e1764c985c2be5a7a5ff09b6..190695196a16fe36edc2309fe01581fb703a9a45 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -6,11 +6,6 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( - 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php', '253c157292f75eb38082b5acb06f3f01' => $vendorDir . '/nikic/fast-route/src/functions.php', - 'ddc0a4d7e61c0286f0f8593b1903e894' => $vendorDir . '/clue/stream-filter/src/functions.php', - '8cff32064859f4559445b89279f3199c' => $vendorDir . '/php-http/message/src/filters.php', - 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php', - '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', ); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php old mode 100755 new mode 100644 index 3225edbdd0e26babe785f95ec1b6533bab865d37..c3cd02297dec87b029193a2e9138bb90f91fdb82 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -6,9 +6,5 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( - 'Zend_Xml' => array($vendorDir . '/zf1/zend-xml/library'), - 'Zend_Search_Lucene' => array($vendorDir . '/zf1/zend-search-lucene/library'), - 'Zend_Search' => array($vendorDir . '/zf1/zend-search/library'), - 'Zend_Exception' => array($vendorDir . '/zf1/zend-exception/library'), 'Pimple' => array($vendorDir . '/pimple/pimple/src'), ); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php old mode 100755 new mode 100644 index 2540b7fda130881e4fad39787ae12c2efaaa501e..37371201998a4eb294eec8b32712936b7cd2cb7a --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -7,36 +7,20 @@ $baseDir = dirname($vendorDir); return array( 'setasign\\Fpdi\\' => array($vendorDir . '/setasign/fpdi/src'), - 'phpseclib\\' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'), 'User\\' => array($baseDir . '/src/app/user'), 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), - 'Symfony\\Component\\OptionsResolver\\' => array($vendorDir . '/symfony/options-resolver'), 'Status\\' => array($baseDir . '/src/app/status'), 'SrcCore\\' => array($baseDir . '/src/core'), 'Slim\\' => array($vendorDir . '/slim/slim/Slim'), 'Respect\\Validation\\' => array($vendorDir . '/respect/validation/library'), - 'Resource\\' => array($baseDir . '/src/app/resource'), 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'), 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), 'Interop\\Container\\' => array($vendorDir . '/container-interop/container-interop/src/Interop/Container'), - 'Http\\Promise\\' => array($vendorDir . '/php-http/promise/src'), - 'Http\\Message\\MultipartStream\\' => array($vendorDir . '/php-http/multipart-stream-builder/src'), - 'Http\\Message\\' => array($vendorDir . '/php-http/message-factory/src', $vendorDir . '/php-http/message/src'), - 'Http\\Discovery\\' => array($vendorDir . '/php-http/discovery/src'), - 'Http\\Client\\Curl\\' => array($vendorDir . '/php-http/curl-client/src'), - 'Http\\Client\\Common\\' => array($vendorDir . '/php-http/client-common/src'), - 'Http\\Client\\' => array($vendorDir . '/php-http/httplug/src'), - 'Http\\Adapter\\Guzzle6\\' => array($vendorDir . '/php-http/guzzle6-adapter/src'), 'History\\' => array($baseDir . '/src/app/history'), - 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), - 'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'), - 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'), - 'Gitlab\\' => array($vendorDir . '/m4tthumphrey/php-gitlab-api/lib/Gitlab'), 'FastRoute\\' => array($vendorDir . '/nikic/fast-route/src'), 'Document\\' => array($baseDir . '/src/app/document'), 'Docserver\\' => array($baseDir . '/src/app/docserver'), 'Convert\\' => array($baseDir . '/src/app/convert'), - 'Clue\\StreamFilter\\' => array($vendorDir . '/clue/stream-filter/src'), 'Attachment\\' => array($baseDir . '/src/app/attachment'), 'Action\\' => array($baseDir . '/src/app/action'), ); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php old mode 100755 new mode 100644 index b8fbafd354ac72748157163a2587ff89ac3ae3ba..a1cb1ce02690bcfe1b25c2ccf7fb76185be9f1c8 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitf21aebccfa6df888200dcb099aa69fbd +class ComposerAutoloaderInit637514d10f1ed5d4c55a005a428a3656 { private static $loader; @@ -19,15 +19,15 @@ class ComposerAutoloaderInitf21aebccfa6df888200dcb099aa69fbd return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitf21aebccfa6df888200dcb099aa69fbd', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit637514d10f1ed5d4c55a005a428a3656', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInitf21aebccfa6df888200dcb099aa69fbd', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit637514d10f1ed5d4c55a005a428a3656', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit637514d10f1ed5d4c55a005a428a3656::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -48,19 +48,19 @@ class ComposerAutoloaderInitf21aebccfa6df888200dcb099aa69fbd $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit637514d10f1ed5d4c55a005a428a3656::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequiref21aebccfa6df888200dcb099aa69fbd($fileIdentifier, $file); + composerRequire637514d10f1ed5d4c55a005a428a3656($fileIdentifier, $file); } return $loader; } } -function composerRequiref21aebccfa6df888200dcb099aa69fbd($fileIdentifier, $file) +function composerRequire637514d10f1ed5d4c55a005a428a3656($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php old mode 100755 new mode 100644 index 9a2125c0f32577987081c2cd83fdb4159b345ce0..48ba9097022211b845ad0740df2298bfe5964979 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,15 +4,10 @@ namespace Composer\Autoload; -class ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd +class ComposerStaticInit637514d10f1ed5d4c55a005a428a3656 { public static $files = array ( - 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php', '253c157292f75eb38082b5acb06f3f01' => __DIR__ . '/..' . '/nikic/fast-route/src/functions.php', - 'ddc0a4d7e61c0286f0f8593b1903e894' => __DIR__ . '/..' . '/clue/stream-filter/src/functions.php', - '8cff32064859f4559445b89279f3199c' => __DIR__ . '/..' . '/php-http/message/src/filters.php', - 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php', - '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', ); @@ -21,10 +16,6 @@ class ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd array ( 'setasign\\Fpdi\\' => 14, ), - 'p' => - array ( - 'phpseclib\\' => 10, - ), 'U' => array ( 'User\\' => 5, @@ -32,7 +23,6 @@ class ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd 'S' => array ( 'Symfony\\Polyfill\\Mbstring\\' => 26, - 'Symfony\\Component\\OptionsResolver\\' => 34, 'Status\\' => 7, 'SrcCore\\' => 8, 'Slim\\' => 5, @@ -40,7 +30,6 @@ class ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd 'R' => array ( 'Respect\\Validation\\' => 19, - 'Resource\\' => 9, ), 'P' => array ( @@ -53,23 +42,8 @@ class ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd ), 'H' => array ( - 'Http\\Promise\\' => 13, - 'Http\\Message\\MultipartStream\\' => 29, - 'Http\\Message\\' => 13, - 'Http\\Discovery\\' => 15, - 'Http\\Client\\Curl\\' => 17, - 'Http\\Client\\Common\\' => 19, - 'Http\\Client\\' => 12, - 'Http\\Adapter\\Guzzle6\\' => 21, 'History\\' => 8, ), - 'G' => - array ( - 'GuzzleHttp\\Psr7\\' => 16, - 'GuzzleHttp\\Promise\\' => 19, - 'GuzzleHttp\\' => 11, - 'Gitlab\\' => 7, - ), 'F' => array ( 'FastRoute\\' => 10, @@ -82,7 +56,6 @@ class ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd 'C' => array ( 'Convert\\' => 8, - 'Clue\\StreamFilter\\' => 18, ), 'A' => array ( @@ -96,10 +69,6 @@ class ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd array ( 0 => __DIR__ . '/..' . '/setasign/fpdi/src', ), - 'phpseclib\\' => - array ( - 0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib', - ), 'User\\' => array ( 0 => __DIR__ . '/../..' . '/src/app/user', @@ -108,10 +77,6 @@ class ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd array ( 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring', ), - 'Symfony\\Component\\OptionsResolver\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/options-resolver', - ), 'Status\\' => array ( 0 => __DIR__ . '/../..' . '/src/app/status', @@ -128,10 +93,6 @@ class ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd array ( 0 => __DIR__ . '/..' . '/respect/validation/library', ), - 'Resource\\' => - array ( - 0 => __DIR__ . '/../..' . '/src/app/resource', - ), 'Psr\\Http\\Message\\' => array ( 0 => __DIR__ . '/..' . '/psr/http-message/src', @@ -144,59 +105,10 @@ class ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd array ( 0 => __DIR__ . '/..' . '/container-interop/container-interop/src/Interop/Container', ), - 'Http\\Promise\\' => - array ( - 0 => __DIR__ . '/..' . '/php-http/promise/src', - ), - 'Http\\Message\\MultipartStream\\' => - array ( - 0 => __DIR__ . '/..' . '/php-http/multipart-stream-builder/src', - ), - 'Http\\Message\\' => - array ( - 0 => __DIR__ . '/..' . '/php-http/message-factory/src', - 1 => __DIR__ . '/..' . '/php-http/message/src', - ), - 'Http\\Discovery\\' => - array ( - 0 => __DIR__ . '/..' . '/php-http/discovery/src', - ), - 'Http\\Client\\Curl\\' => - array ( - 0 => __DIR__ . '/..' . '/php-http/curl-client/src', - ), - 'Http\\Client\\Common\\' => - array ( - 0 => __DIR__ . '/..' . '/php-http/client-common/src', - ), - 'Http\\Client\\' => - array ( - 0 => __DIR__ . '/..' . '/php-http/httplug/src', - ), - 'Http\\Adapter\\Guzzle6\\' => - array ( - 0 => __DIR__ . '/..' . '/php-http/guzzle6-adapter/src', - ), 'History\\' => array ( 0 => __DIR__ . '/../..' . '/src/app/history', ), - 'GuzzleHttp\\Psr7\\' => - array ( - 0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src', - ), - 'GuzzleHttp\\Promise\\' => - array ( - 0 => __DIR__ . '/..' . '/guzzlehttp/promises/src', - ), - 'GuzzleHttp\\' => - array ( - 0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src', - ), - 'Gitlab\\' => - array ( - 0 => __DIR__ . '/..' . '/m4tthumphrey/php-gitlab-api/lib/Gitlab', - ), 'FastRoute\\' => array ( 0 => __DIR__ . '/..' . '/nikic/fast-route/src', @@ -213,10 +125,6 @@ class ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd array ( 0 => __DIR__ . '/../..' . '/src/app/convert', ), - 'Clue\\StreamFilter\\' => - array ( - 0 => __DIR__ . '/..' . '/clue/stream-filter/src', - ), 'Attachment\\' => array ( 0 => __DIR__ . '/../..' . '/src/app/attachment', @@ -228,25 +136,6 @@ class ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd ); public static $prefixesPsr0 = array ( - 'Z' => - array ( - 'Zend_Xml' => - array ( - 0 => __DIR__ . '/..' . '/zf1/zend-xml/library', - ), - 'Zend_Search_Lucene' => - array ( - 0 => __DIR__ . '/..' . '/zf1/zend-search-lucene/library', - ), - 'Zend_Search' => - array ( - 0 => __DIR__ . '/..' . '/zf1/zend-search/library', - ), - 'Zend_Exception' => - array ( - 0 => __DIR__ . '/..' . '/zf1/zend-exception/library', - ), - ), 'P' => array ( 'Pimple' => @@ -258,8 +147,6 @@ class ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd public static $classMap = array ( 'Datamatrix' => __DIR__ . '/..' . '/tecnickcom/tcpdf/include/barcodes/datamatrix.php', - 'OpenIDConnectClient' => __DIR__ . '/..' . '/jumbojett/openid-connect-php/OpenIDConnectClient.php', - 'OpenIDConnectClientException' => __DIR__ . '/..' . '/jumbojett/openid-connect-php/OpenIDConnectClient.php', 'PDF417' => __DIR__ . '/..' . '/tecnickcom/tcpdf/include/barcodes/pdf417.php', 'QRcode' => __DIR__ . '/..' . '/tecnickcom/tcpdf/include/barcodes/qrcode.php', 'TCPDF' => __DIR__ . '/..' . '/tecnickcom/tcpdf/tcpdf.php', @@ -278,10 +165,10 @@ class ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd::$prefixDirsPsr4; - $loader->prefixesPsr0 = ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd::$prefixesPsr0; - $loader->classMap = ComposerStaticInitf21aebccfa6df888200dcb099aa69fbd::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit637514d10f1ed5d4c55a005a428a3656::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit637514d10f1ed5d4c55a005a428a3656::$prefixDirsPsr4; + $loader->prefixesPsr0 = ComposerStaticInit637514d10f1ed5d4c55a005a428a3656::$prefixesPsr0; + $loader->classMap = ComposerStaticInit637514d10f1ed5d4c55a005a428a3656::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json old mode 100755 new mode 100644 index 67429495ef7208bfb5c661f7fd3d3c9cedf1d1ee..a00c92a03d4690ab90b7b217b44decd60f0725fa --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1,293 +1,4 @@ [ - { - "name": "phpseclib/phpseclib", - "version": "2.0.1", - "version_normalized": "2.0.1.0", - "source": { - "type": "git", - "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "ba6fb78f727cd09f2a649113b95468019e490585" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/ba6fb78f727cd09f2a649113b95468019e490585", - "reference": "ba6fb78f727cd09f2a649113b95468019e490585", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phing/phing": "~2.7", - "phpunit/phpunit": "~4.0", - "sami/sami": "~2.0", - "squizlabs/php_codesniffer": "~2.0" - }, - "suggest": { - "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", - "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.", - "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.", - "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations." - }, - "time": "2016-01-18T17:07:21+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "phpseclib\\": "phpseclib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jim Wigginton", - "email": "terrafrost@php.net", - "role": "Lead Developer" - }, - { - "name": "Patrick Monnerat", - "email": "pm@datasphere.ch", - "role": "Developer" - }, - { - "name": "Andreas Fischer", - "email": "bantu@phpbb.com", - "role": "Developer" - }, - { - "name": "Hans-Jürgen Petrich", - "email": "petrich@tronic-media.com", - "role": "Developer" - }, - { - "name": "Graham Campbell", - "email": "graham@alt-three.com", - "role": "Developer" - } - ], - "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", - "homepage": "http://phpseclib.sourceforge.net", - "keywords": [ - "BigInteger", - "aes", - "asn.1", - "asn1", - "blowfish", - "crypto", - "cryptography", - "encryption", - "rsa", - "security", - "sftp", - "signature", - "signing", - "ssh", - "twofish", - "x.509", - "x509" - ] - }, - { - "name": "jumbojett/openid-connect-php", - "version": "0.3.0", - "version_normalized": "0.3.0.0", - "source": { - "type": "git", - "url": "https://github.com/jumbojett/OpenID-Connect-PHP.git", - "reference": "fe79a249e36614ca111f2d253af3b991343bc23f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/jumbojett/OpenID-Connect-PHP/zipball/fe79a249e36614ca111f2d253af3b991343bc23f", - "reference": "fe79a249e36614ca111f2d253af3b991343bc23f", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "ext-json": "*", - "php": ">=5.4", - "phpseclib/phpseclib": "2.0.1" - }, - "time": "2017-02-20T20:38:13+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "classmap": [ - "OpenIDConnectClient.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "description": "Bare-bones OpenID Connect client" - }, - { - "name": "setasign/fpdi", - "version": "v2.0.3", - "version_normalized": "2.0.3.0", - "source": { - "type": "git", - "url": "https://github.com/Setasign/FPDI.git", - "reference": "5998a2f81ae5b4a59eb75ed65e6ec0518163de8d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Setasign/FPDI/zipball/5998a2f81ae5b4a59eb75ed65e6ec0518163de8d", - "reference": "5998a2f81ae5b4a59eb75ed65e6ec0518163de8d", - "shasum": "" - }, - "require": { - "ext-zlib": "*", - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "~5.7", - "setasign/fpdf": "~1.8", - "tecnickcom/tcpdf": "~6.2" - }, - "suggest": { - "setasign/fpdf": "FPDI will extend this class but as it is also possible to use \"tecnickcom/tcpdf\" as an alternative there's no fixed dependency configured.", - "setasign/fpdi-fpdf": "Use this package to automatically evaluate dependencies to FPDF.", - "setasign/fpdi-tcpdf": "Use this package to automatically evaluate dependencies to TCPDF." - }, - "time": "2018-04-18T13:00:41+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "setasign\\Fpdi\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jan Slabon", - "email": "jan.slabon@setasign.com", - "homepage": "https://www.setasign.com" - }, - { - "name": "Maximilian Kresse", - "email": "maximilian.kresse@setasign.com", - "homepage": "https://www.setasign.com" - } - ], - "description": "FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies automatically.", - "homepage": "https://www.setasign.com/fpdi", - "keywords": [ - "fpdf", - "fpdi", - "pdf" - ] - }, - { - "name": "tecnickcom/tcpdf", - "version": "6.2.17", - "version_normalized": "6.2.17.0", - "source": { - "type": "git", - "url": "https://github.com/tecnickcom/TCPDF.git", - "reference": "64fc19439863e1b1314487a72a74d9bfd0b55a53" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/64fc19439863e1b1314487a72a74d9bfd0b55a53", - "reference": "64fc19439863e1b1314487a72a74d9bfd0b55a53", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "time": "2018-02-24T11:48:20+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "classmap": [ - "config", - "include", - "tcpdf.php", - "tcpdf_parser.php", - "tcpdf_import.php", - "tcpdf_barcodes_1d.php", - "tcpdf_barcodes_2d.php", - "include/tcpdf_colors.php", - "include/tcpdf_filters.php", - "include/tcpdf_font_data.php", - "include/tcpdf_fonts.php", - "include/tcpdf_images.php", - "include/tcpdf_static.php", - "include/barcodes/datamatrix.php", - "include/barcodes/pdf417.php", - "include/barcodes/qrcode.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-3.0" - ], - "authors": [ - { - "name": "Nicola Asuni", - "email": "info@tecnick.com", - "role": "lead" - } - ], - "description": "TCPDF is a PHP class for generating PDF documents and barcodes.", - "homepage": "http://www.tcpdf.org/", - "keywords": [ - "PDFD32000-2008", - "TCPDF", - "barcodes", - "datamatrix", - "pdf", - "pdf417", - "qrcode" - ] - }, - { - "name": "setasign/fpdi-tcpdf", - "version": "v2.0.0", - "version_normalized": "2.0.0.0", - "source": { - "type": "git", - "url": "https://github.com/Setasign/FPDI-TCPDF.git", - "reference": "326df0f31ef0fab8f1e6559833b21a6275ae15bc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Setasign/FPDI-TCPDF/zipball/326df0f31ef0fab8f1e6559833b21a6275ae15bc", - "reference": "326df0f31ef0fab8f1e6559833b21a6275ae15bc", - "shasum": "" - }, - "require": { - "setasign/fpdi": "^2.0", - "tecnickcom/tcpdf": "^6.2" - }, - "time": "2017-10-12T14:31:02+00:00", - "type": "library", - "installation-source": "dist", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jan Slabon", - "email": "jan.slabon@setasign.com", - "homepage": "https://www.setasign.com" - } - ], - "description": "Kind of metadata package for dependencies of the latest versions of FPDI and TCPDF.", - "homepage": "https://www.setasign.com/fpdi", - "keywords": [ - "TCPDF", - "fpdi", - "pdf" - ] - }, { "name": "psr/container", "version": "1.0.0", @@ -526,17 +237,17 @@ }, { "name": "slim/slim", - "version": "3.10.0", - "version_normalized": "3.10.0.0", + "version": "3.11.0", + "version_normalized": "3.11.0.0", "source": { "type": "git", "url": "https://github.com/slimphp/Slim.git", - "reference": "d8aabeacc3688b25e2f2dd2db91df91ec6fdd748" + "reference": "d378e70431e78ee92ee32ddde61ecc72edf5dc0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slimphp/Slim/zipball/d8aabeacc3688b25e2f2dd2db91df91ec6fdd748", - "reference": "d8aabeacc3688b25e2f2dd2db91df91ec6fdd748", + "url": "https://api.github.com/repos/slimphp/Slim/zipball/d378e70431e78ee92ee32ddde61ecc72edf5dc0a", + "reference": "d378e70431e78ee92ee32ddde61ecc72edf5dc0a", "shasum": "" }, "require": { @@ -554,7 +265,7 @@ "phpunit/phpunit": "^4.0", "squizlabs/php_codesniffer": "^2.5" }, - "time": "2018-04-19T19:29:08+00:00", + "time": "2018-09-16T10:54:21+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -599,17 +310,17 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.8.0", - "version_normalized": "1.8.0.0", + "version": "v1.10.0", + "version_normalized": "1.10.0.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "3296adf6a6454a050679cde90f95350ad604b171" + "reference": "c79c051f5b3a46be09205c73b80b346e4153e494" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3296adf6a6454a050679cde90f95350ad604b171", - "reference": "3296adf6a6454a050679cde90f95350ad604b171", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494", + "reference": "c79c051f5b3a46be09205c73b80b346e4153e494", "shasum": "" }, "require": { @@ -618,11 +329,11 @@ "suggest": { "ext-mbstring": "For best performance" }, - "time": "2018-04-26T10:06:28+00:00", + "time": "2018-09-21T13:07:52+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8-dev" + "dev-master": "1.9-dev" } }, "installation-source": "dist", @@ -660,17 +371,17 @@ }, { "name": "respect/validation", - "version": "1.1.19", - "version_normalized": "1.1.19.0", + "version": "1.1.29", + "version_normalized": "1.1.29.0", "source": { "type": "git", "url": "https://github.com/Respect/Validation.git", - "reference": "667ed36b4868e785d52d815181ff00c798a61be7" + "reference": "f8c90fa36859ca41c766efcf0c476d58913a7767" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Respect/Validation/zipball/667ed36b4868e785d52d815181ff00c798a61be7", - "reference": "667ed36b4868e785d52d815181ff00c798a61be7", + "url": "https://api.github.com/repos/Respect/Validation/zipball/f8c90fa36859ca41c766efcf0c476d58913a7767", + "reference": "f8c90fa36859ca41c766efcf0c476d58913a7767", "shasum": "" }, "require": { @@ -678,7 +389,7 @@ "symfony/polyfill-mbstring": "^1.2" }, "require-dev": { - "egulias/email-validator": "~1.2", + "egulias/email-validator": "~1.2 || ~2.1", "mikey179/vfsstream": "^1.5", "phpunit/phpunit": "~4.0", "symfony/validator": "~2.6.9", @@ -692,7 +403,7 @@ "symfony/validator": "Use Symfony validator through Respect\\Validation", "zendframework/zend-validator": "Use Zend Framework validator through Respect\\Validation" }, - "time": "2018-07-02T06:22:41+00:00", + "time": "2018-11-04T21:58:45+00:00", "type": "library", "extra": { "branch-alias": { @@ -707,7 +418,7 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD Style" + "BSD-3-Clause" ], "authors": [ { @@ -724,45 +435,42 @@ ] }, { - "name": "php-http/discovery", - "version": "1.4.0", - "version_normalized": "1.4.0.0", + "name": "setasign/fpdi", + "version": "v2.1.1", + "version_normalized": "2.1.1.0", "source": { "type": "git", - "url": "https://github.com/php-http/discovery.git", - "reference": "9a6cb24de552bfe1aa9d7d1569e2d49c5b169a33" + "url": "https://github.com/Setasign/FPDI.git", + "reference": "356de9cb6b6a826ac952c86aee6599463ea87362" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-http/discovery/zipball/9a6cb24de552bfe1aa9d7d1569e2d49c5b169a33", - "reference": "9a6cb24de552bfe1aa9d7d1569e2d49c5b169a33", + "url": "https://api.github.com/repos/Setasign/FPDI/zipball/356de9cb6b6a826ac952c86aee6599463ea87362", + "reference": "356de9cb6b6a826ac952c86aee6599463ea87362", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0" + "ext-zlib": "*", + "php": "^5.6 || ^7.0" }, "require-dev": { - "henrikbjorn/phpspec-code-coverage": "^2.0.2", - "php-http/httplug": "^1.0", - "php-http/message-factory": "^1.0", - "phpspec/phpspec": "^2.4", - "puli/composer-plugin": "1.0.0-beta10" + "phpunit/phpunit": "~5.7", + "setasign/fpdf": "~1.8", + "setasign/tfpdf": "1.25", + "tecnickcom/tcpdf": "~6.2" }, "suggest": { - "php-http/message": "Allow to use Guzzle, Diactoros or Slim Framework factories", - "puli/composer-plugin": "Sets up Puli which is recommended for Discovery to work. Check http://docs.php-http.org/en/latest/discovery.html for more details." + "setasign/fpdf": "FPDI will extend this class but as it is also possible to use TCPDF or tFPDF as an alternative. There's no fixed dependency configured.", + "setasign/fpdi-fpdf": "Use this package to automatically evaluate dependencies to FPDF.", + "setasign/fpdi-tcpdf": "Use this package to automatically evaluate dependencies to TCPDF.", + "setasign/fpdi-tfpdf": "Use this package to automatically evaluate dependencies to tFPDF." }, - "time": "2018-02-06T10:55:24+00:00", + "time": "2018-11-06T10:02:00+00:00", "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, "installation-source": "dist", "autoload": { "psr-4": { - "Http\\Discovery\\": "src/" + "setasign\\Fpdi\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -771,1027 +479,127 @@ ], "authors": [ { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" + "name": "Jan Slabon", + "email": "jan.slabon@setasign.com", + "homepage": "https://www.setasign.com" + }, + { + "name": "Maximilian Kresse", + "email": "maximilian.kresse@setasign.com", + "homepage": "https://www.setasign.com" } ], - "description": "Finds installed HTTPlug implementations and PSR-7 message factories", - "homepage": "http://php-http.org", + "description": "FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies automatically.", + "homepage": "https://www.setasign.com/fpdi", "keywords": [ - "adapter", - "client", - "discovery", - "factory", - "http", - "message", - "psr7" + "fpdf", + "fpdi", + "pdf" ] }, { - "name": "clue/stream-filter", - "version": "v1.4.0", - "version_normalized": "1.4.0.0", + "name": "tecnickcom/tcpdf", + "version": "6.2.26", + "version_normalized": "6.2.26.0", "source": { "type": "git", - "url": "https://github.com/clue/php-stream-filter.git", - "reference": "d80fdee9b3a7e0d16fc330a22f41f3ad0eeb09d0" + "url": "https://github.com/tecnickcom/TCPDF.git", + "reference": "367241059ca166e3a76490f4448c284e0a161f15" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/clue/php-stream-filter/zipball/d80fdee9b3a7e0d16fc330a22f41f3ad0eeb09d0", - "reference": "d80fdee9b3a7e0d16fc330a22f41f3ad0eeb09d0", + "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/367241059ca166e3a76490f4448c284e0a161f15", + "reference": "367241059ca166e3a76490f4448c284e0a161f15", "shasum": "" }, "require": { - "php": ">=5.3" - }, - "require-dev": { - "phpunit/phpunit": "^5.0 || ^4.8" + "php": ">=5.3.0" }, - "time": "2017-08-18T09:54:01+00:00", + "time": "2018-10-16T17:24:05+00:00", "type": "library", "installation-source": "dist", "autoload": { - "psr-4": { - "Clue\\StreamFilter\\": "src/" - }, - "files": [ - "src/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@lueck.tv" - } - ], - "description": "A simple and modern approach to stream filtering in PHP", - "homepage": "https://github.com/clue/php-stream-filter", - "keywords": [ - "bucket brigade", - "callback", - "filter", - "php_user_filter", - "stream", - "stream_filter_append", - "stream_filter_register" - ] - }, - { - "name": "php-http/message-factory", - "version": "v1.0.2", - "version_normalized": "1.0.2.0", - "source": { - "type": "git", - "url": "https://github.com/php-http/message-factory.git", - "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1", - "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1", - "shasum": "" - }, - "require": { - "php": ">=5.4", - "psr/http-message": "^1.0" - }, - "time": "2015-12-19T14:08:53+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "description": "Factory interfaces for PSR-7 HTTP Message", - "homepage": "http://php-http.org", - "keywords": [ - "factory", - "http", - "message", - "stream", - "uri" - ] - }, - { - "name": "php-http/message", - "version": "1.6.0", - "version_normalized": "1.6.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-http/message.git", - "reference": "2edd63bae5f52f79363c5f18904b05ce3a4b7253" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/message/zipball/2edd63bae5f52f79363c5f18904b05ce3a4b7253", - "reference": "2edd63bae5f52f79363c5f18904b05ce3a4b7253", - "shasum": "" - }, - "require": { - "clue/stream-filter": "^1.3", - "php": ">=5.4", - "php-http/message-factory": "^1.0.2", - "psr/http-message": "^1.0" - }, - "provide": { - "php-http/message-factory-implementation": "1.0" - }, - "require-dev": { - "akeneo/phpspec-skip-example-extension": "^1.0", - "coduo/phpspec-data-provider-extension": "^1.0", - "ext-zlib": "*", - "guzzlehttp/psr7": "^1.0", - "henrikbjorn/phpspec-code-coverage": "^1.0", - "phpspec/phpspec": "^2.4", - "slim/slim": "^3.0", - "zendframework/zend-diactoros": "^1.0" - }, - "suggest": { - "ext-zlib": "Used with compressor/decompressor streams", - "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", - "slim/slim": "Used with Slim Framework PSR-7 implementation", - "zendframework/zend-diactoros": "Used with Diactoros Factories" - }, - "time": "2017-07-05T06:40:53+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Http\\Message\\": "src/" - }, - "files": [ - "src/filters.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "description": "HTTP Message related tools", - "homepage": "http://php-http.org", - "keywords": [ - "http", - "message", - "psr-7" - ] - }, - { - "name": "php-http/promise", - "version": "v1.0.0", - "version_normalized": "1.0.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-http/promise.git", - "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/promise/zipball/dc494cdc9d7160b9a09bd5573272195242ce7980", - "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980", - "shasum": "" - }, - "require-dev": { - "henrikbjorn/phpspec-code-coverage": "^1.0", - "phpspec/phpspec": "^2.4" - }, - "time": "2016-01-26T13:27:02+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Http\\Promise\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - }, - { - "name": "Joel Wurtz", - "email": "joel.wurtz@gmail.com" - } - ], - "description": "Promise used for asynchronous HTTP requests", - "homepage": "http://httplug.io", - "keywords": [ - "promise" - ] - }, - { - "name": "php-http/httplug", - "version": "v1.1.0", - "version_normalized": "1.1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-http/httplug.git", - "reference": "1c6381726c18579c4ca2ef1ec1498fdae8bdf018" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/httplug/zipball/1c6381726c18579c4ca2ef1ec1498fdae8bdf018", - "reference": "1c6381726c18579c4ca2ef1ec1498fdae8bdf018", - "shasum": "" - }, - "require": { - "php": ">=5.4", - "php-http/promise": "^1.0", - "psr/http-message": "^1.0" - }, - "require-dev": { - "henrikbjorn/phpspec-code-coverage": "^1.0", - "phpspec/phpspec": "^2.4" - }, - "time": "2016-08-31T08:30:17+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Http\\Client\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Eric GELOEN", - "email": "geloen.eric@gmail.com" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "description": "HTTPlug, the HTTP client abstraction for PHP", - "homepage": "http://httplug.io", - "keywords": [ - "client", - "http" - ] - }, - { - "name": "php-http/curl-client", - "version": "v1.7.1", - "version_normalized": "1.7.1.0", - "source": { - "type": "git", - "url": "https://github.com/php-http/curl-client.git", - "reference": "6341a93d00e5d953fc868a3928b5167e6513f2b6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/curl-client/zipball/6341a93d00e5d953fc868a3928b5167e6513f2b6", - "reference": "6341a93d00e5d953fc868a3928b5167e6513f2b6", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "php": "^5.5 || ^7.0", - "php-http/discovery": "^1.0", - "php-http/httplug": "^1.0", - "php-http/message": "^1.2", - "php-http/message-factory": "^1.0.2" - }, - "provide": { - "php-http/async-client-implementation": "1.0", - "php-http/client-implementation": "1.0" - }, - "require-dev": { - "guzzlehttp/psr7": "^1.0", - "php-http/client-integration-tests": "^0.6", - "phpunit/phpunit": "^4.8.27", - "zendframework/zend-diactoros": "^1.0" - }, - "time": "2018-03-26T19:21:48+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "Http\\Client\\Curl\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Михаил Красильников", - "email": "m.krasilnikov@yandex.ru" - } - ], - "description": "cURL client for PHP-HTTP", - "homepage": "http://php-http.org", - "keywords": [ - "curl", - "http" - ] - }, - { - "name": "zf1/zend-exception", - "version": "1.12.20", - "version_normalized": "1.12.20.0", - "source": { - "type": "git", - "url": "https://github.com/zf1/zend-exception.git", - "reference": "ca30959d3e2f522f481a3d1459386acf1aa4ca74" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zf1/zend-exception/zipball/ca30959d3e2f522f481a3d1459386acf1aa4ca74", - "reference": "ca30959d3e2f522f481a3d1459386acf1aa4ca74", - "shasum": "" - }, - "require": { - "php": ">=5.2.11" - }, - "time": "2015-04-30T11:10:20+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "Zend_Exception": "library/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Zend Framework 1 Exception package", - "homepage": "http://framework.zend.com/", - "keywords": [ - "ZF1", - "exception", - "framework", - "zend" - ] - }, - { - "name": "zf1/zend-xml", - "version": "1.12.20", - "version_normalized": "1.12.20.0", - "source": { - "type": "git", - "url": "https://github.com/zf1/zend-xml.git", - "reference": "d4f99144a0cf0c5e383f3fb765cdd7dfde7caab4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zf1/zend-xml/zipball/d4f99144a0cf0c5e383f3fb765cdd7dfde7caab4", - "reference": "d4f99144a0cf0c5e383f3fb765cdd7dfde7caab4", - "shasum": "" - }, - "require": { - "php": ">=5.2.11", - "zf1/zend-exception": "self.version" - }, - "time": "2017-07-11T23:59:06+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "Zend_Xml": "library/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Zend Framework 1 Xml package", - "homepage": "http://framework.zend.com/", - "keywords": [ - "ZF1", - "framework", - "xml", - "zend" - ] - }, - { - "name": "zf1/zend-search", - "version": "1.12.20", - "version_normalized": "1.12.20.0", - "source": { - "type": "git", - "url": "https://github.com/zf1/zend-search.git", - "reference": "c966e380667e02f83bf0806132e9cf392831930b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zf1/zend-search/zipball/c966e380667e02f83bf0806132e9cf392831930b", - "reference": "c966e380667e02f83bf0806132e9cf392831930b", - "shasum": "" - }, - "require": { - "php": ">=5.2.11", - "zf1/zend-exception": "self.version" - }, - "time": "2015-04-30T11:08:53+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "Zend_Search": "library/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Zend Framework 1 Search package", - "homepage": "http://framework.zend.com/", - "keywords": [ - "ZF1", - "framework", - "search", - "zend" - ] - }, - { - "name": "zf1/zend-search-lucene", - "version": "1.12.20", - "version_normalized": "1.12.20.0", - "source": { - "type": "git", - "url": "https://github.com/zf1/zend-search-lucene.git", - "reference": "8a07584308d86c86fdd9f743d574cc2cbfffc7ac" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zf1/zend-search-lucene/zipball/8a07584308d86c86fdd9f743d574cc2cbfffc7ac", - "reference": "8a07584308d86c86fdd9f743d574cc2cbfffc7ac", - "shasum": "" - }, - "require": { - "php": ">=5.2.11", - "zf1/zend-exception": "self.version", - "zf1/zend-search": "self.version", - "zf1/zend-xml": "self.version" - }, - "time": "2017-07-12T00:31:21+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "Zend_Search_Lucene": "library/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Zend Framework 1 Search Lucene package", - "homepage": "http://framework.zend.com/", - "keywords": [ - "ZF1", - "framework", - "lucene", - "search", - "zend" - ] - }, - { - "name": "guzzlehttp/promises", - "version": "v1.3.1", - "version_normalized": "1.3.1.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", - "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", - "shasum": "" - }, - "require": { - "php": ">=5.5.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0" - }, - "time": "2016-12-20T10:07:11+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ] - }, - { - "name": "guzzlehttp/psr7", - "version": "1.4.2", - "version_normalized": "1.4.2.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", - "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "time": "2017-03-20T17:10:46+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Tobias Schultze", - "homepage": "https://github.com/Tobion" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "request", - "response", - "stream", - "uri", - "url" - ] - }, - { - "name": "guzzlehttp/guzzle", - "version": "6.3.3", - "version_normalized": "6.3.3.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba", - "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba", - "shasum": "" - }, - "require": { - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.4", - "php": ">=5.5" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", - "psr/log": "^1.0" - }, - "suggest": { - "psr/log": "Required for using the Log middleware" - }, - "time": "2018-04-22T15:46:56+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ] - }, - { - "name": "php-http/guzzle6-adapter", - "version": "v1.1.1", - "version_normalized": "1.1.1.0", - "source": { - "type": "git", - "url": "https://github.com/php-http/guzzle6-adapter.git", - "reference": "a56941f9dc6110409cfcddc91546ee97039277ab" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/guzzle6-adapter/zipball/a56941f9dc6110409cfcddc91546ee97039277ab", - "reference": "a56941f9dc6110409cfcddc91546ee97039277ab", - "shasum": "" - }, - "require": { - "guzzlehttp/guzzle": "^6.0", - "php": ">=5.5.0", - "php-http/httplug": "^1.0" - }, - "provide": { - "php-http/async-client-implementation": "1.0", - "php-http/client-implementation": "1.0" - }, - "require-dev": { - "ext-curl": "*", - "php-http/adapter-integration-tests": "^0.4" - }, - "time": "2016-05-10T06:13:32+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Http\\Adapter\\Guzzle6\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - }, - { - "name": "David de Boer", - "email": "david@ddeboer.nl" - } - ], - "description": "Guzzle 6 HTTP Adapter", - "homepage": "http://httplug.io", - "keywords": [ - "Guzzle", - "http" - ] - }, - { - "name": "symfony/options-resolver", - "version": "v3.4.13", - "version_normalized": "3.4.13.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/options-resolver.git", - "reference": "638f5ad40a6400d78568187522731e5643eed60a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/638f5ad40a6400d78568187522731e5643eed60a", - "reference": "638f5ad40a6400d78568187522731e5643eed60a", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "time": "2018-07-07T15:09:44+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Symfony\\Component\\OptionsResolver\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "config", + "include", + "tcpdf.php", + "tcpdf_parser.php", + "tcpdf_import.php", + "tcpdf_barcodes_1d.php", + "tcpdf_barcodes_2d.php", + "include/tcpdf_colors.php", + "include/tcpdf_filters.php", + "include/tcpdf_font_data.php", + "include/tcpdf_fonts.php", + "include/tcpdf_images.php", + "include/tcpdf_static.php", + "include/barcodes/datamatrix.php", + "include/barcodes/pdf417.php", + "include/barcodes/qrcode.php" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony OptionsResolver Component", - "homepage": "https://symfony.com", - "keywords": [ - "config", - "configuration", - "options" - ] - }, - { - "name": "php-http/multipart-stream-builder", - "version": "1.0.0", - "version_normalized": "1.0.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-http/multipart-stream-builder.git", - "reference": "1fa3c623fc813a43b39494b2a1612174e36e0fb0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/multipart-stream-builder/zipball/1fa3c623fc813a43b39494b2a1612174e36e0fb0", - "reference": "1fa3c623fc813a43b39494b2a1612174e36e0fb0", - "shasum": "" - }, - "require": { - "php": "^5.5 || ^7.0", - "php-http/discovery": "^1.0", - "php-http/message-factory": "^1.0.2", - "psr/http-message": "^1.0" - }, - "require-dev": { - "php-http/message": "^1.5", - "phpunit/phpunit": "^4.8 || ^5.4", - "zendframework/zend-diactoros": "^1.3.5" - }, - "time": "2017-05-21T17:45:25+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Http\\Message\\MultipartStream\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com" - } - ], - "description": "A builder class that help you create a multipart stream", - "homepage": "http://php-http.org", - "keywords": [ - "factory", - "http", - "message", - "multipart stream", - "stream" - ] - }, - { - "name": "php-http/client-common", - "version": "1.7.0", - "version_normalized": "1.7.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-http/client-common.git", - "reference": "9accb4a082eb06403747c0ffd444112eda41a0fd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-http/client-common/zipball/9accb4a082eb06403747c0ffd444112eda41a0fd", - "reference": "9accb4a082eb06403747c0ffd444112eda41a0fd", - "shasum": "" - }, - "require": { - "php": "^5.4 || ^7.0", - "php-http/httplug": "^1.1", - "php-http/message": "^1.6", - "php-http/message-factory": "^1.0", - "symfony/options-resolver": "^2.6 || ^3.0 || ^4.0" - }, - "require-dev": { - "guzzlehttp/psr7": "^1.4", - "phpspec/phpspec": "^2.5 || ^3.4 || ^4.2" - }, - "suggest": { - "php-http/cache-plugin": "PSR-6 Cache plugin", - "php-http/logger-plugin": "PSR-3 Logger plugin", - "php-http/stopwatch-plugin": "Symfony Stopwatch plugin" - }, - "time": "2017-11-30T11:06:59+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.7-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Http\\Client\\Common\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" + "LGPL-3.0" ], "authors": [ { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" + "name": "Nicola Asuni", + "email": "info@tecnick.com", + "role": "lead" } ], - "description": "Common HTTP Client implementations and tools for HTTPlug", - "homepage": "http://httplug.io", + "description": "TCPDF is a PHP class for generating PDF documents and barcodes.", + "homepage": "http://www.tcpdf.org/", "keywords": [ - "client", - "common", - "http", - "httplug" + "PDFD32000-2008", + "TCPDF", + "barcodes", + "datamatrix", + "pdf", + "pdf417", + "qrcode" ] }, { - "name": "m4tthumphrey/php-gitlab-api", - "version": "9.5.0", - "version_normalized": "9.5.0.0", + "name": "setasign/fpdi-tcpdf", + "version": "v2.1.0", + "version_normalized": "2.1.0.0", "source": { "type": "git", - "url": "https://github.com/m4tthumphrey/php-gitlab-api.git", - "reference": "010fe9fbf415ee0563f0f892ffa9363d1fb890ab" + "url": "https://github.com/Setasign/FPDI-TCPDF.git", + "reference": "9ebaf04475c0171d4b43b6eb579120ca02da22e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/m4tthumphrey/php-gitlab-api/zipball/010fe9fbf415ee0563f0f892ffa9363d1fb890ab", - "reference": "010fe9fbf415ee0563f0f892ffa9363d1fb890ab", + "url": "https://api.github.com/repos/Setasign/FPDI-TCPDF/zipball/9ebaf04475c0171d4b43b6eb579120ca02da22e8", + "reference": "9ebaf04475c0171d4b43b6eb579120ca02da22e8", "shasum": "" }, "require": { - "ext-xml": "*", - "php": "^5.6 || ^7.0", - "php-http/client-common": "^1.5", - "php-http/client-implementation": "^1.0", - "php-http/discovery": "^1.2", - "php-http/httplug": "^1.1", - "php-http/multipart-stream-builder": "^1.0", - "symfony/options-resolver": "^2.6 || ^3.0" - }, - "require-dev": { - "guzzlehttp/psr7": "^1.2", - "php-http/guzzle6-adapter": "^1.0", - "php-http/mock-client": "^1.0", - "phpunit/phpunit": "~4.5" + "setasign/fpdi": "^2.1", + "tecnickcom/tcpdf": "^6.2" }, - "time": "2017-10-11T08:57:20+00:00", + "time": "2018-11-06T10:38:50+00:00", "type": "library", - "extra": { - "branch-alias": { - "dev-master": "9.0.x-dev" - } - }, "installation-source": "dist", - "autoload": { - "psr-4": { - "Gitlab\\": "lib/Gitlab/" - } - }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { - "name": "Thibault Duplessis", - "email": "thibault.duplessis@gmail.com", - "homepage": "http://ornicar.github.com" - }, - { - "name": "KnpLabs Team", - "homepage": "http://knplabs.com" - }, - { - "name": "Matt Humphrey", - "homepage": "http://m4tt.io" + "name": "Jan Slabon", + "email": "jan.slabon@setasign.com", + "homepage": "https://www.setasign.com" } ], - "description": "GitLab API client", - "homepage": "https://github.com/m4tthumphrey/php-gitlab-api", + "description": "Kind of metadata package for dependencies of the latest versions of FPDI and TCPDF.", + "homepage": "https://www.setasign.com/fpdi", "keywords": [ - "api", - "gitlab" + "TCPDF", + "fpdi", + "pdf" ] } ] diff --git a/vendor/container-interop/container-interop/.gitignore b/vendor/container-interop/container-interop/.gitignore old mode 100755 new mode 100644 diff --git a/vendor/container-interop/container-interop/LICENSE b/vendor/container-interop/container-interop/LICENSE old mode 100755 new mode 100644 diff --git a/vendor/container-interop/container-interop/README.md b/vendor/container-interop/container-interop/README.md old mode 100755 new mode 100644 diff --git a/vendor/container-interop/container-interop/composer.json b/vendor/container-interop/container-interop/composer.json old mode 100755 new mode 100644 diff --git a/vendor/container-interop/container-interop/docs/ContainerInterface-meta.md b/vendor/container-interop/container-interop/docs/ContainerInterface-meta.md old mode 100755 new mode 100644 diff --git a/vendor/container-interop/container-interop/docs/ContainerInterface.md b/vendor/container-interop/container-interop/docs/ContainerInterface.md old mode 100755 new mode 100644 diff --git a/vendor/container-interop/container-interop/docs/Delegate-lookup-meta.md b/vendor/container-interop/container-interop/docs/Delegate-lookup-meta.md old mode 100755 new mode 100644 diff --git a/vendor/container-interop/container-interop/docs/Delegate-lookup.md b/vendor/container-interop/container-interop/docs/Delegate-lookup.md old mode 100755 new mode 100644 diff --git a/vendor/container-interop/container-interop/docs/images/interoperating_containers.png b/vendor/container-interop/container-interop/docs/images/interoperating_containers.png old mode 100755 new mode 100644 diff --git a/vendor/container-interop/container-interop/docs/images/priority.png b/vendor/container-interop/container-interop/docs/images/priority.png old mode 100755 new mode 100644 diff --git a/vendor/container-interop/container-interop/docs/images/side_by_side_containers.png b/vendor/container-interop/container-interop/docs/images/side_by_side_containers.png old mode 100755 new mode 100644 diff --git a/vendor/container-interop/container-interop/src/Interop/Container/ContainerInterface.php b/vendor/container-interop/container-interop/src/Interop/Container/ContainerInterface.php old mode 100755 new mode 100644 diff --git a/vendor/container-interop/container-interop/src/Interop/Container/Exception/ContainerException.php b/vendor/container-interop/container-interop/src/Interop/Container/Exception/ContainerException.php old mode 100755 new mode 100644 diff --git a/vendor/container-interop/container-interop/src/Interop/Container/Exception/NotFoundException.php b/vendor/container-interop/container-interop/src/Interop/Container/Exception/NotFoundException.php old mode 100755 new mode 100644 diff --git a/vendor/guzzlehttp/guzzle/CHANGELOG.md b/vendor/guzzlehttp/guzzle/CHANGELOG.md deleted file mode 100755 index 17badd756062b2fbb6d893750da457b88117d2f1..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/CHANGELOG.md +++ /dev/null @@ -1,1287 +0,0 @@ -# Change Log - -## 6.3.3 - 2018-04-22 - -* Fix: Default headers when decode_content is specified - - -## 6.3.2 - 2018-03-26 - -* Fix: Release process - - -## 6.3.1 - 2018-03-26 - -* Bug fix: Parsing 0 epoch expiry times in cookies [#2014](https://github.com/guzzle/guzzle/pull/2014) -* Improvement: Better ConnectException detection [#2012](https://github.com/guzzle/guzzle/pull/2012) -* Bug fix: Malformed domain that contains a "/" [#1999](https://github.com/guzzle/guzzle/pull/1999) -* Bug fix: Undefined offset when a cookie has no first key-value pair [#1998](https://github.com/guzzle/guzzle/pull/1998) -* Improvement: Support PHPUnit 6 [#1953](https://github.com/guzzle/guzzle/pull/1953) -* Bug fix: Support empty headers [#1915](https://github.com/guzzle/guzzle/pull/1915) -* Bug fix: Ignore case during header modifications [#1916](https://github.com/guzzle/guzzle/pull/1916) - -+ Minor code cleanups, documentation fixes and clarifications. - - -## 6.3.0 - 2017-06-22 - -* Feature: force IP resolution (ipv4 or ipv6) [#1608](https://github.com/guzzle/guzzle/pull/1608), [#1659](https://github.com/guzzle/guzzle/pull/1659) -* Improvement: Don't include summary in exception message when body is empty [#1621](https://github.com/guzzle/guzzle/pull/1621) -* Improvement: Handle `on_headers` option in MockHandler [#1580](https://github.com/guzzle/guzzle/pull/1580) -* Improvement: Added SUSE Linux CA path [#1609](https://github.com/guzzle/guzzle/issues/1609) -* Improvement: Use class reference for getting the name of the class instead of using hardcoded strings [#1641](https://github.com/guzzle/guzzle/pull/1641) -* Feature: Added `read_timeout` option [#1611](https://github.com/guzzle/guzzle/pull/1611) -* Bug fix: PHP 7.x fixes [#1685](https://github.com/guzzle/guzzle/pull/1685), [#1686](https://github.com/guzzle/guzzle/pull/1686), [#1811](https://github.com/guzzle/guzzle/pull/1811) -* Deprecation: BadResponseException instantiation without a response [#1642](https://github.com/guzzle/guzzle/pull/1642) -* Feature: Added NTLM auth [#1569](https://github.com/guzzle/guzzle/pull/1569) -* Feature: Track redirect HTTP status codes [#1711](https://github.com/guzzle/guzzle/pull/1711) -* Improvement: Check handler type during construction [#1745](https://github.com/guzzle/guzzle/pull/1745) -* Improvement: Always include the Content-Length if there's a body [#1721](https://github.com/guzzle/guzzle/pull/1721) -* Feature: Added convenience method to access a cookie by name [#1318](https://github.com/guzzle/guzzle/pull/1318) -* Bug fix: Fill `CURLOPT_CAPATH` and `CURLOPT_CAINFO` properly [#1684](https://github.com/guzzle/guzzle/pull/1684) -* Improvement: Use `\GuzzleHttp\Promise\rejection_for` function instead of object init [#1827](https://github.com/guzzle/guzzle/pull/1827) - - -+ Minor code cleanups, documentation fixes and clarifications. - -## 6.2.3 - 2017-02-28 - -* Fix deprecations with guzzle/psr7 version 1.4 - -## 6.2.2 - 2016-10-08 - -* Allow to pass nullable Response to delay callable -* Only add scheme when host is present -* Fix drain case where content-length is the literal string zero -* Obfuscate in-URL credentials in exceptions - -## 6.2.1 - 2016-07-18 - -* Address HTTP_PROXY security vulnerability, CVE-2016-5385: - https://httpoxy.org/ -* Fixing timeout bug with StreamHandler: - https://github.com/guzzle/guzzle/pull/1488 -* Only read up to `Content-Length` in PHP StreamHandler to avoid timeouts when - a server does not honor `Connection: close`. -* Ignore URI fragment when sending requests. - -## 6.2.0 - 2016-03-21 - -* Feature: added `GuzzleHttp\json_encode` and `GuzzleHttp\json_decode`. - https://github.com/guzzle/guzzle/pull/1389 -* Bug fix: Fix sleep calculation when waiting for delayed requests. - https://github.com/guzzle/guzzle/pull/1324 -* Feature: More flexible history containers. - https://github.com/guzzle/guzzle/pull/1373 -* Bug fix: defer sink stream opening in StreamHandler. - https://github.com/guzzle/guzzle/pull/1377 -* Bug fix: do not attempt to escape cookie values. - https://github.com/guzzle/guzzle/pull/1406 -* Feature: report original content encoding and length on decoded responses. - https://github.com/guzzle/guzzle/pull/1409 -* Bug fix: rewind seekable request bodies before dispatching to cURL. - https://github.com/guzzle/guzzle/pull/1422 -* Bug fix: provide an empty string to `http_build_query` for HHVM workaround. - https://github.com/guzzle/guzzle/pull/1367 - -## 6.1.1 - 2015-11-22 - -* Bug fix: Proxy::wrapSync() now correctly proxies to the appropriate handler - https://github.com/guzzle/guzzle/commit/911bcbc8b434adce64e223a6d1d14e9a8f63e4e4 -* Feature: HandlerStack is now more generic. - https://github.com/guzzle/guzzle/commit/f2102941331cda544745eedd97fc8fd46e1ee33e -* Bug fix: setting verify to false in the StreamHandler now disables peer - verification. https://github.com/guzzle/guzzle/issues/1256 -* Feature: Middleware now uses an exception factory, including more error - context. https://github.com/guzzle/guzzle/pull/1282 -* Feature: better support for disabled functions. - https://github.com/guzzle/guzzle/pull/1287 -* Bug fix: fixed regression where MockHandler was not using `sink`. - https://github.com/guzzle/guzzle/pull/1292 - -## 6.1.0 - 2015-09-08 - -* Feature: Added the `on_stats` request option to provide access to transfer - statistics for requests. https://github.com/guzzle/guzzle/pull/1202 -* Feature: Added the ability to persist session cookies in CookieJars. - https://github.com/guzzle/guzzle/pull/1195 -* Feature: Some compatibility updates for Google APP Engine - https://github.com/guzzle/guzzle/pull/1216 -* Feature: Added support for NO_PROXY to prevent the use of a proxy based on - a simple set of rules. https://github.com/guzzle/guzzle/pull/1197 -* Feature: Cookies can now contain square brackets. - https://github.com/guzzle/guzzle/pull/1237 -* Bug fix: Now correctly parsing `=` inside of quotes in Cookies. - https://github.com/guzzle/guzzle/pull/1232 -* Bug fix: Cusotm cURL options now correctly override curl options of the - same name. https://github.com/guzzle/guzzle/pull/1221 -* Bug fix: Content-Type header is now added when using an explicitly provided - multipart body. https://github.com/guzzle/guzzle/pull/1218 -* Bug fix: Now ignoring Set-Cookie headers that have no name. -* Bug fix: Reason phrase is no longer cast to an int in some cases in the - cURL handler. https://github.com/guzzle/guzzle/pull/1187 -* Bug fix: Remove the Authorization header when redirecting if the Host - header changes. https://github.com/guzzle/guzzle/pull/1207 -* Bug fix: Cookie path matching fixes - https://github.com/guzzle/guzzle/issues/1129 -* Bug fix: Fixing the cURL `body_as_string` setting - https://github.com/guzzle/guzzle/pull/1201 -* Bug fix: quotes are no longer stripped when parsing cookies. - https://github.com/guzzle/guzzle/issues/1172 -* Bug fix: `form_params` and `query` now always uses the `&` separator. - https://github.com/guzzle/guzzle/pull/1163 -* Bug fix: Adding a Content-Length to PHP stream wrapper requests if not set. - https://github.com/guzzle/guzzle/pull/1189 - -## 6.0.2 - 2015-07-04 - -* Fixed a memory leak in the curl handlers in which references to callbacks - were not being removed by `curl_reset`. -* Cookies are now extracted properly before redirects. -* Cookies now allow more character ranges. -* Decoded Content-Encoding responses are now modified to correctly reflect - their state if the encoding was automatically removed by a handler. This - means that the `Content-Encoding` header may be removed an the - `Content-Length` modified to reflect the message size after removing the - encoding. -* Added a more explicit error message when trying to use `form_params` and - `multipart` in the same request. -* Several fixes for HHVM support. -* Functions are now conditionally required using an additional level of - indirection to help with global Composer installations. - -## 6.0.1 - 2015-05-27 - -* Fixed a bug with serializing the `query` request option where the `&` - separator was missing. -* Added a better error message for when `body` is provided as an array. Please - use `form_params` or `multipart` instead. -* Various doc fixes. - -## 6.0.0 - 2015-05-26 - -* See the UPGRADING.md document for more information. -* Added `multipart` and `form_params` request options. -* Added `synchronous` request option. -* Added the `on_headers` request option. -* Fixed `expect` handling. -* No longer adding default middlewares in the client ctor. These need to be - present on the provided handler in order to work. -* Requests are no longer initiated when sending async requests with the - CurlMultiHandler. This prevents unexpected recursion from requests completing - while ticking the cURL loop. -* Removed the semantics of setting `default` to `true`. This is no longer - required now that the cURL loop is not ticked for async requests. -* Added request and response logging middleware. -* No longer allowing self signed certificates when using the StreamHandler. -* Ensuring that `sink` is valid if saving to a file. -* Request exceptions now include a "handler context" which provides handler - specific contextual information. -* Added `GuzzleHttp\RequestOptions` to allow request options to be applied - using constants. -* `$maxHandles` has been removed from CurlMultiHandler. -* `MultipartPostBody` is now part of the `guzzlehttp/psr7` package. - -## 5.3.0 - 2015-05-19 - -* Mock now supports `save_to` -* Marked `AbstractRequestEvent::getTransaction()` as public. -* Fixed a bug in which multiple headers using different casing would overwrite - previous headers in the associative array. -* Added `Utils::getDefaultHandler()` -* Marked `GuzzleHttp\Client::getDefaultUserAgent` as deprecated. -* URL scheme is now always lowercased. - -## 6.0.0-beta.1 - -* Requires PHP >= 5.5 -* Updated to use PSR-7 - * Requires immutable messages, which basically means an event based system - owned by a request instance is no longer possible. - * Utilizing the [Guzzle PSR-7 package](https://github.com/guzzle/psr7). - * Removed the dependency on `guzzlehttp/streams`. These stream abstractions - are available in the `guzzlehttp/psr7` package under the `GuzzleHttp\Psr7` - namespace. -* Added middleware and handler system - * Replaced the Guzzle event and subscriber system with a middleware system. - * No longer depends on RingPHP, but rather places the HTTP handlers directly - in Guzzle, operating on PSR-7 messages. - * Retry logic is now encapsulated in `GuzzleHttp\Middleware::retry`, which - means the `guzzlehttp/retry-subscriber` is now obsolete. - * Mocking responses is now handled using `GuzzleHttp\Handler\MockHandler`. -* Asynchronous responses - * No longer supports the `future` request option to send an async request. - Instead, use one of the `*Async` methods of a client (e.g., `requestAsync`, - `getAsync`, etc.). - * Utilizing `GuzzleHttp\Promise` instead of React's promise library to avoid - recursion required by chaining and forwarding react promises. See - https://github.com/guzzle/promises - * Added `requestAsync` and `sendAsync` to send request asynchronously. - * Added magic methods for `getAsync()`, `postAsync()`, etc. to send requests - asynchronously. -* Request options - * POST and form updates - * Added the `form_fields` and `form_files` request options. - * Removed the `GuzzleHttp\Post` namespace. - * The `body` request option no longer accepts an array for POST requests. - * The `exceptions` request option has been deprecated in favor of the - `http_errors` request options. - * The `save_to` request option has been deprecated in favor of `sink` request - option. -* Clients no longer accept an array of URI template string and variables for - URI variables. You will need to expand URI templates before passing them - into a client constructor or request method. -* Client methods `get()`, `post()`, `put()`, `patch()`, `options()`, etc. are - now magic methods that will send synchronous requests. -* Replaced `Utils.php` with plain functions in `functions.php`. -* Removed `GuzzleHttp\Collection`. -* Removed `GuzzleHttp\BatchResults`. Batched pool results are now returned as - an array. -* Removed `GuzzleHttp\Query`. Query string handling is now handled using an - associative array passed into the `query` request option. The query string - is serialized using PHP's `http_build_query`. If you need more control, you - can pass the query string in as a string. -* `GuzzleHttp\QueryParser` has been replaced with the - `GuzzleHttp\Psr7\parse_query`. - -## 5.2.0 - 2015-01-27 - -* Added `AppliesHeadersInterface` to make applying headers to a request based - on the body more generic and not specific to `PostBodyInterface`. -* Reduced the number of stack frames needed to send requests. -* Nested futures are now resolved in the client rather than the RequestFsm -* Finishing state transitions is now handled in the RequestFsm rather than the - RingBridge. -* Added a guard in the Pool class to not use recursion for request retries. - -## 5.1.0 - 2014-12-19 - -* Pool class no longer uses recursion when a request is intercepted. -* The size of a Pool can now be dynamically adjusted using a callback. - See https://github.com/guzzle/guzzle/pull/943. -* Setting a request option to `null` when creating a request with a client will - ensure that the option is not set. This allows you to overwrite default - request options on a per-request basis. - See https://github.com/guzzle/guzzle/pull/937. -* Added the ability to limit which protocols are allowed for redirects by - specifying a `protocols` array in the `allow_redirects` request option. -* Nested futures due to retries are now resolved when waiting for synchronous - responses. See https://github.com/guzzle/guzzle/pull/947. -* `"0"` is now an allowed URI path. See - https://github.com/guzzle/guzzle/pull/935. -* `Query` no longer typehints on the `$query` argument in the constructor, - allowing for strings and arrays. -* Exceptions thrown in the `end` event are now correctly wrapped with Guzzle - specific exceptions if necessary. - -## 5.0.3 - 2014-11-03 - -This change updates query strings so that they are treated as un-encoded values -by default where the value represents an un-encoded value to send over the -wire. A Query object then encodes the value before sending over the wire. This -means that even value query string values (e.g., ":") are url encoded. This -makes the Query class match PHP's http_build_query function. However, if you -want to send requests over the wire using valid query string characters that do -not need to be encoded, then you can provide a string to Url::setQuery() and -pass true as the second argument to specify that the query string is a raw -string that should not be parsed or encoded (unless a call to getQuery() is -subsequently made, forcing the query-string to be converted into a Query -object). - -## 5.0.2 - 2014-10-30 - -* Added a trailing `\r\n` to multipart/form-data payloads. See - https://github.com/guzzle/guzzle/pull/871 -* Added a `GuzzleHttp\Pool::send()` convenience method to match the docs. -* Status codes are now returned as integers. See - https://github.com/guzzle/guzzle/issues/881 -* No longer overwriting an existing `application/x-www-form-urlencoded` header - when sending POST requests, allowing for customized headers. See - https://github.com/guzzle/guzzle/issues/877 -* Improved path URL serialization. - - * No longer double percent-encoding characters in the path or query string if - they are already encoded. - * Now properly encoding the supplied path to a URL object, instead of only - encoding ' ' and '?'. - * Note: This has been changed in 5.0.3 to now encode query string values by - default unless the `rawString` argument is provided when setting the query - string on a URL: Now allowing many more characters to be present in the - query string without being percent encoded. See http://tools.ietf.org/html/rfc3986#appendix-A - -## 5.0.1 - 2014-10-16 - -Bugfix release. - -* Fixed an issue where connection errors still returned response object in - error and end events event though the response is unusable. This has been - corrected so that a response is not returned in the `getResponse` method of - these events if the response did not complete. https://github.com/guzzle/guzzle/issues/867 -* Fixed an issue where transfer statistics were not being populated in the - RingBridge. https://github.com/guzzle/guzzle/issues/866 - -## 5.0.0 - 2014-10-12 - -Adding support for non-blocking responses and some minor API cleanup. - -### New Features - -* Added support for non-blocking responses based on `guzzlehttp/guzzle-ring`. -* Added a public API for creating a default HTTP adapter. -* Updated the redirect plugin to be non-blocking so that redirects are sent - concurrently. Other plugins like this can now be updated to be non-blocking. -* Added a "progress" event so that you can get upload and download progress - events. -* Added `GuzzleHttp\Pool` which implements FutureInterface and transfers - requests concurrently using a capped pool size as efficiently as possible. -* Added `hasListeners()` to EmitterInterface. -* Removed `GuzzleHttp\ClientInterface::sendAll` and marked - `GuzzleHttp\Client::sendAll` as deprecated (it's still there, just not the - recommended way). - -### Breaking changes - -The breaking changes in this release are relatively minor. The biggest thing to -look out for is that request and response objects no longer implement fluent -interfaces. - -* Removed the fluent interfaces (i.e., `return $this`) from requests, - responses, `GuzzleHttp\Collection`, `GuzzleHttp\Url`, - `GuzzleHttp\Query`, `GuzzleHttp\Post\PostBody`, and - `GuzzleHttp\Cookie\SetCookie`. This blog post provides a good outline of - why I did this: http://ocramius.github.io/blog/fluent-interfaces-are-evil/. - This also makes the Guzzle message interfaces compatible with the current - PSR-7 message proposal. -* Removed "functions.php", so that Guzzle is truly PSR-4 compliant. Except - for the HTTP request functions from function.php, these functions are now - implemented in `GuzzleHttp\Utils` using camelCase. `GuzzleHttp\json_decode` - moved to `GuzzleHttp\Utils::jsonDecode`. `GuzzleHttp\get_path` moved to - `GuzzleHttp\Utils::getPath`. `GuzzleHttp\set_path` moved to - `GuzzleHttp\Utils::setPath`. `GuzzleHttp\batch` should now be - `GuzzleHttp\Pool::batch`, which returns an `objectStorage`. Using functions.php - caused problems for many users: they aren't PSR-4 compliant, require an - explicit include, and needed an if-guard to ensure that the functions are not - declared multiple times. -* Rewrote adapter layer. - * Removing all classes from `GuzzleHttp\Adapter`, these are now - implemented as callables that are stored in `GuzzleHttp\Ring\Client`. - * Removed the concept of "parallel adapters". Sending requests serially or - concurrently is now handled using a single adapter. - * Moved `GuzzleHttp\Adapter\Transaction` to `GuzzleHttp\Transaction`. The - Transaction object now exposes the request, response, and client as public - properties. The getters and setters have been removed. -* Removed the "headers" event. This event was only useful for changing the - body a response once the headers of the response were known. You can implement - a similar behavior in a number of ways. One example might be to use a - FnStream that has access to the transaction being sent. For example, when the - first byte is written, you could check if the response headers match your - expectations, and if so, change the actual stream body that is being - written to. -* Removed the `asArray` parameter from - `GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header - value as an array, then use the newly added `getHeaderAsArray()` method of - `MessageInterface`. This change makes the Guzzle interfaces compatible with - the PSR-7 interfaces. -* `GuzzleHttp\Message\MessageFactory` no longer allows subclasses to add - custom request options using double-dispatch (this was an implementation - detail). Instead, you should now provide an associative array to the - constructor which is a mapping of the request option name mapping to a - function that applies the option value to a request. -* Removed the concept of "throwImmediately" from exceptions and error events. - This control mechanism was used to stop a transfer of concurrent requests - from completing. This can now be handled by throwing the exception or by - cancelling a pool of requests or each outstanding future request individually. -* Updated to "GuzzleHttp\Streams" 3.0. - * `GuzzleHttp\Stream\StreamInterface::getContents()` no longer accepts a - `maxLen` parameter. This update makes the Guzzle streams project - compatible with the current PSR-7 proposal. - * `GuzzleHttp\Stream\Stream::__construct`, - `GuzzleHttp\Stream\Stream::factory`, and - `GuzzleHttp\Stream\Utils::create` no longer accept a size in the second - argument. They now accept an associative array of options, including the - "size" key and "metadata" key which can be used to provide custom metadata. - -## 4.2.2 - 2014-09-08 - -* Fixed a memory leak in the CurlAdapter when reusing cURL handles. -* No longer using `request_fulluri` in stream adapter proxies. -* Relative redirects are now based on the last response, not the first response. - -## 4.2.1 - 2014-08-19 - -* Ensuring that the StreamAdapter does not always add a Content-Type header -* Adding automated github releases with a phar and zip - -## 4.2.0 - 2014-08-17 - -* Now merging in default options using a case-insensitive comparison. - Closes https://github.com/guzzle/guzzle/issues/767 -* Added the ability to automatically decode `Content-Encoding` response bodies - using the `decode_content` request option. This is set to `true` by default - to decode the response body if it comes over the wire with a - `Content-Encoding`. Set this value to `false` to disable decoding the - response content, and pass a string to provide a request `Accept-Encoding` - header and turn on automatic response decoding. This feature now allows you - to pass an `Accept-Encoding` header in the headers of a request but still - disable automatic response decoding. - Closes https://github.com/guzzle/guzzle/issues/764 -* Added the ability to throw an exception immediately when transferring - requests in parallel. Closes https://github.com/guzzle/guzzle/issues/760 -* Updating guzzlehttp/streams dependency to ~2.1 -* No longer utilizing the now deprecated namespaced methods from the stream - package. - -## 4.1.8 - 2014-08-14 - -* Fixed an issue in the CurlFactory that caused setting the `stream=false` - request option to throw an exception. - See: https://github.com/guzzle/guzzle/issues/769 -* TransactionIterator now calls rewind on the inner iterator. - See: https://github.com/guzzle/guzzle/pull/765 -* You can now set the `Content-Type` header to `multipart/form-data` - when creating POST requests to force multipart bodies. - See https://github.com/guzzle/guzzle/issues/768 - -## 4.1.7 - 2014-08-07 - -* Fixed an error in the HistoryPlugin that caused the same request and response - to be logged multiple times when an HTTP protocol error occurs. -* Ensuring that cURL does not add a default Content-Type when no Content-Type - has been supplied by the user. This prevents the adapter layer from modifying - the request that is sent over the wire after any listeners may have already - put the request in a desired state (e.g., signed the request). -* Throwing an exception when you attempt to send requests that have the - "stream" set to true in parallel using the MultiAdapter. -* Only calling curl_multi_select when there are active cURL handles. This was - previously changed and caused performance problems on some systems due to PHP - always selecting until the maximum select timeout. -* Fixed a bug where multipart/form-data POST fields were not correctly - aggregated (e.g., values with "&"). - -## 4.1.6 - 2014-08-03 - -* Added helper methods to make it easier to represent messages as strings, - including getting the start line and getting headers as a string. - -## 4.1.5 - 2014-08-02 - -* Automatically retrying cURL "Connection died, retrying a fresh connect" - errors when possible. -* cURL implementation cleanup -* Allowing multiple event subscriber listeners to be registered per event by - passing an array of arrays of listener configuration. - -## 4.1.4 - 2014-07-22 - -* Fixed a bug that caused multi-part POST requests with more than one field to - serialize incorrectly. -* Paths can now be set to "0" -* `ResponseInterface::xml` now accepts a `libxml_options` option and added a - missing default argument that was required when parsing XML response bodies. -* A `save_to` stream is now created lazily, which means that files are not - created on disk unless a request succeeds. - -## 4.1.3 - 2014-07-15 - -* Various fixes to multipart/form-data POST uploads -* Wrapping function.php in an if-statement to ensure Guzzle can be used - globally and in a Composer install -* Fixed an issue with generating and merging in events to an event array -* POST headers are only applied before sending a request to allow you to change - the query aggregator used before uploading -* Added much more robust query string parsing -* Fixed various parsing and normalization issues with URLs -* Fixing an issue where multi-valued headers were not being utilized correctly - in the StreamAdapter - -## 4.1.2 - 2014-06-18 - -* Added support for sending payloads with GET requests - -## 4.1.1 - 2014-06-08 - -* Fixed an issue related to using custom message factory options in subclasses -* Fixed an issue with nested form fields in a multi-part POST -* Fixed an issue with using the `json` request option for POST requests -* Added `ToArrayInterface` to `GuzzleHttp\Cookie\CookieJar` - -## 4.1.0 - 2014-05-27 - -* Added a `json` request option to easily serialize JSON payloads. -* Added a `GuzzleHttp\json_decode()` wrapper to safely parse JSON. -* Added `setPort()` and `getPort()` to `GuzzleHttp\Message\RequestInterface`. -* Added the ability to provide an emitter to a client in the client constructor. -* Added the ability to persist a cookie session using $_SESSION. -* Added a trait that can be used to add event listeners to an iterator. -* Removed request method constants from RequestInterface. -* Fixed warning when invalid request start-lines are received. -* Updated MessageFactory to work with custom request option methods. -* Updated cacert bundle to latest build. - -4.0.2 (2014-04-16) ------------------- - -* Proxy requests using the StreamAdapter now properly use request_fulluri (#632) -* Added the ability to set scalars as POST fields (#628) - -## 4.0.1 - 2014-04-04 - -* The HTTP status code of a response is now set as the exception code of - RequestException objects. -* 303 redirects will now correctly switch from POST to GET requests. -* The default parallel adapter of a client now correctly uses the MultiAdapter. -* HasDataTrait now initializes the internal data array as an empty array so - that the toArray() method always returns an array. - -## 4.0.0 - 2014-03-29 - -* For more information on the 4.0 transition, see: - http://mtdowling.com/blog/2014/03/15/guzzle-4-rc/ -* For information on changes and upgrading, see: - https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40 -* Added `GuzzleHttp\batch()` as a convenience function for sending requests in - parallel without needing to write asynchronous code. -* Restructured how events are added to `GuzzleHttp\ClientInterface::sendAll()`. - You can now pass a callable or an array of associative arrays where each - associative array contains the "fn", "priority", and "once" keys. - -## 4.0.0.rc-2 - 2014-03-25 - -* Removed `getConfig()` and `setConfig()` from clients to avoid confusion - around whether things like base_url, message_factory, etc. should be able to - be retrieved or modified. -* Added `getDefaultOption()` and `setDefaultOption()` to ClientInterface -* functions.php functions were renamed using snake_case to match PHP idioms -* Added support for `HTTP_PROXY`, `HTTPS_PROXY`, and - `GUZZLE_CURL_SELECT_TIMEOUT` environment variables -* Added the ability to specify custom `sendAll()` event priorities -* Added the ability to specify custom stream context options to the stream - adapter. -* Added a functions.php function for `get_path()` and `set_path()` -* CurlAdapter and MultiAdapter now use a callable to generate curl resources -* MockAdapter now properly reads a body and emits a `headers` event -* Updated Url class to check if a scheme and host are set before adding ":" - and "//". This allows empty Url (e.g., "") to be serialized as "". -* Parsing invalid XML no longer emits warnings -* Curl classes now properly throw AdapterExceptions -* Various performance optimizations -* Streams are created with the faster `Stream\create()` function -* Marked deprecation_proxy() as internal -* Test server is now a collection of static methods on a class - -## 4.0.0-rc.1 - 2014-03-15 - -* See https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40 - -## 3.8.1 - 2014-01-28 - -* Bug: Always using GET requests when redirecting from a 303 response -* Bug: CURLOPT_SSL_VERIFYHOST is now correctly set to false when setting `$certificateAuthority` to false in - `Guzzle\Http\ClientInterface::setSslVerification()` -* Bug: RedirectPlugin now uses strict RFC 3986 compliance when combining a base URL with a relative URL -* Bug: The body of a request can now be set to `"0"` -* Sending PHP stream requests no longer forces `HTTP/1.0` -* Adding more information to ExceptionCollection exceptions so that users have more context, including a stack trace of - each sub-exception -* Updated the `$ref` attribute in service descriptions to merge over any existing parameters of a schema (rather than - clobbering everything). -* Merging URLs will now use the query string object from the relative URL (thus allowing custom query aggregators) -* Query strings are now parsed in a way that they do no convert empty keys with no value to have a dangling `=`. - For example `foo&bar=baz` is now correctly parsed and recognized as `foo&bar=baz` rather than `foo=&bar=baz`. -* Now properly escaping the regular expression delimiter when matching Cookie domains. -* Network access is now disabled when loading XML documents - -## 3.8.0 - 2013-12-05 - -* Added the ability to define a POST name for a file -* JSON response parsing now properly walks additionalProperties -* cURL error code 18 is now retried automatically in the BackoffPlugin -* Fixed a cURL error when URLs contain fragments -* Fixed an issue in the BackoffPlugin retry event where it was trying to access all exceptions as if they were - CurlExceptions -* CURLOPT_PROGRESS function fix for PHP 5.5 (69fcc1e) -* Added the ability for Guzzle to work with older versions of cURL that do not support `CURLOPT_TIMEOUT_MS` -* Fixed a bug that was encountered when parsing empty header parameters -* UriTemplate now has a `setRegex()` method to match the docs -* The `debug` request parameter now checks if it is truthy rather than if it exists -* Setting the `debug` request parameter to true shows verbose cURL output instead of using the LogPlugin -* Added the ability to combine URLs using strict RFC 3986 compliance -* Command objects can now return the validation errors encountered by the command -* Various fixes to cache revalidation (#437 and 29797e5) -* Various fixes to the AsyncPlugin -* Cleaned up build scripts - -## 3.7.4 - 2013-10-02 - -* Bug fix: 0 is now an allowed value in a description parameter that has a default value (#430) -* Bug fix: SchemaFormatter now returns an integer when formatting to a Unix timestamp - (see https://github.com/aws/aws-sdk-php/issues/147) -* Bug fix: Cleaned up and fixed URL dot segment removal to properly resolve internal dots -* Minimum PHP version is now properly specified as 5.3.3 (up from 5.3.2) (#420) -* Updated the bundled cacert.pem (#419) -* OauthPlugin now supports adding authentication to headers or query string (#425) - -## 3.7.3 - 2013-09-08 - -* Added the ability to get the exception associated with a request/command when using `MultiTransferException` and - `CommandTransferException`. -* Setting `additionalParameters` of a response to false is now honored when parsing responses with a service description -* Schemas are only injected into response models when explicitly configured. -* No longer guessing Content-Type based on the path of a request. Content-Type is now only guessed based on the path of - an EntityBody. -* Bug fix: ChunkedIterator can now properly chunk a \Traversable as well as an \Iterator. -* Bug fix: FilterIterator now relies on `\Iterator` instead of `\Traversable`. -* Bug fix: Gracefully handling malformed responses in RequestMediator::writeResponseBody() -* Bug fix: Replaced call to canCache with canCacheRequest in the CallbackCanCacheStrategy of the CachePlugin -* Bug fix: Visiting XML attributes first before visiting XML children when serializing requests -* Bug fix: Properly parsing headers that contain commas contained in quotes -* Bug fix: mimetype guessing based on a filename is now case-insensitive - -## 3.7.2 - 2013-08-02 - -* Bug fix: Properly URL encoding paths when using the PHP-only version of the UriTemplate expander - See https://github.com/guzzle/guzzle/issues/371 -* Bug fix: Cookie domains are now matched correctly according to RFC 6265 - See https://github.com/guzzle/guzzle/issues/377 -* Bug fix: GET parameters are now used when calculating an OAuth signature -* Bug fix: Fixed an issue with cache revalidation where the If-None-Match header was being double quoted -* `Guzzle\Common\AbstractHasDispatcher::dispatch()` now returns the event that was dispatched -* `Guzzle\Http\QueryString::factory()` now guesses the most appropriate query aggregator to used based on the input. - See https://github.com/guzzle/guzzle/issues/379 -* Added a way to add custom domain objects to service description parsing using the `operation.parse_class` event. See - https://github.com/guzzle/guzzle/pull/380 -* cURL multi cleanup and optimizations - -## 3.7.1 - 2013-07-05 - -* Bug fix: Setting default options on a client now works -* Bug fix: Setting options on HEAD requests now works. See #352 -* Bug fix: Moving stream factory before send event to before building the stream. See #353 -* Bug fix: Cookies no longer match on IP addresses per RFC 6265 -* Bug fix: Correctly parsing header parameters that are in `<>` and quotes -* Added `cert` and `ssl_key` as request options -* `Host` header can now diverge from the host part of a URL if the header is set manually -* `Guzzle\Service\Command\LocationVisitor\Request\XmlVisitor` was rewritten to change from using SimpleXML to XMLWriter -* OAuth parameters are only added via the plugin if they aren't already set -* Exceptions are now thrown when a URL cannot be parsed -* Returning `false` if `Guzzle\Http\EntityBody::getContentMd5()` fails -* Not setting a `Content-MD5` on a command if calculating the Content-MD5 fails via the CommandContentMd5Plugin - -## 3.7.0 - 2013-06-10 - -* See UPGRADING.md for more information on how to upgrade. -* Requests now support the ability to specify an array of $options when creating a request to more easily modify a - request. You can pass a 'request.options' configuration setting to a client to apply default request options to - every request created by a client (e.g. default query string variables, headers, curl options, etc.). -* Added a static facade class that allows you to use Guzzle with static methods and mount the class to `\Guzzle`. - See `Guzzle\Http\StaticClient::mount`. -* Added `command.request_options` to `Guzzle\Service\Command\AbstractCommand` to pass request options to requests - created by a command (e.g. custom headers, query string variables, timeout settings, etc.). -* Stream size in `Guzzle\Stream\PhpStreamRequestFactory` will now be set if Content-Length is returned in the - headers of a response -* Added `Guzzle\Common\Collection::setPath($path, $value)` to set a value into an array using a nested key - (e.g. `$collection->setPath('foo/baz/bar', 'test'); echo $collection['foo']['bar']['bar'];`) -* ServiceBuilders now support storing and retrieving arbitrary data -* CachePlugin can now purge all resources for a given URI -* CachePlugin can automatically purge matching cached items when a non-idempotent request is sent to a resource -* CachePlugin now uses the Vary header to determine if a resource is a cache hit -* `Guzzle\Http\Message\Response` now implements `\Serializable` -* Added `Guzzle\Cache\CacheAdapterFactory::fromCache()` to more easily create cache adapters -* `Guzzle\Service\ClientInterface::execute()` now accepts an array, single command, or Traversable -* Fixed a bug in `Guzzle\Http\Message\Header\Link::addLink()` -* Better handling of calculating the size of a stream in `Guzzle\Stream\Stream` using fstat() and caching the size -* `Guzzle\Common\Exception\ExceptionCollection` now creates a more readable exception message -* Fixing BC break: Added back the MonologLogAdapter implementation rather than extending from PsrLog so that older - Symfony users can still use the old version of Monolog. -* Fixing BC break: Added the implementation back in for `Guzzle\Http\Message\AbstractMessage::getTokenizedHeader()`. - Now triggering an E_USER_DEPRECATED warning when used. Use `$message->getHeader()->parseParams()`. -* Several performance improvements to `Guzzle\Common\Collection` -* Added an `$options` argument to the end of the following methods of `Guzzle\Http\ClientInterface`: - createRequest, head, delete, put, patch, post, options, prepareRequest -* Added an `$options` argument to the end of `Guzzle\Http\Message\Request\RequestFactoryInterface::createRequest()` -* Added an `applyOptions()` method to `Guzzle\Http\Message\Request\RequestFactoryInterface` -* Changed `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $body = null)` to - `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $options = array())`. You can still pass in a - resource, string, or EntityBody into the $options parameter to specify the download location of the response. -* Changed `Guzzle\Common\Collection::__construct($data)` to no longer accepts a null value for `$data` but a - default `array()` -* Added `Guzzle\Stream\StreamInterface::isRepeatable` -* Removed `Guzzle\Http\ClientInterface::setDefaultHeaders(). Use - $client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. or - $client->getConfig()->setPath('request.options/headers', array('header_name' => 'value'))`. -* Removed `Guzzle\Http\ClientInterface::getDefaultHeaders(). Use $client->getConfig()->getPath('request.options/headers')`. -* Removed `Guzzle\Http\ClientInterface::expandTemplate()` -* Removed `Guzzle\Http\ClientInterface::setRequestFactory()` -* Removed `Guzzle\Http\ClientInterface::getCurlMulti()` -* Removed `Guzzle\Http\Message\RequestInterface::canCache` -* Removed `Guzzle\Http\Message\RequestInterface::setIsRedirect` -* Removed `Guzzle\Http\Message\RequestInterface::isRedirect` -* Made `Guzzle\Http\Client::expandTemplate` and `getUriTemplate` protected methods. -* You can now enable E_USER_DEPRECATED warnings to see if you are using a deprecated method by setting - `Guzzle\Common\Version::$emitWarnings` to true. -* Marked `Guzzle\Http\Message\Request::isResponseBodyRepeatable()` as deprecated. Use - `$request->getResponseBody()->isRepeatable()` instead. -* Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use - `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead. -* Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use - `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead. -* Marked `Guzzle\Http\Message\Request::setIsRedirect()` as deprecated. Use the HistoryPlugin instead. -* Marked `Guzzle\Http\Message\Request::isRedirect()` as deprecated. Use the HistoryPlugin instead. -* Marked `Guzzle\Cache\CacheAdapterFactory::factory()` as deprecated -* Marked 'command.headers', 'command.response_body' and 'command.on_complete' as deprecated for AbstractCommand. - These will work through Guzzle 4.0 -* Marked 'request.params' for `Guzzle\Http\Client` as deprecated. Use [request.options][params]. -* Marked `Guzzle\Service\Client::enableMagicMethods()` as deprecated. Magic methods can no longer be disabled on a Guzzle\Service\Client. -* Marked `Guzzle\Service\Client::getDefaultHeaders()` as deprecated. Use $client->getConfig()->getPath('request.options/headers')`. -* Marked `Guzzle\Service\Client::setDefaultHeaders()` as deprecated. Use $client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. -* Marked `Guzzle\Parser\Url\UrlParser` as deprecated. Just use PHP's `parse_url()` and percent encode your UTF-8. -* Marked `Guzzle\Common\Collection::inject()` as deprecated. -* Marked `Guzzle\Plugin\CurlAuth\CurlAuthPlugin` as deprecated. Use `$client->getConfig()->setPath('request.options/auth', array('user', 'pass', 'Basic|Digest');` -* CacheKeyProviderInterface and DefaultCacheKeyProvider are no longer used. All of this logic is handled in a - CacheStorageInterface. These two objects and interface will be removed in a future version. -* Always setting X-cache headers on cached responses -* Default cache TTLs are now handled by the CacheStorageInterface of a CachePlugin -* `CacheStorageInterface::cache($key, Response $response, $ttl = null)` has changed to `cache(RequestInterface - $request, Response $response);` -* `CacheStorageInterface::fetch($key)` has changed to `fetch(RequestInterface $request);` -* `CacheStorageInterface::delete($key)` has changed to `delete(RequestInterface $request);` -* Added `CacheStorageInterface::purge($url)` -* `DefaultRevalidation::__construct(CacheKeyProviderInterface $cacheKey, CacheStorageInterface $cache, CachePlugin - $plugin)` has changed to `DefaultRevalidation::__construct(CacheStorageInterface $cache, - CanCacheStrategyInterface $canCache = null)` -* Added `RevalidationInterface::shouldRevalidate(RequestInterface $request, Response $response)` - -## 3.6.0 - 2013-05-29 - -* ServiceDescription now implements ToArrayInterface -* Added command.hidden_params to blacklist certain headers from being treated as additionalParameters -* Guzzle can now correctly parse incomplete URLs -* Mixed casing of headers are now forced to be a single consistent casing across all values for that header. -* Messages internally use a HeaderCollection object to delegate handling case-insensitive header resolution -* Removed the whole changedHeader() function system of messages because all header changes now go through addHeader(). -* Specific header implementations can be created for complex headers. When a message creates a header, it uses a - HeaderFactory which can map specific headers to specific header classes. There is now a Link header and - CacheControl header implementation. -* Removed from interface: Guzzle\Http\ClientInterface::setUriTemplate -* Removed from interface: Guzzle\Http\ClientInterface::setCurlMulti() -* Removed Guzzle\Http\Message\Request::receivedRequestHeader() and implemented this functionality in - Guzzle\Http\Curl\RequestMediator -* Removed the optional $asString parameter from MessageInterface::getHeader(). Just cast the header to a string. -* Removed the optional $tryChunkedTransfer option from Guzzle\Http\Message\EntityEnclosingRequestInterface -* Removed the $asObjects argument from Guzzle\Http\Message\MessageInterface::getHeaders() -* Removed Guzzle\Parser\ParserRegister::get(). Use getParser() -* Removed Guzzle\Parser\ParserRegister::set(). Use registerParser(). -* All response header helper functions return a string rather than mixing Header objects and strings inconsistently -* Removed cURL blacklist support. This is no longer necessary now that Expect, Accept, etc. are managed by Guzzle - directly via interfaces -* Removed the injecting of a request object onto a response object. The methods to get and set a request still exist - but are a no-op until removed. -* Most classes that used to require a `Guzzle\Service\Command\CommandInterface` typehint now request a - `Guzzle\Service\Command\ArrayCommandInterface`. -* Added `Guzzle\Http\Message\RequestInterface::startResponse()` to the RequestInterface to handle injecting a response - on a request while the request is still being transferred -* The ability to case-insensitively search for header values -* Guzzle\Http\Message\Header::hasExactHeader -* Guzzle\Http\Message\Header::raw. Use getAll() -* Deprecated cache control specific methods on Guzzle\Http\Message\AbstractMessage. Use the CacheControl header object - instead. -* `Guzzle\Service\Command\CommandInterface` now extends from ToArrayInterface and ArrayAccess -* Added the ability to cast Model objects to a string to view debug information. - -## 3.5.0 - 2013-05-13 - -* Bug: Fixed a regression so that request responses are parsed only once per oncomplete event rather than multiple times -* Bug: Better cleanup of one-time events across the board (when an event is meant to fire once, it will now remove - itself from the EventDispatcher) -* Bug: `Guzzle\Log\MessageFormatter` now properly writes "total_time" and "connect_time" values -* Bug: Cloning an EntityEnclosingRequest now clones the EntityBody too -* Bug: Fixed an undefined index error when parsing nested JSON responses with a sentAs parameter that reference a - non-existent key -* Bug: All __call() method arguments are now required (helps with mocking frameworks) -* Deprecating Response::getRequest() and now using a shallow clone of a request object to remove a circular reference - to help with refcount based garbage collection of resources created by sending a request -* Deprecating ZF1 cache and log adapters. These will be removed in the next major version. -* Deprecating `Response::getPreviousResponse()` (method signature still exists, but it's deprecated). Use the - HistoryPlugin for a history. -* Added a `responseBody` alias for the `response_body` location -* Refactored internals to no longer rely on Response::getRequest() -* HistoryPlugin can now be cast to a string -* HistoryPlugin now logs transactions rather than requests and responses to more accurately keep track of the requests - and responses that are sent over the wire -* Added `getEffectiveUrl()` and `getRedirectCount()` to Response objects - -## 3.4.3 - 2013-04-30 - -* Bug fix: Fixing bug introduced in 3.4.2 where redirect responses are duplicated on the final redirected response -* Added a check to re-extract the temp cacert bundle from the phar before sending each request - -## 3.4.2 - 2013-04-29 - -* Bug fix: Stream objects now work correctly with "a" and "a+" modes -* Bug fix: Removing `Transfer-Encoding: chunked` header when a Content-Length is present -* Bug fix: AsyncPlugin no longer forces HEAD requests -* Bug fix: DateTime timezones are now properly handled when using the service description schema formatter -* Bug fix: CachePlugin now properly handles stale-if-error directives when a request to the origin server fails -* Setting a response on a request will write to the custom request body from the response body if one is specified -* LogPlugin now writes to php://output when STDERR is undefined -* Added the ability to set multiple POST files for the same key in a single call -* application/x-www-form-urlencoded POSTs now use the utf-8 charset by default -* Added the ability to queue CurlExceptions to the MockPlugin -* Cleaned up how manual responses are queued on requests (removed "queued_response" and now using request.before_send) -* Configuration loading now allows remote files - -## 3.4.1 - 2013-04-16 - -* Large refactoring to how CurlMulti handles work. There is now a proxy that sits in front of a pool of CurlMulti - handles. This greatly simplifies the implementation, fixes a couple bugs, and provides a small performance boost. -* Exceptions are now properly grouped when sending requests in parallel -* Redirects are now properly aggregated when a multi transaction fails -* Redirects now set the response on the original object even in the event of a failure -* Bug fix: Model names are now properly set even when using $refs -* Added support for PHP 5.5's CurlFile to prevent warnings with the deprecated @ syntax -* Added support for oauth_callback in OAuth signatures -* Added support for oauth_verifier in OAuth signatures -* Added support to attempt to retrieve a command first literally, then ucfirst, the with inflection - -## 3.4.0 - 2013-04-11 - -* Bug fix: URLs are now resolved correctly based on http://tools.ietf.org/html/rfc3986#section-5.2. #289 -* Bug fix: Absolute URLs with a path in a service description will now properly override the base URL. #289 -* Bug fix: Parsing a query string with a single PHP array value will now result in an array. #263 -* Bug fix: Better normalization of the User-Agent header to prevent duplicate headers. #264. -* Bug fix: Added `number` type to service descriptions. -* Bug fix: empty parameters are removed from an OAuth signature -* Bug fix: Revalidating a cache entry prefers the Last-Modified over the Date header -* Bug fix: Fixed "array to string" error when validating a union of types in a service description -* Bug fix: Removed code that attempted to determine the size of a stream when data is written to the stream -* Bug fix: Not including an `oauth_token` if the value is null in the OauthPlugin. -* Bug fix: Now correctly aggregating successful requests and failed requests in CurlMulti when a redirect occurs. -* The new default CURLOPT_TIMEOUT setting has been increased to 150 seconds so that Guzzle works on poor connections. -* Added a feature to EntityEnclosingRequest::setBody() that will automatically set the Content-Type of the request if - the Content-Type can be determined based on the entity body or the path of the request. -* Added the ability to overwrite configuration settings in a client when grabbing a throwaway client from a builder. -* Added support for a PSR-3 LogAdapter. -* Added a `command.after_prepare` event -* Added `oauth_callback` parameter to the OauthPlugin -* Added the ability to create a custom stream class when using a stream factory -* Added a CachingEntityBody decorator -* Added support for `additionalParameters` in service descriptions to define how custom parameters are serialized. -* The bundled SSL certificate is now provided in the phar file and extracted when running Guzzle from a phar. -* You can now send any EntityEnclosingRequest with POST fields or POST files and cURL will handle creating bodies -* POST requests using a custom entity body are now treated exactly like PUT requests but with a custom cURL method. This - means that the redirect behavior of POST requests with custom bodies will not be the same as POST requests that use - POST fields or files (the latter is only used when emulating a form POST in the browser). -* Lots of cleanup to CurlHandle::factory and RequestFactory::createRequest - -## 3.3.1 - 2013-03-10 - -* Added the ability to create PHP streaming responses from HTTP requests -* Bug fix: Running any filters when parsing response headers with service descriptions -* Bug fix: OauthPlugin fixes to allow for multi-dimensional array signing, and sorting parameters before signing -* Bug fix: Removed the adding of default empty arrays and false Booleans to responses in order to be consistent across - response location visitors. -* Bug fix: Removed the possibility of creating configuration files with circular dependencies -* RequestFactory::create() now uses the key of a POST file when setting the POST file name -* Added xmlAllowEmpty to serialize an XML body even if no XML specific parameters are set - -## 3.3.0 - 2013-03-03 - -* A large number of performance optimizations have been made -* Bug fix: Added 'wb' as a valid write mode for streams -* Bug fix: `Guzzle\Http\Message\Response::json()` now allows scalar values to be returned -* Bug fix: Fixed bug in `Guzzle\Http\Message\Response` where wrapping quotes were stripped from `getEtag()` -* BC: Removed `Guzzle\Http\Utils` class -* BC: Setting a service description on a client will no longer modify the client's command factories. -* BC: Emitting IO events from a RequestMediator is now a parameter that must be set in a request's curl options using - the 'emit_io' key. This was previously set under a request's parameters using 'curl.emit_io' -* BC: `Guzzle\Stream\Stream::getWrapper()` and `Guzzle\Stream\Stream::getSteamType()` are no longer converted to - lowercase -* Operation parameter objects are now lazy loaded internally -* Added ErrorResponsePlugin that can throw errors for responses defined in service description operations' errorResponses -* Added support for instantiating responseType=class responseClass classes. Classes must implement - `Guzzle\Service\Command\ResponseClassInterface` -* Added support for additionalProperties for top-level parameters in responseType=model responseClasses. These - additional properties also support locations and can be used to parse JSON responses where the outermost part of the - JSON is an array -* Added support for nested renaming of JSON models (rename sentAs to name) -* CachePlugin - * Added support for stale-if-error so that the CachePlugin can now serve stale content from the cache on error - * Debug headers can now added to cached response in the CachePlugin - -## 3.2.0 - 2013-02-14 - -* CurlMulti is no longer reused globally. A new multi object is created per-client. This helps to isolate clients. -* URLs with no path no longer contain a "/" by default -* Guzzle\Http\QueryString does no longer manages the leading "?". This is now handled in Guzzle\Http\Url. -* BadResponseException no longer includes the full request and response message -* Adding setData() to Guzzle\Service\Description\ServiceDescriptionInterface -* Adding getResponseBody() to Guzzle\Http\Message\RequestInterface -* Various updates to classes to use ServiceDescriptionInterface type hints rather than ServiceDescription -* Header values can now be normalized into distinct values when multiple headers are combined with a comma separated list -* xmlEncoding can now be customized for the XML declaration of a XML service description operation -* Guzzle\Http\QueryString now uses Guzzle\Http\QueryAggregator\QueryAggregatorInterface objects to add custom value - aggregation and no longer uses callbacks -* The URL encoding implementation of Guzzle\Http\QueryString can now be customized -* Bug fix: Filters were not always invoked for array service description parameters -* Bug fix: Redirects now use a target response body rather than a temporary response body -* Bug fix: The default exponential backoff BackoffPlugin was not giving when the request threshold was exceeded -* Bug fix: Guzzle now takes the first found value when grabbing Cache-Control directives - -## 3.1.2 - 2013-01-27 - -* Refactored how operation responses are parsed. Visitors now include a before() method responsible for parsing the - response body. For example, the XmlVisitor now parses the XML response into an array in the before() method. -* Fixed an issue where cURL would not automatically decompress responses when the Accept-Encoding header was sent -* CURLOPT_SSL_VERIFYHOST is never set to 1 because it is deprecated (see 5e0ff2ef20f839e19d1eeb298f90ba3598784444) -* Fixed a bug where redirect responses were not chained correctly using getPreviousResponse() -* Setting default headers on a client after setting the user-agent will not erase the user-agent setting - -## 3.1.1 - 2013-01-20 - -* Adding wildcard support to Guzzle\Common\Collection::getPath() -* Adding alias support to ServiceBuilder configs -* Adding Guzzle\Service\Resource\CompositeResourceIteratorFactory and cleaning up factory interface - -## 3.1.0 - 2013-01-12 - -* BC: CurlException now extends from RequestException rather than BadResponseException -* BC: Renamed Guzzle\Plugin\Cache\CanCacheStrategyInterface::canCache() to canCacheRequest() and added CanCacheResponse() -* Added getData to ServiceDescriptionInterface -* Added context array to RequestInterface::setState() -* Bug: Removing hard dependency on the BackoffPlugin from Guzzle\Http -* Bug: Adding required content-type when JSON request visitor adds JSON to a command -* Bug: Fixing the serialization of a service description with custom data -* Made it easier to deal with exceptions thrown when transferring commands or requests in parallel by providing - an array of successful and failed responses -* Moved getPath from Guzzle\Service\Resource\Model to Guzzle\Common\Collection -* Added Guzzle\Http\IoEmittingEntityBody -* Moved command filtration from validators to location visitors -* Added `extends` attributes to service description parameters -* Added getModels to ServiceDescriptionInterface - -## 3.0.7 - 2012-12-19 - -* Fixing phar detection when forcing a cacert to system if null or true -* Allowing filename to be passed to `Guzzle\Http\Message\Request::setResponseBody()` -* Cleaning up `Guzzle\Common\Collection::inject` method -* Adding a response_body location to service descriptions - -## 3.0.6 - 2012-12-09 - -* CurlMulti performance improvements -* Adding setErrorResponses() to Operation -* composer.json tweaks - -## 3.0.5 - 2012-11-18 - -* Bug: Fixing an infinite recursion bug caused from revalidating with the CachePlugin -* Bug: Response body can now be a string containing "0" -* Bug: Using Guzzle inside of a phar uses system by default but now allows for a custom cacert -* Bug: QueryString::fromString now properly parses query string parameters that contain equal signs -* Added support for XML attributes in service description responses -* DefaultRequestSerializer now supports array URI parameter values for URI template expansion -* Added better mimetype guessing to requests and post files - -## 3.0.4 - 2012-11-11 - -* Bug: Fixed a bug when adding multiple cookies to a request to use the correct glue value -* Bug: Cookies can now be added that have a name, domain, or value set to "0" -* Bug: Using the system cacert bundle when using the Phar -* Added json and xml methods to Response to make it easier to parse JSON and XML response data into data structures -* Enhanced cookie jar de-duplication -* Added the ability to enable strict cookie jars that throw exceptions when invalid cookies are added -* Added setStream to StreamInterface to actually make it possible to implement custom rewind behavior for entity bodies -* Added the ability to create any sort of hash for a stream rather than just an MD5 hash - -## 3.0.3 - 2012-11-04 - -* Implementing redirects in PHP rather than cURL -* Added PECL URI template extension and using as default parser if available -* Bug: Fixed Content-Length parsing of Response factory -* Adding rewind() method to entity bodies and streams. Allows for custom rewinding of non-repeatable streams. -* Adding ToArrayInterface throughout library -* Fixing OauthPlugin to create unique nonce values per request - -## 3.0.2 - 2012-10-25 - -* Magic methods are enabled by default on clients -* Magic methods return the result of a command -* Service clients no longer require a base_url option in the factory -* Bug: Fixed an issue with URI templates where null template variables were being expanded - -## 3.0.1 - 2012-10-22 - -* Models can now be used like regular collection objects by calling filter, map, etc. -* Models no longer require a Parameter structure or initial data in the constructor -* Added a custom AppendIterator to get around a PHP bug with the `\AppendIterator` - -## 3.0.0 - 2012-10-15 - -* Rewrote service description format to be based on Swagger - * Now based on JSON schema - * Added nested input structures and nested response models - * Support for JSON and XML input and output models - * Renamed `commands` to `operations` - * Removed dot class notation - * Removed custom types -* Broke the project into smaller top-level namespaces to be more component friendly -* Removed support for XML configs and descriptions. Use arrays or JSON files. -* Removed the Validation component and Inspector -* Moved all cookie code to Guzzle\Plugin\Cookie -* Magic methods on a Guzzle\Service\Client now return the command un-executed. -* Calling getResult() or getResponse() on a command will lazily execute the command if needed. -* Now shipping with cURL's CA certs and using it by default -* Added previousResponse() method to response objects -* No longer sending Accept and Accept-Encoding headers on every request -* Only sending an Expect header by default when a payload is greater than 1MB -* Added/moved client options: - * curl.blacklist to curl.option.blacklist - * Added ssl.certificate_authority -* Added a Guzzle\Iterator component -* Moved plugins from Guzzle\Http\Plugin to Guzzle\Plugin -* Added a more robust backoff retry strategy (replaced the ExponentialBackoffPlugin) -* Added a more robust caching plugin -* Added setBody to response objects -* Updating LogPlugin to use a more flexible MessageFormatter -* Added a completely revamped build process -* Cleaning up Collection class and removing default values from the get method -* Fixed ZF2 cache adapters - -## 2.8.8 - 2012-10-15 - -* Bug: Fixed a cookie issue that caused dot prefixed domains to not match where popular browsers did - -## 2.8.7 - 2012-09-30 - -* Bug: Fixed config file aliases for JSON includes -* Bug: Fixed cookie bug on a request object by using CookieParser to parse cookies on requests -* Bug: Removing the path to a file when sending a Content-Disposition header on a POST upload -* Bug: Hardening request and response parsing to account for missing parts -* Bug: Fixed PEAR packaging -* Bug: Fixed Request::getInfo -* Bug: Fixed cases where CURLM_CALL_MULTI_PERFORM return codes were causing curl transactions to fail -* Adding the ability for the namespace Iterator factory to look in multiple directories -* Added more getters/setters/removers from service descriptions -* Added the ability to remove POST fields from OAuth signatures -* OAuth plugin now supports 2-legged OAuth - -## 2.8.6 - 2012-09-05 - -* Added the ability to modify and build service descriptions -* Added the use of visitors to apply parameters to locations in service descriptions using the dynamic command -* Added a `json` parameter location -* Now allowing dot notation for classes in the CacheAdapterFactory -* Using the union of two arrays rather than an array_merge when extending service builder services and service params -* Ensuring that a service is a string before doing strpos() checks on it when substituting services for references - in service builder config files. -* Services defined in two different config files that include one another will by default replace the previously - defined service, but you can now create services that extend themselves and merge their settings over the previous -* The JsonLoader now supports aliasing filenames with different filenames. This allows you to alias something like - '_default' with a default JSON configuration file. - -## 2.8.5 - 2012-08-29 - -* Bug: Suppressed empty arrays from URI templates -* Bug: Added the missing $options argument from ServiceDescription::factory to enable caching -* Added support for HTTP responses that do not contain a reason phrase in the start-line -* AbstractCommand commands are now invokable -* Added a way to get the data used when signing an Oauth request before a request is sent - -## 2.8.4 - 2012-08-15 - -* Bug: Custom delay time calculations are no longer ignored in the ExponentialBackoffPlugin -* Added the ability to transfer entity bodies as a string rather than streamed. This gets around curl error 65. Set `body_as_string` in a request's curl options to enable. -* Added a StreamInterface, EntityBodyInterface, and added ftell() to Guzzle\Common\Stream -* Added an AbstractEntityBodyDecorator and a ReadLimitEntityBody decorator to transfer only a subset of a decorated stream -* Stream and EntityBody objects will now return the file position to the previous position after a read required operation (e.g. getContentMd5()) -* Added additional response status codes -* Removed SSL information from the default User-Agent header -* DELETE requests can now send an entity body -* Added an EventDispatcher to the ExponentialBackoffPlugin and added an ExponentialBackoffLogger to log backoff retries -* Added the ability of the MockPlugin to consume mocked request bodies -* LogPlugin now exposes request and response objects in the extras array - -## 2.8.3 - 2012-07-30 - -* Bug: Fixed a case where empty POST requests were sent as GET requests -* Bug: Fixed a bug in ExponentialBackoffPlugin that caused fatal errors when retrying an EntityEnclosingRequest that does not have a body -* Bug: Setting the response body of a request to null after completing a request, not when setting the state of a request to new -* Added multiple inheritance to service description commands -* Added an ApiCommandInterface and added `getParamNames()` and `hasParam()` -* Removed the default 2mb size cutoff from the Md5ValidatorPlugin so that it now defaults to validating everything -* Changed CurlMulti::perform to pass a smaller timeout to CurlMulti::executeHandles - -## 2.8.2 - 2012-07-24 - -* Bug: Query string values set to 0 are no longer dropped from the query string -* Bug: A Collection object is no longer created each time a call is made to `Guzzle\Service\Command\AbstractCommand::getRequestHeaders()` -* Bug: `+` is now treated as an encoded space when parsing query strings -* QueryString and Collection performance improvements -* Allowing dot notation for class paths in filters attribute of a service descriptions - -## 2.8.1 - 2012-07-16 - -* Loosening Event Dispatcher dependency -* POST redirects can now be customized using CURLOPT_POSTREDIR - -## 2.8.0 - 2012-07-15 - -* BC: Guzzle\Http\Query - * Query strings with empty variables will always show an equal sign unless the variable is set to QueryString::BLANK (e.g. ?acl= vs ?acl) - * Changed isEncodingValues() and isEncodingFields() to isUrlEncoding() - * Changed setEncodeValues(bool) and setEncodeFields(bool) to useUrlEncoding(bool) - * Changed the aggregation functions of QueryString to be static methods - * Can now use fromString() with querystrings that have a leading ? -* cURL configuration values can be specified in service descriptions using `curl.` prefixed parameters -* Content-Length is set to 0 before emitting the request.before_send event when sending an empty request body -* Cookies are no longer URL decoded by default -* Bug: URI template variables set to null are no longer expanded - -## 2.7.2 - 2012-07-02 - -* BC: Moving things to get ready for subtree splits. Moving Inflection into Common. Moving Guzzle\Http\Parser to Guzzle\Parser. -* BC: Removing Guzzle\Common\Batch\Batch::count() and replacing it with isEmpty() -* CachePlugin now allows for a custom request parameter function to check if a request can be cached -* Bug fix: CachePlugin now only caches GET and HEAD requests by default -* Bug fix: Using header glue when transferring headers over the wire -* Allowing deeply nested arrays for composite variables in URI templates -* Batch divisors can now return iterators or arrays - -## 2.7.1 - 2012-06-26 - -* Minor patch to update version number in UA string -* Updating build process - -## 2.7.0 - 2012-06-25 - -* BC: Inflection classes moved to Guzzle\Inflection. No longer static methods. Can now inject custom inflectors into classes. -* BC: Removed magic setX methods from commands -* BC: Magic methods mapped to service description commands are now inflected in the command factory rather than the client __call() method -* Verbose cURL options are no longer enabled by default. Set curl.debug to true on a client to enable. -* Bug: Now allowing colons in a response start-line (e.g. HTTP/1.1 503 Service Unavailable: Back-end server is at capacity) -* Guzzle\Service\Resource\ResourceIteratorApplyBatched now internally uses the Guzzle\Common\Batch namespace -* Added Guzzle\Service\Plugin namespace and a PluginCollectionPlugin -* Added the ability to set POST fields and files in a service description -* Guzzle\Http\EntityBody::factory() now accepts objects with a __toString() method -* Adding a command.before_prepare event to clients -* Added BatchClosureTransfer and BatchClosureDivisor -* BatchTransferException now includes references to the batch divisor and transfer strategies -* Fixed some tests so that they pass more reliably -* Added Guzzle\Common\Log\ArrayLogAdapter - -## 2.6.6 - 2012-06-10 - -* BC: Removing Guzzle\Http\Plugin\BatchQueuePlugin -* BC: Removing Guzzle\Service\Command\CommandSet -* Adding generic batching system (replaces the batch queue plugin and command set) -* Updating ZF cache and log adapters and now using ZF's composer repository -* Bug: Setting the name of each ApiParam when creating through an ApiCommand -* Adding result_type, result_doc, deprecated, and doc_url to service descriptions -* Bug: Changed the default cookie header casing back to 'Cookie' - -## 2.6.5 - 2012-06-03 - -* BC: Renaming Guzzle\Http\Message\RequestInterface::getResourceUri() to getResource() -* BC: Removing unused AUTH_BASIC and AUTH_DIGEST constants from -* BC: Guzzle\Http\Cookie is now used to manage Set-Cookie data, not Cookie data -* BC: Renaming methods in the CookieJarInterface -* Moving almost all cookie logic out of the CookiePlugin and into the Cookie or CookieJar implementations -* Making the default glue for HTTP headers ';' instead of ',' -* Adding a removeValue to Guzzle\Http\Message\Header -* Adding getCookies() to request interface. -* Making it easier to add event subscribers to HasDispatcherInterface classes. Can now directly call addSubscriber() - -## 2.6.4 - 2012-05-30 - -* BC: Cleaning up how POST files are stored in EntityEnclosingRequest objects. Adding PostFile class. -* BC: Moving ApiCommand specific functionality from the Inspector and on to the ApiCommand -* Bug: Fixing magic method command calls on clients -* Bug: Email constraint only validates strings -* Bug: Aggregate POST fields when POST files are present in curl handle -* Bug: Fixing default User-Agent header -* Bug: Only appending or prepending parameters in commands if they are specified -* Bug: Not requiring response reason phrases or status codes to match a predefined list of codes -* Allowing the use of dot notation for class namespaces when using instance_of constraint -* Added any_match validation constraint -* Added an AsyncPlugin -* Passing request object to the calculateWait method of the ExponentialBackoffPlugin -* Allowing the result of a command object to be changed -* Parsing location and type sub values when instantiating a service description rather than over and over at runtime - -## 2.6.3 - 2012-05-23 - -* [BC] Guzzle\Common\FromConfigInterface no longer requires any config options. -* [BC] Refactoring how POST files are stored on an EntityEnclosingRequest. They are now separate from POST fields. -* You can now use an array of data when creating PUT request bodies in the request factory. -* Removing the requirement that HTTPS requests needed a Cache-Control: public directive to be cacheable. -* [Http] Adding support for Content-Type in multipart POST uploads per upload -* [Http] Added support for uploading multiple files using the same name (foo[0], foo[1]) -* Adding more POST data operations for easier manipulation of POST data. -* You can now set empty POST fields. -* The body of a request is only shown on EntityEnclosingRequest objects that do not use POST files. -* Split the Guzzle\Service\Inspector::validateConfig method into two methods. One to initialize when a command is created, and one to validate. -* CS updates - -## 2.6.2 - 2012-05-19 - -* [Http] Better handling of nested scope requests in CurlMulti. Requests are now always prepares in the send() method rather than the addRequest() method. - -## 2.6.1 - 2012-05-19 - -* [BC] Removing 'path' support in service descriptions. Use 'uri'. -* [BC] Guzzle\Service\Inspector::parseDocBlock is now protected. Adding getApiParamsForClass() with cache. -* [BC] Removing Guzzle\Common\NullObject. Use https://github.com/mtdowling/NullObject if you need it. -* [BC] Removing Guzzle\Common\XmlElement. -* All commands, both dynamic and concrete, have ApiCommand objects. -* Adding a fix for CurlMulti so that if all of the connections encounter some sort of curl error, then the loop exits. -* Adding checks to EntityEnclosingRequest so that empty POST files and fields are ignored. -* Making the method signature of Guzzle\Service\Builder\ServiceBuilder::factory more flexible. - -## 2.6.0 - 2012-05-15 - -* [BC] Moving Guzzle\Service\Builder to Guzzle\Service\Builder\ServiceBuilder -* [BC] Executing a Command returns the result of the command rather than the command -* [BC] Moving all HTTP parsing logic to Guzzle\Http\Parsers. Allows for faster C implementations if needed. -* [BC] Changing the Guzzle\Http\Message\Response::setProtocol() method to accept a protocol and version in separate args. -* [BC] Moving ResourceIterator* to Guzzle\Service\Resource -* [BC] Completely refactored ResourceIterators to iterate over a cloned command object -* [BC] Moved Guzzle\Http\UriTemplate to Guzzle\Http\Parser\UriTemplate\UriTemplate -* [BC] Guzzle\Guzzle is now deprecated -* Moving Guzzle\Common\Guzzle::inject to Guzzle\Common\Collection::inject -* Adding Guzzle\Version class to give version information about Guzzle -* Adding Guzzle\Http\Utils class to provide getDefaultUserAgent() and getHttpDate() -* Adding Guzzle\Curl\CurlVersion to manage caching curl_version() data -* ServiceDescription and ServiceBuilder are now cacheable using similar configs -* Changing the format of XML and JSON service builder configs. Backwards compatible. -* Cleaned up Cookie parsing -* Trimming the default Guzzle User-Agent header -* Adding a setOnComplete() method to Commands that is called when a command completes -* Keeping track of requests that were mocked in the MockPlugin -* Fixed a caching bug in the CacheAdapterFactory -* Inspector objects can be injected into a Command object -* Refactoring a lot of code and tests to be case insensitive when dealing with headers -* Adding Guzzle\Http\Message\HeaderComparison for easy comparison of HTTP headers using a DSL -* Adding the ability to set global option overrides to service builder configs -* Adding the ability to include other service builder config files from within XML and JSON files -* Moving the parseQuery method out of Url and on to QueryString::fromString() as a static factory method. - -## 2.5.0 - 2012-05-08 - -* Major performance improvements -* [BC] Simplifying Guzzle\Common\Collection. Please check to see if you are using features that are now deprecated. -* [BC] Using a custom validation system that allows a flyweight implementation for much faster validation. No longer using Symfony2 Validation component. -* [BC] No longer supporting "{{ }}" for injecting into command or UriTemplates. Use "{}" -* Added the ability to passed parameters to all requests created by a client -* Added callback functionality to the ExponentialBackoffPlugin -* Using microtime in ExponentialBackoffPlugin to allow more granular backoff strategies. -* Rewinding request stream bodies when retrying requests -* Exception is thrown when JSON response body cannot be decoded -* Added configurable magic method calls to clients and commands. This is off by default. -* Fixed a defect that added a hash to every parsed URL part -* Fixed duplicate none generation for OauthPlugin. -* Emitting an event each time a client is generated by a ServiceBuilder -* Using an ApiParams object instead of a Collection for parameters of an ApiCommand -* cache.* request parameters should be renamed to params.cache.* -* Added the ability to set arbitrary curl options on requests (disable_wire, progress, etc.). See CurlHandle. -* Added the ability to disable type validation of service descriptions -* ServiceDescriptions and ServiceBuilders are now Serializable diff --git a/vendor/guzzlehttp/guzzle/LICENSE b/vendor/guzzlehttp/guzzle/LICENSE deleted file mode 100755 index 50a177b0320c3f1f201fe6c57d4ecc0971017037..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2011-2018 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/guzzlehttp/guzzle/README.md b/vendor/guzzlehttp/guzzle/README.md deleted file mode 100755 index bcd18b8e718bcfb922288cf6350eced1dbae966d..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/README.md +++ /dev/null @@ -1,91 +0,0 @@ -Guzzle, PHP HTTP client -======================= - -[](https://github.com/guzzle/guzzle/releases) -[](https://travis-ci.org/guzzle/guzzle) -[](https://packagist.org/packages/guzzlehttp/guzzle) - -Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and -trivial to integrate with web services. - -- Simple interface for building query strings, POST requests, streaming large - uploads, streaming large downloads, using HTTP cookies, uploading JSON data, - etc... -- Can send both synchronous and asynchronous requests using the same interface. -- Uses PSR-7 interfaces for requests, responses, and streams. This allows you - to utilize other PSR-7 compatible libraries with Guzzle. -- Abstracts away the underlying HTTP transport, allowing you to write - environment and transport agnostic code; i.e., no hard dependency on cURL, - PHP streams, sockets, or non-blocking event loops. -- Middleware system allows you to augment and compose client behavior. - -```php -$client = new \GuzzleHttp\Client(); -$res = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle'); -echo $res->getStatusCode(); -// 200 -echo $res->getHeaderLine('content-type'); -// 'application/json; charset=utf8' -echo $res->getBody(); -// '{"id": 1420053, "name": "guzzle", ...}' - -// Send an asynchronous request. -$request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org'); -$promise = $client->sendAsync($request)->then(function ($response) { - echo 'I completed! ' . $response->getBody(); -}); -$promise->wait(); -``` - -## Help and docs - -- [Documentation](http://guzzlephp.org/) -- [Stack Overflow](http://stackoverflow.com/questions/tagged/guzzle) -- [Gitter](https://gitter.im/guzzle/guzzle) - - -## Installing Guzzle - -The recommended way to install Guzzle is through -[Composer](http://getcomposer.org). - -```bash -# Install Composer -curl -sS https://getcomposer.org/installer | php -``` - -Next, run the Composer command to install the latest stable version of Guzzle: - -```bash -php composer.phar require guzzlehttp/guzzle -``` - -After installing, you need to require Composer's autoloader: - -```php -require 'vendor/autoload.php'; -``` - -You can then later update Guzzle using composer: - - ```bash -composer.phar update - ``` - - -## Version Guidance - -| Version | Status | Packagist | Namespace | Repo | Docs | PSR-7 | PHP Version | -|---------|------------|---------------------|--------------|---------------------|---------------------|-------|-------------| -| 3.x | EOL | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | >= 5.3.3 | -| 4.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v4][guzzle-4-repo] | N/A | No | >= 5.4 | -| 5.x | Maintained | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >= 5.4 | -| 6.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >= 5.5 | - -[guzzle-3-repo]: https://github.com/guzzle/guzzle3 -[guzzle-4-repo]: https://github.com/guzzle/guzzle/tree/4.x -[guzzle-5-repo]: https://github.com/guzzle/guzzle/tree/5.3 -[guzzle-6-repo]: https://github.com/guzzle/guzzle -[guzzle-3-docs]: http://guzzle3.readthedocs.org/en/latest/ -[guzzle-5-docs]: http://guzzle.readthedocs.org/en/5.3/ -[guzzle-6-docs]: http://guzzle.readthedocs.org/en/latest/ diff --git a/vendor/guzzlehttp/guzzle/UPGRADING.md b/vendor/guzzlehttp/guzzle/UPGRADING.md deleted file mode 100755 index 91d1dcc99317e1dd713f18638cf97d2921d31f6a..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/UPGRADING.md +++ /dev/null @@ -1,1203 +0,0 @@ -Guzzle Upgrade Guide -==================== - -5.0 to 6.0 ----------- - -Guzzle now uses [PSR-7](http://www.php-fig.org/psr/psr-7/) for HTTP messages. -Due to the fact that these messages are immutable, this prompted a refactoring -of Guzzle to use a middleware based system rather than an event system. Any -HTTP message interaction (e.g., `GuzzleHttp\Message\Request`) need to be -updated to work with the new immutable PSR-7 request and response objects. Any -event listeners or subscribers need to be updated to become middleware -functions that wrap handlers (or are injected into a -`GuzzleHttp\HandlerStack`). - -- Removed `GuzzleHttp\BatchResults` -- Removed `GuzzleHttp\Collection` -- Removed `GuzzleHttp\HasDataTrait` -- Removed `GuzzleHttp\ToArrayInterface` -- The `guzzlehttp/streams` dependency has been removed. Stream functionality - is now present in the `GuzzleHttp\Psr7` namespace provided by the - `guzzlehttp/psr7` package. -- Guzzle no longer uses ReactPHP promises and now uses the - `guzzlehttp/promises` library. We use a custom promise library for three - significant reasons: - 1. React promises (at the time of writing this) are recursive. Promise - chaining and promise resolution will eventually blow the stack. Guzzle - promises are not recursive as they use a sort of trampolining technique. - Note: there has been movement in the React project to modify promises to - no longer utilize recursion. - 2. Guzzle needs to have the ability to synchronously block on a promise to - wait for a result. Guzzle promises allows this functionality (and does - not require the use of recursion). - 3. Because we need to be able to wait on a result, doing so using React - promises requires wrapping react promises with RingPHP futures. This - overhead is no longer needed, reducing stack sizes, reducing complexity, - and improving performance. -- `GuzzleHttp\Mimetypes` has been moved to a function in - `GuzzleHttp\Psr7\mimetype_from_extension` and - `GuzzleHttp\Psr7\mimetype_from_filename`. -- `GuzzleHttp\Query` and `GuzzleHttp\QueryParser` have been removed. Query - strings must now be passed into request objects as strings, or provided to - the `query` request option when creating requests with clients. The `query` - option uses PHP's `http_build_query` to convert an array to a string. If you - need a different serialization technique, you will need to pass the query - string in as a string. There are a couple helper functions that will make - working with query strings easier: `GuzzleHttp\Psr7\parse_query` and - `GuzzleHttp\Psr7\build_query`. -- Guzzle no longer has a dependency on RingPHP. Due to the use of a middleware - system based on PSR-7, using RingPHP and it's middleware system as well adds - more complexity than the benefits it provides. All HTTP handlers that were - present in RingPHP have been modified to work directly with PSR-7 messages - and placed in the `GuzzleHttp\Handler` namespace. This significantly reduces - complexity in Guzzle, removes a dependency, and improves performance. RingPHP - will be maintained for Guzzle 5 support, but will no longer be a part of - Guzzle 6. -- As Guzzle now uses a middleware based systems the event system and RingPHP - integration has been removed. Note: while the event system has been removed, - it is possible to add your own type of event system that is powered by the - middleware system. - - Removed the `Event` namespace. - - Removed the `Subscriber` namespace. - - Removed `Transaction` class - - Removed `RequestFsm` - - Removed `RingBridge` - - `GuzzleHttp\Subscriber\Cookie` is now provided by - `GuzzleHttp\Middleware::cookies` - - `GuzzleHttp\Subscriber\HttpError` is now provided by - `GuzzleHttp\Middleware::httpError` - - `GuzzleHttp\Subscriber\History` is now provided by - `GuzzleHttp\Middleware::history` - - `GuzzleHttp\Subscriber\Mock` is now provided by - `GuzzleHttp\Handler\MockHandler` - - `GuzzleHttp\Subscriber\Prepare` is now provided by - `GuzzleHttp\PrepareBodyMiddleware` - - `GuzzleHttp\Subscriber\Redirect` is now provided by - `GuzzleHttp\RedirectMiddleware` -- Guzzle now uses `Psr\Http\Message\UriInterface` (implements in - `GuzzleHttp\Psr7\Uri`) for URI support. `GuzzleHttp\Url` is now gone. -- Static functions in `GuzzleHttp\Utils` have been moved to namespaced - functions under the `GuzzleHttp` namespace. This requires either a Composer - based autoloader or you to include functions.php. -- `GuzzleHttp\ClientInterface::getDefaultOption` has been renamed to - `GuzzleHttp\ClientInterface::getConfig`. -- `GuzzleHttp\ClientInterface::setDefaultOption` has been removed. -- The `json` and `xml` methods of response objects has been removed. With the - migration to strictly adhering to PSR-7 as the interface for Guzzle messages, - adding methods to message interfaces would actually require Guzzle messages - to extend from PSR-7 messages rather then work with them directly. - -## Migrating to middleware - -The change to PSR-7 unfortunately required significant refactoring to Guzzle -due to the fact that PSR-7 messages are immutable. Guzzle 5 relied on an event -system from plugins. The event system relied on mutability of HTTP messages and -side effects in order to work. With immutable messages, you have to change your -workflow to become more about either returning a value (e.g., functional -middlewares) or setting a value on an object. Guzzle v6 has chosen the -functional middleware approach. - -Instead of using the event system to listen for things like the `before` event, -you now create a stack based middleware function that intercepts a request on -the way in and the promise of the response on the way out. This is a much -simpler and more predictable approach than the event system and works nicely -with PSR-7 middleware. Due to the use of promises, the middleware system is -also asynchronous. - -v5: - -```php -use GuzzleHttp\Event\BeforeEvent; -$client = new GuzzleHttp\Client(); -// Get the emitter and listen to the before event. -$client->getEmitter()->on('before', function (BeforeEvent $e) { - // Guzzle v5 events relied on mutation - $e->getRequest()->setHeader('X-Foo', 'Bar'); -}); -``` - -v6: - -In v6, you can modify the request before it is sent using the `mapRequest` -middleware. The idiomatic way in v6 to modify the request/response lifecycle is -to setup a handler middleware stack up front and inject the handler into a -client. - -```php -use GuzzleHttp\Middleware; -// Create a handler stack that has all of the default middlewares attached -$handler = GuzzleHttp\HandlerStack::create(); -// Push the handler onto the handler stack -$handler->push(Middleware::mapRequest(function (RequestInterface $request) { - // Notice that we have to return a request object - return $request->withHeader('X-Foo', 'Bar'); -})); -// Inject the handler into the client -$client = new GuzzleHttp\Client(['handler' => $handler]); -``` - -## POST Requests - -This version added the [`form_params`](http://guzzle.readthedocs.org/en/latest/request-options.html#form_params) -and `multipart` request options. `form_params` is an associative array of -strings or array of strings and is used to serialize an -`application/x-www-form-urlencoded` POST request. The -[`multipart`](http://guzzle.readthedocs.org/en/latest/request-options.html#multipart) -option is now used to send a multipart/form-data POST request. - -`GuzzleHttp\Post\PostFile` has been removed. Use the `multipart` option to add -POST files to a multipart/form-data request. - -The `body` option no longer accepts an array to send POST requests. Please use -`multipart` or `form_params` instead. - -The `base_url` option has been renamed to `base_uri`. - -4.x to 5.0 ----------- - -## Rewritten Adapter Layer - -Guzzle now uses [RingPHP](http://ringphp.readthedocs.org/en/latest) to send -HTTP requests. The `adapter` option in a `GuzzleHttp\Client` constructor -is still supported, but it has now been renamed to `handler`. Instead of -passing a `GuzzleHttp\Adapter\AdapterInterface`, you must now pass a PHP -`callable` that follows the RingPHP specification. - -## Removed Fluent Interfaces - -[Fluent interfaces were removed](http://ocramius.github.io/blog/fluent-interfaces-are-evil) -from the following classes: - -- `GuzzleHttp\Collection` -- `GuzzleHttp\Url` -- `GuzzleHttp\Query` -- `GuzzleHttp\Post\PostBody` -- `GuzzleHttp\Cookie\SetCookie` - -## Removed functions.php - -Removed "functions.php", so that Guzzle is truly PSR-4 compliant. The following -functions can be used as replacements. - -- `GuzzleHttp\json_decode` -> `GuzzleHttp\Utils::jsonDecode` -- `GuzzleHttp\get_path` -> `GuzzleHttp\Utils::getPath` -- `GuzzleHttp\Utils::setPath` -> `GuzzleHttp\set_path` -- `GuzzleHttp\Pool::batch` -> `GuzzleHttp\batch`. This function is, however, - deprecated in favor of using `GuzzleHttp\Pool::batch()`. - -The "procedural" global client has been removed with no replacement (e.g., -`GuzzleHttp\get()`, `GuzzleHttp\post()`, etc.). Use a `GuzzleHttp\Client` -object as a replacement. - -## `throwImmediately` has been removed - -The concept of "throwImmediately" has been removed from exceptions and error -events. This control mechanism was used to stop a transfer of concurrent -requests from completing. This can now be handled by throwing the exception or -by cancelling a pool of requests or each outstanding future request -individually. - -## headers event has been removed - -Removed the "headers" event. This event was only useful for changing the -body a response once the headers of the response were known. You can implement -a similar behavior in a number of ways. One example might be to use a -FnStream that has access to the transaction being sent. For example, when the -first byte is written, you could check if the response headers match your -expectations, and if so, change the actual stream body that is being -written to. - -## Updates to HTTP Messages - -Removed the `asArray` parameter from -`GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header -value as an array, then use the newly added `getHeaderAsArray()` method of -`MessageInterface`. This change makes the Guzzle interfaces compatible with -the PSR-7 interfaces. - -3.x to 4.0 ----------- - -## Overarching changes: - -- Now requires PHP 5.4 or greater. -- No longer requires cURL to send requests. -- Guzzle no longer wraps every exception it throws. Only exceptions that are - recoverable are now wrapped by Guzzle. -- Various namespaces have been removed or renamed. -- No longer requiring the Symfony EventDispatcher. A custom event dispatcher - based on the Symfony EventDispatcher is - now utilized in `GuzzleHttp\Event\EmitterInterface` (resulting in significant - speed and functionality improvements). - -Changes per Guzzle 3.x namespace are described below. - -## Batch - -The `Guzzle\Batch` namespace has been removed. This is best left to -third-parties to implement on top of Guzzle's core HTTP library. - -## Cache - -The `Guzzle\Cache` namespace has been removed. (Todo: No suitable replacement -has been implemented yet, but hoping to utilize a PSR cache interface). - -## Common - -- Removed all of the wrapped exceptions. It's better to use the standard PHP - library for unrecoverable exceptions. -- `FromConfigInterface` has been removed. -- `Guzzle\Common\Version` has been removed. The VERSION constant can be found - at `GuzzleHttp\ClientInterface::VERSION`. - -### Collection - -- `getAll` has been removed. Use `toArray` to convert a collection to an array. -- `inject` has been removed. -- `keySearch` has been removed. -- `getPath` no longer supports wildcard expressions. Use something better like - JMESPath for this. -- `setPath` now supports appending to an existing array via the `[]` notation. - -### Events - -Guzzle no longer requires Symfony's EventDispatcher component. Guzzle now uses -`GuzzleHttp\Event\Emitter`. - -- `Symfony\Component\EventDispatcher\EventDispatcherInterface` is replaced by - `GuzzleHttp\Event\EmitterInterface`. -- `Symfony\Component\EventDispatcher\EventDispatcher` is replaced by - `GuzzleHttp\Event\Emitter`. -- `Symfony\Component\EventDispatcher\Event` is replaced by - `GuzzleHttp\Event\Event`, and Guzzle now has an EventInterface in - `GuzzleHttp\Event\EventInterface`. -- `AbstractHasDispatcher` has moved to a trait, `HasEmitterTrait`, and - `HasDispatcherInterface` has moved to `HasEmitterInterface`. Retrieving the - event emitter of a request, client, etc. now uses the `getEmitter` method - rather than the `getDispatcher` method. - -#### Emitter - -- Use the `once()` method to add a listener that automatically removes itself - the first time it is invoked. -- Use the `listeners()` method to retrieve a list of event listeners rather than - the `getListeners()` method. -- Use `emit()` instead of `dispatch()` to emit an event from an emitter. -- Use `attach()` instead of `addSubscriber()` and `detach()` instead of - `removeSubscriber()`. - -```php -$mock = new Mock(); -// 3.x -$request->getEventDispatcher()->addSubscriber($mock); -$request->getEventDispatcher()->removeSubscriber($mock); -// 4.x -$request->getEmitter()->attach($mock); -$request->getEmitter()->detach($mock); -``` - -Use the `on()` method to add a listener rather than the `addListener()` method. - -```php -// 3.x -$request->getEventDispatcher()->addListener('foo', function (Event $event) { /* ... */ } ); -// 4.x -$request->getEmitter()->on('foo', function (Event $event, $name) { /* ... */ } ); -``` - -## Http - -### General changes - -- The cacert.pem certificate has been moved to `src/cacert.pem`. -- Added the concept of adapters that are used to transfer requests over the - wire. -- Simplified the event system. -- Sending requests in parallel is still possible, but batching is no longer a - concept of the HTTP layer. Instead, you must use the `complete` and `error` - events to asynchronously manage parallel request transfers. -- `Guzzle\Http\Url` has moved to `GuzzleHttp\Url`. -- `Guzzle\Http\QueryString` has moved to `GuzzleHttp\Query`. -- QueryAggregators have been rewritten so that they are simply callable - functions. -- `GuzzleHttp\StaticClient` has been removed. Use the functions provided in - `functions.php` for an easy to use static client instance. -- Exceptions in `GuzzleHttp\Exception` have been updated to all extend from - `GuzzleHttp\Exception\TransferException`. - -### Client - -Calling methods like `get()`, `post()`, `head()`, etc. no longer create and -return a request, but rather creates a request, sends the request, and returns -the response. - -```php -// 3.0 -$request = $client->get('/'); -$response = $request->send(); - -// 4.0 -$response = $client->get('/'); - -// or, to mirror the previous behavior -$request = $client->createRequest('GET', '/'); -$response = $client->send($request); -``` - -`GuzzleHttp\ClientInterface` has changed. - -- The `send` method no longer accepts more than one request. Use `sendAll` to - send multiple requests in parallel. -- `setUserAgent()` has been removed. Use a default request option instead. You - could, for example, do something like: - `$client->setConfig('defaults/headers/User-Agent', 'Foo/Bar ' . $client::getDefaultUserAgent())`. -- `setSslVerification()` has been removed. Use default request options instead, - like `$client->setConfig('defaults/verify', true)`. - -`GuzzleHttp\Client` has changed. - -- The constructor now accepts only an associative array. You can include a - `base_url` string or array to use a URI template as the base URL of a client. - You can also specify a `defaults` key that is an associative array of default - request options. You can pass an `adapter` to use a custom adapter, - `batch_adapter` to use a custom adapter for sending requests in parallel, or - a `message_factory` to change the factory used to create HTTP requests and - responses. -- The client no longer emits a `client.create_request` event. -- Creating requests with a client no longer automatically utilize a URI - template. You must pass an array into a creational method (e.g., - `createRequest`, `get`, `put`, etc.) in order to expand a URI template. - -### Messages - -Messages no longer have references to their counterparts (i.e., a request no -longer has a reference to it's response, and a response no loger has a -reference to its request). This association is now managed through a -`GuzzleHttp\Adapter\TransactionInterface` object. You can get references to -these transaction objects using request events that are emitted over the -lifecycle of a request. - -#### Requests with a body - -- `GuzzleHttp\Message\EntityEnclosingRequest` and - `GuzzleHttp\Message\EntityEnclosingRequestInterface` have been removed. The - separation between requests that contain a body and requests that do not - contain a body has been removed, and now `GuzzleHttp\Message\RequestInterface` - handles both use cases. -- Any method that previously accepts a `GuzzleHttp\Response` object now accept a - `GuzzleHttp\Message\ResponseInterface`. -- `GuzzleHttp\Message\RequestFactoryInterface` has been renamed to - `GuzzleHttp\Message\MessageFactoryInterface`. This interface is used to create - both requests and responses and is implemented in - `GuzzleHttp\Message\MessageFactory`. -- POST field and file methods have been removed from the request object. You - must now use the methods made available to `GuzzleHttp\Post\PostBodyInterface` - to control the format of a POST body. Requests that are created using a - standard `GuzzleHttp\Message\MessageFactoryInterface` will automatically use - a `GuzzleHttp\Post\PostBody` body if the body was passed as an array or if - the method is POST and no body is provided. - -```php -$request = $client->createRequest('POST', '/'); -$request->getBody()->setField('foo', 'bar'); -$request->getBody()->addFile(new PostFile('file_key', fopen('/path/to/content', 'r'))); -``` - -#### Headers - -- `GuzzleHttp\Message\Header` has been removed. Header values are now simply - represented by an array of values or as a string. Header values are returned - as a string by default when retrieving a header value from a message. You can - pass an optional argument of `true` to retrieve a header value as an array - of strings instead of a single concatenated string. -- `GuzzleHttp\PostFile` and `GuzzleHttp\PostFileInterface` have been moved to - `GuzzleHttp\Post`. This interface has been simplified and now allows the - addition of arbitrary headers. -- Custom headers like `GuzzleHttp\Message\Header\Link` have been removed. Most - of the custom headers are now handled separately in specific - subscribers/plugins, and `GuzzleHttp\Message\HeaderValues::parseParams()` has - been updated to properly handle headers that contain parameters (like the - `Link` header). - -#### Responses - -- `GuzzleHttp\Message\Response::getInfo()` and - `GuzzleHttp\Message\Response::setInfo()` have been removed. Use the event - system to retrieve this type of information. -- `GuzzleHttp\Message\Response::getRawHeaders()` has been removed. -- `GuzzleHttp\Message\Response::getMessage()` has been removed. -- `GuzzleHttp\Message\Response::calculateAge()` and other cache specific - methods have moved to the CacheSubscriber. -- Header specific helper functions like `getContentMd5()` have been removed. - Just use `getHeader('Content-MD5')` instead. -- `GuzzleHttp\Message\Response::setRequest()` and - `GuzzleHttp\Message\Response::getRequest()` have been removed. Use the event - system to work with request and response objects as a transaction. -- `GuzzleHttp\Message\Response::getRedirectCount()` has been removed. Use the - Redirect subscriber instead. -- `GuzzleHttp\Message\Response::isSuccessful()` and other related methods have - been removed. Use `getStatusCode()` instead. - -#### Streaming responses - -Streaming requests can now be created by a client directly, returning a -`GuzzleHttp\Message\ResponseInterface` object that contains a body stream -referencing an open PHP HTTP stream. - -```php -// 3.0 -use Guzzle\Stream\PhpStreamRequestFactory; -$request = $client->get('/'); -$factory = new PhpStreamRequestFactory(); -$stream = $factory->fromRequest($request); -$data = $stream->read(1024); - -// 4.0 -$response = $client->get('/', ['stream' => true]); -// Read some data off of the stream in the response body -$data = $response->getBody()->read(1024); -``` - -#### Redirects - -The `configureRedirects()` method has been removed in favor of a -`allow_redirects` request option. - -```php -// Standard redirects with a default of a max of 5 redirects -$request = $client->createRequest('GET', '/', ['allow_redirects' => true]); - -// Strict redirects with a custom number of redirects -$request = $client->createRequest('GET', '/', [ - 'allow_redirects' => ['max' => 5, 'strict' => true] -]); -``` - -#### EntityBody - -EntityBody interfaces and classes have been removed or moved to -`GuzzleHttp\Stream`. All classes and interfaces that once required -`GuzzleHttp\EntityBodyInterface` now require -`GuzzleHttp\Stream\StreamInterface`. Creating a new body for a request no -longer uses `GuzzleHttp\EntityBody::factory` but now uses -`GuzzleHttp\Stream\Stream::factory` or even better: -`GuzzleHttp\Stream\create()`. - -- `Guzzle\Http\EntityBodyInterface` is now `GuzzleHttp\Stream\StreamInterface` -- `Guzzle\Http\EntityBody` is now `GuzzleHttp\Stream\Stream` -- `Guzzle\Http\CachingEntityBody` is now `GuzzleHttp\Stream\CachingStream` -- `Guzzle\Http\ReadLimitEntityBody` is now `GuzzleHttp\Stream\LimitStream` -- `Guzzle\Http\IoEmittyinEntityBody` has been removed. - -#### Request lifecycle events - -Requests previously submitted a large number of requests. The number of events -emitted over the lifecycle of a request has been significantly reduced to make -it easier to understand how to extend the behavior of a request. All events -emitted during the lifecycle of a request now emit a custom -`GuzzleHttp\Event\EventInterface` object that contains context providing -methods and a way in which to modify the transaction at that specific point in -time (e.g., intercept the request and set a response on the transaction). - -- `request.before_send` has been renamed to `before` and now emits a - `GuzzleHttp\Event\BeforeEvent` -- `request.complete` has been renamed to `complete` and now emits a - `GuzzleHttp\Event\CompleteEvent`. -- `request.sent` has been removed. Use `complete`. -- `request.success` has been removed. Use `complete`. -- `error` is now an event that emits a `GuzzleHttp\Event\ErrorEvent`. -- `request.exception` has been removed. Use `error`. -- `request.receive.status_line` has been removed. -- `curl.callback.progress` has been removed. Use a custom `StreamInterface` to - maintain a status update. -- `curl.callback.write` has been removed. Use a custom `StreamInterface` to - intercept writes. -- `curl.callback.read` has been removed. Use a custom `StreamInterface` to - intercept reads. - -`headers` is a new event that is emitted after the response headers of a -request have been received before the body of the response is downloaded. This -event emits a `GuzzleHttp\Event\HeadersEvent`. - -You can intercept a request and inject a response using the `intercept()` event -of a `GuzzleHttp\Event\BeforeEvent`, `GuzzleHttp\Event\CompleteEvent`, and -`GuzzleHttp\Event\ErrorEvent` event. - -See: http://docs.guzzlephp.org/en/latest/events.html - -## Inflection - -The `Guzzle\Inflection` namespace has been removed. This is not a core concern -of Guzzle. - -## Iterator - -The `Guzzle\Iterator` namespace has been removed. - -- `Guzzle\Iterator\AppendIterator`, `Guzzle\Iterator\ChunkedIterator`, and - `Guzzle\Iterator\MethodProxyIterator` are nice, but not a core requirement of - Guzzle itself. -- `Guzzle\Iterator\FilterIterator` is no longer needed because an equivalent - class is shipped with PHP 5.4. -- `Guzzle\Iterator\MapIterator` is not really needed when using PHP 5.5 because - it's easier to just wrap an iterator in a generator that maps values. - -For a replacement of these iterators, see https://github.com/nikic/iter - -## Log - -The LogPlugin has moved to https://github.com/guzzle/log-subscriber. The -`Guzzle\Log` namespace has been removed. Guzzle now relies on -`Psr\Log\LoggerInterface` for all logging. The MessageFormatter class has been -moved to `GuzzleHttp\Subscriber\Log\Formatter`. - -## Parser - -The `Guzzle\Parser` namespace has been removed. This was previously used to -make it possible to plug in custom parsers for cookies, messages, URI -templates, and URLs; however, this level of complexity is not needed in Guzzle -so it has been removed. - -- Cookie: Cookie parsing logic has been moved to - `GuzzleHttp\Cookie\SetCookie::fromString`. -- Message: Message parsing logic for both requests and responses has been moved - to `GuzzleHttp\Message\MessageFactory::fromMessage`. Message parsing is only - used in debugging or deserializing messages, so it doesn't make sense for - Guzzle as a library to add this level of complexity to parsing messages. -- UriTemplate: URI template parsing has been moved to - `GuzzleHttp\UriTemplate`. The Guzzle library will automatically use the PECL - URI template library if it is installed. -- Url: URL parsing is now performed in `GuzzleHttp\Url::fromString` (previously - it was `Guzzle\Http\Url::factory()`). If custom URL parsing is necessary, - then developers are free to subclass `GuzzleHttp\Url`. - -## Plugin - -The `Guzzle\Plugin` namespace has been renamed to `GuzzleHttp\Subscriber`. -Several plugins are shipping with the core Guzzle library under this namespace. - -- `GuzzleHttp\Subscriber\Cookie`: Replaces the old CookiePlugin. Cookie jar - code has moved to `GuzzleHttp\Cookie`. -- `GuzzleHttp\Subscriber\History`: Replaces the old HistoryPlugin. -- `GuzzleHttp\Subscriber\HttpError`: Throws errors when a bad HTTP response is - received. -- `GuzzleHttp\Subscriber\Mock`: Replaces the old MockPlugin. -- `GuzzleHttp\Subscriber\Prepare`: Prepares the body of a request just before - sending. This subscriber is attached to all requests by default. -- `GuzzleHttp\Subscriber\Redirect`: Replaces the RedirectPlugin. - -The following plugins have been removed (third-parties are free to re-implement -these if needed): - -- `GuzzleHttp\Plugin\Async` has been removed. -- `GuzzleHttp\Plugin\CurlAuth` has been removed. -- `GuzzleHttp\Plugin\ErrorResponse\ErrorResponsePlugin` has been removed. This - functionality should instead be implemented with event listeners that occur - after normal response parsing occurs in the guzzle/command package. - -The following plugins are not part of the core Guzzle package, but are provided -in separate repositories: - -- `Guzzle\Http\Plugin\BackoffPlugin` has been rewritten to be much simpler - to build custom retry policies using simple functions rather than various - chained classes. See: https://github.com/guzzle/retry-subscriber -- `Guzzle\Http\Plugin\Cache\CachePlugin` has moved to - https://github.com/guzzle/cache-subscriber -- `Guzzle\Http\Plugin\Log\LogPlugin` has moved to - https://github.com/guzzle/log-subscriber -- `Guzzle\Http\Plugin\Md5\Md5Plugin` has moved to - https://github.com/guzzle/message-integrity-subscriber -- `Guzzle\Http\Plugin\Mock\MockPlugin` has moved to - `GuzzleHttp\Subscriber\MockSubscriber`. -- `Guzzle\Http\Plugin\Oauth\OauthPlugin` has moved to - https://github.com/guzzle/oauth-subscriber - -## Service - -The service description layer of Guzzle has moved into two separate packages: - -- http://github.com/guzzle/command Provides a high level abstraction over web - services by representing web service operations using commands. -- http://github.com/guzzle/guzzle-services Provides an implementation of - guzzle/command that provides request serialization and response parsing using - Guzzle service descriptions. - -## Stream - -Stream have moved to a separate package available at -https://github.com/guzzle/streams. - -`Guzzle\Stream\StreamInterface` has been given a large update to cleanly take -on the responsibilities of `Guzzle\Http\EntityBody` and -`Guzzle\Http\EntityBodyInterface` now that they have been removed. The number -of methods implemented by the `StreamInterface` has been drastically reduced to -allow developers to more easily extend and decorate stream behavior. - -## Removed methods from StreamInterface - -- `getStream` and `setStream` have been removed to better encapsulate streams. -- `getMetadata` and `setMetadata` have been removed in favor of - `GuzzleHttp\Stream\MetadataStreamInterface`. -- `getWrapper`, `getWrapperData`, `getStreamType`, and `getUri` have all been - removed. This data is accessible when - using streams that implement `GuzzleHttp\Stream\MetadataStreamInterface`. -- `rewind` has been removed. Use `seek(0)` for a similar behavior. - -## Renamed methods - -- `detachStream` has been renamed to `detach`. -- `feof` has been renamed to `eof`. -- `ftell` has been renamed to `tell`. -- `readLine` has moved from an instance method to a static class method of - `GuzzleHttp\Stream\Stream`. - -## Metadata streams - -`GuzzleHttp\Stream\MetadataStreamInterface` has been added to denote streams -that contain additional metadata accessible via `getMetadata()`. -`GuzzleHttp\Stream\StreamInterface::getMetadata` and -`GuzzleHttp\Stream\StreamInterface::setMetadata` have been removed. - -## StreamRequestFactory - -The entire concept of the StreamRequestFactory has been removed. The way this -was used in Guzzle 3 broke the actual interface of sending streaming requests -(instead of getting back a Response, you got a StreamInterface). Streaming -PHP requests are now implemented through the `GuzzleHttp\Adapter\StreamAdapter`. - -3.6 to 3.7 ----------- - -### Deprecations - -- You can now enable E_USER_DEPRECATED warnings to see if you are using any deprecated methods.: - -```php -\Guzzle\Common\Version::$emitWarnings = true; -``` - -The following APIs and options have been marked as deprecated: - -- Marked `Guzzle\Http\Message\Request::isResponseBodyRepeatable()` as deprecated. Use `$request->getResponseBody()->isRepeatable()` instead. -- Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead. -- Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead. -- Marked `Guzzle\Http\Message\Request::setIsRedirect()` as deprecated. Use the HistoryPlugin instead. -- Marked `Guzzle\Http\Message\Request::isRedirect()` as deprecated. Use the HistoryPlugin instead. -- Marked `Guzzle\Cache\CacheAdapterFactory::factory()` as deprecated -- Marked `Guzzle\Service\Client::enableMagicMethods()` as deprecated. Magic methods can no longer be disabled on a Guzzle\Service\Client. -- Marked `Guzzle\Parser\Url\UrlParser` as deprecated. Just use PHP's `parse_url()` and percent encode your UTF-8. -- Marked `Guzzle\Common\Collection::inject()` as deprecated. -- Marked `Guzzle\Plugin\CurlAuth\CurlAuthPlugin` as deprecated. Use - `$client->getConfig()->setPath('request.options/auth', array('user', 'pass', 'Basic|Digest|NTLM|Any'));` or - `$client->setDefaultOption('auth', array('user', 'pass', 'Basic|Digest|NTLM|Any'));` - -3.7 introduces `request.options` as a parameter for a client configuration and as an optional argument to all creational -request methods. When paired with a client's configuration settings, these options allow you to specify default settings -for various aspects of a request. Because these options make other previous configuration options redundant, several -configuration options and methods of a client and AbstractCommand have been deprecated. - -- Marked `Guzzle\Service\Client::getDefaultHeaders()` as deprecated. Use `$client->getDefaultOption('headers')`. -- Marked `Guzzle\Service\Client::setDefaultHeaders()` as deprecated. Use `$client->setDefaultOption('headers/{header_name}', 'value')`. -- Marked 'request.params' for `Guzzle\Http\Client` as deprecated. Use `$client->setDefaultOption('params/{param_name}', 'value')` -- Marked 'command.headers', 'command.response_body' and 'command.on_complete' as deprecated for AbstractCommand. These will work through Guzzle 4.0 - - $command = $client->getCommand('foo', array( - 'command.headers' => array('Test' => '123'), - 'command.response_body' => '/path/to/file' - )); - - // Should be changed to: - - $command = $client->getCommand('foo', array( - 'command.request_options' => array( - 'headers' => array('Test' => '123'), - 'save_as' => '/path/to/file' - ) - )); - -### Interface changes - -Additions and changes (you will need to update any implementations or subclasses you may have created): - -- Added an `$options` argument to the end of the following methods of `Guzzle\Http\ClientInterface`: - createRequest, head, delete, put, patch, post, options, prepareRequest -- Added an `$options` argument to the end of `Guzzle\Http\Message\Request\RequestFactoryInterface::createRequest()` -- Added an `applyOptions()` method to `Guzzle\Http\Message\Request\RequestFactoryInterface` -- Changed `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $body = null)` to - `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $options = array())`. You can still pass in a - resource, string, or EntityBody into the $options parameter to specify the download location of the response. -- Changed `Guzzle\Common\Collection::__construct($data)` to no longer accepts a null value for `$data` but a - default `array()` -- Added `Guzzle\Stream\StreamInterface::isRepeatable` -- Made `Guzzle\Http\Client::expandTemplate` and `getUriTemplate` protected methods. - -The following methods were removed from interfaces. All of these methods are still available in the concrete classes -that implement them, but you should update your code to use alternative methods: - -- Removed `Guzzle\Http\ClientInterface::setDefaultHeaders(). Use - `$client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. or - `$client->getConfig()->setPath('request.options/headers', array('header_name' => 'value'))` or - `$client->setDefaultOption('headers/{header_name}', 'value')`. or - `$client->setDefaultOption('headers', array('header_name' => 'value'))`. -- Removed `Guzzle\Http\ClientInterface::getDefaultHeaders(). Use `$client->getConfig()->getPath('request.options/headers')`. -- Removed `Guzzle\Http\ClientInterface::expandTemplate()`. This is an implementation detail. -- Removed `Guzzle\Http\ClientInterface::setRequestFactory()`. This is an implementation detail. -- Removed `Guzzle\Http\ClientInterface::getCurlMulti()`. This is a very specific implementation detail. -- Removed `Guzzle\Http\Message\RequestInterface::canCache`. Use the CachePlugin. -- Removed `Guzzle\Http\Message\RequestInterface::setIsRedirect`. Use the HistoryPlugin. -- Removed `Guzzle\Http\Message\RequestInterface::isRedirect`. Use the HistoryPlugin. - -### Cache plugin breaking changes - -- CacheKeyProviderInterface and DefaultCacheKeyProvider are no longer used. All of this logic is handled in a - CacheStorageInterface. These two objects and interface will be removed in a future version. -- Always setting X-cache headers on cached responses -- Default cache TTLs are now handled by the CacheStorageInterface of a CachePlugin -- `CacheStorageInterface::cache($key, Response $response, $ttl = null)` has changed to `cache(RequestInterface - $request, Response $response);` -- `CacheStorageInterface::fetch($key)` has changed to `fetch(RequestInterface $request);` -- `CacheStorageInterface::delete($key)` has changed to `delete(RequestInterface $request);` -- Added `CacheStorageInterface::purge($url)` -- `DefaultRevalidation::__construct(CacheKeyProviderInterface $cacheKey, CacheStorageInterface $cache, CachePlugin - $plugin)` has changed to `DefaultRevalidation::__construct(CacheStorageInterface $cache, - CanCacheStrategyInterface $canCache = null)` -- Added `RevalidationInterface::shouldRevalidate(RequestInterface $request, Response $response)` - -3.5 to 3.6 ----------- - -* Mixed casing of headers are now forced to be a single consistent casing across all values for that header. -* Messages internally use a HeaderCollection object to delegate handling case-insensitive header resolution -* Removed the whole changedHeader() function system of messages because all header changes now go through addHeader(). - For example, setHeader() first removes the header using unset on a HeaderCollection and then calls addHeader(). - Keeping the Host header and URL host in sync is now handled by overriding the addHeader method in Request. -* Specific header implementations can be created for complex headers. When a message creates a header, it uses a - HeaderFactory which can map specific headers to specific header classes. There is now a Link header and - CacheControl header implementation. -* Moved getLinks() from Response to just be used on a Link header object. - -If you previously relied on Guzzle\Http\Message\Header::raw(), then you will need to update your code to use the -HeaderInterface (e.g. toArray(), getAll(), etc.). - -### Interface changes - -* Removed from interface: Guzzle\Http\ClientInterface::setUriTemplate -* Removed from interface: Guzzle\Http\ClientInterface::setCurlMulti() -* Removed Guzzle\Http\Message\Request::receivedRequestHeader() and implemented this functionality in - Guzzle\Http\Curl\RequestMediator -* Removed the optional $asString parameter from MessageInterface::getHeader(). Just cast the header to a string. -* Removed the optional $tryChunkedTransfer option from Guzzle\Http\Message\EntityEnclosingRequestInterface -* Removed the $asObjects argument from Guzzle\Http\Message\MessageInterface::getHeaders() - -### Removed deprecated functions - -* Removed Guzzle\Parser\ParserRegister::get(). Use getParser() -* Removed Guzzle\Parser\ParserRegister::set(). Use registerParser(). - -### Deprecations - -* The ability to case-insensitively search for header values -* Guzzle\Http\Message\Header::hasExactHeader -* Guzzle\Http\Message\Header::raw. Use getAll() -* Deprecated cache control specific methods on Guzzle\Http\Message\AbstractMessage. Use the CacheControl header object - instead. - -### Other changes - -* All response header helper functions return a string rather than mixing Header objects and strings inconsistently -* Removed cURL blacklist support. This is no longer necessary now that Expect, Accept, etc. are managed by Guzzle - directly via interfaces -* Removed the injecting of a request object onto a response object. The methods to get and set a request still exist - but are a no-op until removed. -* Most classes that used to require a `Guzzle\Service\Command\CommandInterface` typehint now request a - `Guzzle\Service\Command\ArrayCommandInterface`. -* Added `Guzzle\Http\Message\RequestInterface::startResponse()` to the RequestInterface to handle injecting a response - on a request while the request is still being transferred -* `Guzzle\Service\Command\CommandInterface` now extends from ToArrayInterface and ArrayAccess - -3.3 to 3.4 ----------- - -Base URLs of a client now follow the rules of http://tools.ietf.org/html/rfc3986#section-5.2.2 when merging URLs. - -3.2 to 3.3 ----------- - -### Response::getEtag() quote stripping removed - -`Guzzle\Http\Message\Response::getEtag()` no longer strips quotes around the ETag response header - -### Removed `Guzzle\Http\Utils` - -The `Guzzle\Http\Utils` class was removed. This class was only used for testing. - -### Stream wrapper and type - -`Guzzle\Stream\Stream::getWrapper()` and `Guzzle\Stream\Stream::getStreamType()` are no longer converted to lowercase. - -### curl.emit_io became emit_io - -Emitting IO events from a RequestMediator is now a parameter that must be set in a request's curl options using the -'emit_io' key. This was previously set under a request's parameters using 'curl.emit_io' - -3.1 to 3.2 ----------- - -### CurlMulti is no longer reused globally - -Before 3.2, the same CurlMulti object was reused globally for each client. This can cause issue where plugins added -to a single client can pollute requests dispatched from other clients. - -If you still wish to reuse the same CurlMulti object with each client, then you can add a listener to the -ServiceBuilder's `service_builder.create_client` event to inject a custom CurlMulti object into each client as it is -created. - -```php -$multi = new Guzzle\Http\Curl\CurlMulti(); -$builder = Guzzle\Service\Builder\ServiceBuilder::factory('/path/to/config.json'); -$builder->addListener('service_builder.create_client', function ($event) use ($multi) { - $event['client']->setCurlMulti($multi); -} -}); -``` - -### No default path - -URLs no longer have a default path value of '/' if no path was specified. - -Before: - -```php -$request = $client->get('http://www.foo.com'); -echo $request->getUrl(); -// >> http://www.foo.com/ -``` - -After: - -```php -$request = $client->get('http://www.foo.com'); -echo $request->getUrl(); -// >> http://www.foo.com -``` - -### Less verbose BadResponseException - -The exception message for `Guzzle\Http\Exception\BadResponseException` no longer contains the full HTTP request and -response information. You can, however, get access to the request and response object by calling `getRequest()` or -`getResponse()` on the exception object. - -### Query parameter aggregation - -Multi-valued query parameters are no longer aggregated using a callback function. `Guzzle\Http\Query` now has a -setAggregator() method that accepts a `Guzzle\Http\QueryAggregator\QueryAggregatorInterface` object. This object is -responsible for handling the aggregation of multi-valued query string variables into a flattened hash. - -2.8 to 3.x ----------- - -### Guzzle\Service\Inspector - -Change `\Guzzle\Service\Inspector::fromConfig` to `\Guzzle\Common\Collection::fromConfig` - -**Before** - -```php -use Guzzle\Service\Inspector; - -class YourClient extends \Guzzle\Service\Client -{ - public static function factory($config = array()) - { - $default = array(); - $required = array('base_url', 'username', 'api_key'); - $config = Inspector::fromConfig($config, $default, $required); - - $client = new self( - $config->get('base_url'), - $config->get('username'), - $config->get('api_key') - ); - $client->setConfig($config); - - $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json')); - - return $client; - } -``` - -**After** - -```php -use Guzzle\Common\Collection; - -class YourClient extends \Guzzle\Service\Client -{ - public static function factory($config = array()) - { - $default = array(); - $required = array('base_url', 'username', 'api_key'); - $config = Collection::fromConfig($config, $default, $required); - - $client = new self( - $config->get('base_url'), - $config->get('username'), - $config->get('api_key') - ); - $client->setConfig($config); - - $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json')); - - return $client; - } -``` - -### Convert XML Service Descriptions to JSON - -**Before** - -```xml -<?xml version="1.0" encoding="UTF-8"?> -<client> - <commands> - <!-- Groups --> - <command name="list_groups" method="GET" uri="groups.json"> - <doc>Get a list of groups</doc> - </command> - <command name="search_groups" method="GET" uri='search.json?query="{{query}} type:group"'> - <doc>Uses a search query to get a list of groups</doc> - <param name="query" type="string" required="true" /> - </command> - <command name="create_group" method="POST" uri="groups.json"> - <doc>Create a group</doc> - <param name="data" type="array" location="body" filters="json_encode" doc="Group JSON"/> - <param name="Content-Type" location="header" static="application/json"/> - </command> - <command name="delete_group" method="DELETE" uri="groups/{{id}}.json"> - <doc>Delete a group by ID</doc> - <param name="id" type="integer" required="true"/> - </command> - <command name="get_group" method="GET" uri="groups/{{id}}.json"> - <param name="id" type="integer" required="true"/> - </command> - <command name="update_group" method="PUT" uri="groups/{{id}}.json"> - <doc>Update a group</doc> - <param name="id" type="integer" required="true"/> - <param name="data" type="array" location="body" filters="json_encode" doc="Group JSON"/> - <param name="Content-Type" location="header" static="application/json"/> - </command> - </commands> -</client> -``` - -**After** - -```json -{ - "name": "Zendesk REST API v2", - "apiVersion": "2012-12-31", - "description":"Provides access to Zendesk views, groups, tickets, ticket fields, and users", - "operations": { - "list_groups": { - "httpMethod":"GET", - "uri": "groups.json", - "summary": "Get a list of groups" - }, - "search_groups":{ - "httpMethod":"GET", - "uri": "search.json?query=\"{query} type:group\"", - "summary": "Uses a search query to get a list of groups", - "parameters":{ - "query":{ - "location": "uri", - "description":"Zendesk Search Query", - "type": "string", - "required": true - } - } - }, - "create_group": { - "httpMethod":"POST", - "uri": "groups.json", - "summary": "Create a group", - "parameters":{ - "data": { - "type": "array", - "location": "body", - "description":"Group JSON", - "filters": "json_encode", - "required": true - }, - "Content-Type":{ - "type": "string", - "location":"header", - "static": "application/json" - } - } - }, - "delete_group": { - "httpMethod":"DELETE", - "uri": "groups/{id}.json", - "summary": "Delete a group", - "parameters":{ - "id":{ - "location": "uri", - "description":"Group to delete by ID", - "type": "integer", - "required": true - } - } - }, - "get_group": { - "httpMethod":"GET", - "uri": "groups/{id}.json", - "summary": "Get a ticket", - "parameters":{ - "id":{ - "location": "uri", - "description":"Group to get by ID", - "type": "integer", - "required": true - } - } - }, - "update_group": { - "httpMethod":"PUT", - "uri": "groups/{id}.json", - "summary": "Update a group", - "parameters":{ - "id": { - "location": "uri", - "description":"Group to update by ID", - "type": "integer", - "required": true - }, - "data": { - "type": "array", - "location": "body", - "description":"Group JSON", - "filters": "json_encode", - "required": true - }, - "Content-Type":{ - "type": "string", - "location":"header", - "static": "application/json" - } - } - } -} -``` - -### Guzzle\Service\Description\ServiceDescription - -Commands are now called Operations - -**Before** - -```php -use Guzzle\Service\Description\ServiceDescription; - -$sd = new ServiceDescription(); -$sd->getCommands(); // @returns ApiCommandInterface[] -$sd->hasCommand($name); -$sd->getCommand($name); // @returns ApiCommandInterface|null -$sd->addCommand($command); // @param ApiCommandInterface $command -``` - -**After** - -```php -use Guzzle\Service\Description\ServiceDescription; - -$sd = new ServiceDescription(); -$sd->getOperations(); // @returns OperationInterface[] -$sd->hasOperation($name); -$sd->getOperation($name); // @returns OperationInterface|null -$sd->addOperation($operation); // @param OperationInterface $operation -``` - -### Guzzle\Common\Inflection\Inflector - -Namespace is now `Guzzle\Inflection\Inflector` - -### Guzzle\Http\Plugin - -Namespace is now `Guzzle\Plugin`. Many other changes occur within this namespace and are detailed in their own sections below. - -### Guzzle\Http\Plugin\LogPlugin and Guzzle\Common\Log - -Now `Guzzle\Plugin\Log\LogPlugin` and `Guzzle\Log` respectively. - -**Before** - -```php -use Guzzle\Common\Log\ClosureLogAdapter; -use Guzzle\Http\Plugin\LogPlugin; - -/** @var \Guzzle\Http\Client */ -$client; - -// $verbosity is an integer indicating desired message verbosity level -$client->addSubscriber(new LogPlugin(new ClosureLogAdapter(function($m) { echo $m; }, $verbosity = LogPlugin::LOG_VERBOSE); -``` - -**After** - -```php -use Guzzle\Log\ClosureLogAdapter; -use Guzzle\Log\MessageFormatter; -use Guzzle\Plugin\Log\LogPlugin; - -/** @var \Guzzle\Http\Client */ -$client; - -// $format is a string indicating desired message format -- @see MessageFormatter -$client->addSubscriber(new LogPlugin(new ClosureLogAdapter(function($m) { echo $m; }, $format = MessageFormatter::DEBUG_FORMAT); -``` - -### Guzzle\Http\Plugin\CurlAuthPlugin - -Now `Guzzle\Plugin\CurlAuth\CurlAuthPlugin`. - -### Guzzle\Http\Plugin\ExponentialBackoffPlugin - -Now `Guzzle\Plugin\Backoff\BackoffPlugin`, and other changes. - -**Before** - -```php -use Guzzle\Http\Plugin\ExponentialBackoffPlugin; - -$backoffPlugin = new ExponentialBackoffPlugin($maxRetries, array_merge( - ExponentialBackoffPlugin::getDefaultFailureCodes(), array(429) - )); - -$client->addSubscriber($backoffPlugin); -``` - -**After** - -```php -use Guzzle\Plugin\Backoff\BackoffPlugin; -use Guzzle\Plugin\Backoff\HttpBackoffStrategy; - -// Use convenient factory method instead -- see implementation for ideas of what -// you can do with chaining backoff strategies -$backoffPlugin = BackoffPlugin::getExponentialBackoff($maxRetries, array_merge( - HttpBackoffStrategy::getDefaultFailureCodes(), array(429) - )); -$client->addSubscriber($backoffPlugin); -``` - -### Known Issues - -#### [BUG] Accept-Encoding header behavior changed unintentionally. - -(See #217) (Fixed in 09daeb8c666fb44499a0646d655a8ae36456575e) - -In version 2.8 setting the `Accept-Encoding` header would set the CURLOPT_ENCODING option, which permitted cURL to -properly handle gzip/deflate compressed responses from the server. In versions affected by this bug this does not happen. -See issue #217 for a workaround, or use a version containing the fix. diff --git a/vendor/guzzlehttp/guzzle/composer.json b/vendor/guzzlehttp/guzzle/composer.json deleted file mode 100755 index 1f328e308cdbf05fd63eac1be11099a194d3cb1c..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/composer.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "guzzlehttp/guzzle", - "type": "library", - "description": "Guzzle is a PHP HTTP client library", - "keywords": ["framework", "http", "rest", "web service", "curl", "client", "HTTP client"], - "homepage": "http://guzzlephp.org/", - "license": "MIT", - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "require": { - "php": ">=5.5", - "guzzlehttp/psr7": "^1.4", - "guzzlehttp/promises": "^1.0" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", - "psr/log": "^1.0" - }, - "autoload": { - "files": ["src/functions_include.php"], - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "GuzzleHttp\\Tests\\": "tests/" - } - }, - "suggest": { - "psr/log": "Required for using the Log middleware" - }, - "extra": { - "branch-alias": { - "dev-master": "6.3-dev" - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Client.php b/vendor/guzzlehttp/guzzle/src/Client.php deleted file mode 100755 index 80417918d053c720a6079496dc9dbf40d19c41d7..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Client.php +++ /dev/null @@ -1,422 +0,0 @@ -<?php -namespace GuzzleHttp; - -use GuzzleHttp\Cookie\CookieJar; -use GuzzleHttp\Promise; -use GuzzleHttp\Psr7; -use Psr\Http\Message\UriInterface; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * @method ResponseInterface get(string|UriInterface $uri, array $options = []) - * @method ResponseInterface head(string|UriInterface $uri, array $options = []) - * @method ResponseInterface put(string|UriInterface $uri, array $options = []) - * @method ResponseInterface post(string|UriInterface $uri, array $options = []) - * @method ResponseInterface patch(string|UriInterface $uri, array $options = []) - * @method ResponseInterface delete(string|UriInterface $uri, array $options = []) - * @method Promise\PromiseInterface getAsync(string|UriInterface $uri, array $options = []) - * @method Promise\PromiseInterface headAsync(string|UriInterface $uri, array $options = []) - * @method Promise\PromiseInterface putAsync(string|UriInterface $uri, array $options = []) - * @method Promise\PromiseInterface postAsync(string|UriInterface $uri, array $options = []) - * @method Promise\PromiseInterface patchAsync(string|UriInterface $uri, array $options = []) - * @method Promise\PromiseInterface deleteAsync(string|UriInterface $uri, array $options = []) - */ -class Client implements ClientInterface -{ - /** @var array Default request options */ - private $config; - - /** - * Clients accept an array of constructor parameters. - * - * Here's an example of creating a client using a base_uri and an array of - * default request options to apply to each request: - * - * $client = new Client([ - * 'base_uri' => 'http://www.foo.com/1.0/', - * 'timeout' => 0, - * 'allow_redirects' => false, - * 'proxy' => '192.168.16.1:10' - * ]); - * - * Client configuration settings include the following options: - * - * - handler: (callable) Function that transfers HTTP requests over the - * wire. The function is called with a Psr7\Http\Message\RequestInterface - * and array of transfer options, and must return a - * GuzzleHttp\Promise\PromiseInterface that is fulfilled with a - * Psr7\Http\Message\ResponseInterface on success. "handler" is a - * constructor only option that cannot be overridden in per/request - * options. If no handler is provided, a default handler will be created - * that enables all of the request options below by attaching all of the - * default middleware to the handler. - * - base_uri: (string|UriInterface) Base URI of the client that is merged - * into relative URIs. Can be a string or instance of UriInterface. - * - **: any request option - * - * @param array $config Client configuration settings. - * - * @see \GuzzleHttp\RequestOptions for a list of available request options. - */ - public function __construct(array $config = []) - { - if (!isset($config['handler'])) { - $config['handler'] = HandlerStack::create(); - } elseif (!is_callable($config['handler'])) { - throw new \InvalidArgumentException('handler must be a callable'); - } - - // Convert the base_uri to a UriInterface - if (isset($config['base_uri'])) { - $config['base_uri'] = Psr7\uri_for($config['base_uri']); - } - - $this->configureDefaults($config); - } - - public function __call($method, $args) - { - if (count($args) < 1) { - throw new \InvalidArgumentException('Magic request methods require a URI and optional options array'); - } - - $uri = $args[0]; - $opts = isset($args[1]) ? $args[1] : []; - - return substr($method, -5) === 'Async' - ? $this->requestAsync(substr($method, 0, -5), $uri, $opts) - : $this->request($method, $uri, $opts); - } - - public function sendAsync(RequestInterface $request, array $options = []) - { - // Merge the base URI into the request URI if needed. - $options = $this->prepareDefaults($options); - - return $this->transfer( - $request->withUri($this->buildUri($request->getUri(), $options), $request->hasHeader('Host')), - $options - ); - } - - public function send(RequestInterface $request, array $options = []) - { - $options[RequestOptions::SYNCHRONOUS] = true; - return $this->sendAsync($request, $options)->wait(); - } - - public function requestAsync($method, $uri = '', array $options = []) - { - $options = $this->prepareDefaults($options); - // Remove request modifying parameter because it can be done up-front. - $headers = isset($options['headers']) ? $options['headers'] : []; - $body = isset($options['body']) ? $options['body'] : null; - $version = isset($options['version']) ? $options['version'] : '1.1'; - // Merge the URI into the base URI. - $uri = $this->buildUri($uri, $options); - if (is_array($body)) { - $this->invalidBody(); - } - $request = new Psr7\Request($method, $uri, $headers, $body, $version); - // Remove the option so that they are not doubly-applied. - unset($options['headers'], $options['body'], $options['version']); - - return $this->transfer($request, $options); - } - - public function request($method, $uri = '', array $options = []) - { - $options[RequestOptions::SYNCHRONOUS] = true; - return $this->requestAsync($method, $uri, $options)->wait(); - } - - public function getConfig($option = null) - { - return $option === null - ? $this->config - : (isset($this->config[$option]) ? $this->config[$option] : null); - } - - private function buildUri($uri, array $config) - { - // for BC we accept null which would otherwise fail in uri_for - $uri = Psr7\uri_for($uri === null ? '' : $uri); - - if (isset($config['base_uri'])) { - $uri = Psr7\UriResolver::resolve(Psr7\uri_for($config['base_uri']), $uri); - } - - return $uri->getScheme() === '' && $uri->getHost() !== '' ? $uri->withScheme('http') : $uri; - } - - /** - * Configures the default options for a client. - * - * @param array $config - */ - private function configureDefaults(array $config) - { - $defaults = [ - 'allow_redirects' => RedirectMiddleware::$defaultSettings, - 'http_errors' => true, - 'decode_content' => true, - 'verify' => true, - 'cookies' => false - ]; - - // Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set. - - // We can only trust the HTTP_PROXY environment variable in a CLI - // process due to the fact that PHP has no reliable mechanism to - // get environment variables that start with "HTTP_". - if (php_sapi_name() == 'cli' && getenv('HTTP_PROXY')) { - $defaults['proxy']['http'] = getenv('HTTP_PROXY'); - } - - if ($proxy = getenv('HTTPS_PROXY')) { - $defaults['proxy']['https'] = $proxy; - } - - if ($noProxy = getenv('NO_PROXY')) { - $cleanedNoProxy = str_replace(' ', '', $noProxy); - $defaults['proxy']['no'] = explode(',', $cleanedNoProxy); - } - - $this->config = $config + $defaults; - - if (!empty($config['cookies']) && $config['cookies'] === true) { - $this->config['cookies'] = new CookieJar(); - } - - // Add the default user-agent header. - if (!isset($this->config['headers'])) { - $this->config['headers'] = ['User-Agent' => default_user_agent()]; - } else { - // Add the User-Agent header if one was not already set. - foreach (array_keys($this->config['headers']) as $name) { - if (strtolower($name) === 'user-agent') { - return; - } - } - $this->config['headers']['User-Agent'] = default_user_agent(); - } - } - - /** - * Merges default options into the array. - * - * @param array $options Options to modify by reference - * - * @return array - */ - private function prepareDefaults($options) - { - $defaults = $this->config; - - if (!empty($defaults['headers'])) { - // Default headers are only added if they are not present. - $defaults['_conditional'] = $defaults['headers']; - unset($defaults['headers']); - } - - // Special handling for headers is required as they are added as - // conditional headers and as headers passed to a request ctor. - if (array_key_exists('headers', $options)) { - // Allows default headers to be unset. - if ($options['headers'] === null) { - $defaults['_conditional'] = null; - unset($options['headers']); - } elseif (!is_array($options['headers'])) { - throw new \InvalidArgumentException('headers must be an array'); - } - } - - // Shallow merge defaults underneath options. - $result = $options + $defaults; - - // Remove null values. - foreach ($result as $k => $v) { - if ($v === null) { - unset($result[$k]); - } - } - - return $result; - } - - /** - * Transfers the given request and applies request options. - * - * The URI of the request is not modified and the request options are used - * as-is without merging in default options. - * - * @param RequestInterface $request - * @param array $options - * - * @return Promise\PromiseInterface - */ - private function transfer(RequestInterface $request, array $options) - { - // save_to -> sink - if (isset($options['save_to'])) { - $options['sink'] = $options['save_to']; - unset($options['save_to']); - } - - // exceptions -> http_errors - if (isset($options['exceptions'])) { - $options['http_errors'] = $options['exceptions']; - unset($options['exceptions']); - } - - $request = $this->applyOptions($request, $options); - $handler = $options['handler']; - - try { - return Promise\promise_for($handler($request, $options)); - } catch (\Exception $e) { - return Promise\rejection_for($e); - } - } - - /** - * Applies the array of request options to a request. - * - * @param RequestInterface $request - * @param array $options - * - * @return RequestInterface - */ - private function applyOptions(RequestInterface $request, array &$options) - { - $modify = [ - 'set_headers' => [], - ]; - - if (isset($options['headers'])) { - $modify['set_headers'] = $options['headers']; - unset($options['headers']); - } - - if (isset($options['form_params'])) { - if (isset($options['multipart'])) { - throw new \InvalidArgumentException('You cannot use ' - . 'form_params and multipart at the same time. Use the ' - . 'form_params option if you want to send application/' - . 'x-www-form-urlencoded requests, and the multipart ' - . 'option to send multipart/form-data requests.'); - } - $options['body'] = http_build_query($options['form_params'], '', '&'); - unset($options['form_params']); - // Ensure that we don't have the header in different case and set the new value. - $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']); - $options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded'; - } - - if (isset($options['multipart'])) { - $options['body'] = new Psr7\MultipartStream($options['multipart']); - unset($options['multipart']); - } - - if (isset($options['json'])) { - $options['body'] = \GuzzleHttp\json_encode($options['json']); - unset($options['json']); - // Ensure that we don't have the header in different case and set the new value. - $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']); - $options['_conditional']['Content-Type'] = 'application/json'; - } - - if (!empty($options['decode_content']) - && $options['decode_content'] !== true - ) { - // Ensure that we don't have the header in different case and set the new value. - $options['_conditional'] = Psr7\_caseless_remove(['Accept-Encoding'], $options['_conditional']); - $modify['set_headers']['Accept-Encoding'] = $options['decode_content']; - } - - if (isset($options['body'])) { - if (is_array($options['body'])) { - $this->invalidBody(); - } - $modify['body'] = Psr7\stream_for($options['body']); - unset($options['body']); - } - - if (!empty($options['auth']) && is_array($options['auth'])) { - $value = $options['auth']; - $type = isset($value[2]) ? strtolower($value[2]) : 'basic'; - switch ($type) { - case 'basic': - // Ensure that we don't have the header in different case and set the new value. - $modify['set_headers'] = Psr7\_caseless_remove(['Authorization'], $modify['set_headers']); - $modify['set_headers']['Authorization'] = 'Basic ' - . base64_encode("$value[0]:$value[1]"); - break; - case 'digest': - // @todo: Do not rely on curl - $options['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_DIGEST; - $options['curl'][CURLOPT_USERPWD] = "$value[0]:$value[1]"; - break; - case 'ntlm': - $options['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_NTLM; - $options['curl'][CURLOPT_USERPWD] = "$value[0]:$value[1]"; - break; - } - } - - if (isset($options['query'])) { - $value = $options['query']; - if (is_array($value)) { - $value = http_build_query($value, null, '&', PHP_QUERY_RFC3986); - } - if (!is_string($value)) { - throw new \InvalidArgumentException('query must be a string or array'); - } - $modify['query'] = $value; - unset($options['query']); - } - - // Ensure that sink is not an invalid value. - if (isset($options['sink'])) { - // TODO: Add more sink validation? - if (is_bool($options['sink'])) { - throw new \InvalidArgumentException('sink must not be a boolean'); - } - } - - $request = Psr7\modify_request($request, $modify); - if ($request->getBody() instanceof Psr7\MultipartStream) { - // Use a multipart/form-data POST if a Content-Type is not set. - // Ensure that we don't have the header in different case and set the new value. - $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']); - $options['_conditional']['Content-Type'] = 'multipart/form-data; boundary=' - . $request->getBody()->getBoundary(); - } - - // Merge in conditional headers if they are not present. - if (isset($options['_conditional'])) { - // Build up the changes so it's in a single clone of the message. - $modify = []; - foreach ($options['_conditional'] as $k => $v) { - if (!$request->hasHeader($k)) { - $modify['set_headers'][$k] = $v; - } - } - $request = Psr7\modify_request($request, $modify); - // Don't pass this internal value along to middleware/handlers. - unset($options['_conditional']); - } - - return $request; - } - - private function invalidBody() - { - throw new \InvalidArgumentException('Passing in the "body" request ' - . 'option as an array to send a POST request has been deprecated. ' - . 'Please use the "form_params" request option to send a ' - . 'application/x-www-form-urlencoded request, or the "multipart" ' - . 'request option to send a multipart/form-data request.'); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/ClientInterface.php b/vendor/guzzlehttp/guzzle/src/ClientInterface.php deleted file mode 100755 index 2dbcffa492d0c4ade0b8bf7ba73756cdede249a0..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/ClientInterface.php +++ /dev/null @@ -1,84 +0,0 @@ -<?php -namespace GuzzleHttp; - -use GuzzleHttp\Promise\PromiseInterface; -use GuzzleHttp\Exception\GuzzleException; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\UriInterface; - -/** - * Client interface for sending HTTP requests. - */ -interface ClientInterface -{ - const VERSION = '6.3.3'; - - /** - * Send an HTTP request. - * - * @param RequestInterface $request Request to send - * @param array $options Request options to apply to the given - * request and to the transfer. - * - * @return ResponseInterface - * @throws GuzzleException - */ - public function send(RequestInterface $request, array $options = []); - - /** - * Asynchronously send an HTTP request. - * - * @param RequestInterface $request Request to send - * @param array $options Request options to apply to the given - * request and to the transfer. - * - * @return PromiseInterface - */ - public function sendAsync(RequestInterface $request, array $options = []); - - /** - * Create and send an HTTP request. - * - * Use an absolute path to override the base path of the client, or a - * relative path to append to the base path of the client. The URL can - * contain the query string as well. - * - * @param string $method HTTP method. - * @param string|UriInterface $uri URI object or string. - * @param array $options Request options to apply. - * - * @return ResponseInterface - * @throws GuzzleException - */ - public function request($method, $uri, array $options = []); - - /** - * Create and send an asynchronous HTTP request. - * - * Use an absolute path to override the base path of the client, or a - * relative path to append to the base path of the client. The URL can - * contain the query string as well. Use an array to provide a URL - * template and additional variables to use in the URL template expansion. - * - * @param string $method HTTP method - * @param string|UriInterface $uri URI object or string. - * @param array $options Request options to apply. - * - * @return PromiseInterface - */ - public function requestAsync($method, $uri, array $options = []); - - /** - * Get a client configuration option. - * - * These options include default request options of the client, a "handler" - * (if utilized by the concrete client), and a "base_uri" if utilized by - * the concrete client. - * - * @param string|null $option The config option to retrieve. - * - * @return mixed - */ - public function getConfig($option = null); -} diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php b/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php deleted file mode 100755 index 78f2b79fecb55316ad3b974e3293206d66e81590..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php +++ /dev/null @@ -1,314 +0,0 @@ -<?php -namespace GuzzleHttp\Cookie; - -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Cookie jar that stores cookies as an array - */ -class CookieJar implements CookieJarInterface -{ - /** @var SetCookie[] Loaded cookie data */ - private $cookies = []; - - /** @var bool */ - private $strictMode; - - /** - * @param bool $strictMode Set to true to throw exceptions when invalid - * cookies are added to the cookie jar. - * @param array $cookieArray Array of SetCookie objects or a hash of - * arrays that can be used with the SetCookie - * constructor - */ - public function __construct($strictMode = false, $cookieArray = []) - { - $this->strictMode = $strictMode; - - foreach ($cookieArray as $cookie) { - if (!($cookie instanceof SetCookie)) { - $cookie = new SetCookie($cookie); - } - $this->setCookie($cookie); - } - } - - /** - * Create a new Cookie jar from an associative array and domain. - * - * @param array $cookies Cookies to create the jar from - * @param string $domain Domain to set the cookies to - * - * @return self - */ - public static function fromArray(array $cookies, $domain) - { - $cookieJar = new self(); - foreach ($cookies as $name => $value) { - $cookieJar->setCookie(new SetCookie([ - 'Domain' => $domain, - 'Name' => $name, - 'Value' => $value, - 'Discard' => true - ])); - } - - return $cookieJar; - } - - /** - * @deprecated - */ - public static function getCookieValue($value) - { - return $value; - } - - /** - * Evaluate if this cookie should be persisted to storage - * that survives between requests. - * - * @param SetCookie $cookie Being evaluated. - * @param bool $allowSessionCookies If we should persist session cookies - * @return bool - */ - public static function shouldPersist( - SetCookie $cookie, - $allowSessionCookies = false - ) { - if ($cookie->getExpires() || $allowSessionCookies) { - if (!$cookie->getDiscard()) { - return true; - } - } - - return false; - } - - /** - * Finds and returns the cookie based on the name - * - * @param string $name cookie name to search for - * @return SetCookie|null cookie that was found or null if not found - */ - public function getCookieByName($name) - { - // don't allow a null name - if ($name === null) { - return null; - } - foreach ($this->cookies as $cookie) { - if ($cookie->getName() !== null && strcasecmp($cookie->getName(), $name) === 0) { - return $cookie; - } - } - } - - public function toArray() - { - return array_map(function (SetCookie $cookie) { - return $cookie->toArray(); - }, $this->getIterator()->getArrayCopy()); - } - - public function clear($domain = null, $path = null, $name = null) - { - if (!$domain) { - $this->cookies = []; - return; - } elseif (!$path) { - $this->cookies = array_filter( - $this->cookies, - function (SetCookie $cookie) use ($path, $domain) { - return !$cookie->matchesDomain($domain); - } - ); - } elseif (!$name) { - $this->cookies = array_filter( - $this->cookies, - function (SetCookie $cookie) use ($path, $domain) { - return !($cookie->matchesPath($path) && - $cookie->matchesDomain($domain)); - } - ); - } else { - $this->cookies = array_filter( - $this->cookies, - function (SetCookie $cookie) use ($path, $domain, $name) { - return !($cookie->getName() == $name && - $cookie->matchesPath($path) && - $cookie->matchesDomain($domain)); - } - ); - } - } - - public function clearSessionCookies() - { - $this->cookies = array_filter( - $this->cookies, - function (SetCookie $cookie) { - return !$cookie->getDiscard() && $cookie->getExpires(); - } - ); - } - - public function setCookie(SetCookie $cookie) - { - // If the name string is empty (but not 0), ignore the set-cookie - // string entirely. - $name = $cookie->getName(); - if (!$name && $name !== '0') { - return false; - } - - // Only allow cookies with set and valid domain, name, value - $result = $cookie->validate(); - if ($result !== true) { - if ($this->strictMode) { - throw new \RuntimeException('Invalid cookie: ' . $result); - } else { - $this->removeCookieIfEmpty($cookie); - return false; - } - } - - // Resolve conflicts with previously set cookies - foreach ($this->cookies as $i => $c) { - - // Two cookies are identical, when their path, and domain are - // identical. - if ($c->getPath() != $cookie->getPath() || - $c->getDomain() != $cookie->getDomain() || - $c->getName() != $cookie->getName() - ) { - continue; - } - - // The previously set cookie is a discard cookie and this one is - // not so allow the new cookie to be set - if (!$cookie->getDiscard() && $c->getDiscard()) { - unset($this->cookies[$i]); - continue; - } - - // If the new cookie's expiration is further into the future, then - // replace the old cookie - if ($cookie->getExpires() > $c->getExpires()) { - unset($this->cookies[$i]); - continue; - } - - // If the value has changed, we better change it - if ($cookie->getValue() !== $c->getValue()) { - unset($this->cookies[$i]); - continue; - } - - // The cookie exists, so no need to continue - return false; - } - - $this->cookies[] = $cookie; - - return true; - } - - public function count() - { - return count($this->cookies); - } - - public function getIterator() - { - return new \ArrayIterator(array_values($this->cookies)); - } - - public function extractCookies( - RequestInterface $request, - ResponseInterface $response - ) { - if ($cookieHeader = $response->getHeader('Set-Cookie')) { - foreach ($cookieHeader as $cookie) { - $sc = SetCookie::fromString($cookie); - if (!$sc->getDomain()) { - $sc->setDomain($request->getUri()->getHost()); - } - if (0 !== strpos($sc->getPath(), '/')) { - $sc->setPath($this->getCookiePathFromRequest($request)); - } - $this->setCookie($sc); - } - } - } - - /** - * Computes cookie path following RFC 6265 section 5.1.4 - * - * @link https://tools.ietf.org/html/rfc6265#section-5.1.4 - * - * @param RequestInterface $request - * @return string - */ - private function getCookiePathFromRequest(RequestInterface $request) - { - $uriPath = $request->getUri()->getPath(); - if ('' === $uriPath) { - return '/'; - } - if (0 !== strpos($uriPath, '/')) { - return '/'; - } - if ('/' === $uriPath) { - return '/'; - } - if (0 === $lastSlashPos = strrpos($uriPath, '/')) { - return '/'; - } - - return substr($uriPath, 0, $lastSlashPos); - } - - public function withCookieHeader(RequestInterface $request) - { - $values = []; - $uri = $request->getUri(); - $scheme = $uri->getScheme(); - $host = $uri->getHost(); - $path = $uri->getPath() ?: '/'; - - foreach ($this->cookies as $cookie) { - if ($cookie->matchesPath($path) && - $cookie->matchesDomain($host) && - !$cookie->isExpired() && - (!$cookie->getSecure() || $scheme === 'https') - ) { - $values[] = $cookie->getName() . '=' - . $cookie->getValue(); - } - } - - return $values - ? $request->withHeader('Cookie', implode('; ', $values)) - : $request; - } - - /** - * If a cookie already exists and the server asks to set it again with a - * null value, the cookie must be deleted. - * - * @param SetCookie $cookie - */ - private function removeCookieIfEmpty(SetCookie $cookie) - { - $cookieValue = $cookie->getValue(); - if ($cookieValue === null || $cookieValue === '') { - $this->clear( - $cookie->getDomain(), - $cookie->getPath(), - $cookie->getName() - ); - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php b/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php deleted file mode 100755 index 2cf298a867b3713f6fa3143d5288ce2458c311c2..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php +++ /dev/null @@ -1,84 +0,0 @@ -<?php -namespace GuzzleHttp\Cookie; - -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Stores HTTP cookies. - * - * It extracts cookies from HTTP requests, and returns them in HTTP responses. - * CookieJarInterface instances automatically expire contained cookies when - * necessary. Subclasses are also responsible for storing and retrieving - * cookies from a file, database, etc. - * - * @link http://docs.python.org/2/library/cookielib.html Inspiration - */ -interface CookieJarInterface extends \Countable, \IteratorAggregate -{ - /** - * Create a request with added cookie headers. - * - * If no matching cookies are found in the cookie jar, then no Cookie - * header is added to the request and the same request is returned. - * - * @param RequestInterface $request Request object to modify. - * - * @return RequestInterface returns the modified request. - */ - public function withCookieHeader(RequestInterface $request); - - /** - * Extract cookies from an HTTP response and store them in the CookieJar. - * - * @param RequestInterface $request Request that was sent - * @param ResponseInterface $response Response that was received - */ - public function extractCookies( - RequestInterface $request, - ResponseInterface $response - ); - - /** - * Sets a cookie in the cookie jar. - * - * @param SetCookie $cookie Cookie to set. - * - * @return bool Returns true on success or false on failure - */ - public function setCookie(SetCookie $cookie); - - /** - * Remove cookies currently held in the cookie jar. - * - * Invoking this method without arguments will empty the whole cookie jar. - * If given a $domain argument only cookies belonging to that domain will - * be removed. If given a $domain and $path argument, cookies belonging to - * the specified path within that domain are removed. If given all three - * arguments, then the cookie with the specified name, path and domain is - * removed. - * - * @param string $domain Clears cookies matching a domain - * @param string $path Clears cookies matching a domain and path - * @param string $name Clears cookies matching a domain, path, and name - * - * @return CookieJarInterface - */ - public function clear($domain = null, $path = null, $name = null); - - /** - * Discard all sessions cookies. - * - * Removes cookies that don't have an expire field or a have a discard - * field set to true. To be called when the user agent shuts down according - * to RFC 2965. - */ - public function clearSessionCookies(); - - /** - * Converts the cookie jar to an array. - * - * @return array - */ - public function toArray(); -} diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php b/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php deleted file mode 100755 index 9887c1d54b2db295e6d9e5dfc67510d54941d940..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php -namespace GuzzleHttp\Cookie; - -/** - * Persists non-session cookies using a JSON formatted file - */ -class FileCookieJar extends CookieJar -{ - /** @var string filename */ - private $filename; - - /** @var bool Control whether to persist session cookies or not. */ - private $storeSessionCookies; - - /** - * Create a new FileCookieJar object - * - * @param string $cookieFile File to store the cookie data - * @param bool $storeSessionCookies Set to true to store session cookies - * in the cookie jar. - * - * @throws \RuntimeException if the file cannot be found or created - */ - public function __construct($cookieFile, $storeSessionCookies = false) - { - $this->filename = $cookieFile; - $this->storeSessionCookies = $storeSessionCookies; - - if (file_exists($cookieFile)) { - $this->load($cookieFile); - } - } - - /** - * Saves the file when shutting down - */ - public function __destruct() - { - $this->save($this->filename); - } - - /** - * Saves the cookies to a file. - * - * @param string $filename File to save - * @throws \RuntimeException if the file cannot be found or created - */ - public function save($filename) - { - $json = []; - foreach ($this as $cookie) { - /** @var SetCookie $cookie */ - if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) { - $json[] = $cookie->toArray(); - } - } - - $jsonStr = \GuzzleHttp\json_encode($json); - if (false === file_put_contents($filename, $jsonStr)) { - throw new \RuntimeException("Unable to save file {$filename}"); - } - } - - /** - * Load cookies from a JSON formatted file. - * - * Old cookies are kept unless overwritten by newly loaded ones. - * - * @param string $filename Cookie file to load. - * @throws \RuntimeException if the file cannot be loaded. - */ - public function load($filename) - { - $json = file_get_contents($filename); - if (false === $json) { - throw new \RuntimeException("Unable to load file {$filename}"); - } elseif ($json === '') { - return; - } - - $data = \GuzzleHttp\json_decode($json, true); - if (is_array($data)) { - foreach (json_decode($json, true) as $cookie) { - $this->setCookie(new SetCookie($cookie)); - } - } elseif (strlen($data)) { - throw new \RuntimeException("Invalid cookie file: {$filename}"); - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php b/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php deleted file mode 100755 index 4497bcf03e24ec69b443eff05ac56b2c94e62c9f..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php +++ /dev/null @@ -1,71 +0,0 @@ -<?php -namespace GuzzleHttp\Cookie; - -/** - * Persists cookies in the client session - */ -class SessionCookieJar extends CookieJar -{ - /** @var string session key */ - private $sessionKey; - - /** @var bool Control whether to persist session cookies or not. */ - private $storeSessionCookies; - - /** - * Create a new SessionCookieJar object - * - * @param string $sessionKey Session key name to store the cookie - * data in session - * @param bool $storeSessionCookies Set to true to store session cookies - * in the cookie jar. - */ - public function __construct($sessionKey, $storeSessionCookies = false) - { - $this->sessionKey = $sessionKey; - $this->storeSessionCookies = $storeSessionCookies; - $this->load(); - } - - /** - * Saves cookies to session when shutting down - */ - public function __destruct() - { - $this->save(); - } - - /** - * Save cookies to the client session - */ - public function save() - { - $json = []; - foreach ($this as $cookie) { - /** @var SetCookie $cookie */ - if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) { - $json[] = $cookie->toArray(); - } - } - - $_SESSION[$this->sessionKey] = json_encode($json); - } - - /** - * Load the contents of the client session into the data array - */ - protected function load() - { - if (!isset($_SESSION[$this->sessionKey])) { - return; - } - $data = json_decode($_SESSION[$this->sessionKey], true); - if (is_array($data)) { - foreach ($data as $cookie) { - $this->setCookie(new SetCookie($cookie)); - } - } elseif (strlen($data)) { - throw new \RuntimeException("Invalid cookie data"); - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php b/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php deleted file mode 100755 index f6993943e747c2d56218b343c74d7444bcb98cd8..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php +++ /dev/null @@ -1,403 +0,0 @@ -<?php -namespace GuzzleHttp\Cookie; - -/** - * Set-Cookie object - */ -class SetCookie -{ - /** @var array */ - private static $defaults = [ - 'Name' => null, - 'Value' => null, - 'Domain' => null, - 'Path' => '/', - 'Max-Age' => null, - 'Expires' => null, - 'Secure' => false, - 'Discard' => false, - 'HttpOnly' => false - ]; - - /** @var array Cookie data */ - private $data; - - /** - * Create a new SetCookie object from a string - * - * @param string $cookie Set-Cookie header string - * - * @return self - */ - public static function fromString($cookie) - { - // Create the default return array - $data = self::$defaults; - // Explode the cookie string using a series of semicolons - $pieces = array_filter(array_map('trim', explode(';', $cookie))); - // The name of the cookie (first kvp) must exist and include an equal sign. - if (empty($pieces[0]) || !strpos($pieces[0], '=')) { - return new self($data); - } - - // Add the cookie pieces into the parsed data array - foreach ($pieces as $part) { - $cookieParts = explode('=', $part, 2); - $key = trim($cookieParts[0]); - $value = isset($cookieParts[1]) - ? trim($cookieParts[1], " \n\r\t\0\x0B") - : true; - - // Only check for non-cookies when cookies have been found - if (empty($data['Name'])) { - $data['Name'] = $key; - $data['Value'] = $value; - } else { - foreach (array_keys(self::$defaults) as $search) { - if (!strcasecmp($search, $key)) { - $data[$search] = $value; - continue 2; - } - } - $data[$key] = $value; - } - } - - return new self($data); - } - - /** - * @param array $data Array of cookie data provided by a Cookie parser - */ - public function __construct(array $data = []) - { - $this->data = array_replace(self::$defaults, $data); - // Extract the Expires value and turn it into a UNIX timestamp if needed - if (!$this->getExpires() && $this->getMaxAge()) { - // Calculate the Expires date - $this->setExpires(time() + $this->getMaxAge()); - } elseif ($this->getExpires() && !is_numeric($this->getExpires())) { - $this->setExpires($this->getExpires()); - } - } - - public function __toString() - { - $str = $this->data['Name'] . '=' . $this->data['Value'] . '; '; - foreach ($this->data as $k => $v) { - if ($k !== 'Name' && $k !== 'Value' && $v !== null && $v !== false) { - if ($k === 'Expires') { - $str .= 'Expires=' . gmdate('D, d M Y H:i:s \G\M\T', $v) . '; '; - } else { - $str .= ($v === true ? $k : "{$k}={$v}") . '; '; - } - } - } - - return rtrim($str, '; '); - } - - public function toArray() - { - return $this->data; - } - - /** - * Get the cookie name - * - * @return string - */ - public function getName() - { - return $this->data['Name']; - } - - /** - * Set the cookie name - * - * @param string $name Cookie name - */ - public function setName($name) - { - $this->data['Name'] = $name; - } - - /** - * Get the cookie value - * - * @return string - */ - public function getValue() - { - return $this->data['Value']; - } - - /** - * Set the cookie value - * - * @param string $value Cookie value - */ - public function setValue($value) - { - $this->data['Value'] = $value; - } - - /** - * Get the domain - * - * @return string|null - */ - public function getDomain() - { - return $this->data['Domain']; - } - - /** - * Set the domain of the cookie - * - * @param string $domain - */ - public function setDomain($domain) - { - $this->data['Domain'] = $domain; - } - - /** - * Get the path - * - * @return string - */ - public function getPath() - { - return $this->data['Path']; - } - - /** - * Set the path of the cookie - * - * @param string $path Path of the cookie - */ - public function setPath($path) - { - $this->data['Path'] = $path; - } - - /** - * Maximum lifetime of the cookie in seconds - * - * @return int|null - */ - public function getMaxAge() - { - return $this->data['Max-Age']; - } - - /** - * Set the max-age of the cookie - * - * @param int $maxAge Max age of the cookie in seconds - */ - public function setMaxAge($maxAge) - { - $this->data['Max-Age'] = $maxAge; - } - - /** - * The UNIX timestamp when the cookie Expires - * - * @return mixed - */ - public function getExpires() - { - return $this->data['Expires']; - } - - /** - * Set the unix timestamp for which the cookie will expire - * - * @param int $timestamp Unix timestamp - */ - public function setExpires($timestamp) - { - $this->data['Expires'] = is_numeric($timestamp) - ? (int) $timestamp - : strtotime($timestamp); - } - - /** - * Get whether or not this is a secure cookie - * - * @return null|bool - */ - public function getSecure() - { - return $this->data['Secure']; - } - - /** - * Set whether or not the cookie is secure - * - * @param bool $secure Set to true or false if secure - */ - public function setSecure($secure) - { - $this->data['Secure'] = $secure; - } - - /** - * Get whether or not this is a session cookie - * - * @return null|bool - */ - public function getDiscard() - { - return $this->data['Discard']; - } - - /** - * Set whether or not this is a session cookie - * - * @param bool $discard Set to true or false if this is a session cookie - */ - public function setDiscard($discard) - { - $this->data['Discard'] = $discard; - } - - /** - * Get whether or not this is an HTTP only cookie - * - * @return bool - */ - public function getHttpOnly() - { - return $this->data['HttpOnly']; - } - - /** - * Set whether or not this is an HTTP only cookie - * - * @param bool $httpOnly Set to true or false if this is HTTP only - */ - public function setHttpOnly($httpOnly) - { - $this->data['HttpOnly'] = $httpOnly; - } - - /** - * Check if the cookie matches a path value. - * - * A request-path path-matches a given cookie-path if at least one of - * the following conditions holds: - * - * - The cookie-path and the request-path are identical. - * - The cookie-path is a prefix of the request-path, and the last - * character of the cookie-path is %x2F ("/"). - * - The cookie-path is a prefix of the request-path, and the first - * character of the request-path that is not included in the cookie- - * path is a %x2F ("/") character. - * - * @param string $requestPath Path to check against - * - * @return bool - */ - public function matchesPath($requestPath) - { - $cookiePath = $this->getPath(); - - // Match on exact matches or when path is the default empty "/" - if ($cookiePath === '/' || $cookiePath == $requestPath) { - return true; - } - - // Ensure that the cookie-path is a prefix of the request path. - if (0 !== strpos($requestPath, $cookiePath)) { - return false; - } - - // Match if the last character of the cookie-path is "/" - if (substr($cookiePath, -1, 1) === '/') { - return true; - } - - // Match if the first character not included in cookie path is "/" - return substr($requestPath, strlen($cookiePath), 1) === '/'; - } - - /** - * Check if the cookie matches a domain value - * - * @param string $domain Domain to check against - * - * @return bool - */ - public function matchesDomain($domain) - { - // Remove the leading '.' as per spec in RFC 6265. - // http://tools.ietf.org/html/rfc6265#section-5.2.3 - $cookieDomain = ltrim($this->getDomain(), '.'); - - // Domain not set or exact match. - if (!$cookieDomain || !strcasecmp($domain, $cookieDomain)) { - return true; - } - - // Matching the subdomain according to RFC 6265. - // http://tools.ietf.org/html/rfc6265#section-5.1.3 - if (filter_var($domain, FILTER_VALIDATE_IP)) { - return false; - } - - return (bool) preg_match('/\.' . preg_quote($cookieDomain, '/') . '$/', $domain); - } - - /** - * Check if the cookie is expired - * - * @return bool - */ - public function isExpired() - { - return $this->getExpires() !== null && time() > $this->getExpires(); - } - - /** - * Check if the cookie is valid according to RFC 6265 - * - * @return bool|string Returns true if valid or an error message if invalid - */ - public function validate() - { - // Names must not be empty, but can be 0 - $name = $this->getName(); - if (empty($name) && !is_numeric($name)) { - return 'The cookie name must not be empty'; - } - - // Check if any of the invalid characters are present in the cookie name - if (preg_match( - '/[\x00-\x20\x22\x28-\x29\x2c\x2f\x3a-\x40\x5c\x7b\x7d\x7f]/', - $name - )) { - return 'Cookie name must not contain invalid characters: ASCII ' - . 'Control characters (0-31;127), space, tab and the ' - . 'following characters: ()<>@,;:\"/?={}'; - } - - // Value must not be empty, but can be 0 - $value = $this->getValue(); - if (empty($value) && !is_numeric($value)) { - return 'The cookie value must not be empty'; - } - - // Domains must not be empty, but can be 0 - // A "0" is not a valid internet domain, but may be used as server name - // in a private network. - $domain = $this->getDomain(); - if (empty($domain) && !is_numeric($domain)) { - return 'The cookie domain must not be empty'; - } - - return true; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php b/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php deleted file mode 100755 index 427d896fb2f2a715d6c797b87ec6159ddf8453bc..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php -namespace GuzzleHttp\Exception; - -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Exception when an HTTP error occurs (4xx or 5xx error) - */ -class BadResponseException extends RequestException -{ - public function __construct( - $message, - RequestInterface $request, - ResponseInterface $response = null, - \Exception $previous = null, - array $handlerContext = [] - ) { - if (null === $response) { - @trigger_error( - 'Instantiating the ' . __CLASS__ . ' class without a Response is deprecated since version 6.3 and will be removed in 7.0.', - E_USER_DEPRECATED - ); - } - parent::__construct($message, $request, $response, $previous, $handlerContext); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php b/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php deleted file mode 100755 index f95c09f2b1a50923056acbf108e1695e2a148bfa..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php +++ /dev/null @@ -1,7 +0,0 @@ -<?php -namespace GuzzleHttp\Exception; - -/** - * Exception when a client error is encountered (4xx codes) - */ -class ClientException extends BadResponseException {} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php b/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php deleted file mode 100755 index d33b0cc19d6f808fd16ad5f24982348b219cb999..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -namespace GuzzleHttp\Exception; - -use Psr\Http\Message\RequestInterface; - -/** - * Exception thrown when a connection cannot be established. - * - * Note that no response is present for a ConnectException - */ -class ConnectException extends RequestException -{ - public function __construct( - $message, - RequestInterface $request, - \Exception $previous = null, - array $handlerContext = [] - ) { - parent::__construct($message, $request, null, $previous, $handlerContext); - } - - /** - * @return null - */ - public function getResponse() - { - return null; - } - - /** - * @return bool - */ - public function hasResponse() - { - return false; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php b/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php deleted file mode 100755 index 510778f6eb2f6800eef95d903d0b5b3ff139b415..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php -namespace GuzzleHttp\Exception; - -/** - * @method string getMessage() - * @method \Throwable|null getPrevious() - * @method mixed getCode() - * @method string getFile() - * @method int getLine() - * @method array getTrace() - * @method string getTraceAsString() - */ -interface GuzzleException {} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php b/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php deleted file mode 100755 index 39de327e7b6ea887f0ebb904faa3340c2c1d5d0f..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php +++ /dev/null @@ -1,217 +0,0 @@ -<?php -namespace GuzzleHttp\Exception; - -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use GuzzleHttp\Promise\PromiseInterface; -use Psr\Http\Message\UriInterface; - -/** - * HTTP Request exception - */ -class RequestException extends TransferException -{ - /** @var RequestInterface */ - private $request; - - /** @var ResponseInterface */ - private $response; - - /** @var array */ - private $handlerContext; - - public function __construct( - $message, - RequestInterface $request, - ResponseInterface $response = null, - \Exception $previous = null, - array $handlerContext = [] - ) { - // Set the code of the exception if the response is set and not future. - $code = $response && !($response instanceof PromiseInterface) - ? $response->getStatusCode() - : 0; - parent::__construct($message, $code, $previous); - $this->request = $request; - $this->response = $response; - $this->handlerContext = $handlerContext; - } - - /** - * Wrap non-RequestExceptions with a RequestException - * - * @param RequestInterface $request - * @param \Exception $e - * - * @return RequestException - */ - public static function wrapException(RequestInterface $request, \Exception $e) - { - return $e instanceof RequestException - ? $e - : new RequestException($e->getMessage(), $request, null, $e); - } - - /** - * Factory method to create a new exception with a normalized error message - * - * @param RequestInterface $request Request - * @param ResponseInterface $response Response received - * @param \Exception $previous Previous exception - * @param array $ctx Optional handler context. - * - * @return self - */ - public static function create( - RequestInterface $request, - ResponseInterface $response = null, - \Exception $previous = null, - array $ctx = [] - ) { - if (!$response) { - return new self( - 'Error completing request', - $request, - null, - $previous, - $ctx - ); - } - - $level = (int) floor($response->getStatusCode() / 100); - if ($level === 4) { - $label = 'Client error'; - $className = ClientException::class; - } elseif ($level === 5) { - $label = 'Server error'; - $className = ServerException::class; - } else { - $label = 'Unsuccessful request'; - $className = __CLASS__; - } - - $uri = $request->getUri(); - $uri = static::obfuscateUri($uri); - - // Client Error: `GET /` resulted in a `404 Not Found` response: - // <html> ... (truncated) - $message = sprintf( - '%s: `%s %s` resulted in a `%s %s` response', - $label, - $request->getMethod(), - $uri, - $response->getStatusCode(), - $response->getReasonPhrase() - ); - - $summary = static::getResponseBodySummary($response); - - if ($summary !== null) { - $message .= ":\n{$summary}\n"; - } - - return new $className($message, $request, $response, $previous, $ctx); - } - - /** - * Get a short summary of the response - * - * Will return `null` if the response is not printable. - * - * @param ResponseInterface $response - * - * @return string|null - */ - public static function getResponseBodySummary(ResponseInterface $response) - { - $body = $response->getBody(); - - if (!$body->isSeekable()) { - return null; - } - - $size = $body->getSize(); - - if ($size === 0) { - return null; - } - - $summary = $body->read(120); - $body->rewind(); - - if ($size > 120) { - $summary .= ' (truncated...)'; - } - - // Matches any printable character, including unicode characters: - // letters, marks, numbers, punctuation, spacing, and separators. - if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/', $summary)) { - return null; - } - - return $summary; - } - - /** - * Obfuscates URI if there is an username and a password present - * - * @param UriInterface $uri - * - * @return UriInterface - */ - private static function obfuscateUri($uri) - { - $userInfo = $uri->getUserInfo(); - - if (false !== ($pos = strpos($userInfo, ':'))) { - return $uri->withUserInfo(substr($userInfo, 0, $pos), '***'); - } - - return $uri; - } - - /** - * Get the request that caused the exception - * - * @return RequestInterface - */ - public function getRequest() - { - return $this->request; - } - - /** - * Get the associated response - * - * @return ResponseInterface|null - */ - public function getResponse() - { - return $this->response; - } - - /** - * Check if a response was received - * - * @return bool - */ - public function hasResponse() - { - return $this->response !== null; - } - - /** - * Get contextual information about the error from the underlying handler. - * - * The contents of this array will vary depending on which handler you are - * using. It may also be just an empty array. Relying on this data will - * couple you to a specific handler, but can give more debug information - * when needed. - * - * @return array - */ - public function getHandlerContext() - { - return $this->handlerContext; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/SeekException.php b/vendor/guzzlehttp/guzzle/src/Exception/SeekException.php deleted file mode 100755 index a77c28926cf94c4232feeda5d3062b87b15dce53..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Exception/SeekException.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php -namespace GuzzleHttp\Exception; - -use Psr\Http\Message\StreamInterface; - -/** - * Exception thrown when a seek fails on a stream. - */ -class SeekException extends \RuntimeException implements GuzzleException -{ - private $stream; - - public function __construct(StreamInterface $stream, $pos = 0, $msg = '') - { - $this->stream = $stream; - $msg = $msg ?: 'Could not seek the stream to position ' . $pos; - parent::__construct($msg); - } - - /** - * @return StreamInterface - */ - public function getStream() - { - return $this->stream; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php b/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php deleted file mode 100755 index 7cdd340866b63b318e78b38981565d3e78eaacdd..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php +++ /dev/null @@ -1,7 +0,0 @@ -<?php -namespace GuzzleHttp\Exception; - -/** - * Exception when a server error is encountered (5xx codes) - */ -class ServerException extends BadResponseException {} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php b/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php deleted file mode 100755 index b60a9678d650676bdecd6fab6740d0f9a39e7849..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php +++ /dev/null @@ -1,4 +0,0 @@ -<?php -namespace GuzzleHttp\Exception; - -class TooManyRedirectsException extends RequestException {} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php b/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php deleted file mode 100755 index b92071ca20630d1a988249a9befc247ab4e3d2de..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php +++ /dev/null @@ -1,4 +0,0 @@ -<?php -namespace GuzzleHttp\Exception; - -class TransferException extends \RuntimeException implements GuzzleException {} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php b/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php deleted file mode 100755 index e0923714306af0cc5c92bfbd838503e872e4fc68..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php +++ /dev/null @@ -1,565 +0,0 @@ -<?php -namespace GuzzleHttp\Handler; - -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Exception\ConnectException; -use GuzzleHttp\Promise\FulfilledPromise; -use GuzzleHttp\Psr7; -use GuzzleHttp\Psr7\LazyOpenStream; -use GuzzleHttp\TransferStats; -use Psr\Http\Message\RequestInterface; - -/** - * Creates curl resources from a request - */ -class CurlFactory implements CurlFactoryInterface -{ - /** @var array */ - private $handles = []; - - /** @var int Total number of idle handles to keep in cache */ - private $maxHandles; - - /** - * @param int $maxHandles Maximum number of idle handles. - */ - public function __construct($maxHandles) - { - $this->maxHandles = $maxHandles; - } - - public function create(RequestInterface $request, array $options) - { - if (isset($options['curl']['body_as_string'])) { - $options['_body_as_string'] = $options['curl']['body_as_string']; - unset($options['curl']['body_as_string']); - } - - $easy = new EasyHandle; - $easy->request = $request; - $easy->options = $options; - $conf = $this->getDefaultConf($easy); - $this->applyMethod($easy, $conf); - $this->applyHandlerOptions($easy, $conf); - $this->applyHeaders($easy, $conf); - unset($conf['_headers']); - - // Add handler options from the request configuration options - if (isset($options['curl'])) { - $conf = array_replace($conf, $options['curl']); - } - - $conf[CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy); - $easy->handle = $this->handles - ? array_pop($this->handles) - : curl_init(); - curl_setopt_array($easy->handle, $conf); - - return $easy; - } - - public function release(EasyHandle $easy) - { - $resource = $easy->handle; - unset($easy->handle); - - if (count($this->handles) >= $this->maxHandles) { - curl_close($resource); - } else { - // Remove all callback functions as they can hold onto references - // and are not cleaned up by curl_reset. Using curl_setopt_array - // does not work for some reason, so removing each one - // individually. - curl_setopt($resource, CURLOPT_HEADERFUNCTION, null); - curl_setopt($resource, CURLOPT_READFUNCTION, null); - curl_setopt($resource, CURLOPT_WRITEFUNCTION, null); - curl_setopt($resource, CURLOPT_PROGRESSFUNCTION, null); - curl_reset($resource); - $this->handles[] = $resource; - } - } - - /** - * Completes a cURL transaction, either returning a response promise or a - * rejected promise. - * - * @param callable $handler - * @param EasyHandle $easy - * @param CurlFactoryInterface $factory Dictates how the handle is released - * - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public static function finish( - callable $handler, - EasyHandle $easy, - CurlFactoryInterface $factory - ) { - if (isset($easy->options['on_stats'])) { - self::invokeStats($easy); - } - - if (!$easy->response || $easy->errno) { - return self::finishError($handler, $easy, $factory); - } - - // Return the response if it is present and there is no error. - $factory->release($easy); - - // Rewind the body of the response if possible. - $body = $easy->response->getBody(); - if ($body->isSeekable()) { - $body->rewind(); - } - - return new FulfilledPromise($easy->response); - } - - private static function invokeStats(EasyHandle $easy) - { - $curlStats = curl_getinfo($easy->handle); - $stats = new TransferStats( - $easy->request, - $easy->response, - $curlStats['total_time'], - $easy->errno, - $curlStats - ); - call_user_func($easy->options['on_stats'], $stats); - } - - private static function finishError( - callable $handler, - EasyHandle $easy, - CurlFactoryInterface $factory - ) { - // Get error information and release the handle to the factory. - $ctx = [ - 'errno' => $easy->errno, - 'error' => curl_error($easy->handle), - ] + curl_getinfo($easy->handle); - $factory->release($easy); - - // Retry when nothing is present or when curl failed to rewind. - if (empty($easy->options['_err_message']) - && (!$easy->errno || $easy->errno == 65) - ) { - return self::retryFailedRewind($handler, $easy, $ctx); - } - - return self::createRejection($easy, $ctx); - } - - private static function createRejection(EasyHandle $easy, array $ctx) - { - static $connectionErrors = [ - CURLE_OPERATION_TIMEOUTED => true, - CURLE_COULDNT_RESOLVE_HOST => true, - CURLE_COULDNT_CONNECT => true, - CURLE_SSL_CONNECT_ERROR => true, - CURLE_GOT_NOTHING => true, - ]; - - // If an exception was encountered during the onHeaders event, then - // return a rejected promise that wraps that exception. - if ($easy->onHeadersException) { - return \GuzzleHttp\Promise\rejection_for( - new RequestException( - 'An error was encountered during the on_headers event', - $easy->request, - $easy->response, - $easy->onHeadersException, - $ctx - ) - ); - } - - $message = sprintf( - 'cURL error %s: %s (%s)', - $ctx['errno'], - $ctx['error'], - 'see http://curl.haxx.se/libcurl/c/libcurl-errors.html' - ); - - // Create a connection exception if it was a specific error code. - $error = isset($connectionErrors[$easy->errno]) - ? new ConnectException($message, $easy->request, null, $ctx) - : new RequestException($message, $easy->request, $easy->response, null, $ctx); - - return \GuzzleHttp\Promise\rejection_for($error); - } - - private function getDefaultConf(EasyHandle $easy) - { - $conf = [ - '_headers' => $easy->request->getHeaders(), - CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(), - CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''), - CURLOPT_RETURNTRANSFER => false, - CURLOPT_HEADER => false, - CURLOPT_CONNECTTIMEOUT => 150, - ]; - - if (defined('CURLOPT_PROTOCOLS')) { - $conf[CURLOPT_PROTOCOLS] = CURLPROTO_HTTP | CURLPROTO_HTTPS; - } - - $version = $easy->request->getProtocolVersion(); - if ($version == 1.1) { - $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1; - } elseif ($version == 2.0) { - $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0; - } else { - $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0; - } - - return $conf; - } - - private function applyMethod(EasyHandle $easy, array &$conf) - { - $body = $easy->request->getBody(); - $size = $body->getSize(); - - if ($size === null || $size > 0) { - $this->applyBody($easy->request, $easy->options, $conf); - return; - } - - $method = $easy->request->getMethod(); - if ($method === 'PUT' || $method === 'POST') { - // See http://tools.ietf.org/html/rfc7230#section-3.3.2 - if (!$easy->request->hasHeader('Content-Length')) { - $conf[CURLOPT_HTTPHEADER][] = 'Content-Length: 0'; - } - } elseif ($method === 'HEAD') { - $conf[CURLOPT_NOBODY] = true; - unset( - $conf[CURLOPT_WRITEFUNCTION], - $conf[CURLOPT_READFUNCTION], - $conf[CURLOPT_FILE], - $conf[CURLOPT_INFILE] - ); - } - } - - private function applyBody(RequestInterface $request, array $options, array &$conf) - { - $size = $request->hasHeader('Content-Length') - ? (int) $request->getHeaderLine('Content-Length') - : null; - - // Send the body as a string if the size is less than 1MB OR if the - // [curl][body_as_string] request value is set. - if (($size !== null && $size < 1000000) || - !empty($options['_body_as_string']) - ) { - $conf[CURLOPT_POSTFIELDS] = (string) $request->getBody(); - // Don't duplicate the Content-Length header - $this->removeHeader('Content-Length', $conf); - $this->removeHeader('Transfer-Encoding', $conf); - } else { - $conf[CURLOPT_UPLOAD] = true; - if ($size !== null) { - $conf[CURLOPT_INFILESIZE] = $size; - $this->removeHeader('Content-Length', $conf); - } - $body = $request->getBody(); - if ($body->isSeekable()) { - $body->rewind(); - } - $conf[CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use ($body) { - return $body->read($length); - }; - } - - // If the Expect header is not present, prevent curl from adding it - if (!$request->hasHeader('Expect')) { - $conf[CURLOPT_HTTPHEADER][] = 'Expect:'; - } - - // cURL sometimes adds a content-type by default. Prevent this. - if (!$request->hasHeader('Content-Type')) { - $conf[CURLOPT_HTTPHEADER][] = 'Content-Type:'; - } - } - - private function applyHeaders(EasyHandle $easy, array &$conf) - { - foreach ($conf['_headers'] as $name => $values) { - foreach ($values as $value) { - $value = (string) $value; - if ($value === '') { - // cURL requires a special format for empty headers. - // See https://github.com/guzzle/guzzle/issues/1882 for more details. - $conf[CURLOPT_HTTPHEADER][] = "$name;"; - } else { - $conf[CURLOPT_HTTPHEADER][] = "$name: $value"; - } - } - } - - // Remove the Accept header if one was not set - if (!$easy->request->hasHeader('Accept')) { - $conf[CURLOPT_HTTPHEADER][] = 'Accept:'; - } - } - - /** - * Remove a header from the options array. - * - * @param string $name Case-insensitive header to remove - * @param array $options Array of options to modify - */ - private function removeHeader($name, array &$options) - { - foreach (array_keys($options['_headers']) as $key) { - if (!strcasecmp($key, $name)) { - unset($options['_headers'][$key]); - return; - } - } - } - - private function applyHandlerOptions(EasyHandle $easy, array &$conf) - { - $options = $easy->options; - if (isset($options['verify'])) { - if ($options['verify'] === false) { - unset($conf[CURLOPT_CAINFO]); - $conf[CURLOPT_SSL_VERIFYHOST] = 0; - $conf[CURLOPT_SSL_VERIFYPEER] = false; - } else { - $conf[CURLOPT_SSL_VERIFYHOST] = 2; - $conf[CURLOPT_SSL_VERIFYPEER] = true; - if (is_string($options['verify'])) { - // Throw an error if the file/folder/link path is not valid or doesn't exist. - if (!file_exists($options['verify'])) { - throw new \InvalidArgumentException( - "SSL CA bundle not found: {$options['verify']}" - ); - } - // If it's a directory or a link to a directory use CURLOPT_CAPATH. - // If not, it's probably a file, or a link to a file, so use CURLOPT_CAINFO. - if (is_dir($options['verify']) || - (is_link($options['verify']) && is_dir(readlink($options['verify'])))) { - $conf[CURLOPT_CAPATH] = $options['verify']; - } else { - $conf[CURLOPT_CAINFO] = $options['verify']; - } - } - } - } - - if (!empty($options['decode_content'])) { - $accept = $easy->request->getHeaderLine('Accept-Encoding'); - if ($accept) { - $conf[CURLOPT_ENCODING] = $accept; - } else { - $conf[CURLOPT_ENCODING] = ''; - // Don't let curl send the header over the wire - $conf[CURLOPT_HTTPHEADER][] = 'Accept-Encoding:'; - } - } - - if (isset($options['sink'])) { - $sink = $options['sink']; - if (!is_string($sink)) { - $sink = \GuzzleHttp\Psr7\stream_for($sink); - } elseif (!is_dir(dirname($sink))) { - // Ensure that the directory exists before failing in curl. - throw new \RuntimeException(sprintf( - 'Directory %s does not exist for sink value of %s', - dirname($sink), - $sink - )); - } else { - $sink = new LazyOpenStream($sink, 'w+'); - } - $easy->sink = $sink; - $conf[CURLOPT_WRITEFUNCTION] = function ($ch, $write) use ($sink) { - return $sink->write($write); - }; - } else { - // Use a default temp stream if no sink was set. - $conf[CURLOPT_FILE] = fopen('php://temp', 'w+'); - $easy->sink = Psr7\stream_for($conf[CURLOPT_FILE]); - } - $timeoutRequiresNoSignal = false; - if (isset($options['timeout'])) { - $timeoutRequiresNoSignal |= $options['timeout'] < 1; - $conf[CURLOPT_TIMEOUT_MS] = $options['timeout'] * 1000; - } - - // CURL default value is CURL_IPRESOLVE_WHATEVER - if (isset($options['force_ip_resolve'])) { - if ('v4' === $options['force_ip_resolve']) { - $conf[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4; - } elseif ('v6' === $options['force_ip_resolve']) { - $conf[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V6; - } - } - - if (isset($options['connect_timeout'])) { - $timeoutRequiresNoSignal |= $options['connect_timeout'] < 1; - $conf[CURLOPT_CONNECTTIMEOUT_MS] = $options['connect_timeout'] * 1000; - } - - if ($timeoutRequiresNoSignal && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { - $conf[CURLOPT_NOSIGNAL] = true; - } - - if (isset($options['proxy'])) { - if (!is_array($options['proxy'])) { - $conf[CURLOPT_PROXY] = $options['proxy']; - } else { - $scheme = $easy->request->getUri()->getScheme(); - if (isset($options['proxy'][$scheme])) { - $host = $easy->request->getUri()->getHost(); - if (!isset($options['proxy']['no']) || - !\GuzzleHttp\is_host_in_noproxy($host, $options['proxy']['no']) - ) { - $conf[CURLOPT_PROXY] = $options['proxy'][$scheme]; - } - } - } - } - - if (isset($options['cert'])) { - $cert = $options['cert']; - if (is_array($cert)) { - $conf[CURLOPT_SSLCERTPASSWD] = $cert[1]; - $cert = $cert[0]; - } - if (!file_exists($cert)) { - throw new \InvalidArgumentException( - "SSL certificate not found: {$cert}" - ); - } - $conf[CURLOPT_SSLCERT] = $cert; - } - - if (isset($options['ssl_key'])) { - $sslKey = $options['ssl_key']; - if (is_array($sslKey)) { - $conf[CURLOPT_SSLKEYPASSWD] = $sslKey[1]; - $sslKey = $sslKey[0]; - } - if (!file_exists($sslKey)) { - throw new \InvalidArgumentException( - "SSL private key not found: {$sslKey}" - ); - } - $conf[CURLOPT_SSLKEY] = $sslKey; - } - - if (isset($options['progress'])) { - $progress = $options['progress']; - if (!is_callable($progress)) { - throw new \InvalidArgumentException( - 'progress client option must be callable' - ); - } - $conf[CURLOPT_NOPROGRESS] = false; - $conf[CURLOPT_PROGRESSFUNCTION] = function () use ($progress) { - $args = func_get_args(); - // PHP 5.5 pushed the handle onto the start of the args - if (is_resource($args[0])) { - array_shift($args); - } - call_user_func_array($progress, $args); - }; - } - - if (!empty($options['debug'])) { - $conf[CURLOPT_STDERR] = \GuzzleHttp\debug_resource($options['debug']); - $conf[CURLOPT_VERBOSE] = true; - } - } - - /** - * This function ensures that a response was set on a transaction. If one - * was not set, then the request is retried if possible. This error - * typically means you are sending a payload, curl encountered a - * "Connection died, retrying a fresh connect" error, tried to rewind the - * stream, and then encountered a "necessary data rewind wasn't possible" - * error, causing the request to be sent through curl_multi_info_read() - * without an error status. - */ - private static function retryFailedRewind( - callable $handler, - EasyHandle $easy, - array $ctx - ) { - try { - // Only rewind if the body has been read from. - $body = $easy->request->getBody(); - if ($body->tell() > 0) { - $body->rewind(); - } - } catch (\RuntimeException $e) { - $ctx['error'] = 'The connection unexpectedly failed without ' - . 'providing an error. The request would have been retried, ' - . 'but attempting to rewind the request body failed. ' - . 'Exception: ' . $e; - return self::createRejection($easy, $ctx); - } - - // Retry no more than 3 times before giving up. - if (!isset($easy->options['_curl_retries'])) { - $easy->options['_curl_retries'] = 1; - } elseif ($easy->options['_curl_retries'] == 2) { - $ctx['error'] = 'The cURL request was retried 3 times ' - . 'and did not succeed. The most likely reason for the failure ' - . 'is that cURL was unable to rewind the body of the request ' - . 'and subsequent retries resulted in the same error. Turn on ' - . 'the debug option to see what went wrong. See ' - . 'https://bugs.php.net/bug.php?id=47204 for more information.'; - return self::createRejection($easy, $ctx); - } else { - $easy->options['_curl_retries']++; - } - - return $handler($easy->request, $easy->options); - } - - private function createHeaderFn(EasyHandle $easy) - { - if (isset($easy->options['on_headers'])) { - $onHeaders = $easy->options['on_headers']; - - if (!is_callable($onHeaders)) { - throw new \InvalidArgumentException('on_headers must be callable'); - } - } else { - $onHeaders = null; - } - - return function ($ch, $h) use ( - $onHeaders, - $easy, - &$startingResponse - ) { - $value = trim($h); - if ($value === '') { - $startingResponse = true; - $easy->createResponse(); - if ($onHeaders !== null) { - try { - $onHeaders($easy->response); - } catch (\Exception $e) { - // Associate the exception with the handle and trigger - // a curl header write error by returning 0. - $easy->onHeadersException = $e; - return -1; - } - } - } elseif ($startingResponse) { - $startingResponse = false; - $easy->headers = [$value]; - } else { - $easy->headers[] = $value; - } - return strlen($h); - }; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php b/vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php deleted file mode 100755 index b0fc236850b5db204532665f3db1f39ae907c4fa..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php -namespace GuzzleHttp\Handler; - -use Psr\Http\Message\RequestInterface; - -interface CurlFactoryInterface -{ - /** - * Creates a cURL handle resource. - * - * @param RequestInterface $request Request - * @param array $options Transfer options - * - * @return EasyHandle - * @throws \RuntimeException when an option cannot be applied - */ - public function create(RequestInterface $request, array $options); - - /** - * Release an easy handle, allowing it to be reused or closed. - * - * This function must call unset on the easy handle's "handle" property. - * - * @param EasyHandle $easy - */ - public function release(EasyHandle $easy); -} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php b/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php deleted file mode 100755 index 43577da66e25de9e8ab4f9f4fb74ebe20b4afd4a..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php -namespace GuzzleHttp\Handler; - -use GuzzleHttp\Psr7; -use Psr\Http\Message\RequestInterface; - -/** - * HTTP handler that uses cURL easy handles as a transport layer. - * - * When using the CurlHandler, custom curl options can be specified as an - * associative array of curl option constants mapping to values in the - * **curl** key of the "client" key of the request. - */ -class CurlHandler -{ - /** @var CurlFactoryInterface */ - private $factory; - - /** - * Accepts an associative array of options: - * - * - factory: Optional curl factory used to create cURL handles. - * - * @param array $options Array of options to use with the handler - */ - public function __construct(array $options = []) - { - $this->factory = isset($options['handle_factory']) - ? $options['handle_factory'] - : new CurlFactory(3); - } - - public function __invoke(RequestInterface $request, array $options) - { - if (isset($options['delay'])) { - usleep($options['delay'] * 1000); - } - - $easy = $this->factory->create($request, $options); - curl_exec($easy->handle); - $easy->errno = curl_errno($easy->handle); - - return CurlFactory::finish($this, $easy, $this->factory); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php b/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php deleted file mode 100755 index 2754d8e4378d92530e1a3767c92cc3b673660161..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php +++ /dev/null @@ -1,199 +0,0 @@ -<?php -namespace GuzzleHttp\Handler; - -use GuzzleHttp\Promise as P; -use GuzzleHttp\Promise\Promise; -use GuzzleHttp\Psr7; -use Psr\Http\Message\RequestInterface; - -/** - * Returns an asynchronous response using curl_multi_* functions. - * - * When using the CurlMultiHandler, custom curl options can be specified as an - * associative array of curl option constants mapping to values in the - * **curl** key of the provided request options. - * - * @property resource $_mh Internal use only. Lazy loaded multi-handle. - */ -class CurlMultiHandler -{ - /** @var CurlFactoryInterface */ - private $factory; - private $selectTimeout; - private $active; - private $handles = []; - private $delays = []; - - /** - * This handler accepts the following options: - * - * - handle_factory: An optional factory used to create curl handles - * - select_timeout: Optional timeout (in seconds) to block before timing - * out while selecting curl handles. Defaults to 1 second. - * - * @param array $options - */ - public function __construct(array $options = []) - { - $this->factory = isset($options['handle_factory']) - ? $options['handle_factory'] : new CurlFactory(50); - $this->selectTimeout = isset($options['select_timeout']) - ? $options['select_timeout'] : 1; - } - - public function __get($name) - { - if ($name === '_mh') { - return $this->_mh = curl_multi_init(); - } - - throw new \BadMethodCallException(); - } - - public function __destruct() - { - if (isset($this->_mh)) { - curl_multi_close($this->_mh); - unset($this->_mh); - } - } - - public function __invoke(RequestInterface $request, array $options) - { - $easy = $this->factory->create($request, $options); - $id = (int) $easy->handle; - - $promise = new Promise( - [$this, 'execute'], - function () use ($id) { - return $this->cancel($id); - } - ); - - $this->addRequest(['easy' => $easy, 'deferred' => $promise]); - - return $promise; - } - - /** - * Ticks the curl event loop. - */ - public function tick() - { - // Add any delayed handles if needed. - if ($this->delays) { - $currentTime = microtime(true); - foreach ($this->delays as $id => $delay) { - if ($currentTime >= $delay) { - unset($this->delays[$id]); - curl_multi_add_handle( - $this->_mh, - $this->handles[$id]['easy']->handle - ); - } - } - } - - // Step through the task queue which may add additional requests. - P\queue()->run(); - - if ($this->active && - curl_multi_select($this->_mh, $this->selectTimeout) === -1 - ) { - // Perform a usleep if a select returns -1. - // See: https://bugs.php.net/bug.php?id=61141 - usleep(250); - } - - while (curl_multi_exec($this->_mh, $this->active) === CURLM_CALL_MULTI_PERFORM); - - $this->processMessages(); - } - - /** - * Runs until all outstanding connections have completed. - */ - public function execute() - { - $queue = P\queue(); - - while ($this->handles || !$queue->isEmpty()) { - // If there are no transfers, then sleep for the next delay - if (!$this->active && $this->delays) { - usleep($this->timeToNext()); - } - $this->tick(); - } - } - - private function addRequest(array $entry) - { - $easy = $entry['easy']; - $id = (int) $easy->handle; - $this->handles[$id] = $entry; - if (empty($easy->options['delay'])) { - curl_multi_add_handle($this->_mh, $easy->handle); - } else { - $this->delays[$id] = microtime(true) + ($easy->options['delay'] / 1000); - } - } - - /** - * Cancels a handle from sending and removes references to it. - * - * @param int $id Handle ID to cancel and remove. - * - * @return bool True on success, false on failure. - */ - private function cancel($id) - { - // Cannot cancel if it has been processed. - if (!isset($this->handles[$id])) { - return false; - } - - $handle = $this->handles[$id]['easy']->handle; - unset($this->delays[$id], $this->handles[$id]); - curl_multi_remove_handle($this->_mh, $handle); - curl_close($handle); - - return true; - } - - private function processMessages() - { - while ($done = curl_multi_info_read($this->_mh)) { - $id = (int) $done['handle']; - curl_multi_remove_handle($this->_mh, $done['handle']); - - if (!isset($this->handles[$id])) { - // Probably was cancelled. - continue; - } - - $entry = $this->handles[$id]; - unset($this->handles[$id], $this->delays[$id]); - $entry['easy']->errno = $done['result']; - $entry['deferred']->resolve( - CurlFactory::finish( - $this, - $entry['easy'], - $this->factory - ) - ); - } - } - - private function timeToNext() - { - $currentTime = microtime(true); - $nextTime = PHP_INT_MAX; - foreach ($this->delays as $time) { - if ($time < $nextTime) { - $nextTime = $time; - } - } - - return max(0, $nextTime - $currentTime) * 1000000; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php b/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php deleted file mode 100755 index 7754e9111b7a18add1a188aa9efff05e2eebe550..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php +++ /dev/null @@ -1,92 +0,0 @@ -<?php -namespace GuzzleHttp\Handler; - -use GuzzleHttp\Psr7\Response; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\StreamInterface; - -/** - * Represents a cURL easy handle and the data it populates. - * - * @internal - */ -final class EasyHandle -{ - /** @var resource cURL resource */ - public $handle; - - /** @var StreamInterface Where data is being written */ - public $sink; - - /** @var array Received HTTP headers so far */ - public $headers = []; - - /** @var ResponseInterface Received response (if any) */ - public $response; - - /** @var RequestInterface Request being sent */ - public $request; - - /** @var array Request options */ - public $options = []; - - /** @var int cURL error number (if any) */ - public $errno = 0; - - /** @var \Exception Exception during on_headers (if any) */ - public $onHeadersException; - - /** - * Attach a response to the easy handle based on the received headers. - * - * @throws \RuntimeException if no headers have been received. - */ - public function createResponse() - { - if (empty($this->headers)) { - throw new \RuntimeException('No headers have been received'); - } - - // HTTP-version SP status-code SP reason-phrase - $startLine = explode(' ', array_shift($this->headers), 3); - $headers = \GuzzleHttp\headers_from_lines($this->headers); - $normalizedKeys = \GuzzleHttp\normalize_header_keys($headers); - - if (!empty($this->options['decode_content']) - && isset($normalizedKeys['content-encoding']) - ) { - $headers['x-encoded-content-encoding'] - = $headers[$normalizedKeys['content-encoding']]; - unset($headers[$normalizedKeys['content-encoding']]); - if (isset($normalizedKeys['content-length'])) { - $headers['x-encoded-content-length'] - = $headers[$normalizedKeys['content-length']]; - - $bodyLength = (int) $this->sink->getSize(); - if ($bodyLength) { - $headers[$normalizedKeys['content-length']] = $bodyLength; - } else { - unset($headers[$normalizedKeys['content-length']]); - } - } - } - - // Attach a response to the easy handle with the parsed headers. - $this->response = new Response( - $startLine[1], - $headers, - $this->sink, - substr($startLine[0], 5), - isset($startLine[2]) ? (string) $startLine[2] : null - ); - } - - public function __get($name) - { - $msg = $name === 'handle' - ? 'The EasyHandle has been released' - : 'Invalid property: ' . $name; - throw new \BadMethodCallException($msg); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php b/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php deleted file mode 100755 index d892061c7a0074063d33c20fea167c898dc2beb2..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php +++ /dev/null @@ -1,189 +0,0 @@ -<?php -namespace GuzzleHttp\Handler; - -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\HandlerStack; -use GuzzleHttp\Promise\PromiseInterface; -use GuzzleHttp\Promise\RejectedPromise; -use GuzzleHttp\TransferStats; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Handler that returns responses or throw exceptions from a queue. - */ -class MockHandler implements \Countable -{ - private $queue = []; - private $lastRequest; - private $lastOptions; - private $onFulfilled; - private $onRejected; - - /** - * Creates a new MockHandler that uses the default handler stack list of - * middlewares. - * - * @param array $queue Array of responses, callables, or exceptions. - * @param callable $onFulfilled Callback to invoke when the return value is fulfilled. - * @param callable $onRejected Callback to invoke when the return value is rejected. - * - * @return HandlerStack - */ - public static function createWithMiddleware( - array $queue = null, - callable $onFulfilled = null, - callable $onRejected = null - ) { - return HandlerStack::create(new self($queue, $onFulfilled, $onRejected)); - } - - /** - * The passed in value must be an array of - * {@see Psr7\Http\Message\ResponseInterface} objects, Exceptions, - * callables, or Promises. - * - * @param array $queue - * @param callable $onFulfilled Callback to invoke when the return value is fulfilled. - * @param callable $onRejected Callback to invoke when the return value is rejected. - */ - public function __construct( - array $queue = null, - callable $onFulfilled = null, - callable $onRejected = null - ) { - $this->onFulfilled = $onFulfilled; - $this->onRejected = $onRejected; - - if ($queue) { - call_user_func_array([$this, 'append'], $queue); - } - } - - public function __invoke(RequestInterface $request, array $options) - { - if (!$this->queue) { - throw new \OutOfBoundsException('Mock queue is empty'); - } - - if (isset($options['delay'])) { - usleep($options['delay'] * 1000); - } - - $this->lastRequest = $request; - $this->lastOptions = $options; - $response = array_shift($this->queue); - - if (isset($options['on_headers'])) { - if (!is_callable($options['on_headers'])) { - throw new \InvalidArgumentException('on_headers must be callable'); - } - try { - $options['on_headers']($response); - } catch (\Exception $e) { - $msg = 'An error was encountered during the on_headers event'; - $response = new RequestException($msg, $request, $response, $e); - } - } - - if (is_callable($response)) { - $response = call_user_func($response, $request, $options); - } - - $response = $response instanceof \Exception - ? \GuzzleHttp\Promise\rejection_for($response) - : \GuzzleHttp\Promise\promise_for($response); - - return $response->then( - function ($value) use ($request, $options) { - $this->invokeStats($request, $options, $value); - if ($this->onFulfilled) { - call_user_func($this->onFulfilled, $value); - } - if (isset($options['sink'])) { - $contents = (string) $value->getBody(); - $sink = $options['sink']; - - if (is_resource($sink)) { - fwrite($sink, $contents); - } elseif (is_string($sink)) { - file_put_contents($sink, $contents); - } elseif ($sink instanceof \Psr\Http\Message\StreamInterface) { - $sink->write($contents); - } - } - - return $value; - }, - function ($reason) use ($request, $options) { - $this->invokeStats($request, $options, null, $reason); - if ($this->onRejected) { - call_user_func($this->onRejected, $reason); - } - return \GuzzleHttp\Promise\rejection_for($reason); - } - ); - } - - /** - * Adds one or more variadic requests, exceptions, callables, or promises - * to the queue. - */ - public function append() - { - foreach (func_get_args() as $value) { - if ($value instanceof ResponseInterface - || $value instanceof \Exception - || $value instanceof PromiseInterface - || is_callable($value) - ) { - $this->queue[] = $value; - } else { - throw new \InvalidArgumentException('Expected a response or ' - . 'exception. Found ' . \GuzzleHttp\describe_type($value)); - } - } - } - - /** - * Get the last received request. - * - * @return RequestInterface - */ - public function getLastRequest() - { - return $this->lastRequest; - } - - /** - * Get the last received request options. - * - * @return array - */ - public function getLastOptions() - { - return $this->lastOptions; - } - - /** - * Returns the number of remaining items in the queue. - * - * @return int - */ - public function count() - { - return count($this->queue); - } - - private function invokeStats( - RequestInterface $request, - array $options, - ResponseInterface $response = null, - $reason = null - ) { - if (isset($options['on_stats'])) { - $stats = new TransferStats($request, $response, 0, $reason); - call_user_func($options['on_stats'], $stats); - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php b/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php deleted file mode 100755 index f8b00be0b99ed4b5de18098ca153fa1b44d41685..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php -namespace GuzzleHttp\Handler; - -use GuzzleHttp\RequestOptions; -use Psr\Http\Message\RequestInterface; - -/** - * Provides basic proxies for handlers. - */ -class Proxy -{ - /** - * Sends synchronous requests to a specific handler while sending all other - * requests to another handler. - * - * @param callable $default Handler used for normal responses - * @param callable $sync Handler used for synchronous responses. - * - * @return callable Returns the composed handler. - */ - public static function wrapSync( - callable $default, - callable $sync - ) { - return function (RequestInterface $request, array $options) use ($default, $sync) { - return empty($options[RequestOptions::SYNCHRONOUS]) - ? $default($request, $options) - : $sync($request, $options); - }; - } - - /** - * Sends streaming requests to a streaming compatible handler while sending - * all other requests to a default handler. - * - * This, for example, could be useful for taking advantage of the - * performance benefits of curl while still supporting true streaming - * through the StreamHandler. - * - * @param callable $default Handler used for non-streaming responses - * @param callable $streaming Handler used for streaming responses - * - * @return callable Returns the composed handler. - */ - public static function wrapStreaming( - callable $default, - callable $streaming - ) { - return function (RequestInterface $request, array $options) use ($default, $streaming) { - return empty($options['stream']) - ? $default($request, $options) - : $streaming($request, $options); - }; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php b/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php deleted file mode 100755 index b686545ea7f1d44d0de79ee0343524fc2b68128f..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php +++ /dev/null @@ -1,532 +0,0 @@ -<?php -namespace GuzzleHttp\Handler; - -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Exception\ConnectException; -use GuzzleHttp\Promise\FulfilledPromise; -use GuzzleHttp\Promise\PromiseInterface; -use GuzzleHttp\Psr7; -use GuzzleHttp\TransferStats; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\StreamInterface; - -/** - * HTTP handler that uses PHP's HTTP stream wrapper. - */ -class StreamHandler -{ - private $lastHeaders = []; - - /** - * Sends an HTTP request. - * - * @param RequestInterface $request Request to send. - * @param array $options Request transfer options. - * - * @return PromiseInterface - */ - public function __invoke(RequestInterface $request, array $options) - { - // Sleep if there is a delay specified. - if (isset($options['delay'])) { - usleep($options['delay'] * 1000); - } - - $startTime = isset($options['on_stats']) ? microtime(true) : null; - - try { - // Does not support the expect header. - $request = $request->withoutHeader('Expect'); - - // Append a content-length header if body size is zero to match - // cURL's behavior. - if (0 === $request->getBody()->getSize()) { - $request = $request->withHeader('Content-Length', 0); - } - - return $this->createResponse( - $request, - $options, - $this->createStream($request, $options), - $startTime - ); - } catch (\InvalidArgumentException $e) { - throw $e; - } catch (\Exception $e) { - // Determine if the error was a networking error. - $message = $e->getMessage(); - // This list can probably get more comprehensive. - if (strpos($message, 'getaddrinfo') // DNS lookup failed - || strpos($message, 'Connection refused') - || strpos($message, "couldn't connect to host") // error on HHVM - || strpos($message, "connection attempt failed") - ) { - $e = new ConnectException($e->getMessage(), $request, $e); - } - $e = RequestException::wrapException($request, $e); - $this->invokeStats($options, $request, $startTime, null, $e); - - return \GuzzleHttp\Promise\rejection_for($e); - } - } - - private function invokeStats( - array $options, - RequestInterface $request, - $startTime, - ResponseInterface $response = null, - $error = null - ) { - if (isset($options['on_stats'])) { - $stats = new TransferStats( - $request, - $response, - microtime(true) - $startTime, - $error, - [] - ); - call_user_func($options['on_stats'], $stats); - } - } - - private function createResponse( - RequestInterface $request, - array $options, - $stream, - $startTime - ) { - $hdrs = $this->lastHeaders; - $this->lastHeaders = []; - $parts = explode(' ', array_shift($hdrs), 3); - $ver = explode('/', $parts[0])[1]; - $status = $parts[1]; - $reason = isset($parts[2]) ? $parts[2] : null; - $headers = \GuzzleHttp\headers_from_lines($hdrs); - list($stream, $headers) = $this->checkDecode($options, $headers, $stream); - $stream = Psr7\stream_for($stream); - $sink = $stream; - - if (strcasecmp('HEAD', $request->getMethod())) { - $sink = $this->createSink($stream, $options); - } - - $response = new Psr7\Response($status, $headers, $sink, $ver, $reason); - - if (isset($options['on_headers'])) { - try { - $options['on_headers']($response); - } catch (\Exception $e) { - $msg = 'An error was encountered during the on_headers event'; - $ex = new RequestException($msg, $request, $response, $e); - return \GuzzleHttp\Promise\rejection_for($ex); - } - } - - // Do not drain when the request is a HEAD request because they have - // no body. - if ($sink !== $stream) { - $this->drain( - $stream, - $sink, - $response->getHeaderLine('Content-Length') - ); - } - - $this->invokeStats($options, $request, $startTime, $response, null); - - return new FulfilledPromise($response); - } - - private function createSink(StreamInterface $stream, array $options) - { - if (!empty($options['stream'])) { - return $stream; - } - - $sink = isset($options['sink']) - ? $options['sink'] - : fopen('php://temp', 'r+'); - - return is_string($sink) - ? new Psr7\LazyOpenStream($sink, 'w+') - : Psr7\stream_for($sink); - } - - private function checkDecode(array $options, array $headers, $stream) - { - // Automatically decode responses when instructed. - if (!empty($options['decode_content'])) { - $normalizedKeys = \GuzzleHttp\normalize_header_keys($headers); - if (isset($normalizedKeys['content-encoding'])) { - $encoding = $headers[$normalizedKeys['content-encoding']]; - if ($encoding[0] === 'gzip' || $encoding[0] === 'deflate') { - $stream = new Psr7\InflateStream( - Psr7\stream_for($stream) - ); - $headers['x-encoded-content-encoding'] - = $headers[$normalizedKeys['content-encoding']]; - // Remove content-encoding header - unset($headers[$normalizedKeys['content-encoding']]); - // Fix content-length header - if (isset($normalizedKeys['content-length'])) { - $headers['x-encoded-content-length'] - = $headers[$normalizedKeys['content-length']]; - - $length = (int) $stream->getSize(); - if ($length === 0) { - unset($headers[$normalizedKeys['content-length']]); - } else { - $headers[$normalizedKeys['content-length']] = [$length]; - } - } - } - } - } - - return [$stream, $headers]; - } - - /** - * Drains the source stream into the "sink" client option. - * - * @param StreamInterface $source - * @param StreamInterface $sink - * @param string $contentLength Header specifying the amount of - * data to read. - * - * @return StreamInterface - * @throws \RuntimeException when the sink option is invalid. - */ - private function drain( - StreamInterface $source, - StreamInterface $sink, - $contentLength - ) { - // If a content-length header is provided, then stop reading once - // that number of bytes has been read. This can prevent infinitely - // reading from a stream when dealing with servers that do not honor - // Connection: Close headers. - Psr7\copy_to_stream( - $source, - $sink, - (strlen($contentLength) > 0 && (int) $contentLength > 0) ? (int) $contentLength : -1 - ); - - $sink->seek(0); - $source->close(); - - return $sink; - } - - /** - * Create a resource and check to ensure it was created successfully - * - * @param callable $callback Callable that returns stream resource - * - * @return resource - * @throws \RuntimeException on error - */ - private function createResource(callable $callback) - { - $errors = null; - set_error_handler(function ($_, $msg, $file, $line) use (&$errors) { - $errors[] = [ - 'message' => $msg, - 'file' => $file, - 'line' => $line - ]; - return true; - }); - - $resource = $callback(); - restore_error_handler(); - - if (!$resource) { - $message = 'Error creating resource: '; - foreach ($errors as $err) { - foreach ($err as $key => $value) { - $message .= "[$key] $value" . PHP_EOL; - } - } - throw new \RuntimeException(trim($message)); - } - - return $resource; - } - - private function createStream(RequestInterface $request, array $options) - { - static $methods; - if (!$methods) { - $methods = array_flip(get_class_methods(__CLASS__)); - } - - // HTTP/1.1 streams using the PHP stream wrapper require a - // Connection: close header - if ($request->getProtocolVersion() == '1.1' - && !$request->hasHeader('Connection') - ) { - $request = $request->withHeader('Connection', 'close'); - } - - // Ensure SSL is verified by default - if (!isset($options['verify'])) { - $options['verify'] = true; - } - - $params = []; - $context = $this->getDefaultContext($request); - - if (isset($options['on_headers']) && !is_callable($options['on_headers'])) { - throw new \InvalidArgumentException('on_headers must be callable'); - } - - if (!empty($options)) { - foreach ($options as $key => $value) { - $method = "add_{$key}"; - if (isset($methods[$method])) { - $this->{$method}($request, $context, $value, $params); - } - } - } - - if (isset($options['stream_context'])) { - if (!is_array($options['stream_context'])) { - throw new \InvalidArgumentException('stream_context must be an array'); - } - $context = array_replace_recursive( - $context, - $options['stream_context'] - ); - } - - // Microsoft NTLM authentication only supported with curl handler - if (isset($options['auth']) - && is_array($options['auth']) - && isset($options['auth'][2]) - && 'ntlm' == $options['auth'][2] - ) { - throw new \InvalidArgumentException('Microsoft NTLM authentication only supported with curl handler'); - } - - $uri = $this->resolveHost($request, $options); - - $context = $this->createResource( - function () use ($context, $params) { - return stream_context_create($context, $params); - } - ); - - return $this->createResource( - function () use ($uri, &$http_response_header, $context, $options) { - $resource = fopen((string) $uri, 'r', null, $context); - $this->lastHeaders = $http_response_header; - - if (isset($options['read_timeout'])) { - $readTimeout = $options['read_timeout']; - $sec = (int) $readTimeout; - $usec = ($readTimeout - $sec) * 100000; - stream_set_timeout($resource, $sec, $usec); - } - - return $resource; - } - ); - } - - private function resolveHost(RequestInterface $request, array $options) - { - $uri = $request->getUri(); - - if (isset($options['force_ip_resolve']) && !filter_var($uri->getHost(), FILTER_VALIDATE_IP)) { - if ('v4' === $options['force_ip_resolve']) { - $records = dns_get_record($uri->getHost(), DNS_A); - if (!isset($records[0]['ip'])) { - throw new ConnectException(sprintf("Could not resolve IPv4 address for host '%s'", $uri->getHost()), $request); - } - $uri = $uri->withHost($records[0]['ip']); - } elseif ('v6' === $options['force_ip_resolve']) { - $records = dns_get_record($uri->getHost(), DNS_AAAA); - if (!isset($records[0]['ipv6'])) { - throw new ConnectException(sprintf("Could not resolve IPv6 address for host '%s'", $uri->getHost()), $request); - } - $uri = $uri->withHost('[' . $records[0]['ipv6'] . ']'); - } - } - - return $uri; - } - - private function getDefaultContext(RequestInterface $request) - { - $headers = ''; - foreach ($request->getHeaders() as $name => $value) { - foreach ($value as $val) { - $headers .= "$name: $val\r\n"; - } - } - - $context = [ - 'http' => [ - 'method' => $request->getMethod(), - 'header' => $headers, - 'protocol_version' => $request->getProtocolVersion(), - 'ignore_errors' => true, - 'follow_location' => 0, - ], - ]; - - $body = (string) $request->getBody(); - - if (!empty($body)) { - $context['http']['content'] = $body; - // Prevent the HTTP handler from adding a Content-Type header. - if (!$request->hasHeader('Content-Type')) { - $context['http']['header'] .= "Content-Type:\r\n"; - } - } - - $context['http']['header'] = rtrim($context['http']['header']); - - return $context; - } - - private function add_proxy(RequestInterface $request, &$options, $value, &$params) - { - if (!is_array($value)) { - $options['http']['proxy'] = $value; - } else { - $scheme = $request->getUri()->getScheme(); - if (isset($value[$scheme])) { - if (!isset($value['no']) - || !\GuzzleHttp\is_host_in_noproxy( - $request->getUri()->getHost(), - $value['no'] - ) - ) { - $options['http']['proxy'] = $value[$scheme]; - } - } - } - } - - private function add_timeout(RequestInterface $request, &$options, $value, &$params) - { - if ($value > 0) { - $options['http']['timeout'] = $value; - } - } - - private function add_verify(RequestInterface $request, &$options, $value, &$params) - { - if ($value === true) { - // PHP 5.6 or greater will find the system cert by default. When - // < 5.6, use the Guzzle bundled cacert. - if (PHP_VERSION_ID < 50600) { - $options['ssl']['cafile'] = \GuzzleHttp\default_ca_bundle(); - } - } elseif (is_string($value)) { - $options['ssl']['cafile'] = $value; - if (!file_exists($value)) { - throw new \RuntimeException("SSL CA bundle not found: $value"); - } - } elseif ($value === false) { - $options['ssl']['verify_peer'] = false; - $options['ssl']['verify_peer_name'] = false; - return; - } else { - throw new \InvalidArgumentException('Invalid verify request option'); - } - - $options['ssl']['verify_peer'] = true; - $options['ssl']['verify_peer_name'] = true; - $options['ssl']['allow_self_signed'] = false; - } - - private function add_cert(RequestInterface $request, &$options, $value, &$params) - { - if (is_array($value)) { - $options['ssl']['passphrase'] = $value[1]; - $value = $value[0]; - } - - if (!file_exists($value)) { - throw new \RuntimeException("SSL certificate not found: {$value}"); - } - - $options['ssl']['local_cert'] = $value; - } - - private function add_progress(RequestInterface $request, &$options, $value, &$params) - { - $this->addNotification( - $params, - function ($code, $a, $b, $c, $transferred, $total) use ($value) { - if ($code == STREAM_NOTIFY_PROGRESS) { - $value($total, $transferred, null, null); - } - } - ); - } - - private function add_debug(RequestInterface $request, &$options, $value, &$params) - { - if ($value === false) { - return; - } - - static $map = [ - STREAM_NOTIFY_CONNECT => 'CONNECT', - STREAM_NOTIFY_AUTH_REQUIRED => 'AUTH_REQUIRED', - STREAM_NOTIFY_AUTH_RESULT => 'AUTH_RESULT', - STREAM_NOTIFY_MIME_TYPE_IS => 'MIME_TYPE_IS', - STREAM_NOTIFY_FILE_SIZE_IS => 'FILE_SIZE_IS', - STREAM_NOTIFY_REDIRECTED => 'REDIRECTED', - STREAM_NOTIFY_PROGRESS => 'PROGRESS', - STREAM_NOTIFY_FAILURE => 'FAILURE', - STREAM_NOTIFY_COMPLETED => 'COMPLETED', - STREAM_NOTIFY_RESOLVE => 'RESOLVE', - ]; - static $args = ['severity', 'message', 'message_code', - 'bytes_transferred', 'bytes_max']; - - $value = \GuzzleHttp\debug_resource($value); - $ident = $request->getMethod() . ' ' . $request->getUri()->withFragment(''); - $this->addNotification( - $params, - function () use ($ident, $value, $map, $args) { - $passed = func_get_args(); - $code = array_shift($passed); - fprintf($value, '<%s> [%s] ', $ident, $map[$code]); - foreach (array_filter($passed) as $i => $v) { - fwrite($value, $args[$i] . ': "' . $v . '" '); - } - fwrite($value, "\n"); - } - ); - } - - private function addNotification(array &$params, callable $notify) - { - // Wrap the existing function if needed. - if (!isset($params['notification'])) { - $params['notification'] = $notify; - } else { - $params['notification'] = $this->callArray([ - $params['notification'], - $notify - ]); - } - } - - private function callArray(array $functions) - { - return function () use ($functions) { - $args = func_get_args(); - foreach ($functions as $fn) { - call_user_func_array($fn, $args); - } - }; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/HandlerStack.php b/vendor/guzzlehttp/guzzle/src/HandlerStack.php deleted file mode 100755 index 24c46fd9fea30c28a93137325f39bc18e9c8873c..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/HandlerStack.php +++ /dev/null @@ -1,273 +0,0 @@ -<?php -namespace GuzzleHttp; - -use Psr\Http\Message\RequestInterface; - -/** - * Creates a composed Guzzle handler function by stacking middlewares on top of - * an HTTP handler function. - */ -class HandlerStack -{ - /** @var callable */ - private $handler; - - /** @var array */ - private $stack = []; - - /** @var callable|null */ - private $cached; - - /** - * Creates a default handler stack that can be used by clients. - * - * The returned handler will wrap the provided handler or use the most - * appropriate default handler for your system. The returned HandlerStack has - * support for cookies, redirects, HTTP error exceptions, and preparing a body - * before sending. - * - * The returned handler stack can be passed to a client in the "handler" - * option. - * - * @param callable $handler HTTP handler function to use with the stack. If no - * handler is provided, the best handler for your - * system will be utilized. - * - * @return HandlerStack - */ - public static function create(callable $handler = null) - { - $stack = new self($handler ?: choose_handler()); - $stack->push(Middleware::httpErrors(), 'http_errors'); - $stack->push(Middleware::redirect(), 'allow_redirects'); - $stack->push(Middleware::cookies(), 'cookies'); - $stack->push(Middleware::prepareBody(), 'prepare_body'); - - return $stack; - } - - /** - * @param callable $handler Underlying HTTP handler. - */ - public function __construct(callable $handler = null) - { - $this->handler = $handler; - } - - /** - * Invokes the handler stack as a composed handler - * - * @param RequestInterface $request - * @param array $options - */ - public function __invoke(RequestInterface $request, array $options) - { - $handler = $this->resolve(); - - return $handler($request, $options); - } - - /** - * Dumps a string representation of the stack. - * - * @return string - */ - public function __toString() - { - $depth = 0; - $stack = []; - if ($this->handler) { - $stack[] = "0) Handler: " . $this->debugCallable($this->handler); - } - - $result = ''; - foreach (array_reverse($this->stack) as $tuple) { - $depth++; - $str = "{$depth}) Name: '{$tuple[1]}', "; - $str .= "Function: " . $this->debugCallable($tuple[0]); - $result = "> {$str}\n{$result}"; - $stack[] = $str; - } - - foreach (array_keys($stack) as $k) { - $result .= "< {$stack[$k]}\n"; - } - - return $result; - } - - /** - * Set the HTTP handler that actually returns a promise. - * - * @param callable $handler Accepts a request and array of options and - * returns a Promise. - */ - public function setHandler(callable $handler) - { - $this->handler = $handler; - $this->cached = null; - } - - /** - * Returns true if the builder has a handler. - * - * @return bool - */ - public function hasHandler() - { - return (bool) $this->handler; - } - - /** - * Unshift a middleware to the bottom of the stack. - * - * @param callable $middleware Middleware function - * @param string $name Name to register for this middleware. - */ - public function unshift(callable $middleware, $name = null) - { - array_unshift($this->stack, [$middleware, $name]); - $this->cached = null; - } - - /** - * Push a middleware to the top of the stack. - * - * @param callable $middleware Middleware function - * @param string $name Name to register for this middleware. - */ - public function push(callable $middleware, $name = '') - { - $this->stack[] = [$middleware, $name]; - $this->cached = null; - } - - /** - * Add a middleware before another middleware by name. - * - * @param string $findName Middleware to find - * @param callable $middleware Middleware function - * @param string $withName Name to register for this middleware. - */ - public function before($findName, callable $middleware, $withName = '') - { - $this->splice($findName, $withName, $middleware, true); - } - - /** - * Add a middleware after another middleware by name. - * - * @param string $findName Middleware to find - * @param callable $middleware Middleware function - * @param string $withName Name to register for this middleware. - */ - public function after($findName, callable $middleware, $withName = '') - { - $this->splice($findName, $withName, $middleware, false); - } - - /** - * Remove a middleware by instance or name from the stack. - * - * @param callable|string $remove Middleware to remove by instance or name. - */ - public function remove($remove) - { - $this->cached = null; - $idx = is_callable($remove) ? 0 : 1; - $this->stack = array_values(array_filter( - $this->stack, - function ($tuple) use ($idx, $remove) { - return $tuple[$idx] !== $remove; - } - )); - } - - /** - * Compose the middleware and handler into a single callable function. - * - * @return callable - */ - public function resolve() - { - if (!$this->cached) { - if (!($prev = $this->handler)) { - throw new \LogicException('No handler has been specified'); - } - - foreach (array_reverse($this->stack) as $fn) { - $prev = $fn[0]($prev); - } - - $this->cached = $prev; - } - - return $this->cached; - } - - /** - * @param $name - * @return int - */ - private function findByName($name) - { - foreach ($this->stack as $k => $v) { - if ($v[1] === $name) { - return $k; - } - } - - throw new \InvalidArgumentException("Middleware not found: $name"); - } - - /** - * Splices a function into the middleware list at a specific position. - * - * @param $findName - * @param $withName - * @param callable $middleware - * @param $before - */ - private function splice($findName, $withName, callable $middleware, $before) - { - $this->cached = null; - $idx = $this->findByName($findName); - $tuple = [$middleware, $withName]; - - if ($before) { - if ($idx === 0) { - array_unshift($this->stack, $tuple); - } else { - $replacement = [$tuple, $this->stack[$idx]]; - array_splice($this->stack, $idx, 1, $replacement); - } - } elseif ($idx === count($this->stack) - 1) { - $this->stack[] = $tuple; - } else { - $replacement = [$this->stack[$idx], $tuple]; - array_splice($this->stack, $idx, 1, $replacement); - } - } - - /** - * Provides a debug string for a given callable. - * - * @param array|callable $fn Function to write as a string. - * - * @return string - */ - private function debugCallable($fn) - { - if (is_string($fn)) { - return "callable({$fn})"; - } - - if (is_array($fn)) { - return is_string($fn[0]) - ? "callable({$fn[0]}::{$fn[1]})" - : "callable(['" . get_class($fn[0]) . "', '{$fn[1]}'])"; - } - - return 'callable(' . spl_object_hash($fn) . ')'; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/MessageFormatter.php b/vendor/guzzlehttp/guzzle/src/MessageFormatter.php deleted file mode 100755 index 663ac7391632645eb2f6b926123a1d669c1b9e69..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/MessageFormatter.php +++ /dev/null @@ -1,180 +0,0 @@ -<?php -namespace GuzzleHttp; - -use Psr\Http\Message\MessageInterface; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Formats log messages using variable substitutions for requests, responses, - * and other transactional data. - * - * The following variable substitutions are supported: - * - * - {request}: Full HTTP request message - * - {response}: Full HTTP response message - * - {ts}: ISO 8601 date in GMT - * - {date_iso_8601} ISO 8601 date in GMT - * - {date_common_log} Apache common log date using the configured timezone. - * - {host}: Host of the request - * - {method}: Method of the request - * - {uri}: URI of the request - * - {version}: Protocol version - * - {target}: Request target of the request (path + query + fragment) - * - {hostname}: Hostname of the machine that sent the request - * - {code}: Status code of the response (if available) - * - {phrase}: Reason phrase of the response (if available) - * - {error}: Any error messages (if available) - * - {req_header_*}: Replace `*` with the lowercased name of a request header to add to the message - * - {res_header_*}: Replace `*` with the lowercased name of a response header to add to the message - * - {req_headers}: Request headers - * - {res_headers}: Response headers - * - {req_body}: Request body - * - {res_body}: Response body - */ -class MessageFormatter -{ - /** - * Apache Common Log Format. - * @link http://httpd.apache.org/docs/2.4/logs.html#common - * @var string - */ - const CLF = "{hostname} {req_header_User-Agent} - [{date_common_log}] \"{method} {target} HTTP/{version}\" {code} {res_header_Content-Length}"; - const DEBUG = ">>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{error}"; - const SHORT = '[{ts}] "{method} {target} HTTP/{version}" {code}'; - - /** @var string Template used to format log messages */ - private $template; - - /** - * @param string $template Log message template - */ - public function __construct($template = self::CLF) - { - $this->template = $template ?: self::CLF; - } - - /** - * Returns a formatted message string. - * - * @param RequestInterface $request Request that was sent - * @param ResponseInterface $response Response that was received - * @param \Exception $error Exception that was received - * - * @return string - */ - public function format( - RequestInterface $request, - ResponseInterface $response = null, - \Exception $error = null - ) { - $cache = []; - - return preg_replace_callback( - '/{\s*([A-Za-z_\-\.0-9]+)\s*}/', - function (array $matches) use ($request, $response, $error, &$cache) { - if (isset($cache[$matches[1]])) { - return $cache[$matches[1]]; - } - - $result = ''; - switch ($matches[1]) { - case 'request': - $result = Psr7\str($request); - break; - case 'response': - $result = $response ? Psr7\str($response) : ''; - break; - case 'req_headers': - $result = trim($request->getMethod() - . ' ' . $request->getRequestTarget()) - . ' HTTP/' . $request->getProtocolVersion() . "\r\n" - . $this->headers($request); - break; - case 'res_headers': - $result = $response ? - sprintf( - 'HTTP/%s %d %s', - $response->getProtocolVersion(), - $response->getStatusCode(), - $response->getReasonPhrase() - ) . "\r\n" . $this->headers($response) - : 'NULL'; - break; - case 'req_body': - $result = $request->getBody(); - break; - case 'res_body': - $result = $response ? $response->getBody() : 'NULL'; - break; - case 'ts': - case 'date_iso_8601': - $result = gmdate('c'); - break; - case 'date_common_log': - $result = date('d/M/Y:H:i:s O'); - break; - case 'method': - $result = $request->getMethod(); - break; - case 'version': - $result = $request->getProtocolVersion(); - break; - case 'uri': - case 'url': - $result = $request->getUri(); - break; - case 'target': - $result = $request->getRequestTarget(); - break; - case 'req_version': - $result = $request->getProtocolVersion(); - break; - case 'res_version': - $result = $response - ? $response->getProtocolVersion() - : 'NULL'; - break; - case 'host': - $result = $request->getHeaderLine('Host'); - break; - case 'hostname': - $result = gethostname(); - break; - case 'code': - $result = $response ? $response->getStatusCode() : 'NULL'; - break; - case 'phrase': - $result = $response ? $response->getReasonPhrase() : 'NULL'; - break; - case 'error': - $result = $error ? $error->getMessage() : 'NULL'; - break; - default: - // handle prefixed dynamic headers - if (strpos($matches[1], 'req_header_') === 0) { - $result = $request->getHeaderLine(substr($matches[1], 11)); - } elseif (strpos($matches[1], 'res_header_') === 0) { - $result = $response - ? $response->getHeaderLine(substr($matches[1], 11)) - : 'NULL'; - } - } - - $cache[$matches[1]] = $result; - return $result; - }, - $this->template - ); - } - - private function headers(MessageInterface $message) - { - $result = ''; - foreach ($message->getHeaders() as $name => $values) { - $result .= $name . ': ' . implode(', ', $values) . "\r\n"; - } - - return trim($result); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Middleware.php b/vendor/guzzlehttp/guzzle/src/Middleware.php deleted file mode 100755 index d4ad75c94f333a43b97f42e973e3c5962572d606..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Middleware.php +++ /dev/null @@ -1,255 +0,0 @@ -<?php -namespace GuzzleHttp; - -use GuzzleHttp\Cookie\CookieJarInterface; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Promise\RejectedPromise; -use GuzzleHttp\Psr7; -use Psr\Http\Message\ResponseInterface; -use Psr\Log\LoggerInterface; -use Psr\Log\LogLevel; - -/** - * Functions used to create and wrap handlers with handler middleware. - */ -final class Middleware -{ - /** - * Middleware that adds cookies to requests. - * - * The options array must be set to a CookieJarInterface in order to use - * cookies. This is typically handled for you by a client. - * - * @return callable Returns a function that accepts the next handler. - */ - public static function cookies() - { - return function (callable $handler) { - return function ($request, array $options) use ($handler) { - if (empty($options['cookies'])) { - return $handler($request, $options); - } elseif (!($options['cookies'] instanceof CookieJarInterface)) { - throw new \InvalidArgumentException('cookies must be an instance of GuzzleHttp\Cookie\CookieJarInterface'); - } - $cookieJar = $options['cookies']; - $request = $cookieJar->withCookieHeader($request); - return $handler($request, $options) - ->then( - function ($response) use ($cookieJar, $request) { - $cookieJar->extractCookies($request, $response); - return $response; - } - ); - }; - }; - } - - /** - * Middleware that throws exceptions for 4xx or 5xx responses when the - * "http_error" request option is set to true. - * - * @return callable Returns a function that accepts the next handler. - */ - public static function httpErrors() - { - return function (callable $handler) { - return function ($request, array $options) use ($handler) { - if (empty($options['http_errors'])) { - return $handler($request, $options); - } - return $handler($request, $options)->then( - function (ResponseInterface $response) use ($request, $handler) { - $code = $response->getStatusCode(); - if ($code < 400) { - return $response; - } - throw RequestException::create($request, $response); - } - ); - }; - }; - } - - /** - * Middleware that pushes history data to an ArrayAccess container. - * - * @param array|\ArrayAccess $container Container to hold the history (by reference). - * - * @return callable Returns a function that accepts the next handler. - * @throws \InvalidArgumentException if container is not an array or ArrayAccess. - */ - public static function history(&$container) - { - if (!is_array($container) && !$container instanceof \ArrayAccess) { - throw new \InvalidArgumentException('history container must be an array or object implementing ArrayAccess'); - } - - return function (callable $handler) use (&$container) { - return function ($request, array $options) use ($handler, &$container) { - return $handler($request, $options)->then( - function ($value) use ($request, &$container, $options) { - $container[] = [ - 'request' => $request, - 'response' => $value, - 'error' => null, - 'options' => $options - ]; - return $value; - }, - function ($reason) use ($request, &$container, $options) { - $container[] = [ - 'request' => $request, - 'response' => null, - 'error' => $reason, - 'options' => $options - ]; - return \GuzzleHttp\Promise\rejection_for($reason); - } - ); - }; - }; - } - - /** - * Middleware that invokes a callback before and after sending a request. - * - * The provided listener cannot modify or alter the response. It simply - * "taps" into the chain to be notified before returning the promise. The - * before listener accepts a request and options array, and the after - * listener accepts a request, options array, and response promise. - * - * @param callable $before Function to invoke before forwarding the request. - * @param callable $after Function invoked after forwarding. - * - * @return callable Returns a function that accepts the next handler. - */ - public static function tap(callable $before = null, callable $after = null) - { - return function (callable $handler) use ($before, $after) { - return function ($request, array $options) use ($handler, $before, $after) { - if ($before) { - $before($request, $options); - } - $response = $handler($request, $options); - if ($after) { - $after($request, $options, $response); - } - return $response; - }; - }; - } - - /** - * Middleware that handles request redirects. - * - * @return callable Returns a function that accepts the next handler. - */ - public static function redirect() - { - return function (callable $handler) { - return new RedirectMiddleware($handler); - }; - } - - /** - * Middleware that retries requests based on the boolean result of - * invoking the provided "decider" function. - * - * If no delay function is provided, a simple implementation of exponential - * backoff will be utilized. - * - * @param callable $decider Function that accepts the number of retries, - * a request, [response], and [exception] and - * returns true if the request is to be retried. - * @param callable $delay Function that accepts the number of retries and - * returns the number of milliseconds to delay. - * - * @return callable Returns a function that accepts the next handler. - */ - public static function retry(callable $decider, callable $delay = null) - { - return function (callable $handler) use ($decider, $delay) { - return new RetryMiddleware($decider, $handler, $delay); - }; - } - - /** - * Middleware that logs requests, responses, and errors using a message - * formatter. - * - * @param LoggerInterface $logger Logs messages. - * @param MessageFormatter $formatter Formatter used to create message strings. - * @param string $logLevel Level at which to log requests. - * - * @return callable Returns a function that accepts the next handler. - */ - public static function log(LoggerInterface $logger, MessageFormatter $formatter, $logLevel = LogLevel::INFO) - { - return function (callable $handler) use ($logger, $formatter, $logLevel) { - return function ($request, array $options) use ($handler, $logger, $formatter, $logLevel) { - return $handler($request, $options)->then( - function ($response) use ($logger, $request, $formatter, $logLevel) { - $message = $formatter->format($request, $response); - $logger->log($logLevel, $message); - return $response; - }, - function ($reason) use ($logger, $request, $formatter) { - $response = $reason instanceof RequestException - ? $reason->getResponse() - : null; - $message = $formatter->format($request, $response, $reason); - $logger->notice($message); - return \GuzzleHttp\Promise\rejection_for($reason); - } - ); - }; - }; - } - - /** - * This middleware adds a default content-type if possible, a default - * content-length or transfer-encoding header, and the expect header. - * - * @return callable - */ - public static function prepareBody() - { - return function (callable $handler) { - return new PrepareBodyMiddleware($handler); - }; - } - - /** - * Middleware that applies a map function to the request before passing to - * the next handler. - * - * @param callable $fn Function that accepts a RequestInterface and returns - * a RequestInterface. - * @return callable - */ - public static function mapRequest(callable $fn) - { - return function (callable $handler) use ($fn) { - return function ($request, array $options) use ($handler, $fn) { - return $handler($fn($request), $options); - }; - }; - } - - /** - * Middleware that applies a map function to the resolved promise's - * response. - * - * @param callable $fn Function that accepts a ResponseInterface and - * returns a ResponseInterface. - * @return callable - */ - public static function mapResponse(callable $fn) - { - return function (callable $handler) use ($fn) { - return function ($request, array $options) use ($handler, $fn) { - return $handler($request, $options)->then($fn); - }; - }; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Pool.php b/vendor/guzzlehttp/guzzle/src/Pool.php deleted file mode 100755 index 8f1be33cd396b60e9dd738fe81150cb62dd9e211..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/Pool.php +++ /dev/null @@ -1,123 +0,0 @@ -<?php -namespace GuzzleHttp; - -use GuzzleHttp\Promise\PromisorInterface; -use Psr\Http\Message\RequestInterface; -use GuzzleHttp\Promise\EachPromise; - -/** - * Sends and iterator of requests concurrently using a capped pool size. - * - * The pool will read from an iterator until it is cancelled or until the - * iterator is consumed. When a request is yielded, the request is sent after - * applying the "request_options" request options (if provided in the ctor). - * - * When a function is yielded by the iterator, the function is provided the - * "request_options" array that should be merged on top of any existing - * options, and the function MUST then return a wait-able promise. - */ -class Pool implements PromisorInterface -{ - /** @var EachPromise */ - private $each; - - /** - * @param ClientInterface $client Client used to send the requests. - * @param array|\Iterator $requests Requests or functions that return - * requests to send concurrently. - * @param array $config Associative array of options - * - concurrency: (int) Maximum number of requests to send concurrently - * - options: Array of request options to apply to each request. - * - fulfilled: (callable) Function to invoke when a request completes. - * - rejected: (callable) Function to invoke when a request is rejected. - */ - public function __construct( - ClientInterface $client, - $requests, - array $config = [] - ) { - // Backwards compatibility. - if (isset($config['pool_size'])) { - $config['concurrency'] = $config['pool_size']; - } elseif (!isset($config['concurrency'])) { - $config['concurrency'] = 25; - } - - if (isset($config['options'])) { - $opts = $config['options']; - unset($config['options']); - } else { - $opts = []; - } - - $iterable = \GuzzleHttp\Promise\iter_for($requests); - $requests = function () use ($iterable, $client, $opts) { - foreach ($iterable as $key => $rfn) { - if ($rfn instanceof RequestInterface) { - yield $key => $client->sendAsync($rfn, $opts); - } elseif (is_callable($rfn)) { - yield $key => $rfn($opts); - } else { - throw new \InvalidArgumentException('Each value yielded by ' - . 'the iterator must be a Psr7\Http\Message\RequestInterface ' - . 'or a callable that returns a promise that fulfills ' - . 'with a Psr7\Message\Http\ResponseInterface object.'); - } - } - }; - - $this->each = new EachPromise($requests(), $config); - } - - public function promise() - { - return $this->each->promise(); - } - - /** - * Sends multiple requests concurrently and returns an array of responses - * and exceptions that uses the same ordering as the provided requests. - * - * IMPORTANT: This method keeps every request and response in memory, and - * as such, is NOT recommended when sending a large number or an - * indeterminate number of requests concurrently. - * - * @param ClientInterface $client Client used to send the requests - * @param array|\Iterator $requests Requests to send concurrently. - * @param array $options Passes through the options available in - * {@see GuzzleHttp\Pool::__construct} - * - * @return array Returns an array containing the response or an exception - * in the same order that the requests were sent. - * @throws \InvalidArgumentException if the event format is incorrect. - */ - public static function batch( - ClientInterface $client, - $requests, - array $options = [] - ) { - $res = []; - self::cmpCallback($options, 'fulfilled', $res); - self::cmpCallback($options, 'rejected', $res); - $pool = new static($client, $requests, $options); - $pool->promise()->wait(); - ksort($res); - - return $res; - } - - private static function cmpCallback(array &$options, $name, array &$results) - { - if (!isset($options[$name])) { - $options[$name] = function ($v, $k) use (&$results) { - $results[$k] = $v; - }; - } else { - $currentFn = $options[$name]; - $options[$name] = function ($v, $k) use (&$results, $currentFn) { - $currentFn($v, $k); - $results[$k] = $v; - }; - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php b/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php deleted file mode 100755 index 2eb95f9b2d3a1d9ce581f34bb01fcdf46ddd493d..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php +++ /dev/null @@ -1,106 +0,0 @@ -<?php -namespace GuzzleHttp; - -use GuzzleHttp\Promise\PromiseInterface; -use GuzzleHttp\Psr7; -use Psr\Http\Message\RequestInterface; - -/** - * Prepares requests that contain a body, adding the Content-Length, - * Content-Type, and Expect headers. - */ -class PrepareBodyMiddleware -{ - /** @var callable */ - private $nextHandler; - - /** - * @param callable $nextHandler Next handler to invoke. - */ - public function __construct(callable $nextHandler) - { - $this->nextHandler = $nextHandler; - } - - /** - * @param RequestInterface $request - * @param array $options - * - * @return PromiseInterface - */ - public function __invoke(RequestInterface $request, array $options) - { - $fn = $this->nextHandler; - - // Don't do anything if the request has no body. - if ($request->getBody()->getSize() === 0) { - return $fn($request, $options); - } - - $modify = []; - - // Add a default content-type if possible. - if (!$request->hasHeader('Content-Type')) { - if ($uri = $request->getBody()->getMetadata('uri')) { - if ($type = Psr7\mimetype_from_filename($uri)) { - $modify['set_headers']['Content-Type'] = $type; - } - } - } - - // Add a default content-length or transfer-encoding header. - if (!$request->hasHeader('Content-Length') - && !$request->hasHeader('Transfer-Encoding') - ) { - $size = $request->getBody()->getSize(); - if ($size !== null) { - $modify['set_headers']['Content-Length'] = $size; - } else { - $modify['set_headers']['Transfer-Encoding'] = 'chunked'; - } - } - - // Add the expect header if needed. - $this->addExpectHeader($request, $options, $modify); - - return $fn(Psr7\modify_request($request, $modify), $options); - } - - private function addExpectHeader( - RequestInterface $request, - array $options, - array &$modify - ) { - // Determine if the Expect header should be used - if ($request->hasHeader('Expect')) { - return; - } - - $expect = isset($options['expect']) ? $options['expect'] : null; - - // Return if disabled or if you're not using HTTP/1.1 or HTTP/2.0 - if ($expect === false || $request->getProtocolVersion() < 1.1) { - return; - } - - // The expect header is unconditionally enabled - if ($expect === true) { - $modify['set_headers']['Expect'] = '100-Continue'; - return; - } - - // By default, send the expect header when the payload is > 1mb - if ($expect === null) { - $expect = 1048576; - } - - // Always add if the body cannot be rewound, the size cannot be - // determined, or the size is greater than the cutoff threshold - $body = $request->getBody(); - $size = $body->getSize(); - - if ($size === null || $size >= (int) $expect || !$body->isSeekable()) { - $modify['set_headers']['Expect'] = '100-Continue'; - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php b/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php deleted file mode 100755 index 131b77179aa07f59ef65ff0945dd51083d58eb0e..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php +++ /dev/null @@ -1,237 +0,0 @@ -<?php -namespace GuzzleHttp; - -use GuzzleHttp\Exception\BadResponseException; -use GuzzleHttp\Exception\TooManyRedirectsException; -use GuzzleHttp\Promise\PromiseInterface; -use GuzzleHttp\Psr7; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\UriInterface; - -/** - * Request redirect middleware. - * - * Apply this middleware like other middleware using - * {@see GuzzleHttp\Middleware::redirect()}. - */ -class RedirectMiddleware -{ - const HISTORY_HEADER = 'X-Guzzle-Redirect-History'; - - const STATUS_HISTORY_HEADER = 'X-Guzzle-Redirect-Status-History'; - - public static $defaultSettings = [ - 'max' => 5, - 'protocols' => ['http', 'https'], - 'strict' => false, - 'referer' => false, - 'track_redirects' => false, - ]; - - /** @var callable */ - private $nextHandler; - - /** - * @param callable $nextHandler Next handler to invoke. - */ - public function __construct(callable $nextHandler) - { - $this->nextHandler = $nextHandler; - } - - /** - * @param RequestInterface $request - * @param array $options - * - * @return PromiseInterface - */ - public function __invoke(RequestInterface $request, array $options) - { - $fn = $this->nextHandler; - - if (empty($options['allow_redirects'])) { - return $fn($request, $options); - } - - if ($options['allow_redirects'] === true) { - $options['allow_redirects'] = self::$defaultSettings; - } elseif (!is_array($options['allow_redirects'])) { - throw new \InvalidArgumentException('allow_redirects must be true, false, or array'); - } else { - // Merge the default settings with the provided settings - $options['allow_redirects'] += self::$defaultSettings; - } - - if (empty($options['allow_redirects']['max'])) { - return $fn($request, $options); - } - - return $fn($request, $options) - ->then(function (ResponseInterface $response) use ($request, $options) { - return $this->checkRedirect($request, $options, $response); - }); - } - - /** - * @param RequestInterface $request - * @param array $options - * @param ResponseInterface|PromiseInterface $response - * - * @return ResponseInterface|PromiseInterface - */ - public function checkRedirect( - RequestInterface $request, - array $options, - ResponseInterface $response - ) { - if (substr($response->getStatusCode(), 0, 1) != '3' - || !$response->hasHeader('Location') - ) { - return $response; - } - - $this->guardMax($request, $options); - $nextRequest = $this->modifyRequest($request, $options, $response); - - if (isset($options['allow_redirects']['on_redirect'])) { - call_user_func( - $options['allow_redirects']['on_redirect'], - $request, - $response, - $nextRequest->getUri() - ); - } - - /** @var PromiseInterface|ResponseInterface $promise */ - $promise = $this($nextRequest, $options); - - // Add headers to be able to track history of redirects. - if (!empty($options['allow_redirects']['track_redirects'])) { - return $this->withTracking( - $promise, - (string) $nextRequest->getUri(), - $response->getStatusCode() - ); - } - - return $promise; - } - - private function withTracking(PromiseInterface $promise, $uri, $statusCode) - { - return $promise->then( - function (ResponseInterface $response) use ($uri, $statusCode) { - // Note that we are pushing to the front of the list as this - // would be an earlier response than what is currently present - // in the history header. - $historyHeader = $response->getHeader(self::HISTORY_HEADER); - $statusHeader = $response->getHeader(self::STATUS_HISTORY_HEADER); - array_unshift($historyHeader, $uri); - array_unshift($statusHeader, $statusCode); - return $response->withHeader(self::HISTORY_HEADER, $historyHeader) - ->withHeader(self::STATUS_HISTORY_HEADER, $statusHeader); - } - ); - } - - private function guardMax(RequestInterface $request, array &$options) - { - $current = isset($options['__redirect_count']) - ? $options['__redirect_count'] - : 0; - $options['__redirect_count'] = $current + 1; - $max = $options['allow_redirects']['max']; - - if ($options['__redirect_count'] > $max) { - throw new TooManyRedirectsException( - "Will not follow more than {$max} redirects", - $request - ); - } - } - - /** - * @param RequestInterface $request - * @param array $options - * @param ResponseInterface $response - * - * @return RequestInterface - */ - public function modifyRequest( - RequestInterface $request, - array $options, - ResponseInterface $response - ) { - // Request modifications to apply. - $modify = []; - $protocols = $options['allow_redirects']['protocols']; - - // Use a GET request if this is an entity enclosing request and we are - // not forcing RFC compliance, but rather emulating what all browsers - // would do. - $statusCode = $response->getStatusCode(); - if ($statusCode == 303 || - ($statusCode <= 302 && $request->getBody() && !$options['allow_redirects']['strict']) - ) { - $modify['method'] = 'GET'; - $modify['body'] = ''; - } - - $modify['uri'] = $this->redirectUri($request, $response, $protocols); - Psr7\rewind_body($request); - - // Add the Referer header if it is told to do so and only - // add the header if we are not redirecting from https to http. - if ($options['allow_redirects']['referer'] - && $modify['uri']->getScheme() === $request->getUri()->getScheme() - ) { - $uri = $request->getUri()->withUserInfo('', ''); - $modify['set_headers']['Referer'] = (string) $uri; - } else { - $modify['remove_headers'][] = 'Referer'; - } - - // Remove Authorization header if host is different. - if ($request->getUri()->getHost() !== $modify['uri']->getHost()) { - $modify['remove_headers'][] = 'Authorization'; - } - - return Psr7\modify_request($request, $modify); - } - - /** - * Set the appropriate URL on the request based on the location header - * - * @param RequestInterface $request - * @param ResponseInterface $response - * @param array $protocols - * - * @return UriInterface - */ - private function redirectUri( - RequestInterface $request, - ResponseInterface $response, - array $protocols - ) { - $location = Psr7\UriResolver::resolve( - $request->getUri(), - new Psr7\Uri($response->getHeaderLine('Location')) - ); - - // Ensure that the redirect URI is allowed based on the protocols. - if (!in_array($location->getScheme(), $protocols)) { - throw new BadResponseException( - sprintf( - 'Redirect URI, %s, does not use one of the allowed redirect protocols: %s', - $location, - implode(', ', $protocols) - ), - $request, - $response - ); - } - - return $location; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/RequestOptions.php b/vendor/guzzlehttp/guzzle/src/RequestOptions.php deleted file mode 100755 index c6aacfb15782756a14e24ccc71143663795011fa..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/RequestOptions.php +++ /dev/null @@ -1,255 +0,0 @@ -<?php -namespace GuzzleHttp; - -/** - * This class contains a list of built-in Guzzle request options. - * - * More documentation for each option can be found at http://guzzlephp.org/. - * - * @link http://docs.guzzlephp.org/en/v6/request-options.html - */ -final class RequestOptions -{ - /** - * allow_redirects: (bool|array) Controls redirect behavior. Pass false - * to disable redirects, pass true to enable redirects, pass an - * associative to provide custom redirect settings. Defaults to "false". - * This option only works if your handler has the RedirectMiddleware. When - * passing an associative array, you can provide the following key value - * pairs: - * - * - max: (int, default=5) maximum number of allowed redirects. - * - strict: (bool, default=false) Set to true to use strict redirects - * meaning redirect POST requests with POST requests vs. doing what most - * browsers do which is redirect POST requests with GET requests - * - referer: (bool, default=true) Set to false to disable the Referer - * header. - * - protocols: (array, default=['http', 'https']) Allowed redirect - * protocols. - * - on_redirect: (callable) PHP callable that is invoked when a redirect - * is encountered. The callable is invoked with the request, the redirect - * response that was received, and the effective URI. Any return value - * from the on_redirect function is ignored. - */ - const ALLOW_REDIRECTS = 'allow_redirects'; - - /** - * auth: (array) Pass an array of HTTP authentication parameters to use - * with the request. The array must contain the username in index [0], - * the password in index [1], and you can optionally provide a built-in - * authentication type in index [2]. Pass null to disable authentication - * for a request. - */ - const AUTH = 'auth'; - - /** - * body: (resource|string|null|int|float|StreamInterface|callable|\Iterator) - * Body to send in the request. - */ - const BODY = 'body'; - - /** - * cert: (string|array) Set to a string to specify the path to a file - * containing a PEM formatted SSL client side certificate. If a password - * is required, then set cert to an array containing the path to the PEM - * file in the first array element followed by the certificate password - * in the second array element. - */ - const CERT = 'cert'; - - /** - * cookies: (bool|GuzzleHttp\Cookie\CookieJarInterface, default=false) - * Specifies whether or not cookies are used in a request or what cookie - * jar to use or what cookies to send. This option only works if your - * handler has the `cookie` middleware. Valid values are `false` and - * an instance of {@see GuzzleHttp\Cookie\CookieJarInterface}. - */ - const COOKIES = 'cookies'; - - /** - * connect_timeout: (float, default=0) Float describing the number of - * seconds to wait while trying to connect to a server. Use 0 to wait - * indefinitely (the default behavior). - */ - const CONNECT_TIMEOUT = 'connect_timeout'; - - /** - * debug: (bool|resource) Set to true or set to a PHP stream returned by - * fopen() enable debug output with the HTTP handler used to send a - * request. - */ - const DEBUG = 'debug'; - - /** - * decode_content: (bool, default=true) Specify whether or not - * Content-Encoding responses (gzip, deflate, etc.) are automatically - * decoded. - */ - const DECODE_CONTENT = 'decode_content'; - - /** - * delay: (int) The amount of time to delay before sending in milliseconds. - */ - const DELAY = 'delay'; - - /** - * expect: (bool|integer) Controls the behavior of the - * "Expect: 100-Continue" header. - * - * Set to `true` to enable the "Expect: 100-Continue" header for all - * requests that sends a body. Set to `false` to disable the - * "Expect: 100-Continue" header for all requests. Set to a number so that - * the size of the payload must be greater than the number in order to send - * the Expect header. Setting to a number will send the Expect header for - * all requests in which the size of the payload cannot be determined or - * where the body is not rewindable. - * - * By default, Guzzle will add the "Expect: 100-Continue" header when the - * size of the body of a request is greater than 1 MB and a request is - * using HTTP/1.1. - */ - const EXPECT = 'expect'; - - /** - * form_params: (array) Associative array of form field names to values - * where each value is a string or array of strings. Sets the Content-Type - * header to application/x-www-form-urlencoded when no Content-Type header - * is already present. - */ - const FORM_PARAMS = 'form_params'; - - /** - * headers: (array) Associative array of HTTP headers. Each value MUST be - * a string or array of strings. - */ - const HEADERS = 'headers'; - - /** - * http_errors: (bool, default=true) Set to false to disable exceptions - * when a non- successful HTTP response is received. By default, - * exceptions will be thrown for 4xx and 5xx responses. This option only - * works if your handler has the `httpErrors` middleware. - */ - const HTTP_ERRORS = 'http_errors'; - - /** - * json: (mixed) Adds JSON data to a request. The provided value is JSON - * encoded and a Content-Type header of application/json will be added to - * the request if no Content-Type header is already present. - */ - const JSON = 'json'; - - /** - * multipart: (array) Array of associative arrays, each containing a - * required "name" key mapping to the form field, name, a required - * "contents" key mapping to a StreamInterface|resource|string, an - * optional "headers" associative array of custom headers, and an - * optional "filename" key mapping to a string to send as the filename in - * the part. If no "filename" key is present, then no "filename" attribute - * will be added to the part. - */ - const MULTIPART = 'multipart'; - - /** - * on_headers: (callable) A callable that is invoked when the HTTP headers - * of the response have been received but the body has not yet begun to - * download. - */ - const ON_HEADERS = 'on_headers'; - - /** - * on_stats: (callable) allows you to get access to transfer statistics of - * a request and access the lower level transfer details of the handler - * associated with your client. ``on_stats`` is a callable that is invoked - * when a handler has finished sending a request. The callback is invoked - * with transfer statistics about the request, the response received, or - * the error encountered. Included in the data is the total amount of time - * taken to send the request. - */ - const ON_STATS = 'on_stats'; - - /** - * progress: (callable) Defines a function to invoke when transfer - * progress is made. The function accepts the following positional - * arguments: the total number of bytes expected to be downloaded, the - * number of bytes downloaded so far, the number of bytes expected to be - * uploaded, the number of bytes uploaded so far. - */ - const PROGRESS = 'progress'; - - /** - * proxy: (string|array) Pass a string to specify an HTTP proxy, or an - * array to specify different proxies for different protocols (where the - * key is the protocol and the value is a proxy string). - */ - const PROXY = 'proxy'; - - /** - * query: (array|string) Associative array of query string values to add - * to the request. This option uses PHP's http_build_query() to create - * the string representation. Pass a string value if you need more - * control than what this method provides - */ - const QUERY = 'query'; - - /** - * sink: (resource|string|StreamInterface) Where the data of the - * response is written to. Defaults to a PHP temp stream. Providing a - * string will write data to a file by the given name. - */ - const SINK = 'sink'; - - /** - * synchronous: (bool) Set to true to inform HTTP handlers that you intend - * on waiting on the response. This can be useful for optimizations. Note - * that a promise is still returned if you are using one of the async - * client methods. - */ - const SYNCHRONOUS = 'synchronous'; - - /** - * ssl_key: (array|string) Specify the path to a file containing a private - * SSL key in PEM format. If a password is required, then set to an array - * containing the path to the SSL key in the first array element followed - * by the password required for the certificate in the second element. - */ - const SSL_KEY = 'ssl_key'; - - /** - * stream: Set to true to attempt to stream a response rather than - * download it all up-front. - */ - const STREAM = 'stream'; - - /** - * verify: (bool|string, default=true) Describes the SSL certificate - * verification behavior of a request. Set to true to enable SSL - * certificate verification using the system CA bundle when available - * (the default). Set to false to disable certificate verification (this - * is insecure!). Set to a string to provide the path to a CA bundle on - * disk to enable verification using a custom certificate. - */ - const VERIFY = 'verify'; - - /** - * timeout: (float, default=0) Float describing the timeout of the - * request in seconds. Use 0 to wait indefinitely (the default behavior). - */ - const TIMEOUT = 'timeout'; - - /** - * read_timeout: (float, default=default_socket_timeout ini setting) Float describing - * the body read timeout, for stream requests. - */ - const READ_TIMEOUT = 'read_timeout'; - - /** - * version: (float) Specifies the HTTP protocol version to attempt to use. - */ - const VERSION = 'version'; - - /** - * force_ip_resolve: (bool) Force client to use only ipv4 or ipv6 protocol - */ - const FORCE_IP_RESOLVE = 'force_ip_resolve'; -} diff --git a/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php b/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php deleted file mode 100755 index f27090fd197ab7ff443f12f6501d639f169871cf..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php +++ /dev/null @@ -1,112 +0,0 @@ -<?php -namespace GuzzleHttp; - -use GuzzleHttp\Promise\PromiseInterface; -use GuzzleHttp\Promise\RejectedPromise; -use GuzzleHttp\Psr7; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Middleware that retries requests based on the boolean result of - * invoking the provided "decider" function. - */ -class RetryMiddleware -{ - /** @var callable */ - private $nextHandler; - - /** @var callable */ - private $decider; - - /** - * @param callable $decider Function that accepts the number of retries, - * a request, [response], and [exception] and - * returns true if the request is to be - * retried. - * @param callable $nextHandler Next handler to invoke. - * @param callable $delay Function that accepts the number of retries - * and [response] and returns the number of - * milliseconds to delay. - */ - public function __construct( - callable $decider, - callable $nextHandler, - callable $delay = null - ) { - $this->decider = $decider; - $this->nextHandler = $nextHandler; - $this->delay = $delay ?: __CLASS__ . '::exponentialDelay'; - } - - /** - * Default exponential backoff delay function. - * - * @param $retries - * - * @return int - */ - public static function exponentialDelay($retries) - { - return (int) pow(2, $retries - 1); - } - - /** - * @param RequestInterface $request - * @param array $options - * - * @return PromiseInterface - */ - public function __invoke(RequestInterface $request, array $options) - { - if (!isset($options['retries'])) { - $options['retries'] = 0; - } - - $fn = $this->nextHandler; - return $fn($request, $options) - ->then( - $this->onFulfilled($request, $options), - $this->onRejected($request, $options) - ); - } - - private function onFulfilled(RequestInterface $req, array $options) - { - return function ($value) use ($req, $options) { - if (!call_user_func( - $this->decider, - $options['retries'], - $req, - $value, - null - )) { - return $value; - } - return $this->doRetry($req, $options, $value); - }; - } - - private function onRejected(RequestInterface $req, array $options) - { - return function ($reason) use ($req, $options) { - if (!call_user_func( - $this->decider, - $options['retries'], - $req, - null, - $reason - )) { - return \GuzzleHttp\Promise\rejection_for($reason); - } - return $this->doRetry($req, $options); - }; - } - - private function doRetry(RequestInterface $request, array $options, ResponseInterface $response = null) - { - $options['delay'] = call_user_func($this->delay, ++$options['retries'], $response); - - return $this($request, $options); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/TransferStats.php b/vendor/guzzlehttp/guzzle/src/TransferStats.php deleted file mode 100755 index 15f717e1ea6e8edf6bc3a252f5a478e19e835b04..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/TransferStats.php +++ /dev/null @@ -1,126 +0,0 @@ -<?php -namespace GuzzleHttp; - -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\UriInterface; - -/** - * Represents data at the point after it was transferred either successfully - * or after a network error. - */ -final class TransferStats -{ - private $request; - private $response; - private $transferTime; - private $handlerStats; - private $handlerErrorData; - - /** - * @param RequestInterface $request Request that was sent. - * @param ResponseInterface $response Response received (if any) - * @param null $transferTime Total handler transfer time. - * @param mixed $handlerErrorData Handler error data. - * @param array $handlerStats Handler specific stats. - */ - public function __construct( - RequestInterface $request, - ResponseInterface $response = null, - $transferTime = null, - $handlerErrorData = null, - $handlerStats = [] - ) { - $this->request = $request; - $this->response = $response; - $this->transferTime = $transferTime; - $this->handlerErrorData = $handlerErrorData; - $this->handlerStats = $handlerStats; - } - - /** - * @return RequestInterface - */ - public function getRequest() - { - return $this->request; - } - - /** - * Returns the response that was received (if any). - * - * @return ResponseInterface|null - */ - public function getResponse() - { - return $this->response; - } - - /** - * Returns true if a response was received. - * - * @return bool - */ - public function hasResponse() - { - return $this->response !== null; - } - - /** - * Gets handler specific error data. - * - * This might be an exception, a integer representing an error code, or - * anything else. Relying on this value assumes that you know what handler - * you are using. - * - * @return mixed - */ - public function getHandlerErrorData() - { - return $this->handlerErrorData; - } - - /** - * Get the effective URI the request was sent to. - * - * @return UriInterface - */ - public function getEffectiveUri() - { - return $this->request->getUri(); - } - - /** - * Get the estimated time the request was being transferred by the handler. - * - * @return float Time in seconds. - */ - public function getTransferTime() - { - return $this->transferTime; - } - - /** - * Gets an array of all of the handler specific transfer data. - * - * @return array - */ - public function getHandlerStats() - { - return $this->handlerStats; - } - - /** - * Get a specific handler statistic from the handler by name. - * - * @param string $stat Handler specific transfer stat to retrieve. - * - * @return mixed|null - */ - public function getHandlerStat($stat) - { - return isset($this->handlerStats[$stat]) - ? $this->handlerStats[$stat] - : null; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/UriTemplate.php b/vendor/guzzlehttp/guzzle/src/UriTemplate.php deleted file mode 100755 index 96dcfd09cd71fb4a2c40b38445faee78568ba0cc..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/UriTemplate.php +++ /dev/null @@ -1,237 +0,0 @@ -<?php -namespace GuzzleHttp; - -/** - * Expands URI templates. Userland implementation of PECL uri_template. - * - * @link http://tools.ietf.org/html/rfc6570 - */ -class UriTemplate -{ - /** @var string URI template */ - private $template; - - /** @var array Variables to use in the template expansion */ - private $variables; - - /** @var array Hash for quick operator lookups */ - private static $operatorHash = [ - '' => ['prefix' => '', 'joiner' => ',', 'query' => false], - '+' => ['prefix' => '', 'joiner' => ',', 'query' => false], - '#' => ['prefix' => '#', 'joiner' => ',', 'query' => false], - '.' => ['prefix' => '.', 'joiner' => '.', 'query' => false], - '/' => ['prefix' => '/', 'joiner' => '/', 'query' => false], - ';' => ['prefix' => ';', 'joiner' => ';', 'query' => true], - '?' => ['prefix' => '?', 'joiner' => '&', 'query' => true], - '&' => ['prefix' => '&', 'joiner' => '&', 'query' => true] - ]; - - /** @var array Delimiters */ - private static $delims = [':', '/', '?', '#', '[', ']', '@', '!', '$', - '&', '\'', '(', ')', '*', '+', ',', ';', '=']; - - /** @var array Percent encoded delimiters */ - private static $delimsPct = ['%3A', '%2F', '%3F', '%23', '%5B', '%5D', - '%40', '%21', '%24', '%26', '%27', '%28', '%29', '%2A', '%2B', '%2C', - '%3B', '%3D']; - - public function expand($template, array $variables) - { - if (false === strpos($template, '{')) { - return $template; - } - - $this->template = $template; - $this->variables = $variables; - - return preg_replace_callback( - '/\{([^\}]+)\}/', - [$this, 'expandMatch'], - $this->template - ); - } - - /** - * Parse an expression into parts - * - * @param string $expression Expression to parse - * - * @return array Returns an associative array of parts - */ - private function parseExpression($expression) - { - $result = []; - - if (isset(self::$operatorHash[$expression[0]])) { - $result['operator'] = $expression[0]; - $expression = substr($expression, 1); - } else { - $result['operator'] = ''; - } - - foreach (explode(',', $expression) as $value) { - $value = trim($value); - $varspec = []; - if ($colonPos = strpos($value, ':')) { - $varspec['value'] = substr($value, 0, $colonPos); - $varspec['modifier'] = ':'; - $varspec['position'] = (int) substr($value, $colonPos + 1); - } elseif (substr($value, -1) === '*') { - $varspec['modifier'] = '*'; - $varspec['value'] = substr($value, 0, -1); - } else { - $varspec['value'] = (string) $value; - $varspec['modifier'] = ''; - } - $result['values'][] = $varspec; - } - - return $result; - } - - /** - * Process an expansion - * - * @param array $matches Matches met in the preg_replace_callback - * - * @return string Returns the replacement string - */ - private function expandMatch(array $matches) - { - static $rfc1738to3986 = ['+' => '%20', '%7e' => '~']; - - $replacements = []; - $parsed = self::parseExpression($matches[1]); - $prefix = self::$operatorHash[$parsed['operator']]['prefix']; - $joiner = self::$operatorHash[$parsed['operator']]['joiner']; - $useQuery = self::$operatorHash[$parsed['operator']]['query']; - - foreach ($parsed['values'] as $value) { - if (!isset($this->variables[$value['value']])) { - continue; - } - - $variable = $this->variables[$value['value']]; - $actuallyUseQuery = $useQuery; - $expanded = ''; - - if (is_array($variable)) { - $isAssoc = $this->isAssoc($variable); - $kvp = []; - foreach ($variable as $key => $var) { - if ($isAssoc) { - $key = rawurlencode($key); - $isNestedArray = is_array($var); - } else { - $isNestedArray = false; - } - - if (!$isNestedArray) { - $var = rawurlencode($var); - if ($parsed['operator'] === '+' || - $parsed['operator'] === '#' - ) { - $var = $this->decodeReserved($var); - } - } - - if ($value['modifier'] === '*') { - if ($isAssoc) { - if ($isNestedArray) { - // Nested arrays must allow for deeply nested - // structures. - $var = strtr( - http_build_query([$key => $var]), - $rfc1738to3986 - ); - } else { - $var = $key . '=' . $var; - } - } elseif ($key > 0 && $actuallyUseQuery) { - $var = $value['value'] . '=' . $var; - } - } - - $kvp[$key] = $var; - } - - if (empty($variable)) { - $actuallyUseQuery = false; - } elseif ($value['modifier'] === '*') { - $expanded = implode($joiner, $kvp); - if ($isAssoc) { - // Don't prepend the value name when using the explode - // modifier with an associative array. - $actuallyUseQuery = false; - } - } else { - if ($isAssoc) { - // When an associative array is encountered and the - // explode modifier is not set, then the result must be - // a comma separated list of keys followed by their - // respective values. - foreach ($kvp as $k => &$v) { - $v = $k . ',' . $v; - } - } - $expanded = implode(',', $kvp); - } - } else { - if ($value['modifier'] === ':') { - $variable = substr($variable, 0, $value['position']); - } - $expanded = rawurlencode($variable); - if ($parsed['operator'] === '+' || $parsed['operator'] === '#') { - $expanded = $this->decodeReserved($expanded); - } - } - - if ($actuallyUseQuery) { - if (!$expanded && $joiner !== '&') { - $expanded = $value['value']; - } else { - $expanded = $value['value'] . '=' . $expanded; - } - } - - $replacements[] = $expanded; - } - - $ret = implode($joiner, $replacements); - if ($ret && $prefix) { - return $prefix . $ret; - } - - return $ret; - } - - /** - * Determines if an array is associative. - * - * This makes the assumption that input arrays are sequences or hashes. - * This assumption is a tradeoff for accuracy in favor of speed, but it - * should work in almost every case where input is supplied for a URI - * template. - * - * @param array $array Array to check - * - * @return bool - */ - private function isAssoc(array $array) - { - return $array && array_keys($array)[0] !== 0; - } - - /** - * Removes percent encoding on reserved characters (used with + and # - * modifiers). - * - * @param string $string String to fix - * - * @return string - */ - private function decodeReserved($string) - { - return str_replace(self::$delimsPct, self::$delims, $string); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/functions.php b/vendor/guzzlehttp/guzzle/src/functions.php deleted file mode 100755 index a3ac450db94cfe1409f5ec052d2710e6426e469e..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/functions.php +++ /dev/null @@ -1,333 +0,0 @@ -<?php -namespace GuzzleHttp; - -use GuzzleHttp\Handler\CurlHandler; -use GuzzleHttp\Handler\CurlMultiHandler; -use GuzzleHttp\Handler\Proxy; -use GuzzleHttp\Handler\StreamHandler; - -/** - * Expands a URI template - * - * @param string $template URI template - * @param array $variables Template variables - * - * @return string - */ -function uri_template($template, array $variables) -{ - if (extension_loaded('uri_template')) { - // @codeCoverageIgnoreStart - return \uri_template($template, $variables); - // @codeCoverageIgnoreEnd - } - - static $uriTemplate; - if (!$uriTemplate) { - $uriTemplate = new UriTemplate(); - } - - return $uriTemplate->expand($template, $variables); -} - -/** - * Debug function used to describe the provided value type and class. - * - * @param mixed $input - * - * @return string Returns a string containing the type of the variable and - * if a class is provided, the class name. - */ -function describe_type($input) -{ - switch (gettype($input)) { - case 'object': - return 'object(' . get_class($input) . ')'; - case 'array': - return 'array(' . count($input) . ')'; - default: - ob_start(); - var_dump($input); - // normalize float vs double - return str_replace('double(', 'float(', rtrim(ob_get_clean())); - } -} - -/** - * Parses an array of header lines into an associative array of headers. - * - * @param array $lines Header lines array of strings in the following - * format: "Name: Value" - * @return array - */ -function headers_from_lines($lines) -{ - $headers = []; - - foreach ($lines as $line) { - $parts = explode(':', $line, 2); - $headers[trim($parts[0])][] = isset($parts[1]) - ? trim($parts[1]) - : null; - } - - return $headers; -} - -/** - * Returns a debug stream based on the provided variable. - * - * @param mixed $value Optional value - * - * @return resource - */ -function debug_resource($value = null) -{ - if (is_resource($value)) { - return $value; - } elseif (defined('STDOUT')) { - return STDOUT; - } - - return fopen('php://output', 'w'); -} - -/** - * Chooses and creates a default handler to use based on the environment. - * - * The returned handler is not wrapped by any default middlewares. - * - * @throws \RuntimeException if no viable Handler is available. - * @return callable Returns the best handler for the given system. - */ -function choose_handler() -{ - $handler = null; - if (function_exists('curl_multi_exec') && function_exists('curl_exec')) { - $handler = Proxy::wrapSync(new CurlMultiHandler(), new CurlHandler()); - } elseif (function_exists('curl_exec')) { - $handler = new CurlHandler(); - } elseif (function_exists('curl_multi_exec')) { - $handler = new CurlMultiHandler(); - } - - if (ini_get('allow_url_fopen')) { - $handler = $handler - ? Proxy::wrapStreaming($handler, new StreamHandler()) - : new StreamHandler(); - } elseif (!$handler) { - throw new \RuntimeException('GuzzleHttp requires cURL, the ' - . 'allow_url_fopen ini setting, or a custom HTTP handler.'); - } - - return $handler; -} - -/** - * Get the default User-Agent string to use with Guzzle - * - * @return string - */ -function default_user_agent() -{ - static $defaultAgent = ''; - - if (!$defaultAgent) { - $defaultAgent = 'GuzzleHttp/' . Client::VERSION; - if (extension_loaded('curl') && function_exists('curl_version')) { - $defaultAgent .= ' curl/' . \curl_version()['version']; - } - $defaultAgent .= ' PHP/' . PHP_VERSION; - } - - return $defaultAgent; -} - -/** - * Returns the default cacert bundle for the current system. - * - * First, the openssl.cafile and curl.cainfo php.ini settings are checked. - * If those settings are not configured, then the common locations for - * bundles found on Red Hat, CentOS, Fedora, Ubuntu, Debian, FreeBSD, OS X - * and Windows are checked. If any of these file locations are found on - * disk, they will be utilized. - * - * Note: the result of this function is cached for subsequent calls. - * - * @return string - * @throws \RuntimeException if no bundle can be found. - */ -function default_ca_bundle() -{ - static $cached = null; - static $cafiles = [ - // Red Hat, CentOS, Fedora (provided by the ca-certificates package) - '/etc/pki/tls/certs/ca-bundle.crt', - // Ubuntu, Debian (provided by the ca-certificates package) - '/etc/ssl/certs/ca-certificates.crt', - // FreeBSD (provided by the ca_root_nss package) - '/usr/local/share/certs/ca-root-nss.crt', - // SLES 12 (provided by the ca-certificates package) - '/var/lib/ca-certificates/ca-bundle.pem', - // OS X provided by homebrew (using the default path) - '/usr/local/etc/openssl/cert.pem', - // Google app engine - '/etc/ca-certificates.crt', - // Windows? - 'C:\\windows\\system32\\curl-ca-bundle.crt', - 'C:\\windows\\curl-ca-bundle.crt', - ]; - - if ($cached) { - return $cached; - } - - if ($ca = ini_get('openssl.cafile')) { - return $cached = $ca; - } - - if ($ca = ini_get('curl.cainfo')) { - return $cached = $ca; - } - - foreach ($cafiles as $filename) { - if (file_exists($filename)) { - return $cached = $filename; - } - } - - throw new \RuntimeException(<<< EOT -No system CA bundle could be found in any of the the common system locations. -PHP versions earlier than 5.6 are not properly configured to use the system's -CA bundle by default. In order to verify peer certificates, you will need to -supply the path on disk to a certificate bundle to the 'verify' request -option: http://docs.guzzlephp.org/en/latest/clients.html#verify. If you do not -need a specific certificate bundle, then Mozilla provides a commonly used CA -bundle which can be downloaded here (provided by the maintainer of cURL): -https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt. Once -you have a CA bundle available on disk, you can set the 'openssl.cafile' PHP -ini setting to point to the path to the file, allowing you to omit the 'verify' -request option. See http://curl.haxx.se/docs/sslcerts.html for more -information. -EOT - ); -} - -/** - * Creates an associative array of lowercase header names to the actual - * header casing. - * - * @param array $headers - * - * @return array - */ -function normalize_header_keys(array $headers) -{ - $result = []; - foreach (array_keys($headers) as $key) { - $result[strtolower($key)] = $key; - } - - return $result; -} - -/** - * Returns true if the provided host matches any of the no proxy areas. - * - * This method will strip a port from the host if it is present. Each pattern - * can be matched with an exact match (e.g., "foo.com" == "foo.com") or a - * partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" == - * "baz.foo.com", but ".foo.com" != "foo.com"). - * - * Areas are matched in the following cases: - * 1. "*" (without quotes) always matches any hosts. - * 2. An exact match. - * 3. The area starts with "." and the area is the last part of the host. e.g. - * '.mit.edu' will match any host that ends with '.mit.edu'. - * - * @param string $host Host to check against the patterns. - * @param array $noProxyArray An array of host patterns. - * - * @return bool - */ -function is_host_in_noproxy($host, array $noProxyArray) -{ - if (strlen($host) === 0) { - throw new \InvalidArgumentException('Empty host provided'); - } - - // Strip port if present. - if (strpos($host, ':')) { - $host = explode($host, ':', 2)[0]; - } - - foreach ($noProxyArray as $area) { - // Always match on wildcards. - if ($area === '*') { - return true; - } elseif (empty($area)) { - // Don't match on empty values. - continue; - } elseif ($area === $host) { - // Exact matches. - return true; - } else { - // Special match if the area when prefixed with ".". Remove any - // existing leading "." and add a new leading ".". - $area = '.' . ltrim($area, '.'); - if (substr($host, -(strlen($area))) === $area) { - return true; - } - } - } - - return false; -} - -/** - * Wrapper for json_decode that throws when an error occurs. - * - * @param string $json JSON data to parse - * @param bool $assoc When true, returned objects will be converted - * into associative arrays. - * @param int $depth User specified recursion depth. - * @param int $options Bitmask of JSON decode options. - * - * @return mixed - * @throws \InvalidArgumentException if the JSON cannot be decoded. - * @link http://www.php.net/manual/en/function.json-decode.php - */ -function json_decode($json, $assoc = false, $depth = 512, $options = 0) -{ - $data = \json_decode($json, $assoc, $depth, $options); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException( - 'json_decode error: ' . json_last_error_msg() - ); - } - - return $data; -} - -/** - * Wrapper for JSON encoding that throws when an error occurs. - * - * @param mixed $value The value being encoded - * @param int $options JSON encode option bitmask - * @param int $depth Set the maximum depth. Must be greater than zero. - * - * @return string - * @throws \InvalidArgumentException if the JSON cannot be encoded. - * @link http://www.php.net/manual/en/function.json-encode.php - */ -function json_encode($value, $options = 0, $depth = 512) -{ - $json = \json_encode($value, $options, $depth); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException( - 'json_encode error: ' . json_last_error_msg() - ); - } - - return $json; -} diff --git a/vendor/guzzlehttp/guzzle/src/functions_include.php b/vendor/guzzlehttp/guzzle/src/functions_include.php deleted file mode 100755 index a93393acc4e7c5e6021f070ad65dbbf2e3924241..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/guzzle/src/functions_include.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php - -// Don't redefine the functions if included multiple times. -if (!function_exists('GuzzleHttp\uri_template')) { - require __DIR__ . '/functions.php'; -} diff --git a/vendor/guzzlehttp/promises/CHANGELOG.md b/vendor/guzzlehttp/promises/CHANGELOG.md deleted file mode 100755 index 551929f6bd5ad98911da0dc6bb279f8861ec6b7f..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/CHANGELOG.md +++ /dev/null @@ -1,65 +0,0 @@ -# CHANGELOG - - -## 1.3.1 - 2016-12-20 - -### Fixed - -- `wait()` foreign promise compatibility - - -## 1.3.0 - 2016-11-18 - -### Added - -- Adds support for custom task queues. - -### Fixed - -- Fixed coroutine promise memory leak. - - -## 1.2.0 - 2016-05-18 - -### Changed - -- Update to now catch `\Throwable` on PHP 7+ - - -## 1.1.0 - 2016-03-07 - -### Changed - -- Update EachPromise to prevent recurring on a iterator when advancing, as this - could trigger fatal generator errors. -- Update Promise to allow recursive waiting without unwrapping exceptions. - - -## 1.0.3 - 2015-10-15 - -### Changed - -- Update EachPromise to immediately resolve when the underlying promise iterator - is empty. Previously, such a promise would throw an exception when its `wait` - function was called. - - -## 1.0.2 - 2015-05-15 - -### Changed - -- Conditionally require functions.php. - - -## 1.0.1 - 2015-06-24 - -### Changed - -- Updating EachPromise to call next on the underlying promise iterator as late - as possible to ensure that generators that generate new requests based on - callbacks are not iterated until after callbacks are invoked. - - -## 1.0.0 - 2015-05-12 - -- Initial release diff --git a/vendor/guzzlehttp/promises/LICENSE b/vendor/guzzlehttp/promises/LICENSE deleted file mode 100755 index 67f91a14c0057818f23322c77e80daa80ae9d751..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015-2016 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/guzzlehttp/promises/Makefile b/vendor/guzzlehttp/promises/Makefile deleted file mode 100755 index 8d5b3ef95eb4679a3998176bcc96fa88f5d60cdd..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -all: clean test - -test: - vendor/bin/phpunit - -coverage: - vendor/bin/phpunit --coverage-html=artifacts/coverage - -view-coverage: - open artifacts/coverage/index.html - -clean: - rm -rf artifacts/* diff --git a/vendor/guzzlehttp/promises/README.md b/vendor/guzzlehttp/promises/README.md deleted file mode 100755 index 7b607e28b13bfdd4f9b784082ef4ef20169e4458..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/README.md +++ /dev/null @@ -1,504 +0,0 @@ -# Guzzle Promises - -[Promises/A+](https://promisesaplus.com/) implementation that handles promise -chaining and resolution iteratively, allowing for "infinite" promise chaining -while keeping the stack size constant. Read [this blog post](https://blog.domenic.me/youre-missing-the-point-of-promises/) -for a general introduction to promises. - -- [Features](#features) -- [Quick start](#quick-start) -- [Synchronous wait](#synchronous-wait) -- [Cancellation](#cancellation) -- [API](#api) - - [Promise](#promise) - - [FulfilledPromise](#fulfilledpromise) - - [RejectedPromise](#rejectedpromise) -- [Promise interop](#promise-interop) -- [Implementation notes](#implementation-notes) - - -# Features - -- [Promises/A+](https://promisesaplus.com/) implementation. -- Promise resolution and chaining is handled iteratively, allowing for - "infinite" promise chaining. -- Promises have a synchronous `wait` method. -- Promises can be cancelled. -- Works with any object that has a `then` function. -- C# style async/await coroutine promises using - `GuzzleHttp\Promise\coroutine()`. - - -# Quick start - -A *promise* represents the eventual result of an asynchronous operation. The -primary way of interacting with a promise is through its `then` method, which -registers callbacks to receive either a promise's eventual value or the reason -why the promise cannot be fulfilled. - - -## Callbacks - -Callbacks are registered with the `then` method by providing an optional -`$onFulfilled` followed by an optional `$onRejected` function. - - -```php -use GuzzleHttp\Promise\Promise; - -$promise = new Promise(); -$promise->then( - // $onFulfilled - function ($value) { - echo 'The promise was fulfilled.'; - }, - // $onRejected - function ($reason) { - echo 'The promise was rejected.'; - } -); -``` - -*Resolving* a promise means that you either fulfill a promise with a *value* or -reject a promise with a *reason*. Resolving a promises triggers callbacks -registered with the promises's `then` method. These callbacks are triggered -only once and in the order in which they were added. - - -## Resolving a promise - -Promises are fulfilled using the `resolve($value)` method. Resolving a promise -with any value other than a `GuzzleHttp\Promise\RejectedPromise` will trigger -all of the onFulfilled callbacks (resolving a promise with a rejected promise -will reject the promise and trigger the `$onRejected` callbacks). - -```php -use GuzzleHttp\Promise\Promise; - -$promise = new Promise(); -$promise - ->then(function ($value) { - // Return a value and don't break the chain - return "Hello, " . $value; - }) - // This then is executed after the first then and receives the value - // returned from the first then. - ->then(function ($value) { - echo $value; - }); - -// Resolving the promise triggers the $onFulfilled callbacks and outputs -// "Hello, reader". -$promise->resolve('reader.'); -``` - - -## Promise forwarding - -Promises can be chained one after the other. Each then in the chain is a new -promise. The return value of a promise is what's forwarded to the next -promise in the chain. Returning a promise in a `then` callback will cause the -subsequent promises in the chain to only be fulfilled when the returned promise -has been fulfilled. The next promise in the chain will be invoked with the -resolved value of the promise. - -```php -use GuzzleHttp\Promise\Promise; - -$promise = new Promise(); -$nextPromise = new Promise(); - -$promise - ->then(function ($value) use ($nextPromise) { - echo $value; - return $nextPromise; - }) - ->then(function ($value) { - echo $value; - }); - -// Triggers the first callback and outputs "A" -$promise->resolve('A'); -// Triggers the second callback and outputs "B" -$nextPromise->resolve('B'); -``` - -## Promise rejection - -When a promise is rejected, the `$onRejected` callbacks are invoked with the -rejection reason. - -```php -use GuzzleHttp\Promise\Promise; - -$promise = new Promise(); -$promise->then(null, function ($reason) { - echo $reason; -}); - -$promise->reject('Error!'); -// Outputs "Error!" -``` - -## Rejection forwarding - -If an exception is thrown in an `$onRejected` callback, subsequent -`$onRejected` callbacks are invoked with the thrown exception as the reason. - -```php -use GuzzleHttp\Promise\Promise; - -$promise = new Promise(); -$promise->then(null, function ($reason) { - throw new \Exception($reason); -})->then(null, function ($reason) { - assert($reason->getMessage() === 'Error!'); -}); - -$promise->reject('Error!'); -``` - -You can also forward a rejection down the promise chain by returning a -`GuzzleHttp\Promise\RejectedPromise` in either an `$onFulfilled` or -`$onRejected` callback. - -```php -use GuzzleHttp\Promise\Promise; -use GuzzleHttp\Promise\RejectedPromise; - -$promise = new Promise(); -$promise->then(null, function ($reason) { - return new RejectedPromise($reason); -})->then(null, function ($reason) { - assert($reason === 'Error!'); -}); - -$promise->reject('Error!'); -``` - -If an exception is not thrown in a `$onRejected` callback and the callback -does not return a rejected promise, downstream `$onFulfilled` callbacks are -invoked using the value returned from the `$onRejected` callback. - -```php -use GuzzleHttp\Promise\Promise; -use GuzzleHttp\Promise\RejectedPromise; - -$promise = new Promise(); -$promise - ->then(null, function ($reason) { - return "It's ok"; - }) - ->then(function ($value) { - assert($value === "It's ok"); - }); - -$promise->reject('Error!'); -``` - -# Synchronous wait - -You can synchronously force promises to complete using a promise's `wait` -method. When creating a promise, you can provide a wait function that is used -to synchronously force a promise to complete. When a wait function is invoked -it is expected to deliver a value to the promise or reject the promise. If the -wait function does not deliver a value, then an exception is thrown. The wait -function provided to a promise constructor is invoked when the `wait` function -of the promise is called. - -```php -$promise = new Promise(function () use (&$promise) { - $promise->resolve('foo'); -}); - -// Calling wait will return the value of the promise. -echo $promise->wait(); // outputs "foo" -``` - -If an exception is encountered while invoking the wait function of a promise, -the promise is rejected with the exception and the exception is thrown. - -```php -$promise = new Promise(function () use (&$promise) { - throw new \Exception('foo'); -}); - -$promise->wait(); // throws the exception. -``` - -Calling `wait` on a promise that has been fulfilled will not trigger the wait -function. It will simply return the previously resolved value. - -```php -$promise = new Promise(function () { die('this is not called!'); }); -$promise->resolve('foo'); -echo $promise->wait(); // outputs "foo" -``` - -Calling `wait` on a promise that has been rejected will throw an exception. If -the rejection reason is an instance of `\Exception` the reason is thrown. -Otherwise, a `GuzzleHttp\Promise\RejectionException` is thrown and the reason -can be obtained by calling the `getReason` method of the exception. - -```php -$promise = new Promise(); -$promise->reject('foo'); -$promise->wait(); -``` - -> PHP Fatal error: Uncaught exception 'GuzzleHttp\Promise\RejectionException' with message 'The promise was rejected with value: foo' - - -## Unwrapping a promise - -When synchronously waiting on a promise, you are joining the state of the -promise into the current state of execution (i.e., return the value of the -promise if it was fulfilled or throw an exception if it was rejected). This is -called "unwrapping" the promise. Waiting on a promise will by default unwrap -the promise state. - -You can force a promise to resolve and *not* unwrap the state of the promise -by passing `false` to the first argument of the `wait` function: - -```php -$promise = new Promise(); -$promise->reject('foo'); -// This will not throw an exception. It simply ensures the promise has -// been resolved. -$promise->wait(false); -``` - -When unwrapping a promise, the resolved value of the promise will be waited -upon until the unwrapped value is not a promise. This means that if you resolve -promise A with a promise B and unwrap promise A, the value returned by the -wait function will be the value delivered to promise B. - -**Note**: when you do not unwrap the promise, no value is returned. - - -# Cancellation - -You can cancel a promise that has not yet been fulfilled using the `cancel()` -method of a promise. When creating a promise you can provide an optional -cancel function that when invoked cancels the action of computing a resolution -of the promise. - - -# API - - -## Promise - -When creating a promise object, you can provide an optional `$waitFn` and -`$cancelFn`. `$waitFn` is a function that is invoked with no arguments and is -expected to resolve the promise. `$cancelFn` is a function with no arguments -that is expected to cancel the computation of a promise. It is invoked when the -`cancel()` method of a promise is called. - -```php -use GuzzleHttp\Promise\Promise; - -$promise = new Promise( - function () use (&$promise) { - $promise->resolve('waited'); - }, - function () { - // do something that will cancel the promise computation (e.g., close - // a socket, cancel a database query, etc...) - } -); - -assert('waited' === $promise->wait()); -``` - -A promise has the following methods: - -- `then(callable $onFulfilled, callable $onRejected) : PromiseInterface` - - Appends fulfillment and rejection handlers to the promise, and returns a new promise resolving to the return value of the called handler. - -- `otherwise(callable $onRejected) : PromiseInterface` - - Appends a rejection handler callback to the promise, and returns a new promise resolving to the return value of the callback if it is called, or to its original fulfillment value if the promise is instead fulfilled. - -- `wait($unwrap = true) : mixed` - - Synchronously waits on the promise to complete. - - `$unwrap` controls whether or not the value of the promise is returned for a - fulfilled promise or if an exception is thrown if the promise is rejected. - This is set to `true` by default. - -- `cancel()` - - Attempts to cancel the promise if possible. The promise being cancelled and - the parent most ancestor that has not yet been resolved will also be - cancelled. Any promises waiting on the cancelled promise to resolve will also - be cancelled. - -- `getState() : string` - - Returns the state of the promise. One of `pending`, `fulfilled`, or - `rejected`. - -- `resolve($value)` - - Fulfills the promise with the given `$value`. - -- `reject($reason)` - - Rejects the promise with the given `$reason`. - - -## FulfilledPromise - -A fulfilled promise can be created to represent a promise that has been -fulfilled. - -```php -use GuzzleHttp\Promise\FulfilledPromise; - -$promise = new FulfilledPromise('value'); - -// Fulfilled callbacks are immediately invoked. -$promise->then(function ($value) { - echo $value; -}); -``` - - -## RejectedPromise - -A rejected promise can be created to represent a promise that has been -rejected. - -```php -use GuzzleHttp\Promise\RejectedPromise; - -$promise = new RejectedPromise('Error'); - -// Rejected callbacks are immediately invoked. -$promise->then(null, function ($reason) { - echo $reason; -}); -``` - - -# Promise interop - -This library works with foreign promises that have a `then` method. This means -you can use Guzzle promises with [React promises](https://github.com/reactphp/promise) -for example. When a foreign promise is returned inside of a then method -callback, promise resolution will occur recursively. - -```php -// Create a React promise -$deferred = new React\Promise\Deferred(); -$reactPromise = $deferred->promise(); - -// Create a Guzzle promise that is fulfilled with a React promise. -$guzzlePromise = new \GuzzleHttp\Promise\Promise(); -$guzzlePromise->then(function ($value) use ($reactPromise) { - // Do something something with the value... - // Return the React promise - return $reactPromise; -}); -``` - -Please note that wait and cancel chaining is no longer possible when forwarding -a foreign promise. You will need to wrap a third-party promise with a Guzzle -promise in order to utilize wait and cancel functions with foreign promises. - - -## Event Loop Integration - -In order to keep the stack size constant, Guzzle promises are resolved -asynchronously using a task queue. When waiting on promises synchronously, the -task queue will be automatically run to ensure that the blocking promise and -any forwarded promises are resolved. When using promises asynchronously in an -event loop, you will need to run the task queue on each tick of the loop. If -you do not run the task queue, then promises will not be resolved. - -You can run the task queue using the `run()` method of the global task queue -instance. - -```php -// Get the global task queue -$queue = \GuzzleHttp\Promise\queue(); -$queue->run(); -``` - -For example, you could use Guzzle promises with React using a periodic timer: - -```php -$loop = React\EventLoop\Factory::create(); -$loop->addPeriodicTimer(0, [$queue, 'run']); -``` - -*TODO*: Perhaps adding a `futureTick()` on each tick would be faster? - - -# Implementation notes - - -## Promise resolution and chaining is handled iteratively - -By shuffling pending handlers from one owner to another, promises are -resolved iteratively, allowing for "infinite" then chaining. - -```php -<?php -require 'vendor/autoload.php'; - -use GuzzleHttp\Promise\Promise; - -$parent = new Promise(); -$p = $parent; - -for ($i = 0; $i < 1000; $i++) { - $p = $p->then(function ($v) { - // The stack size remains constant (a good thing) - echo xdebug_get_stack_depth() . ', '; - return $v + 1; - }); -} - -$parent->resolve(0); -var_dump($p->wait()); // int(1000) - -``` - -When a promise is fulfilled or rejected with a non-promise value, the promise -then takes ownership of the handlers of each child promise and delivers values -down the chain without using recursion. - -When a promise is resolved with another promise, the original promise transfers -all of its pending handlers to the new promise. When the new promise is -eventually resolved, all of the pending handlers are delivered the forwarded -value. - - -## A promise is the deferred. - -Some promise libraries implement promises using a deferred object to represent -a computation and a promise object to represent the delivery of the result of -the computation. This is a nice separation of computation and delivery because -consumers of the promise cannot modify the value that will be eventually -delivered. - -One side effect of being able to implement promise resolution and chaining -iteratively is that you need to be able for one promise to reach into the state -of another promise to shuffle around ownership of handlers. In order to achieve -this without making the handlers of a promise publicly mutable, a promise is -also the deferred value, allowing promises of the same parent class to reach -into and modify the private properties of promises of the same type. While this -does allow consumers of the value to modify the resolution or rejection of the -deferred, it is a small price to pay for keeping the stack size constant. - -```php -$promise = new Promise(); -$promise->then(function ($value) { echo $value; }); -// The promise is the deferred value, so you can deliver a value to it. -$promise->resolve('foo'); -// prints "foo" -``` diff --git a/vendor/guzzlehttp/promises/composer.json b/vendor/guzzlehttp/promises/composer.json deleted file mode 100755 index ec41a61e6e8765924b0caeb2c29671e96b061c07..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/composer.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "guzzlehttp/promises", - "description": "Guzzle promises library", - "keywords": ["promise"], - "license": "MIT", - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "require": { - "php": ">=5.5.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0" - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - }, - "files": ["src/functions_include.php"] - }, - "scripts": { - "test": "vendor/bin/phpunit", - "test-ci": "vendor/bin/phpunit --coverage-text" - }, - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - } -} diff --git a/vendor/guzzlehttp/promises/src/AggregateException.php b/vendor/guzzlehttp/promises/src/AggregateException.php deleted file mode 100755 index 6a5690c3762224eb73a6555b128074dd185d58bf..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/src/AggregateException.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php -namespace GuzzleHttp\Promise; - -/** - * Exception thrown when too many errors occur in the some() or any() methods. - */ -class AggregateException extends RejectionException -{ - public function __construct($msg, array $reasons) - { - parent::__construct( - $reasons, - sprintf('%s; %d rejected promises', $msg, count($reasons)) - ); - } -} diff --git a/vendor/guzzlehttp/promises/src/CancellationException.php b/vendor/guzzlehttp/promises/src/CancellationException.php deleted file mode 100755 index cb360b8056abbf065ea27ef93a4e2fe895b3989f..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/src/CancellationException.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php -namespace GuzzleHttp\Promise; - -/** - * Exception that is set as the reason for a promise that has been cancelled. - */ -class CancellationException extends RejectionException -{ -} diff --git a/vendor/guzzlehttp/promises/src/Coroutine.php b/vendor/guzzlehttp/promises/src/Coroutine.php deleted file mode 100755 index 6aa095870224617d89b5f82d949e3dcb375a9dc3..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/src/Coroutine.php +++ /dev/null @@ -1,151 +0,0 @@ -<?php -namespace GuzzleHttp\Promise; - -use Exception; -use Generator; -use Throwable; - -/** - * Creates a promise that is resolved using a generator that yields values or - * promises (somewhat similar to C#'s async keyword). - * - * When called, the coroutine function will start an instance of the generator - * and returns a promise that is fulfilled with its final yielded value. - * - * Control is returned back to the generator when the yielded promise settles. - * This can lead to less verbose code when doing lots of sequential async calls - * with minimal processing in between. - * - * use GuzzleHttp\Promise; - * - * function createPromise($value) { - * return new Promise\FulfilledPromise($value); - * } - * - * $promise = Promise\coroutine(function () { - * $value = (yield createPromise('a')); - * try { - * $value = (yield createPromise($value . 'b')); - * } catch (\Exception $e) { - * // The promise was rejected. - * } - * yield $value . 'c'; - * }); - * - * // Outputs "abc" - * $promise->then(function ($v) { echo $v; }); - * - * @param callable $generatorFn Generator function to wrap into a promise. - * - * @return Promise - * @link https://github.com/petkaantonov/bluebird/blob/master/API.md#generators inspiration - */ -final class Coroutine implements PromiseInterface -{ - /** - * @var PromiseInterface|null - */ - private $currentPromise; - - /** - * @var Generator - */ - private $generator; - - /** - * @var Promise - */ - private $result; - - public function __construct(callable $generatorFn) - { - $this->generator = $generatorFn(); - $this->result = new Promise(function () { - while (isset($this->currentPromise)) { - $this->currentPromise->wait(); - } - }); - $this->nextCoroutine($this->generator->current()); - } - - public function then( - callable $onFulfilled = null, - callable $onRejected = null - ) { - return $this->result->then($onFulfilled, $onRejected); - } - - public function otherwise(callable $onRejected) - { - return $this->result->otherwise($onRejected); - } - - public function wait($unwrap = true) - { - return $this->result->wait($unwrap); - } - - public function getState() - { - return $this->result->getState(); - } - - public function resolve($value) - { - $this->result->resolve($value); - } - - public function reject($reason) - { - $this->result->reject($reason); - } - - public function cancel() - { - $this->currentPromise->cancel(); - $this->result->cancel(); - } - - private function nextCoroutine($yielded) - { - $this->currentPromise = promise_for($yielded) - ->then([$this, '_handleSuccess'], [$this, '_handleFailure']); - } - - /** - * @internal - */ - public function _handleSuccess($value) - { - unset($this->currentPromise); - try { - $next = $this->generator->send($value); - if ($this->generator->valid()) { - $this->nextCoroutine($next); - } else { - $this->result->resolve($value); - } - } catch (Exception $exception) { - $this->result->reject($exception); - } catch (Throwable $throwable) { - $this->result->reject($throwable); - } - } - - /** - * @internal - */ - public function _handleFailure($reason) - { - unset($this->currentPromise); - try { - $nextYield = $this->generator->throw(exception_for($reason)); - // The throw was caught, so keep iterating on the coroutine - $this->nextCoroutine($nextYield); - } catch (Exception $exception) { - $this->result->reject($exception); - } catch (Throwable $throwable) { - $this->result->reject($throwable); - } - } -} diff --git a/vendor/guzzlehttp/promises/src/EachPromise.php b/vendor/guzzlehttp/promises/src/EachPromise.php deleted file mode 100755 index d0ddf603fb3d566bc90a7f711b0723b876782983..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/src/EachPromise.php +++ /dev/null @@ -1,229 +0,0 @@ -<?php -namespace GuzzleHttp\Promise; - -/** - * Represents a promise that iterates over many promises and invokes - * side-effect functions in the process. - */ -class EachPromise implements PromisorInterface -{ - private $pending = []; - - /** @var \Iterator */ - private $iterable; - - /** @var callable|int */ - private $concurrency; - - /** @var callable */ - private $onFulfilled; - - /** @var callable */ - private $onRejected; - - /** @var Promise */ - private $aggregate; - - /** @var bool */ - private $mutex; - - /** - * Configuration hash can include the following key value pairs: - * - * - fulfilled: (callable) Invoked when a promise fulfills. The function - * is invoked with three arguments: the fulfillment value, the index - * position from the iterable list of the promise, and the aggregate - * promise that manages all of the promises. The aggregate promise may - * be resolved from within the callback to short-circuit the promise. - * - rejected: (callable) Invoked when a promise is rejected. The - * function is invoked with three arguments: the rejection reason, the - * index position from the iterable list of the promise, and the - * aggregate promise that manages all of the promises. The aggregate - * promise may be resolved from within the callback to short-circuit - * the promise. - * - concurrency: (integer) Pass this configuration option to limit the - * allowed number of outstanding concurrently executing promises, - * creating a capped pool of promises. There is no limit by default. - * - * @param mixed $iterable Promises or values to iterate. - * @param array $config Configuration options - */ - public function __construct($iterable, array $config = []) - { - $this->iterable = iter_for($iterable); - - if (isset($config['concurrency'])) { - $this->concurrency = $config['concurrency']; - } - - if (isset($config['fulfilled'])) { - $this->onFulfilled = $config['fulfilled']; - } - - if (isset($config['rejected'])) { - $this->onRejected = $config['rejected']; - } - } - - public function promise() - { - if ($this->aggregate) { - return $this->aggregate; - } - - try { - $this->createPromise(); - $this->iterable->rewind(); - $this->refillPending(); - } catch (\Throwable $e) { - $this->aggregate->reject($e); - } catch (\Exception $e) { - $this->aggregate->reject($e); - } - - return $this->aggregate; - } - - private function createPromise() - { - $this->mutex = false; - $this->aggregate = new Promise(function () { - reset($this->pending); - if (empty($this->pending) && !$this->iterable->valid()) { - $this->aggregate->resolve(null); - return; - } - - // Consume a potentially fluctuating list of promises while - // ensuring that indexes are maintained (precluding array_shift). - while ($promise = current($this->pending)) { - next($this->pending); - $promise->wait(); - if ($this->aggregate->getState() !== PromiseInterface::PENDING) { - return; - } - } - }); - - // Clear the references when the promise is resolved. - $clearFn = function () { - $this->iterable = $this->concurrency = $this->pending = null; - $this->onFulfilled = $this->onRejected = null; - }; - - $this->aggregate->then($clearFn, $clearFn); - } - - private function refillPending() - { - if (!$this->concurrency) { - // Add all pending promises. - while ($this->addPending() && $this->advanceIterator()); - return; - } - - // Add only up to N pending promises. - $concurrency = is_callable($this->concurrency) - ? call_user_func($this->concurrency, count($this->pending)) - : $this->concurrency; - $concurrency = max($concurrency - count($this->pending), 0); - // Concurrency may be set to 0 to disallow new promises. - if (!$concurrency) { - return; - } - // Add the first pending promise. - $this->addPending(); - // Note this is special handling for concurrency=1 so that we do - // not advance the iterator after adding the first promise. This - // helps work around issues with generators that might not have the - // next value to yield until promise callbacks are called. - while (--$concurrency - && $this->advanceIterator() - && $this->addPending()); - } - - private function addPending() - { - if (!$this->iterable || !$this->iterable->valid()) { - return false; - } - - $promise = promise_for($this->iterable->current()); - $idx = $this->iterable->key(); - - $this->pending[$idx] = $promise->then( - function ($value) use ($idx) { - if ($this->onFulfilled) { - call_user_func( - $this->onFulfilled, $value, $idx, $this->aggregate - ); - } - $this->step($idx); - }, - function ($reason) use ($idx) { - if ($this->onRejected) { - call_user_func( - $this->onRejected, $reason, $idx, $this->aggregate - ); - } - $this->step($idx); - } - ); - - return true; - } - - private function advanceIterator() - { - // Place a lock on the iterator so that we ensure to not recurse, - // preventing fatal generator errors. - if ($this->mutex) { - return false; - } - - $this->mutex = true; - - try { - $this->iterable->next(); - $this->mutex = false; - return true; - } catch (\Throwable $e) { - $this->aggregate->reject($e); - $this->mutex = false; - return false; - } catch (\Exception $e) { - $this->aggregate->reject($e); - $this->mutex = false; - return false; - } - } - - private function step($idx) - { - // If the promise was already resolved, then ignore this step. - if ($this->aggregate->getState() !== PromiseInterface::PENDING) { - return; - } - - unset($this->pending[$idx]); - - // Only refill pending promises if we are not locked, preventing the - // EachPromise to recursively invoke the provided iterator, which - // cause a fatal error: "Cannot resume an already running generator" - if ($this->advanceIterator() && !$this->checkIfFinished()) { - // Add more pending promises if possible. - $this->refillPending(); - } - } - - private function checkIfFinished() - { - if (!$this->pending && !$this->iterable->valid()) { - // Resolve the promise if there's nothing left to do. - $this->aggregate->resolve(null); - return true; - } - - return false; - } -} diff --git a/vendor/guzzlehttp/promises/src/FulfilledPromise.php b/vendor/guzzlehttp/promises/src/FulfilledPromise.php deleted file mode 100755 index dbbeeb9f71b2927a66057c5ac34d1a9b9d356183..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/src/FulfilledPromise.php +++ /dev/null @@ -1,82 +0,0 @@ -<?php -namespace GuzzleHttp\Promise; - -/** - * A promise that has been fulfilled. - * - * Thenning off of this promise will invoke the onFulfilled callback - * immediately and ignore other callbacks. - */ -class FulfilledPromise implements PromiseInterface -{ - private $value; - - public function __construct($value) - { - if (method_exists($value, 'then')) { - throw new \InvalidArgumentException( - 'You cannot create a FulfilledPromise with a promise.'); - } - - $this->value = $value; - } - - public function then( - callable $onFulfilled = null, - callable $onRejected = null - ) { - // Return itself if there is no onFulfilled function. - if (!$onFulfilled) { - return $this; - } - - $queue = queue(); - $p = new Promise([$queue, 'run']); - $value = $this->value; - $queue->add(static function () use ($p, $value, $onFulfilled) { - if ($p->getState() === self::PENDING) { - try { - $p->resolve($onFulfilled($value)); - } catch (\Throwable $e) { - $p->reject($e); - } catch (\Exception $e) { - $p->reject($e); - } - } - }); - - return $p; - } - - public function otherwise(callable $onRejected) - { - return $this->then(null, $onRejected); - } - - public function wait($unwrap = true, $defaultDelivery = null) - { - return $unwrap ? $this->value : null; - } - - public function getState() - { - return self::FULFILLED; - } - - public function resolve($value) - { - if ($value !== $this->value) { - throw new \LogicException("Cannot resolve a fulfilled promise"); - } - } - - public function reject($reason) - { - throw new \LogicException("Cannot reject a fulfilled promise"); - } - - public function cancel() - { - // pass - } -} diff --git a/vendor/guzzlehttp/promises/src/Promise.php b/vendor/guzzlehttp/promises/src/Promise.php deleted file mode 100755 index 844ada073c808ce92dfcf3a5a66a010586cec9b3..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/src/Promise.php +++ /dev/null @@ -1,280 +0,0 @@ -<?php -namespace GuzzleHttp\Promise; - -/** - * Promises/A+ implementation that avoids recursion when possible. - * - * @link https://promisesaplus.com/ - */ -class Promise implements PromiseInterface -{ - private $state = self::PENDING; - private $result; - private $cancelFn; - private $waitFn; - private $waitList; - private $handlers = []; - - /** - * @param callable $waitFn Fn that when invoked resolves the promise. - * @param callable $cancelFn Fn that when invoked cancels the promise. - */ - public function __construct( - callable $waitFn = null, - callable $cancelFn = null - ) { - $this->waitFn = $waitFn; - $this->cancelFn = $cancelFn; - } - - public function then( - callable $onFulfilled = null, - callable $onRejected = null - ) { - if ($this->state === self::PENDING) { - $p = new Promise(null, [$this, 'cancel']); - $this->handlers[] = [$p, $onFulfilled, $onRejected]; - $p->waitList = $this->waitList; - $p->waitList[] = $this; - return $p; - } - - // Return a fulfilled promise and immediately invoke any callbacks. - if ($this->state === self::FULFILLED) { - return $onFulfilled - ? promise_for($this->result)->then($onFulfilled) - : promise_for($this->result); - } - - // It's either cancelled or rejected, so return a rejected promise - // and immediately invoke any callbacks. - $rejection = rejection_for($this->result); - return $onRejected ? $rejection->then(null, $onRejected) : $rejection; - } - - public function otherwise(callable $onRejected) - { - return $this->then(null, $onRejected); - } - - public function wait($unwrap = true) - { - $this->waitIfPending(); - - $inner = $this->result instanceof PromiseInterface - ? $this->result->wait($unwrap) - : $this->result; - - if ($unwrap) { - if ($this->result instanceof PromiseInterface - || $this->state === self::FULFILLED - ) { - return $inner; - } else { - // It's rejected so "unwrap" and throw an exception. - throw exception_for($inner); - } - } - } - - public function getState() - { - return $this->state; - } - - public function cancel() - { - if ($this->state !== self::PENDING) { - return; - } - - $this->waitFn = $this->waitList = null; - - if ($this->cancelFn) { - $fn = $this->cancelFn; - $this->cancelFn = null; - try { - $fn(); - } catch (\Throwable $e) { - $this->reject($e); - } catch (\Exception $e) { - $this->reject($e); - } - } - - // Reject the promise only if it wasn't rejected in a then callback. - if ($this->state === self::PENDING) { - $this->reject(new CancellationException('Promise has been cancelled')); - } - } - - public function resolve($value) - { - $this->settle(self::FULFILLED, $value); - } - - public function reject($reason) - { - $this->settle(self::REJECTED, $reason); - } - - private function settle($state, $value) - { - if ($this->state !== self::PENDING) { - // Ignore calls with the same resolution. - if ($state === $this->state && $value === $this->result) { - return; - } - throw $this->state === $state - ? new \LogicException("The promise is already {$state}.") - : new \LogicException("Cannot change a {$this->state} promise to {$state}"); - } - - if ($value === $this) { - throw new \LogicException('Cannot fulfill or reject a promise with itself'); - } - - // Clear out the state of the promise but stash the handlers. - $this->state = $state; - $this->result = $value; - $handlers = $this->handlers; - $this->handlers = null; - $this->waitList = $this->waitFn = null; - $this->cancelFn = null; - - if (!$handlers) { - return; - } - - // If the value was not a settled promise or a thenable, then resolve - // it in the task queue using the correct ID. - if (!method_exists($value, 'then')) { - $id = $state === self::FULFILLED ? 1 : 2; - // It's a success, so resolve the handlers in the queue. - queue()->add(static function () use ($id, $value, $handlers) { - foreach ($handlers as $handler) { - self::callHandler($id, $value, $handler); - } - }); - } elseif ($value instanceof Promise - && $value->getState() === self::PENDING - ) { - // We can just merge our handlers onto the next promise. - $value->handlers = array_merge($value->handlers, $handlers); - } else { - // Resolve the handlers when the forwarded promise is resolved. - $value->then( - static function ($value) use ($handlers) { - foreach ($handlers as $handler) { - self::callHandler(1, $value, $handler); - } - }, - static function ($reason) use ($handlers) { - foreach ($handlers as $handler) { - self::callHandler(2, $reason, $handler); - } - } - ); - } - } - - /** - * Call a stack of handlers using a specific callback index and value. - * - * @param int $index 1 (resolve) or 2 (reject). - * @param mixed $value Value to pass to the callback. - * @param array $handler Array of handler data (promise and callbacks). - * - * @return array Returns the next group to resolve. - */ - private static function callHandler($index, $value, array $handler) - { - /** @var PromiseInterface $promise */ - $promise = $handler[0]; - - // The promise may have been cancelled or resolved before placing - // this thunk in the queue. - if ($promise->getState() !== self::PENDING) { - return; - } - - try { - if (isset($handler[$index])) { - $promise->resolve($handler[$index]($value)); - } elseif ($index === 1) { - // Forward resolution values as-is. - $promise->resolve($value); - } else { - // Forward rejections down the chain. - $promise->reject($value); - } - } catch (\Throwable $reason) { - $promise->reject($reason); - } catch (\Exception $reason) { - $promise->reject($reason); - } - } - - private function waitIfPending() - { - if ($this->state !== self::PENDING) { - return; - } elseif ($this->waitFn) { - $this->invokeWaitFn(); - } elseif ($this->waitList) { - $this->invokeWaitList(); - } else { - // If there's not wait function, then reject the promise. - $this->reject('Cannot wait on a promise that has ' - . 'no internal wait function. You must provide a wait ' - . 'function when constructing the promise to be able to ' - . 'wait on a promise.'); - } - - queue()->run(); - - if ($this->state === self::PENDING) { - $this->reject('Invoking the wait callback did not resolve the promise'); - } - } - - private function invokeWaitFn() - { - try { - $wfn = $this->waitFn; - $this->waitFn = null; - $wfn(true); - } catch (\Exception $reason) { - if ($this->state === self::PENDING) { - // The promise has not been resolved yet, so reject the promise - // with the exception. - $this->reject($reason); - } else { - // The promise was already resolved, so there's a problem in - // the application. - throw $reason; - } - } - } - - private function invokeWaitList() - { - $waitList = $this->waitList; - $this->waitList = null; - - foreach ($waitList as $result) { - while (true) { - $result->waitIfPending(); - - if ($result->result instanceof Promise) { - $result = $result->result; - } else { - if ($result->result instanceof PromiseInterface) { - $result->result->wait(false); - } - break; - } - } - } - } -} diff --git a/vendor/guzzlehttp/promises/src/PromiseInterface.php b/vendor/guzzlehttp/promises/src/PromiseInterface.php deleted file mode 100755 index 8f5f4b99b26c64c7e4177e537e13a2703ca56a6d..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/src/PromiseInterface.php +++ /dev/null @@ -1,93 +0,0 @@ -<?php -namespace GuzzleHttp\Promise; - -/** - * A promise represents the eventual result of an asynchronous operation. - * - * The primary way of interacting with a promise is through its then method, - * which registers callbacks to receive either a promise’s eventual value or - * the reason why the promise cannot be fulfilled. - * - * @link https://promisesaplus.com/ - */ -interface PromiseInterface -{ - const PENDING = 'pending'; - const FULFILLED = 'fulfilled'; - const REJECTED = 'rejected'; - - /** - * Appends fulfillment and rejection handlers to the promise, and returns - * a new promise resolving to the return value of the called handler. - * - * @param callable $onFulfilled Invoked when the promise fulfills. - * @param callable $onRejected Invoked when the promise is rejected. - * - * @return PromiseInterface - */ - public function then( - callable $onFulfilled = null, - callable $onRejected = null - ); - - /** - * Appends a rejection handler callback to the promise, and returns a new - * promise resolving to the return value of the callback if it is called, - * or to its original fulfillment value if the promise is instead - * fulfilled. - * - * @param callable $onRejected Invoked when the promise is rejected. - * - * @return PromiseInterface - */ - public function otherwise(callable $onRejected); - - /** - * Get the state of the promise ("pending", "rejected", or "fulfilled"). - * - * The three states can be checked against the constants defined on - * PromiseInterface: PENDING, FULFILLED, and REJECTED. - * - * @return string - */ - public function getState(); - - /** - * Resolve the promise with the given value. - * - * @param mixed $value - * @throws \RuntimeException if the promise is already resolved. - */ - public function resolve($value); - - /** - * Reject the promise with the given reason. - * - * @param mixed $reason - * @throws \RuntimeException if the promise is already resolved. - */ - public function reject($reason); - - /** - * Cancels the promise if possible. - * - * @link https://github.com/promises-aplus/cancellation-spec/issues/7 - */ - public function cancel(); - - /** - * Waits until the promise completes if possible. - * - * Pass $unwrap as true to unwrap the result of the promise, either - * returning the resolved value or throwing the rejected exception. - * - * If the promise cannot be waited on, then the promise will be rejected. - * - * @param bool $unwrap - * - * @return mixed - * @throws \LogicException if the promise has no wait function or if the - * promise does not settle after waiting. - */ - public function wait($unwrap = true); -} diff --git a/vendor/guzzlehttp/promises/src/PromisorInterface.php b/vendor/guzzlehttp/promises/src/PromisorInterface.php deleted file mode 100755 index b07fe32bc138c56fc393522434d852531012174e..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/src/PromisorInterface.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php -namespace GuzzleHttp\Promise; - -/** - * Interface used with classes that return a promise. - */ -interface PromisorInterface -{ - /** - * Returns a promise. - * - * @return PromiseInterface - */ - public function promise(); -} diff --git a/vendor/guzzlehttp/promises/src/RejectedPromise.php b/vendor/guzzlehttp/promises/src/RejectedPromise.php deleted file mode 100755 index 2bc6508e7b6faae653a076b8ba57c8e339a9fbad..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/src/RejectedPromise.php +++ /dev/null @@ -1,87 +0,0 @@ -<?php -namespace GuzzleHttp\Promise; - -/** - * A promise that has been rejected. - * - * Thenning off of this promise will invoke the onRejected callback - * immediately and ignore other callbacks. - */ -class RejectedPromise implements PromiseInterface -{ - private $reason; - - public function __construct($reason) - { - if (method_exists($reason, 'then')) { - throw new \InvalidArgumentException( - 'You cannot create a RejectedPromise with a promise.'); - } - - $this->reason = $reason; - } - - public function then( - callable $onFulfilled = null, - callable $onRejected = null - ) { - // If there's no onRejected callback then just return self. - if (!$onRejected) { - return $this; - } - - $queue = queue(); - $reason = $this->reason; - $p = new Promise([$queue, 'run']); - $queue->add(static function () use ($p, $reason, $onRejected) { - if ($p->getState() === self::PENDING) { - try { - // Return a resolved promise if onRejected does not throw. - $p->resolve($onRejected($reason)); - } catch (\Throwable $e) { - // onRejected threw, so return a rejected promise. - $p->reject($e); - } catch (\Exception $e) { - // onRejected threw, so return a rejected promise. - $p->reject($e); - } - } - }); - - return $p; - } - - public function otherwise(callable $onRejected) - { - return $this->then(null, $onRejected); - } - - public function wait($unwrap = true, $defaultDelivery = null) - { - if ($unwrap) { - throw exception_for($this->reason); - } - } - - public function getState() - { - return self::REJECTED; - } - - public function resolve($value) - { - throw new \LogicException("Cannot resolve a rejected promise"); - } - - public function reject($reason) - { - if ($reason !== $this->reason) { - throw new \LogicException("Cannot reject a rejected promise"); - } - } - - public function cancel() - { - // pass - } -} diff --git a/vendor/guzzlehttp/promises/src/RejectionException.php b/vendor/guzzlehttp/promises/src/RejectionException.php deleted file mode 100755 index 07c1136da166075fb7354548306b5755be8ceab2..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/src/RejectionException.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php -namespace GuzzleHttp\Promise; - -/** - * A special exception that is thrown when waiting on a rejected promise. - * - * The reason value is available via the getReason() method. - */ -class RejectionException extends \RuntimeException -{ - /** @var mixed Rejection reason. */ - private $reason; - - /** - * @param mixed $reason Rejection reason. - * @param string $description Optional description - */ - public function __construct($reason, $description = null) - { - $this->reason = $reason; - - $message = 'The promise was rejected'; - - if ($description) { - $message .= ' with reason: ' . $description; - } elseif (is_string($reason) - || (is_object($reason) && method_exists($reason, '__toString')) - ) { - $message .= ' with reason: ' . $this->reason; - } elseif ($reason instanceof \JsonSerializable) { - $message .= ' with reason: ' - . json_encode($this->reason, JSON_PRETTY_PRINT); - } - - parent::__construct($message); - } - - /** - * Returns the rejection reason. - * - * @return mixed - */ - public function getReason() - { - return $this->reason; - } -} diff --git a/vendor/guzzlehttp/promises/src/TaskQueue.php b/vendor/guzzlehttp/promises/src/TaskQueue.php deleted file mode 100755 index 6e8a2a083cd919ad90efd13b0701da0605267fe2..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/src/TaskQueue.php +++ /dev/null @@ -1,66 +0,0 @@ -<?php -namespace GuzzleHttp\Promise; - -/** - * A task queue that executes tasks in a FIFO order. - * - * This task queue class is used to settle promises asynchronously and - * maintains a constant stack size. You can use the task queue asynchronously - * by calling the `run()` function of the global task queue in an event loop. - * - * GuzzleHttp\Promise\queue()->run(); - */ -class TaskQueue implements TaskQueueInterface -{ - private $enableShutdown = true; - private $queue = []; - - public function __construct($withShutdown = true) - { - if ($withShutdown) { - register_shutdown_function(function () { - if ($this->enableShutdown) { - // Only run the tasks if an E_ERROR didn't occur. - $err = error_get_last(); - if (!$err || ($err['type'] ^ E_ERROR)) { - $this->run(); - } - } - }); - } - } - - public function isEmpty() - { - return !$this->queue; - } - - public function add(callable $task) - { - $this->queue[] = $task; - } - - public function run() - { - /** @var callable $task */ - while ($task = array_shift($this->queue)) { - $task(); - } - } - - /** - * The task queue will be run and exhausted by default when the process - * exits IFF the exit is not the result of a PHP E_ERROR error. - * - * You can disable running the automatic shutdown of the queue by calling - * this function. If you disable the task queue shutdown process, then you - * MUST either run the task queue (as a result of running your event loop - * or manually using the run() method) or wait on each outstanding promise. - * - * Note: This shutdown will occur before any destructors are triggered. - */ - public function disableShutdown() - { - $this->enableShutdown = false; - } -} diff --git a/vendor/guzzlehttp/promises/src/TaskQueueInterface.php b/vendor/guzzlehttp/promises/src/TaskQueueInterface.php deleted file mode 100755 index ac8306e1971226a46e5fdff1bed9140f8cbade59..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/src/TaskQueueInterface.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -namespace GuzzleHttp\Promise; - -interface TaskQueueInterface -{ - /** - * Returns true if the queue is empty. - * - * @return bool - */ - public function isEmpty(); - - /** - * Adds a task to the queue that will be executed the next time run is - * called. - * - * @param callable $task - */ - public function add(callable $task); - - /** - * Execute all of the pending task in the queue. - */ - public function run(); -} diff --git a/vendor/guzzlehttp/promises/src/functions.php b/vendor/guzzlehttp/promises/src/functions.php deleted file mode 100755 index 4e27709af3641337e285f66e9a22d1778060d2ec..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/src/functions.php +++ /dev/null @@ -1,457 +0,0 @@ -<?php -namespace GuzzleHttp\Promise; - -/** - * Get the global task queue used for promise resolution. - * - * This task queue MUST be run in an event loop in order for promises to be - * settled asynchronously. It will be automatically run when synchronously - * waiting on a promise. - * - * <code> - * while ($eventLoop->isRunning()) { - * GuzzleHttp\Promise\queue()->run(); - * } - * </code> - * - * @param TaskQueueInterface $assign Optionally specify a new queue instance. - * - * @return TaskQueueInterface - */ -function queue(TaskQueueInterface $assign = null) -{ - static $queue; - - if ($assign) { - $queue = $assign; - } elseif (!$queue) { - $queue = new TaskQueue(); - } - - return $queue; -} - -/** - * Adds a function to run in the task queue when it is next `run()` and returns - * a promise that is fulfilled or rejected with the result. - * - * @param callable $task Task function to run. - * - * @return PromiseInterface - */ -function task(callable $task) -{ - $queue = queue(); - $promise = new Promise([$queue, 'run']); - $queue->add(function () use ($task, $promise) { - try { - $promise->resolve($task()); - } catch (\Throwable $e) { - $promise->reject($e); - } catch (\Exception $e) { - $promise->reject($e); - } - }); - - return $promise; -} - -/** - * Creates a promise for a value if the value is not a promise. - * - * @param mixed $value Promise or value. - * - * @return PromiseInterface - */ -function promise_for($value) -{ - if ($value instanceof PromiseInterface) { - return $value; - } - - // Return a Guzzle promise that shadows the given promise. - if (method_exists($value, 'then')) { - $wfn = method_exists($value, 'wait') ? [$value, 'wait'] : null; - $cfn = method_exists($value, 'cancel') ? [$value, 'cancel'] : null; - $promise = new Promise($wfn, $cfn); - $value->then([$promise, 'resolve'], [$promise, 'reject']); - return $promise; - } - - return new FulfilledPromise($value); -} - -/** - * Creates a rejected promise for a reason if the reason is not a promise. If - * the provided reason is a promise, then it is returned as-is. - * - * @param mixed $reason Promise or reason. - * - * @return PromiseInterface - */ -function rejection_for($reason) -{ - if ($reason instanceof PromiseInterface) { - return $reason; - } - - return new RejectedPromise($reason); -} - -/** - * Create an exception for a rejected promise value. - * - * @param mixed $reason - * - * @return \Exception|\Throwable - */ -function exception_for($reason) -{ - return $reason instanceof \Exception || $reason instanceof \Throwable - ? $reason - : new RejectionException($reason); -} - -/** - * Returns an iterator for the given value. - * - * @param mixed $value - * - * @return \Iterator - */ -function iter_for($value) -{ - if ($value instanceof \Iterator) { - return $value; - } elseif (is_array($value)) { - return new \ArrayIterator($value); - } else { - return new \ArrayIterator([$value]); - } -} - -/** - * Synchronously waits on a promise to resolve and returns an inspection state - * array. - * - * Returns a state associative array containing a "state" key mapping to a - * valid promise state. If the state of the promise is "fulfilled", the array - * will contain a "value" key mapping to the fulfilled value of the promise. If - * the promise is rejected, the array will contain a "reason" key mapping to - * the rejection reason of the promise. - * - * @param PromiseInterface $promise Promise or value. - * - * @return array - */ -function inspect(PromiseInterface $promise) -{ - try { - return [ - 'state' => PromiseInterface::FULFILLED, - 'value' => $promise->wait() - ]; - } catch (RejectionException $e) { - return ['state' => PromiseInterface::REJECTED, 'reason' => $e->getReason()]; - } catch (\Throwable $e) { - return ['state' => PromiseInterface::REJECTED, 'reason' => $e]; - } catch (\Exception $e) { - return ['state' => PromiseInterface::REJECTED, 'reason' => $e]; - } -} - -/** - * Waits on all of the provided promises, but does not unwrap rejected promises - * as thrown exception. - * - * Returns an array of inspection state arrays. - * - * @param PromiseInterface[] $promises Traversable of promises to wait upon. - * - * @return array - * @see GuzzleHttp\Promise\inspect for the inspection state array format. - */ -function inspect_all($promises) -{ - $results = []; - foreach ($promises as $key => $promise) { - $results[$key] = inspect($promise); - } - - return $results; -} - -/** - * Waits on all of the provided promises and returns the fulfilled values. - * - * Returns an array that contains the value of each promise (in the same order - * the promises were provided). An exception is thrown if any of the promises - * are rejected. - * - * @param mixed $promises Iterable of PromiseInterface objects to wait on. - * - * @return array - * @throws \Exception on error - * @throws \Throwable on error in PHP >=7 - */ -function unwrap($promises) -{ - $results = []; - foreach ($promises as $key => $promise) { - $results[$key] = $promise->wait(); - } - - return $results; -} - -/** - * Given an array of promises, return a promise that is fulfilled when all the - * items in the array are fulfilled. - * - * The promise's fulfillment value is an array with fulfillment values at - * respective positions to the original array. If any promise in the array - * rejects, the returned promise is rejected with the rejection reason. - * - * @param mixed $promises Promises or values. - * - * @return PromiseInterface - */ -function all($promises) -{ - $results = []; - return each( - $promises, - function ($value, $idx) use (&$results) { - $results[$idx] = $value; - }, - function ($reason, $idx, Promise $aggregate) { - $aggregate->reject($reason); - } - )->then(function () use (&$results) { - ksort($results); - return $results; - }); -} - -/** - * Initiate a competitive race between multiple promises or values (values will - * become immediately fulfilled promises). - * - * When count amount of promises have been fulfilled, the returned promise is - * fulfilled with an array that contains the fulfillment values of the winners - * in order of resolution. - * - * This prommise is rejected with a {@see GuzzleHttp\Promise\AggregateException} - * if the number of fulfilled promises is less than the desired $count. - * - * @param int $count Total number of promises. - * @param mixed $promises Promises or values. - * - * @return PromiseInterface - */ -function some($count, $promises) -{ - $results = []; - $rejections = []; - - return each( - $promises, - function ($value, $idx, PromiseInterface $p) use (&$results, $count) { - if ($p->getState() !== PromiseInterface::PENDING) { - return; - } - $results[$idx] = $value; - if (count($results) >= $count) { - $p->resolve(null); - } - }, - function ($reason) use (&$rejections) { - $rejections[] = $reason; - } - )->then( - function () use (&$results, &$rejections, $count) { - if (count($results) !== $count) { - throw new AggregateException( - 'Not enough promises to fulfill count', - $rejections - ); - } - ksort($results); - return array_values($results); - } - ); -} - -/** - * Like some(), with 1 as count. However, if the promise fulfills, the - * fulfillment value is not an array of 1 but the value directly. - * - * @param mixed $promises Promises or values. - * - * @return PromiseInterface - */ -function any($promises) -{ - return some(1, $promises)->then(function ($values) { return $values[0]; }); -} - -/** - * Returns a promise that is fulfilled when all of the provided promises have - * been fulfilled or rejected. - * - * The returned promise is fulfilled with an array of inspection state arrays. - * - * @param mixed $promises Promises or values. - * - * @return PromiseInterface - * @see GuzzleHttp\Promise\inspect for the inspection state array format. - */ -function settle($promises) -{ - $results = []; - - return each( - $promises, - function ($value, $idx) use (&$results) { - $results[$idx] = ['state' => PromiseInterface::FULFILLED, 'value' => $value]; - }, - function ($reason, $idx) use (&$results) { - $results[$idx] = ['state' => PromiseInterface::REJECTED, 'reason' => $reason]; - } - )->then(function () use (&$results) { - ksort($results); - return $results; - }); -} - -/** - * Given an iterator that yields promises or values, returns a promise that is - * fulfilled with a null value when the iterator has been consumed or the - * aggregate promise has been fulfilled or rejected. - * - * $onFulfilled is a function that accepts the fulfilled value, iterator - * index, and the aggregate promise. The callback can invoke any necessary side - * effects and choose to resolve or reject the aggregate promise if needed. - * - * $onRejected is a function that accepts the rejection reason, iterator - * index, and the aggregate promise. The callback can invoke any necessary side - * effects and choose to resolve or reject the aggregate promise if needed. - * - * @param mixed $iterable Iterator or array to iterate over. - * @param callable $onFulfilled - * @param callable $onRejected - * - * @return PromiseInterface - */ -function each( - $iterable, - callable $onFulfilled = null, - callable $onRejected = null -) { - return (new EachPromise($iterable, [ - 'fulfilled' => $onFulfilled, - 'rejected' => $onRejected - ]))->promise(); -} - -/** - * Like each, but only allows a certain number of outstanding promises at any - * given time. - * - * $concurrency may be an integer or a function that accepts the number of - * pending promises and returns a numeric concurrency limit value to allow for - * dynamic a concurrency size. - * - * @param mixed $iterable - * @param int|callable $concurrency - * @param callable $onFulfilled - * @param callable $onRejected - * - * @return PromiseInterface - */ -function each_limit( - $iterable, - $concurrency, - callable $onFulfilled = null, - callable $onRejected = null -) { - return (new EachPromise($iterable, [ - 'fulfilled' => $onFulfilled, - 'rejected' => $onRejected, - 'concurrency' => $concurrency - ]))->promise(); -} - -/** - * Like each_limit, but ensures that no promise in the given $iterable argument - * is rejected. If any promise is rejected, then the aggregate promise is - * rejected with the encountered rejection. - * - * @param mixed $iterable - * @param int|callable $concurrency - * @param callable $onFulfilled - * - * @return PromiseInterface - */ -function each_limit_all( - $iterable, - $concurrency, - callable $onFulfilled = null -) { - return each_limit( - $iterable, - $concurrency, - $onFulfilled, - function ($reason, $idx, PromiseInterface $aggregate) { - $aggregate->reject($reason); - } - ); -} - -/** - * Returns true if a promise is fulfilled. - * - * @param PromiseInterface $promise - * - * @return bool - */ -function is_fulfilled(PromiseInterface $promise) -{ - return $promise->getState() === PromiseInterface::FULFILLED; -} - -/** - * Returns true if a promise is rejected. - * - * @param PromiseInterface $promise - * - * @return bool - */ -function is_rejected(PromiseInterface $promise) -{ - return $promise->getState() === PromiseInterface::REJECTED; -} - -/** - * Returns true if a promise is fulfilled or rejected. - * - * @param PromiseInterface $promise - * - * @return bool - */ -function is_settled(PromiseInterface $promise) -{ - return $promise->getState() !== PromiseInterface::PENDING; -} - -/** - * @see Coroutine - * - * @param callable $generatorFn - * - * @return PromiseInterface - */ -function coroutine(callable $generatorFn) -{ - return new Coroutine($generatorFn); -} diff --git a/vendor/guzzlehttp/promises/src/functions_include.php b/vendor/guzzlehttp/promises/src/functions_include.php deleted file mode 100755 index 34cd1710aa220b6e7ee59a7bda1ea0c6ab52ef80..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/promises/src/functions_include.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php - -// Don't redefine the functions if included multiple times. -if (!function_exists('GuzzleHttp\Promise\promise_for')) { - require __DIR__ . '/functions.php'; -} diff --git a/vendor/guzzlehttp/psr7/CHANGELOG.md b/vendor/guzzlehttp/psr7/CHANGELOG.md deleted file mode 100755 index 5c252b3a208313cd73f7a84d63b752800edd96ff..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/CHANGELOG.md +++ /dev/null @@ -1,110 +0,0 @@ -# CHANGELOG - -## 1.4.2 - 2017-03-20 - -* Reverted BC break to `Uri::resolve` and `Uri::removeDotSegments` by removing - calls to `trigger_error` when deprecated methods are invoked. - -## 1.4.1 - 2017-02-27 - -* Reverted BC break by reintroducing behavior to automagically fix a URI with a - relative path and an authority by adding a leading slash to the path. It's only - deprecated now. -* Added triggering of silenced deprecation warnings. - -## 1.4.0 - 2017-02-21 - -* Fix `Stream::read` when length parameter <= 0. -* `copy_to_stream` reads bytes in chunks instead of `maxLen` into memory. -* Fix `ServerRequest::getUriFromGlobals` when `Host` header contains port. -* Ensure `ServerRequest::getUriFromGlobals` returns a URI in absolute form. -* Allow `parse_response` to parse a response without delimiting space and reason. -* Ensure each URI modification results in a valid URI according to PSR-7 discussions. - Invalid modifications will throw an exception instead of returning a wrong URI or - doing some magic. - - `(new Uri)->withPath('foo')->withHost('example.com')` will throw an exception - because the path of a URI with an authority must start with a slash "/" or be empty - - `(new Uri())->withScheme('http')` will return `'http://localhost'` -* Fix compatibility of URIs with `file` scheme and empty host. -* Added common URI utility methods based on RFC 3986 (see documentation in the readme): - - `Uri::isDefaultPort` - - `Uri::isAbsolute` - - `Uri::isNetworkPathReference` - - `Uri::isAbsolutePathReference` - - `Uri::isRelativePathReference` - - `Uri::isSameDocumentReference` - - `Uri::composeComponents` - - `UriNormalizer::normalize` - - `UriNormalizer::isEquivalent` - - `UriResolver::relativize` -* Deprecated `Uri::resolve` in favor of `UriResolver::resolve` -* Deprecated `Uri::removeDotSegments` in favor of `UriResolver::removeDotSegments` - -## 1.3.1 - 2016-06-25 - -* Fix `Uri::__toString` for network path references, e.g. `//example.org`. -* Fix missing lowercase normalization for host. -* Fix handling of URI components in case they are `'0'` in a lot of places, - e.g. as a user info password. -* Fix `Uri::withAddedHeader` to correctly merge headers with different case. -* Fix trimming of header values in `Uri::withAddedHeader`. Header values may - be surrounded by whitespace which should be ignored according to RFC 7230 - Section 3.2.4. This does not apply to header names. -* Fix `Uri::withAddedHeader` with an array of header values. -* Fix `Uri::resolve` when base path has no slash and handling of fragment. -* Fix handling of encoding in `Uri::with(out)QueryValue` so one can pass the - key/value both in encoded as well as decoded form to those methods. This is - consistent with withPath, withQuery etc. -* Fix `ServerRequest::withoutAttribute` when attribute value is null. - -## 1.3.0 - 2016-04-13 - -* Added remaining interfaces needed for full PSR7 compatibility - (ServerRequestInterface, UploadedFileInterface, etc.). -* Added support for stream_for from scalars. -* Can now extend Uri. -* Fixed a bug in validating request methods by making it more permissive. - -## 1.2.3 - 2016-02-18 - -* Fixed support in `GuzzleHttp\Psr7\CachingStream` for seeking forward on remote - streams, which can sometimes return fewer bytes than requested with `fread`. -* Fixed handling of gzipped responses with FNAME headers. - -## 1.2.2 - 2016-01-22 - -* Added support for URIs without any authority. -* Added support for HTTP 451 'Unavailable For Legal Reasons.' -* Added support for using '0' as a filename. -* Added support for including non-standard ports in Host headers. - -## 1.2.1 - 2015-11-02 - -* Now supporting negative offsets when seeking to SEEK_END. - -## 1.2.0 - 2015-08-15 - -* Body as `"0"` is now properly added to a response. -* Now allowing forward seeking in CachingStream. -* Now properly parsing HTTP requests that contain proxy targets in - `parse_request`. -* functions.php is now conditionally required. -* user-info is no longer dropped when resolving URIs. - -## 1.1.0 - 2015-06-24 - -* URIs can now be relative. -* `multipart/form-data` headers are now overridden case-insensitively. -* URI paths no longer encode the following characters because they are allowed - in URIs: "(", ")", "*", "!", "'" -* A port is no longer added to a URI when the scheme is missing and no port is - present. - -## 1.0.0 - 2015-05-19 - -Initial release. - -Currently unsupported: - -- `Psr\Http\Message\ServerRequestInterface` -- `Psr\Http\Message\UploadedFileInterface` diff --git a/vendor/guzzlehttp/psr7/LICENSE b/vendor/guzzlehttp/psr7/LICENSE deleted file mode 100755 index 581d95f92024be7c805599690867b4d1e2e10f40..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/guzzlehttp/psr7/README.md b/vendor/guzzlehttp/psr7/README.md deleted file mode 100755 index 16499358ea102a6d05d5cc44fcdb7abba19083ab..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/README.md +++ /dev/null @@ -1,739 +0,0 @@ -# PSR-7 Message Implementation - -This repository contains a full [PSR-7](http://www.php-fig.org/psr/psr-7/) -message implementation, several stream decorators, and some helpful -functionality like query string parsing. - - -[](https://travis-ci.org/guzzle/psr7) - - -# Stream implementation - -This package comes with a number of stream implementations and stream -decorators. - - -## AppendStream - -`GuzzleHttp\Psr7\AppendStream` - -Reads from multiple streams, one after the other. - -```php -use GuzzleHttp\Psr7; - -$a = Psr7\stream_for('abc, '); -$b = Psr7\stream_for('123.'); -$composed = new Psr7\AppendStream([$a, $b]); - -$composed->addStream(Psr7\stream_for(' Above all listen to me')); - -echo $composed; // abc, 123. Above all listen to me. -``` - - -## BufferStream - -`GuzzleHttp\Psr7\BufferStream` - -Provides a buffer stream that can be written to fill a buffer, and read -from to remove bytes from the buffer. - -This stream returns a "hwm" metadata value that tells upstream consumers -what the configured high water mark of the stream is, or the maximum -preferred size of the buffer. - -```php -use GuzzleHttp\Psr7; - -// When more than 1024 bytes are in the buffer, it will begin returning -// false to writes. This is an indication that writers should slow down. -$buffer = new Psr7\BufferStream(1024); -``` - - -## CachingStream - -The CachingStream is used to allow seeking over previously read bytes on -non-seekable streams. This can be useful when transferring a non-seekable -entity body fails due to needing to rewind the stream (for example, resulting -from a redirect). Data that is read from the remote stream will be buffered in -a PHP temp stream so that previously read bytes are cached first in memory, -then on disk. - -```php -use GuzzleHttp\Psr7; - -$original = Psr7\stream_for(fopen('http://www.google.com', 'r')); -$stream = new Psr7\CachingStream($original); - -$stream->read(1024); -echo $stream->tell(); -// 1024 - -$stream->seek(0); -echo $stream->tell(); -// 0 -``` - - -## DroppingStream - -`GuzzleHttp\Psr7\DroppingStream` - -Stream decorator that begins dropping data once the size of the underlying -stream becomes too full. - -```php -use GuzzleHttp\Psr7; - -// Create an empty stream -$stream = Psr7\stream_for(); - -// Start dropping data when the stream has more than 10 bytes -$dropping = new Psr7\DroppingStream($stream, 10); - -$dropping->write('01234567890123456789'); -echo $stream; // 0123456789 -``` - - -## FnStream - -`GuzzleHttp\Psr7\FnStream` - -Compose stream implementations based on a hash of functions. - -Allows for easy testing and extension of a provided stream without needing -to create a concrete class for a simple extension point. - -```php - -use GuzzleHttp\Psr7; - -$stream = Psr7\stream_for('hi'); -$fnStream = Psr7\FnStream::decorate($stream, [ - 'rewind' => function () use ($stream) { - echo 'About to rewind - '; - $stream->rewind(); - echo 'rewound!'; - } -]); - -$fnStream->rewind(); -// Outputs: About to rewind - rewound! -``` - - -## InflateStream - -`GuzzleHttp\Psr7\InflateStream` - -Uses PHP's zlib.inflate filter to inflate deflate or gzipped content. - -This stream decorator skips the first 10 bytes of the given stream to remove -the gzip header, converts the provided stream to a PHP stream resource, -then appends the zlib.inflate filter. The stream is then converted back -to a Guzzle stream resource to be used as a Guzzle stream. - - -## LazyOpenStream - -`GuzzleHttp\Psr7\LazyOpenStream` - -Lazily reads or writes to a file that is opened only after an IO operation -take place on the stream. - -```php -use GuzzleHttp\Psr7; - -$stream = new Psr7\LazyOpenStream('/path/to/file', 'r'); -// The file has not yet been opened... - -echo $stream->read(10); -// The file is opened and read from only when needed. -``` - - -## LimitStream - -`GuzzleHttp\Psr7\LimitStream` - -LimitStream can be used to read a subset or slice of an existing stream object. -This can be useful for breaking a large file into smaller pieces to be sent in -chunks (e.g. Amazon S3's multipart upload API). - -```php -use GuzzleHttp\Psr7; - -$original = Psr7\stream_for(fopen('/tmp/test.txt', 'r+')); -echo $original->getSize(); -// >>> 1048576 - -// Limit the size of the body to 1024 bytes and start reading from byte 2048 -$stream = new Psr7\LimitStream($original, 1024, 2048); -echo $stream->getSize(); -// >>> 1024 -echo $stream->tell(); -// >>> 0 -``` - - -## MultipartStream - -`GuzzleHttp\Psr7\MultipartStream` - -Stream that when read returns bytes for a streaming multipart or -multipart/form-data stream. - - -## NoSeekStream - -`GuzzleHttp\Psr7\NoSeekStream` - -NoSeekStream wraps a stream and does not allow seeking. - -```php -use GuzzleHttp\Psr7; - -$original = Psr7\stream_for('foo'); -$noSeek = new Psr7\NoSeekStream($original); - -echo $noSeek->read(3); -// foo -var_export($noSeek->isSeekable()); -// false -$noSeek->seek(0); -var_export($noSeek->read(3)); -// NULL -``` - - -## PumpStream - -`GuzzleHttp\Psr7\PumpStream` - -Provides a read only stream that pumps data from a PHP callable. - -When invoking the provided callable, the PumpStream will pass the amount of -data requested to read to the callable. The callable can choose to ignore -this value and return fewer or more bytes than requested. Any extra data -returned by the provided callable is buffered internally until drained using -the read() function of the PumpStream. The provided callable MUST return -false when there is no more data to read. - - -## Implementing stream decorators - -Creating a stream decorator is very easy thanks to the -`GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that -implement `Psr\Http\Message\StreamInterface` by proxying to an underlying -stream. Just `use` the `StreamDecoratorTrait` and implement your custom -methods. - -For example, let's say we wanted to call a specific function each time the last -byte is read from a stream. This could be implemented by overriding the -`read()` method. - -```php -use Psr\Http\Message\StreamInterface; -use GuzzleHttp\Psr7\StreamDecoratorTrait; - -class EofCallbackStream implements StreamInterface -{ - use StreamDecoratorTrait; - - private $callback; - - public function __construct(StreamInterface $stream, callable $cb) - { - $this->stream = $stream; - $this->callback = $cb; - } - - public function read($length) - { - $result = $this->stream->read($length); - - // Invoke the callback when EOF is hit. - if ($this->eof()) { - call_user_func($this->callback); - } - - return $result; - } -} -``` - -This decorator could be added to any existing stream and used like so: - -```php -use GuzzleHttp\Psr7; - -$original = Psr7\stream_for('foo'); - -$eofStream = new EofCallbackStream($original, function () { - echo 'EOF!'; -}); - -$eofStream->read(2); -$eofStream->read(1); -// echoes "EOF!" -$eofStream->seek(0); -$eofStream->read(3); -// echoes "EOF!" -``` - - -## PHP StreamWrapper - -You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a -PSR-7 stream as a PHP stream resource. - -Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP -stream from a PSR-7 stream. - -```php -use GuzzleHttp\Psr7\StreamWrapper; - -$stream = GuzzleHttp\Psr7\stream_for('hello!'); -$resource = StreamWrapper::getResource($stream); -echo fread($resource, 6); // outputs hello! -``` - - -# Function API - -There are various functions available under the `GuzzleHttp\Psr7` namespace. - - -## `function str` - -`function str(MessageInterface $message)` - -Returns the string representation of an HTTP message. - -```php -$request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com'); -echo GuzzleHttp\Psr7\str($request); -``` - - -## `function uri_for` - -`function uri_for($uri)` - -This function accepts a string or `Psr\Http\Message\UriInterface` and returns a -UriInterface for the given value. If the value is already a `UriInterface`, it -is returned as-is. - -```php -$uri = GuzzleHttp\Psr7\uri_for('http://example.com'); -assert($uri === GuzzleHttp\Psr7\uri_for($uri)); -``` - - -## `function stream_for` - -`function stream_for($resource = '', array $options = [])` - -Create a new stream based on the input type. - -Options is an associative array that can contain the following keys: - -* - metadata: Array of custom metadata. -* - size: Size of the stream. - -This method accepts the following `$resource` types: - -- `Psr\Http\Message\StreamInterface`: Returns the value as-is. -- `string`: Creates a stream object that uses the given string as the contents. -- `resource`: Creates a stream object that wraps the given PHP stream resource. -- `Iterator`: If the provided value implements `Iterator`, then a read-only - stream object will be created that wraps the given iterable. Each time the - stream is read from, data from the iterator will fill a buffer and will be - continuously called until the buffer is equal to the requested read size. - Subsequent read calls will first read from the buffer and then call `next` - on the underlying iterator until it is exhausted. -- `object` with `__toString()`: If the object has the `__toString()` method, - the object will be cast to a string and then a stream will be returned that - uses the string value. -- `NULL`: When `null` is passed, an empty stream object is returned. -- `callable` When a callable is passed, a read-only stream object will be - created that invokes the given callable. The callable is invoked with the - number of suggested bytes to read. The callable can return any number of - bytes, but MUST return `false` when there is no more data to return. The - stream object that wraps the callable will invoke the callable until the - number of requested bytes are available. Any additional bytes will be - buffered and used in subsequent reads. - -```php -$stream = GuzzleHttp\Psr7\stream_for('foo'); -$stream = GuzzleHttp\Psr7\stream_for(fopen('/path/to/file', 'r')); - -$generator function ($bytes) { - for ($i = 0; $i < $bytes; $i++) { - yield ' '; - } -} - -$stream = GuzzleHttp\Psr7\stream_for($generator(100)); -``` - - -## `function parse_header` - -`function parse_header($header)` - -Parse an array of header values containing ";" separated data into an array of -associative arrays representing the header key value pair data of the header. -When a parameter does not contain a value, but just contains a key, this -function will inject a key with a '' string value. - - -## `function normalize_header` - -`function normalize_header($header)` - -Converts an array of header values that may contain comma separated headers -into an array of headers with no comma separated values. - - -## `function modify_request` - -`function modify_request(RequestInterface $request, array $changes)` - -Clone and modify a request with the given changes. This method is useful for -reducing the number of clones needed to mutate a message. - -The changes can be one of: - -- method: (string) Changes the HTTP method. -- set_headers: (array) Sets the given headers. -- remove_headers: (array) Remove the given headers. -- body: (mixed) Sets the given body. -- uri: (UriInterface) Set the URI. -- query: (string) Set the query string value of the URI. -- version: (string) Set the protocol version. - - -## `function rewind_body` - -`function rewind_body(MessageInterface $message)` - -Attempts to rewind a message body and throws an exception on failure. The body -of the message will only be rewound if a call to `tell()` returns a value other -than `0`. - - -## `function try_fopen` - -`function try_fopen($filename, $mode)` - -Safely opens a PHP stream resource using a filename. - -When fopen fails, PHP normally raises a warning. This function adds an error -handler that checks for errors and throws an exception instead. - - -## `function copy_to_string` - -`function copy_to_string(StreamInterface $stream, $maxLen = -1)` - -Copy the contents of a stream into a string until the given number of bytes -have been read. - - -## `function copy_to_stream` - -`function copy_to_stream(StreamInterface $source, StreamInterface $dest, $maxLen = -1)` - -Copy the contents of a stream into another stream until the given number of -bytes have been read. - - -## `function hash` - -`function hash(StreamInterface $stream, $algo, $rawOutput = false)` - -Calculate a hash of a Stream. This method reads the entire stream to calculate -a rolling hash (based on PHP's hash_init functions). - - -## `function readline` - -`function readline(StreamInterface $stream, $maxLength = null)` - -Read a line from the stream up to the maximum allowed buffer length. - - -## `function parse_request` - -`function parse_request($message)` - -Parses a request message string into a request object. - - -## `function parse_response` - -`function parse_response($message)` - -Parses a response message string into a response object. - - -## `function parse_query` - -`function parse_query($str, $urlEncoding = true)` - -Parse a query string into an associative array. - -If multiple values are found for the same key, the value of that key value pair -will become an array. This function does not parse nested PHP style arrays into -an associative array (e.g., `foo[a]=1&foo[b]=2` will be parsed into -`['foo[a]' => '1', 'foo[b]' => '2']`). - - -## `function build_query` - -`function build_query(array $params, $encoding = PHP_QUERY_RFC3986)` - -Build a query string from an array of key value pairs. - -This function can use the return value of parse_query() to build a query string. -This function does not modify the provided keys when an array is encountered -(like http_build_query would). - - -## `function mimetype_from_filename` - -`function mimetype_from_filename($filename)` - -Determines the mimetype of a file by looking at its extension. - - -## `function mimetype_from_extension` - -`function mimetype_from_extension($extension)` - -Maps a file extensions to a mimetype. - - -# Additional URI Methods - -Aside from the standard `Psr\Http\Message\UriInterface` implementation in form of the `GuzzleHttp\Psr7\Uri` class, -this library also provides additional functionality when working with URIs as static methods. - -## URI Types - -An instance of `Psr\Http\Message\UriInterface` can either be an absolute URI or a relative reference. -An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI, -the base URI. Relative references can be divided into several forms according to -[RFC 3986 Section 4.2](https://tools.ietf.org/html/rfc3986#section-4.2): - -- network-path references, e.g. `//example.com/path` -- absolute-path references, e.g. `/path` -- relative-path references, e.g. `subpath` - -The following methods can be used to identify the type of the URI. - -### `GuzzleHttp\Psr7\Uri::isAbsolute` - -`public static function isAbsolute(UriInterface $uri): bool` - -Whether the URI is absolute, i.e. it has a scheme. - -### `GuzzleHttp\Psr7\Uri::isNetworkPathReference` - -`public static function isNetworkPathReference(UriInterface $uri): bool` - -Whether the URI is a network-path reference. A relative reference that begins with two slash characters is -termed an network-path reference. - -### `GuzzleHttp\Psr7\Uri::isAbsolutePathReference` - -`public static function isAbsolutePathReference(UriInterface $uri): bool` - -Whether the URI is a absolute-path reference. A relative reference that begins with a single slash character is -termed an absolute-path reference. - -### `GuzzleHttp\Psr7\Uri::isRelativePathReference` - -`public static function isRelativePathReference(UriInterface $uri): bool` - -Whether the URI is a relative-path reference. A relative reference that does not begin with a slash character is -termed a relative-path reference. - -### `GuzzleHttp\Psr7\Uri::isSameDocumentReference` - -`public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null): bool` - -Whether the URI is a same-document reference. A same-document reference refers to a URI that is, aside from its -fragment component, identical to the base URI. When no base URI is given, only an empty URI reference -(apart from its fragment) is considered a same-document reference. - -## URI Components - -Additional methods to work with URI components. - -### `GuzzleHttp\Psr7\Uri::isDefaultPort` - -`public static function isDefaultPort(UriInterface $uri): bool` - -Whether the URI has the default port of the current scheme. `Psr\Http\Message\UriInterface::getPort` may return null -or the standard port. This method can be used independently of the implementation. - -### `GuzzleHttp\Psr7\Uri::composeComponents` - -`public static function composeComponents($scheme, $authority, $path, $query, $fragment): string` - -Composes a URI reference string from its various components according to -[RFC 3986 Section 5.3](https://tools.ietf.org/html/rfc3986#section-5.3). Usually this method does not need to be called -manually but instead is used indirectly via `Psr\Http\Message\UriInterface::__toString`. - -### `GuzzleHttp\Psr7\Uri::fromParts` - -`public static function fromParts(array $parts): UriInterface` - -Creates a URI from a hash of [`parse_url`](http://php.net/manual/en/function.parse-url.php) components. - - -### `GuzzleHttp\Psr7\Uri::withQueryValue` - -`public static function withQueryValue(UriInterface $uri, $key, $value): UriInterface` - -Creates a new URI with a specific query string value. Any existing query string values that exactly match the -provided key are removed and replaced with the given key value pair. A value of null will set the query string -key without a value, e.g. "key" instead of "key=value". - - -### `GuzzleHttp\Psr7\Uri::withoutQueryValue` - -`public static function withoutQueryValue(UriInterface $uri, $key): UriInterface` - -Creates a new URI with a specific query string value removed. Any existing query string values that exactly match the -provided key are removed. - -## Reference Resolution - -`GuzzleHttp\Psr7\UriResolver` provides methods to resolve a URI reference in the context of a base URI according -to [RFC 3986 Section 5](https://tools.ietf.org/html/rfc3986#section-5). This is for example also what web browsers -do when resolving a link in a website based on the current request URI. - -### `GuzzleHttp\Psr7\UriResolver::resolve` - -`public static function resolve(UriInterface $base, UriInterface $rel): UriInterface` - -Converts the relative URI into a new URI that is resolved against the base URI. - -### `GuzzleHttp\Psr7\UriResolver::removeDotSegments` - -`public static function removeDotSegments(string $path): string` - -Removes dot segments from a path and returns the new path according to -[RFC 3986 Section 5.2.4](https://tools.ietf.org/html/rfc3986#section-5.2.4). - -### `GuzzleHttp\Psr7\UriResolver::relativize` - -`public static function relativize(UriInterface $base, UriInterface $target): UriInterface` - -Returns the target URI as a relative reference from the base URI. This method is the counterpart to resolve(): - -```php -(string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target)) -``` - -One use-case is to use the current request URI as base URI and then generate relative links in your documents -to reduce the document size or offer self-contained downloadable document archives. - -```php -$base = new Uri('http://example.com/a/b/'); -echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'. -echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'. -echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'. -echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'. -``` - -## Normalization and Comparison - -`GuzzleHttp\Psr7\UriNormalizer` provides methods to normalize and compare URIs according to -[RFC 3986 Section 6](https://tools.ietf.org/html/rfc3986#section-6). - -### `GuzzleHttp\Psr7\UriNormalizer::normalize` - -`public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS): UriInterface` - -Returns a normalized URI. The scheme and host component are already normalized to lowercase per PSR-7 UriInterface. -This methods adds additional normalizations that can be configured with the `$flags` parameter which is a bitmask -of normalizations to apply. The following normalizations are available: - -- `UriNormalizer::PRESERVING_NORMALIZATIONS` - - Default normalizations which only include the ones that preserve semantics. - -- `UriNormalizer::CAPITALIZE_PERCENT_ENCODING` - - All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized. - - Example: `http://example.org/a%c2%b1b` → `http://example.org/a%C2%B1b` - -- `UriNormalizer::DECODE_UNRESERVED_CHARACTERS` - - Decodes percent-encoded octets of unreserved characters. For consistency, percent-encoded octets in the ranges of - ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should - not be created by URI producers and, when found in a URI, should be decoded to their corresponding unreserved - characters by URI normalizers. - - Example: `http://example.org/%7Eusern%61me/` → `http://example.org/~username/` - -- `UriNormalizer::CONVERT_EMPTY_PATH` - - Converts the empty path to "/" for http and https URIs. - - Example: `http://example.org` → `http://example.org/` - -- `UriNormalizer::REMOVE_DEFAULT_HOST` - - Removes the default host of the given URI scheme from the URI. Only the "file" scheme defines the default host - "localhost". All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile` are equivalent according to - RFC 3986. - - Example: `file://localhost/myfile` → `file:///myfile` - -- `UriNormalizer::REMOVE_DEFAULT_PORT` - - Removes the default port of the given URI scheme from the URI. - - Example: `http://example.org:80/` → `http://example.org/` - -- `UriNormalizer::REMOVE_DOT_SEGMENTS` - - Removes unnecessary dot-segments. Dot-segments in relative-path references are not removed as it would - change the semantics of the URI reference. - - Example: `http://example.org/../a/b/../c/./d.html` → `http://example.org/a/c/d.html` - -- `UriNormalizer::REMOVE_DUPLICATE_SLASHES` - - Paths which include two or more adjacent slashes are converted to one. Webservers usually ignore duplicate slashes - and treat those URIs equivalent. But in theory those URIs do not need to be equivalent. So this normalization - may change the semantics. Encoded slashes (%2F) are not removed. - - Example: `http://example.org//foo///bar.html` → `http://example.org/foo/bar.html` - -- `UriNormalizer::SORT_QUERY_PARAMETERS` - - Sort query parameters with their values in alphabetical order. However, the order of parameters in a URI may be - significant (this is not defined by the standard). So this normalization is not safe and may change the semantics - of the URI. - - Example: `?lang=en&article=fred` → `?article=fred&lang=en` - -### `GuzzleHttp\Psr7\UriNormalizer::isEquivalent` - -`public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS): bool` - -Whether two URIs can be considered equivalent. Both URIs are normalized automatically before comparison with the given -`$normalizations` bitmask. The method also accepts relative URI references and returns true when they are equivalent. -This of course assumes they will be resolved against the same base URI. If this is not the case, determination of -equivalence or difference of relative references does not mean anything. diff --git a/vendor/guzzlehttp/psr7/composer.json b/vendor/guzzlehttp/psr7/composer.json deleted file mode 100755 index b1c5a90ba71569e748dd46146a1cd31dd3509a5a..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/composer.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "guzzlehttp/psr7", - "type": "library", - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": ["request", "response", "message", "stream", "http", "uri", "url"], - "license": "MIT", - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Tobias Schultze", - "homepage": "https://github.com/Tobion" - } - ], - "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - }, - "files": ["src/functions_include.php"] - }, - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - } -} diff --git a/vendor/guzzlehttp/psr7/src/AppendStream.php b/vendor/guzzlehttp/psr7/src/AppendStream.php deleted file mode 100755 index 23039fd794bbcaaf1fda658301e90d0a4b209c46..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/AppendStream.php +++ /dev/null @@ -1,233 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\StreamInterface; - -/** - * Reads from multiple streams, one after the other. - * - * This is a read-only stream decorator. - */ -class AppendStream implements StreamInterface -{ - /** @var StreamInterface[] Streams being decorated */ - private $streams = []; - - private $seekable = true; - private $current = 0; - private $pos = 0; - private $detached = false; - - /** - * @param StreamInterface[] $streams Streams to decorate. Each stream must - * be readable. - */ - public function __construct(array $streams = []) - { - foreach ($streams as $stream) { - $this->addStream($stream); - } - } - - public function __toString() - { - try { - $this->rewind(); - return $this->getContents(); - } catch (\Exception $e) { - return ''; - } - } - - /** - * Add a stream to the AppendStream - * - * @param StreamInterface $stream Stream to append. Must be readable. - * - * @throws \InvalidArgumentException if the stream is not readable - */ - public function addStream(StreamInterface $stream) - { - if (!$stream->isReadable()) { - throw new \InvalidArgumentException('Each stream must be readable'); - } - - // The stream is only seekable if all streams are seekable - if (!$stream->isSeekable()) { - $this->seekable = false; - } - - $this->streams[] = $stream; - } - - public function getContents() - { - return copy_to_string($this); - } - - /** - * Closes each attached stream. - * - * {@inheritdoc} - */ - public function close() - { - $this->pos = $this->current = 0; - - foreach ($this->streams as $stream) { - $stream->close(); - } - - $this->streams = []; - } - - /** - * Detaches each attached stream - * - * {@inheritdoc} - */ - public function detach() - { - $this->close(); - $this->detached = true; - } - - public function tell() - { - return $this->pos; - } - - /** - * Tries to calculate the size by adding the size of each stream. - * - * If any of the streams do not return a valid number, then the size of the - * append stream cannot be determined and null is returned. - * - * {@inheritdoc} - */ - public function getSize() - { - $size = 0; - - foreach ($this->streams as $stream) { - $s = $stream->getSize(); - if ($s === null) { - return null; - } - $size += $s; - } - - return $size; - } - - public function eof() - { - return !$this->streams || - ($this->current >= count($this->streams) - 1 && - $this->streams[$this->current]->eof()); - } - - public function rewind() - { - $this->seek(0); - } - - /** - * Attempts to seek to the given position. Only supports SEEK_SET. - * - * {@inheritdoc} - */ - public function seek($offset, $whence = SEEK_SET) - { - if (!$this->seekable) { - throw new \RuntimeException('This AppendStream is not seekable'); - } elseif ($whence !== SEEK_SET) { - throw new \RuntimeException('The AppendStream can only seek with SEEK_SET'); - } - - $this->pos = $this->current = 0; - - // Rewind each stream - foreach ($this->streams as $i => $stream) { - try { - $stream->rewind(); - } catch (\Exception $e) { - throw new \RuntimeException('Unable to seek stream ' - . $i . ' of the AppendStream', 0, $e); - } - } - - // Seek to the actual position by reading from each stream - while ($this->pos < $offset && !$this->eof()) { - $result = $this->read(min(8096, $offset - $this->pos)); - if ($result === '') { - break; - } - } - } - - /** - * Reads from all of the appended streams until the length is met or EOF. - * - * {@inheritdoc} - */ - public function read($length) - { - $buffer = ''; - $total = count($this->streams) - 1; - $remaining = $length; - $progressToNext = false; - - while ($remaining > 0) { - - // Progress to the next stream if needed. - if ($progressToNext || $this->streams[$this->current]->eof()) { - $progressToNext = false; - if ($this->current === $total) { - break; - } - $this->current++; - } - - $result = $this->streams[$this->current]->read($remaining); - - // Using a loose comparison here to match on '', false, and null - if ($result == null) { - $progressToNext = true; - continue; - } - - $buffer .= $result; - $remaining = $length - strlen($buffer); - } - - $this->pos += strlen($buffer); - - return $buffer; - } - - public function isReadable() - { - return true; - } - - public function isWritable() - { - return false; - } - - public function isSeekable() - { - return $this->seekable; - } - - public function write($string) - { - throw new \RuntimeException('Cannot write to an AppendStream'); - } - - public function getMetadata($key = null) - { - return $key ? null : []; - } -} diff --git a/vendor/guzzlehttp/psr7/src/BufferStream.php b/vendor/guzzlehttp/psr7/src/BufferStream.php deleted file mode 100755 index af4d4c2277786966521deda08580d241ba4cd522..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/BufferStream.php +++ /dev/null @@ -1,137 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\StreamInterface; - -/** - * Provides a buffer stream that can be written to to fill a buffer, and read - * from to remove bytes from the buffer. - * - * This stream returns a "hwm" metadata value that tells upstream consumers - * what the configured high water mark of the stream is, or the maximum - * preferred size of the buffer. - */ -class BufferStream implements StreamInterface -{ - private $hwm; - private $buffer = ''; - - /** - * @param int $hwm High water mark, representing the preferred maximum - * buffer size. If the size of the buffer exceeds the high - * water mark, then calls to write will continue to succeed - * but will return false to inform writers to slow down - * until the buffer has been drained by reading from it. - */ - public function __construct($hwm = 16384) - { - $this->hwm = $hwm; - } - - public function __toString() - { - return $this->getContents(); - } - - public function getContents() - { - $buffer = $this->buffer; - $this->buffer = ''; - - return $buffer; - } - - public function close() - { - $this->buffer = ''; - } - - public function detach() - { - $this->close(); - } - - public function getSize() - { - return strlen($this->buffer); - } - - public function isReadable() - { - return true; - } - - public function isWritable() - { - return true; - } - - public function isSeekable() - { - return false; - } - - public function rewind() - { - $this->seek(0); - } - - public function seek($offset, $whence = SEEK_SET) - { - throw new \RuntimeException('Cannot seek a BufferStream'); - } - - public function eof() - { - return strlen($this->buffer) === 0; - } - - public function tell() - { - throw new \RuntimeException('Cannot determine the position of a BufferStream'); - } - - /** - * Reads data from the buffer. - */ - public function read($length) - { - $currentLength = strlen($this->buffer); - - if ($length >= $currentLength) { - // No need to slice the buffer because we don't have enough data. - $result = $this->buffer; - $this->buffer = ''; - } else { - // Slice up the result to provide a subset of the buffer. - $result = substr($this->buffer, 0, $length); - $this->buffer = substr($this->buffer, $length); - } - - return $result; - } - - /** - * Writes data to the buffer. - */ - public function write($string) - { - $this->buffer .= $string; - - // TODO: What should happen here? - if (strlen($this->buffer) >= $this->hwm) { - return false; - } - - return strlen($string); - } - - public function getMetadata($key = null) - { - if ($key == 'hwm') { - return $this->hwm; - } - - return $key ? null : []; - } -} diff --git a/vendor/guzzlehttp/psr7/src/CachingStream.php b/vendor/guzzlehttp/psr7/src/CachingStream.php deleted file mode 100755 index ed68f0861aabae9e2426129bf9fe234ce95e6654..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/CachingStream.php +++ /dev/null @@ -1,138 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\StreamInterface; - -/** - * Stream decorator that can cache previously read bytes from a sequentially - * read stream. - */ -class CachingStream implements StreamInterface -{ - use StreamDecoratorTrait; - - /** @var StreamInterface Stream being wrapped */ - private $remoteStream; - - /** @var int Number of bytes to skip reading due to a write on the buffer */ - private $skipReadBytes = 0; - - /** - * We will treat the buffer object as the body of the stream - * - * @param StreamInterface $stream Stream to cache - * @param StreamInterface $target Optionally specify where data is cached - */ - public function __construct( - StreamInterface $stream, - StreamInterface $target = null - ) { - $this->remoteStream = $stream; - $this->stream = $target ?: new Stream(fopen('php://temp', 'r+')); - } - - public function getSize() - { - return max($this->stream->getSize(), $this->remoteStream->getSize()); - } - - public function rewind() - { - $this->seek(0); - } - - public function seek($offset, $whence = SEEK_SET) - { - if ($whence == SEEK_SET) { - $byte = $offset; - } elseif ($whence == SEEK_CUR) { - $byte = $offset + $this->tell(); - } elseif ($whence == SEEK_END) { - $size = $this->remoteStream->getSize(); - if ($size === null) { - $size = $this->cacheEntireStream(); - } - $byte = $size + $offset; - } else { - throw new \InvalidArgumentException('Invalid whence'); - } - - $diff = $byte - $this->stream->getSize(); - - if ($diff > 0) { - // Read the remoteStream until we have read in at least the amount - // of bytes requested, or we reach the end of the file. - while ($diff > 0 && !$this->remoteStream->eof()) { - $this->read($diff); - $diff = $byte - $this->stream->getSize(); - } - } else { - // We can just do a normal seek since we've already seen this byte. - $this->stream->seek($byte); - } - } - - public function read($length) - { - // Perform a regular read on any previously read data from the buffer - $data = $this->stream->read($length); - $remaining = $length - strlen($data); - - // More data was requested so read from the remote stream - if ($remaining) { - // If data was written to the buffer in a position that would have - // been filled from the remote stream, then we must skip bytes on - // the remote stream to emulate overwriting bytes from that - // position. This mimics the behavior of other PHP stream wrappers. - $remoteData = $this->remoteStream->read( - $remaining + $this->skipReadBytes - ); - - if ($this->skipReadBytes) { - $len = strlen($remoteData); - $remoteData = substr($remoteData, $this->skipReadBytes); - $this->skipReadBytes = max(0, $this->skipReadBytes - $len); - } - - $data .= $remoteData; - $this->stream->write($remoteData); - } - - return $data; - } - - public function write($string) - { - // When appending to the end of the currently read stream, you'll want - // to skip bytes from being read from the remote stream to emulate - // other stream wrappers. Basically replacing bytes of data of a fixed - // length. - $overflow = (strlen($string) + $this->tell()) - $this->remoteStream->tell(); - if ($overflow > 0) { - $this->skipReadBytes += $overflow; - } - - return $this->stream->write($string); - } - - public function eof() - { - return $this->stream->eof() && $this->remoteStream->eof(); - } - - /** - * Close both the remote stream and buffer stream - */ - public function close() - { - $this->remoteStream->close() && $this->stream->close(); - } - - private function cacheEntireStream() - { - $target = new FnStream(['write' => 'strlen']); - copy_to_stream($this, $target); - - return $this->tell(); - } -} diff --git a/vendor/guzzlehttp/psr7/src/DroppingStream.php b/vendor/guzzlehttp/psr7/src/DroppingStream.php deleted file mode 100755 index 8935c80d7298b82796025998b4451d4cd0a91df2..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/DroppingStream.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\StreamInterface; - -/** - * Stream decorator that begins dropping data once the size of the underlying - * stream becomes too full. - */ -class DroppingStream implements StreamInterface -{ - use StreamDecoratorTrait; - - private $maxLength; - - /** - * @param StreamInterface $stream Underlying stream to decorate. - * @param int $maxLength Maximum size before dropping data. - */ - public function __construct(StreamInterface $stream, $maxLength) - { - $this->stream = $stream; - $this->maxLength = $maxLength; - } - - public function write($string) - { - $diff = $this->maxLength - $this->stream->getSize(); - - // Begin returning 0 when the underlying stream is too large. - if ($diff <= 0) { - return 0; - } - - // Write the stream or a subset of the stream if needed. - if (strlen($string) < $diff) { - return $this->stream->write($string); - } - - return $this->stream->write(substr($string, 0, $diff)); - } -} diff --git a/vendor/guzzlehttp/psr7/src/FnStream.php b/vendor/guzzlehttp/psr7/src/FnStream.php deleted file mode 100755 index cc9b4453f716150dacb93db04289b65a014c9186..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/FnStream.php +++ /dev/null @@ -1,149 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\StreamInterface; - -/** - * Compose stream implementations based on a hash of functions. - * - * Allows for easy testing and extension of a provided stream without needing - * to create a concrete class for a simple extension point. - */ -class FnStream implements StreamInterface -{ - /** @var array */ - private $methods; - - /** @var array Methods that must be implemented in the given array */ - private static $slots = ['__toString', 'close', 'detach', 'rewind', - 'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write', - 'isReadable', 'read', 'getContents', 'getMetadata']; - - /** - * @param array $methods Hash of method name to a callable. - */ - public function __construct(array $methods) - { - $this->methods = $methods; - - // Create the functions on the class - foreach ($methods as $name => $fn) { - $this->{'_fn_' . $name} = $fn; - } - } - - /** - * Lazily determine which methods are not implemented. - * @throws \BadMethodCallException - */ - public function __get($name) - { - throw new \BadMethodCallException(str_replace('_fn_', '', $name) - . '() is not implemented in the FnStream'); - } - - /** - * The close method is called on the underlying stream only if possible. - */ - public function __destruct() - { - if (isset($this->_fn_close)) { - call_user_func($this->_fn_close); - } - } - - /** - * Adds custom functionality to an underlying stream by intercepting - * specific method calls. - * - * @param StreamInterface $stream Stream to decorate - * @param array $methods Hash of method name to a closure - * - * @return FnStream - */ - public static function decorate(StreamInterface $stream, array $methods) - { - // If any of the required methods were not provided, then simply - // proxy to the decorated stream. - foreach (array_diff(self::$slots, array_keys($methods)) as $diff) { - $methods[$diff] = [$stream, $diff]; - } - - return new self($methods); - } - - public function __toString() - { - return call_user_func($this->_fn___toString); - } - - public function close() - { - return call_user_func($this->_fn_close); - } - - public function detach() - { - return call_user_func($this->_fn_detach); - } - - public function getSize() - { - return call_user_func($this->_fn_getSize); - } - - public function tell() - { - return call_user_func($this->_fn_tell); - } - - public function eof() - { - return call_user_func($this->_fn_eof); - } - - public function isSeekable() - { - return call_user_func($this->_fn_isSeekable); - } - - public function rewind() - { - call_user_func($this->_fn_rewind); - } - - public function seek($offset, $whence = SEEK_SET) - { - call_user_func($this->_fn_seek, $offset, $whence); - } - - public function isWritable() - { - return call_user_func($this->_fn_isWritable); - } - - public function write($string) - { - return call_user_func($this->_fn_write, $string); - } - - public function isReadable() - { - return call_user_func($this->_fn_isReadable); - } - - public function read($length) - { - return call_user_func($this->_fn_read, $length); - } - - public function getContents() - { - return call_user_func($this->_fn_getContents); - } - - public function getMetadata($key = null) - { - return call_user_func($this->_fn_getMetadata, $key); - } -} diff --git a/vendor/guzzlehttp/psr7/src/InflateStream.php b/vendor/guzzlehttp/psr7/src/InflateStream.php deleted file mode 100755 index 0051d3fec5a8bdd2d906f85bad4c6120949c7f4b..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/InflateStream.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\StreamInterface; - -/** - * Uses PHP's zlib.inflate filter to inflate deflate or gzipped content. - * - * This stream decorator skips the first 10 bytes of the given stream to remove - * the gzip header, converts the provided stream to a PHP stream resource, - * then appends the zlib.inflate filter. The stream is then converted back - * to a Guzzle stream resource to be used as a Guzzle stream. - * - * @link http://tools.ietf.org/html/rfc1952 - * @link http://php.net/manual/en/filters.compression.php - */ -class InflateStream implements StreamInterface -{ - use StreamDecoratorTrait; - - public function __construct(StreamInterface $stream) - { - // read the first 10 bytes, ie. gzip header - $header = $stream->read(10); - $filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header); - // Skip the header, that is 10 + length of filename + 1 (nil) bytes - $stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength); - $resource = StreamWrapper::getResource($stream); - stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ); - $this->stream = new Stream($resource); - } - - /** - * @param StreamInterface $stream - * @param $header - * @return int - */ - private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header) - { - $filename_header_length = 0; - - if (substr(bin2hex($header), 6, 2) === '08') { - // we have a filename, read until nil - $filename_header_length = 1; - while ($stream->read(1) !== chr(0)) { - $filename_header_length++; - } - } - - return $filename_header_length; - } -} diff --git a/vendor/guzzlehttp/psr7/src/LazyOpenStream.php b/vendor/guzzlehttp/psr7/src/LazyOpenStream.php deleted file mode 100755 index 02cec3af493cf3115dcb7cf8af0fc0a87dfbb0eb..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/LazyOpenStream.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\StreamInterface; - -/** - * Lazily reads or writes to a file that is opened only after an IO operation - * take place on the stream. - */ -class LazyOpenStream implements StreamInterface -{ - use StreamDecoratorTrait; - - /** @var string File to open */ - private $filename; - - /** @var string $mode */ - private $mode; - - /** - * @param string $filename File to lazily open - * @param string $mode fopen mode to use when opening the stream - */ - public function __construct($filename, $mode) - { - $this->filename = $filename; - $this->mode = $mode; - } - - /** - * Creates the underlying stream lazily when required. - * - * @return StreamInterface - */ - protected function createStream() - { - return stream_for(try_fopen($this->filename, $this->mode)); - } -} diff --git a/vendor/guzzlehttp/psr7/src/LimitStream.php b/vendor/guzzlehttp/psr7/src/LimitStream.php deleted file mode 100755 index 3c13d4f41155dc292b81be222a4bde4d027a63fd..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/LimitStream.php +++ /dev/null @@ -1,155 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\StreamInterface; - - -/** - * Decorator used to return only a subset of a stream - */ -class LimitStream implements StreamInterface -{ - use StreamDecoratorTrait; - - /** @var int Offset to start reading from */ - private $offset; - - /** @var int Limit the number of bytes that can be read */ - private $limit; - - /** - * @param StreamInterface $stream Stream to wrap - * @param int $limit Total number of bytes to allow to be read - * from the stream. Pass -1 for no limit. - * @param int $offset Position to seek to before reading (only - * works on seekable streams). - */ - public function __construct( - StreamInterface $stream, - $limit = -1, - $offset = 0 - ) { - $this->stream = $stream; - $this->setLimit($limit); - $this->setOffset($offset); - } - - public function eof() - { - // Always return true if the underlying stream is EOF - if ($this->stream->eof()) { - return true; - } - - // No limit and the underlying stream is not at EOF - if ($this->limit == -1) { - return false; - } - - return $this->stream->tell() >= $this->offset + $this->limit; - } - - /** - * Returns the size of the limited subset of data - * {@inheritdoc} - */ - public function getSize() - { - if (null === ($length = $this->stream->getSize())) { - return null; - } elseif ($this->limit == -1) { - return $length - $this->offset; - } else { - return min($this->limit, $length - $this->offset); - } - } - - /** - * Allow for a bounded seek on the read limited stream - * {@inheritdoc} - */ - public function seek($offset, $whence = SEEK_SET) - { - if ($whence !== SEEK_SET || $offset < 0) { - throw new \RuntimeException(sprintf( - 'Cannot seek to offset % with whence %s', - $offset, - $whence - )); - } - - $offset += $this->offset; - - if ($this->limit !== -1) { - if ($offset > $this->offset + $this->limit) { - $offset = $this->offset + $this->limit; - } - } - - $this->stream->seek($offset); - } - - /** - * Give a relative tell() - * {@inheritdoc} - */ - public function tell() - { - return $this->stream->tell() - $this->offset; - } - - /** - * Set the offset to start limiting from - * - * @param int $offset Offset to seek to and begin byte limiting from - * - * @throws \RuntimeException if the stream cannot be seeked. - */ - public function setOffset($offset) - { - $current = $this->stream->tell(); - - if ($current !== $offset) { - // If the stream cannot seek to the offset position, then read to it - if ($this->stream->isSeekable()) { - $this->stream->seek($offset); - } elseif ($current > $offset) { - throw new \RuntimeException("Could not seek to stream offset $offset"); - } else { - $this->stream->read($offset - $current); - } - } - - $this->offset = $offset; - } - - /** - * Set the limit of bytes that the decorator allows to be read from the - * stream. - * - * @param int $limit Number of bytes to allow to be read from the stream. - * Use -1 for no limit. - */ - public function setLimit($limit) - { - $this->limit = $limit; - } - - public function read($length) - { - if ($this->limit == -1) { - return $this->stream->read($length); - } - - // Check if the current position is less than the total allowed - // bytes + original offset - $remaining = ($this->offset + $this->limit) - $this->stream->tell(); - if ($remaining > 0) { - // Only return the amount of requested data, ensuring that the byte - // limit is not exceeded - return $this->stream->read(min($remaining, $length)); - } - - return ''; - } -} diff --git a/vendor/guzzlehttp/psr7/src/MessageTrait.php b/vendor/guzzlehttp/psr7/src/MessageTrait.php deleted file mode 100755 index 1e4da649ad5279f94c351f3ef95cc64a3cf837e3..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/MessageTrait.php +++ /dev/null @@ -1,183 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\StreamInterface; - -/** - * Trait implementing functionality common to requests and responses. - */ -trait MessageTrait -{ - /** @var array Map of all registered headers, as original name => array of values */ - private $headers = []; - - /** @var array Map of lowercase header name => original name at registration */ - private $headerNames = []; - - /** @var string */ - private $protocol = '1.1'; - - /** @var StreamInterface */ - private $stream; - - public function getProtocolVersion() - { - return $this->protocol; - } - - public function withProtocolVersion($version) - { - if ($this->protocol === $version) { - return $this; - } - - $new = clone $this; - $new->protocol = $version; - return $new; - } - - public function getHeaders() - { - return $this->headers; - } - - public function hasHeader($header) - { - return isset($this->headerNames[strtolower($header)]); - } - - public function getHeader($header) - { - $header = strtolower($header); - - if (!isset($this->headerNames[$header])) { - return []; - } - - $header = $this->headerNames[$header]; - - return $this->headers[$header]; - } - - public function getHeaderLine($header) - { - return implode(', ', $this->getHeader($header)); - } - - public function withHeader($header, $value) - { - if (!is_array($value)) { - $value = [$value]; - } - - $value = $this->trimHeaderValues($value); - $normalized = strtolower($header); - - $new = clone $this; - if (isset($new->headerNames[$normalized])) { - unset($new->headers[$new->headerNames[$normalized]]); - } - $new->headerNames[$normalized] = $header; - $new->headers[$header] = $value; - - return $new; - } - - public function withAddedHeader($header, $value) - { - if (!is_array($value)) { - $value = [$value]; - } - - $value = $this->trimHeaderValues($value); - $normalized = strtolower($header); - - $new = clone $this; - if (isset($new->headerNames[$normalized])) { - $header = $this->headerNames[$normalized]; - $new->headers[$header] = array_merge($this->headers[$header], $value); - } else { - $new->headerNames[$normalized] = $header; - $new->headers[$header] = $value; - } - - return $new; - } - - public function withoutHeader($header) - { - $normalized = strtolower($header); - - if (!isset($this->headerNames[$normalized])) { - return $this; - } - - $header = $this->headerNames[$normalized]; - - $new = clone $this; - unset($new->headers[$header], $new->headerNames[$normalized]); - - return $new; - } - - public function getBody() - { - if (!$this->stream) { - $this->stream = stream_for(''); - } - - return $this->stream; - } - - public function withBody(StreamInterface $body) - { - if ($body === $this->stream) { - return $this; - } - - $new = clone $this; - $new->stream = $body; - return $new; - } - - private function setHeaders(array $headers) - { - $this->headerNames = $this->headers = []; - foreach ($headers as $header => $value) { - if (!is_array($value)) { - $value = [$value]; - } - - $value = $this->trimHeaderValues($value); - $normalized = strtolower($header); - if (isset($this->headerNames[$normalized])) { - $header = $this->headerNames[$normalized]; - $this->headers[$header] = array_merge($this->headers[$header], $value); - } else { - $this->headerNames[$normalized] = $header; - $this->headers[$header] = $value; - } - } - } - - /** - * Trims whitespace from the header values. - * - * Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field. - * - * header-field = field-name ":" OWS field-value OWS - * OWS = *( SP / HTAB ) - * - * @param string[] $values Header values - * - * @return string[] Trimmed header values - * - * @see https://tools.ietf.org/html/rfc7230#section-3.2.4 - */ - private function trimHeaderValues(array $values) - { - return array_map(function ($value) { - return trim($value, " \t"); - }, $values); - } -} diff --git a/vendor/guzzlehttp/psr7/src/MultipartStream.php b/vendor/guzzlehttp/psr7/src/MultipartStream.php deleted file mode 100755 index c0fd584f759909f1491fdc316698fcbc6f92b365..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/MultipartStream.php +++ /dev/null @@ -1,153 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\StreamInterface; - -/** - * Stream that when read returns bytes for a streaming multipart or - * multipart/form-data stream. - */ -class MultipartStream implements StreamInterface -{ - use StreamDecoratorTrait; - - private $boundary; - - /** - * @param array $elements Array of associative arrays, each containing a - * required "name" key mapping to the form field, - * name, a required "contents" key mapping to a - * StreamInterface/resource/string, an optional - * "headers" associative array of custom headers, - * and an optional "filename" key mapping to a - * string to send as the filename in the part. - * @param string $boundary You can optionally provide a specific boundary - * - * @throws \InvalidArgumentException - */ - public function __construct(array $elements = [], $boundary = null) - { - $this->boundary = $boundary ?: sha1(uniqid('', true)); - $this->stream = $this->createStream($elements); - } - - /** - * Get the boundary - * - * @return string - */ - public function getBoundary() - { - return $this->boundary; - } - - public function isWritable() - { - return false; - } - - /** - * Get the headers needed before transferring the content of a POST file - */ - private function getHeaders(array $headers) - { - $str = ''; - foreach ($headers as $key => $value) { - $str .= "{$key}: {$value}\r\n"; - } - - return "--{$this->boundary}\r\n" . trim($str) . "\r\n\r\n"; - } - - /** - * Create the aggregate stream that will be used to upload the POST data - */ - protected function createStream(array $elements) - { - $stream = new AppendStream(); - - foreach ($elements as $element) { - $this->addElement($stream, $element); - } - - // Add the trailing boundary with CRLF - $stream->addStream(stream_for("--{$this->boundary}--\r\n")); - - return $stream; - } - - private function addElement(AppendStream $stream, array $element) - { - foreach (['contents', 'name'] as $key) { - if (!array_key_exists($key, $element)) { - throw new \InvalidArgumentException("A '{$key}' key is required"); - } - } - - $element['contents'] = stream_for($element['contents']); - - if (empty($element['filename'])) { - $uri = $element['contents']->getMetadata('uri'); - if (substr($uri, 0, 6) !== 'php://') { - $element['filename'] = $uri; - } - } - - list($body, $headers) = $this->createElement( - $element['name'], - $element['contents'], - isset($element['filename']) ? $element['filename'] : null, - isset($element['headers']) ? $element['headers'] : [] - ); - - $stream->addStream(stream_for($this->getHeaders($headers))); - $stream->addStream($body); - $stream->addStream(stream_for("\r\n")); - } - - /** - * @return array - */ - private function createElement($name, StreamInterface $stream, $filename, array $headers) - { - // Set a default content-disposition header if one was no provided - $disposition = $this->getHeader($headers, 'content-disposition'); - if (!$disposition) { - $headers['Content-Disposition'] = ($filename === '0' || $filename) - ? sprintf('form-data; name="%s"; filename="%s"', - $name, - basename($filename)) - : "form-data; name=\"{$name}\""; - } - - // Set a default content-length header if one was no provided - $length = $this->getHeader($headers, 'content-length'); - if (!$length) { - if ($length = $stream->getSize()) { - $headers['Content-Length'] = (string) $length; - } - } - - // Set a default Content-Type if one was not supplied - $type = $this->getHeader($headers, 'content-type'); - if (!$type && ($filename === '0' || $filename)) { - if ($type = mimetype_from_filename($filename)) { - $headers['Content-Type'] = $type; - } - } - - return [$stream, $headers]; - } - - private function getHeader(array $headers, $key) - { - $lowercaseHeader = strtolower($key); - foreach ($headers as $k => $v) { - if (strtolower($k) === $lowercaseHeader) { - return $v; - } - } - - return null; - } -} diff --git a/vendor/guzzlehttp/psr7/src/NoSeekStream.php b/vendor/guzzlehttp/psr7/src/NoSeekStream.php deleted file mode 100755 index 233221805ec619a752486e34251555f53987f410..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/NoSeekStream.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\StreamInterface; - -/** - * Stream decorator that prevents a stream from being seeked - */ -class NoSeekStream implements StreamInterface -{ - use StreamDecoratorTrait; - - public function seek($offset, $whence = SEEK_SET) - { - throw new \RuntimeException('Cannot seek a NoSeekStream'); - } - - public function isSeekable() - { - return false; - } -} diff --git a/vendor/guzzlehttp/psr7/src/PumpStream.php b/vendor/guzzlehttp/psr7/src/PumpStream.php deleted file mode 100755 index ffb5440da16585076adb6aea04c281eb9fd492fc..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/PumpStream.php +++ /dev/null @@ -1,165 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\StreamInterface; - -/** - * Provides a read only stream that pumps data from a PHP callable. - * - * When invoking the provided callable, the PumpStream will pass the amount of - * data requested to read to the callable. The callable can choose to ignore - * this value and return fewer or more bytes than requested. Any extra data - * returned by the provided callable is buffered internally until drained using - * the read() function of the PumpStream. The provided callable MUST return - * false when there is no more data to read. - */ -class PumpStream implements StreamInterface -{ - /** @var callable */ - private $source; - - /** @var int */ - private $size; - - /** @var int */ - private $tellPos = 0; - - /** @var array */ - private $metadata; - - /** @var BufferStream */ - private $buffer; - - /** - * @param callable $source Source of the stream data. The callable MAY - * accept an integer argument used to control the - * amount of data to return. The callable MUST - * return a string when called, or false on error - * or EOF. - * @param array $options Stream options: - * - metadata: Hash of metadata to use with stream. - * - size: Size of the stream, if known. - */ - public function __construct(callable $source, array $options = []) - { - $this->source = $source; - $this->size = isset($options['size']) ? $options['size'] : null; - $this->metadata = isset($options['metadata']) ? $options['metadata'] : []; - $this->buffer = new BufferStream(); - } - - public function __toString() - { - try { - return copy_to_string($this); - } catch (\Exception $e) { - return ''; - } - } - - public function close() - { - $this->detach(); - } - - public function detach() - { - $this->tellPos = false; - $this->source = null; - } - - public function getSize() - { - return $this->size; - } - - public function tell() - { - return $this->tellPos; - } - - public function eof() - { - return !$this->source; - } - - public function isSeekable() - { - return false; - } - - public function rewind() - { - $this->seek(0); - } - - public function seek($offset, $whence = SEEK_SET) - { - throw new \RuntimeException('Cannot seek a PumpStream'); - } - - public function isWritable() - { - return false; - } - - public function write($string) - { - throw new \RuntimeException('Cannot write to a PumpStream'); - } - - public function isReadable() - { - return true; - } - - public function read($length) - { - $data = $this->buffer->read($length); - $readLen = strlen($data); - $this->tellPos += $readLen; - $remaining = $length - $readLen; - - if ($remaining) { - $this->pump($remaining); - $data .= $this->buffer->read($remaining); - $this->tellPos += strlen($data) - $readLen; - } - - return $data; - } - - public function getContents() - { - $result = ''; - while (!$this->eof()) { - $result .= $this->read(1000000); - } - - return $result; - } - - public function getMetadata($key = null) - { - if (!$key) { - return $this->metadata; - } - - return isset($this->metadata[$key]) ? $this->metadata[$key] : null; - } - - private function pump($length) - { - if ($this->source) { - do { - $data = call_user_func($this->source, $length); - if ($data === false || $data === null) { - $this->source = null; - return; - } - $this->buffer->write($data); - $length -= strlen($data); - } while ($length > 0); - } - } -} diff --git a/vendor/guzzlehttp/psr7/src/Request.php b/vendor/guzzlehttp/psr7/src/Request.php deleted file mode 100755 index 08285484da22d738e3b7bc2781ef06e81d7f6b19..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/Request.php +++ /dev/null @@ -1,142 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use InvalidArgumentException; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\StreamInterface; -use Psr\Http\Message\UriInterface; - -/** - * PSR-7 request implementation. - */ -class Request implements RequestInterface -{ - use MessageTrait; - - /** @var string */ - private $method; - - /** @var null|string */ - private $requestTarget; - - /** @var UriInterface */ - private $uri; - - /** - * @param string $method HTTP method - * @param string|UriInterface $uri URI - * @param array $headers Request headers - * @param string|null|resource|StreamInterface $body Request body - * @param string $version Protocol version - */ - public function __construct( - $method, - $uri, - array $headers = [], - $body = null, - $version = '1.1' - ) { - if (!($uri instanceof UriInterface)) { - $uri = new Uri($uri); - } - - $this->method = strtoupper($method); - $this->uri = $uri; - $this->setHeaders($headers); - $this->protocol = $version; - - if (!$this->hasHeader('Host')) { - $this->updateHostFromUri(); - } - - if ($body !== '' && $body !== null) { - $this->stream = stream_for($body); - } - } - - public function getRequestTarget() - { - if ($this->requestTarget !== null) { - return $this->requestTarget; - } - - $target = $this->uri->getPath(); - if ($target == '') { - $target = '/'; - } - if ($this->uri->getQuery() != '') { - $target .= '?' . $this->uri->getQuery(); - } - - return $target; - } - - public function withRequestTarget($requestTarget) - { - if (preg_match('#\s#', $requestTarget)) { - throw new InvalidArgumentException( - 'Invalid request target provided; cannot contain whitespace' - ); - } - - $new = clone $this; - $new->requestTarget = $requestTarget; - return $new; - } - - public function getMethod() - { - return $this->method; - } - - public function withMethod($method) - { - $new = clone $this; - $new->method = strtoupper($method); - return $new; - } - - public function getUri() - { - return $this->uri; - } - - public function withUri(UriInterface $uri, $preserveHost = false) - { - if ($uri === $this->uri) { - return $this; - } - - $new = clone $this; - $new->uri = $uri; - - if (!$preserveHost) { - $new->updateHostFromUri(); - } - - return $new; - } - - private function updateHostFromUri() - { - $host = $this->uri->getHost(); - - if ($host == '') { - return; - } - - if (($port = $this->uri->getPort()) !== null) { - $host .= ':' . $port; - } - - if (isset($this->headerNames['host'])) { - $header = $this->headerNames['host']; - } else { - $header = 'Host'; - $this->headerNames['host'] = 'Host'; - } - // Ensure Host is the first header. - // See: http://tools.ietf.org/html/rfc7230#section-5.4 - $this->headers = [$header => [$host]] + $this->headers; - } -} diff --git a/vendor/guzzlehttp/psr7/src/Response.php b/vendor/guzzlehttp/psr7/src/Response.php deleted file mode 100755 index 2830c6c9ee10229c613e94f7b4360d6796c3e752..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/Response.php +++ /dev/null @@ -1,132 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\StreamInterface; - -/** - * PSR-7 response implementation. - */ -class Response implements ResponseInterface -{ - use MessageTrait; - - /** @var array Map of standard HTTP status code/reason phrases */ - private static $phrases = [ - 100 => 'Continue', - 101 => 'Switching Protocols', - 102 => 'Processing', - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - 207 => 'Multi-status', - 208 => 'Already Reported', - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 306 => 'Switch Proxy', - 307 => 'Temporary Redirect', - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Time-out', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Large', - 415 => 'Unsupported Media Type', - 416 => 'Requested range not satisfiable', - 417 => 'Expectation Failed', - 418 => 'I\'m a teapot', - 422 => 'Unprocessable Entity', - 423 => 'Locked', - 424 => 'Failed Dependency', - 425 => 'Unordered Collection', - 426 => 'Upgrade Required', - 428 => 'Precondition Required', - 429 => 'Too Many Requests', - 431 => 'Request Header Fields Too Large', - 451 => 'Unavailable For Legal Reasons', - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Time-out', - 505 => 'HTTP Version not supported', - 506 => 'Variant Also Negotiates', - 507 => 'Insufficient Storage', - 508 => 'Loop Detected', - 511 => 'Network Authentication Required', - ]; - - /** @var string */ - private $reasonPhrase = ''; - - /** @var int */ - private $statusCode = 200; - - /** - * @param int $status Status code - * @param array $headers Response headers - * @param string|null|resource|StreamInterface $body Response body - * @param string $version Protocol version - * @param string|null $reason Reason phrase (when empty a default will be used based on the status code) - */ - public function __construct( - $status = 200, - array $headers = [], - $body = null, - $version = '1.1', - $reason = null - ) { - $this->statusCode = (int) $status; - - if ($body !== '' && $body !== null) { - $this->stream = stream_for($body); - } - - $this->setHeaders($headers); - if ($reason == '' && isset(self::$phrases[$this->statusCode])) { - $this->reasonPhrase = self::$phrases[$this->statusCode]; - } else { - $this->reasonPhrase = (string) $reason; - } - - $this->protocol = $version; - } - - public function getStatusCode() - { - return $this->statusCode; - } - - public function getReasonPhrase() - { - return $this->reasonPhrase; - } - - public function withStatus($code, $reasonPhrase = '') - { - $new = clone $this; - $new->statusCode = (int) $code; - if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) { - $reasonPhrase = self::$phrases[$new->statusCode]; - } - $new->reasonPhrase = $reasonPhrase; - return $new; - } -} diff --git a/vendor/guzzlehttp/psr7/src/ServerRequest.php b/vendor/guzzlehttp/psr7/src/ServerRequest.php deleted file mode 100755 index 575aab8489a60279366f1b1cca29d93ad77287cd..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/ServerRequest.php +++ /dev/null @@ -1,358 +0,0 @@ -<?php - -namespace GuzzleHttp\Psr7; - -use InvalidArgumentException; -use Psr\Http\Message\ServerRequestInterface; -use Psr\Http\Message\UriInterface; -use Psr\Http\Message\StreamInterface; -use Psr\Http\Message\UploadedFileInterface; - -/** - * Server-side HTTP request - * - * Extends the Request definition to add methods for accessing incoming data, - * specifically server parameters, cookies, matched path parameters, query - * string arguments, body parameters, and upload file information. - * - * "Attributes" are discovered via decomposing the request (and usually - * specifically the URI path), and typically will be injected by the application. - * - * Requests are considered immutable; all methods that might change state are - * implemented such that they retain the internal state of the current - * message and return a new instance that contains the changed state. - */ -class ServerRequest extends Request implements ServerRequestInterface -{ - /** - * @var array - */ - private $attributes = []; - - /** - * @var array - */ - private $cookieParams = []; - - /** - * @var null|array|object - */ - private $parsedBody; - - /** - * @var array - */ - private $queryParams = []; - - /** - * @var array - */ - private $serverParams; - - /** - * @var array - */ - private $uploadedFiles = []; - - /** - * @param string $method HTTP method - * @param string|UriInterface $uri URI - * @param array $headers Request headers - * @param string|null|resource|StreamInterface $body Request body - * @param string $version Protocol version - * @param array $serverParams Typically the $_SERVER superglobal - */ - public function __construct( - $method, - $uri, - array $headers = [], - $body = null, - $version = '1.1', - array $serverParams = [] - ) { - $this->serverParams = $serverParams; - - parent::__construct($method, $uri, $headers, $body, $version); - } - - /** - * Return an UploadedFile instance array. - * - * @param array $files A array which respect $_FILES structure - * @throws InvalidArgumentException for unrecognized values - * @return array - */ - public static function normalizeFiles(array $files) - { - $normalized = []; - - foreach ($files as $key => $value) { - if ($value instanceof UploadedFileInterface) { - $normalized[$key] = $value; - } elseif (is_array($value) && isset($value['tmp_name'])) { - $normalized[$key] = self::createUploadedFileFromSpec($value); - } elseif (is_array($value)) { - $normalized[$key] = self::normalizeFiles($value); - continue; - } else { - throw new InvalidArgumentException('Invalid value in files specification'); - } - } - - return $normalized; - } - - /** - * Create and return an UploadedFile instance from a $_FILES specification. - * - * If the specification represents an array of values, this method will - * delegate to normalizeNestedFileSpec() and return that return value. - * - * @param array $value $_FILES struct - * @return array|UploadedFileInterface - */ - private static function createUploadedFileFromSpec(array $value) - { - if (is_array($value['tmp_name'])) { - return self::normalizeNestedFileSpec($value); - } - - return new UploadedFile( - $value['tmp_name'], - (int) $value['size'], - (int) $value['error'], - $value['name'], - $value['type'] - ); - } - - /** - * Normalize an array of file specifications. - * - * Loops through all nested files and returns a normalized array of - * UploadedFileInterface instances. - * - * @param array $files - * @return UploadedFileInterface[] - */ - private static function normalizeNestedFileSpec(array $files = []) - { - $normalizedFiles = []; - - foreach (array_keys($files['tmp_name']) as $key) { - $spec = [ - 'tmp_name' => $files['tmp_name'][$key], - 'size' => $files['size'][$key], - 'error' => $files['error'][$key], - 'name' => $files['name'][$key], - 'type' => $files['type'][$key], - ]; - $normalizedFiles[$key] = self::createUploadedFileFromSpec($spec); - } - - return $normalizedFiles; - } - - /** - * Return a ServerRequest populated with superglobals: - * $_GET - * $_POST - * $_COOKIE - * $_FILES - * $_SERVER - * - * @return ServerRequestInterface - */ - public static function fromGlobals() - { - $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET'; - $headers = function_exists('getallheaders') ? getallheaders() : []; - $uri = self::getUriFromGlobals(); - $body = new LazyOpenStream('php://input', 'r+'); - $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1'; - - $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER); - - return $serverRequest - ->withCookieParams($_COOKIE) - ->withQueryParams($_GET) - ->withParsedBody($_POST) - ->withUploadedFiles(self::normalizeFiles($_FILES)); - } - - /** - * Get a Uri populated with values from $_SERVER. - * - * @return UriInterface - */ - public static function getUriFromGlobals() { - $uri = new Uri(''); - - $uri = $uri->withScheme(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http'); - - $hasPort = false; - if (isset($_SERVER['HTTP_HOST'])) { - $hostHeaderParts = explode(':', $_SERVER['HTTP_HOST']); - $uri = $uri->withHost($hostHeaderParts[0]); - if (isset($hostHeaderParts[1])) { - $hasPort = true; - $uri = $uri->withPort($hostHeaderParts[1]); - } - } elseif (isset($_SERVER['SERVER_NAME'])) { - $uri = $uri->withHost($_SERVER['SERVER_NAME']); - } elseif (isset($_SERVER['SERVER_ADDR'])) { - $uri = $uri->withHost($_SERVER['SERVER_ADDR']); - } - - if (!$hasPort && isset($_SERVER['SERVER_PORT'])) { - $uri = $uri->withPort($_SERVER['SERVER_PORT']); - } - - $hasQuery = false; - if (isset($_SERVER['REQUEST_URI'])) { - $requestUriParts = explode('?', $_SERVER['REQUEST_URI']); - $uri = $uri->withPath($requestUriParts[0]); - if (isset($requestUriParts[1])) { - $hasQuery = true; - $uri = $uri->withQuery($requestUriParts[1]); - } - } - - if (!$hasQuery && isset($_SERVER['QUERY_STRING'])) { - $uri = $uri->withQuery($_SERVER['QUERY_STRING']); - } - - return $uri; - } - - - /** - * {@inheritdoc} - */ - public function getServerParams() - { - return $this->serverParams; - } - - /** - * {@inheritdoc} - */ - public function getUploadedFiles() - { - return $this->uploadedFiles; - } - - /** - * {@inheritdoc} - */ - public function withUploadedFiles(array $uploadedFiles) - { - $new = clone $this; - $new->uploadedFiles = $uploadedFiles; - - return $new; - } - - /** - * {@inheritdoc} - */ - public function getCookieParams() - { - return $this->cookieParams; - } - - /** - * {@inheritdoc} - */ - public function withCookieParams(array $cookies) - { - $new = clone $this; - $new->cookieParams = $cookies; - - return $new; - } - - /** - * {@inheritdoc} - */ - public function getQueryParams() - { - return $this->queryParams; - } - - /** - * {@inheritdoc} - */ - public function withQueryParams(array $query) - { - $new = clone $this; - $new->queryParams = $query; - - return $new; - } - - /** - * {@inheritdoc} - */ - public function getParsedBody() - { - return $this->parsedBody; - } - - /** - * {@inheritdoc} - */ - public function withParsedBody($data) - { - $new = clone $this; - $new->parsedBody = $data; - - return $new; - } - - /** - * {@inheritdoc} - */ - public function getAttributes() - { - return $this->attributes; - } - - /** - * {@inheritdoc} - */ - public function getAttribute($attribute, $default = null) - { - if (false === array_key_exists($attribute, $this->attributes)) { - return $default; - } - - return $this->attributes[$attribute]; - } - - /** - * {@inheritdoc} - */ - public function withAttribute($attribute, $value) - { - $new = clone $this; - $new->attributes[$attribute] = $value; - - return $new; - } - - /** - * {@inheritdoc} - */ - public function withoutAttribute($attribute) - { - if (false === array_key_exists($attribute, $this->attributes)) { - return $this; - } - - $new = clone $this; - unset($new->attributes[$attribute]); - - return $new; - } -} diff --git a/vendor/guzzlehttp/psr7/src/Stream.php b/vendor/guzzlehttp/psr7/src/Stream.php deleted file mode 100755 index e33662879ffbac5ee1fc971f1dc17fdedfd8979f..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/Stream.php +++ /dev/null @@ -1,257 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\StreamInterface; - -/** - * PHP stream implementation. - * - * @var $stream - */ -class Stream implements StreamInterface -{ - private $stream; - private $size; - private $seekable; - private $readable; - private $writable; - private $uri; - private $customMetadata; - - /** @var array Hash of readable and writable stream types */ - private static $readWriteHash = [ - 'read' => [ - 'r' => true, 'w+' => true, 'r+' => true, 'x+' => true, 'c+' => true, - 'rb' => true, 'w+b' => true, 'r+b' => true, 'x+b' => true, - 'c+b' => true, 'rt' => true, 'w+t' => true, 'r+t' => true, - 'x+t' => true, 'c+t' => true, 'a+' => true - ], - 'write' => [ - 'w' => true, 'w+' => true, 'rw' => true, 'r+' => true, 'x+' => true, - 'c+' => true, 'wb' => true, 'w+b' => true, 'r+b' => true, - 'x+b' => true, 'c+b' => true, 'w+t' => true, 'r+t' => true, - 'x+t' => true, 'c+t' => true, 'a' => true, 'a+' => true - ] - ]; - - /** - * This constructor accepts an associative array of options. - * - * - size: (int) If a read stream would otherwise have an indeterminate - * size, but the size is known due to foreknowledge, then you can - * provide that size, in bytes. - * - metadata: (array) Any additional metadata to return when the metadata - * of the stream is accessed. - * - * @param resource $stream Stream resource to wrap. - * @param array $options Associative array of options. - * - * @throws \InvalidArgumentException if the stream is not a stream resource - */ - public function __construct($stream, $options = []) - { - if (!is_resource($stream)) { - throw new \InvalidArgumentException('Stream must be a resource'); - } - - if (isset($options['size'])) { - $this->size = $options['size']; - } - - $this->customMetadata = isset($options['metadata']) - ? $options['metadata'] - : []; - - $this->stream = $stream; - $meta = stream_get_meta_data($this->stream); - $this->seekable = $meta['seekable']; - $this->readable = isset(self::$readWriteHash['read'][$meta['mode']]); - $this->writable = isset(self::$readWriteHash['write'][$meta['mode']]); - $this->uri = $this->getMetadata('uri'); - } - - public function __get($name) - { - if ($name == 'stream') { - throw new \RuntimeException('The stream is detached'); - } - - throw new \BadMethodCallException('No value for ' . $name); - } - - /** - * Closes the stream when the destructed - */ - public function __destruct() - { - $this->close(); - } - - public function __toString() - { - try { - $this->seek(0); - return (string) stream_get_contents($this->stream); - } catch (\Exception $e) { - return ''; - } - } - - public function getContents() - { - $contents = stream_get_contents($this->stream); - - if ($contents === false) { - throw new \RuntimeException('Unable to read stream contents'); - } - - return $contents; - } - - public function close() - { - if (isset($this->stream)) { - if (is_resource($this->stream)) { - fclose($this->stream); - } - $this->detach(); - } - } - - public function detach() - { - if (!isset($this->stream)) { - return null; - } - - $result = $this->stream; - unset($this->stream); - $this->size = $this->uri = null; - $this->readable = $this->writable = $this->seekable = false; - - return $result; - } - - public function getSize() - { - if ($this->size !== null) { - return $this->size; - } - - if (!isset($this->stream)) { - return null; - } - - // Clear the stat cache if the stream has a URI - if ($this->uri) { - clearstatcache(true, $this->uri); - } - - $stats = fstat($this->stream); - if (isset($stats['size'])) { - $this->size = $stats['size']; - return $this->size; - } - - return null; - } - - public function isReadable() - { - return $this->readable; - } - - public function isWritable() - { - return $this->writable; - } - - public function isSeekable() - { - return $this->seekable; - } - - public function eof() - { - return !$this->stream || feof($this->stream); - } - - public function tell() - { - $result = ftell($this->stream); - - if ($result === false) { - throw new \RuntimeException('Unable to determine stream position'); - } - - return $result; - } - - public function rewind() - { - $this->seek(0); - } - - public function seek($offset, $whence = SEEK_SET) - { - if (!$this->seekable) { - throw new \RuntimeException('Stream is not seekable'); - } elseif (fseek($this->stream, $offset, $whence) === -1) { - throw new \RuntimeException('Unable to seek to stream position ' - . $offset . ' with whence ' . var_export($whence, true)); - } - } - - public function read($length) - { - if (!$this->readable) { - throw new \RuntimeException('Cannot read from non-readable stream'); - } - if ($length < 0) { - throw new \RuntimeException('Length parameter cannot be negative'); - } - - if (0 === $length) { - return ''; - } - - $string = fread($this->stream, $length); - if (false === $string) { - throw new \RuntimeException('Unable to read from stream'); - } - - return $string; - } - - public function write($string) - { - if (!$this->writable) { - throw new \RuntimeException('Cannot write to a non-writable stream'); - } - - // We can't know the size after writing anything - $this->size = null; - $result = fwrite($this->stream, $string); - - if ($result === false) { - throw new \RuntimeException('Unable to write to stream'); - } - - return $result; - } - - public function getMetadata($key = null) - { - if (!isset($this->stream)) { - return $key ? null : []; - } elseif (!$key) { - return $this->customMetadata + stream_get_meta_data($this->stream); - } elseif (isset($this->customMetadata[$key])) { - return $this->customMetadata[$key]; - } - - $meta = stream_get_meta_data($this->stream); - - return isset($meta[$key]) ? $meta[$key] : null; - } -} diff --git a/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php b/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php deleted file mode 100755 index daec6f52ea740fe3312af92b63947bd9738168eb..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php +++ /dev/null @@ -1,149 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\StreamInterface; - -/** - * Stream decorator trait - * @property StreamInterface stream - */ -trait StreamDecoratorTrait -{ - /** - * @param StreamInterface $stream Stream to decorate - */ - public function __construct(StreamInterface $stream) - { - $this->stream = $stream; - } - - /** - * Magic method used to create a new stream if streams are not added in - * the constructor of a decorator (e.g., LazyOpenStream). - * - * @param string $name Name of the property (allows "stream" only). - * - * @return StreamInterface - */ - public function __get($name) - { - if ($name == 'stream') { - $this->stream = $this->createStream(); - return $this->stream; - } - - throw new \UnexpectedValueException("$name not found on class"); - } - - public function __toString() - { - try { - if ($this->isSeekable()) { - $this->seek(0); - } - return $this->getContents(); - } catch (\Exception $e) { - // Really, PHP? https://bugs.php.net/bug.php?id=53648 - trigger_error('StreamDecorator::__toString exception: ' - . (string) $e, E_USER_ERROR); - return ''; - } - } - - public function getContents() - { - return copy_to_string($this); - } - - /** - * Allow decorators to implement custom methods - * - * @param string $method Missing method name - * @param array $args Method arguments - * - * @return mixed - */ - public function __call($method, array $args) - { - $result = call_user_func_array([$this->stream, $method], $args); - - // Always return the wrapped object if the result is a return $this - return $result === $this->stream ? $this : $result; - } - - public function close() - { - $this->stream->close(); - } - - public function getMetadata($key = null) - { - return $this->stream->getMetadata($key); - } - - public function detach() - { - return $this->stream->detach(); - } - - public function getSize() - { - return $this->stream->getSize(); - } - - public function eof() - { - return $this->stream->eof(); - } - - public function tell() - { - return $this->stream->tell(); - } - - public function isReadable() - { - return $this->stream->isReadable(); - } - - public function isWritable() - { - return $this->stream->isWritable(); - } - - public function isSeekable() - { - return $this->stream->isSeekable(); - } - - public function rewind() - { - $this->seek(0); - } - - public function seek($offset, $whence = SEEK_SET) - { - $this->stream->seek($offset, $whence); - } - - public function read($length) - { - return $this->stream->read($length); - } - - public function write($string) - { - return $this->stream->write($string); - } - - /** - * Implement in subclasses to dynamically create streams when requested. - * - * @return StreamInterface - * @throws \BadMethodCallException - */ - protected function createStream() - { - throw new \BadMethodCallException('Not implemented'); - } -} diff --git a/vendor/guzzlehttp/psr7/src/StreamWrapper.php b/vendor/guzzlehttp/psr7/src/StreamWrapper.php deleted file mode 100755 index cf7b2232e463e21dc3eb6de440fdef70c6d057e7..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/StreamWrapper.php +++ /dev/null @@ -1,121 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\StreamInterface; - -/** - * Converts Guzzle streams into PHP stream resources. - */ -class StreamWrapper -{ - /** @var resource */ - public $context; - - /** @var StreamInterface */ - private $stream; - - /** @var string r, r+, or w */ - private $mode; - - /** - * Returns a resource representing the stream. - * - * @param StreamInterface $stream The stream to get a resource for - * - * @return resource - * @throws \InvalidArgumentException if stream is not readable or writable - */ - public static function getResource(StreamInterface $stream) - { - self::register(); - - if ($stream->isReadable()) { - $mode = $stream->isWritable() ? 'r+' : 'r'; - } elseif ($stream->isWritable()) { - $mode = 'w'; - } else { - throw new \InvalidArgumentException('The stream must be readable, ' - . 'writable, or both.'); - } - - return fopen('guzzle://stream', $mode, null, stream_context_create([ - 'guzzle' => ['stream' => $stream] - ])); - } - - /** - * Registers the stream wrapper if needed - */ - public static function register() - { - if (!in_array('guzzle', stream_get_wrappers())) { - stream_wrapper_register('guzzle', __CLASS__); - } - } - - public function stream_open($path, $mode, $options, &$opened_path) - { - $options = stream_context_get_options($this->context); - - if (!isset($options['guzzle']['stream'])) { - return false; - } - - $this->mode = $mode; - $this->stream = $options['guzzle']['stream']; - - return true; - } - - public function stream_read($count) - { - return $this->stream->read($count); - } - - public function stream_write($data) - { - return (int) $this->stream->write($data); - } - - public function stream_tell() - { - return $this->stream->tell(); - } - - public function stream_eof() - { - return $this->stream->eof(); - } - - public function stream_seek($offset, $whence) - { - $this->stream->seek($offset, $whence); - - return true; - } - - public function stream_stat() - { - static $modeMap = [ - 'r' => 33060, - 'r+' => 33206, - 'w' => 33188 - ]; - - return [ - 'dev' => 0, - 'ino' => 0, - 'mode' => $modeMap[$this->mode], - 'nlink' => 0, - 'uid' => 0, - 'gid' => 0, - 'rdev' => 0, - 'size' => $this->stream->getSize() ?: 0, - 'atime' => 0, - 'mtime' => 0, - 'ctime' => 0, - 'blksize' => 0, - 'blocks' => 0 - ]; - } -} diff --git a/vendor/guzzlehttp/psr7/src/UploadedFile.php b/vendor/guzzlehttp/psr7/src/UploadedFile.php deleted file mode 100755 index e62bd5c807698e37f2eb6e3c9a351aa9da18d05e..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/UploadedFile.php +++ /dev/null @@ -1,316 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use InvalidArgumentException; -use Psr\Http\Message\StreamInterface; -use Psr\Http\Message\UploadedFileInterface; -use RuntimeException; - -class UploadedFile implements UploadedFileInterface -{ - /** - * @var int[] - */ - private static $errors = [ - UPLOAD_ERR_OK, - UPLOAD_ERR_INI_SIZE, - UPLOAD_ERR_FORM_SIZE, - UPLOAD_ERR_PARTIAL, - UPLOAD_ERR_NO_FILE, - UPLOAD_ERR_NO_TMP_DIR, - UPLOAD_ERR_CANT_WRITE, - UPLOAD_ERR_EXTENSION, - ]; - - /** - * @var string - */ - private $clientFilename; - - /** - * @var string - */ - private $clientMediaType; - - /** - * @var int - */ - private $error; - - /** - * @var null|string - */ - private $file; - - /** - * @var bool - */ - private $moved = false; - - /** - * @var int - */ - private $size; - - /** - * @var StreamInterface|null - */ - private $stream; - - /** - * @param StreamInterface|string|resource $streamOrFile - * @param int $size - * @param int $errorStatus - * @param string|null $clientFilename - * @param string|null $clientMediaType - */ - public function __construct( - $streamOrFile, - $size, - $errorStatus, - $clientFilename = null, - $clientMediaType = null - ) { - $this->setError($errorStatus); - $this->setSize($size); - $this->setClientFilename($clientFilename); - $this->setClientMediaType($clientMediaType); - - if ($this->isOk()) { - $this->setStreamOrFile($streamOrFile); - } - } - - /** - * Depending on the value set file or stream variable - * - * @param mixed $streamOrFile - * @throws InvalidArgumentException - */ - private function setStreamOrFile($streamOrFile) - { - if (is_string($streamOrFile)) { - $this->file = $streamOrFile; - } elseif (is_resource($streamOrFile)) { - $this->stream = new Stream($streamOrFile); - } elseif ($streamOrFile instanceof StreamInterface) { - $this->stream = $streamOrFile; - } else { - throw new InvalidArgumentException( - 'Invalid stream or file provided for UploadedFile' - ); - } - } - - /** - * @param int $error - * @throws InvalidArgumentException - */ - private function setError($error) - { - if (false === is_int($error)) { - throw new InvalidArgumentException( - 'Upload file error status must be an integer' - ); - } - - if (false === in_array($error, UploadedFile::$errors)) { - throw new InvalidArgumentException( - 'Invalid error status for UploadedFile' - ); - } - - $this->error = $error; - } - - /** - * @param int $size - * @throws InvalidArgumentException - */ - private function setSize($size) - { - if (false === is_int($size)) { - throw new InvalidArgumentException( - 'Upload file size must be an integer' - ); - } - - $this->size = $size; - } - - /** - * @param mixed $param - * @return boolean - */ - private function isStringOrNull($param) - { - return in_array(gettype($param), ['string', 'NULL']); - } - - /** - * @param mixed $param - * @return boolean - */ - private function isStringNotEmpty($param) - { - return is_string($param) && false === empty($param); - } - - /** - * @param string|null $clientFilename - * @throws InvalidArgumentException - */ - private function setClientFilename($clientFilename) - { - if (false === $this->isStringOrNull($clientFilename)) { - throw new InvalidArgumentException( - 'Upload file client filename must be a string or null' - ); - } - - $this->clientFilename = $clientFilename; - } - - /** - * @param string|null $clientMediaType - * @throws InvalidArgumentException - */ - private function setClientMediaType($clientMediaType) - { - if (false === $this->isStringOrNull($clientMediaType)) { - throw new InvalidArgumentException( - 'Upload file client media type must be a string or null' - ); - } - - $this->clientMediaType = $clientMediaType; - } - - /** - * Return true if there is no upload error - * - * @return boolean - */ - private function isOk() - { - return $this->error === UPLOAD_ERR_OK; - } - - /** - * @return boolean - */ - public function isMoved() - { - return $this->moved; - } - - /** - * @throws RuntimeException if is moved or not ok - */ - private function validateActive() - { - if (false === $this->isOk()) { - throw new RuntimeException('Cannot retrieve stream due to upload error'); - } - - if ($this->isMoved()) { - throw new RuntimeException('Cannot retrieve stream after it has already been moved'); - } - } - - /** - * {@inheritdoc} - * @throws RuntimeException if the upload was not successful. - */ - public function getStream() - { - $this->validateActive(); - - if ($this->stream instanceof StreamInterface) { - return $this->stream; - } - - return new LazyOpenStream($this->file, 'r+'); - } - - /** - * {@inheritdoc} - * - * @see http://php.net/is_uploaded_file - * @see http://php.net/move_uploaded_file - * @param string $targetPath Path to which to move the uploaded file. - * @throws RuntimeException if the upload was not successful. - * @throws InvalidArgumentException if the $path specified is invalid. - * @throws RuntimeException on any error during the move operation, or on - * the second or subsequent call to the method. - */ - public function moveTo($targetPath) - { - $this->validateActive(); - - if (false === $this->isStringNotEmpty($targetPath)) { - throw new InvalidArgumentException( - 'Invalid path provided for move operation; must be a non-empty string' - ); - } - - if ($this->file) { - $this->moved = php_sapi_name() == 'cli' - ? rename($this->file, $targetPath) - : move_uploaded_file($this->file, $targetPath); - } else { - copy_to_stream( - $this->getStream(), - new LazyOpenStream($targetPath, 'w') - ); - - $this->moved = true; - } - - if (false === $this->moved) { - throw new RuntimeException( - sprintf('Uploaded file could not be moved to %s', $targetPath) - ); - } - } - - /** - * {@inheritdoc} - * - * @return int|null The file size in bytes or null if unknown. - */ - public function getSize() - { - return $this->size; - } - - /** - * {@inheritdoc} - * - * @see http://php.net/manual/en/features.file-upload.errors.php - * @return int One of PHP's UPLOAD_ERR_XXX constants. - */ - public function getError() - { - return $this->error; - } - - /** - * {@inheritdoc} - * - * @return string|null The filename sent by the client or null if none - * was provided. - */ - public function getClientFilename() - { - return $this->clientFilename; - } - - /** - * {@inheritdoc} - */ - public function getClientMediaType() - { - return $this->clientMediaType; - } -} diff --git a/vendor/guzzlehttp/psr7/src/Uri.php b/vendor/guzzlehttp/psr7/src/Uri.php deleted file mode 100755 index f46c1db9e07812e8d0069a4d9beb145ea3bfbf31..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/Uri.php +++ /dev/null @@ -1,702 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\UriInterface; - -/** - * PSR-7 URI implementation. - * - * @author Michael Dowling - * @author Tobias Schultze - * @author Matthew Weier O'Phinney - */ -class Uri implements UriInterface -{ - /** - * Absolute http and https URIs require a host per RFC 7230 Section 2.7 - * but in generic URIs the host can be empty. So for http(s) URIs - * we apply this default host when no host is given yet to form a - * valid URI. - */ - const HTTP_DEFAULT_HOST = 'localhost'; - - private static $defaultPorts = [ - 'http' => 80, - 'https' => 443, - 'ftp' => 21, - 'gopher' => 70, - 'nntp' => 119, - 'news' => 119, - 'telnet' => 23, - 'tn3270' => 23, - 'imap' => 143, - 'pop' => 110, - 'ldap' => 389, - ]; - - private static $charUnreserved = 'a-zA-Z0-9_\-\.~'; - private static $charSubDelims = '!\$&\'\(\)\*\+,;='; - private static $replaceQuery = ['=' => '%3D', '&' => '%26']; - - /** @var string Uri scheme. */ - private $scheme = ''; - - /** @var string Uri user info. */ - private $userInfo = ''; - - /** @var string Uri host. */ - private $host = ''; - - /** @var int|null Uri port. */ - private $port; - - /** @var string Uri path. */ - private $path = ''; - - /** @var string Uri query string. */ - private $query = ''; - - /** @var string Uri fragment. */ - private $fragment = ''; - - /** - * @param string $uri URI to parse - */ - public function __construct($uri = '') - { - // weak type check to also accept null until we can add scalar type hints - if ($uri != '') { - $parts = parse_url($uri); - if ($parts === false) { - throw new \InvalidArgumentException("Unable to parse URI: $uri"); - } - $this->applyParts($parts); - } - } - - public function __toString() - { - return self::composeComponents( - $this->scheme, - $this->getAuthority(), - $this->path, - $this->query, - $this->fragment - ); - } - - /** - * Composes a URI reference string from its various components. - * - * Usually this method does not need to be called manually but instead is used indirectly via - * `Psr\Http\Message\UriInterface::__toString`. - * - * PSR-7 UriInterface treats an empty component the same as a missing component as - * getQuery(), getFragment() etc. always return a string. This explains the slight - * difference to RFC 3986 Section 5.3. - * - * Another adjustment is that the authority separator is added even when the authority is missing/empty - * for the "file" scheme. This is because PHP stream functions like `file_get_contents` only work with - * `file:///myfile` but not with `file:/myfile` although they are equivalent according to RFC 3986. But - * `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to - * that format). - * - * @param string $scheme - * @param string $authority - * @param string $path - * @param string $query - * @param string $fragment - * - * @return string - * - * @link https://tools.ietf.org/html/rfc3986#section-5.3 - */ - public static function composeComponents($scheme, $authority, $path, $query, $fragment) - { - $uri = ''; - - // weak type checks to also accept null until we can add scalar type hints - if ($scheme != '') { - $uri .= $scheme . ':'; - } - - if ($authority != ''|| $scheme === 'file') { - $uri .= '//' . $authority; - } - - $uri .= $path; - - if ($query != '') { - $uri .= '?' . $query; - } - - if ($fragment != '') { - $uri .= '#' . $fragment; - } - - return $uri; - } - - /** - * Whether the URI has the default port of the current scheme. - * - * `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used - * independently of the implementation. - * - * @param UriInterface $uri - * - * @return bool - */ - public static function isDefaultPort(UriInterface $uri) - { - return $uri->getPort() === null - || (isset(self::$defaultPorts[$uri->getScheme()]) && $uri->getPort() === self::$defaultPorts[$uri->getScheme()]); - } - - /** - * Whether the URI is absolute, i.e. it has a scheme. - * - * An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true - * if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative - * to another URI, the base URI. Relative references can be divided into several forms: - * - network-path references, e.g. '//example.com/path' - * - absolute-path references, e.g. '/path' - * - relative-path references, e.g. 'subpath' - * - * @param UriInterface $uri - * - * @return bool - * @see Uri::isNetworkPathReference - * @see Uri::isAbsolutePathReference - * @see Uri::isRelativePathReference - * @link https://tools.ietf.org/html/rfc3986#section-4 - */ - public static function isAbsolute(UriInterface $uri) - { - return $uri->getScheme() !== ''; - } - - /** - * Whether the URI is a network-path reference. - * - * A relative reference that begins with two slash characters is termed an network-path reference. - * - * @param UriInterface $uri - * - * @return bool - * @link https://tools.ietf.org/html/rfc3986#section-4.2 - */ - public static function isNetworkPathReference(UriInterface $uri) - { - return $uri->getScheme() === '' && $uri->getAuthority() !== ''; - } - - /** - * Whether the URI is a absolute-path reference. - * - * A relative reference that begins with a single slash character is termed an absolute-path reference. - * - * @param UriInterface $uri - * - * @return bool - * @link https://tools.ietf.org/html/rfc3986#section-4.2 - */ - public static function isAbsolutePathReference(UriInterface $uri) - { - return $uri->getScheme() === '' - && $uri->getAuthority() === '' - && isset($uri->getPath()[0]) - && $uri->getPath()[0] === '/'; - } - - /** - * Whether the URI is a relative-path reference. - * - * A relative reference that does not begin with a slash character is termed a relative-path reference. - * - * @param UriInterface $uri - * - * @return bool - * @link https://tools.ietf.org/html/rfc3986#section-4.2 - */ - public static function isRelativePathReference(UriInterface $uri) - { - return $uri->getScheme() === '' - && $uri->getAuthority() === '' - && (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/'); - } - - /** - * Whether the URI is a same-document reference. - * - * A same-document reference refers to a URI that is, aside from its fragment - * component, identical to the base URI. When no base URI is given, only an empty - * URI reference (apart from its fragment) is considered a same-document reference. - * - * @param UriInterface $uri The URI to check - * @param UriInterface|null $base An optional base URI to compare against - * - * @return bool - * @link https://tools.ietf.org/html/rfc3986#section-4.4 - */ - public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null) - { - if ($base !== null) { - $uri = UriResolver::resolve($base, $uri); - - return ($uri->getScheme() === $base->getScheme()) - && ($uri->getAuthority() === $base->getAuthority()) - && ($uri->getPath() === $base->getPath()) - && ($uri->getQuery() === $base->getQuery()); - } - - return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === ''; - } - - /** - * Removes dot segments from a path and returns the new path. - * - * @param string $path - * - * @return string - * - * @deprecated since version 1.4. Use UriResolver::removeDotSegments instead. - * @see UriResolver::removeDotSegments - */ - public static function removeDotSegments($path) - { - return UriResolver::removeDotSegments($path); - } - - /** - * Converts the relative URI into a new URI that is resolved against the base URI. - * - * @param UriInterface $base Base URI - * @param string|UriInterface $rel Relative URI - * - * @return UriInterface - * - * @deprecated since version 1.4. Use UriResolver::resolve instead. - * @see UriResolver::resolve - */ - public static function resolve(UriInterface $base, $rel) - { - if (!($rel instanceof UriInterface)) { - $rel = new self($rel); - } - - return UriResolver::resolve($base, $rel); - } - - /** - * Creates a new URI with a specific query string value removed. - * - * Any existing query string values that exactly match the provided key are - * removed. - * - * @param UriInterface $uri URI to use as a base. - * @param string $key Query string key to remove. - * - * @return UriInterface - */ - public static function withoutQueryValue(UriInterface $uri, $key) - { - $current = $uri->getQuery(); - if ($current === '') { - return $uri; - } - - $decodedKey = rawurldecode($key); - $result = array_filter(explode('&', $current), function ($part) use ($decodedKey) { - return rawurldecode(explode('=', $part)[0]) !== $decodedKey; - }); - - return $uri->withQuery(implode('&', $result)); - } - - /** - * Creates a new URI with a specific query string value. - * - * Any existing query string values that exactly match the provided key are - * removed and replaced with the given key value pair. - * - * A value of null will set the query string key without a value, e.g. "key" - * instead of "key=value". - * - * @param UriInterface $uri URI to use as a base. - * @param string $key Key to set. - * @param string|null $value Value to set - * - * @return UriInterface - */ - public static function withQueryValue(UriInterface $uri, $key, $value) - { - $current = $uri->getQuery(); - - if ($current === '') { - $result = []; - } else { - $decodedKey = rawurldecode($key); - $result = array_filter(explode('&', $current), function ($part) use ($decodedKey) { - return rawurldecode(explode('=', $part)[0]) !== $decodedKey; - }); - } - - // Query string separators ("=", "&") within the key or value need to be encoded - // (while preventing double-encoding) before setting the query string. All other - // chars that need percent-encoding will be encoded by withQuery(). - $key = strtr($key, self::$replaceQuery); - - if ($value !== null) { - $result[] = $key . '=' . strtr($value, self::$replaceQuery); - } else { - $result[] = $key; - } - - return $uri->withQuery(implode('&', $result)); - } - - /** - * Creates a URI from a hash of `parse_url` components. - * - * @param array $parts - * - * @return UriInterface - * @link http://php.net/manual/en/function.parse-url.php - * - * @throws \InvalidArgumentException If the components do not form a valid URI. - */ - public static function fromParts(array $parts) - { - $uri = new self(); - $uri->applyParts($parts); - $uri->validateState(); - - return $uri; - } - - public function getScheme() - { - return $this->scheme; - } - - public function getAuthority() - { - $authority = $this->host; - if ($this->userInfo !== '') { - $authority = $this->userInfo . '@' . $authority; - } - - if ($this->port !== null) { - $authority .= ':' . $this->port; - } - - return $authority; - } - - public function getUserInfo() - { - return $this->userInfo; - } - - public function getHost() - { - return $this->host; - } - - public function getPort() - { - return $this->port; - } - - public function getPath() - { - return $this->path; - } - - public function getQuery() - { - return $this->query; - } - - public function getFragment() - { - return $this->fragment; - } - - public function withScheme($scheme) - { - $scheme = $this->filterScheme($scheme); - - if ($this->scheme === $scheme) { - return $this; - } - - $new = clone $this; - $new->scheme = $scheme; - $new->removeDefaultPort(); - $new->validateState(); - - return $new; - } - - public function withUserInfo($user, $password = null) - { - $info = $user; - if ($password != '') { - $info .= ':' . $password; - } - - if ($this->userInfo === $info) { - return $this; - } - - $new = clone $this; - $new->userInfo = $info; - $new->validateState(); - - return $new; - } - - public function withHost($host) - { - $host = $this->filterHost($host); - - if ($this->host === $host) { - return $this; - } - - $new = clone $this; - $new->host = $host; - $new->validateState(); - - return $new; - } - - public function withPort($port) - { - $port = $this->filterPort($port); - - if ($this->port === $port) { - return $this; - } - - $new = clone $this; - $new->port = $port; - $new->removeDefaultPort(); - $new->validateState(); - - return $new; - } - - public function withPath($path) - { - $path = $this->filterPath($path); - - if ($this->path === $path) { - return $this; - } - - $new = clone $this; - $new->path = $path; - $new->validateState(); - - return $new; - } - - public function withQuery($query) - { - $query = $this->filterQueryAndFragment($query); - - if ($this->query === $query) { - return $this; - } - - $new = clone $this; - $new->query = $query; - - return $new; - } - - public function withFragment($fragment) - { - $fragment = $this->filterQueryAndFragment($fragment); - - if ($this->fragment === $fragment) { - return $this; - } - - $new = clone $this; - $new->fragment = $fragment; - - return $new; - } - - /** - * Apply parse_url parts to a URI. - * - * @param array $parts Array of parse_url parts to apply. - */ - private function applyParts(array $parts) - { - $this->scheme = isset($parts['scheme']) - ? $this->filterScheme($parts['scheme']) - : ''; - $this->userInfo = isset($parts['user']) ? $parts['user'] : ''; - $this->host = isset($parts['host']) - ? $this->filterHost($parts['host']) - : ''; - $this->port = isset($parts['port']) - ? $this->filterPort($parts['port']) - : null; - $this->path = isset($parts['path']) - ? $this->filterPath($parts['path']) - : ''; - $this->query = isset($parts['query']) - ? $this->filterQueryAndFragment($parts['query']) - : ''; - $this->fragment = isset($parts['fragment']) - ? $this->filterQueryAndFragment($parts['fragment']) - : ''; - if (isset($parts['pass'])) { - $this->userInfo .= ':' . $parts['pass']; - } - - $this->removeDefaultPort(); - } - - /** - * @param string $scheme - * - * @return string - * - * @throws \InvalidArgumentException If the scheme is invalid. - */ - private function filterScheme($scheme) - { - if (!is_string($scheme)) { - throw new \InvalidArgumentException('Scheme must be a string'); - } - - return strtolower($scheme); - } - - /** - * @param string $host - * - * @return string - * - * @throws \InvalidArgumentException If the host is invalid. - */ - private function filterHost($host) - { - if (!is_string($host)) { - throw new \InvalidArgumentException('Host must be a string'); - } - - return strtolower($host); - } - - /** - * @param int|null $port - * - * @return int|null - * - * @throws \InvalidArgumentException If the port is invalid. - */ - private function filterPort($port) - { - if ($port === null) { - return null; - } - - $port = (int) $port; - if (1 > $port || 0xffff < $port) { - throw new \InvalidArgumentException( - sprintf('Invalid port: %d. Must be between 1 and 65535', $port) - ); - } - - return $port; - } - - private function removeDefaultPort() - { - if ($this->port !== null && self::isDefaultPort($this)) { - $this->port = null; - } - } - - /** - * Filters the path of a URI - * - * @param string $path - * - * @return string - * - * @throws \InvalidArgumentException If the path is invalid. - */ - private function filterPath($path) - { - if (!is_string($path)) { - throw new \InvalidArgumentException('Path must be a string'); - } - - return preg_replace_callback( - '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/', - [$this, 'rawurlencodeMatchZero'], - $path - ); - } - - /** - * Filters the query string or fragment of a URI. - * - * @param string $str - * - * @return string - * - * @throws \InvalidArgumentException If the query or fragment is invalid. - */ - private function filterQueryAndFragment($str) - { - if (!is_string($str)) { - throw new \InvalidArgumentException('Query and fragment must be a string'); - } - - return preg_replace_callback( - '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/', - [$this, 'rawurlencodeMatchZero'], - $str - ); - } - - private function rawurlencodeMatchZero(array $match) - { - return rawurlencode($match[0]); - } - - private function validateState() - { - if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) { - $this->host = self::HTTP_DEFAULT_HOST; - } - - if ($this->getAuthority() === '') { - if (0 === strpos($this->path, '//')) { - throw new \InvalidArgumentException('The path of a URI without an authority must not start with two slashes "//"'); - } - if ($this->scheme === '' && false !== strpos(explode('/', $this->path, 2)[0], ':')) { - throw new \InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon'); - } - } elseif (isset($this->path[0]) && $this->path[0] !== '/') { - @trigger_error( - 'The path of a URI with an authority must start with a slash "/" or be empty. Automagically fixing the URI ' . - 'by adding a leading slash to the path is deprecated since version 1.4 and will throw an exception instead.', - E_USER_DEPRECATED - ); - $this->path = '/'. $this->path; - //throw new \InvalidArgumentException('The path of a URI with an authority must start with a slash "/" or be empty'); - } - } -} diff --git a/vendor/guzzlehttp/psr7/src/UriNormalizer.php b/vendor/guzzlehttp/psr7/src/UriNormalizer.php deleted file mode 100755 index 384c29e50864f584d947e75fddb39538b3862258..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/UriNormalizer.php +++ /dev/null @@ -1,216 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\UriInterface; - -/** - * Provides methods to normalize and compare URIs. - * - * @author Tobias Schultze - * - * @link https://tools.ietf.org/html/rfc3986#section-6 - */ -final class UriNormalizer -{ - /** - * Default normalizations which only include the ones that preserve semantics. - * - * self::CAPITALIZE_PERCENT_ENCODING | self::DECODE_UNRESERVED_CHARACTERS | self::CONVERT_EMPTY_PATH | - * self::REMOVE_DEFAULT_HOST | self::REMOVE_DEFAULT_PORT | self::REMOVE_DOT_SEGMENTS - */ - const PRESERVING_NORMALIZATIONS = 63; - - /** - * All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized. - * - * Example: http://example.org/a%c2%b1b → http://example.org/a%C2%B1b - */ - const CAPITALIZE_PERCENT_ENCODING = 1; - - /** - * Decodes percent-encoded octets of unreserved characters. - * - * For consistency, percent-encoded octets in the ranges of ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), - * hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should not be created by URI producers and, - * when found in a URI, should be decoded to their corresponding unreserved characters by URI normalizers. - * - * Example: http://example.org/%7Eusern%61me/ → http://example.org/~username/ - */ - const DECODE_UNRESERVED_CHARACTERS = 2; - - /** - * Converts the empty path to "/" for http and https URIs. - * - * Example: http://example.org → http://example.org/ - */ - const CONVERT_EMPTY_PATH = 4; - - /** - * Removes the default host of the given URI scheme from the URI. - * - * Only the "file" scheme defines the default host "localhost". - * All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile` - * are equivalent according to RFC 3986. The first format is not accepted - * by PHPs stream functions and thus already normalized implicitly to the - * second format in the Uri class. See `GuzzleHttp\Psr7\Uri::composeComponents`. - * - * Example: file://localhost/myfile → file:///myfile - */ - const REMOVE_DEFAULT_HOST = 8; - - /** - * Removes the default port of the given URI scheme from the URI. - * - * Example: http://example.org:80/ → http://example.org/ - */ - const REMOVE_DEFAULT_PORT = 16; - - /** - * Removes unnecessary dot-segments. - * - * Dot-segments in relative-path references are not removed as it would - * change the semantics of the URI reference. - * - * Example: http://example.org/../a/b/../c/./d.html → http://example.org/a/c/d.html - */ - const REMOVE_DOT_SEGMENTS = 32; - - /** - * Paths which include two or more adjacent slashes are converted to one. - * - * Webservers usually ignore duplicate slashes and treat those URIs equivalent. - * But in theory those URIs do not need to be equivalent. So this normalization - * may change the semantics. Encoded slashes (%2F) are not removed. - * - * Example: http://example.org//foo///bar.html → http://example.org/foo/bar.html - */ - const REMOVE_DUPLICATE_SLASHES = 64; - - /** - * Sort query parameters with their values in alphabetical order. - * - * However, the order of parameters in a URI may be significant (this is not defined by the standard). - * So this normalization is not safe and may change the semantics of the URI. - * - * Example: ?lang=en&article=fred → ?article=fred&lang=en - * - * Note: The sorting is neither locale nor Unicode aware (the URI query does not get decoded at all) as the - * purpose is to be able to compare URIs in a reproducible way, not to have the params sorted perfectly. - */ - const SORT_QUERY_PARAMETERS = 128; - - /** - * Returns a normalized URI. - * - * The scheme and host component are already normalized to lowercase per PSR-7 UriInterface. - * This methods adds additional normalizations that can be configured with the $flags parameter. - * - * PSR-7 UriInterface cannot distinguish between an empty component and a missing component as - * getQuery(), getFragment() etc. always return a string. This means the URIs "/?#" and "/" are - * treated equivalent which is not necessarily true according to RFC 3986. But that difference - * is highly uncommon in reality. So this potential normalization is implied in PSR-7 as well. - * - * @param UriInterface $uri The URI to normalize - * @param int $flags A bitmask of normalizations to apply, see constants - * - * @return UriInterface The normalized URI - * @link https://tools.ietf.org/html/rfc3986#section-6.2 - */ - public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS) - { - if ($flags & self::CAPITALIZE_PERCENT_ENCODING) { - $uri = self::capitalizePercentEncoding($uri); - } - - if ($flags & self::DECODE_UNRESERVED_CHARACTERS) { - $uri = self::decodeUnreservedCharacters($uri); - } - - if ($flags & self::CONVERT_EMPTY_PATH && $uri->getPath() === '' && - ($uri->getScheme() === 'http' || $uri->getScheme() === 'https') - ) { - $uri = $uri->withPath('/'); - } - - if ($flags & self::REMOVE_DEFAULT_HOST && $uri->getScheme() === 'file' && $uri->getHost() === 'localhost') { - $uri = $uri->withHost(''); - } - - if ($flags & self::REMOVE_DEFAULT_PORT && $uri->getPort() !== null && Uri::isDefaultPort($uri)) { - $uri = $uri->withPort(null); - } - - if ($flags & self::REMOVE_DOT_SEGMENTS && !Uri::isRelativePathReference($uri)) { - $uri = $uri->withPath(UriResolver::removeDotSegments($uri->getPath())); - } - - if ($flags & self::REMOVE_DUPLICATE_SLASHES) { - $uri = $uri->withPath(preg_replace('#//++#', '/', $uri->getPath())); - } - - if ($flags & self::SORT_QUERY_PARAMETERS && $uri->getQuery() !== '') { - $queryKeyValues = explode('&', $uri->getQuery()); - sort($queryKeyValues); - $uri = $uri->withQuery(implode('&', $queryKeyValues)); - } - - return $uri; - } - - /** - * Whether two URIs can be considered equivalent. - * - * Both URIs are normalized automatically before comparison with the given $normalizations bitmask. The method also - * accepts relative URI references and returns true when they are equivalent. This of course assumes they will be - * resolved against the same base URI. If this is not the case, determination of equivalence or difference of - * relative references does not mean anything. - * - * @param UriInterface $uri1 An URI to compare - * @param UriInterface $uri2 An URI to compare - * @param int $normalizations A bitmask of normalizations to apply, see constants - * - * @return bool - * @link https://tools.ietf.org/html/rfc3986#section-6.1 - */ - public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS) - { - return (string) self::normalize($uri1, $normalizations) === (string) self::normalize($uri2, $normalizations); - } - - private static function capitalizePercentEncoding(UriInterface $uri) - { - $regex = '/(?:%[A-Fa-f0-9]{2})++/'; - - $callback = function (array $match) { - return strtoupper($match[0]); - }; - - return - $uri->withPath( - preg_replace_callback($regex, $callback, $uri->getPath()) - )->withQuery( - preg_replace_callback($regex, $callback, $uri->getQuery()) - ); - } - - private static function decodeUnreservedCharacters(UriInterface $uri) - { - $regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i'; - - $callback = function (array $match) { - return rawurldecode($match[0]); - }; - - return - $uri->withPath( - preg_replace_callback($regex, $callback, $uri->getPath()) - )->withQuery( - preg_replace_callback($regex, $callback, $uri->getQuery()) - ); - } - - private function __construct() - { - // cannot be instantiated - } -} diff --git a/vendor/guzzlehttp/psr7/src/UriResolver.php b/vendor/guzzlehttp/psr7/src/UriResolver.php deleted file mode 100755 index c1cb8a275af212848f5014f424cc5732e4d32906..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/UriResolver.php +++ /dev/null @@ -1,219 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\UriInterface; - -/** - * Resolves a URI reference in the context of a base URI and the opposite way. - * - * @author Tobias Schultze - * - * @link https://tools.ietf.org/html/rfc3986#section-5 - */ -final class UriResolver -{ - /** - * Removes dot segments from a path and returns the new path. - * - * @param string $path - * - * @return string - * @link http://tools.ietf.org/html/rfc3986#section-5.2.4 - */ - public static function removeDotSegments($path) - { - if ($path === '' || $path === '/') { - return $path; - } - - $results = []; - $segments = explode('/', $path); - foreach ($segments as $segment) { - if ($segment === '..') { - array_pop($results); - } elseif ($segment !== '.') { - $results[] = $segment; - } - } - - $newPath = implode('/', $results); - - if ($path[0] === '/' && (!isset($newPath[0]) || $newPath[0] !== '/')) { - // Re-add the leading slash if necessary for cases like "/.." - $newPath = '/' . $newPath; - } elseif ($newPath !== '' && ($segment === '.' || $segment === '..')) { - // Add the trailing slash if necessary - // If newPath is not empty, then $segment must be set and is the last segment from the foreach - $newPath .= '/'; - } - - return $newPath; - } - - /** - * Converts the relative URI into a new URI that is resolved against the base URI. - * - * @param UriInterface $base Base URI - * @param UriInterface $rel Relative URI - * - * @return UriInterface - * @link http://tools.ietf.org/html/rfc3986#section-5.2 - */ - public static function resolve(UriInterface $base, UriInterface $rel) - { - if ((string) $rel === '') { - // we can simply return the same base URI instance for this same-document reference - return $base; - } - - if ($rel->getScheme() != '') { - return $rel->withPath(self::removeDotSegments($rel->getPath())); - } - - if ($rel->getAuthority() != '') { - $targetAuthority = $rel->getAuthority(); - $targetPath = self::removeDotSegments($rel->getPath()); - $targetQuery = $rel->getQuery(); - } else { - $targetAuthority = $base->getAuthority(); - if ($rel->getPath() === '') { - $targetPath = $base->getPath(); - $targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery(); - } else { - if ($rel->getPath()[0] === '/') { - $targetPath = $rel->getPath(); - } else { - if ($targetAuthority != '' && $base->getPath() === '') { - $targetPath = '/' . $rel->getPath(); - } else { - $lastSlashPos = strrpos($base->getPath(), '/'); - if ($lastSlashPos === false) { - $targetPath = $rel->getPath(); - } else { - $targetPath = substr($base->getPath(), 0, $lastSlashPos + 1) . $rel->getPath(); - } - } - } - $targetPath = self::removeDotSegments($targetPath); - $targetQuery = $rel->getQuery(); - } - } - - return new Uri(Uri::composeComponents( - $base->getScheme(), - $targetAuthority, - $targetPath, - $targetQuery, - $rel->getFragment() - )); - } - - /** - * Returns the target URI as a relative reference from the base URI. - * - * This method is the counterpart to resolve(): - * - * (string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target)) - * - * One use-case is to use the current request URI as base URI and then generate relative links in your documents - * to reduce the document size or offer self-contained downloadable document archives. - * - * $base = new Uri('http://example.com/a/b/'); - * echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'. - * echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'. - * echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'. - * echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'. - * - * This method also accepts a target that is already relative and will try to relativize it further. Only a - * relative-path reference will be returned as-is. - * - * echo UriResolver::relativize($base, new Uri('/a/b/c')); // prints 'c' as well - * - * @param UriInterface $base Base URI - * @param UriInterface $target Target URI - * - * @return UriInterface The relative URI reference - */ - public static function relativize(UriInterface $base, UriInterface $target) - { - if ($target->getScheme() !== '' && - ($base->getScheme() !== $target->getScheme() || $target->getAuthority() === '' && $base->getAuthority() !== '') - ) { - return $target; - } - - if (Uri::isRelativePathReference($target)) { - // As the target is already highly relative we return it as-is. It would be possible to resolve - // the target with `$target = self::resolve($base, $target);` and then try make it more relative - // by removing a duplicate query. But let's not do that automatically. - return $target; - } - - if ($target->getAuthority() !== '' && $base->getAuthority() !== $target->getAuthority()) { - return $target->withScheme(''); - } - - // We must remove the path before removing the authority because if the path starts with two slashes, the URI - // would turn invalid. And we also cannot set a relative path before removing the authority, as that is also - // invalid. - $emptyPathUri = $target->withScheme('')->withPath('')->withUserInfo('')->withPort(null)->withHost(''); - - if ($base->getPath() !== $target->getPath()) { - return $emptyPathUri->withPath(self::getRelativePath($base, $target)); - } - - if ($base->getQuery() === $target->getQuery()) { - // Only the target fragment is left. And it must be returned even if base and target fragment are the same. - return $emptyPathUri->withQuery(''); - } - - // If the base URI has a query but the target has none, we cannot return an empty path reference as it would - // inherit the base query component when resolving. - if ($target->getQuery() === '') { - $segments = explode('/', $target->getPath()); - $lastSegment = end($segments); - - return $emptyPathUri->withPath($lastSegment === '' ? './' : $lastSegment); - } - - return $emptyPathUri; - } - - private static function getRelativePath(UriInterface $base, UriInterface $target) - { - $sourceSegments = explode('/', $base->getPath()); - $targetSegments = explode('/', $target->getPath()); - array_pop($sourceSegments); - $targetLastSegment = array_pop($targetSegments); - foreach ($sourceSegments as $i => $segment) { - if (isset($targetSegments[$i]) && $segment === $targetSegments[$i]) { - unset($sourceSegments[$i], $targetSegments[$i]); - } else { - break; - } - } - $targetSegments[] = $targetLastSegment; - $relativePath = str_repeat('../', count($sourceSegments)) . implode('/', $targetSegments); - - // A reference to am empty last segment or an empty first sub-segment must be prefixed with "./". - // This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used - // as the first segment of a relative-path reference, as it would be mistaken for a scheme name. - if ('' === $relativePath || false !== strpos(explode('/', $relativePath, 2)[0], ':')) { - $relativePath = "./$relativePath"; - } elseif ('/' === $relativePath[0]) { - if ($base->getAuthority() != '' && $base->getPath() === '') { - // In this case an extra slash is added by resolve() automatically. So we must not add one here. - $relativePath = ".$relativePath"; - } else { - $relativePath = "./$relativePath"; - } - } - - return $relativePath; - } - - private function __construct() - { - // cannot be instantiated - } -} diff --git a/vendor/guzzlehttp/psr7/src/functions.php b/vendor/guzzlehttp/psr7/src/functions.php deleted file mode 100755 index e40348d6abdee0bafd739cae12f99f033b131da8..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/functions.php +++ /dev/null @@ -1,828 +0,0 @@ -<?php -namespace GuzzleHttp\Psr7; - -use Psr\Http\Message\MessageInterface; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; -use Psr\Http\Message\StreamInterface; -use Psr\Http\Message\UriInterface; - -/** - * Returns the string representation of an HTTP message. - * - * @param MessageInterface $message Message to convert to a string. - * - * @return string - */ -function str(MessageInterface $message) -{ - if ($message instanceof RequestInterface) { - $msg = trim($message->getMethod() . ' ' - . $message->getRequestTarget()) - . ' HTTP/' . $message->getProtocolVersion(); - if (!$message->hasHeader('host')) { - $msg .= "\r\nHost: " . $message->getUri()->getHost(); - } - } elseif ($message instanceof ResponseInterface) { - $msg = 'HTTP/' . $message->getProtocolVersion() . ' ' - . $message->getStatusCode() . ' ' - . $message->getReasonPhrase(); - } else { - throw new \InvalidArgumentException('Unknown message type'); - } - - foreach ($message->getHeaders() as $name => $values) { - $msg .= "\r\n{$name}: " . implode(', ', $values); - } - - return "{$msg}\r\n\r\n" . $message->getBody(); -} - -/** - * Returns a UriInterface for the given value. - * - * This function accepts a string or {@see Psr\Http\Message\UriInterface} and - * returns a UriInterface for the given value. If the value is already a - * `UriInterface`, it is returned as-is. - * - * @param string|UriInterface $uri - * - * @return UriInterface - * @throws \InvalidArgumentException - */ -function uri_for($uri) -{ - if ($uri instanceof UriInterface) { - return $uri; - } elseif (is_string($uri)) { - return new Uri($uri); - } - - throw new \InvalidArgumentException('URI must be a string or UriInterface'); -} - -/** - * Create a new stream based on the input type. - * - * Options is an associative array that can contain the following keys: - * - metadata: Array of custom metadata. - * - size: Size of the stream. - * - * @param resource|string|null|int|float|bool|StreamInterface|callable $resource Entity body data - * @param array $options Additional options - * - * @return Stream - * @throws \InvalidArgumentException if the $resource arg is not valid. - */ -function stream_for($resource = '', array $options = []) -{ - if (is_scalar($resource)) { - $stream = fopen('php://temp', 'r+'); - if ($resource !== '') { - fwrite($stream, $resource); - fseek($stream, 0); - } - return new Stream($stream, $options); - } - - switch (gettype($resource)) { - case 'resource': - return new Stream($resource, $options); - case 'object': - if ($resource instanceof StreamInterface) { - return $resource; - } elseif ($resource instanceof \Iterator) { - return new PumpStream(function () use ($resource) { - if (!$resource->valid()) { - return false; - } - $result = $resource->current(); - $resource->next(); - return $result; - }, $options); - } elseif (method_exists($resource, '__toString')) { - return stream_for((string) $resource, $options); - } - break; - case 'NULL': - return new Stream(fopen('php://temp', 'r+'), $options); - } - - if (is_callable($resource)) { - return new PumpStream($resource, $options); - } - - throw new \InvalidArgumentException('Invalid resource type: ' . gettype($resource)); -} - -/** - * Parse an array of header values containing ";" separated data into an - * array of associative arrays representing the header key value pair - * data of the header. When a parameter does not contain a value, but just - * contains a key, this function will inject a key with a '' string value. - * - * @param string|array $header Header to parse into components. - * - * @return array Returns the parsed header values. - */ -function parse_header($header) -{ - static $trimmed = "\"' \n\t\r"; - $params = $matches = []; - - foreach (normalize_header($header) as $val) { - $part = []; - foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) { - if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) { - $m = $matches[0]; - if (isset($m[1])) { - $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed); - } else { - $part[] = trim($m[0], $trimmed); - } - } - } - if ($part) { - $params[] = $part; - } - } - - return $params; -} - -/** - * Converts an array of header values that may contain comma separated - * headers into an array of headers with no comma separated values. - * - * @param string|array $header Header to normalize. - * - * @return array Returns the normalized header field values. - */ -function normalize_header($header) -{ - if (!is_array($header)) { - return array_map('trim', explode(',', $header)); - } - - $result = []; - foreach ($header as $value) { - foreach ((array) $value as $v) { - if (strpos($v, ',') === false) { - $result[] = $v; - continue; - } - foreach (preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $v) as $vv) { - $result[] = trim($vv); - } - } - } - - return $result; -} - -/** - * Clone and modify a request with the given changes. - * - * The changes can be one of: - * - method: (string) Changes the HTTP method. - * - set_headers: (array) Sets the given headers. - * - remove_headers: (array) Remove the given headers. - * - body: (mixed) Sets the given body. - * - uri: (UriInterface) Set the URI. - * - query: (string) Set the query string value of the URI. - * - version: (string) Set the protocol version. - * - * @param RequestInterface $request Request to clone and modify. - * @param array $changes Changes to apply. - * - * @return RequestInterface - */ -function modify_request(RequestInterface $request, array $changes) -{ - if (!$changes) { - return $request; - } - - $headers = $request->getHeaders(); - - if (!isset($changes['uri'])) { - $uri = $request->getUri(); - } else { - // Remove the host header if one is on the URI - if ($host = $changes['uri']->getHost()) { - $changes['set_headers']['Host'] = $host; - - if ($port = $changes['uri']->getPort()) { - $standardPorts = ['http' => 80, 'https' => 443]; - $scheme = $changes['uri']->getScheme(); - if (isset($standardPorts[$scheme]) && $port != $standardPorts[$scheme]) { - $changes['set_headers']['Host'] .= ':'.$port; - } - } - } - $uri = $changes['uri']; - } - - if (!empty($changes['remove_headers'])) { - $headers = _caseless_remove($changes['remove_headers'], $headers); - } - - if (!empty($changes['set_headers'])) { - $headers = _caseless_remove(array_keys($changes['set_headers']), $headers); - $headers = $changes['set_headers'] + $headers; - } - - if (isset($changes['query'])) { - $uri = $uri->withQuery($changes['query']); - } - - if ($request instanceof ServerRequestInterface) { - return new ServerRequest( - isset($changes['method']) ? $changes['method'] : $request->getMethod(), - $uri, - $headers, - isset($changes['body']) ? $changes['body'] : $request->getBody(), - isset($changes['version']) - ? $changes['version'] - : $request->getProtocolVersion(), - $request->getServerParams() - ); - } - - return new Request( - isset($changes['method']) ? $changes['method'] : $request->getMethod(), - $uri, - $headers, - isset($changes['body']) ? $changes['body'] : $request->getBody(), - isset($changes['version']) - ? $changes['version'] - : $request->getProtocolVersion() - ); -} - -/** - * Attempts to rewind a message body and throws an exception on failure. - * - * The body of the message will only be rewound if a call to `tell()` returns a - * value other than `0`. - * - * @param MessageInterface $message Message to rewind - * - * @throws \RuntimeException - */ -function rewind_body(MessageInterface $message) -{ - $body = $message->getBody(); - - if ($body->tell()) { - $body->rewind(); - } -} - -/** - * Safely opens a PHP stream resource using a filename. - * - * When fopen fails, PHP normally raises a warning. This function adds an - * error handler that checks for errors and throws an exception instead. - * - * @param string $filename File to open - * @param string $mode Mode used to open the file - * - * @return resource - * @throws \RuntimeException if the file cannot be opened - */ -function try_fopen($filename, $mode) -{ - $ex = null; - set_error_handler(function () use ($filename, $mode, &$ex) { - $ex = new \RuntimeException(sprintf( - 'Unable to open %s using mode %s: %s', - $filename, - $mode, - func_get_args()[1] - )); - }); - - $handle = fopen($filename, $mode); - restore_error_handler(); - - if ($ex) { - /** @var $ex \RuntimeException */ - throw $ex; - } - - return $handle; -} - -/** - * Copy the contents of a stream into a string until the given number of - * bytes have been read. - * - * @param StreamInterface $stream Stream to read - * @param int $maxLen Maximum number of bytes to read. Pass -1 - * to read the entire stream. - * @return string - * @throws \RuntimeException on error. - */ -function copy_to_string(StreamInterface $stream, $maxLen = -1) -{ - $buffer = ''; - - if ($maxLen === -1) { - while (!$stream->eof()) { - $buf = $stream->read(1048576); - // Using a loose equality here to match on '' and false. - if ($buf == null) { - break; - } - $buffer .= $buf; - } - return $buffer; - } - - $len = 0; - while (!$stream->eof() && $len < $maxLen) { - $buf = $stream->read($maxLen - $len); - // Using a loose equality here to match on '' and false. - if ($buf == null) { - break; - } - $buffer .= $buf; - $len = strlen($buffer); - } - - return $buffer; -} - -/** - * Copy the contents of a stream into another stream until the given number - * of bytes have been read. - * - * @param StreamInterface $source Stream to read from - * @param StreamInterface $dest Stream to write to - * @param int $maxLen Maximum number of bytes to read. Pass -1 - * to read the entire stream. - * - * @throws \RuntimeException on error. - */ -function copy_to_stream( - StreamInterface $source, - StreamInterface $dest, - $maxLen = -1 -) { - $bufferSize = 8192; - - if ($maxLen === -1) { - while (!$source->eof()) { - if (!$dest->write($source->read($bufferSize))) { - break; - } - } - } else { - $remaining = $maxLen; - while ($remaining > 0 && !$source->eof()) { - $buf = $source->read(min($bufferSize, $remaining)); - $len = strlen($buf); - if (!$len) { - break; - } - $remaining -= $len; - $dest->write($buf); - } - } -} - -/** - * Calculate a hash of a Stream - * - * @param StreamInterface $stream Stream to calculate the hash for - * @param string $algo Hash algorithm (e.g. md5, crc32, etc) - * @param bool $rawOutput Whether or not to use raw output - * - * @return string Returns the hash of the stream - * @throws \RuntimeException on error. - */ -function hash( - StreamInterface $stream, - $algo, - $rawOutput = false -) { - $pos = $stream->tell(); - - if ($pos > 0) { - $stream->rewind(); - } - - $ctx = hash_init($algo); - while (!$stream->eof()) { - hash_update($ctx, $stream->read(1048576)); - } - - $out = hash_final($ctx, (bool) $rawOutput); - $stream->seek($pos); - - return $out; -} - -/** - * Read a line from the stream up to the maximum allowed buffer length - * - * @param StreamInterface $stream Stream to read from - * @param int $maxLength Maximum buffer length - * - * @return string|bool - */ -function readline(StreamInterface $stream, $maxLength = null) -{ - $buffer = ''; - $size = 0; - - while (!$stream->eof()) { - // Using a loose equality here to match on '' and false. - if (null == ($byte = $stream->read(1))) { - return $buffer; - } - $buffer .= $byte; - // Break when a new line is found or the max length - 1 is reached - if ($byte === "\n" || ++$size === $maxLength - 1) { - break; - } - } - - return $buffer; -} - -/** - * Parses a request message string into a request object. - * - * @param string $message Request message string. - * - * @return Request - */ -function parse_request($message) -{ - $data = _parse_message($message); - $matches = []; - if (!preg_match('/^[\S]+\s+([a-zA-Z]+:\/\/|\/).*/', $data['start-line'], $matches)) { - throw new \InvalidArgumentException('Invalid request string'); - } - $parts = explode(' ', $data['start-line'], 3); - $version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1'; - - $request = new Request( - $parts[0], - $matches[1] === '/' ? _parse_request_uri($parts[1], $data['headers']) : $parts[1], - $data['headers'], - $data['body'], - $version - ); - - return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]); -} - -/** - * Parses a response message string into a response object. - * - * @param string $message Response message string. - * - * @return Response - */ -function parse_response($message) -{ - $data = _parse_message($message); - // According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space - // between status-code and reason-phrase is required. But browsers accept - // responses without space and reason as well. - if (!preg_match('/^HTTP\/.* [0-9]{3}( .*|$)/', $data['start-line'])) { - throw new \InvalidArgumentException('Invalid response string'); - } - $parts = explode(' ', $data['start-line'], 3); - - return new Response( - $parts[1], - $data['headers'], - $data['body'], - explode('/', $parts[0])[1], - isset($parts[2]) ? $parts[2] : null - ); -} - -/** - * Parse a query string into an associative array. - * - * If multiple values are found for the same key, the value of that key - * value pair will become an array. This function does not parse nested - * PHP style arrays into an associative array (e.g., foo[a]=1&foo[b]=2 will - * be parsed into ['foo[a]' => '1', 'foo[b]' => '2']). - * - * @param string $str Query string to parse - * @param bool|string $urlEncoding How the query string is encoded - * - * @return array - */ -function parse_query($str, $urlEncoding = true) -{ - $result = []; - - if ($str === '') { - return $result; - } - - if ($urlEncoding === true) { - $decoder = function ($value) { - return rawurldecode(str_replace('+', ' ', $value)); - }; - } elseif ($urlEncoding == PHP_QUERY_RFC3986) { - $decoder = 'rawurldecode'; - } elseif ($urlEncoding == PHP_QUERY_RFC1738) { - $decoder = 'urldecode'; - } else { - $decoder = function ($str) { return $str; }; - } - - foreach (explode('&', $str) as $kvp) { - $parts = explode('=', $kvp, 2); - $key = $decoder($parts[0]); - $value = isset($parts[1]) ? $decoder($parts[1]) : null; - if (!isset($result[$key])) { - $result[$key] = $value; - } else { - if (!is_array($result[$key])) { - $result[$key] = [$result[$key]]; - } - $result[$key][] = $value; - } - } - - return $result; -} - -/** - * Build a query string from an array of key value pairs. - * - * This function can use the return value of parse_query() to build a query - * string. This function does not modify the provided keys when an array is - * encountered (like http_build_query would). - * - * @param array $params Query string parameters. - * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986 - * to encode using RFC3986, or PHP_QUERY_RFC1738 - * to encode using RFC1738. - * @return string - */ -function build_query(array $params, $encoding = PHP_QUERY_RFC3986) -{ - if (!$params) { - return ''; - } - - if ($encoding === false) { - $encoder = function ($str) { return $str; }; - } elseif ($encoding === PHP_QUERY_RFC3986) { - $encoder = 'rawurlencode'; - } elseif ($encoding === PHP_QUERY_RFC1738) { - $encoder = 'urlencode'; - } else { - throw new \InvalidArgumentException('Invalid type'); - } - - $qs = ''; - foreach ($params as $k => $v) { - $k = $encoder($k); - if (!is_array($v)) { - $qs .= $k; - if ($v !== null) { - $qs .= '=' . $encoder($v); - } - $qs .= '&'; - } else { - foreach ($v as $vv) { - $qs .= $k; - if ($vv !== null) { - $qs .= '=' . $encoder($vv); - } - $qs .= '&'; - } - } - } - - return $qs ? (string) substr($qs, 0, -1) : ''; -} - -/** - * Determines the mimetype of a file by looking at its extension. - * - * @param $filename - * - * @return null|string - */ -function mimetype_from_filename($filename) -{ - return mimetype_from_extension(pathinfo($filename, PATHINFO_EXTENSION)); -} - -/** - * Maps a file extensions to a mimetype. - * - * @param $extension string The file extension. - * - * @return string|null - * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types - */ -function mimetype_from_extension($extension) -{ - static $mimetypes = [ - '7z' => 'application/x-7z-compressed', - 'aac' => 'audio/x-aac', - 'ai' => 'application/postscript', - 'aif' => 'audio/x-aiff', - 'asc' => 'text/plain', - 'asf' => 'video/x-ms-asf', - 'atom' => 'application/atom+xml', - 'avi' => 'video/x-msvideo', - 'bmp' => 'image/bmp', - 'bz2' => 'application/x-bzip2', - 'cer' => 'application/pkix-cert', - 'crl' => 'application/pkix-crl', - 'crt' => 'application/x-x509-ca-cert', - 'css' => 'text/css', - 'csv' => 'text/csv', - 'cu' => 'application/cu-seeme', - 'deb' => 'application/x-debian-package', - 'doc' => 'application/msword', - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'dvi' => 'application/x-dvi', - 'eot' => 'application/vnd.ms-fontobject', - 'eps' => 'application/postscript', - 'epub' => 'application/epub+zip', - 'etx' => 'text/x-setext', - 'flac' => 'audio/flac', - 'flv' => 'video/x-flv', - 'gif' => 'image/gif', - 'gz' => 'application/gzip', - 'htm' => 'text/html', - 'html' => 'text/html', - 'ico' => 'image/x-icon', - 'ics' => 'text/calendar', - 'ini' => 'text/plain', - 'iso' => 'application/x-iso9660-image', - 'jar' => 'application/java-archive', - 'jpe' => 'image/jpeg', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'js' => 'text/javascript', - 'json' => 'application/json', - 'latex' => 'application/x-latex', - 'log' => 'text/plain', - 'm4a' => 'audio/mp4', - 'm4v' => 'video/mp4', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mov' => 'video/quicktime', - 'mp3' => 'audio/mpeg', - 'mp4' => 'video/mp4', - 'mp4a' => 'audio/mp4', - 'mp4v' => 'video/mp4', - 'mpe' => 'video/mpeg', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mpg4' => 'video/mp4', - 'oga' => 'audio/ogg', - 'ogg' => 'audio/ogg', - 'ogv' => 'video/ogg', - 'ogx' => 'application/ogg', - 'pbm' => 'image/x-portable-bitmap', - 'pdf' => 'application/pdf', - 'pgm' => 'image/x-portable-graymap', - 'png' => 'image/png', - 'pnm' => 'image/x-portable-anymap', - 'ppm' => 'image/x-portable-pixmap', - 'ppt' => 'application/vnd.ms-powerpoint', - 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'ps' => 'application/postscript', - 'qt' => 'video/quicktime', - 'rar' => 'application/x-rar-compressed', - 'ras' => 'image/x-cmu-raster', - 'rss' => 'application/rss+xml', - 'rtf' => 'application/rtf', - 'sgm' => 'text/sgml', - 'sgml' => 'text/sgml', - 'svg' => 'image/svg+xml', - 'swf' => 'application/x-shockwave-flash', - 'tar' => 'application/x-tar', - 'tif' => 'image/tiff', - 'tiff' => 'image/tiff', - 'torrent' => 'application/x-bittorrent', - 'ttf' => 'application/x-font-ttf', - 'txt' => 'text/plain', - 'wav' => 'audio/x-wav', - 'webm' => 'video/webm', - 'wma' => 'audio/x-ms-wma', - 'wmv' => 'video/x-ms-wmv', - 'woff' => 'application/x-font-woff', - 'wsdl' => 'application/wsdl+xml', - 'xbm' => 'image/x-xbitmap', - 'xls' => 'application/vnd.ms-excel', - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'xml' => 'application/xml', - 'xpm' => 'image/x-xpixmap', - 'xwd' => 'image/x-xwindowdump', - 'yaml' => 'text/yaml', - 'yml' => 'text/yaml', - 'zip' => 'application/zip', - ]; - - $extension = strtolower($extension); - - return isset($mimetypes[$extension]) - ? $mimetypes[$extension] - : null; -} - -/** - * Parses an HTTP message into an associative array. - * - * The array contains the "start-line" key containing the start line of - * the message, "headers" key containing an associative array of header - * array values, and a "body" key containing the body of the message. - * - * @param string $message HTTP request or response to parse. - * - * @return array - * @internal - */ -function _parse_message($message) -{ - if (!$message) { - throw new \InvalidArgumentException('Invalid message'); - } - - // Iterate over each line in the message, accounting for line endings - $lines = preg_split('/(\\r?\\n)/', $message, -1, PREG_SPLIT_DELIM_CAPTURE); - $result = ['start-line' => array_shift($lines), 'headers' => [], 'body' => '']; - array_shift($lines); - - for ($i = 0, $totalLines = count($lines); $i < $totalLines; $i += 2) { - $line = $lines[$i]; - // If two line breaks were encountered, then this is the end of body - if (empty($line)) { - if ($i < $totalLines - 1) { - $result['body'] = implode('', array_slice($lines, $i + 2)); - } - break; - } - if (strpos($line, ':')) { - $parts = explode(':', $line, 2); - $key = trim($parts[0]); - $value = isset($parts[1]) ? trim($parts[1]) : ''; - $result['headers'][$key][] = $value; - } - } - - return $result; -} - -/** - * Constructs a URI for an HTTP request message. - * - * @param string $path Path from the start-line - * @param array $headers Array of headers (each value an array). - * - * @return string - * @internal - */ -function _parse_request_uri($path, array $headers) -{ - $hostKey = array_filter(array_keys($headers), function ($k) { - return strtolower($k) === 'host'; - }); - - // If no host is found, then a full URI cannot be constructed. - if (!$hostKey) { - return $path; - } - - $host = $headers[reset($hostKey)][0]; - $scheme = substr($host, -4) === ':443' ? 'https' : 'http'; - - return $scheme . '://' . $host . '/' . ltrim($path, '/'); -} - -/** @internal */ -function _caseless_remove($keys, array $data) -{ - $result = []; - - foreach ($keys as &$key) { - $key = strtolower($key); - } - - foreach ($data as $k => $v) { - if (!in_array(strtolower($k), $keys)) { - $result[$k] = $v; - } - } - - return $result; -} diff --git a/vendor/guzzlehttp/psr7/src/functions_include.php b/vendor/guzzlehttp/psr7/src/functions_include.php deleted file mode 100755 index 96a4a83a01aac6412572b74fd9b0abc339f6ad0f..0000000000000000000000000000000000000000 --- a/vendor/guzzlehttp/psr7/src/functions_include.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php - -// Don't redefine the functions if included multiple times. -if (!function_exists('GuzzleHttp\Psr7\str')) { - require __DIR__ . '/functions.php'; -} diff --git a/vendor/jumbojett/openid-connect-php/LICENSE.txt b/vendor/jumbojett/openid-connect-php/LICENSE.txt deleted file mode 100755 index 51fca54c2a05e9f562b19919318daecd451de12f..0000000000000000000000000000000000000000 --- a/vendor/jumbojett/openid-connect-php/LICENSE.txt +++ /dev/null @@ -1,11 +0,0 @@ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/vendor/jumbojett/openid-connect-php/OpenIDConnectClient.php b/vendor/jumbojett/openid-connect-php/OpenIDConnectClient.php deleted file mode 100755 index 6ad8544ca1f172129d10c1ec1e73bf5a9d87055c..0000000000000000000000000000000000000000 --- a/vendor/jumbojett/openid-connect-php/OpenIDConnectClient.php +++ /dev/null @@ -1,1103 +0,0 @@ -<?php - -/** - * - * Copyright MITRE 2017 - * - * OpenIDConnectClient for PHP5 - * Author: Michael Jett <mjett@mitre.org> - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - */ - -/** - * Use session to manage a nonce - */ -if (!isset($_SESSION)) { - session_start(); -} - -/** - * - * JWT signature verification support by Jonathan Reed <jdreed@mit.edu> - * Licensed under the same license as the rest of this file. - * - * phpseclib is required to validate the signatures of some tokens. - * It can be downloaded from: http://phpseclib.sourceforge.net/ - */ - -if (!class_exists('\phpseclib\Crypt\RSA') && !class_exists('Crypt_RSA')) { - user_error('Unable to find phpseclib Crypt/RSA.php. Ensure phpseclib is installed and in include_path before you include this file'); -} - -/** - * A wrapper around base64_decode which decodes Base64URL-encoded data, - * which is not the same alphabet as base64. - */ -function base64url_decode($base64url) { - return base64_decode(b64url2b64($base64url)); -} - -/** - * Per RFC4648, "base64 encoding with URL-safe and filename-safe - * alphabet". This just replaces characters 62 and 63. None of the - * reference implementations seem to restore the padding if necessary, - * but we'll do it anyway. - * - */ -function b64url2b64($base64url) { - // "Shouldn't" be necessary, but why not - $padding = strlen($base64url) % 4; - if ($padding > 0) { - $base64url .= str_repeat("=", 4 - $padding); - } - return strtr($base64url, '-_', '+/'); -} - - -/** - * OpenIDConnect Exception Class - */ -class OpenIDConnectClientException extends Exception -{ - -} - -/** - * Require the CURL and JSON PHP extentions to be installed - */ -if (!function_exists('curl_init')) { - throw new OpenIDConnectClientException('OpenIDConnect needs the CURL PHP extension.'); -} -if (!function_exists('json_decode')) { - throw new OpenIDConnectClientException('OpenIDConnect needs the JSON PHP extension.'); -} - -/** - * - * Please note this class stores nonces by default in $_SESSION['openid_connect_nonce'] - * - */ -class OpenIDConnectClient -{ - - /** - * @var string arbitrary id value - */ - private $clientID; - - /* - * @var string arbitrary name value - */ - private $clientName; - - /** - * @var string arbitrary secret value - */ - private $clientSecret; - - /** - * @var array holds the provider configuration - */ - private $providerConfig = array(); - - /** - * @var string http proxy if necessary - */ - private $httpProxy; - - /** - * @var string full system path to the SSL certificate - */ - private $certPath; - - /** - * @var bool Verify SSL peer on transactions - */ - private $verifyPeer = true; - - /** - * @var bool Verify peer hostname on transactions - */ - private $verifyHost = true; - - /** - * @var string if we aquire an access token it will be stored here - */ - private $accessToken; - - /** - * @var string if we aquire a refresh token it will be stored here - */ - private $refreshToken; - - /** - * @var string if we acquire an id token it will be stored here - */ - private $idToken; - - /** - * @var string stores the token response - */ - private $tokenResponse; - - /** - * @var array holds scopes - */ - private $scopes = array(); - - /** - * @var array holds response types - */ - private $responseTypes = array(); - - /** - * @var array holds a cache of info returned from the user info endpoint - */ - private $userInfo = array(); - - /** - * @var array holds authentication parameters - */ - private $authParams = array(); - - /** - * @var mixed holds well-known openid server properties - */ - private $wellKnown = false; - - /** - * @param $provider_url string optional - * - * @param $client_id string optional - * @param $client_secret string optional - * - */ - public function __construct($provider_url = null, $client_id = null, $client_secret = null) { - $this->setProviderURL($provider_url); - $this->clientID = $client_id; - $this->clientSecret = $client_secret; - } - - /** - * @param $provider_url - */ - public function setProviderURL($provider_url) { - $this->providerConfig['issuer'] = $provider_url; - } - - /** - * @param $response_types - */ - public function setResponseTypes($response_types) { - $this->responseTypes = array_merge($this->responseTypes, (array)$response_types); - } - - /** - * @return bool - * @throws OpenIDConnectClientException - */ - public function authenticate() { - - // Do a preemptive check to see if the provider has thrown an error from a previous redirect - if (isset($_REQUEST['error'])) { - $desc = isset($_REQUEST['error_description']) ? " Description: " . $_REQUEST['error_description'] : ""; - throw new OpenIDConnectClientException("Error: " . $_REQUEST['error'] .$desc); - } - - // If we have an authorization code then proceed to request a token - if (isset($_REQUEST["code"])) { - - $code = $_REQUEST["code"]; - $token_json = $this->requestTokens($code); - - // Throw an error if the server returns one - if (isset($token_json->error)) { - if (isset($token_json->error_description)) { - throw new OpenIDConnectClientException($token_json->error_description); - } - throw new OpenIDConnectClientException('Got response: ' . $token_json->error); - } - - // Do an OpenID Connect session check - if ($_REQUEST['state'] != $this->getState()) { - throw new OpenIDConnectClientException("Unable to determine state"); - } - - // Cleanup state - $this->unsetState(); - - if (!property_exists($token_json, 'id_token')) { - throw new OpenIDConnectClientException("User did not authorize openid scope."); - } - - $claims = $this->decodeJWT($token_json->id_token, 1); - - // Verify the signature - if ($this->canVerifySignatures()) { - if (!$this->getProviderConfigValue('jwks_uri')) { - throw new OpenIDConnectClientException ("Unable to verify signature due to no jwks_uri being defined"); - } - if (!$this->verifyJWTsignature($token_json->id_token)) { - throw new OpenIDConnectClientException ("Unable to verify signature"); - } - } else { - user_error("Warning: JWT signature verification unavailable."); - } - - // If this is a valid claim - if ($this->verifyJWTclaims($claims, $token_json->access_token)) { - - // Clean up the session a little - $this->unsetNonce(); - - // Save the full response - $this->tokenResponse = $token_json; - - // Save the id token - $this->idToken = $token_json->id_token; - - // Save the access token - $this->accessToken = $token_json->access_token; - - // Save the refresh token, if we got one - if (isset($token_json->refresh_token)) $this->refreshToken = $token_json->refresh_token; - - // Success! - return true; - - } else { - throw new OpenIDConnectClientException ("Unable to verify JWT claims"); - } - - } else { - - $this->requestAuthorization(); - return false; - } - - } - - /** - * It calls the end-session endpoint of the OpenID Connect provider to notify the OpenID - * Connect provider that the end-user has logged out of the relying party site - * (the client application). - * - * @param $accessToken ID token (obtained at login) - * @param $redirect URL to which the RP is requesting that the End-User's User Agent - * be redirected after a logout has been performed. The value MUST have been previously - * registered with the OP. Value can be null. - * - */ - public function signOut($accessToken, $redirect) { - $signout_endpoint = $this->getProviderConfigValue("end_session_endpoint"); - - $signout_params = null; - if($redirect == null){ - $signout_params = array('id_token_hint' => $accessToken); - } - else { - $signout_params = array( - 'id_token_hint' => $accessToken, - 'post_logout_redirect_uri' => $redirect); - } - - $signout_endpoint .= (strpos($signout_endpoint, '?') === false ? '?' : '&') . http_build_query( $signout_params, null, '&'); - $this->redirect($signout_endpoint); - } - - /** - * @param $scope - example: openid, given_name, etc... - */ - public function addScope($scope) { - $this->scopes = array_merge($this->scopes, (array)$scope); - } - - /** - * @param $param - example: prompt=login - */ - public function addAuthParam($param) { - $this->authParams = array_merge($this->authParams, (array)$param); - } - - /** - * Get's anything that we need configuration wise including endpoints, and other values - * - * @param $param - * @param $default optional - * @throws OpenIDConnectClientException - * @return string - * - */ - private function getProviderConfigValue($param, $default = null) { - - // If the configuration value is not available, attempt to fetch it from a well known config endpoint - // This is also known as auto "discovery" - if (!isset($this->providerConfig[$param])) { - if(!$this->wellKnown){ - $well_known_config_url = rtrim($this->getProviderURL(),"/") . "/.well-known/openid-configuration"; - $this->wellKnown = json_decode($this->fetchURL($well_known_config_url)); - } - - $value = false; - if(isset($this->wellKnown->{$param})){ - $value = $this->wellKnown->{$param}; - } - - if ($value) { - $this->providerConfig[$param] = $value; - } elseif(isset($default)) { - // Uses default value if provided - $this->providerConfig[$param] = $default; - } else { - throw new OpenIDConnectClientException("The provider {$param} has not been set. Make sure your provider has a well known configuration available."); - } - - } - - return $this->providerConfig[$param]; - } - - - /** - * @param $url Sets redirect URL for auth flow - */ - public function setRedirectURL ($url) { - if (filter_var($url, FILTER_VALIDATE_URL) !== false) { - $this->redirectURL = $url; - } - } - - /** - * Gets the URL of the current page we are on, encodes, and returns it - * - * @return string - */ - public function getRedirectURL() { - - // If the redirect URL has been set then return it. - if (property_exists($this, 'redirectURL') && $this->redirectURL) { - return $this->redirectURL; - } - - // Other-wise return the URL of the current page - - /** - * Thank you - * http://stackoverflow.com/questions/189113/how-do-i-get-current-page-full-url-in-php-on-a-windows-iis-server - */ - - /* - * Compatibility with multiple host headers. - * The problem with SSL over port 80 is resolved and non-SSL over port 443. - * Support of 'ProxyReverse' configurations. - */ - - $protocol = @$_SERVER['HTTP_X_FORWARDED_PROTO'] - ?: @$_SERVER['REQUEST_SCHEME'] - ?: ((isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") ? "https" : "http"); - - $port = @intval($_SERVER['HTTP_X_FORWARDED_PORT']) - ?: @intval($_SERVER["SERVER_PORT"]) - ?: (($protocol === 'https') ? 443 : 80); - - $host = @explode(":", $_SERVER['HTTP_HOST'])[0] - ?: @$_SERVER['SERVER_NAME'] - ?: @$_SERVER['SERVER_ADDR']; - - // Don't include port if it's 80 or 443 and the protocol matches - $port = ($protocol === 'https' && $port === 443) || ($protocol === 'http' && $port === 80) ? '' : ':' . $port; - - return sprintf('%s://%s%s/%s', $protocol, $host, $port, @trim(reset(explode("?", $_SERVER['REQUEST_URI'])), '/')); - } - - /** - * Used for arbitrary value generation for nonces and state - * - * @return string - */ - protected function generateRandString() { - return md5(uniqid(rand(), TRUE)); - } - - /** - * Start Here - * @return void - */ - private function requestAuthorization() { - - $auth_endpoint = $this->getProviderConfigValue("authorization_endpoint"); - $response_type = "code"; - - // Generate and store a nonce in the session - // The nonce is an arbitrary value - $nonce = $this->setNonce($this->generateRandString()); - - // State essentially acts as a session key for OIDC - $state = $this->setState($this->generateRandString()); - - $auth_params = array_merge($this->authParams, array( - 'response_type' => $response_type, - 'redirect_uri' => $this->getRedirectURL(), - 'client_id' => $this->clientID, - 'nonce' => $nonce, - 'state' => $state, - 'scope' => 'openid' - )); - - // If the client has been registered with additional scopes - if (sizeof($this->scopes) > 0) { - $auth_params = array_merge($auth_params, array('scope' => implode(' ', $this->scopes))); - } - - // If the client has been registered with additional response types - if (sizeof($this->responseTypes) > 0) { - $auth_params = array_merge($auth_params, array('response_type' => implode(' ', $this->responseTypes))); - } - - $auth_endpoint .= (strpos($auth_endpoint, '?') === false ? '?' : '&') . http_build_query($auth_params, null, '&'); - - session_commit(); - $this->redirect($auth_endpoint); - } - - /** - * Requests a client credentials token - * - */ - public function requestClientCredentialsToken() { - $token_endpoint = $this->getProviderConfigValue("token_endpoint"); - $token_endpoint_auth_methods_supported = $this->getProviderConfigValue("token_endpoint_auth_methods_supported"); - - $headers = []; - - $grant_type = "client_credentials"; - - $post_data = array( - 'grant_type' => $grant_type, - 'client_id' => $this->clientID, - 'client_secret' => $this->clientSecret, - 'scope' => implode(' ', $this->scopes) - ); - - // Convert token params to string format - $post_params = http_build_query($post_data, null, '&'); - - return json_decode($this->fetchURL($token_endpoint, $post_params, $headers)); - } - - - /** - * Requests ID and Access tokens - * - * @param $code - * @return mixed - */ - private function requestTokens($code) { - $token_endpoint = $this->getProviderConfigValue("token_endpoint"); - $token_endpoint_auth_methods_supported = $this->getProviderConfigValue("token_endpoint_auth_methods_supported", ['client_secret_basic']); - - $headers = []; - - $grant_type = "authorization_code"; - - $token_params = array( - 'grant_type' => $grant_type, - 'code' => $code, - 'redirect_uri' => $this->getRedirectURL(), - 'client_id' => $this->clientID, - 'client_secret' => $this->clientSecret - ); - - # Consider Basic authentication if provider config is set this way - if (in_array('client_secret_basic', $token_endpoint_auth_methods_supported)) { - $headers = ['Authorization: Basic ' . base64_encode($this->clientID . ':' . $this->clientSecret)]; - unset($token_params['client_secret']); - } - - // Convert token params to string format - $token_params = http_build_query($token_params, null, '&'); - - return json_decode($this->fetchURL($token_endpoint, $token_params, $headers)); - - } - - /** - * Requests Access token with refresh token - * - * @param $code - * @return mixed - */ - public function refreshToken($refresh_token) { - $token_endpoint = $this->getProviderConfigValue("token_endpoint"); - - $grant_type = "refresh_token"; - - $token_params = array( - 'grant_type' => $grant_type, - 'refresh_token' => $refresh_token, - 'client_id' => $this->clientID, - 'client_secret' => $this->clientSecret, - ); - - // Convert token params to string format - $token_params = http_build_query($token_params, null, '&'); - - $json = json_decode($this->fetchURL($token_endpoint, $token_params)); - $this->refreshToken = $json->refresh_token; - - return $json; - } - - /** - * @param array $keys - * @param array $header - * @throws OpenIDConnectClientException - * @return object - */ - private function get_key_for_header($keys, $header) { - foreach ($keys as $key) { - if ($key->kty == 'RSA') { - if (!isset($header->kid) || $key->kid == $header->kid) { - return $key; - } - } else { - if ($key->alg == $header->alg && $key->kid == $header->kid) { - return $key; - } - } - } - if (isset($header->kid)) { - throw new OpenIDConnectClientException('Unable to find a key for (algorithm, kid):' . $header->alg . ', ' . $header->kid . ')'); - } else { - throw new OpenIDConnectClientException('Unable to find a key for RSA'); - } - } - - - - /** - * @param string $hashtype - * @param object $key - * @throws OpenIDConnectClientException - * @return bool - */ - private function verifyRSAJWTsignature($hashtype, $key, $payload, $signature) { - if (!class_exists('\phpseclib\Crypt\RSA') && !class_exists('Crypt_RSA')) { - throw new OpenIDConnectClientException('Crypt_RSA support unavailable.'); - } - if (!(property_exists($key, 'n') and property_exists($key, 'e'))) { - throw new OpenIDConnectClientException('Malformed key object'); - } - - /* We already have base64url-encoded data, so re-encode it as - regular base64 and use the XML key format for simplicity. - */ - $public_key_xml = "<RSAKeyValue>\r\n". - " <Modulus>" . b64url2b64($key->n) . "</Modulus>\r\n" . - " <Exponent>" . b64url2b64($key->e) . "</Exponent>\r\n" . - "</RSAKeyValue>"; - if(class_exists('Crypt_RSA')) { - $rsa = new Crypt_RSA(); - $rsa->setHash($hashtype); - $rsa->loadKey($public_key_xml, Crypt_RSA::PUBLIC_FORMAT_XML); - $rsa->signatureMode = Crypt_RSA::SIGNATURE_PKCS1; - } else { - $rsa = new \phpseclib\Crypt\RSA(); - $rsa->setHash($hashtype); - $rsa->loadKey($public_key_xml, \phpseclib\Crypt\RSA::PUBLIC_FORMAT_XML); - $rsa->signatureMode = \phpseclib\Crypt\RSA::SIGNATURE_PKCS1; - } - return $rsa->verify($payload, $signature); - } - - /** - * @param $jwt string encoded JWT - * @throws OpenIDConnectClientException - * @return bool - */ - private function verifyJWTsignature($jwt) { - $parts = explode(".", $jwt); - $signature = base64url_decode(array_pop($parts)); - $header = json_decode(base64url_decode($parts[0])); - $payload = implode(".", $parts); - $jwks = json_decode($this->fetchURL($this->getProviderConfigValue('jwks_uri'))); - if ($jwks === NULL) { - throw new OpenIDConnectClientException('Error decoding JSON from jwks_uri'); - } - $verified = false; - switch ($header->alg) { - case 'RS256': - case 'RS384': - case 'RS512': - $hashtype = 'sha' . substr($header->alg, 2); - - $verified = $this->verifyRSAJWTsignature($hashtype, - $this->get_key_for_header($jwks->keys, $header), - $payload, $signature); - break; - default: - throw new OpenIDConnectClientException('No support for signature type: ' . $header->alg); - } - return $verified; - } - - /** - * @param object $claims - * @return bool - */ - private function verifyJWTclaims($claims, $accessToken = null) { - if(isset($claims->at_hash) && isset($accessToken)){ - if(isset($this->getAccessTokenHeader()->alg) && $this->getAccessTokenHeader()->alg != 'none'){ - $bit = substr($this->getAccessTokenHeader()->alg, 2, 3); - }else{ - // TODO: Error case. throw exception??? - $bit = '256'; - } - $len = ((int)$bit)/16; - $expecte_at_hash = $this->urlEncode(substr(hash('sha'.$bit, $accessToken, true), 0, $len)); - } - return (($claims->iss == $this->getProviderURL()) - && (($claims->aud == $this->clientID) || (in_array($this->clientID, $claims->aud))) - && ($claims->nonce == $this->getNonce()) - && ( !isset($claims->exp) || $claims->exp >= time()) - && ( !isset($claims->nbf) || $claims->nbf <= time()) - && ( !isset($claims->at_hash) || $claims->at_hash == $expecte_at_hash ) - ); - } - - /** - * @param string $str - * @return string - */ - protected function urlEncode($str) { - $enc = base64_encode($str); - $enc = rtrim($enc, "="); - $enc = strtr($enc, "+/", "-_"); - return $enc; - } - - /** - * @param $jwt string encoded JWT - * @param int $section the section we would like to decode - * @return object - */ - private function decodeJWT($jwt, $section = 0) { - - $parts = explode(".", $jwt); - return json_decode(base64url_decode($parts[$section])); - } - - /** - * - * @param $attribute string optional - * - * Attribute Type Description - * user_id string REQUIRED Identifier for the End-User at the Issuer. - * name string End-User's full name in displayable form including all name parts, ordered according to End-User's locale and preferences. - * given_name string Given name or first name of the End-User. - * family_name string Surname or last name of the End-User. - * middle_name string Middle name of the End-User. - * nickname string Casual name of the End-User that may or may not be the same as the given_name. For instance, a nickname value of Mike might be returned alongside a given_name value of Michael. - * profile string URL of End-User's profile page. - * picture string URL of the End-User's profile picture. - * website string URL of End-User's web page or blog. - * email string The End-User's preferred e-mail address. - * verified boolean True if the End-User's e-mail address has been verified; otherwise false. - * gender string The End-User's gender: Values defined by this specification are female and male. Other values MAY be used when neither of the defined values are applicable. - * birthday string The End-User's birthday, represented as a date string in MM/DD/YYYY format. The year MAY be 0000, indicating that it is omitted. - * zoneinfo string String from zoneinfo [zoneinfo] time zone database. For example, Europe/Paris or America/Los_Angeles. - * locale string The End-User's locale, represented as a BCP47 [RFC5646] language tag. This is typically an ISO 639-1 Alpha-2 [ISO639‑1] language code in lowercase and an ISO 3166-1 Alpha-2 [ISO3166‑1] country code in uppercase, separated by a dash. For example, en-US or fr-CA. As a compatibility note, some implementations have used an underscore as the separator rather than a dash, for example, en_US; Implementations MAY choose to accept this locale syntax as well. - * phone_number string The End-User's preferred telephone number. E.164 [E.164] is RECOMMENDED as the format of this Claim. For example, +1 (425) 555-1212 or +56 (2) 687 2400. - * address JSON object The End-User's preferred address. The value of the address member is a JSON [RFC4627] structure containing some or all of the members defined in Section 2.4.2.1. - * updated_time string Time the End-User's information was last updated, represented as a RFC 3339 [RFC3339] datetime. For example, 2011-01-03T23:58:42+0000. - * - * @return mixed - * - */ - public function requestUserInfo($attribute = null) { - - $user_info_endpoint = $this->getProviderConfigValue("userinfo_endpoint"); - $schema = 'openid'; - - $user_info_endpoint .= "?schema=" . $schema; - - //The accessToken has to be send in the Authorization header, so we create a new array with only this header. - $headers = array("Authorization: Bearer {$this->accessToken}"); - - $user_json = json_decode($this->fetchURL($user_info_endpoint,null,$headers)); - - $this->userInfo = $user_json; - - if($attribute === null) { - return $this->userInfo; - } else if (array_key_exists($attribute, $this->userInfo)) { - return $this->userInfo->$attribute; - } else { - return null; - } - } - - /** - * @param $url - * @param null $post_body string If this is set the post type will be POST - * @param array() $headers Extra headers to be send with the request. Format as 'NameHeader: ValueHeader' - * @throws OpenIDConnectClientException - * @return mixed - */ - protected function fetchURL($url, $post_body = null,$headers = array()) { - - - // OK cool - then let's create a new cURL resource handle - $ch = curl_init(); - - // Determine whether this is a GET or POST - if ($post_body != null) { - // curl_setopt($ch, CURLOPT_POST, 1); - // Alows to keep the POST method even after redirect - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body); - - // Default content type is form encoded - $content_type = 'application/x-www-form-urlencoded'; - - // Determine if this is a JSON payload and add the appropriate content type - if (is_object(json_decode($post_body))) { - $content_type = 'application/json'; - } - - // Add POST-specific headers - $headers[] = "Content-Type: {$content_type}"; - $headers[] = 'Content-Length: ' . strlen($post_body); - - } - - // If we set some heaers include them - if(count($headers) > 0) { - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - } - - // Set URL to download - curl_setopt($ch, CURLOPT_URL, $url); - - if (isset($this->httpProxy)) { - curl_setopt($ch, CURLOPT_PROXY, $this->httpProxy); - } - - // Include header in result? (0 = yes, 1 = no) - curl_setopt($ch, CURLOPT_HEADER, 0); - - // Allows to follow redirect - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - - /** - * Set cert - * Otherwise ignore SSL peer verification - */ - if (isset($this->certPath)) { - curl_setopt($ch, CURLOPT_CAINFO, $this->certPath); - } - - if($this->verifyHost) { - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); - } else { - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); - } - - if($this->verifyPeer) { - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); - } else { - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - } - - // Should cURL return or print out the data? (true = return, false = print) - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - - // Timeout in seconds - curl_setopt($ch, CURLOPT_TIMEOUT, 60); - - // Download the given URL, and return output - $output = curl_exec($ch); - - if ($output === false) { - throw new OpenIDConnectClientException('Curl error: ' . curl_error($ch)); - } - - // Close the cURL resource, and free system resources - curl_close($ch); - - return $output; - } - - /** - * @return string - * @throws OpenIDConnectClientException - */ - public function getProviderURL() { - - if (!isset($this->providerConfig['issuer'])) { - throw new OpenIDConnectClientException("The provider URL has not been set"); - } else { - return $this->providerConfig['issuer']; - } - } - - /** - * @param $url - */ - public function redirect($url) { - header('Location: ' . $url); - exit; - } - - /** - * @param $httpProxy - */ - public function setHttpProxy($httpProxy) { - $this->httpProxy = $httpProxy; - } - - /** - * @param $certPath - */ - public function setCertPath($certPath) { - $this->certPath = $certPath; - } - - /** - * @param bool $verifyPeer - */ - public function setVerifyPeer($verifyPeer) { - $this->verifyPeer = $verifyPeer; - } - - /** - * @param bool $verifyHost - */ - public function setVerifyHost($verifyHost) { - $this->verifyHost = $verifyHost; - } - - /** - * - * Use this to alter a provider's endpoints and other attributes - * - * @param $array - * simple key => value - */ - public function providerConfigParam($array) { - $this->providerConfig = array_merge($this->providerConfig, $array); - } - - /** - * @param $clientSecret - */ - public function setClientSecret($clientSecret) { - $this->clientSecret = $clientSecret; - } - - /** - * @param $clientID - */ - public function setClientID($clientID) { - $this->clientID = $clientID; - } - - - /** - * Dynamic registration - * - * @throws OpenIDConnectClientException - */ - public function register() { - - $registration_endpoint = $this->getProviderConfigValue('registration_endpoint'); - - $send_object = (object)array( - 'redirect_uris' => array($this->getRedirectURL()), - 'client_name' => $this->getClientName() - ); - - $response = $this->fetchURL($registration_endpoint, json_encode($send_object)); - - $json_response = json_decode($response); - - // Throw some errors if we encounter them - if ($json_response === false) { - throw new OpenIDConnectClientException("Error registering: JSON response received from the server was invalid."); - } elseif (isset($json_response->{'error_description'})) { - throw new OpenIDConnectClientException($json_response->{'error_description'}); - } - - $this->setClientID($json_response->{'client_id'}); - - // The OpenID Connect Dynamic registration protocol makes the client secret optional - // and provides a registration access token and URI endpoint if it is not present - if (isset($json_response->{'client_secret'})) { - $this->setClientSecret($json_response->{'client_secret'}); - } else { - throw new OpenIDConnectClientException("Error registering: - Please contact the OpenID Connect provider and obtain a Client ID and Secret directly from them"); - } - - } - - /** - * @return mixed - */ - public function getClientName() { - return $this->clientName; - } - - /** - * @param $clientName - */ - public function setClientName($clientName) { - $this->clientName = $clientName; - } - - /** - * @return string - */ - public function getClientID() { - return $this->clientID; - } - - /** - * @return string - */ - public function getClientSecret() { - return $this->clientSecret; - } - - /** - * @return bool - */ - public function canVerifySignatures() { - return class_exists('\phpseclib\Crypt\RSA') || class_exists('Crypt_RSA'); - } - - /** - * @return string - */ - public function getAccessToken() { - return $this->accessToken; - } - - /** - * @return string - */ - public function getRefreshToken() { - return $this->refreshToken; - } - - /** - * @return string - */ - public function getIdToken() { - return $this->idToken; - } - - /** - * @return array - */ - public function getAccessTokenHeader() { - return $this->decodeJWT($this->accessToken, 0); - } - - /** - * @return array - */ - public function getAccessTokenPayload() { - return $this->decodeJWT($this->accessToken, 1); - } - - /** - * @return array - */ - public function getIdTokenHeader() { - return $this->decodeJWT($this->idToken, 0); - } - - /** - * @return array - */ - public function getIdTokenPayload() { - return $this->decodeJWT($this->idToken, 1); - } - /** - * @return array - */ - public function getTokenResponse() { - return $this->tokenResponse; - } - - /** - * Stores nonce - * - * @param string $nonce - * @return string - */ - protected function setNonce($nonce) { - $_SESSION['openid_connect_nonce'] = $nonce; - return $nonce; - } - - /** - * Get stored nonce - * - * @return string - */ - protected function getNonce() { - return $_SESSION['openid_connect_nonce']; - } - - /** - * Cleanup nonce - * - * @return void - */ - protected function unsetNonce() { - unset($_SESSION['openid_connect_nonce']); - } - - /** - * Stores $state - * - * @param string $state - * @return string - */ - protected function setState($state) { - $_SESSION['openid_connect_state'] = $state; - return $state; - } - - /** - * Get stored state - * - * @return string - */ - protected function getState() { - return $_SESSION['openid_connect_state']; - } - - /** - * Cleanup state - * - * @return void - */ - protected function unsetState() { - unset($_SESSION['openid_connect_state']); - } -} diff --git a/vendor/jumbojett/openid-connect-php/README.md b/vendor/jumbojett/openid-connect-php/README.md deleted file mode 100755 index 74ac28fad53ae94f92ea6ec9a4ac1a2059ba1514..0000000000000000000000000000000000000000 --- a/vendor/jumbojett/openid-connect-php/README.md +++ /dev/null @@ -1,85 +0,0 @@ -PHP OpenID Connect Basic Client -======================== -A simple library that allows an application to authenticate a user through the basic OpenID Connect flow. -This library hopes to encourage OpenID Connect use by making it simple enough for a developer with little knowledge of -the OpenID Connect protocol to setup authentication. - -A special thanks goes to Justin Richer and Amanda Anganes for their help and support of the protocol. - -# Requirements # - 1. PHP 5.4 or greater - 2. CURL extension - 3. JSON extension - -## Install ## - 1. Install library using composer -``` -composer require jumbojett/openid-connect-php:0.1.* -``` - 2. Include composer autoloader -```php -require '/vendor/autoload.php'; -``` - -## Example 1: Basic Client ## - -```php -$oidc = new OpenIDConnectClient('https://id.provider.com', - 'ClientIDHere', - 'ClientSecretHere'); -$oidc->setCertPath('/path/to/my.cert'); -$oidc->authenticate(); -$name = $oidc->requestUserInfo('given_name'); - -``` - -[See openid spec for available user attributes][1] - -## Example 2: Dynamic Registration ## - -```php -$oidc = new OpenIDConnectClient("https://id.provider.com"); - -$oidc->register(); -$client_id = $oidc->getClientID(); -$client_secret = $oidc->getClientSecret(); - -// Be sure to add logic to store the client id and client secret -``` - -## Example 3: Network and Security ## -```php -// Configure a proxy -$oidc->setHttpProxy("http://my.proxy.com:80/"); - -// Configure a cert -$oidc->setCertPath("/path/to/my.cert"); -``` - -## Example 4: Request Client Credentials Token ## - -```php -$oidc = new OpenIDConnectClient('https://id.provider.com', - 'ClientIDHere', - 'ClientSecretHere'); -$oidc->providerConfigParam(array('token_endpoint'=>'https://id.provider.com/connect/token')); -$oidc->addScope('my_scope'); - -// this assumes success (to validate check if the access_token property is there and a valid JWT) : -$clientCredentialsToken = $oidc->requestClientCredentialsToken()->access_token; - -``` - -## Development Environments ## -In some cases you may need to disable SSL security on on your development systems. -Note: This is not recommended on production systems. - -```php -$oidc->setVerifyHost(false); -$oidc->setVerifyPeer(false); -``` - -### Todo ### -- Dynamic registration does not support registration auth tokens and endpoints - - [1]: http://openid.net/specs/openid-connect-basic-1_0-15.html#id_res diff --git a/vendor/jumbojett/openid-connect-php/client_example.php b/vendor/jumbojett/openid-connect-php/client_example.php deleted file mode 100755 index 60d6971d265e942e7df6b3e115aa37bb6c562f59..0000000000000000000000000000000000000000 --- a/vendor/jumbojett/openid-connect-php/client_example.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php - -/** - * - * Copyright MITRE 2012 - * - * OpenIDConnectClient for PHP5 - * Author: Michael Jett <mjett@mitre.org> - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - */ - -require "../../autoload.php"; - -$oidc = new OpenIDConnectClient('http://myproviderURL.com/', - 'ClientIDHere', - 'ClientSecretHere'); - -$oidc->authenticate(); -$name = $oidc->requestUserInfo('given_name'); - -?> - -<html> -<head> - <title>Example OpenID Connect Client Use</title> - <style> - body { - font-family: 'Lucida Grande', Verdana, Arial, sans-serif; - } - </style> -</head> -<body> - - <div> - Hello <?php echo $name; ?> - </div> - -</body> -</html> - diff --git a/vendor/jumbojett/openid-connect-php/composer.json b/vendor/jumbojett/openid-connect-php/composer.json deleted file mode 100755 index 0baba4118c7e8da2589558307e890cab564e11c2..0000000000000000000000000000000000000000 --- a/vendor/jumbojett/openid-connect-php/composer.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "jumbojett/openid-connect-php", - "description": "Bare-bones OpenID Connect client", - "require": { - "php": ">=5.4", - "phpseclib/phpseclib" : "2.0.1", - "ext-json": "*", - "ext-curl": "*" - }, - "autoload": { - "classmap": ["OpenIDConnectClient.php"] - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/LICENSE b/vendor/m4tthumphrey/php-gitlab-api/LICENSE deleted file mode 100755 index 8791c72e0c8ccb6b5ad8b836b55e50134d383070..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 Matt Humphrey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/m4tthumphrey/php-gitlab-api/composer.json b/vendor/m4tthumphrey/php-gitlab-api/composer.json deleted file mode 100755 index 95c90732d39b8a245dfa44f952a4723880e39dc7..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/composer.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name": "m4tthumphrey/php-gitlab-api", - "type": "library", - "description": "GitLab API client", - "homepage": "https://github.com/m4tthumphrey/php-gitlab-api", - "keywords": ["gitlab", "api"], - "license": "MIT", - "authors": [ - { - "name": "Matt Humphrey", - "homepage": "http://m4tt.io" - }, - { - "name": "KnpLabs Team", - "homepage": "http://knplabs.com" - }, - { - "name": "Thibault Duplessis", - "email": "thibault.duplessis@gmail.com", - "homepage": "http://ornicar.github.com" - } - ], - "require": { - "php": "^5.6 || ^7.0", - "ext-xml": "*", - "php-http/client-common": "^1.5", - "php-http/client-implementation": "^1.0", - "php-http/discovery": "^1.2", - "php-http/httplug": "^1.1", - "php-http/multipart-stream-builder": "^1.0", - "symfony/options-resolver": "^2.6 || ^3.0" - }, - "require-dev": { - "guzzlehttp/psr7": "^1.2", - "php-http/guzzle6-adapter": "^1.0", - "php-http/mock-client": "^1.0", - "phpunit/phpunit": "~4.5" - }, - "autoload": { - "psr-4": { "Gitlab\\": "lib/Gitlab/" } - }, - "autoload-dev": { - "psr-4": { "Gitlab\\Tests\\": "test/Gitlab/Tests/" } - }, - "extra": { - "branch-alias": { - "dev-master": "9.0.x-dev" - } - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/AbstractApi.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/AbstractApi.php deleted file mode 100755 index ef9120a20d0fe1b9926d1541d773d5214676dabd..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/AbstractApi.php +++ /dev/null @@ -1,223 +0,0 @@ -<?php namespace Gitlab\Api; - -use Gitlab\Client; -use Gitlab\HttpClient\Message\QueryStringBuilder; -use Gitlab\HttpClient\Message\ResponseMediator; -use Gitlab\Tests\HttpClient\Message\QueryStringBuilderTest; -use Http\Discovery\StreamFactoryDiscovery; -use Http\Message\MultipartStream\MultipartStreamBuilder; -use Http\Message\StreamFactory; -use Psr\Http\Message\ResponseInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Abstract class for Api classes - * - * @author Joseph Bielawski <stloyd@gmail.com> - * @author Matt Humphrey <matt@m4tt.co> - * @author Radu Topala <radu.topala@trisoft.ro> - */ -abstract class AbstractApi implements ApiInterface -{ - /** - * The client - * - * @var Client - */ - protected $client; - - /** - * @var StreamFactory - */ - private $streamFactory; - - /** - * @param Client $client - * @param StreamFactory|null $streamFactory - */ - public function __construct(Client $client, StreamFactory $streamFactory = null) - { - $this->client = $client; - $this->streamFactory = $streamFactory ?: StreamFactoryDiscovery::find(); - } - - /** - * @return $this - * @codeCoverageIgnore - */ - public function configure() - { - return $this; - } - - /** - * Performs a GET query and returns the response as a PSR-7 response object. - * - * @param string $path - * @param array $parameters - * @param array $requestHeaders - * @return ResponseInterface - */ - protected function getAsResponse($path, array $parameters = array(), $requestHeaders = array()) - { - $path = $this->preparePath($path, $parameters); - - return $this->client->getHttpClient()->get($path, $requestHeaders); - } - - /** - * @param string $path - * @param array $parameters - * @param array $requestHeaders - * @return mixed - */ - protected function get($path, array $parameters = array(), $requestHeaders = array()) - { - return ResponseMediator::getContent($this->getAsResponse($path, $parameters, $requestHeaders)); - } - - /** - * @param string $path - * @param array $parameters - * @param array $requestHeaders - * @param array $files - * @return mixed - */ - protected function post($path, array $parameters = array(), $requestHeaders = array(), array $files = array()) - { - $path = $this->preparePath($path); - - $body = null; - if (empty($files) && !empty($parameters)) { - $body = $this->streamFactory->createStream(QueryStringBuilder::build($parameters)); - $requestHeaders['Content-Type'] = 'application/x-www-form-urlencoded'; - } elseif (!empty($files)) { - $builder = new MultipartStreamBuilder($this->streamFactory); - - foreach ($parameters as $name => $value) { - $builder->addResource($name, $value); - } - - foreach ($files as $name => $file) { - $builder->addResource($name, fopen($file, 'r'), [ - 'headers' => [ - 'Content-Type' => $this->guessContentType($file), - ], - 'filename' => basename($file), - ]); - } - - $body = $builder->build(); - $requestHeaders['Content-Type'] = 'multipart/form-data; boundary='.$builder->getBoundary(); - } - - $response = $this->client->getHttpClient()->post($path, $requestHeaders, $body); - - return ResponseMediator::getContent($response); - } - - /** - * @param string $path - * @param array $parameters - * @param array $requestHeaders - * @return mixed - */ - protected function put($path, array $parameters = array(), $requestHeaders = array()) - { - $path = $this->preparePath($path); - - $body = null; - if (!empty($parameters)) { - $body = $this->streamFactory->createStream(http_build_query($parameters)); - $requestHeaders['Content-Type'] = 'application/x-www-form-urlencoded'; - } - - $response = $this->client->getHttpClient()->put($path, $requestHeaders, $body); - - return ResponseMediator::getContent($response); - } - - /** - * @param string $path - * @param array $parameters - * @param array $requestHeaders - * @return mixed - */ - protected function delete($path, array $parameters = array(), $requestHeaders = array()) - { - $path = $this->preparePath($path, $parameters); - - $response = $this->client->getHttpClient()->delete($path, $requestHeaders); - - return ResponseMediator::getContent($response); - } - - /** - * @param int $id - * @param string $path - * @return string - */ - protected function getProjectPath($id, $path) - { - return 'projects/'.$this->encodePath($id).'/'.$path; - } - - /** - * @param string $path - * @return string - */ - protected function encodePath($path) - { - $path = rawurlencode($path); - - return str_replace('.', '%2E', $path); - } - - /** - * Create a new OptionsResolver with page and per_page options. - * - * @return OptionsResolver - */ - protected function createOptionsResolver() - { - $resolver = new OptionsResolver(); - $resolver->setDefined('page') - ->setAllowedTypes('page', 'int') - ->setAllowedValues('page', function ($value) { - return $value > 0; - }) - ; - $resolver->setDefined('per_page') - ->setAllowedTypes('per_page', 'int') - ->setAllowedValues('per_page', function ($value) { - return $value > 0 && $value <= 100; - }) - ; - - return $resolver; - } - - private function preparePath($path, array $parameters = []) - { - if (count($parameters) > 0) { - $path .= '?'.QueryStringBuilder::build($parameters); - } - - return $path; - } - - /** - * @param $file - * - * @return string - */ - private function guessContentType($file) - { - if (!class_exists(\finfo::class, false)) { - return 'application/octet-stream'; - } - $finfo = new \finfo(FILEINFO_MIME_TYPE); - - return $finfo->file($file); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/ApiInterface.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/ApiInterface.php deleted file mode 100755 index 40c3a56596957f8f961505c98b49b911a55e22f9..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/ApiInterface.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php namespace Gitlab\Api; - -use Gitlab\Client; - -/** - * Api interface - */ -interface ApiInterface -{ - public function __construct(Client $client); -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/DeployKeys.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/DeployKeys.php deleted file mode 100755 index 32e0a82cbd02a10563325903160bd3ac2728e049..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/DeployKeys.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php namespace Gitlab\Api; - -class DeployKeys extends AbstractApi -{ - /** - * @param array $parameters - * - * @return mixed - */ - public function all(array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - - return $this->get('deploy_keys', $resolver->resolve($parameters)); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Groups.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Groups.php deleted file mode 100755 index 94484ead527f601d976ed732e52e778c5f3271dc..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Groups.php +++ /dev/null @@ -1,216 +0,0 @@ -<?php namespace Gitlab\Api; - -class Groups extends AbstractApi -{ - /** - * @param array $parameters ( - * - * @var int[] $skip_groups Skip the group IDs passes. - * @var bool $all_available Show all the groups you have access to. - * @var string $search Return list of authorized groups matching the search criteria. - * @var string $order_by Order groups by name or path. Default is name. - * @var string $sort Order groups in asc or desc order. Default is asc. - * @var bool $statistics Include group statistics (admins only). - * @var bool $owned Limit by groups owned by the current user. - * ) - * @return mixed - */ - public function all(array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - $booleanNormalizer = function ($value) { - return $value ? 'true' : 'false'; - }; - - $resolver->setDefined('skip_groups') - ->setAllowedTypes('skip_groups', 'array') - ->setAllowedValues('skip_groups', function (array $value) { - return count($value) == count(array_filter($value, 'is_int')); - }) - ; - $resolver->setDefined('all_available') - ->setAllowedTypes('all_available', 'bool') - ->setNormalizer('all_available', $booleanNormalizer) - ; - $resolver->setDefined('search'); - $resolver->setDefined('order_by') - ->setAllowedValues('order_by', ['name', 'path']) - ; - $resolver->setDefined('sort') - ->setAllowedValues('sort', ['asc', 'desc']) - ; - $resolver->setDefined('statistics') - ->setAllowedTypes('statistics', 'bool') - ->setNormalizer('statistics', $booleanNormalizer) - ; - $resolver->setDefined('owned') - ->setAllowedTypes('owned', 'bool') - ->setNormalizer('owned', $booleanNormalizer) - ; - - return $this->get('groups', $resolver->resolve($parameters)); - } - - /** - * @param int $id - * @return mixed - */ - public function show($id) - { - return $this->get('groups/'.$this->encodePath($id)); - } - - /** - * @param string $name - * @param string $path - * @param string $description - * @param string $visibility - * @return mixed - */ - public function create($name, $path, $description = null, $visibility = 'private') - { - return $this->post('groups', array( - 'name' => $name, - 'path' => $path, - 'description' => $description, - 'visibility' => $visibility, - )); - } - - /** - * @param int $id - * @param array $params - * @return mixed - */ - public function update($id, array $params) - { - return $this->put('groups/'.$this->encodePath($id), $params); - } - - /** - * @param int $group_id - * @return mixed - */ - public function remove($group_id) - { - return $this->delete('groups/'.$this->encodePath($group_id)); - } - - /** - * @param int $group_id - * @param int $project_id - * @return mixed - */ - public function transfer($group_id, $project_id) - { - return $this->post('groups/'.$this->encodePath($group_id).'/projects/'.$this->encodePath($project_id)); - } - - /** - * @param int $id - * @param array $parameters ( - * - * @var string $query A query string to search for members. - * ) - * - * @return mixed - */ - public function members($id, array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - $resolver->setDefined('query'); - - return $this->get('groups/'.$this->encodePath($id).'/members', $resolver->resolve($parameters)); - } - - /** - * @param int $group_id - * @param int $user_id - * @param int $access_level - * @return mixed - */ - public function addMember($group_id, $user_id, $access_level) - { - return $this->post('groups/'.$this->encodePath($group_id).'/members', array( - 'user_id' => $user_id, - 'access_level' => $access_level - )); - } - - /** - * @param int $group_id - * @param int $user_id - * @param int $access_level - * @return mixed - */ - public function saveMember($group_id, $user_id, $access_level) - { - return $this->put('groups/'.$this->encodePath($group_id).'/members/'.$this->encodePath($user_id), array( - 'access_level' => $access_level - )); - } - - /** - * @param int $group_id - * @param int $user_id - * @return mixed - */ - public function removeMember($group_id, $user_id) - { - return $this->delete('groups/'.$this->encodePath($group_id).'/members/'.$this->encodePath($user_id)); - } - - /** - * @param $id - * @param array $parameters ( - * - * @var bool $archived Limit by archived status. - * @var string $visibility Limit by visibility public, internal, or private. - * @var string $order_by Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields. - * Default is created_at. - * @var string $sort Return projects sorted in asc or desc order. Default is desc. - * @var string $search Return list of authorized projects matching the search criteria. - * @var bool $simple Return only the ID, URL, name, and path of each project. - * @var bool $owned Limit by projects owned by the current user. - * @var bool $starred Limit by projects starred by the current user. - * ) - * - * @return mixed - */ - public function projects($id, array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - $booleanNormalizer = function ($value) { - return $value ? 'true' : 'false'; - }; - - $resolver->setDefined('archived') - ->setAllowedTypes('archived', 'bool') - ->setNormalizer('archived', $booleanNormalizer) - ; - $resolver->setDefined('visibility') - ->setAllowedValues('visibility', ['public', 'internal', 'private']) - ; - $resolver->setDefined('order_by') - ->setAllowedValues('order_by', ['id', 'name', 'path', 'created_at', 'updated_at', 'last_activity_at']) - ; - $resolver->setDefined('sort') - ->setAllowedValues('sort', ['asc', 'desc']) - ; - $resolver->setDefined('search'); - $resolver->setDefined('simple') - ->setAllowedTypes('simple', 'bool') - ->setNormalizer('simple', $booleanNormalizer) - ; - $resolver->setDefined('owned') - ->setAllowedTypes('owned', 'bool') - ->setNormalizer('owned', $booleanNormalizer) - ; - $resolver->setDefined('starred') - ->setAllowedTypes('starred', 'bool') - ->setNormalizer('starred', $booleanNormalizer) - ; - - return $this->get('groups/'.$this->encodePath($id).'/projects', $resolver->resolve($parameters)); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/IssueBoards.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/IssueBoards.php deleted file mode 100755 index e5d460bc553ba866d77057bd4baa355553dc7290..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/IssueBoards.php +++ /dev/null @@ -1,88 +0,0 @@ -<?php namespace Gitlab\Api; - -class IssueBoards extends AbstractApi -{ - /** - * @param int $project_id - * @param array $parameters - * - * @return mixed - */ - public function all($project_id = null, array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - - $path = $project_id === null ? 'boards' : $this->getProjectPath($project_id, 'boards'); - - return $this->get($path, $resolver->resolve($parameters)); - } - - /** - * @param int $project_id - * @param int $board_id - * @return mixed - */ - public function allLists($project_id, $board_id) - { - return $this->get($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id).'/lists')); - } - - - /** - * @param int $project_id - * @param int $board_id - * @param int $list_id - * @return mixed - */ - public function showList($project_id, $board_id, $list_id) - { - return $this->get($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id).'/lists'.$this->encodePath($list_id))); - } - - /** - * @param int $project_id - * @param int $board_id - * @param int $label_id - * @return mixed - */ - public function createList($project_id, $board_id, $label_id) - { - $params = array( - 'id' => $project_id, - 'board_id' => $board_id, - 'label_id' => $label_id - ); - - return $this->get($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id).'/lists'), $params); - } - - /** - * @param int $project_id - * @param int $board_id - * @param int $list_id - * @param int $position - * @return mixed - */ - public function updateList($project_id, $board_id, $list_id, $position) - { - $params = array( - 'id' => $project_id, - 'board_id' => $board_id, - 'list_id' => $list_id, - 'position' => $position - ); - - return $this->put($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id).'/lists/'.$this->encodePath($list_id)), $params); - } - - /** - * @param int $project_id - * @param int $board_id - * @param int $list_id - * @return mixed - */ - public function deleteList($project_id, $board_id, $list_id) - { - return $this->delete($this->getProjectPath($project_id, 'boards/'.$this->encodePath($board_id).'/lists/'.$this->encodePath($list_id))); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Issues.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Issues.php deleted file mode 100755 index 9fa0f74da2b6f9caf6bc7e6bc19600d5aef4aeb0..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Issues.php +++ /dev/null @@ -1,226 +0,0 @@ -<?php namespace Gitlab\Api; - -class Issues extends AbstractApi -{ - /** - * @param int $project_id - * @param array $parameters ( - * - * @var string $state Return all issues or just those that are opened or closed. - * @var string $labels Comma-separated list of label names, issues must have all labels to be returned. - * No+Label lists all issues with no labels. - * @var string $milestone The milestone title. - * @var string scope Return issues for the given scope: created-by-me, assigned-to-me or all. Defaults to created-by-me - * @var int[] $iids Return only the issues having the given iid. - * @var string $order_by Return requests ordered by created_at or updated_at fields. Default is created_at. - * @var string $sort Return requests sorted in asc or desc order. Default is desc. - * @var string $search Search issues against their title and description. - * ) - * - * @return mixed - */ - public function all($project_id = null, array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - - $resolver->setDefined('state') - ->setAllowedValues('state', ['opened', 'closed']) - ; - $resolver->setDefined('labels'); - $resolver->setDefined('milestone'); - $resolver->setDefined('iids') - ->setAllowedTypes('iids', 'array') - ->setAllowedValues('iids', function (array $value) { - return count($value) == count(array_filter($value, 'is_int')); - }) - ; - $resolver->setDefined('scope') - ->setAllowedValues('scope', ['created-by-me', 'assigned-to-me', 'all']) - ; - $resolver->setDefined('order_by') - ->setAllowedValues('order_by', ['created_at', 'updated_at']) - ; - $resolver->setDefined('sort') - ->setAllowedValues('sort', ['asc', 'desc']) - ; - $resolver->setDefined('search'); - - $path = $project_id === null ? 'issues' : $this->getProjectPath($project_id, 'issues'); - - return $this->get($path, $resolver->resolve($parameters)); - } - - /** - * @param int $project_id - * @param int $issue_iid - * @return mixed - */ - public function show($project_id, $issue_iid) - { - return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid))); - } - - /** - * @param int $project_id - * @param array $params - * @return mixed - */ - public function create($project_id, array $params) - { - return $this->post($this->getProjectPath($project_id, 'issues'), $params); - } - - /** - * @param int $project_id - * @param int $issue_iid - * @param array $params - * @return mixed - */ - public function update($project_id, $issue_iid, array $params) - { - return $this->put($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid)), $params); - } - - /** - * @param int $project_id - * @param int $issue_iid - * @return mixed - */ - public function remove($project_id, $issue_iid) - { - return $this->delete($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid))); - } - - /** - * @param int $project_id - * @param int $issue_iid - * @return mixed - */ - public function showComments($project_id, $issue_iid) - { - return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid)).'/notes'); - } - - /** - * @param int $project_id - * @param int $issue_iid - * @param int $note_id - * @return mixed - */ - public function showComment($project_id, $issue_iid, $note_id) - { - return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid)).'/notes/'.$this->encodePath($note_id)); - } - - /** - * @param int $project_id - * @param int $issue_iid - * @param string|array $body - * @return mixed - */ - public function addComment($project_id, $issue_iid, $body) - { - // backwards compatibility - if (is_array($body)) { - $params = $body; - } else { - $params = array('body' => $body); - } - - return $this->post($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid).'/notes'), $params); - } - - /** - * @param int $project_id - * @param int $issue_iid - * @param int $note_id - * @param string $body - * @return mixed - */ - public function updateComment($project_id, $issue_iid, $note_id, $body) - { - return $this->put($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid).'/notes/'.$this->encodePath($note_id)), array( - 'body' => $body - )); - } - - /** - * @param int $project_id - * @param int $issue_iid - * @param int $note_id - * @return mixed - */ - public function removeComment($project_id, $issue_iid, $note_id) - { - return $this->delete($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid).'/notes/'.$this->encodePath($note_id))); - } - - /** - * @param int $project_id - * @param int $issue_iid - * @param string $duration - */ - public function setTimeEstimate($project_id, $issue_iid, $duration) - { - return $this->post($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid).'/time_estimate'), array('duration' => $duration)); - } - - /** - * @param int $project_id - * @param int $issue_iid - */ - public function resetTimeEstimate($project_id, $issue_iid) - { - return $this->post($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid).'/reset_time_estimate')); - } - - /** - * @param int $project_id - * @param int $issue_iid - * @param string $duration - */ - public function addSpentTime($project_id, $issue_iid, $duration) - { - return $this->post($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid).'/add_spent_time'), array('duration' => $duration)); - } - - /** - * @param int $project_id - * @param int $issue_iid - */ - public function resetSpentTime($project_id, $issue_iid) - { - return $this->post($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid).'/reset_spent_time')); - } - - /** - * @param int $project_id - * @param int $issue_iid - * @return mixed - */ - public function getTimeStats($project_id, $issue_iid) - { - return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid) .'/time_stats')); - } - - /** - * @param int $project_id - * @param int $issue_iid - * - * @return mixed - */ - public function awardEmoji($project_id, $issue_iid) - { - return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid).'/award_emoji')); - } - - /** - * @param int $project_id - * @param int $issue_iid - * @return mixed - */ - public function closedByMergeRequests($project_id, $issue_iid) - { - return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid)).'/closed_by'); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Jobs.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Jobs.php deleted file mode 100755 index 2bec5679621145ff75b0b1bc56c55672ec0732d4..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Jobs.php +++ /dev/null @@ -1,178 +0,0 @@ -<?php namespace Gitlab\Api; - -use Psr\Http\Message\StreamInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -class Jobs extends AbstractApi -{ - const SCOPE_CREATED = 'created'; - const SCOPE_PENDING = 'pending'; - const SCOPE_RUNNING = 'running'; - const SCOPE_FAILED = 'failed'; - const SCOPE_SUCCESS = 'success'; - const SCOPE_CANCELED = 'canceled'; - const SCOPE_SKIPPED = 'skipped'; - const SCOPE_MANUAL = 'manual'; - - /** - * @param int|string $project_id - * @param array $parameters ( - * - * @var string|string[] $scope The scope of jobs to show, one or array of: created, pending, running, failed, - * success, canceled, skipped, manual; showing all jobs if none provided. - * ) - * - * @return mixed - */ - public function all($project_id, array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - - return $this->get("projects/".$this->encodePath($project_id)."/jobs", $resolver->resolve($parameters)); - } - - /** - * @param int|string $project_id - * @param int $pipeline_id - * @param array $parameters ( - * - * @var string|string[] $scope The scope of jobs to show, one or array of: created, pending, running, failed, - * success, canceled, skipped, manual; showing all jobs if none provided. - * ) - * - * @return mixed - */ - public function pipelineJobs($project_id, $pipeline_id, array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - - return $this->get( - $this->getProjectPath($project_id, 'pipelines/').$this->encodePath($pipeline_id)."/jobs", - $resolver->resolve($parameters) - ); - } - - /** - * @param int|string $project_id - * @param int $job_id - * @return mixed - */ - public function show($project_id, $job_id) - { - return $this->get("projects/".$this->encodePath($project_id)."/jobs/".$this->encodePath($job_id)); - } - - /** - * @param int|string $project_id - * @param int $job_id - * @return StreamInterface - */ - public function artifacts($project_id, $job_id) - { - return $this->getAsResponse("projects/".$this->encodePath($project_id)."/jobs/".$this->encodePath($job_id)."/artifacts")->getBody(); - } - - /** - * @param int|string $project_id - * @param string $ref_name - * @param string $job_name - * @return StreamInterface - */ - public function artifactsByRefName($project_id, $ref_name, $job_name) - { - return $this->getAsResponse("projects/".$this->encodePath($project_id)."/jobs/artifacts/".$this->encodePath($ref_name)."/download", array( - 'job' => $job_name - ))->getBody(); - } - - /** - * @param int|string $project_id - * @param int $job_id - * @return string - */ - public function trace($project_id, $job_id) - { - return $this->get("projects/".$this->encodePath($project_id)."/jobs/".$this->encodePath($job_id)."/trace"); - } - - /** - * @param int|string $project_id - * @param int $job_id - * @return mixed - */ - public function cancel($project_id, $job_id) - { - return $this->post("projects/".$this->encodePath($project_id)."/jobs/".$this->encodePath($job_id)."/cancel"); - } - - /** - * @param int|string $project_id - * @param int $job_id - * @return mixed - */ - public function retry($project_id, $job_id) - { - return $this->post("projects/".$this->encodePath($project_id)."/jobs/".$this->encodePath($job_id)."/retry"); - } - - /** - * @param int|string $project_id - * @param int $job_id - * @return mixed - */ - public function erase($project_id, $job_id) - { - return $this->post("projects/".$this->encodePath($project_id)."/jobs/".$this->encodePath($job_id)."/erase"); - } - - /** - * @param int|string $project_id - * @param int $job_id - * @return mixed - */ - public function keepArtifacts($project_id, $job_id) - { - return $this->post("projects/".$this->encodePath($project_id)."/jobs/".$this->encodePath($job_id)."/artifacts/keep"); - } - - /** - * @param int|string $project_id - * @param int $job_id - * @return mixed - */ - public function play($project_id, $job_id) - { - return $this->post("projects/".$this->encodePath($project_id)."/jobs/".$this->encodePath($job_id)."/play"); - } - - /** - * {@inheritdoc} - */ - protected function createOptionsResolver() - { - $allowedScopeValues = [ - self::SCOPE_CANCELED, - self::SCOPE_CREATED, - self::SCOPE_FAILED, - self::SCOPE_MANUAL, - self::SCOPE_PENDING, - self::SCOPE_RUNNING, - self::SCOPE_SKIPPED, - self::SCOPE_SUCCESS, - ]; - - $resolver = parent::createOptionsResolver(); - $resolver->setDefined('scope') - ->setAllowedTypes('scope', ['string', 'array']) - ->setAllowedValues('scope', $allowedScopeValues) - ->addAllowedValues('scope', function ($value) use ($allowedScopeValues) { - return is_array($value) && empty(array_diff($value, $allowedScopeValues)); - }) - ->setNormalizer('scope', function (OptionsResolver $resolver, $value) { - return (array) $value; - }) - ; - - return $resolver; - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Keys.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Keys.php deleted file mode 100755 index 162c33855c9028545c0f65989d94e2175f1dff31..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Keys.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php namespace Gitlab\Api; - -class Keys extends AbstractApi -{ - /** - * @param int $id - * @return mixed - */ - public function show($id) - { - return $this->get('keys/'.$this->encodePath($id)); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/MergeRequests.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/MergeRequests.php deleted file mode 100755 index 0cdc602ddb402a70e43388d3fa32dfbe768b1ee1..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/MergeRequests.php +++ /dev/null @@ -1,256 +0,0 @@ -<?php namespace Gitlab\Api; - -use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; -use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; - -class MergeRequests extends AbstractApi -{ - const STATE_ALL = 'all'; - const STATE_MERGED = 'merged'; - const STATE_OPENED = 'opened'; - const STATE_CLOSED = 'closed'; - - /** - * @param int $project_id - * @param array $parameters { - * - * @var int[] $iids Return the request having the given iid. - * @var string $state Return all merge requests or just those that are opened, closed, or - * merged. - * @var string $order_by Return requests ordered by created_at or updated_at fields. Default - * is created_at. - * @var string $sort Return requests sorted in asc or desc order. Default is desc. - * @var string $milestone Return merge requests for a specific milestone. - * @var string $view If simple, returns the iid, URL, title, description, and basic state - * of merge request. - * @var string $labels Return merge requests matching a comma separated list of labels. - * @var \DateTimeInterface $created_after Return merge requests created after the given time (inclusive). - * @var \DateTimeInterface $created_before Return merge requests created before the given time (inclusive). - * } - * - * @throws UndefinedOptionsException If an option name is undefined. - * @throws InvalidOptionsException If an option doesn't fulfill the specified validation rules. - * - * @return mixed - */ - public function all($project_id, array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - $datetimeNormalizer = function (\DateTimeInterface $value) { - return $value->format('c'); - }; - $resolver->setDefined('iids') - ->setAllowedTypes('iids', 'array') - ->setAllowedValues('iids', function (array $value) { - return count($value) == count(array_filter($value, 'is_int')); - }) - ; - $resolver->setDefined('state') - ->setAllowedValues('state', ['all', 'opened', 'merged', 'closed']) - ; - $resolver->setDefined('order_by') - ->setAllowedValues('order_by', ['created_at', 'updated_at']) - ; - $resolver->setDefined('sort') - ->setAllowedValues('sort', ['asc', 'desc']) - ; - $resolver->setDefined('milestone'); - $resolver->setDefined('view') - ->setAllowedValues('view', ['simple']) - ; - $resolver->setDefined('labels'); - $resolver->setDefined('created_after') - ->setAllowedTypes('created_after', \DateTimeInterface::class) - ->setNormalizer('created_after', $datetimeNormalizer) - ; - $resolver->setDefined('created_before') - ->setAllowedTypes('created_before', \DateTimeInterface::class) - ->setNormalizer('created_before', $datetimeNormalizer) - ; - - return $this->get($this->getProjectPath($project_id, 'merge_requests'), $resolver->resolve($parameters)); - } - - /** - * @param int $project_id - * @param int $mr_id - * @return mixed - */ - public function show($project_id, $mr_id) - { - return $this->get($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_id))); - } - - /** - * @param int $project_id - * @param string $source - * @param string $target - * @param string $title - * @param int $assignee - * @param int $target_project_id - * @param string $description - * @return mixed - */ - public function create($project_id, $source, $target, $title, $assignee = null, $target_project_id = null, $description = null) - { - return $this->post($this->getProjectPath($project_id, 'merge_requests'), array( - 'source_branch' => $source, - 'target_branch' => $target, - 'title' => $title, - 'assignee_id' => $assignee, - 'target_project_id' => $target_project_id, - 'description' => $description - )); - } - - /** - * @param int $project_id - * @param int $mr_id - * @param array $params - * @return mixed - */ - public function update($project_id, $mr_id, array $params) - { - return $this->put($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_id)), $params); - } - - /** - * @param int $project_id - * @param int $mr_id - * @param string $message - * @return mixed - */ - public function merge($project_id, $mr_id, $message = null) - { - if (is_array($message)) { - $params = $message; - } else { - $params = array('merge_commit_message' => $message); - } - - return $this->put($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_id).'/merge'), $params); - } - - /** - * @param int $project_id - * @param int $mr_id - * - * @return mixed - */ - public function showNotes($project_id, $mr_id) - { - return $this->get($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_id).'/notes')); - } - - /** - * @param int $project_id - * @param int $mr_id - * @param string $note - * @return mixed - */ - public function addNote($project_id, $mr_id, $note) - { - return $this->post($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_id).'/notes'), array( - 'body' => $note - )); - } - - /** - * @param int $project_id - * @param int $mr_id - * @return mixed - */ - public function showComments($project_id, $mr_id) - { - @trigger_error(sprintf('The %s() method is deprecated since version 9.1 and will be removed in 10.0. Use the showNotes() method instead.', __METHOD__), E_USER_DEPRECATED); - - return $this->showNotes($project_id, $mr_id); - } - - /** - * @param int $project_id - * @param int $mr_id - * @param string $note - * @return mixed - */ - public function addComment($project_id, $mr_id, $note) - { - @trigger_error(sprintf('The %s() method is deprecated since version 9.1 and will be removed in 10.0. Use the addNote() method instead.', __METHOD__), E_USER_DEPRECATED); - - return $this->addNote($project_id, $mr_id, $note); - } - - /** - * @param int $project_id - * @param int $mr_id - * @return mixed - */ - public function changes($project_id, $mr_id) - { - return $this->get($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_id).'/changes')); - } - - /** - * @param int $project_id - * @param int $mr_id - * @return mixed - */ - public function commits($project_id, $mr_id) - { - return $this->get($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_id).'/commits')); - } - - /** - * @param int $project_id - * @param int $mr_id - * @return mixed - */ - public function closesIssues($project_id, $mr_id) - { - return $this->get($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_id).'/closes_issues')); - } - - /** - * @param int $project_id - * @param int $mr_id - * - * @return mixed - */ - public function approvals($project_id, $merge_request_iid) - { - return $this->get($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($merge_request_iid).'/approvals')); - } - - /** - * @param int $project_id - * @param int $mr_id - * - * @return mixed - */ - public function approve($project_id, $merge_request_iid) - { - return $this->post($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($merge_request_iid).'/approve')); - } - - /** - * @param int $project_id - * @param int $mr_id - * - * @return mixed - */ - public function unapprove($project_id, $merge_request_iid) - { - return $this->post($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($merge_request_iid).'/unapprove')); - } - - /** - * @param int $project_id - * @param int $merge_request_iid - * - * @return mixed - */ - public function awardEmoji($project_id, $merge_request_iid) - { - return $this->get($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($merge_request_iid).'/award_emoji')); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Milestones.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Milestones.php deleted file mode 100755 index 0f9b2d25ed55cc1e02dd0a5ff0ed6dd6fb2fae66..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Milestones.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php namespace Gitlab\Api; - -class Milestones extends AbstractApi -{ - /** - * @param int $project_id - * @param array $parameters ( - * - * @var int[] $iids Return only the milestones having the given iids. - * @var string $state Return only active or closed milestones. - * @var string $search Return only milestones with a title or description matching the provided string. - * ) - * - * @return mixed - */ - public function all($project_id, array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - $resolver->setDefined('iids') - ->setAllowedTypes('iids', 'array') - ->setAllowedValues('iids', function (array $value) { - return count($value) == count(array_filter($value, 'is_int')); - }) - ; - $resolver->setDefined('state') - ->setAllowedValues('state', ['active', 'closed']) - ; - $resolver->setDefined('search'); - - return $this->get($this->getProjectPath($project_id, 'milestones'), $resolver->resolve($parameters)); - } - - /** - * @param int $project_id - * @param int $milestone_id - * @return mixed - */ - public function show($project_id, $milestone_id) - { - return $this->get($this->getProjectPath($project_id, 'milestones/'.$this->encodePath($milestone_id))); - } - - /** - * @param int $project_id - * @param array $params - * @return mixed - */ - public function create($project_id, array $params) - { - return $this->post($this->getProjectPath($project_id, 'milestones'), $params); - } - - /** - * @param int $project_id - * @param int $milestone_id - * @param array $params - * @return mixed - */ - public function update($project_id, $milestone_id, array $params) - { - return $this->put($this->getProjectPath($project_id, 'milestones/'.$this->encodePath($milestone_id)), $params); - } - - /** - * @param int $project_id - * @param int $milestone_id - * @return mixed - */ - public function issues($project_id, $milestone_id) - { - return $this->get($this->getProjectPath($project_id, 'milestones/'.$this->encodePath($milestone_id).'/issues')); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/ProjectNamespaces.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/ProjectNamespaces.php deleted file mode 100755 index 815d4e083addf8ebcd669ad5b74a5700911cb410..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/ProjectNamespaces.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php namespace Gitlab\Api; - -class ProjectNamespaces extends AbstractApi -{ - /** - * @param array $parameters ( - * - * @var string $search Returns a list of namespaces the user is authorized to see based on the search criteria. - * ) - * - * @return mixed - */ - public function all(array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - $resolver->setDefined('search'); - - return $this->get('namespaces', $resolver->resolve($parameters)); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Projects.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Projects.php deleted file mode 100755 index 489ddb666cd7e570163477c47df23324be221ae8..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Projects.php +++ /dev/null @@ -1,658 +0,0 @@ -<?php namespace Gitlab\Api; - -use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; -use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; - -class Projects extends AbstractApi -{ - /** - * @param array $parameters { - * - * @var bool $archived Limit by archived status. - * @var string $visibility Limit by visibility public, internal, or private. - * @var string $order_by Return projects ordered by id, name, path, created_at, updated_at, - * or last_activity_at fields. Default is created_at. - * @var string $sort Return projects sorted in asc or desc order. Default is desc. - * @var string $search Return list of projects matching the search criteria. - * @var bool $simple Return only the ID, URL, name, and path of each project. - * @var bool $owned Limit by projects owned by the current user. - * @var bool $membership Limit by projects that the current user is a member of. - * @var bool $starred Limit by projects starred by the current user. - * @var bool $statistics Include project statistics. - * @var bool $with_issues_enabled Limit by enabled issues feature. - * @var bool $with_merge_requests_enabled Limit by enabled merge requests feature. - * } - * - * @throws UndefinedOptionsException If an option name is undefined - * @throws InvalidOptionsException If an option doesn't fulfill the - * specified validation rules - * - * @return mixed - */ - public function all(array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - $booleanNormalizer = function ($value) { - return $value ? 'true' : 'false'; - }; - $resolver->setDefined('archived') - ->setAllowedTypes('archived', 'bool') - ->setNormalizer('archived', $booleanNormalizer) - ; - $resolver->setDefined('visibility') - ->setAllowedValues('visibility', ['public', 'internal', 'private']) - ; - $resolver->setDefined('order_by') - ->setAllowedValues('order_by', ['id', 'name', 'path', 'created_at', 'updated_at', 'last_activity_at']) - ; - $resolver->setDefined('sort') - ->setAllowedValues('sort', ['asc', 'desc']) - ; - $resolver->setDefined('search'); - $resolver->setDefined('simple') - ->setAllowedTypes('simple', 'bool') - ->setNormalizer('simple', $booleanNormalizer) - ; - $resolver->setDefined('owned') - ->setAllowedTypes('owned', 'bool') - ->setNormalizer('owned', $booleanNormalizer) - ; - $resolver->setDefined('membership') - ->setAllowedTypes('membership', 'bool') - ->setNormalizer('membership', $booleanNormalizer) - ; - $resolver->setDefined('starred') - ->setAllowedTypes('starred', 'bool') - ->setNormalizer('starred', $booleanNormalizer) - ; - $resolver->setDefined('statistics') - ->setAllowedTypes('statistics', 'bool') - ->setNormalizer('statistics', $booleanNormalizer) - ; - $resolver->setDefined('with_issues_enabled') - ->setAllowedTypes('with_issues_enabled', 'bool') - ->setNormalizer('with_issues_enabled', $booleanNormalizer) - ; - $resolver->setDefined('with_merge_requests_enabled') - ->setAllowedTypes('with_merge_requests_enabled', 'bool') - ->setNormalizer('with_merge_requests_enabled', $booleanNormalizer) - ; - - return $this->get('projects', $resolver->resolve($parameters)); - } - - /** - * @param int $project_id - * @return mixed - */ - public function show($project_id) - { - return $this->get('projects/'.$this->encodePath($project_id)); - } - - /** - * @param string $name - * @param array $params - * @return mixed - */ - public function create($name, array $params = array()) - { - $params['name'] = $name; - - return $this->post('projects', $params); - } - - /** - * @param int $user_id - * @param string $name - * @param array $params - * @return mixed - */ - public function createForUser($user_id, $name, array $params = array()) - { - $params['name'] = $name; - - return $this->post('projects/user/'.$this->encodePath($user_id), $params); - } - - /** - * @param int $project_id - * @param array $params - * @return mixed - */ - public function update($project_id, array $params) - { - return $this->put('projects/'.$this->encodePath($project_id), $params); - } - - /** - * @param int $project_id - * @return mixed - */ - public function remove($project_id) - { - return $this->delete('projects/'.$this->encodePath($project_id)); - } - - /** - * @param int $project_id - * @return mixed - */ - public function archive($project_id) - { - return $this->post("projects/".$this->encodePath($project_id)."/archive"); - } - - /** - * @param int $project_id - * @return mixed - */ - public function unarchive($project_id) - { - return $this->post("projects/".$this->encodePath($project_id)."/unarchive"); - } - - /** - * @param int $project_id - * @param array $parameters ( - * - * @var string $scope The scope of pipelines, one of: running, pending, finished, branches, tags. - * @var string $status The status of pipelines, one of: running, pending, success, failed, canceled, skipped. - * @var string $ref The ref of pipelines. - * @var bool $yaml_errors Returns pipelines with invalid configurations. - * @var string $name The name of the user who triggered pipelines. - * @var string $username The username of the user who triggered pipelines. - * @var string $order_by Order pipelines by id, status, ref, or user_id (default: id). - * @var string $order Sort pipelines in asc or desc order (default: desc). - * ) - * @return mixed - */ - public function pipelines($project_id, array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - $booleanNormalizer = function ($value) { - return $value ? 'true' : 'false'; - }; - - $resolver->setDefined('scope') - ->setAllowedValues('scope', ['running', 'pending', 'finished', 'branches', 'tags']) - ; - $resolver->setDefined('status') - ->setAllowedValues('status', ['running', 'pending', 'success', 'failed', 'canceled', 'skipped']) - ; - $resolver->setDefined('ref'); - $resolver->setDefined('yaml_errors') - ->setAllowedTypes('yaml_errors', 'bool') - ->setNormalizer('yaml_errors', $booleanNormalizer) - ; - $resolver->setDefined('name'); - $resolver->setDefined('username'); - $resolver->setDefined('order_by') - ->setAllowedValues('order_by', ['id', 'status', 'ref', 'user_id']) - ; - $resolver->setDefined('sort') - ->setAllowedValues('sort', ['asc', 'desc']) - ; - - return $this->get($this->getProjectPath($project_id, 'pipelines'), $resolver->resolve($parameters)); - } - - /** - * @param int $project_id - * @param int $pipeline_id - * @return mixed - */ - public function pipeline($project_id, $pipeline_id) - { - return $this->get($this->getProjectPath($project_id, 'pipelines/'.$this->encodePath($pipeline_id))); - } - - /** - * @param int $project_id - * @param string $commit_ref - * @return mixed - */ - public function createPipeline($project_id, $commit_ref) - { - return $this->post($this->getProjectPath($project_id, 'pipeline'), array( - 'ref' => $commit_ref)); - } - - /** - * @param int $project_id - * @param int $pipeline_id - * @return mixed - */ - public function retryPipeline($project_id, $pipeline_id) - { - return $this->post($this->getProjectPath($project_id, 'pipelines/'.$this->encodePath($pipeline_id)).'/retry'); - } - - /** - * @param int $project_id - * @param int $pipeline_id - * @return mixed - */ - public function cancelPipeline($project_id, $pipeline_id) - { - return $this->post($this->getProjectPath($project_id, 'pipelines/'.$this->encodePath($pipeline_id)).'/cancel'); - } - - /** - * @param int $project_id - * @param string $username_query - * @return mixed - */ - public function members($project_id, $username_query = null) - { - return $this->get($this->getProjectPath($project_id, 'members'), array( - 'query' => $username_query - )); - } - - /** - * @param int $project_id - * @param int $user_id - * @return mixed - */ - public function member($project_id, $user_id) - { - return $this->get($this->getProjectPath($project_id, 'members/'.$this->encodePath($user_id))); - } - - /** - * @param int $project_id - * @param int $user_id - * @param int $access_level - * @return mixed - */ - public function addMember($project_id, $user_id, $access_level) - { - return $this->post($this->getProjectPath($project_id, 'members'), array( - 'user_id' => $user_id, - 'access_level' => $access_level - )); - } - - /** - * @param int $project_id - * @param int $user_id - * @param int $access_level - * @return mixed - */ - public function saveMember($project_id, $user_id, $access_level) - { - return $this->put($this->getProjectPath($project_id, 'members/'.urldecode($user_id)), array( - 'access_level' => $access_level - )); - } - - /** - * @param int $project_id - * @param int $user_id - * @return mixed - */ - public function removeMember($project_id, $user_id) - { - return $this->delete($this->getProjectPath($project_id, 'members/'.urldecode($user_id))); - } - - /** - * @param int $project_id - * @param array $parameters - * - * @return mixed - */ - public function hooks($project_id, array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - - return $this->get($this->getProjectPath($project_id, 'hooks'), $resolver->resolve($parameters)); - } - - /** - * @param int $project_id - * @param int $hook_id - * @return mixed - */ - public function hook($project_id, $hook_id) - { - return $this->get($this->getProjectPath($project_id, 'hooks/'.$this->encodePath($hook_id))); - } - - /** - * @param int $project_id - * @param string $url - * @param array $params - * @return mixed - */ - public function addHook($project_id, $url, array $params = array()) - { - if (empty($params)) { - $params = array('push_events' => true); - } - - $params['url'] = $url; - - return $this->post($this->getProjectPath($project_id, 'hooks'), $params); - } - - /** - * @param int $project_id - * @param int $hook_id - * @param array $params - * @return mixed - */ - public function updateHook($project_id, $hook_id, array $params) - { - return $this->put($this->getProjectPath($project_id, 'hooks/'.$this->encodePath($hook_id)), $params); - } - - /** - * @param int $project_id - * @param int $hook_id - * @return mixed - */ - public function removeHook($project_id, $hook_id) - { - return $this->delete($this->getProjectPath($project_id, 'hooks/'.$this->encodePath($hook_id))); - } - - /** - * @param int $project_id - * @return mixed - */ - public function deployKeys($project_id) - { - return $this->get($this->getProjectPath($project_id, 'deploy_keys')); - } - - /** - * @param int $project_id - * @param int $key_id - * @return mixed - */ - public function deployKey($project_id, $key_id) - { - return $this->get($this->getProjectPath($project_id, 'deploy_keys/'.$this->encodePath($key_id))); - } - - /** - * @param int $project_id - * @param string $title - * @param string $key - * @param bool $canPush - * @return mixed - */ - public function addDeployKey($project_id, $title, $key, $canPush = false) - { - return $this->post($this->getProjectPath($project_id, 'deploy_keys'), array( - 'title' => $title, - 'key' => $key, - 'can_push' => $canPush - )); - } - - /** - * @param int $project_id - * @param int $key_id - * @return mixed - */ - public function deleteDeployKey($project_id, $key_id) - { - return $this->delete($this->getProjectPath($project_id, 'deploy_keys/'.$this->encodePath($key_id))); - } - - /** - * @param int $project_id - * @param int $key_id - * @return mixed - */ - public function enableDeployKey($project_id, $key_id) - { - return $this->post($this->getProjectPath($project_id, 'deploy_keys/'.$this->encodePath($key_id).'/enable')); - } - - /** - * @param int $project_id - * @param array $parameters ( - * - * @var string $action Include only events of a particular action type. - * @var string $target_type Include only events of a particular target type. - * @var \DateTimeInterface $before Include only events created before a particular date. - * @var \DateTimeInterface $after Include only events created after a particular date. - * @var string $sort Sort events in asc or desc order by created_at. Default is desc. - * ) - * - * @return mixed - */ - public function events($project_id, array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - $datetimeNormalizer = function (\DateTimeInterface $value) { - return $value->format('Y-m-d'); - }; - - $resolver->setDefined('action') - ->setAllowedValues('action', ['created', 'updated', 'closed', 'reopened', 'pushed', 'commented', 'merged', 'joined', 'left', 'destroyed', 'expired']) - ; - $resolver->setDefined('target_type') - ->setAllowedValues('target_type', ['issue', 'milestone', 'merge_request', 'note', 'project', 'snippet', 'user']) - ; - $resolver->setDefined('before') - ->setAllowedTypes('before', \DateTimeInterface::class) - ->setNormalizer('before', $datetimeNormalizer); - $resolver->setDefined('after') - ->setAllowedTypes('after', \DateTimeInterface::class) - ->setNormalizer('after', $datetimeNormalizer) - ; - $resolver->setDefined('sort') - ->setAllowedValues('sort', ['asc', 'desc']) - ; - - return $this->get($this->getProjectPath($project_id, 'events'), $resolver->resolve($parameters)); - } - - /** - * @param int $project_id - * @return mixed - */ - public function labels($project_id) - { - return $this->get($this->getProjectPath($project_id, 'labels')); - } - - /** - * @param int $project_id - * @param array $params - * @return mixed - */ - public function addLabel($project_id, array $params) - { - return $this->post($this->getProjectPath($project_id, 'labels'), $params); - } - - /** - * @param int $project_id - * @param array $params - * @return mixed - */ - public function updateLabel($project_id, array $params) - { - return $this->put($this->getProjectPath($project_id, 'labels'), $params); - } - - /** - * @param int $project_id - * @param string $name - * @return mixed - */ - public function removeLabel($project_id, $name) - { - return $this->delete($this->getProjectPath($project_id, 'labels'), array( - 'name' => $name - )); - } - - /** - * @param int $project_id - * @return mixed - */ - public function fork($project_id) - { - return $this->post('projects/'.$this->encodePath($project_id).'/fork'); - } - - /** - * @param int $project_id - * @param int $forked_project_id - * @return mixed - */ - public function createForkRelation($project_id, $forked_project_id) - { - return $this->post($this->getProjectPath($project_id, 'fork/'.$this->encodePath($forked_project_id))); - } - - /** - * @param int $project_id - * @return mixed - */ - public function removeForkRelation($project_id) - { - return $this->delete($this->getProjectPath($project_id, 'fork')); - } - - /** - * @param int $project_id - * @param string $service_name - * @param array $params - * @return mixed - */ - public function setService($project_id, $service_name, array $params = array()) - { - return $this->put($this->getProjectPath($project_id, 'services/'.$this->encodePath($service_name)), $params); - } - - /** - * @param int $project_id - * @param string $service_name - * @return mixed - */ - public function removeService($project_id, $service_name) - { - return $this->delete($this->getProjectPath($project_id, 'services/'.$this->encodePath($service_name))); - } - - /** - * @param int $project_id - * @return mixed - */ - public function variables($project_id) - { - return $this->get($this->getProjectPath($project_id, 'variables')); - } - - /** - * @param int $project_id - * @param string $key - * @return mixed - */ - public function variable($project_id, $key) - { - return $this->get($this->getProjectPath($project_id, 'variables/'.$this->encodePath($key))); - } - - /** - * @param int $project_id - * @param string $key - * @param string $value - * @param bool $protected - * @param string $environment_scope - * @return mixed - */ - public function addVariable($project_id, $key, $value, $protected = null, $environment_scope = null) - { - $payload = array( - 'key' => $key, - 'value' => $value, - ); - - if ($protected) { - $payload['protected'] = $protected; - } - - if ($environment_scope) { - $payload['environment_scope'] = $environment_scope; - } - - return $this->post($this->getProjectPath($project_id, 'variables'), $payload); - } - - /** - * @param int $project_id - * @param string $key - * @param string $value - * @param bool $protected - * @param string $environment_scope - * @return mixed - */ - public function updateVariable($project_id, $key, $value, $protected = null, $environment_scope = null) - { - $payload = array( - 'value' => $value, - ); - - if ($protected) { - $payload['protected'] = $protected; - } - - if ($environment_scope) { - $payload['environment_scope'] = $environment_scope; - } - - return $this->put($this->getProjectPath($project_id, 'variables/'.$this->encodePath($key)), $payload); - } - - /** - * @param int $project_id - * @param string $key - * @return mixed - */ - public function removeVariable($project_id, $key) - { - return $this->delete($this->getProjectPath($project_id, 'variables/'.$this->encodePath($key))); - } - - /** - * @param int $project_id - * @param string $file - * @return mixed - */ - public function uploadFile($project_id, $file) - { - return $this->post($this->getProjectPath($project_id, 'uploads'), array(), array(), array('file' => $file)); - } - - /** - * @param int $project_id - * @param array $parameters - * - * @return mixed - */ - public function deployments($project_id, array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - - return $this->get($this->getProjectPath($project_id, 'deployments'), $resolver->resolve($parameters)); - } - - /** - * @param int $project_id - * @param int $deployment_id - * @return mixed - */ - public function deployment($project_id, $deployment_id) - { - return $this->get($this->getProjectPath($project_id, 'deployments/'.$this->encodePath($deployment_id))); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Repositories.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Repositories.php deleted file mode 100755 index 9fcca55a63684154cdb5ed03757760ba753d818f..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Repositories.php +++ /dev/null @@ -1,434 +0,0 @@ -<?php namespace Gitlab\Api; - -use Symfony\Component\OptionsResolver\OptionsResolver; - -class Repositories extends AbstractApi -{ - /** - * @param int $project_id - * @return mixed - */ - public function branches($project_id) - { - return $this->get($this->getProjectPath($project_id, 'repository/branches')); - } - - /** - * @param int $project_id - * @param int $branch_id - * @return mixed - */ - public function branch($project_id, $branch_id) - { - return $this->get($this->getProjectPath($project_id, 'repository/branches/'.$this->encodeBranch($branch_id))); - } - - /** - * @param int $project_id - * @param string $branch - * @param string $ref - * @return mixed - */ - public function createBranch($project_id, $branch, $ref) - { - return $this->post($this->getProjectPath($project_id, 'repository/branches'), array( - 'branch' => $branch, - 'ref' => $ref - )); - } - - /** - * @param int $project_id - * @param string $branch - * @return mixed - */ - public function deleteBranch($project_id, $branch) - { - return $this->delete($this->getProjectPath($project_id, 'repository/branches/'.$this->encodeBranch($branch))); - } - - /** - * @param int $project_id - * @param string $branch_name - * @param bool $devPush - * @param bool $devMerge - * @return mixed - */ - public function protectBranch($project_id, $branch_name, $devPush = false, $devMerge = false) - { - return $this->put($this->getProjectPath($project_id, 'repository/branches/'.$this->encodeBranch($branch_name).'/protect'), array( - 'developers_can_push' => $devPush, - 'developers_can_merge' => $devMerge - )); - } - - /** - * @param int $project_id - * @param string $branch_name - * @return mixed - */ - public function unprotectBranch($project_id, $branch_name) - { - return $this->put($this->getProjectPath($project_id, 'repository/branches/'.$this->encodeBranch($branch_name).'/unprotect')); - } - - /** - * @param int $project_id - * @param array $parameters - * @return mixed - */ - public function tags($project_id, array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - - return $this->get($this->getProjectPath($project_id, 'repository/tags'), $resolver->resolve($parameters)); - } - - /** - * @param int $project_id - * @param string $name - * @param string $ref - * @param string $message - * @return mixed - */ - public function createTag($project_id, $name, $ref, $message = null) - { - return $this->post($this->getProjectPath($project_id, 'repository/tags'), array( - 'tag_name' => $name, - 'ref' => $ref, - 'message' => $message - )); - } - - /** - * @param int $project_id - * @param string $tag_name - * @param string $description - * - * @return mixed - */ - public function createRelease($project_id, $tag_name, $description) - { - return $this->post($this->getProjectPath($project_id, 'repository/tags/' . $this->encodeBranch($tag_name) . '/release'), array( - 'id' => $project_id, - 'tag_name' => $tag_name, - 'description' => $description - )); - } - - /** - * @param int $project_id - * @param string $tag_name - * @param string $description - * - * @return mixed - */ - public function updateRelease($project_id, $tag_name, $description) - { - return $this->put($this->getProjectPath($project_id, 'repository/tags/' . $this->encodeBranch($tag_name) . '/release'), array( - 'id' => $project_id, - 'tag_name' => $tag_name, - 'description' => $description - )); - } - - /** - * @param int $project_id - * @param array $parameters ( - * - * @var string $ref_name The name of a repository branch or tag or if not given the default branch. - * @var \DateTimeInterface $since Only commits after or on this date will be returned. - * @var \DateTimeInterface $until Only commits before or on this date will be returned. - * ) - * - * @return mixed - */ - public function commits($project_id, array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - $datetimeNormalizer = function (\DateTimeInterface $value) { - return $value->format('c'); - }; - - $resolver->setDefined('ref_name'); - $resolver->setDefined('since') - ->setAllowedTypes('since', \DateTimeInterface::class) - ->setNormalizer('since', $datetimeNormalizer) - ; - $resolver->setDefined('until') - ->setAllowedTypes('until', \DateTimeInterface::class) - ->setNormalizer('until', $datetimeNormalizer) - ; - - return $this->get($this->getProjectPath($project_id, 'repository/commits'), $resolver->resolve($parameters)); - } - - /** - * @param int $project_id - * @param $sha - * @return mixed - */ - public function commit($project_id, $sha) - { - return $this->get($this->getProjectPath($project_id, 'repository/commits/'.$this->encodePath($sha))); - } - - /** - * @param int $project_id - * @param array $parameters ( - * - * @var string $branch Name of the branch to commit into. To create a new branch, also provide start_branch. - * @var string $commit_message Commit message. - * @var string $start_branch Name of the branch to start the new commit from. - * @var array $actions ( - * - * @var string $action he action to perform, create, delete, move, update. - * @var string $file_path Full path to the file. - * @var string $previous_path Original full path to the file being moved. - * @var string $content File content, required for all except delete. Optional for move. - * @var string $encoding text or base64. text is default. - * ) - * @var string $author_email Specify the commit author's email address. - * @var string $author_name Specify the commit author's name. - * ) - * - * @return mixed - */ - public function createCommit($project_id, array $parameters = []) - { - $resolver = new OptionsResolver(); - $resolver->setDefined('branch') - ->setRequired('branch') - ; - $resolver->setDefined('commit_message') - ->setRequired('commit_message') - ; - $resolver->setDefined('start_branch'); - $resolver->setDefined('actions') - ->setRequired('actions') - ->setAllowedTypes('actions', 'array') - ->setAllowedValues('actions', function (array $actions) { - return !empty($actions); - }) - ->setNormalizer('actions', function (OptionsResolver $resolver, array $actions) { - $actionsOptionsResolver = new OptionsResolver(); - $actionsOptionsResolver->setDefined('action') - ->setRequired('action') - ->setAllowedValues('action', ['create', 'delete', 'move', 'update']) - ; - $actionsOptionsResolver->setDefined('file_path') - ->setRequired('file_path') - ; - $actionsOptionsResolver->setDefined('previous_path'); - $actionsOptionsResolver->setDefined('content'); - $actionsOptionsResolver->setDefined('encoding') - ->setAllowedValues('encoding', ['test', 'base64']) - ; - - return array_map(function ($action) use ($actionsOptionsResolver) { - return $actionsOptionsResolver->resolve($action); - }, $actions); - }) - ; - $resolver->setDefined('author_email'); - $resolver->setDefined('author_name'); - - return $this->post($this->getProjectPath($project_id, 'repository/commits'), $resolver->resolve($parameters)); - } - - /** - * @param int $project_id - * @param string $sha - * @param array $parameters - * - * @return mixed - */ - public function commitComments($project_id, $sha, array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - - return $this->get( - $this->getProjectPath($project_id, 'repository/commits/'.$this->encodePath($sha).'/comments'), - $resolver->resolve($parameters) - ); - } - - /** - * @param int $project_id - * @param string $sha - * @param string $note - * @param array $params - * @return mixed - */ - public function createCommitComment($project_id, $sha, $note, array $params = array()) - { - $params['note'] = $note; - - return $this->post($this->getProjectPath($project_id, 'repository/commits/'.$this->encodePath($sha).'/comments'), $params); - } - - /** - * @param int $project_id - * @param string $fromShaOrMaster - * @param string $toShaOrMaster - * @return mixed - */ - public function compare($project_id, $fromShaOrMaster, $toShaOrMaster) - { - return $this->get($this->getProjectPath( - $project_id, - 'repository/compare?from='.$this->encodeBranch($fromShaOrMaster).'&to='.$this->encodeBranch($toShaOrMaster) - )); - } - - /** - * @param int $project_id - * @param string $sha - * @return string - */ - public function diff($project_id, $sha) - { - return $this->get($this->getProjectPath($project_id, 'repository/commits/'.$this->encodePath($sha).'/diff')); - } - - /** - * @param int $project_id - * @param array $params - * @return mixed - */ - public function tree($project_id, array $params = array()) - { - return $this->get($this->getProjectPath($project_id, 'repository/tree'), $params); - } - - /** - * @param int $project_id - * @param string $sha - * @param string $filepath - * @return mixed - */ - public function blob($project_id, $sha, $filepath) - { - @trigger_error(sprintf('The %s() method is deprecated since version 9.2 and will be removed in 10.0. Use the %s::getRawFile() method instead.', __METHOD__, RepositoryFiles::class), E_USER_DEPRECATED); - - return $this->client->repositoryFiles()->getRawFile($project_id, $filepath, $sha); - } - - /** - * @param int $project_id - * @param string $file_path - * @param string $ref - * @return mixed - */ - public function getFile($project_id, $file_path, $ref) - { - @trigger_error(sprintf('The %s() method is deprecated since version 9.2 and will be removed in 10.0. Use the %s::getFile() method instead.', __METHOD__, RepositoryFiles::class), E_USER_DEPRECATED); - - return $this->client->repositoryFiles()->getFile($project_id, $file_path, $ref); - } - - /** - * @param int $project_id - * @param string $file_path - * @param string $content - * @param string $branch - * @param string $commit_message - * @param string $encoding - * @param string $author_email - * @param string $author_name - * @return mixed - */ - public function createFile($project_id, $file_path, $content, $branch, $commit_message, $encoding = null, $author_email = null, $author_name = null) - { - @trigger_error(sprintf('The %s() method is deprecated since version 9.2 and will be removed in 10.0. Use the %s::createFile() method instead.', __METHOD__, RepositoryFiles::class), E_USER_DEPRECATED); - - return $this->client->repositoryFiles()->createFile($project_id, [ - 'file_path' => $file_path, - 'branch' => $branch, - 'content' => $content, - 'commit_message' => $commit_message, - 'encoding' => $encoding, - 'author_email' => $author_email, - 'author_name' => $author_name, - ]); - } - - /** - * @param int $project_id - * @param string $file_path - * @param string $content - * @param string $branch - * @param string $commit_message - * @param string $encoding - * @param string $author_email - * @param string $author_name - * @return mixed - */ - public function updateFile($project_id, $file_path, $content, $branch, $commit_message, $encoding = null, $author_email = null, $author_name = null) - { - @trigger_error(sprintf('The %s() method is deprecated since version 9.2 and will be removed in 10.0. Use the %s::updateFile() method instead.', __METHOD__, RepositoryFiles::class), E_USER_DEPRECATED); - - return $this->client->repositoryFiles()->updateFile($project_id, [ - 'file_path' => $file_path, - 'branch' => $branch, - 'content' => $content, - 'commit_message' => $commit_message, - 'encoding' => $encoding, - 'author_email' => $author_email, - 'author_name' => $author_name, - ]); - } - - /** - * @param int $project_id - * @param string $file_path - * @param string $branch - * @param string $commit_message - * @param string $author_email - * @param string $author_name - * @return mixed - */ - public function deleteFile($project_id, $file_path, $branch, $commit_message, $author_email = null, $author_name = null) - { - @trigger_error(sprintf('The %s() method is deprecated since version 9.2 and will be removed in 10.0. Use the %s::deleteFile() method instead.', __METHOD__, RepositoryFiles::class), E_USER_DEPRECATED); - - return $this->client->repositoryFiles()->deleteFile($project_id, [ - 'file_path' => $file_path, - 'branch' => $branch, - 'commit_message' => $commit_message, - 'author_email' => $author_email, - 'author_name' => $author_name, - ]); - } - - /** - * @param int $project_id - * @return mixed - */ - public function contributors($project_id) - { - return $this->get($this->getProjectPath($project_id, 'repository/contributors')); - } - - /** - * @param int $project_id - * @param array $params - * @param string $format Options: "tar.gz", "zip", "tar.bz2" and "tar" - * @return mixed - */ - public function archive($project_id, $params = array(), $format = 'tar.gz') - { - return $this->get($this->getProjectPath($project_id, 'repository/archive.'.$format), $params); - } - - /** - * @param string $path - * @return string - */ - protected function encodeBranch($path) - { - $path = $this->encodePath($path); - - return str_replace('%2F', '/', $path); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/RepositoryFiles.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/RepositoryFiles.php deleted file mode 100755 index bc20c00f0d8604756353474517e7dbfe84e4e7c7..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/RepositoryFiles.php +++ /dev/null @@ -1,135 +0,0 @@ -<?php - -namespace Gitlab\Api; - -use Symfony\Component\OptionsResolver\OptionsResolver; - -class RepositoryFiles extends AbstractApi -{ - /** - * @param int $project_id - * @param string $file_path - * @param string $ref - * @return mixed - */ - public function getFile($project_id, $file_path, $ref) - { - return $this->get($this->getProjectPath($project_id, 'repository/files/'.$this->encodePath($file_path)), array( - 'ref' => $ref - )); - } - - /** - * @param int $project_id - * @param string $file_path - * @param string $ref - * @return mixed - */ - public function getRawFile($project_id, $file_path, $ref) - { - return $this->get($this->getProjectPath($project_id, 'repository/files/'.$this->encodePath($file_path).'/raw'), array( - 'ref' => $ref, - )); - } - - /** - * @param int $project_id - * @param array $parameters ( - * - * @var string $file_path Url encoded full path to new file. Ex. lib%2Fclass%2Erb. - * @var string $branch Name of the branch. - * @var string $start_branch Name of the branch to start the new commit from. - * @var string $encoding Change encoding to 'base64'. Default is text. - * @var string $author_email Specify the commit author's email address. - * @var string $author_name Specify the commit author's name. - * @var string $content File content. - * @var string $commit_message Commit message. - * ) - * - * @return mixed - */ - public function createFile($project_id, array $parameters = []) - { - $resolver = new OptionsResolver(); - $resolver->setRequired('file_path'); - $resolver->setRequired('branch'); - $resolver->setDefined('start_branch'); - $resolver->setDefined('encoding') - ->setAllowedValues('encoding', ['text', 'base64']) - ; - $resolver->setDefined('author_email'); - $resolver->setDefined('author_name'); - $resolver->setRequired('content'); - $resolver->setRequired('commit_message'); - - $resolved = $resolver->resolve($parameters); - - return $this->post($this->getProjectPath($project_id, 'repository/files/'.$this->encodePath($resolved['file_path'])), $resolved); - } - - /** - * @param int $project_id - * @param array $parameters ( - * - * @var string $file_path Url encoded full path to new file. Ex. lib%2Fclass%2Erb. - * @var string $branch Name of the branch. - * @var string $start_branch Name of the branch to start the new commit from. - * @var string $encoding Change encoding to 'base64'. Default is text. - * @var string $author_email Specify the commit author's email address. - * @var string $author_name Specify the commit author's name. - * @var string $content File content. - * @var string $commit_message Commit message. - * @var string $last_commit_id Last known file commit id. - * ) - * - * @return mixed - */ - public function updateFile($project_id, array $parameters = []) - { - $resolver = new OptionsResolver(); - $resolver->setRequired('file_path'); - $resolver->setRequired('branch'); - $resolver->setDefined('start_branch'); - $resolver->setDefined('encoding') - ->setAllowedValues('encoding', ['text', 'base64']) - ; - $resolver->setDefined('author_email'); - $resolver->setDefined('author_name'); - $resolver->setRequired('content'); - $resolver->setRequired('commit_message'); - $resolver->setDefined('last_commit_id'); - - $resolved = $resolver->resolve($parameters); - - return $this->put($this->getProjectPath($project_id, 'repository/files/'.$this->encodePath($resolved['file_path'])), $resolved); - } - - /** - * @param int $project_id - * @param array $parameters ( - * - * @var string $file_path Url encoded full path to new file. Ex. lib%2Fclass%2Erb. - * @var string $branch Name of the branch. - * @var string $start_branch Name of the branch to start the new commit from. - * @var string $author_email Specify the commit author's email address. - * @var string $author_name Specify the commit author's name. - * @var string $commit_message Commit message. - * ) - * - * @return mixed - */ - public function deleteFile($project_id, array $parameters = []) - { - $resolver = new OptionsResolver(); - $resolver->setRequired('file_path'); - $resolver->setRequired('branch'); - $resolver->setDefined('start_branch'); - $resolver->setDefined('author_email'); - $resolver->setDefined('author_name'); - $resolver->setRequired('commit_message'); - - $resolved = $resolver->resolve($parameters); - - return $this->delete($this->getProjectPath($project_id, 'repository/files/'.$this->encodePath($resolved['file_path'])), $resolved); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Snippets.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Snippets.php deleted file mode 100755 index e17c0cba754aaafb8cbd437eb4fe7d16b0f33f85..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Snippets.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php namespace Gitlab\Api; - -class Snippets extends AbstractApi -{ - /** - * @param int $project_id - * @return mixed - */ - public function all($project_id) - { - return $this->get($this->getProjectPath($project_id, 'snippets')); - } - - /** - * @param int $project_id - * @param int $snippet_id - * @return mixed - */ - public function show($project_id, $snippet_id) - { - return $this->get($this->getProjectPath($project_id, 'snippets/'.$this->encodePath($snippet_id))); - } - - /** - * @param int $project_id - * @param string $title - * @param string $filename - * @param string $code - * @return mixed - */ - public function create($project_id, $title, $filename, $code) - { - return $this->post($this->getProjectPath($project_id, 'snippets'), array( - 'title' => $title, - 'file_name' => $filename, - 'code' => $code - )); - } - - /** - * @param int $project_id - * @param int $snippet_id - * @param array $params - * @return mixed - */ - public function update($project_id, $snippet_id, array $params) - { - return $this->put($this->getProjectPath($project_id, 'snippets/'.$this->encodePath($snippet_id)), $params); - } - - /** - * @param int $project_id - * @param int $snippet_id - * @return string - */ - public function content($project_id, $snippet_id) - { - return $this->get($this->getProjectPath($project_id, 'snippets/'.$this->encodePath($snippet_id).'/raw')); - } - - /** - * @param int $project_id - * @param int $snippet_id - * @return mixed - */ - public function remove($project_id, $snippet_id) - { - return $this->delete($this->getProjectPath($project_id, 'snippets/'.$this->encodePath($snippet_id))); - } - - /** - * @param int $project_id - * @param int $snippet_id - * - * @return mixed - */ - public function awardEmoji($project_id, $snippet_id) - { - return $this->get($this->getProjectPath($project_id, 'snippets/'.$this->encodePath($snippet_id).'/award_emoji')); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/SystemHooks.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/SystemHooks.php deleted file mode 100755 index b21fd0908ffc06c29befeff674a3432fcfd7b888..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/SystemHooks.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php namespace Gitlab\Api; - -class SystemHooks extends AbstractApi -{ - /** - * @return mixed - */ - public function all() - { - return $this->get('hooks'); - } - - /** - * @param string $url - * @return mixed - */ - public function create($url) - { - return $this->post('hooks', array( - 'url' => $url - )); - } - - /** - * @param int $id - * @return mixed - */ - public function test($id) - { - return $this->get('hooks/'.$this->encodePath($id)); - } - - /** - * @param int $id - * @return mixed - */ - public function remove($id) - { - return $this->delete('hooks/'.$this->encodePath($id)); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Tags.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Tags.php deleted file mode 100755 index 16aa64a67a0d2796d82f73d24042479994287126..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Tags.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php namespace Gitlab\Api; - -class Tags extends AbstractApi -{ - /** - * @param int $project_id - * @return mixed - */ - public function all($project_id) - { - return $this->get($this->getProjectPath($project_id, 'repository/tags')); - } - - /** - * @param int $project_id - * @param string $tag_name - * @return mixed - */ - public function show($project_id, $tag_name) - { - return $this->get($this->getProjectPath($project_id, 'repository/tags/'.$tag_name)); - } - - /** - * @param int $project_id - * @param array $params - * @return mixed - */ - public function create($project_id, array $params = array()) - { - return $this->post($this->getProjectPath($project_id, "repository/tags"), $params); - } - - /** - * @param int $project_id - * @param string $tag_name - * @return mixed - */ - public function remove($project_id, $tag_name) - { - return $this->delete($this->getProjectPath($project_id, 'repository/tags/'.$tag_name)); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Users.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Users.php deleted file mode 100755 index b23430078e58a447f01a17dea4e660058996a7ea..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Api/Users.php +++ /dev/null @@ -1,254 +0,0 @@ -<?php namespace Gitlab\Api; - -class Users extends AbstractApi -{ - /** - * @param array $parameters ( - * - * @var string $search Search for user by email or username. - * @var string $username Lookup for user by username. - * @var bool $external Search for external users only. - * @var string $extern_uid Lookup for users by external uid. - * @var string $provider Lookup for users by provider. - * @var \DateTimeInterface $created_before Return users created before the given time (inclusive). - * @var \DateTimeInterface $created_after Return users created after the given time (inclusive). - * @var bool $active Return only active users. It does not support filtering inactive users. - * @var bool $blocked Return only blocked users. It does not support filtering non-blocked users. - * ) - * - * @return mixed - */ - public function all(array $parameters = []) - { - $resolver = $this->createOptionsResolver(); - $datetimeNormalizer = function (\DateTimeInterface $value) { - return $value->format('c'); - }; - - $resolver->setDefined('search'); - $resolver->setDefined('username'); - $resolver->setDefined('external') - ->setAllowedTypes('external', 'bool') - ; - $resolver->setDefined('extern_uid'); - $resolver->setDefined('provider'); - $resolver->setDefined('created_before') - ->setAllowedTypes('created_before', \DateTimeInterface::class) - ->setNormalizer('created_before', $datetimeNormalizer) - ; - $resolver->setDefined('created_after') - ->setAllowedTypes('created_after', \DateTimeInterface::class) - ->setNormalizer('created_after', $datetimeNormalizer) - ; - $resolver->setDefined('active') - ->setAllowedTypes('active', 'bool') - ->setAllowedValues('active', true) - ; - $resolver->setDefined('blocked') - ->setAllowedTypes('blocked', 'bool') - ->setAllowedValues('blocked', true) - ; - - - return $this->get('users', $resolver->resolve($parameters)); - } - - /** - * @param int $id - * @return mixed - */ - public function show($id) - { - return $this->get('users/'.$this->encodePath($id)); - } - - /** - * @return mixed - */ - public function user() - { - return $this->get('user'); - } - - /** - * @param string $email - * @param string $password - * @param array $params - * @return mixed - */ - public function create($email, $password, array $params = array()) - { - $params['email'] = $email; - $params['password'] = $password; - - return $this->post('users', $params); - } - - /** - * @param int $id - * @param array $params - * @return mixed - */ - public function update($id, array $params) - { - return $this->put('users/'.$this->encodePath($id), $params); - } - - /** - * @param int $id - * @return mixed - */ - public function remove($id) - { - return $this->delete('users/'.$this->encodePath($id)); - } - - /** - * @param int $id - * @return mixed - */ - public function block($id) - { - return $this->post('users/'.$this->encodePath($id).'/block'); - } - - /** - * @param int $id - * @return mixed - */ - public function unblock($id) - { - return $this->post('users/'.$this->encodePath($id).'/unblock'); - } - - /** - * @param string $emailOrUsername - * @param string $password - * @return mixed - */ - public function session($emailOrUsername, $password) - { - return $this->post('session', array( - 'login' => $emailOrUsername, - 'email' => $emailOrUsername, - 'password' => $password - )); - } - - /** - * @param string $email - * @param string $password - * @return mixed - */ - public function login($email, $password) - { - return $this->session($email, $password); - } - - /** - * @return mixed - */ - public function me() - { - return $this->get('user'); - } - - /** - * @return mixed - */ - public function keys() - { - return $this->get('user/keys'); - } - - /** - * @param int $id - * @return mixed - */ - public function key($id) - { - return $this->get('user/keys/'.$this->encodePath($id)); - } - - /** - * @param string $title - * @param string $key - * @return mixed - */ - public function createKey($title, $key) - { - return $this->post('user/keys', array( - 'title' => $title, - 'key' => $key - )); - } - - /** - * @param int $id - * @return mixed - */ - public function removeKey($id) - { - return $this->delete('user/keys/'.$this->encodePath($id)); - } - - /** - * @param int $user_id - * @return mixed - */ - public function userKeys($user_id) - { - return $this->get('users/'.$this->encodePath($user_id).'/keys'); - } - - /* - * @param int $user_id - * @param int $key_id - * @return mixed - */ - public function userKey($user_id, $key_id) - { - return $this->get('users/'.$this->encodePath($user_id).'/keys/'.$this->encodePath($key_id)); - } - - /** - * @param int $user_id - * @param string $title - * @param string $key - * @return mixed - */ - public function createKeyForUser($user_id, $title, $key) - { - return $this->post('users/'.$this->encodePath($user_id).'/keys', array( - 'title' => $title, - 'key' => $key - )); - } - - /** - * @param int $user_id - * @param int $key_id - * @return mixed - */ - public function removeUserKey($user_id, $key_id) - { - return $this->delete('users/'.$this->encodePath($user_id).'/keys/'.$this->encodePath($key_id)); - } - - /** - * @return mixed - */ - public function emails() - { - return $this->get('user/emails'); - } - - /** - * @param $id - * @return mixed - */ - public function email($id) - { - return $this->get('user/emails/'.$this->encodePath($id)); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Client.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Client.php deleted file mode 100755 index 08679e0116bd2d58ec3ab415e340074d8faabbbb..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Client.php +++ /dev/null @@ -1,366 +0,0 @@ -<?php namespace Gitlab; - -use Gitlab\Api\AbstractApi; -use Gitlab\Exception\InvalidArgumentException; -use Gitlab\HttpClient\Builder; -use Gitlab\HttpClient\Plugin\ApiVersion; -use Gitlab\HttpClient\Plugin\History; -use Gitlab\HttpClient\Plugin\Authentication; -use Gitlab\HttpClient\Plugin\GitlabExceptionThrower; -use Http\Client\Common\HttpMethodsClient; -use Http\Client\Common\Plugin\AddHostPlugin; -use Http\Client\Common\Plugin\HeaderDefaultsPlugin; -use Http\Client\Common\Plugin\HistoryPlugin; -use Http\Client\HttpClient; -use Http\Discovery\UriFactoryDiscovery; - -/** - * Simple API wrapper for Gitlab - * - * @author Matt Humphrey <matt@m4tt.co> - * - * @property-read \Gitlab\Api\Groups $groups - * @property-read \Gitlab\Api\Issues $issues - * @property-read \Gitlab\Api\Jobs $jobs - * @property-read \Gitlab\Api\MergeRequests $merge_requests - * @property-read \Gitlab\Api\MergeRequests $mr - * @property-read \Gitlab\Api\Milestones $milestones - * @property-read \Gitlab\Api\Milestones $ms - * @property-read \Gitlab\Api\ProjectNamespaces $namespaces - * @property-read \Gitlab\Api\ProjectNamespaces $ns - * @property-read \Gitlab\Api\Projects $projects - * @property-read \Gitlab\Api\Repositories $repositories - * @property-read \Gitlab\Api\Repositories $repo - * @property-read \Gitlab\Api\Snippets $snippets - * @property-read \Gitlab\Api\SystemHooks $hooks - * @property-read \Gitlab\Api\SystemHooks $system_hooks - * @property-read \Gitlab\Api\Users $users - * @property-read \Gitlab\Api\Keys $keys - * @property-read \Gitlab\Api\Tags $tags - */ -class Client -{ - /** - * Constant for authentication method. Indicates the default, but deprecated - * login with username and token in URL. - */ - const AUTH_URL_TOKEN = 'url_token'; - - /** - * Constant for authentication method. Indicates the new login method with - * with username and token via HTTP Authentication. - */ - const AUTH_HTTP_TOKEN = 'http_token'; - - /** - * Constant for authentication method. Indicates the OAuth method with a key - * obtain using Gitlab's OAuth provider. - */ - const AUTH_OAUTH_TOKEN = 'oauth_token'; - - /** - * @var History - */ - private $responseHistory; - - /** - * @var Builder - */ - private $httpClientBuilder; - - /** - * Instantiate a new Gitlab client - * - * @param Builder $httpClientBuilder - */ - public function __construct(Builder $httpClientBuilder = null) - { - $this->responseHistory = new History(); - $this->httpClientBuilder = $httpClientBuilder ?: new Builder(); - - $this->httpClientBuilder->addPlugin(new GitlabExceptionThrower()); - $this->httpClientBuilder->addPlugin(new HistoryPlugin($this->responseHistory)); - $this->httpClientBuilder->addPlugin(new ApiVersion()); - $this->httpClientBuilder->addPlugin(new HeaderDefaultsPlugin([ - 'User-Agent' => 'php-gitlab-api (http://github.com/m4tthumphrey/php-gitlab-api)', - ])); - - $this->setUrl('https://gitlab.com'); - } - - /** - * Create a Gitlab\Client using an url. - * - * @param string $url - * - * @return Client - */ - public static function create($url) - { - $client = new self(); - $client->setUrl($url); - - return $client; - } - - /** - * Create a Gitlab\Client using an HttpClient. - * - * @param HttpClient $httpClient - * - * @return Client - */ - public static function createWithHttpClient(HttpClient $httpClient) - { - $builder = new Builder($httpClient); - - return new self($builder); - } - - /** - * @return Api\DeployKeys - */ - public function deployKeys() - { - return new Api\DeployKeys($this); - } - - /** - * @return Api\Groups - */ - public function groups() - { - return new Api\Groups($this); - } - - /** - * @return Api\Issues - */ - public function issues() - { - return new Api\Issues($this); - } - - /** - * @return Api\IssueBoards - */ - public function issueBoards() - { - return new Api\IssueBoards($this); - } - - /** - * @return Api\Jobs - */ - public function jobs() - { - return new Api\Jobs($this); - } - - /** - * @return Api\MergeRequests - */ - public function mergeRequests() - { - return new Api\MergeRequests($this); - } - - /** - * @return Api\Milestones - */ - public function milestones() - { - return new Api\Milestones($this); - } - - /** - * @return Api\ProjectNamespaces - */ - public function namespaces() - { - return new Api\ProjectNamespaces($this); - } - - /** - * @return Api\Projects - */ - public function projects() - { - return new Api\Projects($this); - } - - /** - * @return Api\Repositories - */ - public function repositories() - { - return new Api\Repositories($this); - } - - /** - * @return Api\RepositoryFiles - */ - public function repositoryFiles() - { - return new Api\RepositoryFiles($this); - } - - /** - * @return Api\Snippets - */ - public function snippets() - { - return new Api\Snippets($this); - } - - /** - * @return Api\SystemHooks - */ - public function systemHooks() - { - return new Api\SystemHooks($this); - } - - /** - * @return Api\Users - */ - public function users() - { - return new Api\Users($this); - } - - /** - * @return Api\Keys - */ - public function keys() - { - return new Api\Keys($this); - } - - /** - * @return Api\Tags - */ - public function tags() - { - return new Api\Tags($this); - } - - /** - * @param string $name - * - * @return AbstractApi|mixed - * @throws InvalidArgumentException - */ - public function api($name) - { - switch ($name) { - - case 'deploy_keys': - return $this->deployKeys(); - - case 'groups': - return $this->groups(); - - case 'issues': - return $this->issues(); - - case 'board': - case 'issue_boards': - return $this->issueBoards(); - case 'jobs': - return $this->jobs(); - - case 'mr': - case 'merge_requests': - return $this->mergeRequests(); - - case 'milestones': - case 'ms': - return $this->milestones(); - - case 'namespaces': - case 'ns': - return $this->namespaces(); - - case 'projects': - return $this->projects(); - - case 'repo': - case 'repositories': - return $this->repositories(); - - case 'snippets': - return $this->snippets(); - - case 'hooks': - case 'system_hooks': - return $this->systemHooks(); - - case 'users': - return $this->users(); - - case 'keys': - return $this->keys(); - - case 'tags': - return $this->tags(); - - default: - throw new InvalidArgumentException('Invalid endpoint: "'.$name.'"'); - } - } - - /** - * Authenticate a user for all next requests - * - * @param string $token Gitlab private token - * @param string $authMethod One of the AUTH_* class constants - * @param string $sudo - * @return $this - */ - public function authenticate($token, $authMethod = self::AUTH_URL_TOKEN, $sudo = null) - { - $this->httpClientBuilder->removePlugin(Authentication::class); - $this->httpClientBuilder->addPlugin(new Authentication($authMethod, $token, $sudo)); - - return $this; - } - - /** - * @param string $url - * - * @return $this - */ - public function setUrl($url) - { - $this->httpClientBuilder->removePlugin(AddHostPlugin::class); - $this->httpClientBuilder->addPlugin(new AddHostPlugin(UriFactoryDiscovery::find()->createUri($url))); - - return $this; - } - - /** - * @param string $api - * @return AbstractApi - */ - public function __get($api) - { - return $this->api($api); - } - - /** - * @return HttpMethodsClient - */ - public function getHttpClient() - { - return $this->httpClientBuilder->getHttpClient(); - } - - /** - * @return History - */ - public function getResponseHistory() - { - return $this->responseHistory; - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Exception/ErrorException.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Exception/ErrorException.php deleted file mode 100755 index 49e1a1769bef3c53ed6832df3b635fd2aeac3c6c..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Exception/ErrorException.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php namespace Gitlab\Exception; - -/** - * ErrorException - * - * @author Joseph Bielawski <stloyd@gmail.com> - */ -class ErrorException extends \ErrorException -{ -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Exception/InvalidArgumentException.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Exception/InvalidArgumentException.php deleted file mode 100755 index 86f9d60e1d7ad03d2f35f5040ae75230e4a25f60..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Exception/InvalidArgumentException.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php namespace Gitlab\Exception; - -/** - * InvalidArgumentException - * - * @author Joseph Bielawski <stloyd@gmail.com> - */ -class InvalidArgumentException extends \InvalidArgumentException -{ -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Exception/MissingArgumentException.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Exception/MissingArgumentException.php deleted file mode 100755 index f157b49d1e5a263071e637a0f376d417476757dc..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Exception/MissingArgumentException.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php namespace Gitlab\Exception; - -/** - * MissingArgumentException - * - * @author Joseph Bielawski <stloyd@gmail.com> - */ -class MissingArgumentException extends ErrorException -{ - public function __construct($required, $code = 0, $previous = null) - { - if (is_string($required)) { - $required = array($required); - } - - parent::__construct(sprintf('One or more of required ("%s") parameters is missing!', implode('", "', $required)), $code, $previous); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Exception/RuntimeException.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Exception/RuntimeException.php deleted file mode 100755 index ace4bcca436541a4294907db062e85f660607cbd..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Exception/RuntimeException.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php namespace Gitlab\Exception; - -/** - * RuntimeException - * - * @author Joseph Bielawski <stloyd@gmail.com> - */ -class RuntimeException extends \RuntimeException -{ -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Exception/ValidationFailedException.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Exception/ValidationFailedException.php deleted file mode 100755 index c6ed9b0b4186fec62b3d3f3a4780b2260ced9481..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Exception/ValidationFailedException.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php namespace Gitlab\Exception; - -/** - * ValidationFailedException - * - * @author Joseph Bielawski <stloyd@gmail.com> - */ -class ValidationFailedException extends ErrorException -{ -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Builder.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Builder.php deleted file mode 100755 index 15be1ff12bb8e04fcd85fa65122440cf1bf430b5..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Builder.php +++ /dev/null @@ -1,117 +0,0 @@ -<?php - -namespace Gitlab\HttpClient; - -use Http\Client\Common\HttpMethodsClient; -use Http\Client\Common\Plugin; -use Http\Client\Common\PluginClient; -use Http\Client\HttpClient; -use Http\Discovery\HttpClientDiscovery; -use Http\Discovery\MessageFactoryDiscovery; -use Http\Discovery\StreamFactoryDiscovery; -use Http\Message\MessageFactory; -use Http\Message\RequestFactory; -use Http\Message\StreamFactory; - -/** - * A builder that builds the API client. - * This will allow you to fluently add and remove plugins. - * - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -class Builder -{ - /** - * The object that sends HTTP messages. - * - * @var HttpClient - */ - private $httpClient; - - /** - * A HTTP client with all our plugins. - * - * @var HttpMethodsClient - */ - private $pluginClient; - - /** - * @var MessageFactory - */ - private $requestFactory; - - /** - * @var StreamFactory - */ - private $streamFactory; - - /** - * True if we should create a new Plugin client at next request. - * - * @var bool - */ - private $httpClientModified = true; - - /** - * @var Plugin[] - */ - private $plugins = []; - - /** - * @param HttpClient $httpClient - * @param RequestFactory $requestFactory - * @param StreamFactory $streamFactory - */ - public function __construct( - HttpClient $httpClient = null, - RequestFactory $requestFactory = null, - StreamFactory $streamFactory = null - ) { - $this->httpClient = $httpClient ?: HttpClientDiscovery::find(); - $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find(); - $this->streamFactory = $streamFactory ?: StreamFactoryDiscovery::find(); - } - - /** - * @return HttpMethodsClient - */ - public function getHttpClient() - { - if ($this->httpClientModified) { - $this->httpClientModified = false; - - $this->pluginClient = new HttpMethodsClient( - new PluginClient($this->httpClient, $this->plugins), - $this->requestFactory - ); - } - - return $this->pluginClient; - } - - /** - * Add a new plugin to the end of the plugin chain. - * - * @param Plugin $plugin - */ - public function addPlugin(Plugin $plugin) - { - $this->plugins[] = $plugin; - $this->httpClientModified = true; - } - - /** - * Remove a plugin by its fully qualified class name (FQCN). - * - * @param string $fqcn - */ - public function removePlugin($fqcn) - { - foreach ($this->plugins as $idx => $plugin) { - if ($plugin instanceof $fqcn) { - unset($this->plugins[$idx]); - $this->httpClientModified = true; - } - } - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Message/QueryStringBuilder.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Message/QueryStringBuilder.php deleted file mode 100755 index 03e16a32610668223fe1d467c637fb74d65845cb..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Message/QueryStringBuilder.php +++ /dev/null @@ -1,76 +0,0 @@ -<?php - -namespace Gitlab\HttpClient\Message; - -final class QueryStringBuilder -{ - /** - * Encode a query as a query string according to RFC 3986. Indexed arrays are encoded using - * empty squared brackets ([]) unlike http_build_query. - * - * @param mixed $query - * - * @return string - */ - public static function build($query) - { - if (!is_array($query)) { - return static::rawurlencode($query); - } - return implode('&', array_map(function ($value, $key) { - return static::encode($value, $key); - }, $query, array_keys($query))); - } - - /** - * Encode a value - * @param mixed $query - * @param string $prefix - * - * @return string - */ - private static function encode($query, $prefix) - { - if (!is_array($query)) { - return static::rawurlencode($prefix).'='.static::rawurlencode($query); - } - - $isIndexedArray = static::isIndexedArray($query); - return implode('&', array_map(function ($value, $key) use ($prefix, $isIndexedArray) { - $prefix = $isIndexedArray ? $prefix.'[]' : $prefix.'['.$key.']'; - return static::encode($value, $prefix); - }, $query, array_keys($query))); - } - - /** - * Tell if the given array is an indexed one (i.e. contains only sequential integer keys starting from 0). - * - * @param array $query - * - * @return bool - */ - public static function isIndexedArray(array $query) - { - if (empty($query) || !isset($query[0])) { - return false; - } - - return array_keys($query) === range(0, count($query) - 1); - } - - /** - * Encode a value like rawurlencode, but return "0" when false is given. - * - * @param mixed $value - * - * @return string - */ - private static function rawurlencode($value) - { - if ($value === false) { - return '0'; - } - - return rawurlencode($value); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Message/ResponseMediator.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Message/ResponseMediator.php deleted file mode 100755 index 16bd781f07f7179bc93d508e262724da8cddc4a6..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Message/ResponseMediator.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php - -namespace Gitlab\HttpClient\Message; - -use Psr\Http\Message\ResponseInterface; - -/** - * Utilities to parse response headers and content. - */ -class ResponseMediator -{ - /** - * Return the response body as a string or json array if content type is application/json. - *. - * @param ResponseInterface $response - * - * @return array|string - */ - public static function getContent(ResponseInterface $response) - { - $body = $response->getBody()->__toString(); - if (strpos($response->getHeaderLine('Content-Type'), 'application/json') === 0) { - $content = json_decode($body, true); - if (JSON_ERROR_NONE === json_last_error()) { - return $content; - } - } - - return $body; - } - - /** - * Extract pagination URIs from Link header. - * - * @param ResponseInterface $response - * - * @return array|null - */ - public static function getPagination(ResponseInterface $response) - { - if (!$response->hasHeader('Link')) { - return null; - } - - $header = self::getHeader($response, 'Link'); - $pagination = array(); - foreach (explode(',', $header) as $link) { - preg_match('/<(.*)>; rel="(.*)"/i', trim($link, ','), $match); - - if (3 === count($match)) { - $pagination[$match[2]] = $match[1]; - } - } - - return $pagination; - } - - - /** - * Get the value for a single header. - * - * @param ResponseInterface $response - * @param string $name - * - * @return string|null - */ - private static function getHeader(ResponseInterface $response, $name) - { - $headers = $response->getHeader($name); - - return array_shift($headers); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Plugin/ApiVersion.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Plugin/ApiVersion.php deleted file mode 100755 index 46b20e402284357dd3ee81eee9f76b1dfd854d6d..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Plugin/ApiVersion.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - - -namespace Gitlab\HttpClient\Plugin; - -use Http\Client\Common\Plugin; -use Psr\Http\Message\RequestInterface; - -/** - * Prefix requests path with /api/v4/ if required. - * - * @author Fabien Bourigault <bourigaultfabien@gmail.com> - */ -class ApiVersion implements Plugin -{ - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - $uri = $request->getUri(); - - if (substr($uri->getPath(), 0, 8) !== '/api/v4/') { - $request = $request->withUri($uri->withPath('/api/v4/'.$uri->getPath())); - } - - return $next($request); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Plugin/Authentication.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Plugin/Authentication.php deleted file mode 100755 index aac0acc4a2e0c5a3a3cb585398bafa8dc68f6c66..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Plugin/Authentication.php +++ /dev/null @@ -1,86 +0,0 @@ -<?php - -namespace Gitlab\HttpClient\Plugin; - -use Gitlab\Client; -use Http\Client\Common\Plugin; -use Psr\Http\Message\RequestInterface; - -/** - * Add authentication to the request. - * - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - * @author Fabien Bourigault <bourigaultfabien@gmail.com> - */ -class Authentication implements Plugin -{ - /** - * @var string - */ - private $method; - - /** - * @var string - */ - private $token; - - /** - * @var string|null - */ - private $sudo; - - /** - * @param string $method - * @param string $token - * @param string|null $sudo - */ - public function __construct($method, $token, $sudo = null) - { - $this->method = $method; - $this->token = $token; - $this->sudo = $sudo; - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - switch ($this->method) { - case Client::AUTH_HTTP_TOKEN: - $request = $request->withHeader('PRIVATE-TOKEN', $this->token); - if (!is_null($this->sudo)) { - $request = $request->withHeader('SUDO', $this->sudo); - } - break; - - case Client::AUTH_URL_TOKEN: - $uri = $request->getUri(); - $query = $uri->getQuery(); - - $parameters = [ - 'private_token' => $this->token, - ]; - - if (!is_null($this->sudo)) { - $parameters['sudo'] = $this->sudo; - } - - $query .= empty($query) ? '' : '&'; - $query .= utf8_encode(http_build_query($parameters, '', '&')); - - $uri = $uri->withQuery($query); - $request = $request->withUri($uri); - break; - - case Client::AUTH_OAUTH_TOKEN: - $request = $request->withHeader('Authorization', 'Bearer '.$this->token); - if (!is_null($this->sudo)) { - $request = $request->withHeader('SUDO', $this->sudo); - } - break; - } - - return $next($request); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Plugin/GitlabExceptionThrower.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Plugin/GitlabExceptionThrower.php deleted file mode 100755 index bb61e31219f9650a90e8e52980c1e94d666c1bf3..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Plugin/GitlabExceptionThrower.php +++ /dev/null @@ -1,86 +0,0 @@ -<?php - -namespace Gitlab\HttpClient\Plugin; - -use Gitlab\Exception\ErrorException; -use Gitlab\Exception\RuntimeException; -use Gitlab\HttpClient\Message\ResponseMediator; -use Http\Client\Common\Plugin; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * A plugin to remember the last response. - * - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - * @author Fabien Bourigault <bourigaultfabien@gmail.com> - */ -class GitlabExceptionThrower implements Plugin -{ - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - return $next($request)->then(function (ResponseInterface $response) { - if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 600) { - $content = ResponseMediator::getContent($response); - if (is_array($content) && isset($content['message'])) { - if (400 == $response->getStatusCode()) { - $message = $this->parseMessage($content['message']); - - throw new ErrorException($message, 400); - } - } - - $errorMessage = null; - if (isset($content['error'])) { - $errorMessage = $content['error']; - if (is_array($content['error'])) { - $errorMessage = implode("\n", $content['error']); - } - } elseif (isset($content['message'])) { - $errorMessage = $this->parseMessage($content['message']); - } else { - $errorMessage = $content; - } - - throw new RuntimeException($errorMessage, $response->getStatusCode()); - } - - return $response; - }); - } - - /** - * @param mixed $message - * - * @return string - */ - private function parseMessage($message) - { - $string = $message; - - if (is_array($message)) { - $format = '"%s" %s'; - $errors = array(); - - foreach ($message as $field => $messages) { - if (is_array($messages)) { - $messages = array_unique($messages); - foreach ($messages as $error) { - $errors[] = sprintf($format, $field, $error); - } - } elseif (is_integer($field)) { - $errors[] = $messages; - } else { - $errors[] = sprintf($format, $field, $messages); - } - } - - $string = implode(', ', $errors); - } - - return $string; - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Plugin/History.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Plugin/History.php deleted file mode 100755 index 8412356fdae09fea78832a5593bba3f3c187ddf9..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/HttpClient/Plugin/History.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php - -namespace Gitlab\HttpClient\Plugin; - -use Http\Client\Common\Plugin\Journal; -use Http\Client\Exception; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * A plugin to remember the last response. - * - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -class History implements Journal -{ - /** - * @var ResponseInterface - */ - private $lastResponse; - - /** - * @return ResponseInterface|null - */ - public function getLastResponse() - { - return $this->lastResponse; - } - - /** - * {@inheritdoc} - */ - public function addSuccess(RequestInterface $request, ResponseInterface $response) - { - $this->lastResponse = $response; - } - - /** - * {@inheritdoc} - */ - public function addFailure(RequestInterface $request, Exception $exception) - { - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/AbstractModel.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/AbstractModel.php deleted file mode 100755 index 7c11d4b21eb6c62f03ac12525ac7a1ee1b8179b6..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/AbstractModel.php +++ /dev/null @@ -1,129 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; -use Gitlab\Exception\RuntimeException; -use Gitlab\Api\AbstractApi; - -abstract class AbstractModel -{ - /** - * @var array - */ - protected static $properties; - - /** - * @var array - */ - protected $data = array(); - - /** - * @var Client - */ - protected $client; - - /** - * @return Client - */ - public function getClient() - { - return $this->client; - } - - /** - * @param Client $client - * @return $this - */ - public function setClient(Client $client = null) - { - if (null !== $client) { - $this->client = $client; - } - - return $this; - } - - /** - * @param string $api - * @return AbstractApi|mixed - */ - public function api($api) - { - return $this->getClient()->api($api); - } - - /** - * @param array $data - * @return $this - */ - protected function hydrate(array $data = array()) - { - if (!empty($data)) { - foreach ($data as $field => $value) { - $this->setData($field, $value); - } - } - - return $this; - } - - /** - * @param string $field - * @param mixed $value - * @return $this - */ - protected function setData($field, $value) - { - if (in_array($field, static::$properties)) { - $this->data[$field] = $value; - } - - return $this; - } - - /** - * @return array - */ - public function getData() - { - return $this->data; - } - - /** - * @param string $property - * @param mixed $value - * @throws RuntimeException - */ - public function __set($property, $value) - { - throw new RuntimeException('Model properties are immutable'); - } - - /** - * @param string $property - * @return mixed - */ - public function __get($property) - { - if (!in_array($property, static::$properties)) { - throw new RuntimeException(sprintf( - 'Property "%s" does not exist for %s object', - $property, get_called_class() - )); - } - - if (isset($this->data[$property])) { - return $this->data[$property]; - } - - return null; - } - - /** - * @param string $property - * @return bool - */ - public function __isset($property) - { - return isset($this->data[$property]); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Branch.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Branch.php deleted file mode 100755 index 8c7ef36b415c8bd39fd42f397e8b0e545e3d545e..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Branch.php +++ /dev/null @@ -1,146 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Api\Projects; -use Gitlab\Client; - -/** - * Class Branch - * - * @property-read string $name - * @property-read bool $protected - * @property-read Commit $commit - * @property-read Project $project - */ -class Branch extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'name', - 'commit', - 'project', - 'protected' - ); - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return Branch - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $branch = new static($project, $data['name'], $client); - - if (isset($data['commit'])) { - $data['commit'] = Commit::fromArray($client, $project, $data['commit']); - } - - return $branch->hydrate($data); - } - - /** - * @param Project $project - * @param string $name - * @param Client $client - */ - public function __construct(Project $project, $name = null, Client $client = null) - { - $this->setClient($client); - $this->setData('project', $project); - $this->setData('name', $name); - } - - /** - * @return Branch - */ - public function show() - { - $data = $this->client->repositories()->branch($this->project->id, $this->name); - - return static::fromArray($this->getClient(), $this->project, $data); - } - - /** - * @param bool $devPush - * @param bool $devMerge - * @return Branch - */ - public function protect($devPush = false, $devMerge = false) - { - $data = $this->client->repositories()->protectBranch($this->project->id, $this->name, $devPush, $devMerge); - - return static::fromArray($this->getClient(), $this->project, $data); - } - - /** - * @return Branch - */ - public function unprotect() - { - $data = $this->client->repositories()->unprotectBranch($this->project->id, $this->name); - - return static::fromArray($this->getClient(), $this->project, $data); - } - - /** - * @return bool - */ - public function delete() - { - $this->client->repositories()->deleteBranch($this->project->id, $this->name); - - return true; - } - - /** - * @param array $parameters - * - * @see Projects::commits for available parameters. - * - * @return Commit[] - */ - public function commits(array $parameters = []) - { - return $this->project->commits($parameters); - } - - /** - * @param string $file_path - * @param string $content - * @param string $commit_message - * @return File - */ - public function createFile($file_path, $content, $commit_message) - { - $data = $this->client->repositories()->createFile($this->project->id, $file_path, $content, $this->name, $commit_message); - - return File::fromArray($this->getClient(), $this->project, $data); - } - - /** - * @param string $file_path - * @param string $content - * @param string $commit_message - * @return File - */ - public function updateFile($file_path, $content, $commit_message) - { - $data = $this->client->repositories()->updateFile($this->project->id, $file_path, $content, $this->name, $commit_message); - - return File::fromArray($this->getClient(), $this->project, $data); - } - - /** - * @param string $file_path - * @param string $commit_message - * @return bool - */ - public function deleteFile($file_path, $commit_message) - { - $this->client->repositories()->deleteFile($this->project->id, $file_path, $this->name, $commit_message); - - return true; - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Commit.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Commit.php deleted file mode 100755 index 9b007325515feff26f7a49e1269403fd331180e2..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Commit.php +++ /dev/null @@ -1,86 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Commit - * - * @property-read string $id - * @property-read string $short_id - * @property-read string $title - * @property-read string $message - * @property-read string $author_name - * @property-read string $author_email - * @property-read string $authored_date - * @property-read string $committed_date - * @property-read string $created_at - * @property-read Commit[] $parents - * @property-read Node[] $tree - * @property-read User $committer - * @property-read User $author - * @property-read Project $project - */ -class Commit extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'id', - 'short_id', - 'parents', - 'tree', - 'title', - 'message', - 'author', - 'author_name', - 'author_email', - 'committer', - 'authored_date', - 'committed_date', - 'created_at', - 'project' - ); - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return Commit - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $commit = new static($project, $data['id'], $client); - - if (isset($data['parents'])) { - $parents = array(); - foreach ($data['parents'] as $parent) { - $parents[] = static::fromArray($client, $project, $parent); - } - - $data['parents'] = $parents; - } - - if (isset($data['author'])) { - $data['author'] = User::fromArray($client, $data['author']); - } - - if (isset($data['committer'])) { - $data['committer'] = User::fromArray($client, $data['committer']); - } - - return $commit->hydrate($data); - } - - /** - * @param Project $project - * @param int $id - * @param Client $client - */ - public function __construct(Project $project, $id = null, Client $client = null) - { - $this->setClient($client); - $this->setData('project', $project); - $this->setData('id', $id); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/CommitNote.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/CommitNote.php deleted file mode 100755 index 4b455c7f160979748b8cd1744bfcedbc14b2abfd..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/CommitNote.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class CommitNote - * - * @property-read string $note - * @property-read string $path - * @property-read string $line - * @property-read string $line_type - * @property-read User $author - */ -class CommitNote extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'note', - 'path', - 'line', - 'line_type', - 'author' - ); - - /** - * @param Client $client - * @param array $data - * @return CommitNote - */ - public static function fromArray(Client $client, array $data) - { - $comment = new static($client); - - if (isset($data['author'])) { - $data['author'] = User::fromArray($client, $data['author']); - } - - return $comment->hydrate($data); - } - - /** - * @param Client $client - */ - public function __construct(Client $client = null) - { - $this->setClient($client); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Comparison.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Comparison.php deleted file mode 100755 index 27901829d5b6b1673677f911f9b33816ead635f9..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Comparison.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Comparison - * - * @property-read bool $compare_timeout - * @property-read bool $compare_same_ref - * @property-read Commit $commit - * @property-read Commit[] $commits - * @property-read Diff[] $diffs - * @property-read Project $project - */ -class Comparison extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'commit', - 'commits', - 'diffs', - 'compare_timeout', - 'compare_same_ref', - 'project' - ); - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return Comparison - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $file = new static($project, $client); - - if (isset($data['commit'])) { - $data['commit'] = Commit::fromArray($client, $project, $data['commit']); - } - - if (isset($data['commits'])) { - $commits = array(); - foreach ($data['commits'] as $commit) { - $commits[] = Commit::fromArray($client, $project, $commit); - } - - $data['commits'] = $commits; - } - - if (isset($data['diffs'])) { - $diffs = array(); - foreach ($data['diffs'] as $diff) { - $diffs[] = Diff::fromArray($client, $project, $diff); - } - - $data['diffs'] = $diffs; - } - - return $file->hydrate($data); - } - - /** - * @param Project $project - * @param Client $client - */ - public function __construct(Project $project, Client $client = null) - { - $this->setClient($client); - $this->setData('project', $project); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Contributor.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Contributor.php deleted file mode 100755 index 658da48bcfc634bb58db54ac959a168d9f0e4119..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Contributor.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Contributor - * - * @property-read string $name - * @property-read string $email - * @property-read int $commits - * @property-read int $additions - * @property-read int $deletions - * @property-read Project $project - */ -class Contributor extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'name', - 'email', - 'commits', - 'additions', - 'deletions', - 'project' - ); - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return Contributor - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $contributor = new static($project, $client); - - return $contributor->hydrate($data); - } - - /** - * @param Project $project - * @param Client $client - */ - public function __construct(Project $project, Client $client = null) - { - $this->setClient($client); - $this->setData('project', $project); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Diff.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Diff.php deleted file mode 100755 index 5fd95d5ac62a250a04fd07aed5c85624009d75cb..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Diff.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Diff - * - * @property-read string $old_path - * @property-read string $new_path - * @property-read string $a_mode - * @property-read string $b_mode - * @property-read string $diff - * @property-read bool $new_file - * @property-read bool $renamed_file - * @property-read bool $deleted_file - * @property-read Project $project - */ -class Diff extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'old_path', - 'new_path', - 'a_mode', - 'b_mode', - 'diff', - 'new_file', - 'renamed_file', - 'deleted_file', - 'project' - ); - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return Diff - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $diff = new static($project, $client); - - return $diff->hydrate($data); - } - - /** - * @param Project $project - * @param Client $client - */ - public function __construct(Project $project, Client $client = null) - { - $this->setClient($client); - $this->setData('project', $project); - } - - /** - * @return string - */ - public function __toString() - { - return $this->diff; - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Event.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Event.php deleted file mode 100755 index 83565e174da9bebd2b611b814ea43c58910a790a..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Event.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Event - * - * @property-read string $title - * @property-read int $id - * @property-read string $action_name - * @property-read string $data - * @property-read int $target_id - * @property-read string $target_type - * @property-read string $target_title - * @property-read int $author_id - * @property-read string $author_username - * @property-read User $author - * @property-read Project $project - */ -class Event extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'title', - 'project_id', - 'action_name', - 'target_id', - 'target_type', - 'author_id', - 'author_username', - 'data', - 'target_title', - 'author', - 'project' - ); - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return Event - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $event = new static($project, $client); - - if (isset($data['author_id'])) { - $data['author'] = new User($data['author_id'], $client); - } - - return $event->hydrate($data); - } - - /** - * @param Project $project - * @param Client $client - */ - public function __construct(Project $project, Client $client = null) - { - $this->setClient($client); - $this->setData('project', $project); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/File.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/File.php deleted file mode 100755 index b2edac1273e5e11c2b53c3b8283307905829a0a2..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/File.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class File - * - * @property-read string $file_path - * @property-read string $branch_name - * @property-read Project $project - */ -class File extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'project', - 'file_path', - 'branch_name' - ); - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return File - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $file = new static($project, $data['file_path'], $client); - - return $file->hydrate($data); - } - - /** - * @param Project $project - * @param string $file_path - * @param Client $client - */ - public function __construct(Project $project, $file_path = null, Client $client = null) - { - $this->setClient($client); - $this->setData('project', $project); - $this->setData('file_path', $file_path); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Group.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Group.php deleted file mode 100755 index 48923f18240edd64503cb22c99068c15ee919842..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Group.php +++ /dev/null @@ -1,138 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Group - * - * @property-read int $id - * @property-read string $name - * @property-read string $path - * @property-read string $description - * @property-read Project[] $projects - */ -class Group extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'id', - 'name', - 'path', - 'description', - 'projects' - ); - - /** - * @param Client $client - * @param array $data - * @return Group - */ - public static function fromArray(Client $client, array $data) - { - $group = new static($data['id'], $client); - - if (isset($data['projects'])) { - $projects = array(); - foreach ($data['projects'] as $project) { - $projects[] = Project::fromArray($client, $project); - } - $data['projects'] = $projects; - } - - return $group->hydrate($data); - } - - /** - * @param Client $client - * @param string $name - * @param string $path - * @return Group - */ - public static function create(Client $client, $name, $path) - { - $data = $client->groups()->create($name, $path); - - return static::fromArray($client, $data); - } - - /** - * @param int $id - * @param Client $client - */ - public function __construct($id, Client $client = null) - { - $this->setClient($client); - $this->setData('id', $id); - } - - /** - * @return Group - */ - public function show() - { - $data = $this->client->groups()->show($this->id); - - return Group::fromArray($this->getClient(), $data); - } - - /** - * @param int $project_id - * @return Group - */ - public function transfer($project_id) - { - $data = $this->client->groups()->transfer($this->id, $project_id); - - return Group::fromArray($this->getClient(), $data); - } - - /** - * @return User[] - */ - public function members() - { - $data = $this->client->groups()->members($this->id); - - $members = array(); - foreach ($data as $member) { - $members[] = User::fromArray($this->getClient(), $member); - } - - return $members; - } - - /** - * @param int $user_id - * @param int $access_level - * @return User - */ - public function addMember($user_id, $access_level) - { - $data = $this->client->groups()->addMember($this->id, $user_id, $access_level); - - return User::fromArray($this->getClient(), $data); - } - - /** - * @param int $user_id - * @return bool - */ - public function removeMember($user_id) - { - $this->client->groups()->removeMember($this->id, $user_id); - - return true; - } - - /** - * @return Group - */ - public function projects() - { - $data = $this->client->groups()->projects($this->id); - - return Group::fromArray($this->getClient(), $data); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Hook.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Hook.php deleted file mode 100755 index d276982e2065d96ad108324f26064669ae168b5f..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Hook.php +++ /dev/null @@ -1,76 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Hook - * - * @property-read int $id - * @property-read string $url - * @property-read string $created_at - */ -class Hook extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'id', - 'url', - 'created_at' - ); - - /** - * @param Client $client - * @param array $data - * @return Hook - */ - public static function fromArray(Client $client, array $data) - { - $hook = new static($data['id'], $client); - - return $hook->hydrate($data); - } - - /** - * @param Client $client - * @param string $url - * @return Hook - */ - public static function create(Client $client, $url) - { - $data = $client->systemHooks()->create($url); - - return static::fromArray($client, $data); - } - - /** - * @param int $id - * @param Client $client - */ - public function __construct($id, Client $client = null) - { - $this->setClient($client); - $this->setData('id', $id); - } - - /** - * @return bool - */ - public function test() - { - $this->client->systemHooks()->test($this->id); - - return true; - } - - /** - * @return bool - */ - public function delete() - { - $this->client->systemHooks()->remove($this->id); - - return true; - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Issue.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Issue.php deleted file mode 100755 index 5b4724ddd5c0a3dfe1647b5e1fbac7a713ed2d74..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Issue.php +++ /dev/null @@ -1,171 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Issue - * - * @property-read int $id - * @property-read int $iid - * @property-read int $project_id, - * @property-read string $title - * @property-read string $description - * @property-read array $labels - * @property-read bool $closed - * @property-read string $updated_at - * @property-read string $created_at - * @property-read string $state - * @property-read User $assignee - * @property-read User $author - * @property-read Milestone $milestone - * @property-read Project $project - */ -class Issue extends AbstractModel implements Noteable -{ - /** - * @var array - */ - protected static $properties = array( - 'id', - 'iid', - 'project_id', - 'title', - 'description', - 'labels', - 'milestone', - 'assignee', - 'author', - 'closed', - 'updated_at', - 'created_at', - 'project', - 'state' - ); - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return Issue - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $issue = new static($project, $data['id'], $client); - - if (isset($data['author'])) { - $data['author'] = User::fromArray($client, $data['author']); - } - - if (isset($data['assignee'])) { - $data['assignee'] = User::fromArray($client, $data['assignee']); - } - - return $issue->hydrate($data); - } - - /** - * @param Project $project - * @param int $id - * @param Client $client - */ - public function __construct(Project $project, $id = null, Client $client = null) - { - $this->setClient($client); - $this->setData('project', $project); - $this->setData('id', $id); - } - - /** - * @return Issue - */ - public function show() - { - $data = $this->client->issues()->show($this->project->id, $this->iid); - - return static::fromArray($this->getClient(), $this->project, $data); - } - - /** - * @param array $params - * @return Issue - */ - public function update(array $params) - { - $data = $this->client->issues()->update($this->project->id, $this->iid, $params); - - return static::fromArray($this->getClient(), $this->project, $data); - } - - /** - * @param string $comment - * @return Issue - */ - public function close($comment = null) - { - if ($comment) { - $this->addComment($comment); - } - - return $this->update(array( - 'state_event' => 'close' - )); - } - - /** - * @return Issue - */ - public function open() - { - return $this->update(array( - 'state_event' => 'reopen' - )); - } - - /** - * @return Issue - */ - public function reopen() - { - return $this->open(); - } - - /** - * @param string $comment - * @return Note - */ - public function addComment($comment) - { - $data = $this->client->issues()->addComment($this->project->id, $this->iid, array( - 'body' => $comment - )); - - return Note::fromArray($this->getClient(), $this, $data); - } - - /** - * @return Note[] - */ - public function showComments() - { - $notes = array(); - $data = $this->client->issues()->showComments($this->project->id, $this->iid); - - foreach ($data as $note) { - $notes[] = Note::fromArray($this->getClient(), $this, $note); - } - - return $notes; - } - - /** - * @return bool - */ - public function isClosed() - { - if ($this->state == 'closed') { - return true; - } - - return false; - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Job.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Job.php deleted file mode 100755 index 586e3a31185baf94ec1ef05b5edc5bf087446084..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Job.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Commit - * - * @property-read Commit $commit - * @property-read int $id - * @property-read string $coverage - * @property-read string $created_at - * @property-read string $artifacts_file - * @property-read string $finished_at - * @property-read string $name - * @property-read Pipeline $pipeline - * @property-read string $ref - * @property-read string $runner - * @property-read string $stage - * @property-read string $started_at - * @property-read string $status - * @property-read string|bool $tag - * @property-read User $user - */ -class Job extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'id', - 'commit', - 'coverage', - 'created_at', - 'artifacts_file', - 'finished_at', - 'name', - 'pipeline', - 'ref', - 'runner', - 'stage', - 'started_at', - 'status', - 'tag', - 'user' - ); - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return Job - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $job = new static($project, $data['id'], $client); - - if (isset($data['user'])) { - $data['user'] = User::fromArray($client, $data['user']); - } - - if (isset($data['commit'])) { - $data['commit'] = Commit::fromArray($client, $project, $data['commit']); - } - - if (isset($data['pipeline'])) { - $data['pipeline'] = Pipeline::fromArray($client, $project, $data['pipeline']); - } - - return $job->hydrate($data); - } - - /** - * @param Project $project - * @param int $id - * @param Client $client - */ - public function __construct(Project $project, $id = null, Client $client = null) - { - $this->setClient($client); - $this->setData('project', $project); - $this->setData('id', $id); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Key.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Key.php deleted file mode 100755 index 5e6aebfa58ca38c68f91ff412874ff041d8a1015..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Key.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Key - * - * @property-read int $id - * @property-read string $title - * @property-read string $key - * @property-read string $created_at - */ -class Key extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'id', - 'title', - 'key', - 'created_at' - ); - - /** - * @param Client $client - * @param array $data - * @return Key - */ - public static function fromArray(Client $client, array $data) - { - $key = new static($client); - - return $key->hydrate($data); - } - - /** - * @param Client $client - */ - public function __construct(Client $client = null) - { - $this->setClient($client); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Label.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Label.php deleted file mode 100755 index 5c8a2091984e77c06616581f8e6ae69ed7b663fb..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Label.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Label - * - * @property-read string $name - * @property-read string $color - */ -class Label extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'name', - 'color' - ); - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return Label - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $label = new static($project, $client); - - return $label->hydrate($data); - } - - /** - * @param Project $project - * @param Client $client - */ - public function __construct(Project $project, Client $client = null) - { - $this->setClient($client); - $this->setData('project', $project); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/MergeRequest.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/MergeRequest.php deleted file mode 100755 index 03251f3b01dca2d412c1cb5b7fb0631196b14f92..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/MergeRequest.php +++ /dev/null @@ -1,227 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class MergeRequest - * - * @property-read int $id - * @property-read int $iid - * @property-read string $target_branch - * @property-read string $source_branch - * @property-read int $project_id - * @property-read string $title - * @property-read string $description - * @property-read bool $closed - * @property-read bool $merged - * @property-read string $state - * @property-read int $source_project_id - * @property-read int $target_project_id - * @property-read int $upvotes - * @property-read int $downvotes - * @property-read array $labels - * @property-read User $author - * @property-read User $assignee - * @property-read Project $project - * @property-read Milestone $milestone - * @property-read File[] $files - */ -class MergeRequest extends AbstractModel implements Noteable -{ - /** - * @var array - */ - protected static $properties = array( - 'id', - 'iid', - 'target_branch', - 'source_branch', - 'project_id', - 'title', - 'description', - 'closed', - 'merged', - 'author', - 'assignee', - 'project', - 'state', - 'source_project_id', - 'target_project_id', - 'upvotes', - 'downvotes', - 'labels', - 'milestone', - 'files' - ); - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return MergeRequest - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $mr = new static($project, $data['id'], $client); - - if (isset($data['author'])) { - $data['author'] = User::fromArray($client, $data['author']); - } - - if (isset($data['assignee'])) { - $data['assignee'] = User::fromArray($client, $data['assignee']); - } - - if (isset($data['milestone'])) { - $data['milestone'] = Milestone::fromArray($client, $project, $data['milestone']); - } - - if (isset($data['files'])) { - $files = array(); - foreach ($data['files'] as $file) { - $files[] = File::fromArray($client, $project, $file); - } - - $data['files'] = $files; - } - - return $mr->hydrate($data); - } - - /** - * @param Project $project - * @param int $iid - * @param Client $client - */ - public function __construct(Project $project, $iid = null, Client $client = null) - { - $this->setClient($client); - $this->setData('project', $project); - $this->setData('iid', $iid); - } - - /** - * @return MergeRequest - */ - public function show() - { - $data = $this->client->mergeRequests()->show($this->project->id, $this->iid); - - return static::fromArray($this->getClient(), $this->project, $data); - } - - /** - * @param array $params - * @return MergeRequest - */ - public function update(array $params) - { - $data = $this->client->mergeRequests()->update($this->project->id, $this->iid, $params); - - return static::fromArray($this->getClient(), $this->project, $data); - } - - /** - * @param string $comment - * @return MergeRequest - */ - public function close($comment = null) - { - if ($comment) { - $this->addComment($comment); - } - - return $this->update(array( - 'state_event' => 'close' - )); - } - - /** - * @return MergeRequest - */ - public function reopen() - { - return $this->update(array( - 'state_event' => 'reopen' - )); - } - - /** - * @return MergeRequest - */ - public function open() - { - return $this->reopen(); - } - - /** - * @param string $message - * @return MergeRequest - */ - public function merge($message = null) - { - $data = $this->client->mergeRequests()->merge($this->project->id, $this->iid, array( - 'merge_commit_message' => $message - )); - - return static::fromArray($this->getClient(), $this->project, $data); - } - - /** - * @return MergeRequest - */ - public function merged() - { - return $this->update(array( - 'state_event' => 'merge' - )); - } - - /** - * @param string $comment - * @return Note - */ - public function addComment($comment) - { - $data = $this->client->mergeRequests()->addComment($this->project->id, $this->iid, $comment); - - return Note::fromArray($this->getClient(), $this, $data); - } - - /** - * @return Note[] - */ - public function showComments() - { - $notes = array(); - $data = $this->client->mergeRequests()->showComments($this->project->id, $this->iid); - - foreach ($data as $note) { - $notes[] = Note::fromArray($this->getClient(), $this, $note); - } - - return $notes; - } - - /** - * @return bool - */ - public function isClosed() - { - if (in_array($this->state, array('closed', 'merged'))) { - return true; - } - - return false; - } - - /** - * @return MergeRequest - */ - public function changes() - { - $data = $this->client->mergeRequests()->changes($this->project->id, $this->iid); - - return static::fromArray($this->getClient(), $this->project, $data); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Milestone.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Milestone.php deleted file mode 100755 index 8b07d38af8a51dd330abb9738ac442bea872ee30..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Milestone.php +++ /dev/null @@ -1,117 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Milestone - * - * @property-read int $id - * @property-read int $iid - * @property-read int $project_id - * @property-read string $title - * @property-read string $description - * @property-read string $due_date - * @property-read string $start_date - * @property-read string $state - * @property-read bool $closed - * @property-read string $updated_at - * @property-read string $created_at - * @property-read Project $project - */ -class Milestone extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'id', - 'iid', - 'project', - 'project_id', - 'title', - 'description', - 'due_date', - 'start_date', - 'state', - 'closed', - 'updated_at', - 'created_at' - ); - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return Milestone - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $milestone = new static($project, $data['id'], $client); - - return $milestone->hydrate($data); - } - - /** - * @param Project $project - * @param int $id - * @param Client $client - */ - public function __construct(Project $project, $id, Client $client = null) - { - $this->setClient($client); - $this->setData('id', $id); - $this->setData('project', $project); - } - - /** - * @return Milestone - */ - public function show() - { - $data = $this->client->milestones()->show($this->project->id, $this->id); - - return static::fromArray($this->getClient(), $this->project, $data); - } - - /** - * @param array $params - * @return Milestone - */ - public function update(array $params) - { - $data = $this->client->milestones()->update($this->project->id, $this->id, $params); - - return static::fromArray($this->getClient(), $this->project, $data); - } - - /** - * @return Milestone - */ - public function complete() - { - return $this->update(array('closed' => true)); - } - - /** - * @return Milestone - */ - public function incomplete() - { - return $this->update(array('closed' => false)); - } - - /** - * @return Issue[] - */ - public function issues() - { - $data = $this->client->milestones()->issues($this->project->id, $this->id); - - $issues = array(); - foreach ($data as $issue) { - $issues[] = Issue::fromArray($this->getClient(), $this->project, $issue); - } - - return $issues; - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Node.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Node.php deleted file mode 100755 index bb94516877a53b915a12c4f8a135d1bc34d3fae7..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Node.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Node - * - * @property-read string $name - * @property-read string $type - * @property-read string $mode - * @property-read int $id - * @property-read Project $project - */ -class Node extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'name', - 'type', - 'mode', - 'id', - 'path', - 'project' - ); - - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return Node - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $node = new static($project, $data['id'], $client); - - return $node->hydrate($data); - } - - /** - * @param Project $project - * @param int $id - * @param Client $client - */ - public function __construct(Project $project, $id = null, Client $client) - { - $this->setClient($client); - $this->setData('project', $project); - $this->setData('id', $id); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Note.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Note.php deleted file mode 100755 index c7767792d2b816fab093605de7dec9636f3c770d..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Note.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Note - * - * @property-read User $author - * @property-read string $body - * @property-read string $created_at - * @property-read string $updated_at - * @property-read string $parent_type - * @property-read Issue|MergeRequest $parent - * @property-read string $attachment - * @property-read bool $system - */ -class Note extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'id', - 'author', - 'body', - 'created_at', - 'updated_at', - 'parent_type', - 'parent', - 'attachment', - 'system' - ); - - /** - * @param Client $client - * @param Noteable $type - * @param array $data - * @return mixed - */ - public static function fromArray(Client $client, Noteable $type, array $data) - { - $comment = new static($type, $client); - - if (isset($data['author'])) { - $data['author'] = User::fromArray($client, $data['author']); - } - - return $comment->hydrate($data); - } - - /** - * @param Noteable $type - * @param Client $client - */ - public function __construct(Noteable $type, Client $client = null) - { - $this->setClient($client); - $this->setData('parent_type', get_class($type)); - $this->setData('parent', $type); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Noteable.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Noteable.php deleted file mode 100755 index 11e2cb6506d4b83e9e6f98875e6de834447ba4d1..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Noteable.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php namespace Gitlab\Model; - -interface Noteable -{ - /** - * @param string $comment - * @return Note - */ - public function addComment($comment); - - /** - * @return Note[] - */ - public function showComments(); - - /** - * @param string $comment - * @return static - */ - public function close($comment = null); - - /** - * @return static - */ - public function open(); - - /** - * @return static - */ - public function reopen(); - - /** - * @return bool - */ - public function isClosed(); -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Pipeline.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Pipeline.php deleted file mode 100755 index efeccbc9879f78fe2a50df6b51ba0987c6c1ed22..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Pipeline.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Commit - * - * @property-read int $id - * @property-read string $ref - * @property-read string $sha - * @property-read string $status - */ -class Pipeline extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'id', - 'ref', - 'sha', - 'status' - ); - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return Pipeline - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $pipeline = new static($project, $data['id'], $client); - - return $pipeline->hydrate($data); - } - - /** - * @param Project $project - * @param int $id - * @param Client $client - */ - public function __construct(Project $project, $id = null, Client $client = null) - { - $this->setClient($client); - $this->setData('project', $project); - $this->setData('id', $id); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Project.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Project.php deleted file mode 100755 index 3b62a9f7c262899687735fc1ec1fdef2b3d90d89..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Project.php +++ /dev/null @@ -1,1186 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Api\Projects; -use Gitlab\Api\Repositories; -use Gitlab\Client; - -/** - * Class Project - * - * @property-read int $id - * @property-read string $code - * @property-read string $name - * @property-read string $name_with_namespace - * @property-read string $description - * @property-read string $path - * @property-read string $path_with_namespace - * @property-read string $ssh_url_to_repo - * @property-read string $http_url_to_repo - * @property-read string $web_url - * @property-read string $default_branch - * @property-read bool $private - * @property-read bool $public - * @property-read bool $issues_enabled - * @property-read bool $merge_requests_enabled - * @property-read bool $wall_enabled - * @property-read bool $wiki_enabled - * @property-read bool $snippets_enabled - * @property-read string $created_at - * @property-read int $greatest_access_level - * @property-read string $last_activity_at - * @property-read string $tag_list - * @property-read string $avatar_url - * @property-read User $owner - * @property-read ProjectNamespace $namespace - */ -class Project extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'id', - 'code', - 'name', - 'name_with_namespace', - 'namespace', - 'description', - 'path', - 'path_with_namespace', - 'ssh_url_to_repo', - 'http_url_to_repo', - 'web_url', - 'default_branch', - 'owner', - 'private', - 'public', - 'issues_enabled', - 'merge_requests_enabled', - 'wall_enabled', - 'wiki_enabled', - 'created_at', - 'greatest_access_level', - 'last_activity_at', - 'snippets_enabled', - 'tag_list', - 'avatar_url' - ); - - /** - * @param Client $client - * @param array $data - * @return Project - */ - public static function fromArray(Client $client, array $data) - { - $project = new static($data['id']); - $project->setClient($client); - - if (isset($data['owner'])) { - $data['owner'] = User::fromArray($client, $data['owner']); - } - - if (isset($data['namespace']) && is_array($data['namespace'])) { - $data['namespace'] = ProjectNamespace::fromArray($client, $data['namespace']); - } - - return $project->hydrate($data); - } - - /** - * @param Client $client - * @param string $name - * @param array $params - * @return Project - */ - public static function create(Client $client, $name, array $params = array()) - { - $data = $client->projects()->create($name, $params); - - return static::fromArray($client, $data); - } - - /** - * @param int $user_id - * @param Client $client - * @param string $name - * @param array $params - * @return Project - */ - public static function createForUser($user_id, Client $client, $name, array $params = array()) - { - $data = $client->projects()->createForUser($user_id, $name, $params); - - return static::fromArray($client, $data); - } - /** - * @param int $id - * @param Client $client - */ - public function __construct($id = null, Client $client = null) - { - $this->setClient($client); - $this->setData('id', $id); - } - - /** - * @return Project - */ - public function show() - { - $data = $this->client->projects()->show($this->id); - - return static::fromArray($this->getClient(), $data); - } - - /** - * @param array $params - * @return Project - */ - public function update(array $params) - { - $data = $this->client->projects()->update($this->id, $params); - - return static::fromArray($this->getClient(), $data); - } - - /** - * @return Project - */ - public function archive() - { - $data = $this->client->projects()->archive($this->id); - - return static::fromArray($this->getClient(), $data); - } - - /** - * @return Project - */ - public function unarchive() - { - $data = $this->client->projects()->unarchive($this->id); - - return static::fromArray($this->getClient(), $data); - } - - /** - * @return bool - */ - public function remove() - { - $this->client->projects()->remove($this->id); - - return true; - } - - /** - * @param string $username_query - * @return User[] - */ - public function members($username_query = null) - { - $data = $this->client->projects()->members($this->id, $username_query); - - $members = array(); - foreach ($data as $member) { - $members[] = User::fromArray($this->getClient(), $member); - } - - return $members; - } - - /** - * @param int $user_id - * @return User - */ - public function member($user_id) - { - $data = $this->client->projects()->member($this->id, $user_id); - - return User::fromArray($this->getClient(), $data); - } - - /** - * @param int $user_id - * @param int $access_level - * @return User - */ - public function addMember($user_id, $access_level) - { - $data = $this->client->projects()->addMember($this->id, $user_id, $access_level); - - return User::fromArray($this->getClient(), $data); - } - - /** - * @param int $user_id - * @param int $access_level - * @return User - */ - public function saveMember($user_id, $access_level) - { - $data = $this->client->projects()->saveMember($this->id, $user_id, $access_level); - - return User::fromArray($this->getClient(), $data); - } - - /** - * @param int $user_id - * @return bool - */ - public function removeMember($user_id) - { - $this->client->projects()->removeMember($this->id, $user_id); - - return true; - } - - /** - * @param array $parameters - * - * @see Projects::hooks() for available parameters. - * - * @return ProjectHook[] - */ - public function hooks(array $parameters = []) - { - $data = $this->client->projects()->hooks($this->id, $parameters); - - $hooks = array(); - foreach ($data as $hook) { - $hooks[] = ProjectHook::fromArray($this->getClient(), $this, $hook); - } - - return $hooks; - } - - /** - * @param int $id - * @return ProjectHook - */ - public function hook($id) - { - $hook = new ProjectHook($this, $id, $this->getClient()); - - return $hook->show(); - } - - /** - * @param string $url - * @param array $events - * @return ProjectHook - */ - public function addHook($url, array $events = array()) - { - $data = $this->client->projects()->addHook($this->id, $url, $events); - - return ProjectHook::fromArray($this->getClient(), $this, $data); - } - - /** - * @param int $hook_id - * @param array $params - * @return mixed - */ - public function updateHook($hook_id, array $params) - { - $hook = new ProjectHook($this, $hook_id, $this->getClient()); - - return $hook->update($params); - } - - /** - * @param int $hook_id - * @return bool - */ - public function removeHook($hook_id) - { - $hook = new ProjectHook($this, $hook_id, $this->getClient()); - - return $hook->delete(); - } - - /** - * @return Key[] - */ - public function deployKeys() - { - $data = $this->client->projects()->deployKeys($this->id); - - $keys = array(); - foreach ($data as $key) { - $keys[] = Key::fromArray($this->getClient(), $key); - } - - return $keys; - } - - /** - * @param int $key_id - * @return Key - */ - public function deployKey($key_id) - { - $data = $this->client->projects()->deployKey($this->id, $key_id); - - return Key::fromArray($this->getClient(), $data); - } - - /** - * @param string $title - * @param string $key - * @param bool $canPush - * @return Key - */ - public function addDeployKey($title, $key, $canPush = false) - { - $data = $this->client->projects()->addDeployKey($this->id, $title, $key, $canPush); - - return Key::fromArray($this->getClient(), $data); - } - - /** - * @param string $key_id - * @return bool - */ - public function deleteDeployKey($key_id) - { - $this->client->projects()->deleteDeployKey($this->id, $key_id); - - return true; - } - - /** - * @param string $key_id - * @return bool - */ - public function enableDeployKey($key_id) - { - $this->client->projects()->enableDeployKey($this->id, $key_id); - - return true; - } - - /** - * @param string $name - * @param string $ref - * @return Branch - */ - public function createBranch($name, $ref) - { - $data = $this->client->repositories()->createBranch($this->id, $name, $ref); - - return Branch::fromArray($this->getClient(), $this, $data); - } - - /** - * @param string $name - * @return bool - */ - public function deleteBranch($name) - { - $this->client->repositories()->deleteBranch($this->id, $name); - - return true; - } - - /** - * @return Branch[] - */ - public function branches() - { - $data = $this->client->repositories()->branches($this->id); - - $branches = array(); - foreach ($data as $branch) { - $branches[] = Branch::fromArray($this->getClient(), $this, $branch); - } - - return $branches; - } - - /** - * @param string $branch_name - * @return Branch - */ - public function branch($branch_name) - { - $branch = new Branch($this, $branch_name); - $branch->setClient($this->getClient()); - - return $branch->show(); - } - - /** - * @param string $branch_name - * @param bool $devPush - * @param bool $devMerge - * @return Branch - */ - public function protectBranch($branch_name, $devPush = false, $devMerge = false) - { - $branch = new Branch($this, $branch_name); - $branch->setClient($this->getClient()); - - return $branch->protect($devPush, $devMerge); - } - - /** - * @param string $branch_name - * @return Branch - */ - public function unprotectBranch($branch_name) - { - $branch = new Branch($this, $branch_name); - $branch->setClient($this->getClient()); - - return $branch->unprotect(); - } - - /** - * @return Tag[] - */ - public function tags() - { - $data = $this->client->repositories()->tags($this->id); - - $tags = array(); - foreach ($data as $tag) { - $tags[] = Tag::fromArray($this->getClient(), $this, $tag); - } - - return $tags; - } - - /** - * @param array $parameters - * - * @see Repositories::commits() for available parameters. - * - * @return Commit[] - */ - public function commits(array $parameters = []) - { - $data = $this->client->repositories()->commits($this->id, $parameters); - - $commits = array(); - foreach ($data as $commit) { - $commits[] = Commit::fromArray($this->getClient(), $this, $commit); - } - - return $commits; - } - - /** - * @param string $sha - * @return Commit - */ - public function commit($sha) - { - $data = $this->client->repositories()->commit($this->id, $sha); - - return Commit::fromArray($this->getClient(), $this, $data); - } - - /** - * @param string $ref - * @param array $parameters - * - * @see Repositories::commitComments() for available parameters. - * - * @return Commit[] - */ - public function commitComments($ref, array $parameters = []) - { - $data = $this->client->repositories()->commitComments($this->id, $ref, $parameters); - - $comments = array(); - foreach ($data as $comment) { - $comments[] = CommitNote::fromArray($this->getClient(), $comment); - } - - return $comments; - } - - /** - * @param string $ref - * @param string $note - * @param array $params - * @return CommitNote - */ - public function createCommitComment($ref, $note, array $params = array()) - { - $data = $this->client->repositories()->createCommitComment($this->id, $ref, $note, $params); - - return CommitNote::fromArray($this->getClient(), $data); - } - - /** - * @param string $sha - * @return string - */ - public function diff($sha) - { - return $this->client->repositories()->diff($this->id, $sha); - } - - /** - * @param string $from - * @param string $to - * @return Comparison - */ - public function compare($from, $to) - { - $data = $this->client->repositories()->compare($this->id, $from, $to); - - return Comparison::fromArray($this->getClient(), $this, $data); - } - - /** - * @param array $params - * @return Node[] - */ - public function tree(array $params = array()) - { - $data = $this->client->repositories()->tree($this->id, $params); - - $tree = array(); - foreach ($data as $node) { - $tree[] = Node::fromArray($this->getClient(), $this, $node); - } - - return $tree; - } - - /** - * @param string $sha - * @param string $filepath - * @return string - */ - public function blob($sha, $filepath) - { - return $this->client->repositories()->blob($this->id, $sha, $filepath); - } - - /** - * @param $sha - * @param $filepath - * - * @return array - */ - public function getFile($sha, $filepath) - { - return $this->client->repositories()->getFile($this->id, $filepath, $sha); - } - - /** - * @param string $file_path - * @param string $content - * @param string $branch_name - * @param string $commit_message - * @param string $author_email - * @param string $author_name - * @return File - */ - public function createFile($file_path, $content, $branch_name, $commit_message, $author_email = null, $author_name = null) - { - $parameters = [ - 'file_path' => $file_path, - 'branch' => $branch_name, - 'content' => $content, - 'commit_message' => $commit_message, - ]; - - if ($author_email !== null) { - $parameters['author_email'] = $author_email; - } - - if ($author_name !== null) { - $parameters['author_name'] = $author_name; - } - - $data = $this->client->repositoryFiles()->createFile($this->id, $parameters); - - return File::fromArray($this->getClient(), $this, $data); - } - - /** - * @param string $file_path - * @param string $content - * @param string $branch_name - * @param string $commit_message - * @param string $author_email - * @param string $author_name - * @return File - */ - public function updateFile($file_path, $content, $branch_name, $commit_message, $author_email = null, $author_name = null) - { - $parameters = [ - 'file_path' => $file_path, - 'branch' => $branch_name, - 'content' => $content, - 'commit_message' => $commit_message, - ]; - - if ($author_email !== null) { - $parameters['author_email'] = $author_email; - } - - if ($author_name !== null) { - $parameters['author_name'] = $author_name; - } - - $data = $this->client->repositoryFiles()->updateFile($this->id, $parameters); - - return File::fromArray($this->getClient(), $this, $data); - } - - /** - * @param string $file_path - * @param string $branch_name - * @param string $commit_message - * @param string $author_email - * @param string $author_name - * @return bool - */ - public function deleteFile($file_path, $branch_name, $commit_message, $author_email = null, $author_name = null) - { - $parameters = [ - 'file_path' => $file_path, - 'branch' => $branch_name, - 'commit_message' => $commit_message, - ]; - - if ($author_email !== null) { - $parameters['author_email'] = $author_email; - } - - if ($author_name !== null) { - $parameters['author_name'] = $author_name; - } - - $this->client->repositoryFiles()->deleteFile($this->id, $parameters); - - return true; - } - - /** - * @param array $parameters - * - * @see Projects::events() for available parameters. - * - * @return Event[] - */ - public function events(array $parameters = []) - { - $data = $this->client->projects()->events($this->id, $parameters); - - $events = array(); - foreach ($data as $event) { - $events[] = Event::fromArray($this->getClient(), $this, $event); - } - - return $events; - } - - /** - * @param array $parameters - * - * @see MergeRequests::all() for available parameters. - * - * @return MergeRequest[] - */ - public function mergeRequests(array $parameters = []) - { - $data = $this->client->mergeRequests()->all($this->id, $parameters); - - $mrs = array(); - foreach ($data as $mr) { - $mrs[] = MergeRequest::fromArray($this->getClient(), $this, $mr); - } - - return $mrs; - } - - /** - * @param int $id - * @return MergeRequest - */ - public function mergeRequest($id) - { - $mr = new MergeRequest($this, $id, $this->getClient()); - - return $mr->show(); - } - - /** - * @param string $source - * @param string $target - * @param string $title - * @param int $assignee - * @param string $description - * @return MergeRequest - */ - public function createMergeRequest($source, $target, $title, $assignee = null, $description = null) - { - $data = $this->client->mergeRequests()->create($this->id, $source, $target, $title, $assignee, null, $description); - - return MergeRequest::fromArray($this->getClient(), $this, $data); - } - - /** - * @param int $id - * @param array $params - * @return MergeRequest - */ - public function updateMergeRequest($id, array $params) - { - $mr = new MergeRequest($this, $id, $this->getClient()); - - return $mr->update($params); - } - - /** - * @param int $id - * @return MergeRequest - */ - public function closeMergeRequest($id) - { - $mr = new MergeRequest($this, $id, $this->getClient()); - - return $mr->close(); - } - - /** - * @param int $id - * @return MergeRequest - */ - public function openMergeRequest($id) - { - $mr = new MergeRequest($this, $id, $this->getClient()); - - return $mr->reopen(); - } - - /** - * @param int $id - * @return MergeRequest - */ - public function mergeMergeRequest($id) - { - $mr = new MergeRequest($this, $id, $this->getClient()); - - return $mr->merge(); - } - - /** - * @param array $parameters - * - * @see Issues::all() for available parameters. - * - * @return Issue[] - */ - public function issues(array $parameters = []) - { - $data = $this->client->issues()->all($this->id, $parameters); - - $issues = array(); - foreach ($data as $issue) { - $issues[] = Issue::fromArray($this->getClient(), $this, $issue); - } - - return $issues; - } - - /** - * @param string $title - * @param array $params - * @return Issue - */ - public function createIssue($title, array $params = array()) - { - $params['title'] = $title; - $data = $this->client->issues()->create($this->id, $params); - - return Issue::fromArray($this->getClient(), $this, $data); - } - - /** - * @param int $id - * @return Issue - */ - public function issue($id) - { - $issue = new Issue($this, $id, $this->getClient()); - - return $issue->show(); - } - - /** - * @param int $id - * @param array $params - * @return Issue - */ - public function updateIssue($id, array $params) - { - $issue = new Issue($this, $id, $this->getClient()); - - return $issue->update($params); - } - - /** - * @param int $id - * @param string $comment - * @return Issue - */ - public function closeIssue($id, $comment = null) - { - $issue = new Issue($this, $id, $this->getClient()); - - return $issue->close($comment); - } - - /** - * @param int $id - * @return Issue - */ - public function openIssue($id) - { - $issue = new Issue($this, $id, $this->getClient()); - - return $issue->open(); - } - - /** - * @param array $parameters - * - * @see Milestones::all() for available parameters. - * - * @return Milestone[] - */ - public function milestones(array $parameters = []) - { - $data = $this->client->milestones()->all($this->id, $parameters); - - $milestones = array(); - foreach ($data as $milestone) { - $milestones[] = Milestone::fromArray($this->getClient(), $this, $milestone); - } - - return $milestones; - } - - /** - * @param string $title - * @param array $params - * @return Milestone - */ - public function createMilestone($title, array $params = array()) - { - $params['title'] = $title; - $data = $this->client->milestones()->create($this->id, $params); - - return Milestone::fromArray($this->getClient(), $this, $data); - } - - /** - * @param int $id - * @return Milestone - */ - public function milestone($id) - { - $milestone = new Milestone($this, $id, $this->getClient()); - - return $milestone->show(); - } - - /** - * @param int $id - * @param array $params - * @return Milestone - */ - public function updateMilestone($id, array $params) - { - $milestone = new Milestone($this, $id, $this->getClient()); - - return $milestone->update($params); - } - - /** - * @param int $id - * @return Issue[] - */ - public function milestoneIssues($id) - { - $milestone = new Milestone($this, $id, $this->getClient()); - - return $milestone->issues(); - } - - /** - * @return Snippet[] - */ - public function snippets() - { - $data = $this->client->snippets()->all($this->id); - - $snippets = array(); - foreach ($data as $snippet) { - $snippets[] = Snippet::fromArray($this->getClient(), $this, $snippet); - } - - return $snippets; - } - - /** - * @param string $title - * @param string $filename - * @param string $code - * @return Snippet - */ - public function createSnippet($title, $filename, $code) - { - $data = $this->client->snippets()->create($this->id, $title, $filename, $code); - - return Snippet::fromArray($this->getClient(), $this, $data); - } - - /** - * @param int $id - * @return Snippet - */ - public function snippet($id) - { - $snippet = new Snippet($this, $id, $this->getClient()); - - return $snippet->show(); - } - - /** - * @param int $id - * @return string - */ - public function snippetContent($id) - { - $snippet = new Snippet($this, $id, $this->getClient()); - - return $snippet->content(); - } - - /** - * @param int $id - * @param array $params - * @return Snippet - */ - public function updateSnippet($id, array $params) - { - $snippet = new Snippet($this, $id, $this->getClient()); - - return $snippet->update($params); - } - - /** - * @param int $id - * @return bool - */ - public function removeSnippet($id) - { - $snippet = new Snippet($this, $id, $this->getClient()); - - return $snippet->remove(); - } - - /** - * @param int $group_id - * @return Group - */ - public function transfer($group_id) - { - $group = new Group($group_id, $this->getClient()); - - return $group->transfer($this->id); - } - - /** - * @param int $id - * @return Project - */ - public function forkTo($id) - { - $data = $this->client->projects()->createForkRelation($id, $this->id); - - return Project::fromArray($this->getClient(), $data); - } - - /** - * @param int $id - * @return Project - */ - public function forkFrom($id) - { - return $this->createForkRelation($id); - } - - /** - * @param int $id - * @return Project - */ - public function createForkRelation($id) - { - $data = $this->client->projects()->createForkRelation($this->id, $id); - - return Project::fromArray($this->getClient(), $data); - } - - /** - * @return bool - */ - public function removeForkRelation() - { - $this->client->projects()->removeForkRelation($this->id); - - return true; - } - - /** - * @param string $service_name - * @param array $params - * @return bool - */ - public function setService($service_name, array $params = array()) - { - $this->client->projects()->setService($this->id, $service_name, $params); - - return true; - } - - /** - * @param string $service_name - * @return bool - */ - public function removeService($service_name) - { - $this->client->projects()->removeService($this->id, $service_name); - - return true; - } - - /** - * @return Label[] - */ - public function labels() - { - $data = $this->client->projects()->labels($this->id); - - $labels = array(); - foreach ($data as $label) { - $labels[] = Label::fromArray($this->getClient(), $this, $label); - } - - return $labels; - } - - /** - * @param string $name - * @param string $color - * @return Label - */ - public function addLabel($name, $color) - { - $data = $this->client->projects()->addLabel($this->id, array( - 'name' => $name, - 'color' => $color - )); - - return Label::fromArray($this->getClient(), $this, $data); - } - - /** - * @param string $name - * @param array $params - * @return Label - */ - public function updateLabel($name, array $params) - { - if (isset($params['name'])) { - $params['new_name'] = $params['name']; - } - - $params['name'] = $name; - - $data = $this->client->projects()->updateLabel($this->id, $params); - - return Label::fromArray($this->getClient(), $this, $data); - } - - /** - * @param string $name - * @return bool - */ - public function removeLabel($name) - { - $this->client->projects()->removeLabel($this->id, $name); - - return true; - } - - /** - * @return array - */ - public function contributors() - { - $data = $this->client->repositories()->contributors($this->id); - - $contributors = array(); - foreach ($data as $contributor) { - $contributors[] = Contributor::fromArray($this->getClient(), $this, $contributor); - } - - return $contributors; - } - - /** - * @param array $scopes - * @return Job[] - */ - public function jobs(array $scopes = []) - { - $data = $this->client->jobs()->all($this->id, $scopes); - - $jobs = array(); - foreach ($data as $job) { - $jobs[] = Job::fromArray($this->getClient(), $this, $job); - } - - return $jobs; - } - - /** - * @param int $pipeline_id - * @param array $scopes - * @return Job[] - */ - public function pipelineJobs($pipeline_id, array $scopes = []) - { - $data = $this->client->jobs()->pipelineJobs($this->id, $pipeline_id, $scopes); - - $jobs = array(); - foreach ($data as $job) { - $jobs[] = Job::fromArray($this->getClient(), $this, $job); - } - - return $jobs; - } - - /** - * @param int $job_id - * @return Job - */ - public function job($job_id) - { - $data = $this->client->jobs()->show($this->id, $job_id); - - return Job::fromArray($this->getClient(), $this, $data); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/ProjectHook.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/ProjectHook.php deleted file mode 100755 index 1789ca68bbce8edbf9e859aa6ec45a3b67c8cbcf..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/ProjectHook.php +++ /dev/null @@ -1,102 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class ProjectHook - * - * @property-read int $id - * @property-read string $url - * @property-read int $project_id - * @property-read bool $push_events - * @property-read bool $issues_events - * @property-read bool $merge_requests_events - * @property-read bool $job_events - * @property-read bool $tag_push_events - * @property-read bool $pipeline_events - * @property-read string $created_at - * @property-read Project $project - */ -class ProjectHook extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'id', - 'project', - 'url', - 'project_id', - 'push_events', - 'issues_events', - 'merge_requests_events', - 'job_events', - 'tag_push_events', - 'pipeline_events', - 'created_at' - ); - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return ProjectHook - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $hook = new static($project, $data['id'], $client); - - return $hook->hydrate($data); - } - - /** - * @param Project $project - * @param int $id - * @param Client $client - */ - public function __construct(Project $project, $id, Client $client = null) - { - $this->setClient($client); - $this->setData('project', $project); - $this->setData('id', $id); - } - - /** - * @return ProjectHook - */ - public function show() - { - $data = $this->client->projects()->hook($this->project->id, $this->id); - - return static::fromArray($this->getClient(), $this->project, $data); - } - - /** - * @return bool - */ - public function delete() - { - $this->client->projects()->removeHook($this->project->id, $this->id); - - return true; - } - - /** - * @return bool - */ - public function remove() - { - return $this->delete(); - } - - /** - * @param array $params - * @return ProjectHook - */ - public function update(array $params) - { - $data = $this->client->projects()->updateHook($this->project->id, $this->id, $params); - - return static::fromArray($this->getClient(), $this->project, $data); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/ProjectNamespace.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/ProjectNamespace.php deleted file mode 100755 index 9e3aee4ed5a366635a4b8165ca73dc91fb74ee9b..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/ProjectNamespace.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class ProjectNamespace - * - * @property-read int $id - * @property-read string $name - * @property-read string $path - * @property-read string $kind - * @property-read int $owner_id - * @property-read string $created_at - * @property-read string $updated_at - * @property-read string $description - */ -class ProjectNamespace extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'id', - 'name', - 'path', - 'kind', - 'owner_id', - 'created_at', - 'updated_at', - 'description' - ); - - /** - * @param Client $client - * @param array $data - * @return ProjectNamespace - */ - public static function fromArray(Client $client, array $data) - { - $project = new static($data['id']); - $project->setClient($client); - - return $project->hydrate($data); - } - - /** - * @param int $id - * @param Client $client - */ - public function __construct($id = null, Client $client = null) - { - $this->setClient($client); - $this->setData('id', $id); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Session.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Session.php deleted file mode 100755 index 7cf4cfe79c42716fad7ec23728154a79dd778f76..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Session.php +++ /dev/null @@ -1,70 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Session - * - * @property-read int $id - * @property-read string $email - * @property-read string $name - * @property-read string $private_token - * @property-read string $created_at - * @property-read bool $blocked - */ -class Session extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'id', - 'email', - 'name', - 'private_token', - 'created_at', - 'blocked' - ); - - /** - * @param Client $client - * @param array $data - * @return Session - */ - public static function fromArray(Client $client, array $data) - { - $session = new static($client); - - return $session->hydrate($data); - } - - /** - * @param Client $client - */ - public function __construct(Client $client = null) - { - $this->setClient($client); - } - - /** - * @return User - */ - public function me() - { - $data = $this->client->users()->user(); - - return User::fromArray($this->getClient(), $data); - } - - /** - * @param string $email - * @param string $password - * @return Session - */ - public function login($email, $password) - { - $data = $this->client->users()->session($email, $password); - - return $this->hydrate($data); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Snippet.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Snippet.php deleted file mode 100755 index 1f021bcb4f85b41e0c9bcdcf97db00d0d9eb8f8c..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Snippet.php +++ /dev/null @@ -1,98 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Snippet - * - * @property-read int $id - * @property-read string $title - * @property-read string $file_name - * @property-read string $updated_at - * @property-read string $created_at - * @property-read Project $project - * @property-read User $author - */ -class Snippet extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'id', - 'title', - 'file_name', - 'author', - 'updated_at', - 'created_at', - 'project' - ); - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return Snippet - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $snippet = new static($project, $data['id'], $client); - - if (isset($data['author'])) { - $data['author'] = User::fromArray($client, $data['author']); - } - - return $snippet->hydrate($data); - } - - /** - * @param Project $project - * @param int $id - * @param Client $client - */ - public function __construct(Project $project, $id = null, Client $client = null) - { - $this->setClient($client); - $this->setData('project', $project); - $this->setData('id', $id); - } - - /** - * @return Snippet - */ - public function show() - { - $data = $this->client->snippets()->show($this->project->id, $this->id); - - return static::fromArray($this->getClient(), $this->project, $data); - } - - /** - * @param array $params - * @return Snippet - */ - public function update(array $params) - { - $data = $this->client->snippets()->update($this->project->id, $this->id, $params); - - return static::fromArray($this->getClient(), $this->project, $data); - } - - /** - * @return string - */ - public function content() - { - return $this->client->snippets()->content($this->project->id, $this->id); - } - - /** - * @return bool - */ - public function remove() - { - $this->client->snippets()->remove($this->project->id, $this->id); - - return true; - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Tag.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Tag.php deleted file mode 100755 index 6028b3da5882dda97d6259d0d61082ad849cc2e8..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/Tag.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class Tag - * - * @property-read string $name - * @property-read bool $protected - * @property-read Commit $commit - * @property-read Project $project - */ -class Tag extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'name', - 'commit', - 'project', - 'protected' - ); - - /** - * @param Client $client - * @param Project $project - * @param array $data - * @return Tag - */ - public static function fromArray(Client $client, Project $project, array $data) - { - $branch = new static($project, $data['name'], $client); - - if (isset($data['commit'])) { - $data['commit'] = Commit::fromArray($client, $project, $data['commit']); - } - - return $branch->hydrate($data); - } - - /** - * @param Project $project - * @param string $name - * @param Client $client - */ - public function __construct(Project $project, $name = null, Client $client = null) - { - $this->setClient($client); - $this->setData('project', $project); - $this->setData('name', $name); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/User.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/User.php deleted file mode 100755 index ef654756df4b5c5bd4b5f2448865a288fd103a32..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/Model/User.php +++ /dev/null @@ -1,227 +0,0 @@ -<?php namespace Gitlab\Model; - -use Gitlab\Client; - -/** - * Class User - * - * @property-read int $id - * @property-read string $email - * @property-read string $password - * @property-read string $username - * @property-read string $name - * @property-read string $bio - * @property-read string $skype - * @property-read string $linkedin - * @property-read string $twitter - * @property-read bool $dark_scheme - * @property-read int $theme_id - * @property-read int $color_scheme_id - * @property-read bool $blocked - * @property-read int $access_level - * @property-read string $created_at - * @property-read string $extern_uid - * @property-read string $provider - * @property-read string $state - * @property-read bool $is_admin - * @property-read bool $can_create_group - * @property-read bool $can_create_project - * @property-read string $avatar_url - * @property-read string $current_sign_in_at - * @property-read bool $two_factor_enabled - */ -class User extends AbstractModel -{ - /** - * @var array - */ - protected static $properties = array( - 'id', - 'email', - 'password', - 'username', - 'name', - 'bio', - 'skype', - 'linkedin', - 'twitter', - 'dark_scheme', - 'theme_id', - 'color_scheme_id', - 'blocked', - 'projects_limit', - 'access_level', - 'created_at', - 'extern_uid', - 'provider', - 'state', - 'is_admin', - 'can_create_group', - 'can_create_project', - 'avatar_url', - 'current_sign_in_at', - 'two_factor_enabled' - ); - - /** - * @param Client $client - * @param array $data - * @return User - */ - public static function fromArray(Client $client, array $data) - { - $id = isset($data['id']) ? $data['id'] : 0; - - $user = new static($id, $client); - - return $user->hydrate($data); - } - - /** - * @param Client $client - * @param string $email - * @param string $password - * @param array $params - * @return User - */ - public static function create(Client $client, $email, $password, array $params = array()) - { - $data = $client->users()->create($email, $password, $params); - - return static::fromArray($client, $data); - } - - /** - * @param int $id - * @param Client $client - */ - public function __construct($id = null, Client $client = null) - { - $this->setClient($client); - $this->setData('id', $id); - } - - /** - * @return User - */ - public function show() - { - $data = $this->client->users()->show($this->id); - - return static::fromArray($this->getClient(), $data); - } - - /** - * @param array $params - * @return User - */ - public function update(array $params) - { - $data = $this->client->users()->update($this->id, $params); - - return static::fromArray($this->getClient(), $data); - } - - /** - * @return bool - */ - public function remove() - { - $this->client->users()->remove($this->id); - - return true; - } - - /** - * @return bool - */ - public function block() - { - $this->client->users()->block($this->id); - - return true; - } - - /** - * @return bool - */ - public function unblock() - { - $this->client->users()->unblock($this->id); - - return true; - } - - /** - * @return Key[] - */ - public function keys() - { - $data = $this->client->users()->keys(); - - $keys = array(); - foreach ($data as $key) { - $keys[] = Key::fromArray($this->getClient(), $key); - } - - return $keys; - } - - /** - * @param string $title - * @param string $key - * @return Key - */ - public function createKey($title, $key) - { - $data = $this->client->users()->createKey($title, $key); - - return Key::fromArray($this->getClient(), $data); - } - - /** - * @param string $title - * @param string $key - * @return Key - */ - public function createKeyForUser($user_id, $title, $key) - { - $data = $this->client->users()->createKeyForUser($user_id, $title, $key); - - return Key::fromArray($this->getClient(), $data); - } - - /** - * @param int $id - * @return bool - */ - public function removeKey($id) - { - $this->client->users()->removeKey($id); - - return true; - } - - /** - * @param int $group_id - * @param int $access_level - * @return User - */ - public function addToGroup($group_id, $access_level) - { - $group = new Group($group_id, $this->getClient()); - - return $group->addMember($this->id, $access_level); - } - - /** - * @param int $group_id - * @return bool - */ - public function removeFromGroup($group_id) - { - $group = new Group($group_id, $this->getClient()); - - return $group->removeMember($this->id); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/ResultPager.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/ResultPager.php deleted file mode 100755 index b436305b135c1d6adc8d963763b398d633c69037..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/ResultPager.php +++ /dev/null @@ -1,132 +0,0 @@ -<?php namespace Gitlab; - -use Gitlab\Api\ApiInterface; -use Gitlab\HttpClient\Message\ResponseMediator; - -/** - * Pager class for supporting pagination in Gitlab classes - */ -class ResultPager implements ResultPagerInterface -{ - /** - * @var \Gitlab\Client client - */ - protected $client; - - /** - * The Gitlab client to use for pagination. This must be the same - * instance that you got the Api instance from, i.e.: - * - * $client = new \Gitlab\Client(); - * $api = $client->api('someApi'); - * $pager = new \Gitlab\ResultPager($client); - * - * @param \Gitlab\Client $client - * - */ - public function __construct(Client $client) - { - $this->client = $client; - } - - /** - * {@inheritdoc} - */ - public function fetch(ApiInterface $api, $method, array $parameters = array()) - { - return call_user_func_array(array($api, $method), $parameters); - } - - /** - * {@inheritdoc} - */ - public function fetchAll(ApiInterface $api, $method, array $parameters = array()) - { - $result = call_user_func_array(array($api, $method), $parameters); - while ($this->hasNext()) { - $result = array_merge($result, $this->fetchNext()); - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function hasNext() - { - return $this->has('next'); - } - - /** - * {@inheritdoc} - */ - public function fetchNext() - { - return $this->get('next'); - } - - /** - * {@inheritdoc} - */ - public function hasPrevious() - { - return $this->has('prev'); - } - - /** - * {@inheritdoc} - */ - public function fetchPrevious() - { - return $this->get('prev'); - } - - /** - * {@inheritdoc} - */ - public function fetchFirst() - { - return $this->get('first'); - } - - /** - * {@inheritdoc} - */ - public function fetchLast() - { - return $this->get('last'); - } - - /** - * {@inheritdoc} - */ - protected function has($key) - { - $lastResponse = $this->client->getResponseHistory()->getLastResponse(); - if ($lastResponse == null) { - return false; - } - - $pagination = ResponseMediator::getPagination($lastResponse); - if ($pagination == null) { - return false; - } - - return isset($pagination[$key]); - } - - /** - * {@inheritdoc} - */ - protected function get($key) - { - if (!$this->has($key)) { - return []; - } - - $pagination = ResponseMediator::getPagination($this->client->getResponseHistory()->getLastResponse()); - - return ResponseMediator::getContent($this->client->getHttpClient()->get($pagination[$key])); - } -} diff --git a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/ResultPagerInterface.php b/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/ResultPagerInterface.php deleted file mode 100755 index 0078580c1d322507e6e4545252b10e69ce3131ee..0000000000000000000000000000000000000000 --- a/vendor/m4tthumphrey/php-gitlab-api/lib/Gitlab/ResultPagerInterface.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php namespace Gitlab; - -use Gitlab\Api\ApiInterface; - -/** - * Pager interface - */ -interface ResultPagerInterface -{ - /** - * Fetch a single result (page) from an api call - * - * @param ApiInterface $api the Api instance - * @param string $method the method name to call on the Api instance - * @param array $parameters the method parameters in an array - * - * @return array returns the result of the Api::$method() call - */ - public function fetch(ApiInterface $api, $method, array $parameters = array()); - - /** - * Fetch all results (pages) from an api call - * Use with care - there is no maximum - * - * @param ApiInterface $api the Api instance - * @param string $method the method name to call on the Api instance - * @param array $parameters the method parameters in an array - * - * @return array returns a merge of the results of the Api::$method() call - */ - public function fetchAll(ApiInterface $api, $method, array $parameters = array()); - - /** - * Check to determine the availability of a next page - * @return bool - */ - public function hasNext(); - - /** - * Check to determine the availability of a previous page - * @return bool - */ - public function hasPrevious(); - - /** - * Fetch the next page - * @return array - */ - public function fetchNext(); - - /** - * Fetch the previous page - * @return array - */ - public function fetchPrevious(); - - /** - * Fetch the first page - * @return array - */ - public function fetchFirst(); - - /** - * Fetch the last page - * @return array - */ - public function fetchLast(); -} diff --git a/vendor/nikic/fast-route/.gitignore b/vendor/nikic/fast-route/.gitignore old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/.hhconfig b/vendor/nikic/fast-route/.hhconfig old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/.travis.yml b/vendor/nikic/fast-route/.travis.yml old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/FastRoute.hhi b/vendor/nikic/fast-route/FastRoute.hhi old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/LICENSE b/vendor/nikic/fast-route/LICENSE old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/README.md b/vendor/nikic/fast-route/README.md old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/composer.json b/vendor/nikic/fast-route/composer.json old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/phpunit.xml b/vendor/nikic/fast-route/phpunit.xml old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/psalm.xml b/vendor/nikic/fast-route/psalm.xml old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/BadRouteException.php b/vendor/nikic/fast-route/src/BadRouteException.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/DataGenerator.php b/vendor/nikic/fast-route/src/DataGenerator.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/DataGenerator/CharCountBased.php b/vendor/nikic/fast-route/src/DataGenerator/CharCountBased.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/DataGenerator/GroupCountBased.php b/vendor/nikic/fast-route/src/DataGenerator/GroupCountBased.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/DataGenerator/GroupPosBased.php b/vendor/nikic/fast-route/src/DataGenerator/GroupPosBased.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/DataGenerator/MarkBased.php b/vendor/nikic/fast-route/src/DataGenerator/MarkBased.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/DataGenerator/RegexBasedAbstract.php b/vendor/nikic/fast-route/src/DataGenerator/RegexBasedAbstract.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/Dispatcher.php b/vendor/nikic/fast-route/src/Dispatcher.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/Dispatcher/CharCountBased.php b/vendor/nikic/fast-route/src/Dispatcher/CharCountBased.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/Dispatcher/GroupCountBased.php b/vendor/nikic/fast-route/src/Dispatcher/GroupCountBased.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/Dispatcher/GroupPosBased.php b/vendor/nikic/fast-route/src/Dispatcher/GroupPosBased.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/Dispatcher/MarkBased.php b/vendor/nikic/fast-route/src/Dispatcher/MarkBased.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/Dispatcher/RegexBasedAbstract.php b/vendor/nikic/fast-route/src/Dispatcher/RegexBasedAbstract.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/Route.php b/vendor/nikic/fast-route/src/Route.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/RouteCollector.php b/vendor/nikic/fast-route/src/RouteCollector.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/RouteParser.php b/vendor/nikic/fast-route/src/RouteParser.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/RouteParser/Std.php b/vendor/nikic/fast-route/src/RouteParser/Std.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/bootstrap.php b/vendor/nikic/fast-route/src/bootstrap.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/src/functions.php b/vendor/nikic/fast-route/src/functions.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/test/Dispatcher/CharCountBasedTest.php b/vendor/nikic/fast-route/test/Dispatcher/CharCountBasedTest.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/test/Dispatcher/DispatcherTest.php b/vendor/nikic/fast-route/test/Dispatcher/DispatcherTest.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/test/Dispatcher/GroupCountBasedTest.php b/vendor/nikic/fast-route/test/Dispatcher/GroupCountBasedTest.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/test/Dispatcher/GroupPosBasedTest.php b/vendor/nikic/fast-route/test/Dispatcher/GroupPosBasedTest.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/test/Dispatcher/MarkBasedTest.php b/vendor/nikic/fast-route/test/Dispatcher/MarkBasedTest.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/test/HackTypechecker/HackTypecheckerTest.php b/vendor/nikic/fast-route/test/HackTypechecker/HackTypecheckerTest.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/test/HackTypechecker/fixtures/all_options.php b/vendor/nikic/fast-route/test/HackTypechecker/fixtures/all_options.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/test/HackTypechecker/fixtures/empty_options.php b/vendor/nikic/fast-route/test/HackTypechecker/fixtures/empty_options.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/test/HackTypechecker/fixtures/no_options.php b/vendor/nikic/fast-route/test/HackTypechecker/fixtures/no_options.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/test/RouteCollectorTest.php b/vendor/nikic/fast-route/test/RouteCollectorTest.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/test/RouteParser/StdTest.php b/vendor/nikic/fast-route/test/RouteParser/StdTest.php old mode 100755 new mode 100644 diff --git a/vendor/nikic/fast-route/test/bootstrap.php b/vendor/nikic/fast-route/test/bootstrap.php old mode 100755 new mode 100644 diff --git a/vendor/php-http/client-common/CHANGELOG.md b/vendor/php-http/client-common/CHANGELOG.md deleted file mode 100755 index 3031720c6d59e8b3362a4eda3370af07f98f56d9..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/CHANGELOG.md +++ /dev/null @@ -1,137 +0,0 @@ -# Change Log - -## 1.7.0 - 2017-11-30 - -### Added - -- Symfony 4 support - -### Changed - -- Strict comparison in DecoderPlugin - -## 1.6.0 - 2017-10-16 - -### Added - -- Add HttpClientPool client to leverage load balancing and fallback mechanism [see the documentation](http://docs.php-http.org/en/latest/components/client-common.html) for more details. -- `PluginClientFactory` to create `PluginClient` instances. -- Added new option 'delay' for `RetryPlugin`. -- Added new option 'decider' for `RetryPlugin`. -- Supports more cookie date formats in the Cookie Plugin - -### Changed - -- The `RetryPlugin` does now wait between retries. To disable/change this feature you must write something like: - -```php -$plugin = new RetryPlugin(['delay' => function(RequestInterface $request, Exception $e, $retries) { - return 0; -}); -``` - -### Deprecated - -- The `debug_plugins` option for `PluginClient` is deprecated and will be removed in 2.0. Use the decorator design pattern instead like in [ProfilePlugin](https://github.com/php-http/HttplugBundle/blob/de33f9c14252f22093a5ec7d84f17535ab31a384/Collector/ProfilePlugin.php). - -## 1.5.0 - 2017-03-30 - -### Added - -- `QueryDefaultsPlugin` to add default query parameters. - -## 1.4.2 - 2017-03-18 - -### Deprecated - -- `DecoderPlugin` does not longer claim to support `compress` content encoding - -### Fixed - -- `CookiePlugin` allows main domain cookies to be sent/stored for subdomains -- `DecoderPlugin` uses the right `FilteredStream` to handle `deflate` content encoding - - -## 1.4.1 - 2017-02-20 - -### Fixed - -- Cast return value of `StreamInterface::getSize` to string in `ContentLengthPlugin` - - -## 1.4.0 - 2016-11-04 - -### Added - -- Add Path plugin -- Base URI plugin that combines Add Host and Add Path plugins - - -## 1.3.0 - 2016-10-16 - -### Changed - -- Fix Emulated Trait to use Http based promise which respect the HttpAsyncClient interface -- Require Httplug 1.1 where we use HTTP specific promises. -- RedirectPlugin: use the full URL instead of the URI to properly keep track of redirects -- Add AddPathPlugin for API URLs with base path -- Add BaseUriPlugin that combines AddHostPlugin and AddPathPlugin - - -## 1.2.1 - 2016-07-26 - -### Changed - -- AddHostPlugin also sets the port if specified - - -## 1.2.0 - 2016-07-14 - -### Added - -- Suggest separate plugins in composer.json -- Introduced `debug_plugins` option for `PluginClient` - - -## 1.1.0 - 2016-05-04 - -### Added - -- Add a flexible http client providing both contract, and only emulating what's necessary -- HTTP Client Router: route requests to underlying clients -- Plugin client and core plugins moved here from `php-http/plugins` - -### Deprecated - -- Extending client classes, they will be made final in version 2.0 - - -## 1.0.0 - 2016-01-27 - -### Changed - -- Remove useless interface in BatchException - - -## 0.2.0 - 2016-01-12 - -### Changed - -- Updated package files -- Updated HTTPlug to RC1 - - -## 0.1.1 - 2015-12-26 - -### Added - -- Emulated clients - - -## 0.1.0 - 2015-12-25 - -### Added - -- Batch client from utils -- Methods client from utils -- Emulators and decorators from client-tools diff --git a/vendor/php-http/client-common/LICENSE b/vendor/php-http/client-common/LICENSE deleted file mode 100755 index 4558d6f06306fce15add8bc10e29152bc4ad5355..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015-2016 PHP HTTP Team <team@php-http.org> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/php-http/client-common/README.md b/vendor/php-http/client-common/README.md deleted file mode 100755 index 017bfcec93b5f7d436bffaade7e051ec0570ccb1..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# HTTP Client Common - -[](https://github.com/php-http/client-common/releases) -[](LICENSE) -[](https://travis-ci.org/php-http/client-common) -[](https://scrutinizer-ci.com/g/php-http/client-common) -[](https://scrutinizer-ci.com/g/php-http/client-common) -[](https://packagist.org/packages/php-http/client-common) - -**Common HTTP Client implementations and tools for HTTPlug.** - - -## Install - -Via Composer - -``` bash -$ composer require php-http/client-common -``` - - -## Usage - -This package provides common tools for HTTP Clients: - -- BatchClient to handle sending requests in parallel -- A convenience client with HTTP method names as class methods -- Emulator, decorator layers for sync/async clients - - -## Documentation - -Please see the [official documentation](http://docs.php-http.org/en/latest/components/client-common.html). - - -## Testing - -``` bash -$ composer test -``` - - -## Contributing - -Please see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html). - - -## Security - -If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org). - - -## License - -The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/vendor/php-http/client-common/composer.json b/vendor/php-http/client-common/composer.json deleted file mode 100755 index fc5fc5fb4ea5e4927b72b29e406b5b47f3f691fa..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/composer.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "php-http/client-common", - "description": "Common HTTP Client implementations and tools for HTTPlug", - "license": "MIT", - "keywords": ["http", "client", "httplug", "common"], - "homepage": "http://httplug.io", - "authors": [ - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "require": { - "php": "^5.4 || ^7.0", - "php-http/httplug": "^1.1", - "php-http/message-factory": "^1.0", - "php-http/message": "^1.6", - "symfony/options-resolver": "^2.6 || ^3.0 || ^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^2.5 || ^3.4 || ^4.2", - "guzzlehttp/psr7": "^1.4" - }, - "suggest": { - "php-http/logger-plugin": "PSR-3 Logger plugin", - "php-http/cache-plugin": "PSR-6 Cache plugin", - "php-http/stopwatch-plugin": "Symfony Stopwatch plugin" - }, - "autoload": { - "psr-4": { - "Http\\Client\\Common\\": "src/" - } - }, - "scripts": { - "test": "vendor/bin/phpspec run", - "test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml" - }, - "extra": { - "branch-alias": { - "dev-master": "1.7-dev" - } - } -} diff --git a/vendor/php-http/client-common/src/BatchClient.php b/vendor/php-http/client-common/src/BatchClient.php deleted file mode 100755 index 2036355b604746ea942b0c69a95ba768723ae0e5..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/BatchClient.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php - -namespace Http\Client\Common; - -use Http\Client\Exception; -use Http\Client\HttpClient; -use Http\Client\Common\Exception\BatchException; -use Psr\Http\Message\RequestInterface; - -/** - * BatchClient allow to sends multiple request and retrieve a Batch Result. - * - * This implementation simply loops over the requests and uses sendRequest with each of them. - * - * @author Joel Wurtz <jwurtz@jolicode.com> - */ -class BatchClient implements HttpClient -{ - /** - * @var HttpClient - */ - private $client; - - /** - * @param HttpClient $client - */ - public function __construct(HttpClient $client) - { - $this->client = $client; - } - - /** - * {@inheritdoc} - */ - public function sendRequest(RequestInterface $request) - { - return $this->client->sendRequest($request); - } - - /** - * Send several requests. - * - * You may not assume that the requests are executed in a particular order. If the order matters - * for your application, use sendRequest sequentially. - * - * @param RequestInterface[] The requests to send - * - * @return BatchResult Containing one result per request - * - * @throws BatchException If one or more requests fails. The exception gives access to the - * BatchResult with a map of request to result for success, request to - * exception for failures - */ - public function sendRequests(array $requests) - { - $batchResult = new BatchResult(); - - foreach ($requests as $request) { - try { - $response = $this->sendRequest($request); - $batchResult = $batchResult->addResponse($request, $response); - } catch (Exception $e) { - $batchResult = $batchResult->addException($request, $e); - } - } - - if ($batchResult->hasExceptions()) { - throw new BatchException($batchResult); - } - - return $batchResult; - } -} diff --git a/vendor/php-http/client-common/src/BatchResult.php b/vendor/php-http/client-common/src/BatchResult.php deleted file mode 100755 index 710611d6d00ff6b3069eff19a26f2daab6ec1e7e..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/BatchResult.php +++ /dev/null @@ -1,181 +0,0 @@ -<?php - -namespace Http\Client\Common; - -use Http\Client\Exception; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Responses and exceptions returned from parallel request execution. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -final class BatchResult -{ - /** - * @var \SplObjectStorage - */ - private $responses; - - /** - * @var \SplObjectStorage - */ - private $exceptions; - - public function __construct() - { - $this->responses = new \SplObjectStorage(); - $this->exceptions = new \SplObjectStorage(); - } - - /** - * Checks if there are any successful responses at all. - * - * @return bool - */ - public function hasResponses() - { - return $this->responses->count() > 0; - } - - /** - * Returns all successful responses. - * - * @return ResponseInterface[] - */ - public function getResponses() - { - $responses = []; - - foreach ($this->responses as $request) { - $responses[] = $this->responses[$request]; - } - - return $responses; - } - - /** - * Checks if there is a successful response for a request. - * - * @param RequestInterface $request - * - * @return bool - */ - public function isSuccessful(RequestInterface $request) - { - return $this->responses->contains($request); - } - - /** - * Returns the response for a successful request. - * - * @param RequestInterface $request - * - * @return ResponseInterface - * - * @throws \UnexpectedValueException If request was not part of the batch or failed - */ - public function getResponseFor(RequestInterface $request) - { - try { - return $this->responses[$request]; - } catch (\UnexpectedValueException $e) { - throw new \UnexpectedValueException('Request not found', $e->getCode(), $e); - } - } - - /** - * Adds a response in an immutable way. - * - * @param RequestInterface $request - * @param ResponseInterface $response - * - * @return BatchResult the new BatchResult with this request-response pair added to it - */ - public function addResponse(RequestInterface $request, ResponseInterface $response) - { - $new = clone $this; - $new->responses->attach($request, $response); - - return $new; - } - - /** - * Checks if there are any unsuccessful requests at all. - * - * @return bool - */ - public function hasExceptions() - { - return $this->exceptions->count() > 0; - } - - /** - * Returns all exceptions for the unsuccessful requests. - * - * @return Exception[] - */ - public function getExceptions() - { - $exceptions = []; - - foreach ($this->exceptions as $request) { - $exceptions[] = $this->exceptions[$request]; - } - - return $exceptions; - } - - /** - * Checks if there is an exception for a request, meaning the request failed. - * - * @param RequestInterface $request - * - * @return bool - */ - public function isFailed(RequestInterface $request) - { - return $this->exceptions->contains($request); - } - - /** - * Returns the exception for a failed request. - * - * @param RequestInterface $request - * - * @return Exception - * - * @throws \UnexpectedValueException If request was not part of the batch or was successful - */ - public function getExceptionFor(RequestInterface $request) - { - try { - return $this->exceptions[$request]; - } catch (\UnexpectedValueException $e) { - throw new \UnexpectedValueException('Request not found', $e->getCode(), $e); - } - } - - /** - * Adds an exception in an immutable way. - * - * @param RequestInterface $request - * @param Exception $exception - * - * @return BatchResult the new BatchResult with this request-exception pair added to it - */ - public function addException(RequestInterface $request, Exception $exception) - { - $new = clone $this; - $new->exceptions->attach($request, $exception); - - return $new; - } - - public function __clone() - { - $this->responses = clone $this->responses; - $this->exceptions = clone $this->exceptions; - } -} diff --git a/vendor/php-http/client-common/src/EmulatedHttpAsyncClient.php b/vendor/php-http/client-common/src/EmulatedHttpAsyncClient.php deleted file mode 100755 index 1b163167e6dfcfb23076e3a9ad4a19b96a86abfe..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/EmulatedHttpAsyncClient.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -namespace Http\Client\Common; - -use Http\Client\HttpAsyncClient; -use Http\Client\HttpClient; - -/** - * Emulates an async HTTP client. - * - * This should be replaced by an anonymous class in PHP 7. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -class EmulatedHttpAsyncClient implements HttpClient, HttpAsyncClient -{ - use HttpAsyncClientEmulator; - use HttpClientDecorator; - - /** - * @param HttpClient $httpClient - */ - public function __construct(HttpClient $httpClient) - { - $this->httpClient = $httpClient; - } -} diff --git a/vendor/php-http/client-common/src/EmulatedHttpClient.php b/vendor/php-http/client-common/src/EmulatedHttpClient.php deleted file mode 100755 index 01046c83e4c29a0578e6132da47ce378e8e71698..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/EmulatedHttpClient.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -namespace Http\Client\Common; - -use Http\Client\HttpAsyncClient; -use Http\Client\HttpClient; - -/** - * Emulates an HTTP client. - * - * This should be replaced by an anonymous class in PHP 7. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -class EmulatedHttpClient implements HttpClient, HttpAsyncClient -{ - use HttpAsyncClientDecorator; - use HttpClientEmulator; - - /** - * @param HttpAsyncClient $httpAsyncClient - */ - public function __construct(HttpAsyncClient $httpAsyncClient) - { - $this->httpAsyncClient = $httpAsyncClient; - } -} diff --git a/vendor/php-http/client-common/src/Exception/BatchException.php b/vendor/php-http/client-common/src/Exception/BatchException.php deleted file mode 100755 index 66a92719e4ae05be21567ce08d5ecb84c716e808..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Exception/BatchException.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -namespace Http\Client\Common\Exception; - -use Http\Client\Exception\TransferException; -use Http\Client\Common\BatchResult; - -/** - * This exception is thrown when HttpClient::sendRequests led to at least one failure. - * - * It gives access to a BatchResult with the request-exception and request-response pairs. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -final class BatchException extends TransferException -{ - /** - * @var BatchResult - */ - private $result; - - /** - * @param BatchResult $result - */ - public function __construct(BatchResult $result) - { - $this->result = $result; - } - - /** - * Returns the BatchResult that contains all responses and exceptions. - * - * @return BatchResult - */ - public function getResult() - { - return $this->result; - } -} diff --git a/vendor/php-http/client-common/src/Exception/CircularRedirectionException.php b/vendor/php-http/client-common/src/Exception/CircularRedirectionException.php deleted file mode 100755 index 73ec521e17348e898ff895a172947e68bce93fce..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Exception/CircularRedirectionException.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -namespace Http\Client\Common\Exception; - -use Http\Client\Exception\HttpException; - -/** - * Thrown when circular redirection is detected. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class CircularRedirectionException extends HttpException -{ -} diff --git a/vendor/php-http/client-common/src/Exception/ClientErrorException.php b/vendor/php-http/client-common/src/Exception/ClientErrorException.php deleted file mode 100755 index b1f6cc855eba0e100f9701f6d7d66269984661e2..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Exception/ClientErrorException.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -namespace Http\Client\Common\Exception; - -use Http\Client\Exception\HttpException; - -/** - * Thrown when there is a client error (4xx). - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class ClientErrorException extends HttpException -{ -} diff --git a/vendor/php-http/client-common/src/Exception/HttpClientNotFoundException.php b/vendor/php-http/client-common/src/Exception/HttpClientNotFoundException.php deleted file mode 100755 index 5d33f9838360395298b9e8ca3ecfbc155f6b9b3f..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Exception/HttpClientNotFoundException.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -namespace Http\Client\Common\Exception; - -use Http\Client\Exception\TransferException; - -/** - * Thrown when a http client cannot be chosen in a pool. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class HttpClientNotFoundException extends TransferException -{ -} diff --git a/vendor/php-http/client-common/src/Exception/LoopException.php b/vendor/php-http/client-common/src/Exception/LoopException.php deleted file mode 100755 index e834124df607bbe10f381cb432598e668771ca7e..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Exception/LoopException.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -namespace Http\Client\Common\Exception; - -use Http\Client\Exception\RequestException; - -/** - * Thrown when the Plugin Client detects an endless loop. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class LoopException extends RequestException -{ -} diff --git a/vendor/php-http/client-common/src/Exception/MultipleRedirectionException.php b/vendor/php-http/client-common/src/Exception/MultipleRedirectionException.php deleted file mode 100755 index ae514cd738c64fa063284a5823e31e06124bdc45..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Exception/MultipleRedirectionException.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -namespace Http\Client\Common\Exception; - -use Http\Client\Exception\HttpException; - -/** - * Redirect location cannot be chosen. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class MultipleRedirectionException extends HttpException -{ -} diff --git a/vendor/php-http/client-common/src/Exception/ServerErrorException.php b/vendor/php-http/client-common/src/Exception/ServerErrorException.php deleted file mode 100755 index 665d72418b0b71403da4f8e8e6ce48c37bf38022..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Exception/ServerErrorException.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -namespace Http\Client\Common\Exception; - -use Http\Client\Exception\HttpException; - -/** - * Thrown when there is a server error (5xx). - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class ServerErrorException extends HttpException -{ -} diff --git a/vendor/php-http/client-common/src/FlexibleHttpClient.php b/vendor/php-http/client-common/src/FlexibleHttpClient.php deleted file mode 100755 index 58f88132d26f185881bf3bbf6e0b1f45b19842e7..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/FlexibleHttpClient.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -namespace Http\Client\Common; - -use Http\Client\HttpAsyncClient; -use Http\Client\HttpClient; - -/** - * A flexible http client, which implements both interface and will emulate - * one contract, the other, or none at all depending on the injected client contract. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class FlexibleHttpClient implements HttpClient, HttpAsyncClient -{ - use HttpClientDecorator; - use HttpAsyncClientDecorator; - - /** - * @param HttpClient|HttpAsyncClient $client - */ - public function __construct($client) - { - if (!($client instanceof HttpClient) && !($client instanceof HttpAsyncClient)) { - throw new \LogicException('Client must be an instance of Http\\Client\\HttpClient or Http\\Client\\HttpAsyncClient'); - } - - $this->httpClient = $client; - $this->httpAsyncClient = $client; - - if (!($this->httpClient instanceof HttpClient)) { - $this->httpClient = new EmulatedHttpClient($this->httpClient); - } - - if (!($this->httpAsyncClient instanceof HttpAsyncClient)) { - $this->httpAsyncClient = new EmulatedHttpAsyncClient($this->httpAsyncClient); - } - } -} diff --git a/vendor/php-http/client-common/src/HttpAsyncClientDecorator.php b/vendor/php-http/client-common/src/HttpAsyncClientDecorator.php deleted file mode 100755 index 6eb576cdb154bb59098cece31e8e0508aad5bdc6..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/HttpAsyncClientDecorator.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -namespace Http\Client\Common; - -use Http\Client\HttpAsyncClient; -use Psr\Http\Message\RequestInterface; - -/** - * Decorates an HTTP Async Client. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -trait HttpAsyncClientDecorator -{ - /** - * @var HttpAsyncClient - */ - protected $httpAsyncClient; - - /** - * {@inheritdoc} - * - * @see HttpAsyncClient::sendAsyncRequest - */ - public function sendAsyncRequest(RequestInterface $request) - { - return $this->httpAsyncClient->sendAsyncRequest($request); - } -} diff --git a/vendor/php-http/client-common/src/HttpAsyncClientEmulator.php b/vendor/php-http/client-common/src/HttpAsyncClientEmulator.php deleted file mode 100755 index c0ba354f87c401d2e70c13cefcceb00e153d018f..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/HttpAsyncClientEmulator.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -namespace Http\Client\Common; - -use Http\Client\Exception; -use Http\Client\Promise; -use Psr\Http\Message\RequestInterface; - -/** - * Emulates an HTTP Async Client in an HTTP Client. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -trait HttpAsyncClientEmulator -{ - /** - * {@inheritdoc} - * - * @see HttpClient::sendRequest - */ - abstract public function sendRequest(RequestInterface $request); - - /** - * {@inheritdoc} - * - * @see HttpAsyncClient::sendAsyncRequest - */ - public function sendAsyncRequest(RequestInterface $request) - { - try { - return new Promise\HttpFulfilledPromise($this->sendRequest($request)); - } catch (Exception $e) { - return new Promise\HttpRejectedPromise($e); - } - } -} diff --git a/vendor/php-http/client-common/src/HttpClientDecorator.php b/vendor/php-http/client-common/src/HttpClientDecorator.php deleted file mode 100755 index a33d5efd79eb717d8c55f237c48068672d715fde..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/HttpClientDecorator.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -namespace Http\Client\Common; - -use Http\Client\HttpClient; -use Psr\Http\Message\RequestInterface; - -/** - * Decorates an HTTP Client. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -trait HttpClientDecorator -{ - /** - * @var HttpClient - */ - protected $httpClient; - - /** - * {@inheritdoc} - * - * @see HttpClient::sendRequest - */ - public function sendRequest(RequestInterface $request) - { - return $this->httpClient->sendRequest($request); - } -} diff --git a/vendor/php-http/client-common/src/HttpClientEmulator.php b/vendor/php-http/client-common/src/HttpClientEmulator.php deleted file mode 100755 index dbec1aba330324dde3cb758ad79cb8f6cedb091f..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/HttpClientEmulator.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -namespace Http\Client\Common; - -use Psr\Http\Message\RequestInterface; - -/** - * Emulates an HTTP Client in an HTTP Async Client. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -trait HttpClientEmulator -{ - /** - * {@inheritdoc} - * - * @see HttpClient::sendRequest - */ - public function sendRequest(RequestInterface $request) - { - $promise = $this->sendAsyncRequest($request); - - return $promise->wait(); - } - - /** - * {@inheritdoc} - * - * @see HttpAsyncClient::sendAsyncRequest - */ - abstract public function sendAsyncRequest(RequestInterface $request); -} diff --git a/vendor/php-http/client-common/src/HttpClientPool.php b/vendor/php-http/client-common/src/HttpClientPool.php deleted file mode 100755 index 7ac292ca138fe31b4830268607e451bc6adfd5a4..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/HttpClientPool.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php - -namespace Http\Client\Common; - -use Http\Client\Common\Exception\HttpClientNotFoundException; -use Http\Client\HttpAsyncClient; -use Http\Client\HttpClient; -use Psr\Http\Message\RequestInterface; - -/** - * A http client pool allows to send requests on a pool of different http client using a specific strategy (least used, - * round robin, ...). - */ -abstract class HttpClientPool implements HttpAsyncClient, HttpClient -{ - /** - * @var HttpClientPoolItem[] - */ - protected $clientPool = []; - - /** - * Add a client to the pool. - * - * @param HttpClient|HttpAsyncClient|HttpClientPoolItem $client - */ - public function addHttpClient($client) - { - if (!$client instanceof HttpClientPoolItem) { - $client = new HttpClientPoolItem($client); - } - - $this->clientPool[] = $client; - } - - /** - * Return an http client given a specific strategy. - * - * @throws HttpClientNotFoundException When no http client has been found into the pool - * - * @return HttpClientPoolItem Return a http client that can do both sync or async - */ - abstract protected function chooseHttpClient(); - - /** - * {@inheritdoc} - */ - public function sendAsyncRequest(RequestInterface $request) - { - return $this->chooseHttpClient()->sendAsyncRequest($request); - } - - /** - * {@inheritdoc} - */ - public function sendRequest(RequestInterface $request) - { - return $this->chooseHttpClient()->sendRequest($request); - } -} diff --git a/vendor/php-http/client-common/src/HttpClientPool/LeastUsedClientPool.php b/vendor/php-http/client-common/src/HttpClientPool/LeastUsedClientPool.php deleted file mode 100755 index 6299cceb60fafb9f70e89ea0323f2ba0d38f7647..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/HttpClientPool/LeastUsedClientPool.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php - -namespace Http\Client\Common\HttpClientPool; - -use Http\Client\Common\Exception\HttpClientNotFoundException; -use Http\Client\Common\HttpClientPool; -use Http\Client\Common\HttpClientPoolItem; - -/** - * LeastUsedClientPool will choose the client with the less current request in the pool. - * - * This strategy is only useful when doing async request - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class LeastUsedClientPool extends HttpClientPool -{ - /** - * {@inheritdoc} - */ - protected function chooseHttpClient() - { - $clientPool = array_filter($this->clientPool, function (HttpClientPoolItem $clientPoolItem) { - return !$clientPoolItem->isDisabled(); - }); - - if (0 === count($clientPool)) { - throw new HttpClientNotFoundException('Cannot choose a http client as there is no one present in the pool'); - } - - usort($clientPool, function (HttpClientPoolItem $clientA, HttpClientPoolItem $clientB) { - if ($clientA->getSendingRequestCount() === $clientB->getSendingRequestCount()) { - return 0; - } - - if ($clientA->getSendingRequestCount() < $clientB->getSendingRequestCount()) { - return -1; - } - - return 1; - }); - - return reset($clientPool); - } -} diff --git a/vendor/php-http/client-common/src/HttpClientPool/RandomClientPool.php b/vendor/php-http/client-common/src/HttpClientPool/RandomClientPool.php deleted file mode 100755 index 3255f865df369dfb2a6d388d28a3705390048274..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/HttpClientPool/RandomClientPool.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php - -namespace Http\Client\Common\HttpClientPool; - -use Http\Client\Common\Exception\HttpClientNotFoundException; -use Http\Client\Common\HttpClientPool; -use Http\Client\Common\HttpClientPoolItem; - -/** - * RoundRobinClientPool will choose the next client in the pool. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class RandomClientPool extends HttpClientPool -{ - /** - * {@inheritdoc} - */ - protected function chooseHttpClient() - { - $clientPool = array_filter($this->clientPool, function (HttpClientPoolItem $clientPoolItem) { - return !$clientPoolItem->isDisabled(); - }); - - if (0 === count($clientPool)) { - throw new HttpClientNotFoundException('Cannot choose a http client as there is no one present in the pool'); - } - - return $clientPool[array_rand($clientPool)]; - } -} diff --git a/vendor/php-http/client-common/src/HttpClientPool/RoundRobinClientPool.php b/vendor/php-http/client-common/src/HttpClientPool/RoundRobinClientPool.php deleted file mode 100755 index 8d8e40a013b036621ae0a9ef6729e7812bc04f3f..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/HttpClientPool/RoundRobinClientPool.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -namespace Http\Client\Common\HttpClientPool; - -use Http\Client\Common\Exception\HttpClientNotFoundException; -use Http\Client\Common\HttpClientPool; - -/** - * RoundRobinClientPool will choose the next client in the pool. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class RoundRobinClientPool extends HttpClientPool -{ - /** - * {@inheritdoc} - */ - protected function chooseHttpClient() - { - $last = current($this->clientPool); - - do { - $client = next($this->clientPool); - - if (false === $client) { - $client = reset($this->clientPool); - - if (false === $client) { - throw new HttpClientNotFoundException('Cannot choose a http client as there is no one present in the pool'); - } - } - - // Case when there is only one and the last one has been disabled - if ($last === $client && $client->isDisabled()) { - throw new HttpClientNotFoundException('Cannot choose a http client as there is no one enabled in the pool'); - } - } while ($client->isDisabled()); - - return $client; - } -} diff --git a/vendor/php-http/client-common/src/HttpClientPoolItem.php b/vendor/php-http/client-common/src/HttpClientPoolItem.php deleted file mode 100755 index 09cd6ddf1c96f4bea9817b25c2d1544497dcc617..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/HttpClientPoolItem.php +++ /dev/null @@ -1,178 +0,0 @@ -<?php - -namespace Http\Client\Common; - -use Http\Client\HttpAsyncClient; -use Http\Client\HttpClient; -use Psr\Http\Message\RequestInterface; -use Http\Client\Exception; - -/** - * A HttpClientPoolItem represent a HttpClient inside a Pool. - * - * It is disabled when a request failed and can be reenable after a certain number of seconds - * It also keep tracks of the current number of request the client is currently sending (only usable for async method) - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class HttpClientPoolItem implements HttpClient, HttpAsyncClient -{ - /** - * @var int Number of request this client is currently sending - */ - private $sendingRequestCount = 0; - - /** - * @var \DateTime|null Time when this client has been disabled or null if enable - */ - private $disabledAt; - - /** - * @var int|null Number of seconds after this client is reenable, by default null: never reenable this client - */ - private $reenableAfter; - - /** - * @var FlexibleHttpClient A http client responding to async and sync request - */ - private $client; - - /** - * @param HttpClient|HttpAsyncClient $client - * @param null|int $reenableAfter Number of seconds after this client is reenable - */ - public function __construct($client, $reenableAfter = null) - { - $this->client = new FlexibleHttpClient($client); - $this->reenableAfter = $reenableAfter; - } - - /** - * {@inheritdoc} - */ - public function sendRequest(RequestInterface $request) - { - if ($this->isDisabled()) { - throw new Exception\RequestException('Cannot send the request as this client has been disabled', $request); - } - - try { - $this->incrementRequestCount(); - $response = $this->client->sendRequest($request); - $this->decrementRequestCount(); - } catch (Exception $e) { - $this->disable(); - $this->decrementRequestCount(); - - throw $e; - } - - return $response; - } - - /** - * {@inheritdoc} - */ - public function sendAsyncRequest(RequestInterface $request) - { - if ($this->isDisabled()) { - throw new Exception\RequestException('Cannot send the request as this client has been disabled', $request); - } - - $this->incrementRequestCount(); - - return $this->client->sendAsyncRequest($request)->then(function ($response) { - $this->decrementRequestCount(); - - return $response; - }, function ($exception) { - $this->disable(); - $this->decrementRequestCount(); - - throw $exception; - }); - } - - /** - * Whether this client is disabled or not. - * - * Will also reactivate this client if possible - * - * @internal - * - * @return bool - */ - public function isDisabled() - { - $disabledAt = $this->getDisabledAt(); - - if (null !== $this->reenableAfter && null !== $disabledAt) { - // Reenable after a certain time - $now = new \DateTime(); - - if (($now->getTimestamp() - $disabledAt->getTimestamp()) >= $this->reenableAfter) { - $this->enable(); - - return false; - } - - return true; - } - - return null !== $disabledAt; - } - - /** - * Get current number of request that is send by the underlying http client. - * - * @internal - * - * @return int - */ - public function getSendingRequestCount() - { - return $this->sendingRequestCount; - } - - /** - * Return when this client has been disabled or null if it's enabled. - * - * @return \DateTime|null - */ - private function getDisabledAt() - { - return $this->disabledAt; - } - - /** - * Increment the request count. - */ - private function incrementRequestCount() - { - ++$this->sendingRequestCount; - } - - /** - * Decrement the request count. - */ - private function decrementRequestCount() - { - --$this->sendingRequestCount; - } - - /** - * Enable the current client. - */ - private function enable() - { - $this->disabledAt = null; - } - - /** - * Disable the current client. - */ - private function disable() - { - $this->disabledAt = new \DateTime('now'); - } -} diff --git a/vendor/php-http/client-common/src/HttpClientRouter.php b/vendor/php-http/client-common/src/HttpClientRouter.php deleted file mode 100755 index 9f721336a172a5ab3f75fe70899a9081503f4618..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/HttpClientRouter.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php - -namespace Http\Client\Common; - -use Http\Client\Exception\RequestException; -use Http\Client\HttpAsyncClient; -use Http\Client\HttpClient; -use Http\Message\RequestMatcher; -use Psr\Http\Message\RequestInterface; - -/** - * Route a request to a specific client in the stack based using a RequestMatcher. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class HttpClientRouter implements HttpClient, HttpAsyncClient -{ - /** - * @var array - */ - private $clients = []; - - /** - * {@inheritdoc} - */ - public function sendRequest(RequestInterface $request) - { - $client = $this->chooseHttpClient($request); - - return $client->sendRequest($request); - } - - /** - * {@inheritdoc} - */ - public function sendAsyncRequest(RequestInterface $request) - { - $client = $this->chooseHttpClient($request); - - return $client->sendAsyncRequest($request); - } - - /** - * Add a client to the router. - * - * @param HttpClient|HttpAsyncClient $client - * @param RequestMatcher $requestMatcher - */ - public function addClient($client, RequestMatcher $requestMatcher) - { - $this->clients[] = [ - 'matcher' => $requestMatcher, - 'client' => new FlexibleHttpClient($client), - ]; - } - - /** - * Choose an HTTP client given a specific request. - * - * @param RequestInterface $request - * - * @return HttpClient|HttpAsyncClient - */ - protected function chooseHttpClient(RequestInterface $request) - { - foreach ($this->clients as $client) { - if ($client['matcher']->matches($request)) { - return $client['client']; - } - } - - throw new RequestException('No client found for the specified request', $request); - } -} diff --git a/vendor/php-http/client-common/src/HttpMethodsClient.php b/vendor/php-http/client-common/src/HttpMethodsClient.php deleted file mode 100755 index 58804fc243f89c9a3a78d16fa0d3200c66c020d6..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/HttpMethodsClient.php +++ /dev/null @@ -1,205 +0,0 @@ -<?php - -namespace Http\Client\Common; - -use Http\Client\Exception; -use Http\Client\HttpClient; -use Http\Message\RequestFactory; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\StreamInterface; -use Psr\Http\Message\UriInterface; - -/** - * Convenience HTTP client that integrates the MessageFactory in order to send - * requests in the following form:. - * - * $client - * ->get('/foo') - * ->post('/bar') - * ; - * - * The client also exposes the sendRequest methods of the wrapped HttpClient. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - * @author David Buchmann <mail@davidbu.ch> - */ -class HttpMethodsClient implements HttpClient -{ - /** - * @var HttpClient - */ - private $httpClient; - - /** - * @var RequestFactory - */ - private $requestFactory; - - /** - * @param HttpClient $httpClient The client to send requests with - * @param RequestFactory $requestFactory The message factory to create requests - */ - public function __construct(HttpClient $httpClient, RequestFactory $requestFactory) - { - $this->httpClient = $httpClient; - $this->requestFactory = $requestFactory; - } - - /** - * Sends a GET request. - * - * @param string|UriInterface $uri - * @param array $headers - * - * @throws Exception - * - * @return ResponseInterface - */ - public function get($uri, array $headers = []) - { - return $this->send('GET', $uri, $headers, null); - } - - /** - * Sends an HEAD request. - * - * @param string|UriInterface $uri - * @param array $headers - * - * @throws Exception - * - * @return ResponseInterface - */ - public function head($uri, array $headers = []) - { - return $this->send('HEAD', $uri, $headers, null); - } - - /** - * Sends a TRACE request. - * - * @param string|UriInterface $uri - * @param array $headers - * - * @throws Exception - * - * @return ResponseInterface - */ - public function trace($uri, array $headers = []) - { - return $this->send('TRACE', $uri, $headers, null); - } - - /** - * Sends a POST request. - * - * @param string|UriInterface $uri - * @param array $headers - * @param string|StreamInterface|null $body - * - * @throws Exception - * - * @return ResponseInterface - */ - public function post($uri, array $headers = [], $body = null) - { - return $this->send('POST', $uri, $headers, $body); - } - - /** - * Sends a PUT request. - * - * @param string|UriInterface $uri - * @param array $headers - * @param string|StreamInterface|null $body - * - * @throws Exception - * - * @return ResponseInterface - */ - public function put($uri, array $headers = [], $body = null) - { - return $this->send('PUT', $uri, $headers, $body); - } - - /** - * Sends a PATCH request. - * - * @param string|UriInterface $uri - * @param array $headers - * @param string|StreamInterface|null $body - * - * @throws Exception - * - * @return ResponseInterface - */ - public function patch($uri, array $headers = [], $body = null) - { - return $this->send('PATCH', $uri, $headers, $body); - } - - /** - * Sends a DELETE request. - * - * @param string|UriInterface $uri - * @param array $headers - * @param string|StreamInterface|null $body - * - * @throws Exception - * - * @return ResponseInterface - */ - public function delete($uri, array $headers = [], $body = null) - { - return $this->send('DELETE', $uri, $headers, $body); - } - - /** - * Sends an OPTIONS request. - * - * @param string|UriInterface $uri - * @param array $headers - * @param string|StreamInterface|null $body - * - * @throws Exception - * - * @return ResponseInterface - */ - public function options($uri, array $headers = [], $body = null) - { - return $this->send('OPTIONS', $uri, $headers, $body); - } - - /** - * Sends a request with any HTTP method. - * - * @param string $method HTTP method to use - * @param string|UriInterface $uri - * @param array $headers - * @param string|StreamInterface|null $body - * - * @throws Exception - * - * @return ResponseInterface - */ - public function send($method, $uri, array $headers = [], $body = null) - { - return $this->sendRequest($this->requestFactory->createRequest( - $method, - $uri, - $headers, - $body - )); - } - - /** - * Forward to the underlying HttpClient. - * - * {@inheritdoc} - */ - public function sendRequest(RequestInterface $request) - { - return $this->httpClient->sendRequest($request); - } -} diff --git a/vendor/php-http/client-common/src/Plugin.php b/vendor/php-http/client-common/src/Plugin.php deleted file mode 100755 index 89a2a622d46c69f9a7ffb47042c4667e46ef556f..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -namespace Http\Client\Common; - -use Http\Promise\Promise; -use Psr\Http\Message\RequestInterface; - -/** - * A plugin is a middleware to transform the request and/or the response. - * - * The plugin can: - * - break the chain and return a response - * - dispatch the request to the next middleware - * - restart the request - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -interface Plugin -{ - /** - * Handle the request and return the response coming from the next callable. - * - * @see http://docs.php-http.org/en/latest/plugins/build-your-own.html - * - * @param RequestInterface $request - * @param callable $next Next middleware in the chain, the request is passed as the first argument - * @param callable $first First middleware in the chain, used to to restart a request - * - * @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception (The same as HttpAsyncClient). - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first); -} diff --git a/vendor/php-http/client-common/src/Plugin/AddHostPlugin.php b/vendor/php-http/client-common/src/Plugin/AddHostPlugin.php deleted file mode 100755 index 29ab8ae84097e9c6ad748d0acba3db2f3911a8b4..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/AddHostPlugin.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Plugin; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\UriInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Add schema, host and port to a request. Can be set to overwrite the schema and host if desired. - * - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -final class AddHostPlugin implements Plugin -{ - /** - * @var UriInterface - */ - private $host; - - /** - * @var bool - */ - private $replace; - - /** - * @param UriInterface $host - * @param array $config { - * - * @var bool $replace True will replace all hosts, false will only add host when none is specified. - * } - */ - public function __construct(UriInterface $host, array $config = []) - { - if ('' === $host->getHost()) { - throw new \LogicException('Host can not be empty'); - } - - $this->host = $host; - - $resolver = new OptionsResolver(); - $this->configureOptions($resolver); - $options = $resolver->resolve($config); - - $this->replace = $options['replace']; - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - if ($this->replace || '' === $request->getUri()->getHost()) { - $uri = $request->getUri() - ->withHost($this->host->getHost()) - ->withScheme($this->host->getScheme()) - ->withPort($this->host->getPort()) - ; - - $request = $request->withUri($uri); - } - - return $next($request); - } - - /** - * @param OptionsResolver $resolver - */ - private function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'replace' => false, - ]); - $resolver->setAllowedTypes('replace', 'bool'); - } -} diff --git a/vendor/php-http/client-common/src/Plugin/AddPathPlugin.php b/vendor/php-http/client-common/src/Plugin/AddPathPlugin.php deleted file mode 100755 index e24d61a4e42a89c60e4ed07c54c93e31b949533d..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/AddPathPlugin.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Plugin; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\UriInterface; - -/** - * Prepend a base path to the request URI. Useful for base API URLs like http://domain.com/api. - * - * @author Sullivan Senechal <soullivaneuh@gmail.com> - */ -final class AddPathPlugin implements Plugin -{ - /** - * @var UriInterface - */ - private $uri; - - /** - * @param UriInterface $uri - */ - public function __construct(UriInterface $uri) - { - if ('' === $uri->getPath()) { - throw new \LogicException('URI path cannot be empty'); - } - - if ('/' === substr($uri->getPath(), -1)) { - throw new \LogicException('URI path cannot end with a slash.'); - } - - $this->uri = $uri; - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - $request = $request->withUri($request->getUri() - ->withPath($this->uri->getPath().$request->getUri()->getPath()) - ); - - return $next($request); - } -} diff --git a/vendor/php-http/client-common/src/Plugin/AuthenticationPlugin.php b/vendor/php-http/client-common/src/Plugin/AuthenticationPlugin.php deleted file mode 100755 index 194712fcde024fa81991162084fa041c6fae2827..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/AuthenticationPlugin.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Plugin; -use Http\Message\Authentication; -use Psr\Http\Message\RequestInterface; - -/** - * Send an authenticated request. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class AuthenticationPlugin implements Plugin -{ - /** - * @var Authentication An authentication system - */ - private $authentication; - - /** - * @param Authentication $authentication - */ - public function __construct(Authentication $authentication) - { - $this->authentication = $authentication; - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - $request = $this->authentication->authenticate($request); - - return $next($request); - } -} diff --git a/vendor/php-http/client-common/src/Plugin/BaseUriPlugin.php b/vendor/php-http/client-common/src/Plugin/BaseUriPlugin.php deleted file mode 100755 index 2c2a7752cf466b2a8061dd1093970c59687317b3..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/BaseUriPlugin.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Plugin; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\UriInterface; - -/** - * Combines the AddHostPlugin and AddPathPlugin. - * - * @author Sullivan Senechal <soullivaneuh@gmail.com> - */ -final class BaseUriPlugin implements Plugin -{ - /** - * @var AddHostPlugin - */ - private $addHostPlugin; - - /** - * @var AddPathPlugin|null - */ - private $addPathPlugin = null; - - /** - * @param UriInterface $uri Has to contain a host name and cans have a path. - * @param array $hostConfig Config for AddHostPlugin. @see AddHostPlugin::configureOptions - */ - public function __construct(UriInterface $uri, array $hostConfig = []) - { - $this->addHostPlugin = new AddHostPlugin($uri, $hostConfig); - - if (rtrim($uri->getPath(), '/')) { - $this->addPathPlugin = new AddPathPlugin($uri); - } - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - $addHostNext = function (RequestInterface $request) use ($next, $first) { - return $this->addHostPlugin->handleRequest($request, $next, $first); - }; - - if ($this->addPathPlugin) { - return $this->addPathPlugin->handleRequest($request, $addHostNext, $first); - } - - return $addHostNext($request); - } -} diff --git a/vendor/php-http/client-common/src/Plugin/ContentLengthPlugin.php b/vendor/php-http/client-common/src/Plugin/ContentLengthPlugin.php deleted file mode 100755 index 0f7aafaeda3197f4571dabd6996b22e2f4e26eec..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/ContentLengthPlugin.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Plugin; -use Http\Message\Encoding\ChunkStream; -use Psr\Http\Message\RequestInterface; - -/** - * Allow to set the correct content length header on the request or to transfer it as a chunk if not possible. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class ContentLengthPlugin implements Plugin -{ - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - if (!$request->hasHeader('Content-Length')) { - $stream = $request->getBody(); - - // Cannot determine the size so we use a chunk stream - if (null === $stream->getSize()) { - $stream = new ChunkStream($stream); - $request = $request->withBody($stream); - $request = $request->withAddedHeader('Transfer-Encoding', 'chunked'); - } else { - $request = $request->withHeader('Content-Length', (string) $stream->getSize()); - } - } - - return $next($request); - } -} diff --git a/vendor/php-http/client-common/src/Plugin/ContentTypePlugin.php b/vendor/php-http/client-common/src/Plugin/ContentTypePlugin.php deleted file mode 100755 index 8ef1d62b34b0dd36cbf21769fda7b4d8de37088b..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/ContentTypePlugin.php +++ /dev/null @@ -1,123 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Plugin; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\StreamInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Allow to set the correct content type header on the request automatically only if it is not set. - * - * @author Karim Pinchon <karim.pinchon@gmail.com> - */ -final class ContentTypePlugin implements Plugin -{ - /** - * Allow to disable the content type detection when stream is too large (as it can consume a lot of resource). - * - * @var bool - * - * true skip the content type detection - * false detect the content type (default value) - */ - protected $skipDetection; - - /** - * Determine the size stream limit for which the detection as to be skipped (default to 16Mb). - * - * @var int - */ - protected $sizeLimit; - - /** - * @param array $config { - * - * @var bool $skip_detection True skip detection if stream size is bigger than $size_limit. - * @var int $size_limit size stream limit for which the detection as to be skipped. - * } - */ - public function __construct(array $config = []) - { - $resolver = new OptionsResolver(); - $resolver->setDefaults([ - 'skip_detection' => false, - 'size_limit' => 16000000, - ]); - $resolver->setAllowedTypes('skip_detection', 'bool'); - $resolver->setAllowedTypes('size_limit', 'int'); - - $options = $resolver->resolve($config); - - $this->skipDetection = $options['skip_detection']; - $this->sizeLimit = $options['size_limit']; - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - if (!$request->hasHeader('Content-Type')) { - $stream = $request->getBody(); - $streamSize = $stream->getSize(); - - if (!$stream->isSeekable()) { - return $next($request); - } - - if (0 === $streamSize) { - return $next($request); - } - - if ($this->skipDetection && (null === $streamSize || $streamSize >= $this->sizeLimit)) { - return $next($request); - } - - if ($this->isJson($stream)) { - $request = $request->withHeader('Content-Type', 'application/json'); - - return $next($request); - } - - if ($this->isXml($stream)) { - $request = $request->withHeader('Content-Type', 'application/xml'); - - return $next($request); - } - } - - return $next($request); - } - - /** - * @param $stream StreamInterface - * - * @return bool - */ - private function isJson($stream) - { - $stream->rewind(); - - json_decode($stream->getContents()); - - return JSON_ERROR_NONE === json_last_error(); - } - - /** - * @param $stream StreamInterface - * - * @return \SimpleXMLElement|false - */ - private function isXml($stream) - { - $stream->rewind(); - - $previousValue = libxml_use_internal_errors(true); - $isXml = simplexml_load_string($stream->getContents()); - libxml_use_internal_errors($previousValue); - - return $isXml; - } -} diff --git a/vendor/php-http/client-common/src/Plugin/CookiePlugin.php b/vendor/php-http/client-common/src/Plugin/CookiePlugin.php deleted file mode 100755 index 59ee90da19d21ea442596a95fa427c630bc41874..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/CookiePlugin.php +++ /dev/null @@ -1,180 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Plugin; -use Http\Client\Exception\TransferException; -use Http\Message\Cookie; -use Http\Message\CookieJar; -use Http\Message\CookieUtil; -use Http\Message\Exception\UnexpectedValueException; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Handle request cookies. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class CookiePlugin implements Plugin -{ - /** - * Cookie storage. - * - * @var CookieJar - */ - private $cookieJar; - - /** - * @param CookieJar $cookieJar - */ - public function __construct(CookieJar $cookieJar) - { - $this->cookieJar = $cookieJar; - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - foreach ($this->cookieJar->getCookies() as $cookie) { - if ($cookie->isExpired()) { - continue; - } - - if (!$cookie->matchDomain($request->getUri()->getHost())) { - continue; - } - - if (!$cookie->matchPath($request->getUri()->getPath())) { - continue; - } - - if ($cookie->isSecure() && ('https' !== $request->getUri()->getScheme())) { - continue; - } - - $request = $request->withAddedHeader('Cookie', sprintf('%s=%s', $cookie->getName(), $cookie->getValue())); - } - - return $next($request)->then(function (ResponseInterface $response) use ($request) { - if ($response->hasHeader('Set-Cookie')) { - $setCookies = $response->getHeader('Set-Cookie'); - - foreach ($setCookies as $setCookie) { - $cookie = $this->createCookie($request, $setCookie); - - // Cookie invalid do not use it - if (null === $cookie) { - continue; - } - - // Restrict setting cookie from another domain - if (!preg_match("/\.{$cookie->getDomain()}$/", '.'.$request->getUri()->getHost())) { - continue; - } - - $this->cookieJar->addCookie($cookie); - } - } - - return $response; - }); - } - - /** - * Creates a cookie from a string. - * - * @param RequestInterface $request - * @param $setCookie - * - * @return Cookie|null - * - * @throws TransferException - */ - private function createCookie(RequestInterface $request, $setCookie) - { - $parts = array_map('trim', explode(';', $setCookie)); - - if (empty($parts) || !strpos($parts[0], '=')) { - return; - } - - list($name, $cookieValue) = $this->createValueKey(array_shift($parts)); - - $maxAge = null; - $expires = null; - $domain = $request->getUri()->getHost(); - $path = $request->getUri()->getPath(); - $secure = false; - $httpOnly = false; - - // Add the cookie pieces into the parsed data array - foreach ($parts as $part) { - list($key, $value) = $this->createValueKey($part); - - switch (strtolower($key)) { - case 'expires': - try { - $expires = CookieUtil::parseDate($value); - } catch (UnexpectedValueException $e) { - throw new TransferException( - sprintf( - 'Cookie header `%s` expires value `%s` could not be converted to date', - $name, - $value - ), - null, - $e - ); - } - - break; - - case 'max-age': - $maxAge = (int) $value; - - break; - - case 'domain': - $domain = $value; - - break; - - case 'path': - $path = $value; - - break; - - case 'secure': - $secure = true; - - break; - - case 'httponly': - $httpOnly = true; - - break; - } - } - - return new Cookie($name, $cookieValue, $maxAge, $domain, $path, $secure, $httpOnly, $expires); - } - - /** - * Separates key/value pair from cookie. - * - * @param $part - * - * @return array - */ - private function createValueKey($part) - { - $parts = explode('=', $part, 2); - $key = trim($parts[0]); - $value = isset($parts[1]) ? trim($parts[1]) : true; - - return [$key, $value]; - } -} diff --git a/vendor/php-http/client-common/src/Plugin/DecoderPlugin.php b/vendor/php-http/client-common/src/Plugin/DecoderPlugin.php deleted file mode 100755 index b661b613ac72a6235f272bdcfb8a5660a95a24e0..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/DecoderPlugin.php +++ /dev/null @@ -1,140 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Plugin; -use Http\Message\Encoding; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\StreamInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Allow to decode response body with a chunk, deflate, compress or gzip encoding. - * - * If zlib is not installed, only chunked encoding can be handled. - * - * If Content-Encoding is not disabled, the plugin will add an Accept-Encoding header for the encoding methods it supports. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class DecoderPlugin implements Plugin -{ - /** - * @var bool Whether this plugin decode stream with value in the Content-Encoding header (default to true). - * - * If set to false only the Transfer-Encoding header will be used - */ - private $useContentEncoding; - - /** - * @param array $config { - * - * @var bool $use_content_encoding Whether this plugin should look at the Content-Encoding header first or only at the Transfer-Encoding (defaults to true). - * } - */ - public function __construct(array $config = []) - { - $resolver = new OptionsResolver(); - $resolver->setDefaults([ - 'use_content_encoding' => true, - ]); - $resolver->setAllowedTypes('use_content_encoding', 'bool'); - $options = $resolver->resolve($config); - - $this->useContentEncoding = $options['use_content_encoding']; - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - $encodings = extension_loaded('zlib') ? ['gzip', 'deflate'] : ['identity']; - - if ($this->useContentEncoding) { - $request = $request->withHeader('Accept-Encoding', $encodings); - } - $encodings[] = 'chunked'; - $request = $request->withHeader('TE', $encodings); - - return $next($request)->then(function (ResponseInterface $response) { - return $this->decodeResponse($response); - }); - } - - /** - * Decode a response body given its Transfer-Encoding or Content-Encoding value. - * - * @param ResponseInterface $response Response to decode - * - * @return ResponseInterface New response decoded - */ - private function decodeResponse(ResponseInterface $response) - { - $response = $this->decodeOnEncodingHeader('Transfer-Encoding', $response); - - if ($this->useContentEncoding) { - $response = $this->decodeOnEncodingHeader('Content-Encoding', $response); - } - - return $response; - } - - /** - * Decode a response on a specific header (content encoding or transfer encoding mainly). - * - * @param string $headerName Name of the header - * @param ResponseInterface $response Response - * - * @return ResponseInterface A new instance of the response decoded - */ - private function decodeOnEncodingHeader($headerName, ResponseInterface $response) - { - if ($response->hasHeader($headerName)) { - $encodings = $response->getHeader($headerName); - $newEncodings = []; - - while ($encoding = array_pop($encodings)) { - $stream = $this->decorateStream($encoding, $response->getBody()); - - if (false === $stream) { - array_unshift($newEncodings, $encoding); - - continue; - } - - $response = $response->withBody($stream); - } - - $response = $response->withHeader($headerName, $newEncodings); - } - - return $response; - } - - /** - * Decorate a stream given an encoding. - * - * @param string $encoding - * @param StreamInterface $stream - * - * @return StreamInterface|false A new stream interface or false if encoding is not supported - */ - private function decorateStream($encoding, StreamInterface $stream) - { - if ('chunked' === strtolower($encoding)) { - return new Encoding\DechunkStream($stream); - } - - if ('deflate' === strtolower($encoding)) { - return new Encoding\DecompressStream($stream); - } - - if ('gzip' === strtolower($encoding)) { - return new Encoding\GzipDecodeStream($stream); - } - - return false; - } -} diff --git a/vendor/php-http/client-common/src/Plugin/ErrorPlugin.php b/vendor/php-http/client-common/src/Plugin/ErrorPlugin.php deleted file mode 100755 index f09d3b161a8883947e2ba6458a46a20c676ba38f..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/ErrorPlugin.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Exception\ClientErrorException; -use Http\Client\Common\Exception\ServerErrorException; -use Http\Client\Common\Plugin; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Throw exception when the response of a request is not acceptable. - * - * Status codes 400-499 lead to a ClientErrorException, status 500-599 to a ServerErrorException. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class ErrorPlugin implements Plugin -{ - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - $promise = $next($request); - - return $promise->then(function (ResponseInterface $response) use ($request) { - return $this->transformResponseToException($request, $response); - }); - } - - /** - * Transform response to an error if possible. - * - * @param RequestInterface $request Request of the call - * @param ResponseInterface $response Response of the call - * - * @throws ClientErrorException If response status code is a 4xx - * @throws ServerErrorException If response status code is a 5xx - * - * @return ResponseInterface If status code is not in 4xx or 5xx return response - */ - protected function transformResponseToException(RequestInterface $request, ResponseInterface $response) - { - if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 500) { - throw new ClientErrorException($response->getReasonPhrase(), $request, $response); - } - - if ($response->getStatusCode() >= 500 && $response->getStatusCode() < 600) { - throw new ServerErrorException($response->getReasonPhrase(), $request, $response); - } - - return $response; - } -} diff --git a/vendor/php-http/client-common/src/Plugin/HeaderAppendPlugin.php b/vendor/php-http/client-common/src/Plugin/HeaderAppendPlugin.php deleted file mode 100755 index 26fd813458564a612d2730ec0735a9ca3930b362..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/HeaderAppendPlugin.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Plugin; -use Psr\Http\Message\RequestInterface; - -/** - * Append headers to the request. - * - * If the header already exists the value will be appended to the current value. - * - * This only makes sense for headers that can have multiple values like 'Forwarded' - * - * @see https://en.wikipedia.org/wiki/List_of_HTTP_header_fields - * - * @author Soufiane Ghzal <sghzal@gmail.com> - */ -final class HeaderAppendPlugin implements Plugin -{ - /** - * @var array - */ - private $headers = []; - - /** - * @param array $headers Hashmap of header name to header value - */ - public function __construct(array $headers) - { - $this->headers = $headers; - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - foreach ($this->headers as $header => $headerValue) { - $request = $request->withAddedHeader($header, $headerValue); - } - - return $next($request); - } -} diff --git a/vendor/php-http/client-common/src/Plugin/HeaderDefaultsPlugin.php b/vendor/php-http/client-common/src/Plugin/HeaderDefaultsPlugin.php deleted file mode 100755 index 6dfc1115a06a099d641b90aa2eb1e9357f2d5d71..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/HeaderDefaultsPlugin.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Plugin; -use Psr\Http\Message\RequestInterface; - -/** - * Set header to default value if it does not exist. - * - * If a given header already exists the value wont be replaced and the request wont be changed. - * - * @author Soufiane Ghzal <sghzal@gmail.com> - */ -final class HeaderDefaultsPlugin implements Plugin -{ - /** - * @var array - */ - private $headers = []; - - /** - * @param array $headers Hashmap of header name to header value - */ - public function __construct(array $headers) - { - $this->headers = $headers; - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - foreach ($this->headers as $header => $headerValue) { - if (!$request->hasHeader($header)) { - $request = $request->withHeader($header, $headerValue); - } - } - - return $next($request); - } -} diff --git a/vendor/php-http/client-common/src/Plugin/HeaderRemovePlugin.php b/vendor/php-http/client-common/src/Plugin/HeaderRemovePlugin.php deleted file mode 100755 index fc9c19d1aadabf34c1287a9ed97b78f78ebbbc74..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/HeaderRemovePlugin.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Plugin; -use Psr\Http\Message\RequestInterface; - -/** - * Removes headers from the request. - * - * @author Soufiane Ghzal <sghzal@gmail.com> - */ -final class HeaderRemovePlugin implements Plugin -{ - /** - * @var array - */ - private $headers = []; - - /** - * @param array $headers List of header names to remove from the request - */ - public function __construct(array $headers) - { - $this->headers = $headers; - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - foreach ($this->headers as $header) { - if ($request->hasHeader($header)) { - $request = $request->withoutHeader($header); - } - } - - return $next($request); - } -} diff --git a/vendor/php-http/client-common/src/Plugin/HeaderSetPlugin.php b/vendor/php-http/client-common/src/Plugin/HeaderSetPlugin.php deleted file mode 100755 index 75f11d40aaae9c7ded7edf960b1dcc99deae9bd8..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/HeaderSetPlugin.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Plugin; -use Psr\Http\Message\RequestInterface; - -/** - * Set headers on the request. - * - * If the header does not exist it wil be set, if the header already exists it will be replaced. - * - * @author Soufiane Ghzal <sghzal@gmail.com> - */ -final class HeaderSetPlugin implements Plugin -{ - /** - * @var array - */ - private $headers = []; - - /** - * @param array $headers Hashmap of header name to header value - */ - public function __construct(array $headers) - { - $this->headers = $headers; - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - foreach ($this->headers as $header => $headerValue) { - $request = $request->withHeader($header, $headerValue); - } - - return $next($request); - } -} diff --git a/vendor/php-http/client-common/src/Plugin/HistoryPlugin.php b/vendor/php-http/client-common/src/Plugin/HistoryPlugin.php deleted file mode 100755 index 5abddbd84128d6a95617ed2410d3b6817736a884..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/HistoryPlugin.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Plugin; -use Http\Client\Exception; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Record HTTP calls. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class HistoryPlugin implements Plugin -{ - /** - * Journal use to store request / responses / exception. - * - * @var Journal - */ - private $journal; - - /** - * @param Journal $journal - */ - public function __construct(Journal $journal) - { - $this->journal = $journal; - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - $journal = $this->journal; - - return $next($request)->then(function (ResponseInterface $response) use ($request, $journal) { - $journal->addSuccess($request, $response); - - return $response; - }, function (Exception $exception) use ($request, $journal) { - $journal->addFailure($request, $exception); - - throw $exception; - }); - } -} diff --git a/vendor/php-http/client-common/src/Plugin/Journal.php b/vendor/php-http/client-common/src/Plugin/Journal.php deleted file mode 100755 index 15f309569fb9842a58ed0c13feb27374f26de40f..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/Journal.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Exception; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Records history of HTTP calls. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -interface Journal -{ - /** - * Record a successful call. - * - * @param RequestInterface $request Request use to make the call - * @param ResponseInterface $response Response returned by the call - */ - public function addSuccess(RequestInterface $request, ResponseInterface $response); - - /** - * Record a failed call. - * - * @param RequestInterface $request Request use to make the call - * @param Exception $exception Exception returned by the call - */ - public function addFailure(RequestInterface $request, Exception $exception); -} diff --git a/vendor/php-http/client-common/src/Plugin/QueryDefaultsPlugin.php b/vendor/php-http/client-common/src/Plugin/QueryDefaultsPlugin.php deleted file mode 100755 index 6c1e32cd307fefe0960c80bf1e6ce57dab518d34..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/QueryDefaultsPlugin.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Plugin; -use Psr\Http\Message\RequestInterface; - -/** - * Set query to default value if it does not exist. - * - * If a given query parameter already exists the value wont be replaced and the request wont be changed. - * - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -final class QueryDefaultsPlugin implements Plugin -{ - /** - * @var array - */ - private $queryParams = []; - - /** - * @param array $queryParams Hashmap of query name to query value. Names and values must not be url encoded as - * this plugin will encode them - */ - public function __construct(array $queryParams) - { - $this->queryParams = $queryParams; - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - foreach ($this->queryParams as $name => $value) { - $uri = $request->getUri(); - $array = []; - parse_str($uri->getQuery(), $array); - - // If query value is not found - if (!isset($array[$name])) { - $array[$name] = $value; - - // Create a new request with the new URI with the added query param - $request = $request->withUri( - $uri->withQuery(http_build_query($array)) - ); - } - } - - return $next($request); - } -} diff --git a/vendor/php-http/client-common/src/Plugin/RedirectPlugin.php b/vendor/php-http/client-common/src/Plugin/RedirectPlugin.php deleted file mode 100755 index d2f442edb8fe95cc9676ef0295e64e2427df9748..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/RedirectPlugin.php +++ /dev/null @@ -1,270 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Exception\CircularRedirectionException; -use Http\Client\Common\Exception\MultipleRedirectionException; -use Http\Client\Common\Plugin; -use Http\Client\Exception\HttpException; -use Psr\Http\Message\MessageInterface; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\UriInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Follow redirections. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class RedirectPlugin implements Plugin -{ - /** - * Rule on how to redirect, change method for the new request. - * - * @var array - */ - protected $redirectCodes = [ - 300 => [ - 'switch' => [ - 'unless' => ['GET', 'HEAD'], - 'to' => 'GET', - ], - 'multiple' => true, - 'permanent' => false, - ], - 301 => [ - 'switch' => [ - 'unless' => ['GET', 'HEAD'], - 'to' => 'GET', - ], - 'multiple' => false, - 'permanent' => true, - ], - 302 => [ - 'switch' => [ - 'unless' => ['GET', 'HEAD'], - 'to' => 'GET', - ], - 'multiple' => false, - 'permanent' => false, - ], - 303 => [ - 'switch' => [ - 'unless' => ['GET', 'HEAD'], - 'to' => 'GET', - ], - 'multiple' => false, - 'permanent' => false, - ], - 307 => [ - 'switch' => false, - 'multiple' => false, - 'permanent' => false, - ], - 308 => [ - 'switch' => false, - 'multiple' => false, - 'permanent' => true, - ], - ]; - - /** - * Determine how header should be preserved from old request. - * - * @var bool|array - * - * true will keep all previous headers (default value) - * false will ditch all previous headers - * string[] will keep only headers with the specified names - */ - protected $preserveHeader; - - /** - * Store all previous redirect from 301 / 308 status code. - * - * @var array - */ - protected $redirectStorage = []; - - /** - * Whether the location header must be directly used for a multiple redirection status code (300). - * - * @var bool - */ - protected $useDefaultForMultiple; - - /** - * @var array - */ - protected $circularDetection = []; - - /** - * @param array $config { - * - * @var bool|string[] $preserve_header True keeps all headers, false remove all of them, an array is interpreted as a list of header names to keep - * @var bool $use_default_for_multiple Whether the location header must be directly used for a multiple redirection status code (300). - * } - */ - public function __construct(array $config = []) - { - $resolver = new OptionsResolver(); - $resolver->setDefaults([ - 'preserve_header' => true, - 'use_default_for_multiple' => true, - ]); - $resolver->setAllowedTypes('preserve_header', ['bool', 'array']); - $resolver->setAllowedTypes('use_default_for_multiple', 'bool'); - $resolver->setNormalizer('preserve_header', function (OptionsResolver $resolver, $value) { - if (is_bool($value) && false === $value) { - return []; - } - - return $value; - }); - $options = $resolver->resolve($config); - - $this->preserveHeader = $options['preserve_header']; - $this->useDefaultForMultiple = $options['use_default_for_multiple']; - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - // Check in storage - if (array_key_exists((string) $request->getUri(), $this->redirectStorage)) { - $uri = $this->redirectStorage[(string) $request->getUri()]['uri']; - $statusCode = $this->redirectStorage[(string) $request->getUri()]['status']; - $redirectRequest = $this->buildRedirectRequest($request, $uri, $statusCode); - - return $first($redirectRequest); - } - - return $next($request)->then(function (ResponseInterface $response) use ($request, $first) { - $statusCode = $response->getStatusCode(); - - if (!array_key_exists($statusCode, $this->redirectCodes)) { - return $response; - } - - $uri = $this->createUri($response, $request); - $redirectRequest = $this->buildRedirectRequest($request, $uri, $statusCode); - $chainIdentifier = spl_object_hash((object) $first); - - if (!array_key_exists($chainIdentifier, $this->circularDetection)) { - $this->circularDetection[$chainIdentifier] = []; - } - - $this->circularDetection[$chainIdentifier][] = (string) $request->getUri(); - - if (in_array((string) $redirectRequest->getUri(), $this->circularDetection[$chainIdentifier])) { - throw new CircularRedirectionException('Circular redirection detected', $request, $response); - } - - if ($this->redirectCodes[$statusCode]['permanent']) { - $this->redirectStorage[(string) $request->getUri()] = [ - 'uri' => $uri, - 'status' => $statusCode, - ]; - } - - // Call redirect request in synchrone - $redirectPromise = $first($redirectRequest); - - return $redirectPromise->wait(); - }); - } - - /** - * Builds the redirect request. - * - * @param RequestInterface $request Original request - * @param UriInterface $uri New uri - * @param int $statusCode Status code from the redirect response - * - * @return MessageInterface|RequestInterface - */ - protected function buildRedirectRequest(RequestInterface $request, UriInterface $uri, $statusCode) - { - $request = $request->withUri($uri); - - if (false !== $this->redirectCodes[$statusCode]['switch'] && !in_array($request->getMethod(), $this->redirectCodes[$statusCode]['switch']['unless'])) { - $request = $request->withMethod($this->redirectCodes[$statusCode]['switch']['to']); - } - - if (is_array($this->preserveHeader)) { - $headers = array_keys($request->getHeaders()); - - foreach ($headers as $name) { - if (!in_array($name, $this->preserveHeader)) { - $request = $request->withoutHeader($name); - } - } - } - - return $request; - } - - /** - * Creates a new Uri from the old request and the location header. - * - * @param ResponseInterface $response The redirect response - * @param RequestInterface $request The original request - * - * @throws HttpException If location header is not usable (missing or incorrect) - * @throws MultipleRedirectionException If a 300 status code is received and default location cannot be resolved (doesn't use the location header or not present) - * - * @return UriInterface - */ - private function createUri(ResponseInterface $response, RequestInterface $request) - { - if ($this->redirectCodes[$response->getStatusCode()]['multiple'] && (!$this->useDefaultForMultiple || !$response->hasHeader('Location'))) { - throw new MultipleRedirectionException('Cannot choose a redirection', $request, $response); - } - - if (!$response->hasHeader('Location')) { - throw new HttpException('Redirect status code, but no location header present in the response', $request, $response); - } - - $location = $response->getHeaderLine('Location'); - $parsedLocation = parse_url($location); - - if (false === $parsedLocation) { - throw new HttpException(sprintf('Location %s could not be parsed', $location), $request, $response); - } - - $uri = $request->getUri(); - - if (array_key_exists('scheme', $parsedLocation)) { - $uri = $uri->withScheme($parsedLocation['scheme']); - } - - if (array_key_exists('host', $parsedLocation)) { - $uri = $uri->withHost($parsedLocation['host']); - } - - if (array_key_exists('port', $parsedLocation)) { - $uri = $uri->withPort($parsedLocation['port']); - } - - if (array_key_exists('path', $parsedLocation)) { - $uri = $uri->withPath($parsedLocation['path']); - } - - if (array_key_exists('query', $parsedLocation)) { - $uri = $uri->withQuery($parsedLocation['query']); - } else { - $uri = $uri->withQuery(''); - } - - if (array_key_exists('fragment', $parsedLocation)) { - $uri = $uri->withFragment($parsedLocation['fragment']); - } else { - $uri = $uri->withFragment(''); - } - - return $uri; - } -} diff --git a/vendor/php-http/client-common/src/Plugin/RequestMatcherPlugin.php b/vendor/php-http/client-common/src/Plugin/RequestMatcherPlugin.php deleted file mode 100755 index 5f72b02d8ac6973ba659ab9d4bf1f7f1eaf97eba..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/RequestMatcherPlugin.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Plugin; -use Http\Message\RequestMatcher; -use Psr\Http\Message\RequestInterface; - -/** - * Apply a delegated plugin based on a request match. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -final class RequestMatcherPlugin implements Plugin -{ - /** - * @var RequestMatcher - */ - private $requestMatcher; - - /** - * @var Plugin - */ - private $delegatedPlugin; - - /** - * @param RequestMatcher $requestMatcher - * @param Plugin $delegatedPlugin - */ - public function __construct(RequestMatcher $requestMatcher, Plugin $delegatedPlugin) - { - $this->requestMatcher = $requestMatcher; - $this->delegatedPlugin = $delegatedPlugin; - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - if ($this->requestMatcher->matches($request)) { - return $this->delegatedPlugin->handleRequest($request, $next, $first); - } - - return $next($request); - } -} diff --git a/vendor/php-http/client-common/src/Plugin/RetryPlugin.php b/vendor/php-http/client-common/src/Plugin/RetryPlugin.php deleted file mode 100755 index 8446246e673c4cab2cb3685f894a18220b14f385..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/Plugin/RetryPlugin.php +++ /dev/null @@ -1,122 +0,0 @@ -<?php - -namespace Http\Client\Common\Plugin; - -use Http\Client\Common\Plugin; -use Http\Client\Exception; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Retry the request if an exception is thrown. - * - * By default will retry only one time. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class RetryPlugin implements Plugin -{ - /** - * Number of retry before sending an exception. - * - * @var int - */ - private $retry; - - /** - * @var callable - */ - private $delay; - - /** - * @var callable - */ - private $decider; - - /** - * Store the retry counter for each request. - * - * @var array - */ - private $retryStorage = []; - - /** - * @param array $config { - * - * @var int $retries Number of retries to attempt if an exception occurs before letting the exception bubble up. - * @var callable $decider A callback that gets a request and an exception to decide after a failure whether the request should be retried. - * @var callable $delay A callback that gets a request, an exception and the number of retries and returns how many microseconds we should wait before trying again. - * } - */ - public function __construct(array $config = []) - { - $resolver = new OptionsResolver(); - $resolver->setDefaults([ - 'retries' => 1, - 'decider' => function (RequestInterface $request, Exception $e) { - return true; - }, - 'delay' => __CLASS__.'::defaultDelay', - ]); - $resolver->setAllowedTypes('retries', 'int'); - $resolver->setAllowedTypes('decider', 'callable'); - $resolver->setAllowedTypes('delay', 'callable'); - $options = $resolver->resolve($config); - - $this->retry = $options['retries']; - $this->decider = $options['decider']; - $this->delay = $options['delay']; - } - - /** - * {@inheritdoc} - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first) - { - $chainIdentifier = spl_object_hash((object) $first); - - return $next($request)->then(function (ResponseInterface $response) use ($request, $chainIdentifier) { - if (array_key_exists($chainIdentifier, $this->retryStorage)) { - unset($this->retryStorage[$chainIdentifier]); - } - - return $response; - }, function (Exception $exception) use ($request, $next, $first, $chainIdentifier) { - if (!array_key_exists($chainIdentifier, $this->retryStorage)) { - $this->retryStorage[$chainIdentifier] = 0; - } - - if ($this->retryStorage[$chainIdentifier] >= $this->retry) { - unset($this->retryStorage[$chainIdentifier]); - - throw $exception; - } - - if (!call_user_func($this->decider, $request, $exception)) { - throw $exception; - } - - $time = call_user_func($this->delay, $request, $exception, $this->retryStorage[$chainIdentifier]); - usleep($time); - - // Retry in synchrone - ++$this->retryStorage[$chainIdentifier]; - $promise = $this->handleRequest($request, $next, $first); - - return $promise->wait(); - }); - } - - /** - * @param RequestInterface $request - * @param Exception $e - * @param int $retries The number of retries we made before. First time this get called it will be 0. - * - * @return int - */ - public static function defaultDelay(RequestInterface $request, Exception $e, $retries) - { - return pow(2, $retries) * 500000; - } -} diff --git a/vendor/php-http/client-common/src/PluginClient.php b/vendor/php-http/client-common/src/PluginClient.php deleted file mode 100755 index 93aea8f2fda0c2ead27a5de67006a43a7a0c51d5..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/PluginClient.php +++ /dev/null @@ -1,179 +0,0 @@ -<?php - -namespace Http\Client\Common; - -use Http\Client\Common\Exception\LoopException; -use Http\Client\Exception as HttplugException; -use Http\Client\HttpAsyncClient; -use Http\Client\HttpClient; -use Http\Client\Promise\HttpFulfilledPromise; -use Http\Client\Promise\HttpRejectedPromise; -use Psr\Http\Message\RequestInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * The client managing plugins and providing a decorator around HTTP Clients. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class PluginClient implements HttpClient, HttpAsyncClient -{ - /** - * An HTTP async client. - * - * @var HttpAsyncClient - */ - private $client; - - /** - * The plugin chain. - * - * @var Plugin[] - */ - private $plugins; - - /** - * A list of options. - * - * @var array - */ - private $options; - - /** - * @param HttpClient|HttpAsyncClient $client - * @param Plugin[] $plugins - * @param array $options { - * - * @var int $max_restarts - * @var Plugin[] $debug_plugins an array of plugins that are injected between each normal plugin - * } - * - * @throws \RuntimeException if client is not an instance of HttpClient or HttpAsyncClient - */ - public function __construct($client, array $plugins = [], array $options = []) - { - if ($client instanceof HttpAsyncClient) { - $this->client = $client; - } elseif ($client instanceof HttpClient) { - $this->client = new EmulatedHttpAsyncClient($client); - } else { - throw new \RuntimeException('Client must be an instance of Http\\Client\\HttpClient or Http\\Client\\HttpAsyncClient'); - } - - $this->plugins = $plugins; - $this->options = $this->configure($options); - } - - /** - * {@inheritdoc} - */ - public function sendRequest(RequestInterface $request) - { - // If we don't have an http client, use the async call - if (!($this->client instanceof HttpClient)) { - return $this->sendAsyncRequest($request)->wait(); - } - - // Else we want to use the synchronous call of the underlying client, and not the async one in the case - // we have both an async and sync call - $pluginChain = $this->createPluginChain($this->plugins, function (RequestInterface $request) { - try { - return new HttpFulfilledPromise($this->client->sendRequest($request)); - } catch (HttplugException $exception) { - return new HttpRejectedPromise($exception); - } - }); - - return $pluginChain($request)->wait(); - } - - /** - * {@inheritdoc} - */ - public function sendAsyncRequest(RequestInterface $request) - { - $pluginChain = $this->createPluginChain($this->plugins, function (RequestInterface $request) { - return $this->client->sendAsyncRequest($request); - }); - - return $pluginChain($request); - } - - /** - * Configure the plugin client. - * - * @param array $options - * - * @return array - */ - private function configure(array $options = []) - { - if (isset($options['debug_plugins'])) { - @trigger_error('The "debug_plugins" option is deprecated since 1.5 and will be removed in 2.0.', E_USER_DEPRECATED); - } - - $resolver = new OptionsResolver(); - $resolver->setDefaults([ - 'max_restarts' => 10, - 'debug_plugins' => [], - ]); - - $resolver - ->setAllowedTypes('debug_plugins', 'array') - ->setAllowedValues('debug_plugins', function (array $plugins) { - foreach ($plugins as $plugin) { - // Make sure each object passed with the `debug_plugins` is an instance of Plugin. - if (!$plugin instanceof Plugin) { - return false; - } - } - - return true; - }); - - return $resolver->resolve($options); - } - - /** - * Create the plugin chain. - * - * @param Plugin[] $pluginList A list of plugins - * @param callable $clientCallable Callable making the HTTP call - * - * @return callable - */ - private function createPluginChain($pluginList, callable $clientCallable) - { - $firstCallable = $lastCallable = $clientCallable; - - /* - * Inject debug plugins between each plugin. - */ - $pluginListWithDebug = $this->options['debug_plugins']; - foreach ($pluginList as $plugin) { - $pluginListWithDebug[] = $plugin; - $pluginListWithDebug = array_merge($pluginListWithDebug, $this->options['debug_plugins']); - } - - while ($plugin = array_pop($pluginListWithDebug)) { - $lastCallable = function (RequestInterface $request) use ($plugin, $lastCallable, &$firstCallable) { - return $plugin->handleRequest($request, $lastCallable, $firstCallable); - }; - - $firstCallable = $lastCallable; - } - - $firstCalls = 0; - $firstCallable = function (RequestInterface $request) use ($lastCallable, &$firstCalls) { - if ($firstCalls > $this->options['max_restarts']) { - throw new LoopException('Too many restarts in plugin client', $request); - } - - ++$firstCalls; - - return $lastCallable($request); - }; - - return $firstCallable; - } -} diff --git a/vendor/php-http/client-common/src/PluginClientFactory.php b/vendor/php-http/client-common/src/PluginClientFactory.php deleted file mode 100755 index bd4c08f9a62530a792022e7830a0ecd681e7c828..0000000000000000000000000000000000000000 --- a/vendor/php-http/client-common/src/PluginClientFactory.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -namespace Http\Client\Common; - -use Http\Client\HttpAsyncClient; -use Http\Client\HttpClient; - -/** - * Factory to create PluginClient instances. Using this factory instead of calling PluginClient constructor will enable - * the Symfony profiling without any configuration. - * - * @author Fabien Bourigault <bourigaultfabien@gmail.com> - */ -final class PluginClientFactory -{ - /** - * @var callable - */ - private static $factory; - - /** - * Set the factory to use. - * The callable to provide must have the same arguments and return type as PluginClientFactory::createClient. - * This is used by the HTTPlugBundle to provide a better Symfony integration. - * Unlike the createClient method, this one is static to allow zero configuration profiling by hooking into early - * application execution. - * - * @internal - * - * @param callable $factory - */ - public static function setFactory(callable $factory) - { - static::$factory = $factory; - } - - /** - * @param HttpClient|HttpAsyncClient $client - * @param Plugin[] $plugins - * @param array $options { - * - * @var string $client_name to give client a name which may be used when displaying client information like in - * the HTTPlugBundle profiler. - * } - * - * @see PluginClient constructor for PluginClient specific $options. - * - * @return PluginClient - */ - public function createClient($client, array $plugins = [], array $options = []) - { - if (static::$factory) { - $factory = static::$factory; - - return $factory($client, $plugins, $options); - } - - unset($options['client_name']); - - return new PluginClient($client, $plugins, $options); - } -} diff --git a/vendor/php-http/curl-client/.php_cs b/vendor/php-http/curl-client/.php_cs deleted file mode 100755 index febeee5866fc55087a9cf78c4666358f26ddf1f3..0000000000000000000000000000000000000000 --- a/vendor/php-http/curl-client/.php_cs +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -return Symfony\CS\Config\Config::create() - ->level(Symfony\CS\FixerInterface::PSR2_LEVEL) - ->fixers([]) - ->finder( - Symfony\CS\Finder\DefaultFinder::create()->in(__DIR__ . '/src') - ) -; diff --git a/vendor/php-http/curl-client/.styleci.yml b/vendor/php-http/curl-client/.styleci.yml deleted file mode 100755 index 4d43c934b3e0a3ba2cc5fc24ba942269acdb9a56..0000000000000000000000000000000000000000 --- a/vendor/php-http/curl-client/.styleci.yml +++ /dev/null @@ -1,4 +0,0 @@ -preset: psr2 -finder: - path: - - "src" diff --git a/vendor/php-http/curl-client/CHANGELOG.md b/vendor/php-http/curl-client/CHANGELOG.md deleted file mode 100755 index a338788cea9f85cee0dfeb730b0e9fb4ae1e34d6..0000000000000000000000000000000000000000 --- a/vendor/php-http/curl-client/CHANGELOG.md +++ /dev/null @@ -1,173 +0,0 @@ -# Change Log - -## Unreleased - - -## 1.7.1 - 2018-03-36 - -### Fixed - -- #36: Failure evaluating code: is_resource($handle) (string assertions are deprecated in PHP 7.2) - - -## 1.7 - 2017-02-09 - -### Changed - -- #30: Make sure we rewind streams - -## 1.6.2 - 2017-01-02 - -### Fixed - -- #29: Request not using CURLOPT_POSTFIELDS have content-length set to - -### Changed - -- Use binary mode to create response body stream. - - -## 1.6.1 - 2016-11-11 - -### Fixed - -- #27: ErrorPlugin and sendAsyncRequest() incompatibility - - -## 1.6 - 2016-09-12 - -### Changed - -- `Client::sendRequest` now throws `Http\Client\Exception\NetworkException` on network errors. -- `\UnexpectedValueException` replaced with `Http\Client\Exception\RequestException` in - `Client::sendRequest` and `Client::sendAsyncRequest` - - -## 1.5.1 - 2016-08-29 - -### Fixed - -- #26: Combining CurlClient with StopwatchPlugin causes Promise onRejected handler to never be - invoked. - - -## 1.5 - 2016-08-03 - -### Changed - -- Request body can be send with any method except GET, HEAD and TRACE. -- #25: Make discovery a hard dependency. - - -## 1.4.2 - 2016-06-14 - -### Added - -- #23: "php-http/async-client-implementation" added to "provide" section. - - -## 1.4.1 - 2016-05-30 - -### Fixed - -- #22: Cannot create the client using `HttpClientDiscovery`. - - -## 1.4 - 2016-03-30 - -### Changed - -- #20: Minimize memory usage when reading large response body. - - -## 1.3 - 2016-03-14 - -### Fixed - -- #18: Invalid "Expect" header. - -### Removed - -- #13: Remove HeaderParser. - - -## 1.2 - 2016-03-09 - -### Added - -- #16: Make sure discovery can find the curl client - -### Fixed - -- #15: "Out of memory" sending large files. - - -## 1.1.0 - 2016-01-29 - -### Changed - -- Switch to php-http/message 1.0. - - -## 1.0.0 - 2016-01-28 - -First stable release. - - -## 0.7.0 - 2016-01-26 - -### Changed - -- Migrate from `php-http/discovery` and `php-http/utils` to `php-http/message`. - -## 0.6.0 - 2016-01-12 - -### Changed - -- Root namespace changed from `Http\Curl` to `Http\Client\Curl`. -- Main client class name renamed from `CurlHttpClient` to `Client`. -- Minimum required [php-http/discovery](https://packagist.org/packages/php-http/discovery) - version changed to 0.5. - - -## 0.5.0 - 2015-12-18 - -### Changed - -- Compatibility with php-http/httplug 1.0 beta -- Switch to php-http/discovery 0.4 - - -## 0.4.0 - 2015-12-16 - -### Changed - -- Switch to php-http/message-factory 1.0 - - -## 0.3.1 - 2015-12-14 - -### Changed - -- Requirements fixed. - - -## 0.3.0 - 2015-11-24 - -### Changed - -- Use cURL constants as options keys. - - -## 0.2.0 - 2015-11-17 - -### Added - -- HttpAsyncClient support. - - -## 0.1.0 - 2015-11-11 - -### Added - -- Initial release diff --git a/vendor/php-http/curl-client/LICENSE b/vendor/php-http/curl-client/LICENSE deleted file mode 100755 index 8e2c4a0b85c31bf132105920cc90ba371025eb8a..0000000000000000000000000000000000000000 --- a/vendor/php-http/curl-client/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015 PHP HTTP Team <team@php-http.org> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/php-http/curl-client/README.md b/vendor/php-http/curl-client/README.md deleted file mode 100755 index fc60b7eebc246a6a1282355790c55dc1fc611bc1..0000000000000000000000000000000000000000 --- a/vendor/php-http/curl-client/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# Curl client for PHP HTTP - -[](https://github.com/php-http/curl-client/releases) -[](LICENSE) -[](https://travis-ci.org/php-http/curl-client) -[](https://scrutinizer-ci.com/g/php-http/curl-client) -[](https://scrutinizer-ci.com/g/php-http/curl-client) -[](https://packagist.org/packages/php-http/curl-client) - -The cURL client use the cURL PHP extension which must be activated in your `php.ini`. - - -## Install - -Via Composer - -``` bash -$ composer require php-http/curl-client -``` - -## Documentation - -Please see the [official documentation](http://docs.php-http.org/en/latest/clients/curl-client.html). - -## Testing - -``` bash -$ composer test -``` - -## Contributing - -Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details. - - -## Security - -If you discover any security related issues, please contact us at -[security@php-http.org](mailto:security@php-http.org). - - -## License - -The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/vendor/php-http/curl-client/composer.json b/vendor/php-http/curl-client/composer.json deleted file mode 100755 index c72b7a7f2cc211d855a1f4f2e494d98a4441094d..0000000000000000000000000000000000000000 --- a/vendor/php-http/curl-client/composer.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name": "php-http/curl-client", - "description": "cURL client for PHP-HTTP", - "license": "MIT", - "keywords": ["http", "curl"], - "homepage": "http://php-http.org", - "authors": [ - { - "name": "Михаил Красильников", - "email": "m.krasilnikov@yandex.ru" - } - ], - "prefer-stable": true, - "minimum-stability": "beta", - "config": { - "bin-dir": "vendor/bin" - }, - "require": { - "php": "^5.5 || ^7.0", - "ext-curl": "*", - "php-http/httplug": "^1.0", - "php-http/message-factory": "^1.0.2", - "php-http/message": "^1.2", - "php-http/discovery": "^1.0" - }, - "require-dev": { - "guzzlehttp/psr7": "^1.0", - "php-http/client-integration-tests": "^0.6", - "phpunit/phpunit": "^4.8.27", - "zendframework/zend-diactoros": "^1.0" - }, - "autoload": { - "psr-4": { - "Http\\Client\\Curl\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "Http\\Client\\Curl\\Tests\\": "tests/" - } - }, - "provide": { - "php-http/client-implementation": "1.0", - "php-http/async-client-implementation": "1.0" - }, - "scripts": { - "test": "vendor/bin/phpunit", - "test-ci": "vendor/bin/phpunit --coverage-clover build/coverage.xml" - } -} diff --git a/vendor/php-http/curl-client/puli.json b/vendor/php-http/curl-client/puli.json deleted file mode 100755 index b35768d81c98e1212dda81fa7da5e5d20fa481da..0000000000000000000000000000000000000000 --- a/vendor/php-http/curl-client/puli.json +++ /dev/null @@ -1,242 +0,0 @@ -{ - "version": "1.0", - "name": "php-http/curl-client", - "bindings": { - "98239b8b-103b-4f47-94c7-4cba49a05a1f": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Client\\Curl\\Client", - "type": "Http\\Client\\HttpAsyncClient" - }, - "a6a79968-2aa5-427c-bbe1-a581d9a48321": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Client\\Curl\\Client", - "type": "Http\\Client\\HttpClient" - } - }, - "config": { - "bootstrap-file": "vendor/autoload.php" - }, - "packages": { - "clue/stream-filter": { - "install-path": "vendor/clue/stream-filter", - "installer": "composer", - "env": "dev" - }, - "doctrine/instantiator": { - "install-path": "vendor/doctrine/instantiator", - "installer": "composer", - "env": "dev" - }, - "guzzlehttp/psr7": { - "install-path": "vendor/guzzlehttp/psr7", - "installer": "composer", - "env": "dev" - }, - "justinrainbow/json-schema": { - "install-path": "vendor/justinrainbow/json-schema", - "installer": "composer", - "env": "dev" - }, - "paragonie/random_compat": { - "install-path": "vendor/paragonie/random_compat", - "installer": "composer", - "env": "dev" - }, - "php-http/adapter-integration-tests": { - "install-path": "vendor/php-http/adapter-integration-tests", - "installer": "composer", - "env": "dev" - }, - "php-http/discovery": { - "install-path": "vendor/php-http/discovery", - "installer": "composer", - "env": "dev" - }, - "php-http/httplug": { - "install-path": "vendor/php-http/httplug", - "installer": "composer" - }, - "php-http/message": { - "install-path": "vendor/php-http/message", - "installer": "composer", - "env": "dev" - }, - "php-http/message-factory": { - "install-path": "vendor/php-http/message-factory", - "installer": "composer" - }, - "php-http/promise": { - "install-path": "vendor/php-http/promise", - "installer": "composer" - }, - "phpdocumentor/reflection-docblock": { - "install-path": "vendor/phpdocumentor/reflection-docblock", - "installer": "composer", - "env": "dev" - }, - "phpspec/prophecy": { - "install-path": "vendor/phpspec/prophecy", - "installer": "composer", - "env": "dev" - }, - "phpunit/php-code-coverage": { - "install-path": "vendor/phpunit/php-code-coverage", - "installer": "composer", - "env": "dev" - }, - "phpunit/php-file-iterator": { - "install-path": "vendor/phpunit/php-file-iterator", - "installer": "composer", - "env": "dev" - }, - "phpunit/php-text-template": { - "install-path": "vendor/phpunit/php-text-template", - "installer": "composer", - "env": "dev" - }, - "phpunit/php-timer": { - "install-path": "vendor/phpunit/php-timer", - "installer": "composer", - "env": "dev" - }, - "phpunit/php-token-stream": { - "install-path": "vendor/phpunit/php-token-stream", - "installer": "composer", - "env": "dev" - }, - "phpunit/phpunit": { - "install-path": "vendor/phpunit/phpunit", - "installer": "composer", - "env": "dev" - }, - "phpunit/phpunit-mock-objects": { - "install-path": "vendor/phpunit/phpunit-mock-objects", - "installer": "composer", - "env": "dev" - }, - "psr/http-message": { - "install-path": "vendor/psr/http-message", - "installer": "composer" - }, - "psr/log": { - "install-path": "vendor/psr/log", - "installer": "composer", - "env": "dev" - }, - "puli/composer-plugin": { - "install-path": "vendor/puli/composer-plugin", - "installer": "composer", - "env": "dev" - }, - "puli/discovery": { - "install-path": "vendor/puli/discovery", - "installer": "composer", - "env": "dev" - }, - "puli/repository": { - "install-path": "vendor/puli/repository", - "installer": "composer", - "env": "dev" - }, - "puli/url-generator": { - "install-path": "vendor/puli/url-generator", - "installer": "composer", - "env": "dev" - }, - "ramsey/uuid": { - "install-path": "vendor/ramsey/uuid", - "installer": "composer", - "env": "dev" - }, - "sebastian/comparator": { - "install-path": "vendor/sebastian/comparator", - "installer": "composer", - "env": "dev" - }, - "sebastian/diff": { - "install-path": "vendor/sebastian/diff", - "installer": "composer", - "env": "dev" - }, - "sebastian/environment": { - "install-path": "vendor/sebastian/environment", - "installer": "composer", - "env": "dev" - }, - "sebastian/exporter": { - "install-path": "vendor/sebastian/exporter", - "installer": "composer", - "env": "dev" - }, - "sebastian/global-state": { - "install-path": "vendor/sebastian/global-state", - "installer": "composer", - "env": "dev" - }, - "sebastian/recursion-context": { - "install-path": "vendor/sebastian/recursion-context", - "installer": "composer", - "env": "dev" - }, - "sebastian/version": { - "install-path": "vendor/sebastian/version", - "installer": "composer", - "env": "dev" - }, - "seld/jsonlint": { - "install-path": "vendor/seld/jsonlint", - "installer": "composer", - "env": "dev" - }, - "symfony/filesystem": { - "install-path": "vendor/symfony/filesystem", - "installer": "composer", - "env": "dev" - }, - "symfony/process": { - "install-path": "vendor/symfony/process", - "installer": "composer", - "env": "dev" - }, - "symfony/yaml": { - "install-path": "vendor/symfony/yaml", - "installer": "composer", - "env": "dev" - }, - "th3n3rd/cartesian-product": { - "install-path": "vendor/th3n3rd/cartesian-product", - "installer": "composer", - "env": "dev" - }, - "webmozart/assert": { - "install-path": "vendor/webmozart/assert", - "installer": "composer", - "env": "dev" - }, - "webmozart/expression": { - "install-path": "vendor/webmozart/expression", - "installer": "composer", - "env": "dev" - }, - "webmozart/glob": { - "install-path": "vendor/webmozart/glob", - "installer": "composer", - "env": "dev" - }, - "webmozart/json": { - "install-path": "vendor/webmozart/json", - "installer": "composer", - "env": "dev" - }, - "webmozart/path-util": { - "install-path": "vendor/webmozart/path-util", - "installer": "composer", - "env": "dev" - }, - "zendframework/zend-diactoros": { - "install-path": "vendor/zendframework/zend-diactoros", - "installer": "composer", - "env": "dev" - } - } -} diff --git a/vendor/php-http/curl-client/src/Client.php b/vendor/php-http/curl-client/src/Client.php deleted file mode 100755 index 015e7eda5f5628ee7d52a0f5386b4f42ae33f8da..0000000000000000000000000000000000000000 --- a/vendor/php-http/curl-client/src/Client.php +++ /dev/null @@ -1,372 +0,0 @@ -<?php - -namespace Http\Client\Curl; - -use Http\Client\Exception; -use Http\Client\HttpAsyncClient; -use Http\Client\HttpClient; -use Http\Discovery\MessageFactoryDiscovery; -use Http\Discovery\StreamFactoryDiscovery; -use Http\Message\MessageFactory; -use Http\Message\StreamFactory; -use Http\Promise\Promise; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * PSR-7 compatible cURL based HTTP client. - * - * @license http://opensource.org/licenses/MIT MIT - * @author Михаил Красильников <m.krasilnikov@yandex.ru> - * @author Blake Williams <github@shabbyrobe.org> - * - * @api - * - * @since 1.0 - */ -class Client implements HttpClient, HttpAsyncClient -{ - /** - * cURL options. - * - * @var array - */ - private $options; - - /** - * PSR-7 message factory. - * - * @var MessageFactory - */ - private $messageFactory; - - /** - * PSR-7 stream factory. - * - * @var StreamFactory - */ - private $streamFactory; - - /** - * cURL synchronous requests handle. - * - * @var resource|null - */ - private $handle = null; - - /** - * Simultaneous requests runner. - * - * @var MultiRunner|null - */ - private $multiRunner = null; - - /** - * Create new client. - * - * @param MessageFactory|null $messageFactory HTTP Message factory - * @param StreamFactory|null $streamFactory HTTP Stream factory - * @param array $options cURL options (see http://php.net/curl_setopt) - * - * @throws \Http\Discovery\Exception\NotFoundException If factory discovery failed - * - * @since 1.0 - */ - public function __construct( - MessageFactory $messageFactory = null, - StreamFactory $streamFactory = null, - array $options = [] - ) { - $this->messageFactory = $messageFactory ?: MessageFactoryDiscovery::find(); - $this->streamFactory = $streamFactory ?: StreamFactoryDiscovery::find(); - $this->options = $options; - } - - /** - * Release resources if still active. - */ - public function __destruct() - { - if (is_resource($this->handle)) { - curl_close($this->handle); - } - } - - /** - * Sends a PSR-7 request. - * - * @param RequestInterface $request - * - * @return ResponseInterface - * - * @throws \Http\Client\Exception\NetworkException In case of network problems - * @throws \Http\Client\Exception\RequestException On invalid request - * @throws \InvalidArgumentException For invalid header names or values - * @throws \RuntimeException If creating the body stream fails - * - * @since 1.6 \UnexpectedValueException replaced with RequestException - * @since 1.6 Throw NetworkException on network errors - * @since 1.0 - */ - public function sendRequest(RequestInterface $request) - { - $responseBuilder = $this->createResponseBuilder(); - $options = $this->createCurlOptions($request, $responseBuilder); - - if (is_resource($this->handle)) { - curl_reset($this->handle); - } else { - $this->handle = curl_init(); - } - - curl_setopt_array($this->handle, $options); - curl_exec($this->handle); - - $errno = curl_errno($this->handle); - switch ($errno) { - case CURLE_OK: - // All OK, no actions needed. - break; - case CURLE_COULDNT_RESOLVE_PROXY: - case CURLE_COULDNT_RESOLVE_HOST: - case CURLE_COULDNT_CONNECT: - case CURLE_OPERATION_TIMEOUTED: - case CURLE_SSL_CONNECT_ERROR: - throw new Exception\NetworkException(curl_error($this->handle), $request); - default: - throw new Exception\RequestException(curl_error($this->handle), $request); - } - - $response = $responseBuilder->getResponse(); - $response->getBody()->seek(0); - - return $response; - } - - /** - * Sends a PSR-7 request in an asynchronous way. - * - * @param RequestInterface $request - * - * @return Promise - * - * @throws \Http\Client\Exception\RequestException On invalid request - * @throws \InvalidArgumentException For invalid header names or values - * @throws \RuntimeException If creating the body stream fails - * - * @since 1.6 \UnexpectedValueException replaced with RequestException - * @since 1.0 - */ - public function sendAsyncRequest(RequestInterface $request) - { - if (!$this->multiRunner instanceof MultiRunner) { - $this->multiRunner = new MultiRunner(); - } - - $handle = curl_init(); - $responseBuilder = $this->createResponseBuilder(); - $options = $this->createCurlOptions($request, $responseBuilder); - curl_setopt_array($handle, $options); - - $core = new PromiseCore($request, $handle, $responseBuilder); - $promise = new CurlPromise($core, $this->multiRunner); - $this->multiRunner->add($core); - - return $promise; - } - - /** - * Generates cURL options. - * - * @param RequestInterface $request - * @param ResponseBuilder $responseBuilder - * - * @throws \Http\Client\Exception\RequestException On invalid request - * @throws \InvalidArgumentException For invalid header names or values - * @throws \RuntimeException if can not read body - * - * @return array - */ - private function createCurlOptions(RequestInterface $request, ResponseBuilder $responseBuilder) - { - $options = $this->options; - - $options[CURLOPT_HEADER] = false; - $options[CURLOPT_RETURNTRANSFER] = false; - $options[CURLOPT_FOLLOWLOCATION] = false; - - try { - $options[CURLOPT_HTTP_VERSION] - = $this->getProtocolVersion($request->getProtocolVersion()); - } catch (\UnexpectedValueException $e) { - throw new Exception\RequestException($e->getMessage(), $request); - } - $options[CURLOPT_URL] = (string) $request->getUri(); - - $options = $this->addRequestBodyOptions($request, $options); - - $options[CURLOPT_HTTPHEADER] = $this->createHeaders($request, $options); - - if ($request->getUri()->getUserInfo()) { - $options[CURLOPT_USERPWD] = $request->getUri()->getUserInfo(); - } - - $options[CURLOPT_HEADERFUNCTION] = function ($ch, $data) use ($responseBuilder) { - $str = trim($data); - if ('' !== $str) { - if (strpos(strtolower($str), 'http/') === 0) { - $responseBuilder->setStatus($str)->getResponse(); - } else { - $responseBuilder->addHeader($str); - } - } - - return strlen($data); - }; - - $options[CURLOPT_WRITEFUNCTION] = function ($ch, $data) use ($responseBuilder) { - return $responseBuilder->getResponse()->getBody()->write($data); - }; - - return $options; - } - - /** - * Return cURL constant for specified HTTP version. - * - * @param string $requestVersion - * - * @throws \UnexpectedValueException if unsupported version requested - * - * @return int - */ - private function getProtocolVersion($requestVersion) - { - switch ($requestVersion) { - case '1.0': - return CURL_HTTP_VERSION_1_0; - case '1.1': - return CURL_HTTP_VERSION_1_1; - case '2.0': - if (defined('CURL_HTTP_VERSION_2_0')) { - return CURL_HTTP_VERSION_2_0; - } - throw new \UnexpectedValueException('libcurl 7.33 needed for HTTP 2.0 support'); - } - - return CURL_HTTP_VERSION_NONE; - } - - /** - * Add request body related cURL options. - * - * @param RequestInterface $request - * @param array $options - * - * @return array - */ - private function addRequestBodyOptions(RequestInterface $request, array $options) - { - /* - * Some HTTP methods cannot have payload: - * - * - GET — cURL will automatically change method to PUT or POST if we set CURLOPT_UPLOAD or - * CURLOPT_POSTFIELDS. - * - HEAD — cURL treats HEAD as GET request with a same restrictions. - * - TRACE — According to RFC7231: a client MUST NOT send a message body in a TRACE request. - */ - if (!in_array($request->getMethod(), ['GET', 'HEAD', 'TRACE'], true)) { - $body = $request->getBody(); - $bodySize = $body->getSize(); - if ($bodySize !== 0) { - if ($body->isSeekable()) { - $body->rewind(); - } - - // Message has non empty body. - if (null === $bodySize || $bodySize > 1024 * 1024) { - // Avoid full loading large or unknown size body into memory - $options[CURLOPT_UPLOAD] = true; - if (null !== $bodySize) { - $options[CURLOPT_INFILESIZE] = $bodySize; - } - $options[CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use ($body) { - return $body->read($length); - }; - } else { - // Small body can be loaded into memory - $options[CURLOPT_POSTFIELDS] = (string) $body; - } - } - } - - if ($request->getMethod() === 'HEAD') { - // This will set HTTP method to "HEAD". - $options[CURLOPT_NOBODY] = true; - } elseif ($request->getMethod() !== 'GET') { - // GET is a default method. Other methods should be specified explicitly. - $options[CURLOPT_CUSTOMREQUEST] = $request->getMethod(); - } - - return $options; - } - - /** - * Create headers array for CURLOPT_HTTPHEADER. - * - * @param RequestInterface $request - * @param array $options cURL options - * - * @return string[] - */ - private function createHeaders(RequestInterface $request, array $options) - { - $curlHeaders = []; - $headers = $request->getHeaders(); - foreach ($headers as $name => $values) { - $header = strtolower($name); - if ('expect' === $header) { - // curl-client does not support "Expect-Continue", so dropping "expect" headers - continue; - } - if ('content-length' === $header) { - if (array_key_exists(CURLOPT_POSTFIELDS, $options)) { - // Small body content length can be calculated here. - $values = [strlen($options[CURLOPT_POSTFIELDS])]; - } elseif (!array_key_exists(CURLOPT_READFUNCTION, $options)) { - // Else if there is no body, forcing "Content-length" to 0 - $values = [0]; - } - } - foreach ($values as $value) { - $curlHeaders[] = $name.': '.$value; - } - } - /* - * curl-client does not support "Expect-Continue", but cURL adds "Expect" header by default. - * We can not suppress it, but we can set it to empty. - */ - $curlHeaders[] = 'Expect:'; - - return $curlHeaders; - } - - /** - * Create new ResponseBuilder instance. - * - * @return ResponseBuilder - * - * @throws \RuntimeException If creating the stream from $body fails - */ - private function createResponseBuilder() - { - try { - $body = $this->streamFactory->createStream(fopen('php://temp', 'w+b')); - } catch (\InvalidArgumentException $e) { - throw new \RuntimeException('Can not create "php://temp" stream.'); - } - $response = $this->messageFactory->createResponse(200, null, [], $body); - - return new ResponseBuilder($response); - } -} diff --git a/vendor/php-http/curl-client/src/CurlPromise.php b/vendor/php-http/curl-client/src/CurlPromise.php deleted file mode 100755 index 5061af579fcdb14eb062ac060283f80d4eb2b38f..0000000000000000000000000000000000000000 --- a/vendor/php-http/curl-client/src/CurlPromise.php +++ /dev/null @@ -1,109 +0,0 @@ -<?php - -namespace Http\Client\Curl; - -use Http\Promise\Promise; - -/** - * Promise represents a response that may not be available yet, but will be resolved at some point - * in future. It acts like a proxy to the actual response. - * - * This interface is an extension of the promises/a+ specification https://promisesaplus.com/ - * Value is replaced by an object where its class implement a Psr\Http\Message\RequestInterface. - * Reason is replaced by an object where its class implement a Http\Client\Exception. - * - * @license http://opensource.org/licenses/MIT MIT - * @author Михаил Красильников <m.krasilnikov@yandex.ru> - */ -class CurlPromise implements Promise -{ - /** - * Shared promise core. - * - * @var PromiseCore - */ - private $core; - - /** - * Requests runner. - * - * @var MultiRunner - */ - private $runner; - - /** - * Create new promise. - * - * @param PromiseCore $core Shared promise core - * @param MultiRunner $runner Simultaneous requests runner - */ - public function __construct(PromiseCore $core, MultiRunner $runner) - { - $this->core = $core; - $this->runner = $runner; - } - - /** - * Add behavior for when the promise is resolved or rejected. - * - * If you do not care about one of the cases, you can set the corresponding callable to null - * The callback will be called when the response or exception arrived and never more than once. - * - * @param callable $onFulfilled Called when a response will be available - * @param callable $onRejected Called when an error happens. - * - * You must always return the Response in the interface or throw an Exception - * - * @return Promise Always returns a new promise which is resolved with value of the executed - * callback (onFulfilled / onRejected) - */ - public function then(callable $onFulfilled = null, callable $onRejected = null) - { - if ($onFulfilled) { - $this->core->addOnFulfilled($onFulfilled); - } - if ($onRejected) { - $this->core->addOnRejected($onRejected); - } - - return new self($this->core, $this->runner); - } - - /** - * Get the state of the promise, one of PENDING, FULFILLED or REJECTED. - * - * @return string - */ - public function getState() - { - return $this->core->getState(); - } - - /** - * Wait for the promise to be fulfilled or rejected. - * - * When this method returns, the request has been resolved and the appropriate callable has terminated. - * - * When called with the unwrap option - * - * @param bool $unwrap Whether to return resolved value / throw reason or not - * - * @return \Psr\Http\Message\ResponseInterface|null Resolved value, null if $unwrap is set to false - * - * @throws \Http\Client\Exception The rejection reason - */ - public function wait($unwrap = true) - { - $this->runner->wait($this->core); - - if ($unwrap) { - if ($this->core->getState() === self::REJECTED) { - throw $this->core->getException(); - } - - return $this->core->getResponse(); - } - - return null; - } -} diff --git a/vendor/php-http/curl-client/src/MultiRunner.php b/vendor/php-http/curl-client/src/MultiRunner.php deleted file mode 100755 index 545f39a3d4b7a5787e80597048d3d1e3ec152be1..0000000000000000000000000000000000000000 --- a/vendor/php-http/curl-client/src/MultiRunner.php +++ /dev/null @@ -1,129 +0,0 @@ -<?php - -namespace Http\Client\Curl; - -use Http\Client\Exception\RequestException; - -/** - * Simultaneous requests runner. - * - * @license http://opensource.org/licenses/MIT MIT - * @author Михаил Красильников <m.krasilnikov@yandex.ru> - */ -class MultiRunner -{ - /** - * cURL multi handle. - * - * @var resource|null - */ - private $multiHandle = null; - - /** - * Awaiting cores. - * - * @var PromiseCore[] - */ - private $cores = []; - - /** - * Release resources if still active. - */ - public function __destruct() - { - if (is_resource($this->multiHandle)) { - curl_multi_close($this->multiHandle); - } - } - - /** - * Add promise to runner. - * - * @param PromiseCore $core - */ - public function add(PromiseCore $core) - { - foreach ($this->cores as $existed) { - if ($existed === $core) { - return; - } - } - - $this->cores[] = $core; - - if (null === $this->multiHandle) { - $this->multiHandle = curl_multi_init(); - } - curl_multi_add_handle($this->multiHandle, $core->getHandle()); - } - - /** - * Remove promise from runner. - * - * @param PromiseCore $core - */ - public function remove(PromiseCore $core) - { - foreach ($this->cores as $index => $existed) { - if ($existed === $core) { - curl_multi_remove_handle($this->multiHandle, $core->getHandle()); - unset($this->cores[$index]); - - return; - } - } - } - - /** - * Wait for request(s) to be completed. - * - * @param PromiseCore|null $targetCore - */ - public function wait(PromiseCore $targetCore = null) - { - do { - $status = curl_multi_exec($this->multiHandle, $active); - $info = curl_multi_info_read($this->multiHandle); - if (false !== $info) { - $core = $this->findCoreByHandle($info['handle']); - - if (null === $core) { - // We have no promise for this handle. Drop it. - curl_multi_remove_handle($this->multiHandle, $info['handle']); - continue; - } - - if (CURLE_OK === $info['result']) { - $core->fulfill(); - } else { - $error = curl_error($core->getHandle()); - $core->reject(new RequestException($error, $core->getRequest())); - } - $this->remove($core); - - // This is a promise we are waited for. So exiting wait(). - if ($core === $targetCore) { - return; - } - } - } while ($status === CURLM_CALL_MULTI_PERFORM || $active); - } - - /** - * Find core by handle. - * - * @param resource $handle - * - * @return PromiseCore|null - */ - private function findCoreByHandle($handle) - { - foreach ($this->cores as $core) { - if ($core->getHandle() === $handle) { - return $core; - } - } - - return null; - } -} diff --git a/vendor/php-http/curl-client/src/PromiseCore.php b/vendor/php-http/curl-client/src/PromiseCore.php deleted file mode 100755 index 09065c4bff3986df6c56836151c2b6be942a95e8..0000000000000000000000000000000000000000 --- a/vendor/php-http/curl-client/src/PromiseCore.php +++ /dev/null @@ -1,241 +0,0 @@ -<?php - -namespace Http\Client\Curl; - -use Http\Client\Exception; -use Http\Promise\Promise; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Shared promises core. - * - * @license http://opensource.org/licenses/MIT MIT - * @author Михаил Красильников <m.krasilnikov@yandex.ru> - */ -class PromiseCore -{ - /** - * HTTP request. - * - * @var RequestInterface - */ - private $request; - - /** - * cURL handle. - * - * @var resource - */ - private $handle; - - /** - * Response builder. - * - * @var ResponseBuilder - */ - private $responseBuilder; - - /** - * Promise state. - * - * @var string - */ - private $state; - - /** - * Exception. - * - * @var Exception|null - */ - private $exception = null; - - /** - * Functions to call when a response will be available. - * - * @var callable[] - */ - private $onFulfilled = []; - - /** - * Functions to call when an error happens. - * - * @var callable[] - */ - private $onRejected = []; - - /** - * Create shared core. - * - * @param RequestInterface $request HTTP request. - * @param resource $handle cURL handle. - * @param ResponseBuilder $responseBuilder Response builder. - * - * @throws \InvalidArgumentException If $handle is not a cURL resource. - */ - public function __construct( - RequestInterface $request, - $handle, - ResponseBuilder $responseBuilder - ) { - if (!is_resource($handle)) { - throw new \InvalidArgumentException( - sprintf( - 'Parameter $handle expected to be a cURL resource, %s given', - gettype($handle) - ) - ); - } - - if (get_resource_type($handle) !== 'curl') { - throw new \InvalidArgumentException( - sprintf( - 'Parameter $handle expected to be a cURL resource, %s resource given', - get_resource_type($handle) - ) - ); - } - - $this->request = $request; - $this->handle = $handle; - $this->responseBuilder = $responseBuilder; - $this->state = Promise::PENDING; - } - - /** - * Add on fulfilled callback. - * - * @param callable $callback - */ - public function addOnFulfilled(callable $callback) - { - if ($this->getState() === Promise::PENDING) { - $this->onFulfilled[] = $callback; - } elseif ($this->getState() === Promise::FULFILLED) { - $response = call_user_func($callback, $this->responseBuilder->getResponse()); - if ($response instanceof ResponseInterface) { - $this->responseBuilder->setResponse($response); - } - } - } - - /** - * Add on rejected callback. - * - * @param callable $callback - */ - public function addOnRejected(callable $callback) - { - if ($this->getState() === Promise::PENDING) { - $this->onRejected[] = $callback; - } elseif ($this->getState() === Promise::REJECTED) { - $this->exception = call_user_func($callback, $this->exception); - } - } - - /** - * Return cURL handle. - * - * @return resource - */ - public function getHandle() - { - return $this->handle; - } - - /** - * Get the state of the promise, one of PENDING, FULFILLED or REJECTED. - * - * @return string - */ - public function getState() - { - return $this->state; - } - - /** - * Return request. - * - * @return RequestInterface - */ - public function getRequest() - { - return $this->request; - } - - /** - * Return the value of the promise (fulfilled). - * - * @return ResponseInterface Response Object only when the Promise is fulfilled - */ - public function getResponse() - { - return $this->responseBuilder->getResponse(); - } - - /** - * Get the reason why the promise was rejected. - * - * If the exception is an instance of Http\Client\Exception\HttpException it will contain - * the response object with the status code and the http reason. - * - * @return Exception Exception Object only when the Promise is rejected - * - * @throws \LogicException When the promise is not rejected - */ - public function getException() - { - if (null === $this->exception) { - throw new \LogicException('Promise is not rejected'); - } - - return $this->exception; - } - - /** - * Fulfill promise. - */ - public function fulfill() - { - $this->state = Promise::FULFILLED; - $response = $this->responseBuilder->getResponse(); - try { - $response->getBody()->seek(0); - } catch (\RuntimeException $e) { - $exception = new Exception\TransferException($e->getMessage(), $e->getCode(), $e); - $this->reject($exception); - - return; - } - - while (count($this->onFulfilled) > 0) { - $callback = array_shift($this->onFulfilled); - $response = call_user_func($callback, $response); - } - - if ($response instanceof ResponseInterface) { - $this->responseBuilder->setResponse($response); - } - } - - /** - * Reject promise. - * - * @param Exception $exception Reject reason - */ - public function reject(Exception $exception) - { - $this->exception = $exception; - $this->state = Promise::REJECTED; - - while (count($this->onRejected) > 0) { - $callback = array_shift($this->onRejected); - try { - $exception = call_user_func($callback, $this->exception); - $this->exception = $exception; - } catch (Exception $exception) { - $this->exception = $exception; - } - } - } -} diff --git a/vendor/php-http/curl-client/src/ResponseBuilder.php b/vendor/php-http/curl-client/src/ResponseBuilder.php deleted file mode 100755 index 805b330bd6a3f6d4329fde0fe85e440c0a2c90c7..0000000000000000000000000000000000000000 --- a/vendor/php-http/curl-client/src/ResponseBuilder.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php - -namespace Http\Client\Curl; - -use Http\Message\Builder\ResponseBuilder as OriginalResponseBuilder; -use Psr\Http\Message\ResponseInterface; - -/** - * Extended response builder. - */ -class ResponseBuilder extends OriginalResponseBuilder -{ - /** - * Replace response with a new instance. - * - * @param ResponseInterface $response - */ - public function setResponse(ResponseInterface $response) - { - $this->response = $response; - } -} diff --git a/vendor/php-http/discovery/CHANGELOG.md b/vendor/php-http/discovery/CHANGELOG.md deleted file mode 100755 index 00c5136b44429d873c66b2b6ab245c7361930a07..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/CHANGELOG.md +++ /dev/null @@ -1,192 +0,0 @@ -# Change Log - -## 1.4.0 - 2018-02-06 - -### Added - -- Discovery support for nyholm/psr7 - -## 1.3.0 - 2017-08-03 - -### Added - -- Discovery support for CakePHP adapter -- Discovery support for Zend adapter -- Discovery support for Artax adapter - -## 1.2.1 - 2017-03-02 - -### Fixed - -- Fixed minor issue with `MockClientStrategy`, also added more tests. - -## 1.2.0 - 2017-02-12 - -### Added - -- MockClientStrategy class. - -## 1.1.1 - 2016-11-27 - -### Changed - -- Made exception messages clearer. `StrategyUnavailableException` is no longer the previous exception to `DiscoveryFailedException`. -- `CommonClassesStrategy` is using `self` instead of `static`. Using `static` makes no sense when `CommonClassesStrategy` is final. - -## 1.1.0 - 2016-10-20 - -### Added - -- Discovery support for Slim Framework factories - -## 1.0.0 - 2016-07-18 - -### Added - -- Added back `Http\Discovery\NotFoundException` to preserve BC with 0.8 version. You may upgrade from 0.8.x and 0.9.x to 1.0.0 without any BC breaks. -- Added interface `Http\Discovery\Exception` which is implemented by all our exceptions - -### Changed - -- Puli strategy renamed to Puli Beta strategy to prevent incompatibility with a future Puli stable - -### Deprecated - -- For BC reasons, the old `Http\Discovery\NotFoundException` (extending the new exception) will be thrown until version 2.0 - - -## 0.9.1 - 2016-06-28 - -### Changed - -- Dropping PHP 5.4 support because we use the ::class constant. - - -## 0.9.0 - 2016-06-25 - -### Added - -- Discovery strategies to find classes - -### Changed - -- [Puli](http://puli.io) made optional -- Improved exceptions -- **[BC] `NotFoundException` moved to `Http\Discovery\Exception\NotFoundException`** - - -## 0.8.0 - 2016-02-11 - -### Changed - -- Puli composer plugin must be installed separately - - -## 0.7.0 - 2016-01-15 - -### Added - -- Temporary puli.phar (Beta 10) executable - -### Changed - -- Updated HTTPlug dependencies -- Updated Puli dependencies -- Local configuration to make tests passing - -### Removed - -- Puli CLI dependency - - -## 0.6.4 - 2016-01-07 - -### Fixed - -- Puli [not working](https://twitter.com/PuliPHP/status/685132540588507137) with the latest json-schema - - -## 0.6.3 - 2016-01-04 - -### Changed - -- Adjust Puli dependencies - - -## 0.6.2 - 2016-01-04 - -### Changed - -- Make Puli CLI a requirement - - -## 0.6.1 - 2016-01-03 - -### Changed - -- More flexible Puli requirement - - -## 0.6.0 - 2015-12-30 - -### Changed - -- Use [Puli](http://puli.io) for discovery -- Improved exception messages - - -## 0.5.0 - 2015-12-25 - -### Changed - -- Updated message factory dependency (php-http/message) - - -## 0.4.0 - 2015-12-17 - -### Added - -- Array condition evaluation in the Class Discovery - -### Removed - -- Message factories (moved to php-http/utils) - - -## 0.3.0 - 2015-11-18 - -### Added - -- HTTP Async Client Discovery -- Stream factories - -### Changed - -- Discoveries and Factories are final -- Message and Uri factories have the type in their names -- Diactoros Message factory uses Stream factory internally - -### Fixed - -- Improved docblocks for API documentation generation - - -## 0.2.0 - 2015-10-31 - -### Changed - -- Renamed AdapterDiscovery to ClientDiscovery - - -## 0.1.1 - 2015-06-13 - -### Fixed - -- Bad HTTP Adapter class name for Guzzle 5 - - -## 0.1.0 - 2015-06-12 - -### Added - -- Initial release diff --git a/vendor/php-http/discovery/LICENSE b/vendor/php-http/discovery/LICENSE deleted file mode 100755 index 4558d6f06306fce15add8bc10e29152bc4ad5355..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015-2016 PHP HTTP Team <team@php-http.org> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/php-http/discovery/README.md b/vendor/php-http/discovery/README.md deleted file mode 100755 index 7c5151eabd84ec8fc006c8eed448ee9aff3e7b4f..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# HTTPlug Discovery - -[](https://github.com/php-http/discovery/releases) -[](LICENSE) -[](https://travis-ci.org/php-http/discovery) -[](https://scrutinizer-ci.com/g/php-http/discovery) -[](https://scrutinizer-ci.com/g/php-http/discovery) -[](https://packagist.org/packages/php-http/discovery) - -**Finds installed HTTPlug implementations and PSR-7 message factories.** - - -## Install - -Via Composer - -``` bash -$ composer require php-http/discovery -``` - - -## Documentation - -Please see the [official documentation](http://php-http.readthedocs.org/en/latest/discovery.html). - - -## Testing - -``` bash -$ composer test -``` - - -## Contributing - -Please see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html). - - -## Security - -If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org). - - -## License - -The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/vendor/php-http/discovery/composer.json b/vendor/php-http/discovery/composer.json deleted file mode 100755 index 128af59a32a72b5e07eb58c734af2e0dd3e2b64b..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/composer.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "name": "php-http/discovery", - "description": "Finds installed HTTPlug implementations and PSR-7 message factories", - "license": "MIT", - "keywords": ["http", "discovery", "client", "adapter", "message", "factory", "psr7"], - "homepage": "http://php-http.org", - "authors": [ - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "require": { - "php": "^5.5 || ^7.0" - }, - "require-dev": { - "php-http/httplug": "^1.0", - "php-http/message-factory": "^1.0", - "puli/composer-plugin": "1.0.0-beta10", - "phpspec/phpspec": "^2.4", - "henrikbjorn/phpspec-code-coverage" : "^2.0.2" - }, - "suggest": { - "puli/composer-plugin": "Sets up Puli which is recommended for Discovery to work. Check http://docs.php-http.org/en/latest/discovery.html for more details.", - "php-http/message": "Allow to use Guzzle, Diactoros or Slim Framework factories" - }, - "autoload": { - "psr-4": { - "Http\\Discovery\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "spec\\Http\\Discovery\\": "spec/" - } - }, - "scripts": { - "test": "vendor/bin/phpspec run", - "test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml" - }, - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "prefer-stable": true, - "minimum-stability": "beta" -} diff --git a/vendor/php-http/discovery/src/ClassDiscovery.php b/vendor/php-http/discovery/src/ClassDiscovery.php deleted file mode 100755 index 760df6b778c1829f78195b0c15077241c3458077..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/ClassDiscovery.php +++ /dev/null @@ -1,208 +0,0 @@ -<?php - -namespace Http\Discovery; - -use Http\Discovery\Exception\ClassInstantiationFailedException; -use Http\Discovery\Exception\DiscoveryFailedException; -use Http\Discovery\Exception\StrategyUnavailableException; - -/** - * Registry that based find results on class existence. - * - * @author David de Boer <david@ddeboer.nl> - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -abstract class ClassDiscovery -{ - /** - * A list of strategies to find classes. - * - * @var array - */ - private static $strategies = [ - Strategy\PuliBetaStrategy::class, - Strategy\CommonClassesStrategy::class, - ]; - - /** - * Discovery cache to make the second time we use discovery faster. - * - * @var array - */ - private static $cache = []; - - /** - * Finds a class. - * - * @param string $type - * - * @return string|\Closure - * - * @throws DiscoveryFailedException - */ - protected static function findOneByType($type) - { - // Look in the cache - if (null !== ($class = self::getFromCache($type))) { - return $class; - } - - $exceptions = []; - foreach (self::$strategies as $strategy) { - try { - $candidates = call_user_func($strategy.'::getCandidates', $type); - } catch (StrategyUnavailableException $e) { - $exceptions[] = $e; - - continue; - } - - foreach ($candidates as $candidate) { - if (isset($candidate['condition'])) { - if (!self::evaluateCondition($candidate['condition'])) { - continue; - } - } - - // save the result for later use - self::storeInCache($type, $candidate); - - return $candidate['class']; - } - } - - throw DiscoveryFailedException::create($exceptions); - } - - /** - * Get a value from cache. - * - * @param string $type - * - * @return string|null - */ - private static function getFromCache($type) - { - if (!isset(self::$cache[$type])) { - return; - } - - $candidate = self::$cache[$type]; - if (isset($candidate['condition'])) { - if (!self::evaluateCondition($candidate['condition'])) { - return; - } - } - - return $candidate['class']; - } - - /** - * Store a value in cache. - * - * @param string $type - * @param string $class - */ - private static function storeInCache($type, $class) - { - self::$cache[$type] = $class; - } - - /** - * Set new strategies and clear the cache. - * - * @param array $strategies string array of fully qualified class name to a DiscoveryStrategy - */ - public static function setStrategies(array $strategies) - { - self::$strategies = $strategies; - self::clearCache(); - } - - /** - * Append a strategy at the end of the strategy queue. - * - * @param string $strategy Fully qualified class name to a DiscoveryStrategy - */ - public static function appendStrategy($strategy) - { - self::$strategies[] = $strategy; - self::clearCache(); - } - - /** - * Prepend a strategy at the beginning of the strategy queue. - * - * @param string $strategy Fully qualified class name to a DiscoveryStrategy - */ - public static function prependStrategy($strategy) - { - array_unshift(self::$strategies, $strategy); - self::clearCache(); - } - - /** - * Clear the cache. - */ - public static function clearCache() - { - self::$cache = []; - } - - /** - * Evaluates conditions to boolean. - * - * @param mixed $condition - * - * @return bool - */ - protected static function evaluateCondition($condition) - { - if (is_string($condition)) { - // Should be extended for functions, extensions??? - return class_exists($condition); - } elseif (is_callable($condition)) { - return $condition(); - } elseif (is_bool($condition)) { - return $condition; - } elseif (is_array($condition)) { - $evaluatedCondition = true; - - // Immediately stop execution if the condition is false - for ($i = 0; $i < count($condition) && false !== $evaluatedCondition; ++$i) { - $evaluatedCondition &= static::evaluateCondition($condition[$i]); - } - - return $evaluatedCondition; - } - - return false; - } - - /** - * Get an instance of the $class. - * - * @param string|\Closure $class A FQCN of a class or a closure that instantiate the class. - * - * @return object - * - * @throws ClassInstantiationFailedException - */ - protected static function instantiateClass($class) - { - try { - if (is_string($class)) { - return new $class(); - } - - if (is_callable($class)) { - return $class(); - } - } catch (\Exception $e) { - throw new ClassInstantiationFailedException('Unexpected exception when instantiating class.', 0, $e); - } - - throw new ClassInstantiationFailedException('Could not instantiate class because parameter is neither a callable nor a string'); - } -} diff --git a/vendor/php-http/discovery/src/Exception.php b/vendor/php-http/discovery/src/Exception.php deleted file mode 100755 index 973c9087e008e8fb767acb0d90b74f249cef0dac..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/Exception.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -namespace Http\Discovery; - -/** - * An interface implemented by all discovery related exceptions. - * - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -interface Exception -{ -} diff --git a/vendor/php-http/discovery/src/Exception/ClassInstantiationFailedException.php b/vendor/php-http/discovery/src/Exception/ClassInstantiationFailedException.php deleted file mode 100755 index e95bf5d826660c3cfc7d57fa4d26a5040c43776d..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/Exception/ClassInstantiationFailedException.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -namespace Http\Discovery\Exception; - -use Http\Discovery\Exception; - -/** - * Thrown when a class fails to instantiate. - * - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -final class ClassInstantiationFailedException extends \RuntimeException implements Exception -{ -} diff --git a/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php b/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php deleted file mode 100755 index 304b7276ec1c87b2e7b8d13deac9a0e47b2caeb0..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php - -namespace Http\Discovery\Exception; - -use Http\Discovery\Exception; - -/** - * Thrown when all discovery strategies fails to find a resource. - * - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -final class DiscoveryFailedException extends \Exception implements Exception -{ - /** - * @var \Exception[] - */ - private $exceptions; - - /** - * @param string $message - * @param \Exception[] $exceptions - */ - public function __construct($message, array $exceptions = []) - { - $this->exceptions = $exceptions; - - parent::__construct($message); - } - - /** - * @param \Exception[] $exceptions - */ - public static function create($exceptions) - { - $message = 'Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors'; - foreach ($exceptions as $e) { - $message .= "\n - ".$e->getMessage(); - } - $message .= "\n\n"; - - return new self($message, $exceptions); - } - - /** - * @return \Exception[] - */ - public function getExceptions() - { - return $this->exceptions; - } -} diff --git a/vendor/php-http/discovery/src/Exception/NotFoundException.php b/vendor/php-http/discovery/src/Exception/NotFoundException.php deleted file mode 100755 index befbf48874e71aa230f4bdd6dd55eee6d72b0eb4..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/Exception/NotFoundException.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php - -namespace Http\Discovery\Exception; - -use Http\Discovery\Exception; - -/** - * Thrown when a discovery does not find any matches. - * - * @final do NOT extend this class, not final for BC reasons - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -/*final */class NotFoundException extends \RuntimeException implements Exception -{ -} diff --git a/vendor/php-http/discovery/src/Exception/PuliUnavailableException.php b/vendor/php-http/discovery/src/Exception/PuliUnavailableException.php deleted file mode 100755 index a6ade733276d7aa911090a93ea0d2b58b50bc126..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/Exception/PuliUnavailableException.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -namespace Http\Discovery\Exception; - -/** - * Thrown when we can't use Puli for discovery. - * - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -final class PuliUnavailableException extends StrategyUnavailableException -{ -} diff --git a/vendor/php-http/discovery/src/Exception/StrategyUnavailableException.php b/vendor/php-http/discovery/src/Exception/StrategyUnavailableException.php deleted file mode 100755 index 89ecf3523b8f31b72b311767a1ceab5468a8d7db..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/Exception/StrategyUnavailableException.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php - -namespace Http\Discovery\Exception; - -use Http\Discovery\Exception; - -/** - * This exception is thrown when we cannot use a discovery strategy. This is *not* thrown when - * the discovery fails to find a class. - * - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -class StrategyUnavailableException extends \RuntimeException implements Exception -{ -} diff --git a/vendor/php-http/discovery/src/HttpAsyncClientDiscovery.php b/vendor/php-http/discovery/src/HttpAsyncClientDiscovery.php deleted file mode 100755 index 6ef60e70a06d5e8a0f8375209fa766859d434b2b..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/HttpAsyncClientDiscovery.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -namespace Http\Discovery; - -use Http\Client\HttpAsyncClient; -use Http\Discovery\Exception\DiscoveryFailedException; - -/** - * Finds an HTTP Asynchronous Client. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class HttpAsyncClientDiscovery extends ClassDiscovery -{ - /** - * Finds an HTTP Async Client. - * - * @return HttpAsyncClient - * - * @throws Exception\NotFoundException - */ - public static function find() - { - try { - $asyncClient = static::findOneByType(HttpAsyncClient::class); - } catch (DiscoveryFailedException $e) { - throw new NotFoundException( - 'No HTTPlug async clients found. Make sure to install a package providing "php-http/async-client-implementation". Example: "php-http/guzzle6-adapter".', - 0, - $e - ); - } - - return static::instantiateClass($asyncClient); - } -} diff --git a/vendor/php-http/discovery/src/HttpClientDiscovery.php b/vendor/php-http/discovery/src/HttpClientDiscovery.php deleted file mode 100755 index 2654b7ed7ed4b2a2be91e70dc87b8e053bc2dc20..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/HttpClientDiscovery.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -namespace Http\Discovery; - -use Http\Client\HttpClient; -use Http\Discovery\Exception\DiscoveryFailedException; - -/** - * Finds an HTTP Client. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -final class HttpClientDiscovery extends ClassDiscovery -{ - /** - * Finds an HTTP Client. - * - * @return HttpClient - * - * @throws Exception\NotFoundException - */ - public static function find() - { - try { - $client = static::findOneByType(HttpClient::class); - } catch (DiscoveryFailedException $e) { - throw new NotFoundException( - 'No HTTPlug clients found. Make sure to install a package providing "php-http/client-implementation". Example: "php-http/guzzle6-adapter".', - 0, - $e - ); - } - - return static::instantiateClass($client); - } -} diff --git a/vendor/php-http/discovery/src/MessageFactoryDiscovery.php b/vendor/php-http/discovery/src/MessageFactoryDiscovery.php deleted file mode 100755 index c21b9bf42bc41b082601b3223f1a4488c8e2e244..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/MessageFactoryDiscovery.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -namespace Http\Discovery; - -use Http\Discovery\Exception\DiscoveryFailedException; -use Http\Message\MessageFactory; - -/** - * Finds a Message Factory. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -final class MessageFactoryDiscovery extends ClassDiscovery -{ - /** - * Finds a Message Factory. - * - * @return MessageFactory - * - * @throws Exception\NotFoundException - */ - public static function find() - { - try { - $messageFactory = static::findOneByType(MessageFactory::class); - } catch (DiscoveryFailedException $e) { - throw new NotFoundException( - 'No message factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message implementation.', - 0, - $e - ); - } - - return static::instantiateClass($messageFactory); - } -} diff --git a/vendor/php-http/discovery/src/NotFoundException.php b/vendor/php-http/discovery/src/NotFoundException.php deleted file mode 100755 index d59dadbf8d256775c1f294986c5c0010c0c285d7..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/NotFoundException.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -namespace Http\Discovery; - -/** - * Thrown when a discovery does not find any matches. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - * - * @deprecated since since version 1.0, and will be removed in 2.0. Use {@link \Http\Discovery\Exception\NotFoundException} instead. - */ -final class NotFoundException extends \Http\Discovery\Exception\NotFoundException -{ -} diff --git a/vendor/php-http/discovery/src/Strategy/CommonClassesStrategy.php b/vendor/php-http/discovery/src/Strategy/CommonClassesStrategy.php deleted file mode 100755 index 31a39656ad5ae98a6916cf19f9c3b9b319754656..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/Strategy/CommonClassesStrategy.php +++ /dev/null @@ -1,94 +0,0 @@ -<?php - -namespace Http\Discovery\Strategy; - -use GuzzleHttp\Psr7\Request as GuzzleRequest; -use Http\Client\HttpAsyncClient; -use Http\Client\HttpClient; -use Http\Message\MessageFactory; -use Http\Message\MessageFactory\GuzzleMessageFactory; -use Http\Message\StreamFactory; -use Http\Message\StreamFactory\GuzzleStreamFactory; -use Http\Message\UriFactory; -use Http\Message\UriFactory\GuzzleUriFactory; -use Http\Message\MessageFactory\DiactorosMessageFactory; -use Http\Message\StreamFactory\DiactorosStreamFactory; -use Http\Message\UriFactory\DiactorosUriFactory; -use Zend\Diactoros\Request as DiactorosRequest; -use Http\Message\MessageFactory\SlimMessageFactory; -use Http\Message\StreamFactory\SlimStreamFactory; -use Http\Message\UriFactory\SlimUriFactory; -use Slim\Http\Request as SlimRequest; -use Http\Adapter\Guzzle6\Client as Guzzle6; -use Http\Adapter\Guzzle5\Client as Guzzle5; -use Http\Client\Curl\Client as Curl; -use Http\Client\Socket\Client as Socket; -use Http\Adapter\React\Client as React; -use Http\Adapter\Buzz\Client as Buzz; -use Http\Adapter\Cake\Client as Cake; -use Http\Adapter\Zend\Client as Zend; -use Http\Adapter\Artax\Client as Artax; -use Nyholm\Psr7\Request as NyholmRequest; -use Nyholm\Psr7\Factory\MessageFactory as NyholmMessageFactory; -use Nyholm\Psr7\Factory\StreamFactory as NyholmStreamFactory; -use Nyholm\Psr7\Factory\UriFactory as NyholmUriFactory; - -/** - * @internal - * - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -final class CommonClassesStrategy implements DiscoveryStrategy -{ - /** - * @var array - */ - private static $classes = [ - MessageFactory::class => [ - ['class' => NyholmMessageFactory::class, 'condition' => [NyholmRequest::class, NyholmMessageFactory::class]], - ['class' => GuzzleMessageFactory::class, 'condition' => [GuzzleRequest::class, GuzzleMessageFactory::class]], - ['class' => DiactorosMessageFactory::class, 'condition' => [DiactorosRequest::class, DiactorosMessageFactory::class]], - ['class' => SlimMessageFactory::class, 'condition' => [SlimRequest::class, SlimMessageFactory::class]], - ], - StreamFactory::class => [ - ['class' => NyholmStreamFactory::class, 'condition' => [NyholmRequest::class, NyholmStreamFactory::class]], - ['class' => GuzzleStreamFactory::class, 'condition' => [GuzzleRequest::class, GuzzleStreamFactory::class]], - ['class' => DiactorosStreamFactory::class, 'condition' => [DiactorosRequest::class, DiactorosStreamFactory::class]], - ['class' => SlimStreamFactory::class, 'condition' => [SlimRequest::class, SlimStreamFactory::class]], - ], - UriFactory::class => [ - ['class' => NyholmUriFactory::class, 'condition' => [NyholmRequest::class, NyholmUriFactory::class]], - ['class' => GuzzleUriFactory::class, 'condition' => [GuzzleRequest::class, GuzzleUriFactory::class]], - ['class' => DiactorosUriFactory::class, 'condition' => [DiactorosRequest::class, DiactorosUriFactory::class]], - ['class' => SlimUriFactory::class, 'condition' => [SlimRequest::class, SlimUriFactory::class]], - ], - HttpAsyncClient::class => [ - ['class' => Guzzle6::class, 'condition' => Guzzle6::class], - ['class' => Curl::class, 'condition' => Curl::class], - ['class' => React::class, 'condition' => React::class], - ], - HttpClient::class => [ - ['class' => Guzzle6::class, 'condition' => Guzzle6::class], - ['class' => Guzzle5::class, 'condition' => Guzzle5::class], - ['class' => Curl::class, 'condition' => Curl::class], - ['class' => Socket::class, 'condition' => Socket::class], - ['class' => Buzz::class, 'condition' => Buzz::class], - ['class' => React::class, 'condition' => React::class], - ['class' => Cake::class, 'condition' => Cake::class], - ['class' => Zend::class, 'condition' => Zend::class], - ['class' => Artax::class, 'condition' => Artax::class], - ], - ]; - - /** - * {@inheritdoc} - */ - public static function getCandidates($type) - { - if (isset(self::$classes[$type])) { - return self::$classes[$type]; - } - - return []; - } -} diff --git a/vendor/php-http/discovery/src/Strategy/DiscoveryStrategy.php b/vendor/php-http/discovery/src/Strategy/DiscoveryStrategy.php deleted file mode 100755 index 641485a63beaa2c6b39484dcf374e97b31e1173d..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/Strategy/DiscoveryStrategy.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php - -namespace Http\Discovery\Strategy; - -use Http\Discovery\Exception\StrategyUnavailableException; - -/** - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -interface DiscoveryStrategy -{ - /** - * Find a resource of a specific type. - * - * @param string $type - * - * @return array The return value is always an array with zero or more elements. Each - * element is an array with two keys ['class' => string, 'condition' => mixed]. - * - * @throws StrategyUnavailableException if we cannot use this strategy. - */ - public static function getCandidates($type); -} diff --git a/vendor/php-http/discovery/src/Strategy/MockClientStrategy.php b/vendor/php-http/discovery/src/Strategy/MockClientStrategy.php deleted file mode 100755 index 574478778c87408623ccd08350e358904ad748aa..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/Strategy/MockClientStrategy.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -namespace Http\Discovery\Strategy; - -use Http\Client\HttpClient; -use Http\Mock\Client as Mock; - -/** - * Find the Mock client. - * - * @author Sam Rapaport <me@samrapdev.com> - */ -final class MockClientStrategy implements DiscoveryStrategy -{ - /** - * {@inheritdoc} - */ - public static function getCandidates($type) - { - return (HttpClient::class === $type) - ? [['class' => Mock::class, 'condition' => Mock::class]] - : []; - } -} diff --git a/vendor/php-http/discovery/src/Strategy/PuliBetaStrategy.php b/vendor/php-http/discovery/src/Strategy/PuliBetaStrategy.php deleted file mode 100755 index 2666fb372cc3d23365ffa90449a1e4f51b315ad8..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/Strategy/PuliBetaStrategy.php +++ /dev/null @@ -1,91 +0,0 @@ -<?php - -namespace Http\Discovery\Strategy; - -use Http\Discovery\Exception\PuliUnavailableException; -use Puli\Discovery\Api\Discovery; -use Puli\GeneratedPuliFactory; - -/** - * Find candidates using Puli. - * - * @internal - * @final - * - * @author David de Boer <david@ddeboer.nl> - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -class PuliBetaStrategy implements DiscoveryStrategy -{ - /** - * @var GeneratedPuliFactory - */ - protected static $puliFactory; - - /** - * @var Discovery - */ - protected static $puliDiscovery; - - /** - * @return GeneratedPuliFactory - * - * @throws PuliUnavailableException - */ - private static function getPuliFactory() - { - if (null === self::$puliFactory) { - if (!defined('PULI_FACTORY_CLASS')) { - throw new PuliUnavailableException('Puli Factory is not available'); - } - - $puliFactoryClass = PULI_FACTORY_CLASS; - - if (!class_exists($puliFactoryClass)) { - throw new PuliUnavailableException('Puli Factory class does not exist'); - } - - self::$puliFactory = new $puliFactoryClass(); - } - - return self::$puliFactory; - } - - /** - * Returns the Puli discovery layer. - * - * @return Discovery - * - * @throws PuliUnavailableException - */ - private static function getPuliDiscovery() - { - if (!isset(self::$puliDiscovery)) { - $factory = self::getPuliFactory(); - $repository = $factory->createRepository(); - - self::$puliDiscovery = $factory->createDiscovery($repository); - } - - return self::$puliDiscovery; - } - - /** - * {@inheritdoc} - */ - public static function getCandidates($type) - { - $returnData = []; - $bindings = self::getPuliDiscovery()->findBindings($type); - - foreach ($bindings as $binding) { - $condition = true; - if ($binding->hasParameterValue('depends')) { - $condition = $binding->getParameterValue('depends'); - } - $returnData[] = ['class' => $binding->getClassName(), 'condition' => $condition]; - } - - return $returnData; - } -} diff --git a/vendor/php-http/discovery/src/StreamFactoryDiscovery.php b/vendor/php-http/discovery/src/StreamFactoryDiscovery.php deleted file mode 100755 index 7bcc8ce1728c36d4e35e41c61c41cd75aad78d58..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/StreamFactoryDiscovery.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -namespace Http\Discovery; - -use Http\Discovery\Exception\DiscoveryFailedException; -use Http\Message\StreamFactory; - -/** - * Finds a Stream Factory. - * - * @author Михаил Красильников <m.krasilnikov@yandex.ru> - */ -final class StreamFactoryDiscovery extends ClassDiscovery -{ - /** - * Finds a Stream Factory. - * - * @return StreamFactory - * - * @throws Exception\NotFoundException - */ - public static function find() - { - try { - $streamFactory = static::findOneByType(StreamFactory::class); - } catch (DiscoveryFailedException $e) { - throw new NotFoundException( - 'No stream factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message implementation.', - 0, - $e - ); - } - - return static::instantiateClass($streamFactory); - } -} diff --git a/vendor/php-http/discovery/src/UriFactoryDiscovery.php b/vendor/php-http/discovery/src/UriFactoryDiscovery.php deleted file mode 100755 index 1eef1e6f0ad7fe2b617faab17049f3beca6de33f..0000000000000000000000000000000000000000 --- a/vendor/php-http/discovery/src/UriFactoryDiscovery.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -namespace Http\Discovery; - -use Http\Discovery\Exception\DiscoveryFailedException; -use Http\Message\UriFactory; - -/** - * Finds a URI Factory. - * - * @author David de Boer <david@ddeboer.nl> - */ -final class UriFactoryDiscovery extends ClassDiscovery -{ - /** - * Finds a URI Factory. - * - * @return UriFactory - * - * @throws Exception\NotFoundException - */ - public static function find() - { - try { - $uriFactory = static::findOneByType(UriFactory::class); - } catch (DiscoveryFailedException $e) { - throw new NotFoundException( - 'No uri factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message implementation.', - 0, - $e - ); - } - - return static::instantiateClass($uriFactory); - } -} diff --git a/vendor/php-http/guzzle6-adapter/CHANGELOG.md b/vendor/php-http/guzzle6-adapter/CHANGELOG.md deleted file mode 100755 index 0fdb5069f33e2434b7136b771d9a1591d408dd97..0000000000000000000000000000000000000000 --- a/vendor/php-http/guzzle6-adapter/CHANGELOG.md +++ /dev/null @@ -1,66 +0,0 @@ -# Change Log - - -## 1.1.1 - 2016-05-10 - -### Fixed - -- Adapter can again be instantiated without a guzzle client. - -## 1.1.0 - 2016-05-09 - -### Added - -- Factory method Client::createWithConfig to create an adapter with custom - configuration for the underlying guzzle client. - - -## 1.0.0 - 2016-01-26 - - -## 0.4.1 - 2016-01-13 - -### Changed - -- Updated integration tests - -### Removed - -- Client common dependency - - -## 0.4.0 - 2016-01-12 - -### Changed - -- Updated package files -- Updated HTTPlug to RC1 - - -## 0.2.1 - 2015-12-17 - -### Added - -- Puli configuration and bindings - -### Changed - -- Guzzle setup conforms to HTTPlug requirement now: Minimal functionality in client - - -## 0.2.0 - 2015-12-15 - -### Added - -- Async client capabalities - -### Changed - -- HTTPlug instead of HTTP Adapter - - -## 0.1.0 - 2015-06-12 - -### Added - -- Initial release diff --git a/vendor/php-http/guzzle6-adapter/LICENSE b/vendor/php-http/guzzle6-adapter/LICENSE deleted file mode 100755 index 48741e41658896043f0cc0ee3d43a5fba5d171a3..0000000000000000000000000000000000000000 --- a/vendor/php-http/guzzle6-adapter/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2014-2015 Eric GELOEN <geloen.eric@gmail.com> -Copyright (c) 2015-2016 PHP HTTP Team <team@php-http.org> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/php-http/guzzle6-adapter/README.md b/vendor/php-http/guzzle6-adapter/README.md deleted file mode 100755 index 623eb2f8d318b57086ae44f8710d900f712fb5da..0000000000000000000000000000000000000000 --- a/vendor/php-http/guzzle6-adapter/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# Guzzle 6 HTTP Adapter - -[](https://github.com/php-http/guzzle6-adapter/releases) -[](LICENSE) -[](https://travis-ci.org/php-http/guzzle6-adapter) -[](https://scrutinizer-ci.com/g/php-http/guzzle6-adapter) -[](https://scrutinizer-ci.com/g/php-http/guzzle6-adapter) -[](https://packagist.org/packages/php-http/guzzle6-adapter) - -**Guzzle 6 HTTP Adapter.** - - -## Install - -Via Composer - -``` bash -$ composer require php-http/guzzle6-adapter -``` - - -## Documentation - -Please see the [official documentation](http://docs.php-http.org/en/latest/clients/guzzle6-adapter.html). - - -## Testing - -First launch the http server: - -```bash -$ ./vendor/bin/http_test_server > /dev/null 2>&1 & -``` - -Then the test suite: - -``` bash -$ composer test -``` - - -## Contributing - -Please see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html). - - -## Security - -If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org). - - -## Credits - -Thanks to [David de Boer](https://github.com/ddeboer) for implementing this adapter. - - -## License - -The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/vendor/php-http/guzzle6-adapter/composer.json b/vendor/php-http/guzzle6-adapter/composer.json deleted file mode 100755 index 2f01d1a465dd35cd95778e6d56ea392dc97a8631..0000000000000000000000000000000000000000 --- a/vendor/php-http/guzzle6-adapter/composer.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "php-http/guzzle6-adapter", - "description": "Guzzle 6 HTTP Adapter", - "license": "MIT", - "keywords": ["guzzle", "http"], - "homepage": "http://httplug.io", - "authors": [ - { - "name": "David de Boer", - "email": "david@ddeboer.nl" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "require": { - "php": ">=5.5.0", - "php-http/httplug": "^1.0", - "guzzlehttp/guzzle": "^6.0" - }, - "require-dev": { - "ext-curl": "*", - "php-http/adapter-integration-tests": "^0.4" - }, - "provide": { - "php-http/client-implementation": "1.0", - "php-http/async-client-implementation": "1.0" - }, - "autoload": { - "psr-4": { - "Http\\Adapter\\Guzzle6\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "Http\\Adapter\\Guzzle6\\Tests\\": "tests/" - } - }, - "scripts": { - "test": "vendor/bin/phpunit", - "test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml" - }, - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - } -} diff --git a/vendor/php-http/guzzle6-adapter/puli.json b/vendor/php-http/guzzle6-adapter/puli.json deleted file mode 100755 index bd296146404b6cec1deb6a7f3ab25f9c1144881c..0000000000000000000000000000000000000000 --- a/vendor/php-http/guzzle6-adapter/puli.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "version": "1.0", - "name": "php-http/guzzle6-adapter", - "bindings": { - "04b5a002-71a8-473d-a8df-75671551b84a": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Adapter\\Guzzle6\\Client", - "type": "Http\\Client\\HttpClient" - }, - "9c856476-7f6b-43df-a740-15420a5f839c": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Adapter\\Guzzle6\\Client", - "type": "Http\\Client\\HttpAsyncClient" - } - } -} diff --git a/vendor/php-http/guzzle6-adapter/src/Client.php b/vendor/php-http/guzzle6-adapter/src/Client.php deleted file mode 100755 index ded7494bddf8e315c9c84402df91f97703ba395d..0000000000000000000000000000000000000000 --- a/vendor/php-http/guzzle6-adapter/src/Client.php +++ /dev/null @@ -1,84 +0,0 @@ -<?php - -namespace Http\Adapter\Guzzle6; - -use GuzzleHttp\Client as GuzzleClient; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\HandlerStack; -use GuzzleHttp\Middleware; -use Http\Client\HttpAsyncClient; -use Http\Client\HttpClient; -use Psr\Http\Message\RequestInterface; - -/** - * HTTP Adapter for Guzzle 6. - * - * @author David de Boer <david@ddeboer.nl> - */ -class Client implements HttpClient, HttpAsyncClient -{ - /** - * @var ClientInterface - */ - private $client; - - /** - * @param ClientInterface|null $client - */ - public function __construct(ClientInterface $client = null) - { - if (!$client) { - $client = static::buildClient(); - } - - $this->client = $client; - } - - /** - * Factory method to create the guzzle 6 adapter with custom configuration for guzzle. - * - * @param array $config Configuration to create guzzle with. - * - * @return Client - */ - public static function createWithConfig(array $config) - { - return new self(static::buildClient($config)); - } - - /** - * {@inheritdoc} - */ - public function sendRequest(RequestInterface $request) - { - $promise = $this->sendAsyncRequest($request); - - return $promise->wait(); - } - - /** - * {@inheritdoc} - */ - public function sendAsyncRequest(RequestInterface $request) - { - $promise = $this->client->sendAsync($request); - - return new Promise($promise, $request); - } - - /** - * Build the guzzle client instance. - * - * @param array $config Additional configuration - * - * @return GuzzleClient - */ - private static function buildClient(array $config = []) - { - $handlerStack = new HandlerStack(\GuzzleHttp\choose_handler()); - $handlerStack->push(Middleware::prepareBody(), 'prepare_body'); - $config = array_merge(['handler' => $handlerStack], $config); - - return new GuzzleClient($config); - } -} diff --git a/vendor/php-http/guzzle6-adapter/src/Promise.php b/vendor/php-http/guzzle6-adapter/src/Promise.php deleted file mode 100755 index 4d5eb8df2071a3ad291cc0467d8c999ab402d5c1..0000000000000000000000000000000000000000 --- a/vendor/php-http/guzzle6-adapter/src/Promise.php +++ /dev/null @@ -1,140 +0,0 @@ -<?php - -namespace Http\Adapter\Guzzle6; - -use GuzzleHttp\Exception as GuzzleExceptions; -use GuzzleHttp\Promise\PromiseInterface; -use Http\Client\Exception as HttplugException; -use Http\Promise\Promise as HttpPromise; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Wrapper around Guzzle promises. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class Promise implements HttpPromise -{ - /** - * @var PromiseInterface - */ - private $promise; - - /** - * @var string State of the promise - */ - private $state; - - /** - * @var ResponseInterface - */ - private $response; - - /** - * @var HttplugException - */ - private $exception; - - /** - * @var RequestInterface - */ - private $request; - - /** - * @param PromiseInterface $promise - * @param RequestInterface $request - */ - public function __construct(PromiseInterface $promise, RequestInterface $request) - { - $this->request = $request; - $this->state = self::PENDING; - $this->promise = $promise->then(function ($response) { - $this->response = $response; - $this->state = self::FULFILLED; - - return $response; - }, function ($reason) use ($request) { - $this->state = self::REJECTED; - - if ($reason instanceof HttplugException) { - $this->exception = $reason; - } elseif ($reason instanceof GuzzleExceptions\GuzzleException) { - $this->exception = $this->handleException($reason, $request); - } elseif ($reason instanceof \Exception) { - $this->exception = new \RuntimeException('Invalid exception returned from Guzzle6', 0, $reason); - } else { - $this->exception = new \UnexpectedValueException('Reason returned from Guzzle6 must be an Exception', 0, $reason); - } - - throw $this->exception; - }); - } - - /** - * {@inheritdoc} - */ - public function then(callable $onFulfilled = null, callable $onRejected = null) - { - return new static($this->promise->then($onFulfilled, $onRejected), $this->request); - } - - /** - * {@inheritdoc} - */ - public function getState() - { - return $this->state; - } - - /** - * {@inheritdoc} - */ - public function wait($unwrap = true) - { - $this->promise->wait(false); - - if ($unwrap) { - if ($this->getState() == self::REJECTED) { - throw $this->exception; - } - - return $this->response; - } - } - - /** - * Converts a Guzzle exception into an Httplug exception. - * - * @param GuzzleExceptions\GuzzleException $exception - * @param RequestInterface $request - * - * @return HttplugException - */ - private function handleException(GuzzleExceptions\GuzzleException $exception, RequestInterface $request) - { - if ($exception instanceof GuzzleExceptions\SeekException) { - return new HttplugException\RequestException($exception->getMessage(), $request, $exception); - } - - if ($exception instanceof GuzzleExceptions\ConnectException) { - return new HttplugException\NetworkException($exception->getMessage(), $exception->getRequest(), $exception); - } - - if ($exception instanceof GuzzleExceptions\RequestException) { - // Make sure we have a response for the HttpException - if ($exception->hasResponse()) { - return new HttplugException\HttpException( - $exception->getMessage(), - $exception->getRequest(), - $exception->getResponse(), - $exception - ); - } - - return new HttplugException\RequestException($exception->getMessage(), $exception->getRequest(), $exception); - } - - return new HttplugException\TransferException($exception->getMessage(), 0, $exception); - } -} diff --git a/vendor/php-http/httplug/CHANGELOG.md b/vendor/php-http/httplug/CHANGELOG.md deleted file mode 100755 index 8478966ac4c4bd54a04ee0fb7255e4f8cad3072c..0000000000000000000000000000000000000000 --- a/vendor/php-http/httplug/CHANGELOG.md +++ /dev/null @@ -1,72 +0,0 @@ -# Change Log - -## 1.1.0 - 2016-08-31 - -- Added HttpFulfilledPromise and HttpRejectedPromise which respect the HttpAsyncClient interface - -## 1.0.0 - 2016-01-26 - -### Removed - -- Stability configuration from composer - - -## 1.0.0-RC1 - 2016-01-12 - -### Changed - -- Updated package files -- Updated promise dependency to RC1 - - -## 1.0.0-beta - 2015-12-17 - -### Added - -- Puli configuration and binding types - -### Changed - -- Exception concept - - -## 1.0.0-alpha3 - 2015-12-13 - -### Changed - -- Async client does not throw exceptions - -### Removed - -- Promise interface moved to its own repository: [php-http/promise](https://github.com/php-http/promise) - - -## 1.0.0-alpha2 - 2015-11-16 - -### Added - -- Async client and Promise interface - - -## 1.0.0-alpha - 2015-10-26 - -### Added - -- Better domain exceptions. - -### Changed - -- Purpose of the library: general HTTP CLient abstraction. - -### Removed - -- Request options: they should be configured at construction time. -- Multiple request sending: should be done asynchronously using Async Client. -- `getName` method - - -## 0.1.0 - 2015-06-03 - -### Added - -- Initial release diff --git a/vendor/php-http/httplug/LICENSE b/vendor/php-http/httplug/LICENSE deleted file mode 100755 index 48741e41658896043f0cc0ee3d43a5fba5d171a3..0000000000000000000000000000000000000000 --- a/vendor/php-http/httplug/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2014-2015 Eric GELOEN <geloen.eric@gmail.com> -Copyright (c) 2015-2016 PHP HTTP Team <team@php-http.org> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/php-http/httplug/README.md b/vendor/php-http/httplug/README.md deleted file mode 100755 index f46212bcc21204fb1ca6ab364295f19b625d5689..0000000000000000000000000000000000000000 --- a/vendor/php-http/httplug/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# HTTPlug - -[](https://github.com/php-http/httplug/releases) -[](LICENSE) -[](https://travis-ci.org/php-http/httplug) -[](https://scrutinizer-ci.com/g/php-http/httplug) -[](https://scrutinizer-ci.com/g/php-http/httplug) -[](https://packagist.org/packages/php-http/httplug) - -[](http://slack.httplug.io) -[](mailto:team@httplug.io) - -**HTTPlug, the HTTP client abstraction for PHP.** - - -## Install - -Via Composer - -``` bash -$ composer require php-http/httplug -``` - - -## Intro - -This is the contract package for HTTP Client. -Use it to create HTTP Clients which are interoperable and compatible with [PSR-7](http://www.php-fig.org/psr/psr-7/). - -This library is the official successor of the [ivory http adapter](https://github.com/egeloen/ivory-http-adapter). - - -## Documentation - -Please see the [official documentation](http://docs.php-http.org). - - -## Testing - -``` bash -$ composer test -``` - - -## Contributing - -Please see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html). - - -## Security - -If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org). - - -## License - -The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/vendor/php-http/httplug/composer.json b/vendor/php-http/httplug/composer.json deleted file mode 100755 index f74c4d30a24514cd4f8ab9b649cd09b276e01fb2..0000000000000000000000000000000000000000 --- a/vendor/php-http/httplug/composer.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "php-http/httplug", - "description": "HTTPlug, the HTTP client abstraction for PHP", - "license": "MIT", - "keywords": ["http", "client"], - "homepage": "http://httplug.io", - "authors": [ - { - "name": "Eric GELOEN", - "email": "geloen.eric@gmail.com" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "require": { - "php": ">=5.4", - "psr/http-message": "^1.0", - "php-http/promise": "^1.0" - }, - "require-dev": { - "phpspec/phpspec": "^2.4", - "henrikbjorn/phpspec-code-coverage" : "^1.0" - }, - "autoload": { - "psr-4": { - "Http\\Client\\": "src/" - } - }, - "scripts": { - "test": "vendor/bin/phpspec run", - "test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml" - }, - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - } -} diff --git a/vendor/php-http/httplug/puli.json b/vendor/php-http/httplug/puli.json deleted file mode 100755 index 416833152d401fcf93cee6b762690002e1a4ee15..0000000000000000000000000000000000000000 --- a/vendor/php-http/httplug/puli.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": "1.0", - "name": "php-http/httplug", - "binding-types": { - "Http\\Client\\HttpAsyncClient": { - "description": "Async HTTP Client" - }, - "Http\\Client\\HttpClient": { - "description": "HTTP Client" - } - } -} diff --git a/vendor/php-http/httplug/src/Exception.php b/vendor/php-http/httplug/src/Exception.php deleted file mode 100755 index e7382c3cdaa8a4d72d2065d04081430df4ad658d..0000000000000000000000000000000000000000 --- a/vendor/php-http/httplug/src/Exception.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -namespace Http\Client; - -/** - * Every HTTP Client related Exception must implement this interface. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -interface Exception -{ -} diff --git a/vendor/php-http/httplug/src/Exception/HttpException.php b/vendor/php-http/httplug/src/Exception/HttpException.php deleted file mode 100755 index f4f32a4d236111a38a6e99cd8c9160ba8accefa6..0000000000000000000000000000000000000000 --- a/vendor/php-http/httplug/src/Exception/HttpException.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php - -namespace Http\Client\Exception; - -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Thrown when a response was received but the request itself failed. - * - * In addition to the request, this exception always provides access to the response object. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -class HttpException extends RequestException -{ - /** - * @var ResponseInterface - */ - protected $response; - - /** - * @param string $message - * @param RequestInterface $request - * @param ResponseInterface $response - * @param \Exception|null $previous - */ - public function __construct( - $message, - RequestInterface $request, - ResponseInterface $response, - \Exception $previous = null - ) { - parent::__construct($message, $request, $previous); - - $this->response = $response; - $this->code = $response->getStatusCode(); - } - - /** - * Returns the response. - * - * @return ResponseInterface - */ - public function getResponse() - { - return $this->response; - } - - /** - * Factory method to create a new exception with a normalized error message. - * - * @param RequestInterface $request - * @param ResponseInterface $response - * @param \Exception|null $previous - * - * @return HttpException - */ - public static function create( - RequestInterface $request, - ResponseInterface $response, - \Exception $previous = null - ) { - $message = sprintf( - '[url] %s [http method] %s [status code] %s [reason phrase] %s', - $request->getRequestTarget(), - $request->getMethod(), - $response->getStatusCode(), - $response->getReasonPhrase() - ); - - return new self($message, $request, $response, $previous); - } -} diff --git a/vendor/php-http/httplug/src/Exception/NetworkException.php b/vendor/php-http/httplug/src/Exception/NetworkException.php deleted file mode 100755 index f2198e5b624c6ef492df7c78017ce6afae74caba..0000000000000000000000000000000000000000 --- a/vendor/php-http/httplug/src/Exception/NetworkException.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -namespace Http\Client\Exception; - -/** - * Thrown when the request cannot be completed because of network issues. - * - * There is no response object as this exception is thrown when no response has been received. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -class NetworkException extends RequestException -{ -} diff --git a/vendor/php-http/httplug/src/Exception/RequestException.php b/vendor/php-http/httplug/src/Exception/RequestException.php deleted file mode 100755 index cdce14bd1410773f2fed4e5f272de69e344e5665..0000000000000000000000000000000000000000 --- a/vendor/php-http/httplug/src/Exception/RequestException.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php - -namespace Http\Client\Exception; - -use Psr\Http\Message\RequestInterface; - -/** - * Exception for when a request failed, providing access to the failed request. - * - * This could be due to an invalid request, or one of the extending exceptions - * for network errors or HTTP error responses. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -class RequestException extends TransferException -{ - /** - * @var RequestInterface - */ - private $request; - - /** - * @param string $message - * @param RequestInterface $request - * @param \Exception|null $previous - */ - public function __construct($message, RequestInterface $request, \Exception $previous = null) - { - $this->request = $request; - - parent::__construct($message, 0, $previous); - } - - /** - * Returns the request. - * - * @return RequestInterface - */ - public function getRequest() - { - return $this->request; - } -} diff --git a/vendor/php-http/httplug/src/Exception/TransferException.php b/vendor/php-http/httplug/src/Exception/TransferException.php deleted file mode 100755 index a858cf5ec3a49168eda778be0c7e1b86e71ec6c1..0000000000000000000000000000000000000000 --- a/vendor/php-http/httplug/src/Exception/TransferException.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -namespace Http\Client\Exception; - -use Http\Client\Exception; - -/** - * Base exception for transfer related exceptions. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -class TransferException extends \RuntimeException implements Exception -{ -} diff --git a/vendor/php-http/httplug/src/HttpAsyncClient.php b/vendor/php-http/httplug/src/HttpAsyncClient.php deleted file mode 100755 index 492e511b697c8cafaa84d52172d2efe848bacfcc..0000000000000000000000000000000000000000 --- a/vendor/php-http/httplug/src/HttpAsyncClient.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -namespace Http\Client; - -use Http\Promise\Promise; -use Psr\Http\Message\RequestInterface; - -/** - * Sends a PSR-7 Request in an asynchronous way by returning a Promise. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -interface HttpAsyncClient -{ - /** - * Sends a PSR-7 request in an asynchronous way. - * - * Exceptions related to processing the request are available from the returned Promise. - * - * @param RequestInterface $request - * - * @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception. - * - * @throws \Exception If processing the request is impossible (eg. bad configuration). - */ - public function sendAsyncRequest(RequestInterface $request); -} diff --git a/vendor/php-http/httplug/src/HttpClient.php b/vendor/php-http/httplug/src/HttpClient.php deleted file mode 100755 index 0e51749fff709d1f548b39fdd0190a22001f161d..0000000000000000000000000000000000000000 --- a/vendor/php-http/httplug/src/HttpClient.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php - -namespace Http\Client; - -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Sends a PSR-7 Request and returns a PSR-7 response. - * - * @author GeLo <geloen.eric@gmail.com> - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - * @author David Buchmann <mail@davidbu.ch> - */ -interface HttpClient -{ - /** - * Sends a PSR-7 request. - * - * @param RequestInterface $request - * - * @return ResponseInterface - * - * @throws \Http\Client\Exception If an error happens during processing the request. - * @throws \Exception If processing the request is impossible (eg. bad configuration). - */ - public function sendRequest(RequestInterface $request); -} diff --git a/vendor/php-http/httplug/src/Promise/HttpFulfilledPromise.php b/vendor/php-http/httplug/src/Promise/HttpFulfilledPromise.php deleted file mode 100755 index 6779e4479fa0e12ec0c462752b778c731d641e3f..0000000000000000000000000000000000000000 --- a/vendor/php-http/httplug/src/Promise/HttpFulfilledPromise.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php - -namespace Http\Client\Promise; - -use Http\Client\Exception; -use Http\Promise\Promise; -use Psr\Http\Message\ResponseInterface; - -final class HttpFulfilledPromise implements Promise -{ - /** - * @var ResponseInterface - */ - private $response; - - /** - * @param ResponseInterface $response - */ - public function __construct(ResponseInterface $response) - { - $this->response = $response; - } - - /** - * {@inheritdoc} - */ - public function then(callable $onFulfilled = null, callable $onRejected = null) - { - if (null === $onFulfilled) { - return $this; - } - - try { - return new self($onFulfilled($this->response)); - } catch (Exception $e) { - return new HttpRejectedPromise($e); - } - } - - /** - * {@inheritdoc} - */ - public function getState() - { - return Promise::FULFILLED; - } - - /** - * {@inheritdoc} - */ - public function wait($unwrap = true) - { - if ($unwrap) { - return $this->response; - } - } -} diff --git a/vendor/php-http/httplug/src/Promise/HttpRejectedPromise.php b/vendor/php-http/httplug/src/Promise/HttpRejectedPromise.php deleted file mode 100755 index bfb0738f1c4abf615ab07797416d702c5017993b..0000000000000000000000000000000000000000 --- a/vendor/php-http/httplug/src/Promise/HttpRejectedPromise.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php - -namespace Http\Client\Promise; - -use Http\Client\Exception; -use Http\Promise\Promise; - -final class HttpRejectedPromise implements Promise -{ - /** - * @var Exception - */ - private $exception; - - /** - * @param Exception $exception - */ - public function __construct(Exception $exception) - { - $this->exception = $exception; - } - - /** - * {@inheritdoc} - */ - public function then(callable $onFulfilled = null, callable $onRejected = null) - { - if (null === $onRejected) { - return $this; - } - - try { - return new HttpFulfilledPromise($onRejected($this->exception)); - } catch (Exception $e) { - return new self($e); - } - } - - /** - * {@inheritdoc} - */ - public function getState() - { - return Promise::REJECTED; - } - - /** - * {@inheritdoc} - */ - public function wait($unwrap = true) - { - if ($unwrap) { - throw $this->exception; - } - } -} diff --git a/vendor/php-http/message-factory/CHANGELOG.md b/vendor/php-http/message-factory/CHANGELOG.md deleted file mode 100755 index 4711924c6e6ae6c63fa80301d5437f5cfac8635e..0000000000000000000000000000000000000000 --- a/vendor/php-http/message-factory/CHANGELOG.md +++ /dev/null @@ -1,65 +0,0 @@ -# Change Log - - -## 1.0.2 - 2015-12-19 - -### Added - -- Request and Response factory binding types to Puli - - -## 1.0.1 - 2015-12-17 - -### Added - -- Puli configuration and binding types - - -## 1.0.0 - 2015-12-15 - -### Added - -- Response Factory in order to be reused in Message and Server Message factories -- Request Factory - -### Changed - -- Message Factory extends Request and Response factories - - -## 1.0.0-RC1 - 2015-12-14 - -### Added - -- CS check - -### Changed - -- RuntimeException is thrown when the StreamFactory cannot write to the underlying stream - - -## 0.3.0 - 2015-11-16 - -### Removed - -- Client Context Factory -- Factory Awares and Templates - - -## 0.2.0 - 2015-11-16 - -### Changed - -- Reordered the parameters when creating a message to have the protocol last, -as its the least likely to need to be changed. - - -## 0.1.0 - 2015-06-01 - -### Added - -- Initial release - -### Changed - -- Helpers are renamed to templates diff --git a/vendor/php-http/message-factory/LICENSE b/vendor/php-http/message-factory/LICENSE deleted file mode 100755 index 8e2c4a0b85c31bf132105920cc90ba371025eb8a..0000000000000000000000000000000000000000 --- a/vendor/php-http/message-factory/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015 PHP HTTP Team <team@php-http.org> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/php-http/message-factory/README.md b/vendor/php-http/message-factory/README.md deleted file mode 100755 index 4654495a72f8c46a8d75eea963dc8ff1517993a1..0000000000000000000000000000000000000000 --- a/vendor/php-http/message-factory/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# PSR-7 Message Factory - -[](https://github.com/php-http/message-factory/releases) -[](LICENSE) -[](https://packagist.org/packages/php-http/message-factory) - -**Factory interfaces for PSR-7 HTTP Message.** - - -## Install - -Via Composer - -``` bash -$ composer require php-http/message-factory -``` - - -## Documentation - -Please see the [official documentation](http://php-http.readthedocs.org/en/latest/message-factory/). - - -## Contributing - -Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details. - - -## Security - -If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org). - - -## License - -The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/vendor/php-http/message-factory/composer.json b/vendor/php-http/message-factory/composer.json deleted file mode 100755 index 7c72febe5b40c1abd64b6ed844cecf544e975bca..0000000000000000000000000000000000000000 --- a/vendor/php-http/message-factory/composer.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "php-http/message-factory", - "description": "Factory interfaces for PSR-7 HTTP Message", - "license": "MIT", - "keywords": ["http", "factory", "message", "stream", "uri"], - "homepage": "http://php-http.org", - "authors": [ - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "require": { - "php": ">=5.4", - "psr/http-message": "^1.0" - }, - "autoload": { - "psr-4": { - "Http\\Message\\": "src/" - } - }, - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - } -} diff --git a/vendor/php-http/message-factory/puli.json b/vendor/php-http/message-factory/puli.json deleted file mode 100755 index 08d37627d1d9f60a6f11c6f7051975393710f5b0..0000000000000000000000000000000000000000 --- a/vendor/php-http/message-factory/puli.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "version": "1.0", - "binding-types": { - "Http\\Message\\MessageFactory": { - "description": "PSR-7 Message Factory", - "parameters": { - "depends": { - "description": "Optional class dependency which can be checked by consumers" - } - } - }, - "Http\\Message\\RequestFactory": { - "parameters": { - "depends": { - "description": "Optional class dependency which can be checked by consumers" - } - } - }, - "Http\\Message\\ResponseFactory": { - "parameters": { - "depends": { - "description": "Optional class dependency which can be checked by consumers" - } - } - }, - "Http\\Message\\StreamFactory": { - "description": "PSR-7 Stream Factory", - "parameters": { - "depends": { - "description": "Optional class dependency which can be checked by consumers" - } - } - }, - "Http\\Message\\UriFactory": { - "description": "PSR-7 URI Factory", - "parameters": { - "depends": { - "description": "Optional class dependency which can be checked by consumers" - } - } - } - } -} diff --git a/vendor/php-http/message-factory/src/MessageFactory.php b/vendor/php-http/message-factory/src/MessageFactory.php deleted file mode 100755 index 965aaa804e58cc65f145e58a021ec4d61094672d..0000000000000000000000000000000000000000 --- a/vendor/php-http/message-factory/src/MessageFactory.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -namespace Http\Message; - -/** - * Factory for PSR-7 Request and Response. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -interface MessageFactory extends RequestFactory, ResponseFactory -{ -} diff --git a/vendor/php-http/message-factory/src/RequestFactory.php b/vendor/php-http/message-factory/src/RequestFactory.php deleted file mode 100755 index 624e82f361c0691f2112e866f39bffcde71d122f..0000000000000000000000000000000000000000 --- a/vendor/php-http/message-factory/src/RequestFactory.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php - -namespace Http\Message; - -use Psr\Http\Message\UriInterface; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\StreamInterface; - -/** - * Factory for PSR-7 Request. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -interface RequestFactory -{ - /** - * Creates a new PSR-7 request. - * - * @param string $method - * @param string|UriInterface $uri - * @param array $headers - * @param resource|string|StreamInterface|null $body - * @param string $protocolVersion - * - * @return RequestInterface - */ - public function createRequest( - $method, - $uri, - array $headers = [], - $body = null, - $protocolVersion = '1.1' - ); -} diff --git a/vendor/php-http/message-factory/src/ResponseFactory.php b/vendor/php-http/message-factory/src/ResponseFactory.php deleted file mode 100755 index 2411ed3a179ee3e0fe2b99cb2a9c83ac6548fc0f..0000000000000000000000000000000000000000 --- a/vendor/php-http/message-factory/src/ResponseFactory.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -namespace Http\Message; - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\StreamInterface; - -/** - * Factory for PSR-7 Response. - * - * This factory contract can be reused in Message and Server Message factories. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -interface ResponseFactory -{ - /** - * Creates a new PSR-7 response. - * - * @param int $statusCode - * @param string|null $reasonPhrase - * @param array $headers - * @param resource|string|StreamInterface|null $body - * @param string $protocolVersion - * - * @return ResponseInterface - */ - public function createResponse( - $statusCode = 200, - $reasonPhrase = null, - array $headers = [], - $body = null, - $protocolVersion = '1.1' - ); -} diff --git a/vendor/php-http/message-factory/src/StreamFactory.php b/vendor/php-http/message-factory/src/StreamFactory.php deleted file mode 100755 index 327a902f9547cb7dd332e8a81b682c6ed9ac3a8a..0000000000000000000000000000000000000000 --- a/vendor/php-http/message-factory/src/StreamFactory.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php - -namespace Http\Message; - -use Psr\Http\Message\StreamInterface; - -/** - * Factory for PSR-7 Stream. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -interface StreamFactory -{ - /** - * Creates a new PSR-7 stream. - * - * @param string|resource|StreamInterface|null $body - * - * @return StreamInterface - * - * @throws \InvalidArgumentException If the stream body is invalid. - * @throws \RuntimeException If creating the stream from $body fails. - */ - public function createStream($body = null); -} diff --git a/vendor/php-http/message-factory/src/UriFactory.php b/vendor/php-http/message-factory/src/UriFactory.php deleted file mode 100755 index f05e62521087e1179fe758d772a438a539829dc5..0000000000000000000000000000000000000000 --- a/vendor/php-http/message-factory/src/UriFactory.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -namespace Http\Message; - -use Psr\Http\Message\UriInterface; - -/** - * Factory for PSR-7 URI. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -interface UriFactory -{ - /** - * Creates an PSR-7 URI. - * - * @param string|UriInterface $uri - * - * @return UriInterface - * - * @throws \InvalidArgumentException If the $uri argument can not be converted into a valid URI. - */ - public function createUri($uri); -} diff --git a/vendor/php-http/message/CHANGELOG.md b/vendor/php-http/message/CHANGELOG.md deleted file mode 100755 index 76763499376d0bbe1c500888fde98211f468054b..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/CHANGELOG.md +++ /dev/null @@ -1,139 +0,0 @@ -# Change Log - - -## 1.6.0 - 2017-07-05 - -### Added - -- CookieUtil::parseDate to create a date from cookie date string - -### Fixed - -- Fix curl command of CurlFormatter when there is an user-agent header - -## 1.5.0 - 2017-02-14 - -### Added - -- Check for empty string in Stream factories -- Cookie::createWithoutValidation Static constructor to create a cookie. Will not perform any attribute validation during instantiation. -- Cookie::isValid Method to check if cookie attributes are valid. - -### Fixed - -- FilteredStream::getSize returns null because the contents size is unknown. -- Stream factories does not rewinds streams. The previous behavior was not coherent between factories and inputs. - -### Deprecated - -- FilteredStream::getReadFilter The read filter is internal and should never be used by consuming code. -- FilteredStream::getWriteFilter We did not implement writing to the streams at all. And if we do, the filter is an internal information and should not be used by consuming code. - - -## 1.4.1 - 2016-12-16 - -### Fixed - -- Cookie::matchPath Cookie with root path (`/`) will not match sub path (e.g. `/cookie`). - - -## 1.4.0 - 2016-10-20 - -### Added - -- Message, stream and URI factories for [Slim Framework](https://github.com/slimphp/Slim) -- BufferedStream that allow you to decorate a non-seekable stream with a seekable one. -- cUrlFormatter to be able to redo the request with a cURL command - - -## 1.3.1 - 2016-07-15 - -### Fixed - -- FullHttpMessageFormatter will not read from streams that you cannot rewind (non-seekable) -- FullHttpMessageFormatter will not read from the stream if $maxBodyLength is zero -- FullHttpMessageFormatter rewinds streams after they are read - - -## 1.3.0 - 2016-07-14 - -### Added - -- FullHttpMessageFormatter to include headers and body in the formatted message - -### Fixed - -- #41: Response builder broke header value - - -## 1.2.0 - 2016-03-29 - -### Added - -- The RequestMatcher is built after the Symfony RequestMatcher and separates - scheme, host and path expressions and provides an option to filter on the - method -- New RequestConditional authentication method using request matchers -- Add automatic basic auth info detection based on the URL - -### Changed - -- Improved ResponseBuilder - -### Deprecated - -- RegexRequestMatcher, use RequestMatcher instead -- Matching authenitcation method, use RequestConditional instead - - -## 1.1.0 - 2016-02-25 - -### Added - - - Add a request matcher interface and regex implementation - - Add a callback request matcher implementation - - Add a ResponseBuilder, to create PSR7 Response from a string - -### Fixed - - - Fix casting string on a FilteredStream not filtering the output - - -## 1.0.0 - 2016-01-27 - - -## 0.2.0 - 2015-12-29 - -### Added - -- Autoregistration of stream filters using Composer autoload -- Cookie -- [Apigen](http://www.apigen.org/) configuration - - -## 0.1.2 - 2015-12-26 - -### Added - -- Request and response factory bindings - -### Fixed - -- Chunk filter namespace in Dechunk stream - - -## 0.1.1 - 2015-12-25 - -### Added - -- Formatter - - -## 0.1.0 - 2015-12-24 - -### Added - -- Authentication -- Encoding -- Message decorator -- Message factory (Guzzle, Diactoros) diff --git a/vendor/php-http/message/LICENSE b/vendor/php-http/message/LICENSE deleted file mode 100755 index 4558d6f06306fce15add8bc10e29152bc4ad5355..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015-2016 PHP HTTP Team <team@php-http.org> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/php-http/message/README.md b/vendor/php-http/message/README.md deleted file mode 100755 index 338b4157e347c4e4325837e04249950da5512d0a..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/README.md +++ /dev/null @@ -1,61 +0,0 @@ -# HTTP Message - -[](https://github.com/php-http/message/releases) -[](LICENSE) -[](https://travis-ci.org/php-http/message) -[](https://scrutinizer-ci.com/g/php-http/message) -[](https://scrutinizer-ci.com/g/php-http/message) -[](https://packagist.org/packages/php-http/message) - -**HTTP Message related tools.** - - -## Install - -Via Composer - -``` bash -$ composer require php-http/message -``` - - -## Intro - -This package contains various PSR-7 tools which might be useful in an HTTP workflow: - -- Authentication method implementations -- Various Stream encoding tools -- Message decorators -- Message factory implementations for Guzzle PSR-7 and Diactoros -- Cookie implementation -- Request matchers - - -## Documentation - -Please see the [official documentation](http://docs.php-http.org/en/latest/message.html). - - -## Testing - -``` bash -$ composer test -``` - - -## Contributing - -Please see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html). - -## Cretids - -Thanks to [Cuzzle](https://github.com/namshi/cuzzle) for inpiration for the `CurlCommandFormatter`. - -## Security - -If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org). - - -## License - -The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/vendor/php-http/message/apigen.neon b/vendor/php-http/message/apigen.neon deleted file mode 100755 index 0ba1a1850a7aeb5fa5382f83a65f50b7cfa79a92..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/apigen.neon +++ /dev/null @@ -1,6 +0,0 @@ -source: - - src/ - -destination: build/api/ - -templateTheme: bootstrap diff --git a/vendor/php-http/message/composer.json b/vendor/php-http/message/composer.json deleted file mode 100755 index 6fbc5dbc55e88d94937da34c4344570e3c9bbcc5..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/composer.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "php-http/message", - "description": "HTTP Message related tools", - "license": "MIT", - "keywords": ["message", "http", "psr-7"], - "homepage": "http://php-http.org", - "authors": [ - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "require": { - "php": ">=5.4", - "psr/http-message": "^1.0", - "php-http/message-factory": "^1.0.2", - "clue/stream-filter": "^1.3" - }, - "provide": { - "php-http/message-factory-implementation": "1.0" - }, - "require-dev": { - "zendframework/zend-diactoros": "^1.0", - "guzzlehttp/psr7": "^1.0", - "ext-zlib": "*", - "phpspec/phpspec": "^2.4", - "henrikbjorn/phpspec-code-coverage" : "^1.0", - "coduo/phpspec-data-provider-extension": "^1.0", - "akeneo/phpspec-skip-example-extension": "^1.0", - "slim/slim": "^3.0" - }, - "suggest": { - "zendframework/zend-diactoros": "Used with Diactoros Factories", - "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", - "slim/slim": "Used with Slim Framework PSR-7 implementation", - "ext-zlib": "Used with compressor/decompressor streams" - }, - "autoload": { - "psr-4": { - "Http\\Message\\": "src/" - }, - "files": [ - "src/filters.php" - ] - }, - "autoload-dev": { - "psr-4": { - "spec\\Http\\Message\\": "spec/" - } - }, - "scripts": { - "test": "vendor/bin/phpspec run", - "test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml" - }, - "extra": { - "branch-alias": { - "dev-master": "1.6-dev" - } - } -} diff --git a/vendor/php-http/message/puli.json b/vendor/php-http/message/puli.json deleted file mode 100755 index 024a85d9eae5cdb926ff1c870ac9f698f01f91ca..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/puli.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "version": "1.0", - "name": "php-http/message", - "bindings": { - "064d003d-78a1-48c4-8f3b-1f92ff25da69": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Message\\MessageFactory\\DiactorosMessageFactory", - "type": "Http\\Message\\MessageFactory", - "parameters": { - "depends": "Zend\\Diactoros\\Request" - } - }, - "0836751e-6558-4d1b-8993-4a52012947c3": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Message\\MessageFactory\\SlimMessageFactory", - "type": "Http\\Message\\ResponseFactory" - }, - "1d127622-dc61-4bfa-b9da-d221548d72c3": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Message\\MessageFactory\\SlimMessageFactory", - "type": "Http\\Message\\RequestFactory" - }, - "2438c2d0-0658-441f-8855-ddaf0f87d54d": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Message\\MessageFactory\\GuzzleMessageFactory", - "type": "Http\\Message\\MessageFactory", - "parameters": { - "depends": "GuzzleHttp\\Psr7\\Request" - } - }, - "253aa08c-d705-46e7-b1d2-e28c97eef792": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Message\\MessageFactory\\GuzzleMessageFactory", - "type": "Http\\Message\\RequestFactory", - "parameters": { - "depends": "GuzzleHttp\\Psr7\\Request" - } - }, - "273a34f9-62f4-4ba1-9801-b1284d49ff89": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Message\\StreamFactory\\GuzzleStreamFactory", - "type": "Http\\Message\\StreamFactory", - "parameters": { - "depends": "GuzzleHttp\\Psr7\\Stream" - } - }, - "304b83db-b594-4d83-ae75-1f633adf92f7": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Message\\UriFactory\\GuzzleUriFactory", - "type": "Http\\Message\\UriFactory", - "parameters": { - "depends": "GuzzleHttp\\Psr7\\Uri" - } - }, - "3f4bc1cd-aa95-4702-9fa7-65408e471691": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Message\\UriFactory\\DiactorosUriFactory", - "type": "Http\\Message\\UriFactory", - "parameters": { - "depends": "Zend\\Diactoros\\Uri" - } - }, - "4672a6ee-ad9e-4109-a5d1-b7d46f26c7a1": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Message\\MessageFactory\\SlimMessageFactory", - "type": "Http\\Message\\MessageFactory" - }, - "6234e947-d3bd-43eb-97d5-7f9e22e6bb1b": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Message\\MessageFactory\\DiactorosMessageFactory", - "type": "Http\\Message\\ResponseFactory", - "parameters": { - "depends": "Zend\\Diactoros\\Response" - } - }, - "6a9ad6ce-d82c-470f-8e30-60f21d9d95bf": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Message\\UriFactory\\SlimUriFactory", - "type": "Http\\Message\\UriFactory" - }, - "72c2afa0-ea56-4d03-adb6-a9f241a8a734": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Message\\StreamFactory\\SlimStreamFactory", - "type": "Http\\Message\\StreamFactory" - }, - "95c1be8f-39fe-4abd-8351-92cb14379a75": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Message\\StreamFactory\\DiactorosStreamFactory", - "type": "Http\\Message\\StreamFactory", - "parameters": { - "depends": "Zend\\Diactoros\\Stream" - } - }, - "a018af27-7590-4dcf-83a1-497f95604cd6": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Message\\MessageFactory\\GuzzleMessageFactory", - "type": "Http\\Message\\ResponseFactory", - "parameters": { - "depends": "GuzzleHttp\\Psr7\\Response" - } - }, - "c07955b1-de46-43db-923b-d07fae9382cb": { - "_class": "Puli\\Discovery\\Binding\\ClassBinding", - "class": "Http\\Message\\MessageFactory\\DiactorosMessageFactory", - "type": "Http\\Message\\RequestFactory", - "parameters": { - "depends": "Zend\\Diactoros\\Request" - } - } - } -} diff --git a/vendor/php-http/message/src/Authentication.php b/vendor/php-http/message/src/Authentication.php deleted file mode 100755 index b50366ffa1881db549571d85b41d8452beec1db2..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Authentication.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php - -namespace Http\Message; - -use Psr\Http\Message\RequestInterface; - -/** - * Authenticate a PSR-7 Request. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -interface Authentication -{ - /** - * Authenticates a request. - * - * @param RequestInterface $request - * - * @return RequestInterface - */ - public function authenticate(RequestInterface $request); -} diff --git a/vendor/php-http/message/src/Authentication/AutoBasicAuth.php b/vendor/php-http/message/src/Authentication/AutoBasicAuth.php deleted file mode 100755 index 7b6a429482ad99f9922b699e3ec14f91038848ea..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Authentication/AutoBasicAuth.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php - -namespace Http\Message\Authentication; - -use Http\Message\Authentication; -use Psr\Http\Message\RequestInterface; - -/** - * Authenticate a PSR-7 Request using Basic Auth based on credentials in the URI. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -final class AutoBasicAuth implements Authentication -{ - /** - * Whether user info should be removed from the URI. - * - * @var bool - */ - private $shouldRemoveUserInfo; - - /** - * @param bool|true $shouldRremoveUserInfo - */ - public function __construct($shouldRremoveUserInfo = true) - { - $this->shouldRemoveUserInfo = (bool) $shouldRremoveUserInfo; - } - - /** - * {@inheritdoc} - */ - public function authenticate(RequestInterface $request) - { - $uri = $request->getUri(); - $userInfo = $uri->getUserInfo(); - - if (!empty($userInfo)) { - if ($this->shouldRemoveUserInfo) { - $request = $request->withUri($uri->withUserInfo('')); - } - - $request = $request->withHeader('Authorization', sprintf('Basic %s', base64_encode($userInfo))); - } - - return $request; - } -} diff --git a/vendor/php-http/message/src/Authentication/BasicAuth.php b/vendor/php-http/message/src/Authentication/BasicAuth.php deleted file mode 100755 index 23618a53c3d99641303695ee0c4b4bd3f2cbc478..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Authentication/BasicAuth.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php - -namespace Http\Message\Authentication; - -use Http\Message\Authentication; -use Psr\Http\Message\RequestInterface; - -/** - * Authenticate a PSR-7 Request using Basic Auth. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -final class BasicAuth implements Authentication -{ - /** - * @var string - */ - private $username; - - /** - * @var string - */ - private $password; - - /** - * @param string $username - * @param string $password - */ - public function __construct($username, $password) - { - $this->username = $username; - $this->password = $password; - } - - /** - * {@inheritdoc} - */ - public function authenticate(RequestInterface $request) - { - $header = sprintf('Basic %s', base64_encode(sprintf('%s:%s', $this->username, $this->password))); - - return $request->withHeader('Authorization', $header); - } -} diff --git a/vendor/php-http/message/src/Authentication/Bearer.php b/vendor/php-http/message/src/Authentication/Bearer.php deleted file mode 100755 index a8fb21a146ff2d726a0b1919015307529ec426bb..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Authentication/Bearer.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -namespace Http\Message\Authentication; - -use Http\Message\Authentication; -use Psr\Http\Message\RequestInterface; - -/** - * Authenticate a PSR-7 Request using a token. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -final class Bearer implements Authentication -{ - /** - * @var string - */ - private $token; - - /** - * @param string $token - */ - public function __construct($token) - { - $this->token = $token; - } - - /** - * {@inheritdoc} - */ - public function authenticate(RequestInterface $request) - { - $header = sprintf('Bearer %s', $this->token); - - return $request->withHeader('Authorization', $header); - } -} diff --git a/vendor/php-http/message/src/Authentication/Chain.php b/vendor/php-http/message/src/Authentication/Chain.php deleted file mode 100755 index 71002bb179a5382dd3ad8baf241dc776444d5ca3..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Authentication/Chain.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -namespace Http\Message\Authentication; - -use Http\Message\Authentication; -use Psr\Http\Message\RequestInterface; - -/** - * Authenticate a PSR-7 Request with a multiple authentication methods. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -final class Chain implements Authentication -{ - /** - * @var Authentication[] - */ - private $authenticationChain = []; - - /** - * @param Authentication[] $authenticationChain - */ - public function __construct(array $authenticationChain = []) - { - foreach ($authenticationChain as $authentication) { - if (!$authentication instanceof Authentication) { - throw new \InvalidArgumentException( - 'Members of the authentication chain must be of type Http\Message\Authentication' - ); - } - } - - $this->authenticationChain = $authenticationChain; - } - - /** - * {@inheritdoc} - */ - public function authenticate(RequestInterface $request) - { - foreach ($this->authenticationChain as $authentication) { - $request = $authentication->authenticate($request); - } - - return $request; - } -} diff --git a/vendor/php-http/message/src/Authentication/Matching.php b/vendor/php-http/message/src/Authentication/Matching.php deleted file mode 100755 index 4b89b5013da439bdbfdcc947a639d1c5740e2f0e..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Authentication/Matching.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php - -namespace Http\Message\Authentication; - -use Http\Message\Authentication; -use Http\Message\RequestMatcher\CallbackRequestMatcher; -use Psr\Http\Message\RequestInterface; - -@trigger_error('The '.__NAMESPACE__.'\Matching class is deprecated since version 1.2 and will be removed in 2.0. Use Http\Message\Authentication\RequestConditional instead.', E_USER_DEPRECATED); - -/** - * Authenticate a PSR-7 Request if the request is matching. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - * - * @deprecated since since version 1.2, and will be removed in 2.0. Use {@link RequestConditional} instead. - */ -final class Matching implements Authentication -{ - /** - * @var Authentication - */ - private $authentication; - - /** - * @var CallbackRequestMatcher - */ - private $matcher; - - /** - * @param Authentication $authentication - * @param callable|null $matcher - */ - public function __construct(Authentication $authentication, callable $matcher = null) - { - if (is_null($matcher)) { - $matcher = function () { - return true; - }; - } - - $this->authentication = $authentication; - $this->matcher = new CallbackRequestMatcher($matcher); - } - - /** - * {@inheritdoc} - */ - public function authenticate(RequestInterface $request) - { - if ($this->matcher->matches($request)) { - return $this->authentication->authenticate($request); - } - - return $request; - } - - /** - * Creates a matching authentication for an URL. - * - * @param Authentication $authentication - * @param string $url - * - * @return self - */ - public static function createUrlMatcher(Authentication $authentication, $url) - { - $matcher = function (RequestInterface $request) use ($url) { - return preg_match($url, $request->getRequestTarget()); - }; - - return new static($authentication, $matcher); - } -} diff --git a/vendor/php-http/message/src/Authentication/QueryParam.php b/vendor/php-http/message/src/Authentication/QueryParam.php deleted file mode 100755 index 14b58ff14964c92573ab44cb42331edd06709a4b..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Authentication/QueryParam.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php - -namespace Http\Message\Authentication; - -use Http\Message\Authentication; -use Psr\Http\Message\RequestInterface; - -/** - * Authenticate a PSR-7 Request by adding parameters to its query. - * - * Note: Although in some cases it can be useful, we do not recommend using query parameters for authentication. - * Credentials in the URL is generally unsafe as they are not encrypted, anyone can see them. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -final class QueryParam implements Authentication -{ - /** - * @var array - */ - private $params = []; - - /** - * @param array $params - */ - public function __construct(array $params) - { - $this->params = $params; - } - - /** - * {@inheritdoc} - */ - public function authenticate(RequestInterface $request) - { - $uri = $request->getUri(); - $query = $uri->getQuery(); - $params = []; - - parse_str($query, $params); - - $params = array_merge($params, $this->params); - - $query = http_build_query($params); - - $uri = $uri->withQuery($query); - - return $request->withUri($uri); - } -} diff --git a/vendor/php-http/message/src/Authentication/RequestConditional.php b/vendor/php-http/message/src/Authentication/RequestConditional.php deleted file mode 100755 index 54774400d6da3dc67ad0e0aa6f5be0006a6c88ce..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Authentication/RequestConditional.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -namespace Http\Message\Authentication; - -use Http\Message\Authentication; -use Http\Message\RequestMatcher; -use Psr\Http\Message\RequestInterface; - -/** - * Authenticate a PSR-7 Request if the request is matching the given request matcher. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -final class RequestConditional implements Authentication -{ - /** - * @var RequestMatcher - */ - private $requestMatcher; - - /** - * @var Authentication - */ - private $authentication; - - /** - * @param RequestMatcher $requestMatcher - * @param Authentication $authentication - */ - public function __construct(RequestMatcher $requestMatcher, Authentication $authentication) - { - $this->requestMatcher = $requestMatcher; - $this->authentication = $authentication; - } - - /** - * {@inheritdoc} - */ - public function authenticate(RequestInterface $request) - { - if ($this->requestMatcher->matches($request)) { - return $this->authentication->authenticate($request); - } - - return $request; - } -} diff --git a/vendor/php-http/message/src/Authentication/Wsse.php b/vendor/php-http/message/src/Authentication/Wsse.php deleted file mode 100755 index fbbde336304824028c24438131c022d21d5d6607..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Authentication/Wsse.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php - -namespace Http\Message\Authentication; - -use Http\Message\Authentication; -use Psr\Http\Message\RequestInterface; - -/** - * Authenticate a PSR-7 Request using WSSE. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -final class Wsse implements Authentication -{ - /** - * @var string - */ - private $username; - - /** - * @var string - */ - private $password; - - /** - * @param string $username - * @param string $password - */ - public function __construct($username, $password) - { - $this->username = $username; - $this->password = $password; - } - - /** - * {@inheritdoc} - */ - public function authenticate(RequestInterface $request) - { - // TODO: generate better nonce? - $nonce = substr(md5(uniqid(uniqid().'_', true)), 0, 16); - $created = date('c'); - $digest = base64_encode(sha1(base64_decode($nonce).$created.$this->password, true)); - - $wsse = sprintf( - 'UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"', - $this->username, - $digest, - $nonce, - $created - ); - - return $request - ->withHeader('Authorization', 'WSSE profile="UsernameToken"') - ->withHeader('X-WSSE', $wsse) - ; - } -} diff --git a/vendor/php-http/message/src/Builder/ResponseBuilder.php b/vendor/php-http/message/src/Builder/ResponseBuilder.php deleted file mode 100755 index e6933a0cdee6a279e907720959a108771cdc0c86..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Builder/ResponseBuilder.php +++ /dev/null @@ -1,148 +0,0 @@ -<?php - -namespace Http\Message\Builder; - -use Psr\Http\Message\ResponseInterface; - -/** - * Fills response object with values. - */ -class ResponseBuilder -{ - /** - * The response to be built. - * - * @var ResponseInterface - */ - protected $response; - - /** - * Create builder for the given response. - * - * @param ResponseInterface $response - */ - public function __construct(ResponseInterface $response) - { - $this->response = $response; - } - - /** - * Return response. - * - * @return ResponseInterface - */ - public function getResponse() - { - return $this->response; - } - - /** - * Add headers represented by an array of header lines. - * - * @param string[] $headers Response headers as array of header lines. - * - * @return $this - * - * @throws \UnexpectedValueException For invalid header values. - * @throws \InvalidArgumentException For invalid status code arguments. - */ - public function setHeadersFromArray(array $headers) - { - $status = array_shift($headers); - $this->setStatus($status); - - foreach ($headers as $headerLine) { - $headerLine = trim($headerLine); - if ('' === $headerLine) { - continue; - } - - $this->addHeader($headerLine); - } - - return $this; - } - - /** - * Add headers represented by a single string. - * - * @param string $headers Response headers as single string. - * - * @return $this - * - * @throws \InvalidArgumentException if $headers is not a string on object with __toString() - * @throws \UnexpectedValueException For invalid header values. - */ - public function setHeadersFromString($headers) - { - if (!(is_string($headers) - || (is_object($headers) && method_exists($headers, '__toString'))) - ) { - throw new \InvalidArgumentException( - sprintf( - '%s expects parameter 1 to be a string, %s given', - __METHOD__, - is_object($headers) ? get_class($headers) : gettype($headers) - ) - ); - } - - $this->setHeadersFromArray(explode("\r\n", $headers)); - - return $this; - } - - /** - * Set response status from a status string. - * - * @param string $statusLine Response status as a string. - * - * @return $this - * - * @throws \InvalidArgumentException For invalid status line. - */ - public function setStatus($statusLine) - { - $parts = explode(' ', $statusLine, 3); - if (count($parts) < 2 || strpos(strtolower($parts[0]), 'http/') !== 0) { - throw new \InvalidArgumentException( - sprintf('"%s" is not a valid HTTP status line', $statusLine) - ); - } - - $reasonPhrase = count($parts) > 2 ? $parts[2] : ''; - $this->response = $this->response - ->withStatus((int) $parts[1], $reasonPhrase) - ->withProtocolVersion(substr($parts[0], 5)); - - return $this; - } - - /** - * Add header represented by a string. - * - * @param string $headerLine Response header as a string. - * - * @return $this - * - * @throws \InvalidArgumentException For invalid header names or values. - */ - public function addHeader($headerLine) - { - $parts = explode(':', $headerLine, 2); - if (count($parts) !== 2) { - throw new \InvalidArgumentException( - sprintf('"%s" is not a valid HTTP header line', $headerLine) - ); - } - $name = trim($parts[0]); - $value = trim($parts[1]); - if ($this->response->hasHeader($name)) { - $this->response = $this->response->withAddedHeader($name, $value); - } else { - $this->response = $this->response->withHeader($name, $value); - } - - return $this; - } -} diff --git a/vendor/php-http/message/src/Cookie.php b/vendor/php-http/message/src/Cookie.php deleted file mode 100755 index 5f61b90656c313568049ed9b52c62bdaa326c2da..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Cookie.php +++ /dev/null @@ -1,526 +0,0 @@ -<?php - -namespace Http\Message; - -/** - * Cookie Value Object. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - * - * @see http://tools.ietf.org/search/rfc6265 - */ -final class Cookie -{ - /** - * @var string - */ - private $name; - - /** - * @var string|null - */ - private $value; - - /** - * @var int|null - */ - private $maxAge; - - /** - * @var string|null - */ - private $domain; - - /** - * @var string - */ - private $path; - - /** - * @var bool - */ - private $secure; - - /** - * @var bool - */ - private $httpOnly; - - /** - * Expires attribute is HTTP 1.0 only and should be avoided. - * - * @var \DateTime|null - */ - private $expires; - - /** - * @param string $name - * @param string|null $value - * @param int $maxAge - * @param string|null $domain - * @param string|null $path - * @param bool $secure - * @param bool $httpOnly - * @param \DateTime|null $expires Expires attribute is HTTP 1.0 only and should be avoided. - * - * @throws \InvalidArgumentException If name, value or max age is not valid. - */ - public function __construct( - $name, - $value = null, - $maxAge = null, - $domain = null, - $path = null, - $secure = false, - $httpOnly = false, - \DateTime $expires = null - ) { - $this->validateName($name); - $this->validateValue($value); - $this->validateMaxAge($maxAge); - - $this->name = $name; - $this->value = $value; - $this->maxAge = $maxAge; - $this->expires = $expires; - $this->domain = $this->normalizeDomain($domain); - $this->path = $this->normalizePath($path); - $this->secure = (bool) $secure; - $this->httpOnly = (bool) $httpOnly; - } - - /** - * Creates a new cookie without any attribute validation. - * - * @param string $name - * @param string|null $value - * @param int $maxAge - * @param string|null $domain - * @param string|null $path - * @param bool $secure - * @param bool $httpOnly - * @param \DateTime|null $expires Expires attribute is HTTP 1.0 only and should be avoided. - */ - public static function createWithoutValidation( - $name, - $value = null, - $maxAge = null, - $domain = null, - $path = null, - $secure = false, - $httpOnly = false, - \DateTime $expires = null - ) { - $cookie = new self('name', null, null, $domain, $path, $secure, $httpOnly, $expires); - $cookie->name = $name; - $cookie->value = $value; - $cookie->maxAge = $maxAge; - - return $cookie; - } - - /** - * Returns the name. - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Returns the value. - * - * @return string|null - */ - public function getValue() - { - return $this->value; - } - - /** - * Checks if there is a value. - * - * @return bool - */ - public function hasValue() - { - return isset($this->value); - } - - /** - * Sets the value. - * - * @param string|null $value - * - * @return Cookie - */ - public function withValue($value) - { - $this->validateValue($value); - - $new = clone $this; - $new->value = $value; - - return $new; - } - - /** - * Returns the max age. - * - * @return int|null - */ - public function getMaxAge() - { - return $this->maxAge; - } - - /** - * Checks if there is a max age. - * - * @return bool - */ - public function hasMaxAge() - { - return isset($this->maxAge); - } - - /** - * Sets the max age. - * - * @param int|null $maxAge - * - * @return Cookie - */ - public function withMaxAge($maxAge) - { - $this->validateMaxAge($maxAge); - - $new = clone $this; - $new->maxAge = $maxAge; - - return $new; - } - - /** - * Returns the expiration time. - * - * @return \DateTime|null - */ - public function getExpires() - { - return $this->expires; - } - - /** - * Checks if there is an expiration time. - * - * @return bool - */ - public function hasExpires() - { - return isset($this->expires); - } - - /** - * Sets the expires. - * - * @param \DateTime|null $expires - * - * @return Cookie - */ - public function withExpires(\DateTime $expires = null) - { - $new = clone $this; - $new->expires = $expires; - - return $new; - } - - /** - * Checks if the cookie is expired. - * - * @return bool - */ - public function isExpired() - { - return isset($this->expires) and $this->expires < new \DateTime(); - } - - /** - * Returns the domain. - * - * @return string|null - */ - public function getDomain() - { - return $this->domain; - } - - /** - * Checks if there is a domain. - * - * @return bool - */ - public function hasDomain() - { - return isset($this->domain); - } - - /** - * Sets the domain. - * - * @param string|null $domain - * - * @return Cookie - */ - public function withDomain($domain) - { - $new = clone $this; - $new->domain = $this->normalizeDomain($domain); - - return $new; - } - - /** - * Checks whether this cookie is meant for this domain. - * - * @see http://tools.ietf.org/html/rfc6265#section-5.1.3 - * - * @param string $domain - * - * @return bool - */ - public function matchDomain($domain) - { - // Domain is not set or exact match - if (!$this->hasDomain() || strcasecmp($domain, $this->domain) === 0) { - return true; - } - - // Domain is not an IP address - if (filter_var($domain, FILTER_VALIDATE_IP)) { - return false; - } - - return (bool) preg_match(sprintf('/\b%s$/i', preg_quote($this->domain)), $domain); - } - - /** - * Returns the path. - * - * @return string - */ - public function getPath() - { - return $this->path; - } - - /** - * Sets the path. - * - * @param string|null $path - * - * @return Cookie - */ - public function withPath($path) - { - $new = clone $this; - $new->path = $this->normalizePath($path); - - return $new; - } - - /** - * Checks whether this cookie is meant for this path. - * - * @see http://tools.ietf.org/html/rfc6265#section-5.1.4 - * - * @param string $path - * - * @return bool - */ - public function matchPath($path) - { - return $this->path === $path || (strpos($path, rtrim($this->path, '/').'/') === 0); - } - - /** - * Checks whether this cookie may only be sent over HTTPS. - * - * @return bool - */ - public function isSecure() - { - return $this->secure; - } - - /** - * Sets whether this cookie should only be sent over HTTPS. - * - * @param bool $secure - * - * @return Cookie - */ - public function withSecure($secure) - { - $new = clone $this; - $new->secure = (bool) $secure; - - return $new; - } - - /** - * Check whether this cookie may not be accessed through Javascript. - * - * @return bool - */ - public function isHttpOnly() - { - return $this->httpOnly; - } - - /** - * Sets whether this cookie may not be accessed through Javascript. - * - * @param bool $httpOnly - * - * @return Cookie - */ - public function withHttpOnly($httpOnly) - { - $new = clone $this; - $new->httpOnly = (bool) $httpOnly; - - return $new; - } - - /** - * Checks if this cookie represents the same cookie as $cookie. - * - * This does not compare the values, only name, domain and path. - * - * @param Cookie $cookie - * - * @return bool - */ - public function match(Cookie $cookie) - { - return $this->name === $cookie->name && $this->domain === $cookie->domain and $this->path === $cookie->path; - } - - /** - * Validates cookie attributes. - * - * @return bool - */ - public function isValid() - { - try { - $this->validateName($this->name); - $this->validateValue($this->value); - $this->validateMaxAge($this->maxAge); - } catch (\InvalidArgumentException $e) { - return false; - } - - return true; - } - - /** - * Validates the name attribute. - * - * @see http://tools.ietf.org/search/rfc2616#section-2.2 - * - * @param string $name - * - * @throws \InvalidArgumentException If the name is empty or contains invalid characters. - */ - private function validateName($name) - { - if (strlen($name) < 1) { - throw new \InvalidArgumentException('The name cannot be empty'); - } - - // Name attribute is a token as per spec in RFC 2616 - if (preg_match('/[\x00-\x20\x22\x28-\x29\x2C\x2F\x3A-\x40\x5B-\x5D\x7B\x7D\x7F]/', $name)) { - throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name)); - } - } - - /** - * Validates a value. - * - * @see http://tools.ietf.org/html/rfc6265#section-4.1.1 - * - * @param string|null $value - * - * @throws \InvalidArgumentException If the value contains invalid characters. - */ - private function validateValue($value) - { - if (isset($value)) { - if (preg_match('/[^\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]/', $value)) { - throw new \InvalidArgumentException(sprintf('The cookie value "%s" contains invalid characters.', $value)); - } - } - } - - /** - * Validates a Max-Age attribute. - * - * @param int|null $maxAge - * - * @throws \InvalidArgumentException If the Max-Age is not an empty or integer value. - */ - private function validateMaxAge($maxAge) - { - if (isset($maxAge)) { - if (!is_int($maxAge)) { - throw new \InvalidArgumentException('Max-Age must be integer'); - } - } - } - - /** - * Remove the leading '.' and lowercase the domain as per spec in RFC 6265. - * - * @see http://tools.ietf.org/html/rfc6265#section-4.1.2.3 - * @see http://tools.ietf.org/html/rfc6265#section-5.1.3 - * @see http://tools.ietf.org/html/rfc6265#section-5.2.3 - * - * @param string|null $domain - * - * @return string - */ - private function normalizeDomain($domain) - { - if (isset($domain)) { - $domain = ltrim(strtolower($domain), '.'); - } - - return $domain; - } - - /** - * Processes path as per spec in RFC 6265. - * - * @see http://tools.ietf.org/html/rfc6265#section-5.1.4 - * @see http://tools.ietf.org/html/rfc6265#section-5.2.4 - * - * @param string|null $path - * - * @return string - */ - private function normalizePath($path) - { - $path = rtrim($path, '/'); - - if (empty($path) or substr($path, 0, 1) !== '/') { - $path = '/'; - } - - return $path; - } -} diff --git a/vendor/php-http/message/src/CookieJar.php b/vendor/php-http/message/src/CookieJar.php deleted file mode 100755 index ab267d3301f65fd442d086157626083ac1da5891..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/CookieJar.php +++ /dev/null @@ -1,220 +0,0 @@ -<?php - -namespace Http\Message; - -/** - * Cookie Jar holds a set of Cookies. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -final class CookieJar implements \Countable, \IteratorAggregate -{ - /** - * @var \SplObjectStorage - */ - protected $cookies; - - public function __construct() - { - $this->cookies = new \SplObjectStorage(); - } - - /** - * Checks if there is a cookie. - * - * @param Cookie $cookie - * - * @return bool - */ - public function hasCookie(Cookie $cookie) - { - return $this->cookies->contains($cookie); - } - - /** - * Adds a cookie. - * - * @param Cookie $cookie - */ - public function addCookie(Cookie $cookie) - { - if (!$this->hasCookie($cookie)) { - $cookies = $this->getMatchingCookies($cookie); - - foreach ($cookies as $matchingCookie) { - if ($cookie->getValue() !== $matchingCookie->getValue() || $cookie->getMaxAge() > $matchingCookie->getMaxAge()) { - $this->removeCookie($matchingCookie); - - continue; - } - } - - if ($cookie->hasValue()) { - $this->cookies->attach($cookie); - } - } - } - - /** - * Removes a cookie. - * - * @param Cookie $cookie - */ - public function removeCookie(Cookie $cookie) - { - $this->cookies->detach($cookie); - } - - /** - * Returns the cookies. - * - * @return Cookie[] - */ - public function getCookies() - { - $match = function ($matchCookie) { - return true; - }; - - return $this->findMatchingCookies($match); - } - - /** - * Returns all matching cookies. - * - * @param Cookie $cookie - * - * @return Cookie[] - */ - public function getMatchingCookies(Cookie $cookie) - { - $match = function ($matchCookie) use ($cookie) { - return $matchCookie->match($cookie); - }; - - return $this->findMatchingCookies($match); - } - - /** - * Finds matching cookies based on a callable. - * - * @param callable $match - * - * @return Cookie[] - */ - protected function findMatchingCookies(callable $match) - { - $cookies = []; - - foreach ($this->cookies as $cookie) { - if ($match($cookie)) { - $cookies[] = $cookie; - } - } - - return $cookies; - } - - /** - * Checks if there are cookies. - * - * @return bool - */ - public function hasCookies() - { - return $this->cookies->count() > 0; - } - - /** - * Sets the cookies and removes any previous one. - * - * @param Cookie[] $cookies - */ - public function setCookies(array $cookies) - { - $this->clear(); - $this->addCookies($cookies); - } - - /** - * Adds some cookies. - * - * @param Cookie[] $cookies - */ - public function addCookies(array $cookies) - { - foreach ($cookies as $cookie) { - $this->addCookie($cookie); - } - } - - /** - * Removes some cookies. - * - * @param Cookie[] $cookies - */ - public function removeCookies(array $cookies) - { - foreach ($cookies as $cookie) { - $this->removeCookie($cookie); - } - } - - /** - * Removes cookies which match the given parameters. - * - * Null means that parameter should not be matched - * - * @param string|null $name - * @param string|null $domain - * @param string|null $path - */ - public function removeMatchingCookies($name = null, $domain = null, $path = null) - { - $match = function ($cookie) use ($name, $domain, $path) { - $match = true; - - if (isset($name)) { - $match = $match && ($cookie->getName() === $name); - } - - if (isset($domain)) { - $match = $match && $cookie->matchDomain($domain); - } - - if (isset($path)) { - $match = $match && $cookie->matchPath($path); - } - - return $match; - }; - - $cookies = $this->findMatchingCookies($match); - - $this->removeCookies($cookies); - } - - /** - * Removes all cookies. - */ - public function clear() - { - $this->cookies = new \SplObjectStorage(); - } - - /** - * {@inheritdoc} - */ - public function count() - { - return $this->cookies->count(); - } - - /** - * {@inheritdoc} - */ - public function getIterator() - { - return clone $this->cookies; - } -} diff --git a/vendor/php-http/message/src/CookieUtil.php b/vendor/php-http/message/src/CookieUtil.php deleted file mode 100755 index 5c670d461288bb47225d38e3648d9164c7d1e869..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/CookieUtil.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -namespace Http\Message; - -use Http\Message\Exception\UnexpectedValueException; - -final class CookieUtil -{ - /** - * Handles dates as defined by RFC 2616 section 3.3.1, and also some other - * non-standard, but common formats. - * - * @var array - */ - private static $dateFormats = [ - 'D, d M y H:i:s T', - 'D, d M Y H:i:s T', - 'D, d-M-y H:i:s T', - 'D, d-M-Y H:i:s T', - 'D, d-m-y H:i:s T', - 'D, d-m-Y H:i:s T', - 'D M j G:i:s Y', - 'D M d H:i:s Y T', - ]; - - /** - * @see https://github.com/symfony/symfony/blob/master/src/Symfony/Component/BrowserKit/Cookie.php - * - * @param string $dateValue - * - * @return \DateTime - * - * @throws UnexpectedValueException if we cannot parse the cookie date string. - */ - public static function parseDate($dateValue) - { - foreach (self::$dateFormats as $dateFormat) { - if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) { - return $date; - } - } - - // attempt a fallback for unusual formatting - if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) { - return $date; - } - - throw new UnexpectedValueException(sprintf( - 'Unparseable cookie date string "%s"', - $dateValue - )); - } -} diff --git a/vendor/php-http/message/src/Decorator/MessageDecorator.php b/vendor/php-http/message/src/Decorator/MessageDecorator.php deleted file mode 100755 index 0ffc7caf6f1f0626f21bd9cfe7f8d60e053e8af6..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Decorator/MessageDecorator.php +++ /dev/null @@ -1,133 +0,0 @@ -<?php - -namespace Http\Message\Decorator; - -use Psr\Http\Message\MessageInterface; -use Psr\Http\Message\StreamInterface; - -/** - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -trait MessageDecorator -{ - /** - * @var MessageInterface - */ - private $message; - - /** - * Returns the decorated message. - * - * Since the underlying Message is immutable as well - * exposing it is not an issue, because it's state cannot be altered - * - * @return MessageInterface - */ - public function getMessage() - { - return $this->message; - } - - /** - * {@inheritdoc} - */ - public function getProtocolVersion() - { - return $this->message->getProtocolVersion(); - } - - /** - * {@inheritdoc} - */ - public function withProtocolVersion($version) - { - $new = clone $this; - $new->message = $this->message->withProtocolVersion($version); - - return $new; - } - - /** - * {@inheritdoc} - */ - public function getHeaders() - { - return $this->message->getHeaders(); - } - - /** - * {@inheritdoc} - */ - public function hasHeader($header) - { - return $this->message->hasHeader($header); - } - - /** - * {@inheritdoc} - */ - public function getHeader($header) - { - return $this->message->getHeader($header); - } - - /** - * {@inheritdoc} - */ - public function getHeaderLine($header) - { - return $this->message->getHeaderLine($header); - } - - /** - * {@inheritdoc} - */ - public function withHeader($header, $value) - { - $new = clone $this; - $new->message = $this->message->withHeader($header, $value); - - return $new; - } - - /** - * {@inheritdoc} - */ - public function withAddedHeader($header, $value) - { - $new = clone $this; - $new->message = $this->message->withAddedHeader($header, $value); - - return $new; - } - - /** - * {@inheritdoc} - */ - public function withoutHeader($header) - { - $new = clone $this; - $new->message = $this->message->withoutHeader($header); - - return $new; - } - - /** - * {@inheritdoc} - */ - public function getBody() - { - return $this->message->getBody(); - } - - /** - * {@inheritdoc} - */ - public function withBody(StreamInterface $body) - { - $new = clone $this; - $new->message = $this->message->withBody($body); - - return $new; - } -} diff --git a/vendor/php-http/message/src/Decorator/RequestDecorator.php b/vendor/php-http/message/src/Decorator/RequestDecorator.php deleted file mode 100755 index 7c50e588925e403ae533daf5e9bbc206f2f3bd16..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Decorator/RequestDecorator.php +++ /dev/null @@ -1,88 +0,0 @@ -<?php - -namespace Http\Message\Decorator; - -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\UriInterface; - -/** - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -trait RequestDecorator -{ - use MessageDecorator { - getMessage as getRequest; - } - - /** - * Exchanges the underlying request with another. - * - * @param RequestInterface $request - * - * @return self - */ - public function withRequest(RequestInterface $request) - { - $new = clone $this; - $new->message = $request; - - return $new; - } - - /** - * {@inheritdoc} - */ - public function getRequestTarget() - { - return $this->message->getRequestTarget(); - } - - /** - * {@inheritdoc} - */ - public function withRequestTarget($requestTarget) - { - $new = clone $this; - $new->message = $this->message->withRequestTarget($requestTarget); - - return $new; - } - - /** - * {@inheritdoc} - */ - public function getMethod() - { - return $this->message->getMethod(); - } - - /** - * {@inheritdoc} - */ - public function withMethod($method) - { - $new = clone $this; - $new->message = $this->message->withMethod($method); - - return $new; - } - - /** - * {@inheritdoc} - */ - public function getUri() - { - return $this->message->getUri(); - } - - /** - * {@inheritdoc} - */ - public function withUri(UriInterface $uri, $preserveHost = false) - { - $new = clone $this; - $new->message = $this->message->withUri($uri, $preserveHost); - - return $new; - } -} diff --git a/vendor/php-http/message/src/Decorator/ResponseDecorator.php b/vendor/php-http/message/src/Decorator/ResponseDecorator.php deleted file mode 100755 index 82d9ae086882c251f0dcdb971dac317f6cb8463a..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Decorator/ResponseDecorator.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php - -namespace Http\Message\Decorator; - -use Psr\Http\Message\ResponseInterface; - -/** - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -trait ResponseDecorator -{ - use MessageDecorator { - getMessage as getResponse; - } - - /** - * Exchanges the underlying response with another. - * - * @param ResponseInterface $response - * - * @return self - */ - public function withResponse(ResponseInterface $response) - { - $new = clone $this; - $new->message = $response; - - return $new; - } - - /** - * {@inheritdoc} - */ - public function getStatusCode() - { - return $this->message->getStatusCode(); - } - - /** - * {@inheritdoc} - */ - public function withStatus($code, $reasonPhrase = '') - { - $new = clone $this; - $new->message = $this->message->withStatus($code, $reasonPhrase); - - return $new; - } - - /** - * {@inheritdoc} - */ - public function getReasonPhrase() - { - return $this->message->getReasonPhrase(); - } -} diff --git a/vendor/php-http/message/src/Decorator/StreamDecorator.php b/vendor/php-http/message/src/Decorator/StreamDecorator.php deleted file mode 100755 index f405c7afe3913cb5a1905fe7698528dacf09186e..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Decorator/StreamDecorator.php +++ /dev/null @@ -1,138 +0,0 @@ -<?php - -namespace Http\Message\Decorator; - -use Psr\Http\Message\StreamInterface; - -/** - * Decorates a stream. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -trait StreamDecorator -{ - /** - * @var StreamInterface - */ - protected $stream; - - /** - * {@inheritdoc} - */ - public function __toString() - { - return $this->stream->__toString(); - } - - /** - * {@inheritdoc} - */ - public function close() - { - $this->stream->close(); - } - - /** - * {@inheritdoc} - */ - public function detach() - { - return $this->stream->detach(); - } - - /** - * {@inheritdoc} - */ - public function getSize() - { - return $this->stream->getSize(); - } - - /** - * {@inheritdoc} - */ - public function tell() - { - return $this->stream->tell(); - } - - /** - * {@inheritdoc} - */ - public function eof() - { - return $this->stream->eof(); - } - - /** - * {@inheritdoc} - */ - public function isSeekable() - { - return $this->stream->isSeekable(); - } - - /** - * {@inheritdoc} - */ - public function seek($offset, $whence = SEEK_SET) - { - $this->stream->seek($offset, $whence); - } - - /** - * {@inheritdoc} - */ - public function rewind() - { - $this->stream->rewind(); - } - - /** - * {@inheritdoc} - */ - public function isWritable() - { - return $this->stream->isWritable(); - } - - /** - * {@inheritdoc} - */ - public function write($string) - { - return $this->stream->write($string); - } - - /** - * {@inheritdoc} - */ - public function isReadable() - { - return $this->stream->isReadable(); - } - - /** - * {@inheritdoc} - */ - public function read($length) - { - return $this->stream->read($length); - } - - /** - * {@inheritdoc} - */ - public function getContents() - { - return $this->stream->getContents(); - } - - /** - * {@inheritdoc} - */ - public function getMetadata($key = null) - { - return $this->stream->getMetadata($key); - } -} diff --git a/vendor/php-http/message/src/Encoding/ChunkStream.php b/vendor/php-http/message/src/Encoding/ChunkStream.php deleted file mode 100755 index 74c2fbd09cd66c3565df5223c396cc5dd8f571ea..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Encoding/ChunkStream.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -namespace Http\Message\Encoding; - -/** - * Transform a regular stream into a chunked one. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class ChunkStream extends FilteredStream -{ - /** - * {@inheritdoc} - */ - protected function readFilter() - { - return 'chunk'; - } - - /** - * {@inheritdoc} - */ - protected function writeFilter() - { - return 'dechunk'; - } - - /** - * {@inheritdoc} - */ - protected function fill() - { - parent::fill(); - - if ($this->stream->eof()) { - $this->buffer .= "0\r\n\r\n"; - } - } -} diff --git a/vendor/php-http/message/src/Encoding/CompressStream.php b/vendor/php-http/message/src/Encoding/CompressStream.php deleted file mode 100755 index d1013dc1325c19ebadfa30d5922de5a03c1585b1..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Encoding/CompressStream.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -namespace Http\Message\Encoding; - -use Psr\Http\Message\StreamInterface; - -/** - * Stream compress (RFC 1950). - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class CompressStream extends FilteredStream -{ - /** - * @param StreamInterface $stream - * @param int $level - */ - public function __construct(StreamInterface $stream, $level = -1) - { - if (!extension_loaded('zlib')) { - throw new \RuntimeException('The zlib extension must be enabled to use this stream'); - } - - parent::__construct($stream, ['window' => 15, 'level' => $level], ['window' => 15]); - } - - /** - * {@inheritdoc} - */ - protected function readFilter() - { - return 'zlib.deflate'; - } - - /** - * {@inheritdoc} - */ - protected function writeFilter() - { - return 'zlib.inflate'; - } -} diff --git a/vendor/php-http/message/src/Encoding/DechunkStream.php b/vendor/php-http/message/src/Encoding/DechunkStream.php deleted file mode 100755 index 4cade835cfd03dd25b2047f012d03716a1e1a783..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Encoding/DechunkStream.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -namespace Http\Message\Encoding; - -/** - * Decorate a stream which is chunked. - * - * Allow to decode a chunked stream - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class DechunkStream extends FilteredStream -{ - /** - * {@inheritdoc} - */ - protected function readFilter() - { - return 'dechunk'; - } - - /** - * {@inheritdoc} - */ - protected function writeFilter() - { - return 'chunk'; - } -} diff --git a/vendor/php-http/message/src/Encoding/DecompressStream.php b/vendor/php-http/message/src/Encoding/DecompressStream.php deleted file mode 100755 index 4e3a723e96ea2fedd718f92516ab146e8dfd0419..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Encoding/DecompressStream.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -namespace Http\Message\Encoding; - -use Psr\Http\Message\StreamInterface; - -/** - * Stream decompress (RFC 1950). - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class DecompressStream extends FilteredStream -{ - /** - * @param StreamInterface $stream - * @param int $level - */ - public function __construct(StreamInterface $stream, $level = -1) - { - if (!extension_loaded('zlib')) { - throw new \RuntimeException('The zlib extension must be enabled to use this stream'); - } - - parent::__construct($stream, ['window' => 15], ['window' => 15, 'level' => $level]); - } - - /** - * {@inheritdoc} - */ - protected function readFilter() - { - return 'zlib.inflate'; - } - - /** - * {@inheritdoc} - */ - protected function writeFilter() - { - return 'zlib.deflate'; - } -} diff --git a/vendor/php-http/message/src/Encoding/DeflateStream.php b/vendor/php-http/message/src/Encoding/DeflateStream.php deleted file mode 100755 index 1d7344bac227f43d5d2278f9f3ef9dd494f1b217..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Encoding/DeflateStream.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -namespace Http\Message\Encoding; - -use Psr\Http\Message\StreamInterface; - -/** - * Stream deflate (RFC 1951). - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class DeflateStream extends FilteredStream -{ - /** - * @param StreamInterface $stream - * @param int $level - */ - public function __construct(StreamInterface $stream, $level = -1) - { - parent::__construct($stream, ['window' => -15, 'level' => $level], ['window' => -15]); - } - - /** - * {@inheritdoc} - */ - protected function readFilter() - { - return 'zlib.deflate'; - } - - /** - * {@inheritdoc} - */ - protected function writeFilter() - { - return 'zlib.inflate'; - } -} diff --git a/vendor/php-http/message/src/Encoding/Filter/Chunk.php b/vendor/php-http/message/src/Encoding/Filter/Chunk.php deleted file mode 100755 index 0f8f53b328876ad373c191a2a06d6b172774fe55..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Encoding/Filter/Chunk.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -namespace Http\Message\Encoding\Filter; - -/** - * Userland implementation of the chunk stream filter. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class Chunk extends \php_user_filter -{ - /** - * {@inheritdoc} - */ - public function filter($in, $out, &$consumed, $closing) - { - while ($bucket = stream_bucket_make_writeable($in)) { - $lenbucket = stream_bucket_new($this->stream, dechex($bucket->datalen)."\r\n"); - stream_bucket_append($out, $lenbucket); - - $consumed += $bucket->datalen; - stream_bucket_append($out, $bucket); - - $lenbucket = stream_bucket_new($this->stream, "\r\n"); - stream_bucket_append($out, $lenbucket); - } - - return PSFS_PASS_ON; - } -} diff --git a/vendor/php-http/message/src/Encoding/FilteredStream.php b/vendor/php-http/message/src/Encoding/FilteredStream.php deleted file mode 100755 index a32554b7a345415459efdc3c1f5855e833d5bc6c..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Encoding/FilteredStream.php +++ /dev/null @@ -1,198 +0,0 @@ -<?php - -namespace Http\Message\Encoding; - -use Clue\StreamFilter as Filter; -use Http\Message\Decorator\StreamDecorator; -use Psr\Http\Message\StreamInterface; - -/** - * A filtered stream has a filter for filtering output and a filter for filtering input made to a underlying stream. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -abstract class FilteredStream implements StreamInterface -{ - const BUFFER_SIZE = 8192; - - use StreamDecorator; - - /** - * @var callable - */ - protected $readFilterCallback; - - /** - * @var resource - * - * @deprecated since version 1.5, will be removed in 2.0 - */ - protected $readFilter; - - /** - * @var callable - * - * @deprecated since version 1.5, will be removed in 2.0 - */ - protected $writeFilterCallback; - - /** - * @var resource - * - * @deprecated since version 1.5, will be removed in 2.0 - */ - protected $writeFilter; - - /** - * Internal buffer. - * - * @var string - */ - protected $buffer = ''; - - /** - * @param StreamInterface $stream - * @param mixed|null $readFilterOptions - * @param mixed|null $writeFilterOptions deprecated since 1.5, will be removed in 2.0 - */ - public function __construct(StreamInterface $stream, $readFilterOptions = null, $writeFilterOptions = null) - { - $this->readFilterCallback = Filter\fun($this->readFilter(), $readFilterOptions); - $this->writeFilterCallback = Filter\fun($this->writeFilter(), $writeFilterOptions); - - if (null !== $writeFilterOptions) { - @trigger_error('The $writeFilterOptions argument is deprecated since version 1.5 and will be removed in 2.0.', E_USER_DEPRECATED); - } - - $this->stream = $stream; - } - - /** - * {@inheritdoc} - */ - public function read($length) - { - if (strlen($this->buffer) >= $length) { - $read = substr($this->buffer, 0, $length); - $this->buffer = substr($this->buffer, $length); - - return $read; - } - - if ($this->stream->eof()) { - $buffer = $this->buffer; - $this->buffer = ''; - - return $buffer; - } - - $read = $this->buffer; - $this->buffer = ''; - $this->fill(); - - return $read.$this->read($length - strlen($read)); - } - - /** - * {@inheritdoc} - */ - public function eof() - { - return $this->stream->eof() && $this->buffer === ''; - } - - /** - * Buffer is filled by reading underlying stream. - * - * Callback is reading once more even if the stream is ended. - * This allow to get last data in the PHP buffer otherwise this - * bug is present : https://bugs.php.net/bug.php?id=48725 - */ - protected function fill() - { - $readFilterCallback = $this->readFilterCallback; - $this->buffer .= $readFilterCallback($this->stream->read(self::BUFFER_SIZE)); - - if ($this->stream->eof()) { - $this->buffer .= $readFilterCallback(); - } - } - - /** - * {@inheritdoc} - */ - public function getContents() - { - $buffer = ''; - - while (!$this->eof()) { - $buf = $this->read(self::BUFFER_SIZE); - // Using a loose equality here to match on '' and false. - if ($buf == null) { - break; - } - - $buffer .= $buf; - } - - return $buffer; - } - - /** - * {@inheritdoc} - */ - public function getSize() - { - return; - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - return $this->getContents(); - } - - /** - * Returns the read filter name. - * - * @return string - * - * @deprecated since version 1.5, will be removed in 2.0 - */ - public function getReadFilter() - { - @trigger_error('The '.__CLASS__.'::'.__METHOD__.' method is deprecated since version 1.5 and will be removed in 2.0.', E_USER_DEPRECATED); - - return $this->readFilter(); - } - - /** - * Returns the write filter name. - * - * @return string - */ - abstract protected function readFilter(); - - /** - * Returns the write filter name. - * - * @return string - * - * @deprecated since version 1.5, will be removed in 2.0 - */ - public function getWriteFilter() - { - @trigger_error('The '.__CLASS__.'::'.__METHOD__.' method is deprecated since version 1.5 and will be removed in 2.0.', E_USER_DEPRECATED); - - return $this->writeFilter(); - } - - /** - * Returns the write filter name. - * - * @return string - */ - abstract protected function writeFilter(); -} diff --git a/vendor/php-http/message/src/Encoding/GzipDecodeStream.php b/vendor/php-http/message/src/Encoding/GzipDecodeStream.php deleted file mode 100755 index 4f958edc965f4facd24ae93633be568e34f082a7..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Encoding/GzipDecodeStream.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -namespace Http\Message\Encoding; - -use Psr\Http\Message\StreamInterface; - -/** - * Stream for decoding from gzip format (RFC 1952). - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class GzipDecodeStream extends FilteredStream -{ - /** - * @param StreamInterface $stream - * @param int $level - */ - public function __construct(StreamInterface $stream, $level = -1) - { - if (!extension_loaded('zlib')) { - throw new \RuntimeException('The zlib extension must be enabled to use this stream'); - } - - parent::__construct($stream, ['window' => 31], ['window' => 31, 'level' => $level]); - } - - /** - * {@inheritdoc} - */ - protected function readFilter() - { - return 'zlib.inflate'; - } - - /** - * {@inheritdoc} - */ - protected function writeFilter() - { - return 'zlib.deflate'; - } -} diff --git a/vendor/php-http/message/src/Encoding/GzipEncodeStream.php b/vendor/php-http/message/src/Encoding/GzipEncodeStream.php deleted file mode 100755 index 1066eec07c34d4053be68a2080e004d2fe971e54..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Encoding/GzipEncodeStream.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -namespace Http\Message\Encoding; - -use Psr\Http\Message\StreamInterface; - -/** - * Stream for encoding to gzip format (RFC 1952). - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class GzipEncodeStream extends FilteredStream -{ - /** - * @param StreamInterface $stream - * @param int $level - */ - public function __construct(StreamInterface $stream, $level = -1) - { - if (!extension_loaded('zlib')) { - throw new \RuntimeException('The zlib extension must be enabled to use this stream'); - } - - parent::__construct($stream, ['window' => 31, 'level' => $level], ['window' => 31]); - } - - /** - * {@inheritdoc} - */ - protected function readFilter() - { - return 'zlib.deflate'; - } - - /** - * {@inheritdoc} - */ - protected function writeFilter() - { - return 'zlib.inflate'; - } -} diff --git a/vendor/php-http/message/src/Encoding/InflateStream.php b/vendor/php-http/message/src/Encoding/InflateStream.php deleted file mode 100755 index 70702304f26a77777da16aa6da4a605d5e306300..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Encoding/InflateStream.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -namespace Http\Message\Encoding; - -use Psr\Http\Message\StreamInterface; - -/** - * Stream inflate (RFC 1951). - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -class InflateStream extends FilteredStream -{ - /** - * @param StreamInterface $stream - * @param int $level - */ - public function __construct(StreamInterface $stream, $level = -1) - { - if (!extension_loaded('zlib')) { - throw new \RuntimeException('The zlib extension must be enabled to use this stream'); - } - - parent::__construct($stream, ['window' => -15], ['window' => -15, 'level' => $level]); - } - - /** - * {@inheritdoc} - */ - protected function readFilter() - { - return 'zlib.inflate'; - } - - /** - * {@inheritdoc} - */ - protected function writeFilter() - { - return 'zlib.deflate'; - } -} diff --git a/vendor/php-http/message/src/Exception.php b/vendor/php-http/message/src/Exception.php deleted file mode 100755 index 80d4cd9deaebf319267cfae89a69261f18e5351b..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Exception.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -namespace Http\Message; - -/** - * An interface implemented by all HTTP message related exceptions. - */ -interface Exception -{ -} diff --git a/vendor/php-http/message/src/Exception/UnexpectedValueException.php b/vendor/php-http/message/src/Exception/UnexpectedValueException.php deleted file mode 100755 index 7788ac7c0948a7cdb010c5d41b00004c6d340598..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Exception/UnexpectedValueException.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace Http\Message\Exception; - -use Http\Message\Exception; - -final class UnexpectedValueException extends \UnexpectedValueException implements Exception -{ -} diff --git a/vendor/php-http/message/src/Formatter.php b/vendor/php-http/message/src/Formatter.php deleted file mode 100755 index d04d2c39707bd45e87f204460802bac0b7569a72..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Formatter.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -namespace Http\Message; - -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Formats a request and/or a response as a string. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -interface Formatter -{ - /** - * Formats a request. - * - * @param RequestInterface $request - * - * @return string - */ - public function formatRequest(RequestInterface $request); - - /** - * Formats a response. - * - * @param ResponseInterface $response - * - * @return string - */ - public function formatResponse(ResponseInterface $response); -} diff --git a/vendor/php-http/message/src/Formatter/CurlCommandFormatter.php b/vendor/php-http/message/src/Formatter/CurlCommandFormatter.php deleted file mode 100755 index a0fe7e5fcb6ba043a914b547bb7d4af35a1b9471..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Formatter/CurlCommandFormatter.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php - -namespace Http\Message\Formatter; - -use Http\Message\Formatter; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * A formatter that prints a cURL command for HTTP requests. - * - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -class CurlCommandFormatter implements Formatter -{ - /** - * {@inheritdoc} - */ - public function formatRequest(RequestInterface $request) - { - $command = sprintf('curl %s', escapeshellarg((string) $request->getUri()->withFragment(''))); - if ($request->getProtocolVersion() === '1.0') { - $command .= ' --http1.0'; - } elseif ($request->getProtocolVersion() === '2.0') { - $command .= ' --http2'; - } - - $method = strtoupper($request->getMethod()); - if ('HEAD' === $method) { - $command .= ' --head'; - } elseif ('GET' !== $method) { - $command .= ' --request '.$method; - } - - $command .= $this->getHeadersAsCommandOptions($request); - - $body = $request->getBody(); - if ($body->getSize() > 0) { - if (!$body->isSeekable()) { - return 'Cant format Request as cUrl command if body stream is not seekable.'; - } - $command .= sprintf(' --data %s', escapeshellarg($body->__toString())); - $body->rewind(); - } - - return $command; - } - - /** - * {@inheritdoc} - */ - public function formatResponse(ResponseInterface $response) - { - return ''; - } - - /** - * @param RequestInterface $request - * - * @return string - */ - private function getHeadersAsCommandOptions(RequestInterface $request) - { - $command = ''; - foreach ($request->getHeaders() as $name => $values) { - if ('host' === strtolower($name) && $values[0] === $request->getUri()->getHost()) { - continue; - } - - if ('user-agent' === strtolower($name)) { - $command .= sprintf(' -A %s', escapeshellarg($values[0])); - continue; - } - - $command .= sprintf(' -H %s', escapeshellarg($name.': '.$request->getHeaderLine($name))); - } - - return $command; - } -} diff --git a/vendor/php-http/message/src/Formatter/FullHttpMessageFormatter.php b/vendor/php-http/message/src/Formatter/FullHttpMessageFormatter.php deleted file mode 100755 index 3fa10295feca1930bb61f0b0062c210f8848839c..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Formatter/FullHttpMessageFormatter.php +++ /dev/null @@ -1,91 +0,0 @@ -<?php - -namespace Http\Message\Formatter; - -use Http\Message\Formatter; -use Psr\Http\Message\MessageInterface; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * A formatter that prints the complete HTTP message. - * - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -class FullHttpMessageFormatter implements Formatter -{ - /** - * The maximum length of the body. - * - * @var int - */ - private $maxBodyLength; - - /** - * @param int $maxBodyLength - */ - public function __construct($maxBodyLength = 1000) - { - $this->maxBodyLength = $maxBodyLength; - } - - /** - * {@inheritdoc} - */ - public function formatRequest(RequestInterface $request) - { - $message = sprintf( - "%s %s HTTP/%s\n", - $request->getMethod(), - $request->getRequestTarget(), - $request->getProtocolVersion() - ); - - foreach ($request->getHeaders() as $name => $values) { - $message .= $name.': '.implode(', ', $values)."\n"; - } - - return $this->addBody($request, $message); - } - - /** - * {@inheritdoc} - */ - public function formatResponse(ResponseInterface $response) - { - $message = sprintf( - "HTTP/%s %s %s\n", - $response->getProtocolVersion(), - $response->getStatusCode(), - $response->getReasonPhrase() - ); - - foreach ($response->getHeaders() as $name => $values) { - $message .= $name.': '.implode(', ', $values)."\n"; - } - - return $this->addBody($response, $message); - } - - /** - * Add the message body if the stream is seekable. - * - * @param MessageInterface $request - * @param string $message - * - * @return string - */ - private function addBody(MessageInterface $request, $message) - { - $stream = $request->getBody(); - if (!$stream->isSeekable() || $this->maxBodyLength === 0) { - // Do not read the stream - $message .= "\n"; - } else { - $message .= "\n".mb_substr($stream->__toString(), 0, $this->maxBodyLength); - $stream->rewind(); - } - - return $message; - } -} diff --git a/vendor/php-http/message/src/Formatter/SimpleFormatter.php b/vendor/php-http/message/src/Formatter/SimpleFormatter.php deleted file mode 100755 index b1fcabdb0aef3f3e354917cb78bd9d134ef72683..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Formatter/SimpleFormatter.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -namespace Http\Message\Formatter; - -use Http\Message\Formatter; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; - -/** - * Normalize a request or a response into a string or an array. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -class SimpleFormatter implements Formatter -{ - /** - * {@inheritdoc} - */ - public function formatRequest(RequestInterface $request) - { - return sprintf( - '%s %s %s', - $request->getMethod(), - $request->getUri()->__toString(), - $request->getProtocolVersion() - ); - } - - /** - * {@inheritdoc} - */ - public function formatResponse(ResponseInterface $response) - { - return sprintf( - '%s %s %s', - $response->getStatusCode(), - $response->getReasonPhrase(), - $response->getProtocolVersion() - ); - } -} diff --git a/vendor/php-http/message/src/MessageFactory/DiactorosMessageFactory.php b/vendor/php-http/message/src/MessageFactory/DiactorosMessageFactory.php deleted file mode 100755 index 53f08ae0d2947fcccf409edd7866ef7ff42713a8..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/MessageFactory/DiactorosMessageFactory.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php - -namespace Http\Message\MessageFactory; - -use Http\Message\StreamFactory\DiactorosStreamFactory; -use Http\Message\MessageFactory; -use Zend\Diactoros\Request; -use Zend\Diactoros\Response; - -/** - * Creates Diactoros messages. - * - * @author GeLo <geloen.eric@gmail.com> - */ -final class DiactorosMessageFactory implements MessageFactory -{ - /** - * @var DiactorosStreamFactory - */ - private $streamFactory; - - public function __construct() - { - $this->streamFactory = new DiactorosStreamFactory(); - } - - /** - * {@inheritdoc} - */ - public function createRequest( - $method, - $uri, - array $headers = [], - $body = null, - $protocolVersion = '1.1' - ) { - return (new Request( - $uri, - $method, - $this->streamFactory->createStream($body), - $headers - ))->withProtocolVersion($protocolVersion); - } - - /** - * {@inheritdoc} - */ - public function createResponse( - $statusCode = 200, - $reasonPhrase = null, - array $headers = [], - $body = null, - $protocolVersion = '1.1' - ) { - return (new Response( - $this->streamFactory->createStream($body), - $statusCode, - $headers - ))->withProtocolVersion($protocolVersion); - } -} diff --git a/vendor/php-http/message/src/MessageFactory/GuzzleMessageFactory.php b/vendor/php-http/message/src/MessageFactory/GuzzleMessageFactory.php deleted file mode 100755 index 59eb6551636f77f45adaffbece93dee503753bf2..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/MessageFactory/GuzzleMessageFactory.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -namespace Http\Message\MessageFactory; - -use GuzzleHttp\Psr7\Request; -use GuzzleHttp\Psr7\Response; -use Http\Message\MessageFactory; - -/** - * Creates Guzzle messages. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -final class GuzzleMessageFactory implements MessageFactory -{ - /** - * {@inheritdoc} - */ - public function createRequest( - $method, - $uri, - array $headers = [], - $body = null, - $protocolVersion = '1.1' - ) { - return new Request( - $method, - $uri, - $headers, - $body, - $protocolVersion - ); - } - - /** - * {@inheritdoc} - */ - public function createResponse( - $statusCode = 200, - $reasonPhrase = null, - array $headers = [], - $body = null, - $protocolVersion = '1.1' - ) { - return new Response( - $statusCode, - $headers, - $body, - $protocolVersion, - $reasonPhrase - ); - } -} diff --git a/vendor/php-http/message/src/MessageFactory/SlimMessageFactory.php b/vendor/php-http/message/src/MessageFactory/SlimMessageFactory.php deleted file mode 100755 index cdad2ec2a6770c7b059b72609849d8a2bdecfb41..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/MessageFactory/SlimMessageFactory.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php - -namespace Http\Message\MessageFactory; - -use Http\Message\StreamFactory\SlimStreamFactory; -use Http\Message\UriFactory\SlimUriFactory; -use Http\Message\MessageFactory; -use Slim\Http\Request; -use Slim\Http\Response; -use Slim\Http\Headers; - -/** - * Creates Slim 3 messages. - * - * @author Mika Tuupola <tuupola@appelsiini.net> - */ -final class SlimMessageFactory implements MessageFactory -{ - /** - * @var SlimStreamFactory - */ - private $streamFactory; - - /** - * @var SlimUriFactory - */ - private $uriFactory; - - public function __construct() - { - $this->streamFactory = new SlimStreamFactory(); - $this->uriFactory = new SlimUriFactory(); - } - - /** - * {@inheritdoc} - */ - public function createRequest( - $method, - $uri, - array $headers = [], - $body = null, - $protocolVersion = '1.1' - ) { - return (new Request( - $method, - $this->uriFactory->createUri($uri), - new Headers($headers), - [], - [], - $this->streamFactory->createStream($body), - [] - ))->withProtocolVersion($protocolVersion); - } - - /** - * {@inheritdoc} - */ - public function createResponse( - $statusCode = 200, - $reasonPhrase = null, - array $headers = [], - $body = null, - $protocolVersion = '1.1' - ) { - return (new Response( - $statusCode, - new Headers($headers), - $this->streamFactory->createStream($body) - ))->withProtocolVersion($protocolVersion); - } -} diff --git a/vendor/php-http/message/src/RequestMatcher.php b/vendor/php-http/message/src/RequestMatcher.php deleted file mode 100755 index 94fe532401502da92df403c4f18b7858cc601378..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/RequestMatcher.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php - -namespace Http\Message; - -use Psr\Http\Message\RequestInterface; - -/** - * Match a request. - * - * PSR-7 equivalent of Symfony's RequestMatcher - * - * @see https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/RequestMatcherInterface.php - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -interface RequestMatcher -{ - /** - * Decides whether the rule(s) implemented by the strategy matches the supplied request. - * - * @param RequestInterface $request The PSR7 request to check for a match - * - * @return bool true if the request matches, false otherwise - */ - public function matches(RequestInterface $request); -} diff --git a/vendor/php-http/message/src/RequestMatcher/CallbackRequestMatcher.php b/vendor/php-http/message/src/RequestMatcher/CallbackRequestMatcher.php deleted file mode 100755 index 4d45e32e5a2b90b80c04705c4130e1c01acad23b..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/RequestMatcher/CallbackRequestMatcher.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -namespace Http\Message\RequestMatcher; - -use Http\Message\RequestMatcher; -use Psr\Http\Message\RequestInterface; - -/** - * Match a request with a callback. - * - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -final class CallbackRequestMatcher implements RequestMatcher -{ - /** - * @var callable - */ - private $callback; - - /** - * @param callable $callback - */ - public function __construct(callable $callback) - { - $this->callback = $callback; - } - - /** - * {@inheritdoc} - */ - public function matches(RequestInterface $request) - { - return (bool) call_user_func($this->callback, $request); - } -} diff --git a/vendor/php-http/message/src/RequestMatcher/RegexRequestMatcher.php b/vendor/php-http/message/src/RequestMatcher/RegexRequestMatcher.php deleted file mode 100755 index 91f3729e6f14df882a60a62340f1bc66b499dc47..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/RequestMatcher/RegexRequestMatcher.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -namespace Http\Message\RequestMatcher; - -use Http\Message\RequestMatcher; -use Psr\Http\Message\RequestInterface; - -@trigger_error('The '.__NAMESPACE__.'\RegexRequestMatcher class is deprecated since version 1.2 and will be removed in 2.0. Use Http\Message\RequestMatcher\RequestMatcher instead.', E_USER_DEPRECATED); - -/** - * Match a request with a regex on the uri. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - * - * @deprecated since version 1.2 and will be removed in 2.0. Use {@link RequestMatcher} instead. - */ -final class RegexRequestMatcher implements RequestMatcher -{ - /** - * Matching regex. - * - * @var string - */ - private $regex; - - /** - * @param string $regex - */ - public function __construct($regex) - { - $this->regex = $regex; - } - - /** - * {@inheritdoc} - */ - public function matches(RequestInterface $request) - { - return (bool) preg_match($this->regex, (string) $request->getUri()); - } -} diff --git a/vendor/php-http/message/src/RequestMatcher/RequestMatcher.php b/vendor/php-http/message/src/RequestMatcher/RequestMatcher.php deleted file mode 100755 index e2aa02123138e2c0775645b9b6ff65ed59f97553..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/RequestMatcher/RequestMatcher.php +++ /dev/null @@ -1,78 +0,0 @@ -<?php - -namespace Http\Message\RequestMatcher; - -use Http\Message\RequestMatcher as RequestMatcherInterface; -use Psr\Http\Message\RequestInterface; - -/** - * A port of the Symfony RequestMatcher for PSR-7. - * - * @author Fabien Potencier <fabien@symfony.com> - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class RequestMatcher implements RequestMatcherInterface -{ - /** - * @var string - */ - private $path; - - /** - * @var string - */ - private $host; - - /** - * @var array - */ - private $methods = []; - - /** - * @var string[] - */ - private $schemes = []; - - /** - * The regular expressions used for path or host must be specified without delimiter. - * You do not need to escape the forward slash / to match it. - * - * @param string|null $path Regular expression for the path - * @param string|null $host Regular expression for the hostname - * @param string|string[]|null $methods Method or list of methods to match - * @param string|string[]|null $schemes Scheme or list of schemes to match (e.g. http or https) - */ - public function __construct($path = null, $host = null, $methods = [], $schemes = []) - { - $this->path = $path; - $this->host = $host; - $this->methods = array_map('strtoupper', (array) $methods); - $this->schemes = array_map('strtolower', (array) $schemes); - } - - /** - * {@inheritdoc} - * - * @api - */ - public function matches(RequestInterface $request) - { - if ($this->schemes && !in_array($request->getUri()->getScheme(), $this->schemes)) { - return false; - } - - if ($this->methods && !in_array($request->getMethod(), $this->methods)) { - return false; - } - - if (null !== $this->path && !preg_match('{'.$this->path.'}', rawurldecode($request->getUri()->getPath()))) { - return false; - } - - if (null !== $this->host && !preg_match('{'.$this->host.'}i', $request->getUri()->getHost())) { - return false; - } - - return true; - } -} diff --git a/vendor/php-http/message/src/Stream/BufferedStream.php b/vendor/php-http/message/src/Stream/BufferedStream.php deleted file mode 100755 index 1eac97474147f18d5fa50e760579ebd5eaa9ad27..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/Stream/BufferedStream.php +++ /dev/null @@ -1,270 +0,0 @@ -<?php - -namespace Http\Message\Stream; - -use Psr\Http\Message\StreamInterface; - -/** - * Decorator to make any stream seekable. - * - * Internally it buffers an existing StreamInterface into a php://temp resource (or memory). By default it will use - * 2 megabytes of memory before writing to a temporary disk file. - * - * Due to this, very large stream can suffer performance issue (i/o slowdown). - */ -class BufferedStream implements StreamInterface -{ - /** @var resource The buffered resource used to seek previous data */ - private $resource; - - /** @var int size of the stream if available */ - private $size; - - /** @var StreamInterface The underlying stream decorated by this class */ - private $stream; - - /** @var int How many bytes were written */ - private $written = 0; - - /** - * @param StreamInterface $stream Decorated stream - * @param bool $useFileBuffer Whether to use a file buffer (write to a file, if data exceed a certain size) - * by default, set this to false to only use memory - * @param int $memoryBuffer In conjunction with using file buffer, limit (in bytes) from which it begins to buffer - * the data in a file - */ - public function __construct(StreamInterface $stream, $useFileBuffer = true, $memoryBuffer = 2097152) - { - $this->stream = $stream; - $this->size = $stream->getSize(); - - if ($useFileBuffer) { - $this->resource = fopen('php://temp/maxmemory:'.$memoryBuffer, 'rw+'); - } else { - $this->resource = fopen('php://memory', 'rw+'); - } - - if (false === $this->resource) { - throw new \RuntimeException('Cannot create a resource over temp or memory implementation'); - } - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - try { - $this->rewind(); - - return $this->getContents(); - } catch (\Throwable $throwable) { - return ''; - } catch (\Exception $exception) { // Layer to be BC with PHP 5, remove this when we only support PHP 7+ - return ''; - } - } - - /** - * {@inheritdoc} - */ - public function close() - { - if (null === $this->resource) { - throw new \RuntimeException('Cannot close on a detached stream'); - } - - $this->stream->close(); - fclose($this->resource); - } - - /** - * {@inheritdoc} - */ - public function detach() - { - if (null === $this->resource) { - return; - } - - // Force reading the remaining data of the stream - $this->getContents(); - - $resource = $this->resource; - $this->stream->close(); - $this->stream = null; - $this->resource = null; - - return $resource; - } - - /** - * {@inheritdoc} - */ - public function getSize() - { - if (null === $this->resource) { - return; - } - - if (null === $this->size && $this->stream->eof()) { - return $this->written; - } - - return $this->size; - } - - /** - * {@inheritdoc} - */ - public function tell() - { - if (null === $this->resource) { - throw new \RuntimeException('Cannot tell on a detached stream'); - } - - return ftell($this->resource); - } - - /** - * {@inheritdoc} - */ - public function eof() - { - if (null === $this->resource) { - throw new \RuntimeException('Cannot call eof on a detached stream'); - } - - // We are at the end only when both our resource and underlying stream are at eof - return $this->stream->eof() && (ftell($this->resource) === $this->written); - } - - /** - * {@inheritdoc} - */ - public function isSeekable() - { - return null !== $this->resource; - } - - /** - * {@inheritdoc} - */ - public function seek($offset, $whence = SEEK_SET) - { - if (null === $this->resource) { - throw new \RuntimeException('Cannot seek on a detached stream'); - } - - fseek($this->resource, $offset, $whence); - } - - /** - * {@inheritdoc} - */ - public function rewind() - { - if (null === $this->resource) { - throw new \RuntimeException('Cannot rewind on a detached stream'); - } - - rewind($this->resource); - } - - /** - * {@inheritdoc} - */ - public function isWritable() - { - return false; - } - - /** - * {@inheritdoc} - */ - public function write($string) - { - throw new \RuntimeException('Cannot write on this stream'); - } - - /** - * {@inheritdoc} - */ - public function isReadable() - { - return null !== $this->resource; - } - - /** - * {@inheritdoc} - */ - public function read($length) - { - if (null === $this->resource) { - throw new \RuntimeException('Cannot read on a detached stream'); - } - - $read = ''; - - // First read from the resource - if (ftell($this->resource) !== $this->written) { - $read = fread($this->resource, $length); - } - - $bytesRead = strlen($read); - - if ($bytesRead < $length) { - $streamRead = $this->stream->read($length - $bytesRead); - - // Write on the underlying stream what we read - $this->written += fwrite($this->resource, $streamRead); - $read .= $streamRead; - } - - return $read; - } - - /** - * {@inheritdoc} - */ - public function getContents() - { - if (null === $this->resource) { - throw new \RuntimeException('Cannot read on a detached stream'); - } - - $read = ''; - - while (!$this->eof()) { - $read .= $this->read(8192); - } - - return $read; - } - - /** - * {@inheritdoc} - */ - public function getMetadata($key = null) - { - if (null === $this->resource) { - if (null === $key) { - return []; - } - - return; - } - - $metadata = stream_get_meta_data($this->resource); - - if (null === $key) { - return $metadata; - } - - if (!array_key_exists($key, $metadata)) { - return; - } - - return $metadata[$key]; - } -} diff --git a/vendor/php-http/message/src/StreamFactory/DiactorosStreamFactory.php b/vendor/php-http/message/src/StreamFactory/DiactorosStreamFactory.php deleted file mode 100755 index a75ec9881c4ce2971c149f96ac1ed73556595ab3..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/StreamFactory/DiactorosStreamFactory.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -namespace Http\Message\StreamFactory; - -use Http\Message\StreamFactory; -use Psr\Http\Message\StreamInterface; -use Zend\Diactoros\Stream; - -/** - * Creates Diactoros streams. - * - * @author Михаил Красильников <m.krasilnikov@yandex.ru> - */ -final class DiactorosStreamFactory implements StreamFactory -{ - /** - * {@inheritdoc} - */ - public function createStream($body = null) - { - if ($body instanceof StreamInterface) { - return $body; - } - - if (is_resource($body)) { - return new Stream($body); - } - - $stream = new Stream('php://memory', 'rw'); - if (null !== $body && '' !== $body) { - $stream->write((string) $body); - } - - return $stream; - } -} diff --git a/vendor/php-http/message/src/StreamFactory/GuzzleStreamFactory.php b/vendor/php-http/message/src/StreamFactory/GuzzleStreamFactory.php deleted file mode 100755 index 10f4d3f9627c041bb68a6d0ce27a4e259a3ff13f..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/StreamFactory/GuzzleStreamFactory.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -namespace Http\Message\StreamFactory; - -use Http\Message\StreamFactory; - -/** - * Creates Guzzle streams. - * - * @author Михаил Красильников <m.krasilnikov@yandex.ru> - */ -final class GuzzleStreamFactory implements StreamFactory -{ - /** - * {@inheritdoc} - */ - public function createStream($body = null) - { - return \GuzzleHttp\Psr7\stream_for($body); - } -} diff --git a/vendor/php-http/message/src/StreamFactory/SlimStreamFactory.php b/vendor/php-http/message/src/StreamFactory/SlimStreamFactory.php deleted file mode 100755 index efcadc439d4c19a5f07307e398b00637c234f045..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/StreamFactory/SlimStreamFactory.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -namespace Http\Message\StreamFactory; - -use Http\Message\StreamFactory; -use Psr\Http\Message\StreamInterface; -use Slim\Http\Stream; - -/** - * Creates Slim 3 streams. - * - * @author Mika Tuupola <tuupola@appelsiini.net> - */ -final class SlimStreamFactory implements StreamFactory -{ - /** - * {@inheritdoc} - */ - public function createStream($body = null) - { - if ($body instanceof StreamInterface) { - return $body; - } - - if (is_resource($body)) { - return new Stream($body); - } - - $resource = fopen('php://memory', 'r+'); - $stream = new Stream($resource); - if (null !== $body && '' !== $body) { - $stream->write((string) $body); - } - - return $stream; - } -} diff --git a/vendor/php-http/message/src/UriFactory/DiactorosUriFactory.php b/vendor/php-http/message/src/UriFactory/DiactorosUriFactory.php deleted file mode 100755 index 268c361d0479e6607769c03a0db1c34eca01d638..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/UriFactory/DiactorosUriFactory.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -namespace Http\Message\UriFactory; - -use Http\Message\UriFactory; -use Psr\Http\Message\UriInterface; -use Zend\Diactoros\Uri; - -/** - * Creates Diactoros URI. - * - * @author David de Boer <david@ddeboer.nl> - */ -final class DiactorosUriFactory implements UriFactory -{ - /** - * {@inheritdoc} - */ - public function createUri($uri) - { - if ($uri instanceof UriInterface) { - return $uri; - } elseif (is_string($uri)) { - return new Uri($uri); - } - - throw new \InvalidArgumentException('URI must be a string or UriInterface'); - } -} diff --git a/vendor/php-http/message/src/UriFactory/GuzzleUriFactory.php b/vendor/php-http/message/src/UriFactory/GuzzleUriFactory.php deleted file mode 100755 index 4c1c286c2cad763c0a0f34bbc152a99d375d5bdb..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/UriFactory/GuzzleUriFactory.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php - -namespace Http\Message\UriFactory; - -use GuzzleHttp\Psr7; -use Http\Message\UriFactory; - -/** - * Creates Guzzle URI. - * - * @author David de Boer <david@ddeboer.nl> - */ -final class GuzzleUriFactory implements UriFactory -{ - /** - * {@inheritdoc} - */ - public function createUri($uri) - { - return Psr7\uri_for($uri); - } -} diff --git a/vendor/php-http/message/src/UriFactory/SlimUriFactory.php b/vendor/php-http/message/src/UriFactory/SlimUriFactory.php deleted file mode 100755 index c013d54298435c0329b643f7de03c6417fa28849..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/UriFactory/SlimUriFactory.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php - -namespace Http\Message\UriFactory; - -use Http\Message\UriFactory; -use Psr\Http\Message\UriInterface; -use Slim\Http\Uri; - -/** - * Creates Slim 3 URI. - * - * @author Mika Tuupola <tuupola@appelsiini.net> - */ -final class SlimUriFactory implements UriFactory -{ - /** - * {@inheritdoc} - */ - public function createUri($uri) - { - if ($uri instanceof UriInterface) { - return $uri; - } - - if (is_string($uri)) { - return Uri::createFromString($uri); - } - - throw new \InvalidArgumentException('URI must be a string or UriInterface'); - } -} diff --git a/vendor/php-http/message/src/filters.php b/vendor/php-http/message/src/filters.php deleted file mode 100755 index 15ed73de79da79b1e093471c97eb330069818816..0000000000000000000000000000000000000000 --- a/vendor/php-http/message/src/filters.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php - -// Register chunk filter if not found -if (!array_key_exists('chunk', stream_get_filters())) { - stream_filter_register('chunk', 'Http\Message\Encoding\Filter\Chunk'); -} diff --git a/vendor/php-http/multipart-stream-builder/CHANGELOG.md b/vendor/php-http/multipart-stream-builder/CHANGELOG.md deleted file mode 100755 index 1f0ee3d7f32e2bc04227bb2988081ba0fbd2af08..0000000000000000000000000000000000000000 --- a/vendor/php-http/multipart-stream-builder/CHANGELOG.md +++ /dev/null @@ -1,60 +0,0 @@ -# Change Log - -## 1.0.0 - 2017-05-21 - -No changes from 0.2.0. - -## 0.2.0 - 2017-02-20 - -You may do a BC update to version 0.2.0 if you are sure that you are not adding -multiple resources with the same name to the Builder. - -### Fixed - -- Make sure one can add resources with same name without overwrite. - -## 0.1.6 - 2017-02-16 - -### Fixed - -- Performance improvements by avoid using `uniqid()`. - -## 0.1.5 - 2017-02-14 - -### Fixed - -- Support for non-readable streams. This fix was needed because flaws in Guzzle, Zend and Slims implementations of PSR-7. - -## 0.1.4 - 2016-12-31 - -### Added - -- Added support for resetting the builder - -## 0.1.3 - 2016-12-22 - -### Added - -- Added `CustomMimetypeHelper` to allow you to configure custom mimetypes. - -### Changed - -- Using regular expression instead of `basename($filename)` because basename is depending on locale. - -## 0.1.2 - 2016-08-31 - -### Added - -- Support for Outlook msg files. - -## 0.1.1 - 2016-08-10 - -### Added - -- Support for Apple passbook. - -## 0.1.0 - 2016-07-19 - -### Added - -- Initial release diff --git a/vendor/php-http/multipart-stream-builder/LICENSE b/vendor/php-http/multipart-stream-builder/LICENSE deleted file mode 100755 index 8e2c4a0b85c31bf132105920cc90ba371025eb8a..0000000000000000000000000000000000000000 --- a/vendor/php-http/multipart-stream-builder/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015 PHP HTTP Team <team@php-http.org> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/php-http/multipart-stream-builder/README.md b/vendor/php-http/multipart-stream-builder/README.md deleted file mode 100755 index 10ad0588b4b7e9a43e9eaced1ecda28c7b4cf372..0000000000000000000000000000000000000000 --- a/vendor/php-http/multipart-stream-builder/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# PSR-7 Multipart Stream Builder - -[](https://github.com/php-http/multipart-stream-builder/releases) -[](https://travis-ci.org/php-http/multipart-stream-builder) -[](https://scrutinizer-ci.com/g/php-http/multipart-stream-builder) -[](https://scrutinizer-ci.com/g/php-http/multipart-stream-builder) -[](https://packagist.org/packages/php-http/multipart-stream-builder) - -**A builder for Multipart PSR-7 Streams. The builder create streams independenly form any PSR-7 implementation.** - - -## Install - -Via Composer - -``` bash -$ composer require php-http/multipart-stream-builder -``` - -## Documentation - -Please see the [official documentation](http://php-http.readthedocs.org/en/latest/components/multipart-stream-builder.html). - - -## Contributing - -Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details. - - -## Security - -If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org). - - -## License - -The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/vendor/php-http/multipart-stream-builder/appveyor.yml b/vendor/php-http/multipart-stream-builder/appveyor.yml deleted file mode 100755 index 8d7af73f722812a369260d79a9078c2b01a02393..0000000000000000000000000000000000000000 --- a/vendor/php-http/multipart-stream-builder/appveyor.yml +++ /dev/null @@ -1,39 +0,0 @@ -build: false -platform: - - x86 - - x64 - -clone_folder: c:\projects\php-http\multipart-stream-builder - -cache: - - c:\tools\php -> appveyor.yml - -init: - - SET PATH=c:\php;%PATH% - - SET COMPOSER_NO_INTERACTION=1 - - SET PHP=1 - - -install: - - IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php) - - cd c:\php - - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-7.0.0-nts-Win32-VC14-x86.zip - - IF %PHP%==1 7z x php-7.0.0-nts-Win32-VC14-x86.zip -y >nul - - IF %PHP%==1 del /Q *.zip - - IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat - - IF %PHP%==1 copy /Y php.ini-development php.ini - - IF %PHP%==1 echo max_execution_time=1200 >> php.ini - - IF %PHP%==1 echo date.timezone="UTC" >> php.ini - - IF %PHP%==1 echo extension_dir=ext >> php.ini - - IF %PHP%==1 echo extension=php_openssl.dll >> php.ini - - IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini - - IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini - - appveyor DownloadFile https://getcomposer.org/composer.phar - - cd c:\projects\php-http\multipart-stream-builder - - mkdir %APPDATA%\Composer - - composer update --prefer-dist --no-progress --ansi - -test_script: - - cd c:\projects\php-http\multipart-stream-builder - - vendor\bin\phpunit.bat --verbose - diff --git a/vendor/php-http/multipart-stream-builder/composer.json b/vendor/php-http/multipart-stream-builder/composer.json deleted file mode 100755 index 1ada3605c54bd13ede3523d86fd9ac8a4cb31fbd..0000000000000000000000000000000000000000 --- a/vendor/php-http/multipart-stream-builder/composer.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "php-http/multipart-stream-builder", - "description": "A builder class that help you create a multipart stream", - "license": "MIT", - "keywords": ["http", "factory", "message", "stream", "multipart stream"], - "homepage": "http://php-http.org", - "authors": [ - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com" - } - ], - "require": { - "php": "^5.5 || ^7.0", - "psr/http-message": "^1.0", - "php-http/message-factory": "^1.0.2", - "php-http/discovery": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.4", - "php-http/message": "^1.5", - "zendframework/zend-diactoros": "^1.3.5" - }, - "autoload": { - "psr-4": { - "Http\\Message\\MultipartStream\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "tests\\Http\\Message\\MultipartStream\\": "tests/" - } - }, - "scripts": { - "test": "vendor/bin/phpunit", - "test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml" - }, - "extra": { - "branch-alias": { - "dev-master": "0.3-dev" - } - } -} diff --git a/vendor/php-http/multipart-stream-builder/src/ApacheMimetypeHelper.php b/vendor/php-http/multipart-stream-builder/src/ApacheMimetypeHelper.php deleted file mode 100755 index 6e4ca660246f5fdc929ca455e3e30b1ddc6c639b..0000000000000000000000000000000000000000 --- a/vendor/php-http/multipart-stream-builder/src/ApacheMimetypeHelper.php +++ /dev/null @@ -1,142 +0,0 @@ -<?php - -namespace Http\Message\MultipartStream; - -/** - * This class helps to find the proper mime types. The source of this file is taken - * from Guzzle. - * - * @author Michael Dowling and contributors to guzzlehttp/psr7 - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -class ApacheMimetypeHelper implements MimetypeHelper -{ - /** - * {@inheritdoc} - * - * @see http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types - */ - public function getMimetypeFromFilename($filename) - { - return $this->getMimetypeFromExtension(pathinfo($filename, PATHINFO_EXTENSION)); - } - - /** - * {@inheritdoc} - * - * @see http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types - */ - public function getMimetypeFromExtension($extension) - { - static $mimetypes = [ - '7z' => 'application/x-7z-compressed', - 'aac' => 'audio/x-aac', - 'ai' => 'application/postscript', - 'aif' => 'audio/x-aiff', - 'asc' => 'text/plain', - 'asf' => 'video/x-ms-asf', - 'atom' => 'application/atom+xml', - 'avi' => 'video/x-msvideo', - 'bmp' => 'image/bmp', - 'bz2' => 'application/x-bzip2', - 'cer' => 'application/pkix-cert', - 'crl' => 'application/pkix-crl', - 'crt' => 'application/x-x509-ca-cert', - 'css' => 'text/css', - 'csv' => 'text/csv', - 'cu' => 'application/cu-seeme', - 'deb' => 'application/x-debian-package', - 'doc' => 'application/msword', - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'dvi' => 'application/x-dvi', - 'eot' => 'application/vnd.ms-fontobject', - 'eps' => 'application/postscript', - 'epub' => 'application/epub+zip', - 'etx' => 'text/x-setext', - 'flac' => 'audio/flac', - 'flv' => 'video/x-flv', - 'gif' => 'image/gif', - 'gz' => 'application/gzip', - 'htm' => 'text/html', - 'html' => 'text/html', - 'ico' => 'image/x-icon', - 'ics' => 'text/calendar', - 'ini' => 'text/plain', - 'iso' => 'application/x-iso9660-image', - 'jar' => 'application/java-archive', - 'jpe' => 'image/jpeg', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'js' => 'text/javascript', - 'json' => 'application/json', - 'latex' => 'application/x-latex', - 'log' => 'text/plain', - 'm4a' => 'audio/mp4', - 'm4v' => 'video/mp4', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mov' => 'video/quicktime', - 'mp3' => 'audio/mpeg', - 'mp4' => 'video/mp4', - 'mp4a' => 'audio/mp4', - 'mp4v' => 'video/mp4', - 'mpe' => 'video/mpeg', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mpg4' => 'video/mp4', - 'oga' => 'audio/ogg', - 'ogg' => 'audio/ogg', - 'ogv' => 'video/ogg', - 'ogx' => 'application/ogg', - 'pbm' => 'image/x-portable-bitmap', - 'pdf' => 'application/pdf', - 'pgm' => 'image/x-portable-graymap', - 'png' => 'image/png', - 'pnm' => 'image/x-portable-anymap', - 'ppm' => 'image/x-portable-pixmap', - 'ppt' => 'application/vnd.ms-powerpoint', - 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'ps' => 'application/postscript', - 'qt' => 'video/quicktime', - 'rar' => 'application/x-rar-compressed', - 'ras' => 'image/x-cmu-raster', - 'rss' => 'application/rss+xml', - 'rtf' => 'application/rtf', - 'sgm' => 'text/sgml', - 'sgml' => 'text/sgml', - 'svg' => 'image/svg+xml', - 'swf' => 'application/x-shockwave-flash', - 'tar' => 'application/x-tar', - 'tif' => 'image/tiff', - 'tiff' => 'image/tiff', - 'torrent' => 'application/x-bittorrent', - 'ttf' => 'application/x-font-ttf', - 'txt' => 'text/plain', - 'wav' => 'audio/x-wav', - 'webm' => 'video/webm', - 'wma' => 'audio/x-ms-wma', - 'wmv' => 'video/x-ms-wmv', - 'woff' => 'application/x-font-woff', - 'wsdl' => 'application/wsdl+xml', - 'xbm' => 'image/x-xbitmap', - 'xls' => 'application/vnd.ms-excel', - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'xml' => 'application/xml', - 'xpm' => 'image/x-xpixmap', - 'xwd' => 'image/x-xwindowdump', - 'yaml' => 'text/yaml', - 'yml' => 'text/yaml', - 'zip' => 'application/zip', - - // Non-Apache standard - 'pkpass' => 'application/vnd.apple.pkpass', - 'msg' => 'application/vnd.ms-outlook', - ]; - - $extension = strtolower($extension); - - return isset($mimetypes[$extension]) - ? $mimetypes[$extension] - : null; - } -} diff --git a/vendor/php-http/multipart-stream-builder/src/CustomMimetypeHelper.php b/vendor/php-http/multipart-stream-builder/src/CustomMimetypeHelper.php deleted file mode 100755 index 9f3f0d9211e563aeabcb59b6e34912de7ae1779e..0000000000000000000000000000000000000000 --- a/vendor/php-http/multipart-stream-builder/src/CustomMimetypeHelper.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php - -namespace Http\Message\MultipartStream; - -/** - * Let you add your own mimetypes. The mimetype lookup will fallback on the ApacheMimeTypeHelper. - * - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -class CustomMimetypeHelper extends ApacheMimetypeHelper -{ - /** - * @var array - */ - private $mimetypes = []; - - /** - * @param array $mimetypes should be of type extension => mimetype - */ - public function __construct(array $mimetypes = []) - { - $this->mimetypes = $mimetypes; - } - - /** - * @param string $extension - * @param string $mimetype - * - * @return $this - */ - public function addMimetype($extension, $mimetype) - { - $this->mimetypes[$extension] = $mimetype; - - return $this; - } - - /** - * {@inheritdoc} - * - * Check if we have any defined mimetypes and of not fallback to ApacheMimetypeHelper - */ - public function getMimetypeFromExtension($extension) - { - $extension = strtolower($extension); - - return isset($this->mimetypes[$extension]) - ? $this->mimetypes[$extension] - : parent::getMimetypeFromExtension($extension); - } -} diff --git a/vendor/php-http/multipart-stream-builder/src/MimetypeHelper.php b/vendor/php-http/multipart-stream-builder/src/MimetypeHelper.php deleted file mode 100755 index fa7cf18003720731c5391e572537fb42795802e4..0000000000000000000000000000000000000000 --- a/vendor/php-http/multipart-stream-builder/src/MimetypeHelper.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -namespace Http\Message\MultipartStream; - -/** - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -interface MimetypeHelper -{ - /** - * Determines the mimetype of a file by looking at its extension. - * - * @param string $filename - * - * @return null|string - */ - public function getMimetypeFromFilename($filename); - - /** - * Maps a file extensions to a mimetype. - * - * @param string $extension The file extension - * - * @return string|null - */ - public function getMimetypeFromExtension($extension); -} diff --git a/vendor/php-http/multipart-stream-builder/src/MultipartStreamBuilder.php b/vendor/php-http/multipart-stream-builder/src/MultipartStreamBuilder.php deleted file mode 100755 index 3421d73487438866f3d037abfd041244927f8b50..0000000000000000000000000000000000000000 --- a/vendor/php-http/multipart-stream-builder/src/MultipartStreamBuilder.php +++ /dev/null @@ -1,278 +0,0 @@ -<?php - -namespace Http\Message\MultipartStream; - -use Http\Discovery\StreamFactoryDiscovery; -use Http\Message\StreamFactory; -use Psr\Http\Message\StreamInterface; - -/** - * Build your own Multipart stream. A Multipart stream is a collection of streams separated with a $bounary. This - * class helps you to create a Multipart stream with stream implementations from any PSR7 library. - * - * @author Michael Dowling and contributors to guzzlehttp/psr7 - * @author Tobias Nyholm <tobias.nyholm@gmail.com> - */ -class MultipartStreamBuilder -{ - /** - * @var StreamFactory - */ - private $streamFactory; - - /** - * @var MimetypeHelper - */ - private $mimetypeHelper; - - /** - * @var string - */ - private $boundary; - - /** - * @var array Element where each Element is an array with keys ['contents', 'headers', 'filename'] - */ - private $data = []; - - /** - * @param StreamFactory|null $streamFactory - */ - public function __construct(StreamFactory $streamFactory = null) - { - $this->streamFactory = $streamFactory ?: StreamFactoryDiscovery::find(); - } - - /** - * Add a resource to the Multipart Stream. - * - * @param string $name the formpost name - * @param string|resource|StreamInterface $resource - * @param array $options { - * - * @var array $headers additional headers ['header-name' => 'header-value'] - * @var string $filename - * } - * - * @return MultipartStreamBuilder - */ - public function addResource($name, $resource, array $options = []) - { - $stream = $this->streamFactory->createStream($resource); - - // validate options['headers'] exists - if (!isset($options['headers'])) { - $options['headers'] = []; - } - - // Try to add filename if it is missing - if (empty($options['filename'])) { - $options['filename'] = null; - $uri = $stream->getMetadata('uri'); - if (substr($uri, 0, 6) !== 'php://') { - $options['filename'] = $uri; - } - } - - $this->prepareHeaders($name, $stream, $options['filename'], $options['headers']); - $this->data[] = ['contents' => $stream, 'headers' => $options['headers'], 'filename' => $options['filename']]; - - return $this; - } - - /** - * Build the stream. - * - * @return StreamInterface - */ - public function build() - { - $streams = ''; - foreach ($this->data as $data) { - // Add start and headers - $streams .= "--{$this->getBoundary()}\r\n". - $this->getHeaders($data['headers'])."\r\n"; - - // Convert the stream to string - /* @var $contentStream StreamInterface */ - $contentStream = $data['contents']; - if ($contentStream->isSeekable()) { - $streams .= $contentStream->__toString(); - } else { - $streams .= $contentStream->getContents(); - } - - $streams .= "\r\n"; - } - - // Append end - $streams .= "--{$this->getBoundary()}--\r\n"; - - return $this->streamFactory->createStream($streams); - } - - /** - * Add extra headers if they are missing. - * - * @param string $name - * @param StreamInterface $stream - * @param string $filename - * @param array &$headers - */ - private function prepareHeaders($name, StreamInterface $stream, $filename, array &$headers) - { - $hasFilename = $filename === '0' || $filename; - - // Set a default content-disposition header if one was not provided - if (!$this->hasHeader($headers, 'content-disposition')) { - $headers['Content-Disposition'] = sprintf('form-data; name="%s"', $name); - if ($hasFilename) { - $headers['Content-Disposition'] .= sprintf('; filename="%s"', $this->basename($filename)); - } - } - - // Set a default content-length header if one was not provided - if (!$this->hasHeader($headers, 'content-length')) { - if ($length = $stream->getSize()) { - $headers['Content-Length'] = (string) $length; - } - } - - // Set a default Content-Type if one was not provided - if (!$this->hasHeader($headers, 'content-type') && $hasFilename) { - if ($type = $this->getMimetypeHelper()->getMimetypeFromFilename($filename)) { - $headers['Content-Type'] = $type; - } - } - } - - /** - * Get the headers formatted for the HTTP message. - * - * @param array $headers - * - * @return string - */ - private function getHeaders(array $headers) - { - $str = ''; - foreach ($headers as $key => $value) { - $str .= sprintf("%s: %s\r\n", $key, $value); - } - - return $str; - } - - /** - * Check if header exist. - * - * @param array $headers - * @param string $key case insensitive - * - * @return bool - */ - private function hasHeader(array $headers, $key) - { - $lowercaseHeader = strtolower($key); - foreach ($headers as $k => $v) { - if (strtolower($k) === $lowercaseHeader) { - return true; - } - } - - return false; - } - - /** - * Get the boundary that separates the streams. - * - * @return string - */ - public function getBoundary() - { - if ($this->boundary === null) { - $this->boundary = uniqid('', true); - } - - return $this->boundary; - } - - /** - * @param string $boundary - * - * @return MultipartStreamBuilder - */ - public function setBoundary($boundary) - { - $this->boundary = $boundary; - - return $this; - } - - /** - * @return MimetypeHelper - */ - private function getMimetypeHelper() - { - if ($this->mimetypeHelper === null) { - $this->mimetypeHelper = new ApacheMimetypeHelper(); - } - - return $this->mimetypeHelper; - } - - /** - * If you have custom file extension you may overwrite the default MimetypeHelper with your own. - * - * @param MimetypeHelper $mimetypeHelper - * - * @return MultipartStreamBuilder - */ - public function setMimetypeHelper(MimetypeHelper $mimetypeHelper) - { - $this->mimetypeHelper = $mimetypeHelper; - - return $this; - } - - /** - * Reset and clear all stored data. This allows you to use builder for a subsequent request. - * - * @return MultipartStreamBuilder - */ - public function reset() - { - $this->data = []; - $this->boundary = null; - - return $this; - } - - /** - * Gets the filename from a given path. - * - * PHP's basename() does not properly support streams or filenames beginning with a non-US-ASCII character. - * - * @author Drupal 8.2 - * - * @param string $path - * - * @return string - */ - private function basename($path) - { - $separators = '/'; - if (DIRECTORY_SEPARATOR != '/') { - // For Windows OS add special separator. - $separators .= DIRECTORY_SEPARATOR; - } - - // Remove right-most slashes when $path points to directory. - $path = rtrim($path, $separators); - - // Returns the trailing part of the $path starting after one of the directory separators. - $filename = preg_match('@[^'.preg_quote($separators, '@').']+$@', $path, $matches) ? $matches[0] : ''; - - return $filename; - } -} diff --git a/vendor/php-http/promise/CHANGELOG.md b/vendor/php-http/promise/CHANGELOG.md deleted file mode 100755 index 336e140995bd8d0ff716cd383d4c19c2c5a5087b..0000000000000000000000000000000000000000 --- a/vendor/php-http/promise/CHANGELOG.md +++ /dev/null @@ -1,35 +0,0 @@ -# Change Log - - -## 1.0.0 - 2016-01-26 - -### Removed - -- PSR-7 dependency - - -## 1.0.0-RC1 - 2016-01-12 - -### Added - -- Tests for full coverage - -## Changed - -- Updated package files -- Clarified wait method behavior -- Contributing guide moved to the documentation - - -## 0.1.1 - 2015-12-24 - -## Added - -- Fulfilled and Rejected promise implementations - - -## 0.1.0 - 2015-12-13 - -## Added - -- Promise interface diff --git a/vendor/php-http/promise/LICENSE b/vendor/php-http/promise/LICENSE deleted file mode 100755 index 4558d6f06306fce15add8bc10e29152bc4ad5355..0000000000000000000000000000000000000000 --- a/vendor/php-http/promise/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015-2016 PHP HTTP Team <team@php-http.org> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/php-http/promise/README.md b/vendor/php-http/promise/README.md deleted file mode 100755 index adda2aeb5d9a7017447171f2f0e6310dd5dd38fe..0000000000000000000000000000000000000000 --- a/vendor/php-http/promise/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# Promise - -[](https://github.com/php-http/promise/releases) -[](LICENSE) -[](https://travis-ci.org/php-http/promise) -[](https://scrutinizer-ci.com/g/php-http/promise) -[](https://scrutinizer-ci.com/g/php-http/promise) -[](https://packagist.org/packages/php-http/promise) - -**Promise used for asynchronous HTTP requests.** - -**Note:** This will eventually be removed/deprecated and replaced with the upcoming Promise PSR. - - -## Install - -Via Composer - -``` bash -$ composer require php-http/promise -``` - - -## Documentation - -Please see the [official documentation](http://docs.php-http.org). - - -## Testing - -``` bash -$ composer test -``` - - -## Contributing - -Please see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html). - - -## Security - -If you discover any security related issues, please contact us at [security@httplug.io](mailto:security@httplug.io) -or [security@php-http.org](mailto:security@php-http.org). - - -## License - -The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/vendor/php-http/promise/composer.json b/vendor/php-http/promise/composer.json deleted file mode 100755 index ff1d2cee3b2b99fc68f3140e85e342fb564146af..0000000000000000000000000000000000000000 --- a/vendor/php-http/promise/composer.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "php-http/promise", - "description": "Promise used for asynchronous HTTP requests", - "license": "MIT", - "keywords": ["promise"], - "homepage": "http://httplug.io", - "authors": [ - { - "name": "Joel Wurtz", - "email": "joel.wurtz@gmail.com" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - } - ], - "require-dev": { - "phpspec/phpspec": "^2.4", - "henrikbjorn/phpspec-code-coverage" : "^1.0" - }, - "autoload": { - "psr-4": { - "Http\\Promise\\": "src/" - } - }, - "scripts": { - "test": "vendor/bin/phpspec run", - "test-ci": "vendor/bin/phpspec run -c phpspec.yml.ci" - }, - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - } -} diff --git a/vendor/php-http/promise/src/FulfilledPromise.php b/vendor/php-http/promise/src/FulfilledPromise.php deleted file mode 100755 index f60f686a2145fe975e92d0a138cabdcf09b68e82..0000000000000000000000000000000000000000 --- a/vendor/php-http/promise/src/FulfilledPromise.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php - -namespace Http\Promise; - -/** - * A promise already fulfilled. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class FulfilledPromise implements Promise -{ - /** - * @var mixed - */ - private $result; - - /** - * @param $result - */ - public function __construct($result) - { - $this->result = $result; - } - - /** - * {@inheritdoc} - */ - public function then(callable $onFulfilled = null, callable $onRejected = null) - { - if (null === $onFulfilled) { - return $this; - } - - try { - return new self($onFulfilled($this->result)); - } catch (\Exception $e) { - return new RejectedPromise($e); - } - } - - /** - * {@inheritdoc} - */ - public function getState() - { - return Promise::FULFILLED; - } - - /** - * {@inheritdoc} - */ - public function wait($unwrap = true) - { - if ($unwrap) { - return $this->result; - } - } -} diff --git a/vendor/php-http/promise/src/Promise.php b/vendor/php-http/promise/src/Promise.php deleted file mode 100755 index e2cf5f89e40bf4bf40406d78d596d8715065c148..0000000000000000000000000000000000000000 --- a/vendor/php-http/promise/src/Promise.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php - -namespace Http\Promise; - -/** - * Promise represents a value that may not be available yet, but will be resolved at some point in future. - * It acts like a proxy to the actual value. - * - * This interface is an extension of the promises/a+ specification. - * - * @see https://promisesaplus.com/ - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> - */ -interface Promise -{ - /** - * Promise has not been fulfilled or rejected. - */ - const PENDING = 'pending'; - - /** - * Promise has been fulfilled. - */ - const FULFILLED = 'fulfilled'; - - /** - * Promise has been rejected. - */ - const REJECTED = 'rejected'; - - /** - * Adds behavior for when the promise is resolved or rejected (response will be available, or error happens). - * - * If you do not care about one of the cases, you can set the corresponding callable to null - * The callback will be called when the value arrived and never more than once. - * - * @param callable $onFulfilled Called when a response will be available. - * @param callable $onRejected Called when an exception occurs. - * - * @return Promise A new resolved promise with value of the executed callback (onFulfilled / onRejected). - */ - public function then(callable $onFulfilled = null, callable $onRejected = null); - - /** - * Returns the state of the promise, one of PENDING, FULFILLED or REJECTED. - * - * @return string - */ - public function getState(); - - /** - * Wait for the promise to be fulfilled or rejected. - * - * When this method returns, the request has been resolved and if callables have been - * specified, the appropriate one has terminated. - * - * When $unwrap is true (the default), the response is returned, or the exception thrown - * on failure. Otherwise, nothing is returned or thrown. - * - * @param bool $unwrap Whether to return resolved value / throw reason or not - * - * @return mixed Resolved value, null if $unwrap is set to false - * - * @throws \Exception The rejection reason if $unwrap is set to true and the request failed. - */ - public function wait($unwrap = true); -} diff --git a/vendor/php-http/promise/src/RejectedPromise.php b/vendor/php-http/promise/src/RejectedPromise.php deleted file mode 100755 index e396a40f7324073c4b88e15dc93022485e770847..0000000000000000000000000000000000000000 --- a/vendor/php-http/promise/src/RejectedPromise.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php - -namespace Http\Promise; - -/** - * A rejected promise. - * - * @author Joel Wurtz <joel.wurtz@gmail.com> - */ -final class RejectedPromise implements Promise -{ - /** - * @var \Exception - */ - private $exception; - - /** - * @param \Exception $exception - */ - public function __construct(\Exception $exception) - { - $this->exception = $exception; - } - - /** - * {@inheritdoc} - */ - public function then(callable $onFulfilled = null, callable $onRejected = null) - { - if (null === $onRejected) { - return $this; - } - - try { - return new FulfilledPromise($onRejected($this->exception)); - } catch (\Exception $e) { - return new self($e); - } - } - - /** - * {@inheritdoc} - */ - public function getState() - { - return Promise::REJECTED; - } - - /** - * {@inheritdoc} - */ - public function wait($unwrap = true) - { - if ($unwrap) { - throw $this->exception; - } - } -} diff --git a/vendor/phpseclib/phpseclib/AUTHORS b/vendor/phpseclib/phpseclib/AUTHORS deleted file mode 100755 index a08b3099c06c5dba585fef78519bc6337e37dcba..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/AUTHORS +++ /dev/null @@ -1,6 +0,0 @@ -phpseclib Lead Developer: TerraFrost (Jim Wigginton) - -phpseclib Developers: monnerat (Patrick Monnerat) - bantu (Andreas Fischer) - petrich (Hans-Jürgen Petrich) - GrahamCampbell (Graham Campbell) diff --git a/vendor/phpseclib/phpseclib/LICENSE b/vendor/phpseclib/phpseclib/LICENSE deleted file mode 100755 index a8ec8ebd4062ee1d6866d823385258d6ccfed48b..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -Copyright 2007-2016 TerraFrost and other contributors -http://phpseclib.sourceforge.net/ - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/phpseclib/phpseclib/README.md b/vendor/phpseclib/phpseclib/README.md deleted file mode 100755 index ecda5a6a7f9fde8a776b4eff4596cde750ab6691..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/README.md +++ /dev/null @@ -1,65 +0,0 @@ -# phpseclib - PHP Secure Communications Library - -[](https://travis-ci.org/phpseclib/phpseclib) - -MIT-licensed pure-PHP implementations of an arbitrary-precision integer -arithmetic library, fully PKCS#1 (v2.1) compliant RSA, DES, 3DES, RC4, Rijndael, -AES, Blowfish, Twofish, SSH-1, SSH-2, SFTP, and X.509 - -* [Download (1.0.1)](http://sourceforge.net/projects/phpseclib/files/phpseclib1.0.1.zip/download) -* [Browse Git](https://github.com/phpseclib/phpseclib) -* [Code Coverage Report](http://phpseclib.bantux.org/code_coverage/2.0/latest/) - -<img src="http://phpseclib.sourceforge.net/pear-icon.png" alt="PEAR Channel" width="16" height="16"> -PEAR Channel: [phpseclib.sourceforge.net](http://phpseclib.sourceforge.net/pear.htm) - -## Documentation - -* [Documentation / Manual](http://phpseclib.sourceforge.net/) -* [API Documentation](http://phpseclib.bantux.org/api/2.0/) (generated by Sami) - -## Support - -Need Support? - -* [Checkout Questions and Answers on Stack Overflow](http://stackoverflow.com/questions/tagged/phpseclib) -* [Create a Support Ticket on GitHub](https://github.com/phpseclib/phpseclib/issues/new) -* [Browse the Support Forum](http://www.frostjedi.com/phpbb/viewforum.php?f=46) (no longer in use) - -## Installing Development Dependencies - -Dependencies are managed via Composer. - -1. Download the [`composer.phar`](https://getcomposer.org/composer.phar) executable as per the - [Composer Download Instructions](https://getcomposer.org/download/), e.g. by running - - ``` sh - curl -sS https://getcomposer.org/installer | php - ``` - -2. Install Dependencies - - ``` sh - php composer.phar install - ``` - -## Contributing - -1. Fork the Project - -2. Install Development Dependencies - -3. Create a Feature Branch - -4. (Recommended) Run the Test Suite - - ``` sh - vendor/bin/phpunit - ``` -5. (Recommended) Check whether your code conforms to our Coding Standards by running - - ``` sh - vendor/bin/phing -f build/build.xml sniff - ``` - -6. Send us a Pull Request diff --git a/vendor/phpseclib/phpseclib/composer.json b/vendor/phpseclib/phpseclib/composer.json deleted file mode 100755 index 10315f3a8a2d7ec417f48bea908b479ebb6a5979..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/composer.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "phpseclib/phpseclib", - "type": "library", - "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", - "keywords": [ - "security", - "crypto", - "cryptography", - "encryption", - "signature", - "signing", - "rsa", - "aes", - "blowfish", - "twofish", - "ssh", - "sftp", - "x509", - "x.509", - "asn1", - "asn.1", - "BigInteger" - ], - "homepage": "http://phpseclib.sourceforge.net", - "license": "MIT", - "authors": [ - { - "name": "Jim Wigginton", - "email": "terrafrost@php.net", - "role": "Lead Developer" - }, - { - "name": "Patrick Monnerat", - "email": "pm@datasphere.ch", - "role": "Developer" - }, - { - "name": "Andreas Fischer", - "email": "bantu@phpbb.com", - "role": "Developer" - }, - { - "name": "Hans-Jürgen Petrich", - "email": "petrich@tronic-media.com", - "role": "Developer" - }, - { - "name": "Graham Campbell", - "email": "graham@alt-three.com", - "role": "Developer" - } - ], - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phing/phing": "~2.7", - "phpunit/phpunit": "~4.0", - "sami/sami": "~2.0", - "squizlabs/php_codesniffer": "~2.0" - }, - "suggest": { - "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.", - "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations.", - "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.", - "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations." - }, - "autoload": { - "psr-4": { - "phpseclib\\": "phpseclib/" - } - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/AES.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/AES.php deleted file mode 100755 index 2bb4d5e8f8a9eed75769fa0f8d70b30251aeaa08..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/AES.php +++ /dev/null @@ -1,128 +0,0 @@ -<?php - -/** - * Pure-PHP implementation of AES. - * - * Uses mcrypt, if available/possible, and an internal implementation, otherwise. - * - * PHP version 5 - * - * NOTE: Since AES.php is (for compatibility and phpseclib-historical reasons) virtually - * just a wrapper to Rijndael.php you may consider using Rijndael.php instead of - * to save one include_once(). - * - * If {@link self::setKeyLength() setKeyLength()} isn't called, it'll be calculated from - * {@link self::setKey() setKey()}. ie. if the key is 128-bits, the key length will be 128-bits. If it's 136-bits - * it'll be null-padded to 192-bits and 192 bits will be the key length until {@link self::setKey() setKey()} - * is called, again, at which point, it'll be recalculated. - * - * Since \phpseclib\Crypt\AES extends \phpseclib\Crypt\Rijndael, some functions are available to be called that, in the context of AES, don't - * make a whole lot of sense. {@link self::setBlockLength() setBlockLength()}, for instance. Calling that function, - * however possible, won't do anything (AES has a fixed block length whereas Rijndael has a variable one). - * - * Here's a short example of how to use this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $aes = new \phpseclib\Crypt\AES(); - * - * $aes->setKey('abcdefghijklmnop'); - * - * $size = 10 * 1024; - * $plaintext = ''; - * for ($i = 0; $i < $size; $i++) { - * $plaintext.= 'a'; - * } - * - * echo $aes->decrypt($aes->encrypt($plaintext)); - * ?> - * </code> - * - * @category Crypt - * @package AES - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2008 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Crypt; - -use phpseclib\Crypt\Rijndael; - -/** - * Pure-PHP implementation of AES. - * - * @package AES - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class AES extends Rijndael -{ - /** - * Dummy function - * - * Since \phpseclib\Crypt\AES extends \phpseclib\Crypt\Rijndael, this function is, technically, available, but it doesn't do anything. - * - * @see \phpseclib\Crypt\Rijndael::setBlockLength() - * @access public - * @param int $length - */ - function setBlockLength($length) - { - return; - } - - /** - * Sets the key length - * - * Valid key lengths are 128, 192, and 256. If the length is less than 128, it will be rounded up to - * 128. If the length is greater than 128 and invalid, it will be rounded down to the closest valid amount. - * - * @see \phpseclib\Crypt\Rijndael:setKeyLength() - * @access public - * @param int $length - */ - function setKeyLength($length) - { - switch ($length) { - case 160: - $length = 192; - break; - case 224: - $length = 256; - } - parent::setKeyLength($length); - } - - /** - * Sets the key. - * - * Rijndael supports five different key lengths, AES only supports three. - * - * @see \phpseclib\Crypt\Rijndael:setKey() - * @see setKeyLength() - * @access public - * @param string $key - */ - function setKey($key) - { - parent::setKey($key); - - if (!$this->explicit_key_length) { - $length = strlen($key); - switch (true) { - case $length <= 16: - $this->key_length = 16; - break; - case $length <= 24: - $this->key_length = 24; - break; - default: - $this->key_length = 32; - } - $this->_setEngine(); - } - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Base.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Base.php deleted file mode 100755 index e1d0b8b272d57055bbe9bb502031cf0a4d239194..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Base.php +++ /dev/null @@ -1,2549 +0,0 @@ -<?php - -/** - * Base Class for all \phpseclib\Crypt\* cipher classes - * - * PHP version 5 - * - * Internally for phpseclib developers: - * If you plan to add a new cipher class, please note following rules: - * - * - The new \phpseclib\Crypt\* cipher class should extend \phpseclib\Crypt\Base - * - * - Following methods are then required to be overridden/overloaded: - * - * - _encryptBlock() - * - * - _decryptBlock() - * - * - _setupKey() - * - * - All other methods are optional to be overridden/overloaded - * - * - Look at the source code of the current ciphers how they extend \phpseclib\Crypt\Base - * and take one of them as a start up for the new cipher class. - * - * - Please read all the other comments/notes/hints here also for each class var/method - * - * @category Crypt - * @package Base - * @author Jim Wigginton <terrafrost@php.net> - * @author Hans-Juergen Petrich <petrich@tronic-media.com> - * @copyright 2007 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Crypt; - -use phpseclib\Crypt\Hash; - -/** - * Base Class for all \phpseclib\Crypt\* cipher classes - * - * @package Base - * @author Jim Wigginton <terrafrost@php.net> - * @author Hans-Juergen Petrich <petrich@tronic-media.com> - */ -abstract class Base -{ - /**#@+ - * @access public - * @see \phpseclib\Crypt\Base::encrypt() - * @see \phpseclib\Crypt\Base::decrypt() - */ - /** - * Encrypt / decrypt using the Counter mode. - * - * Set to -1 since that's what Crypt/Random.php uses to index the CTR mode. - * - * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Counter_.28CTR.29 - */ - const MODE_CTR = -1; - /** - * Encrypt / decrypt using the Electronic Code Book mode. - * - * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29 - */ - const MODE_ECB = 1; - /** - * Encrypt / decrypt using the Code Book Chaining mode. - * - * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29 - */ - const MODE_CBC = 2; - /** - * Encrypt / decrypt using the Cipher Feedback mode. - * - * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher_feedback_.28CFB.29 - */ - const MODE_CFB = 3; - /** - * Encrypt / decrypt using the Output Feedback mode. - * - * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Output_feedback_.28OFB.29 - */ - const MODE_OFB = 4; - /** - * Encrypt / decrypt using streaming mode. - */ - const MODE_STREAM = 5; - /**#@-*/ - - /** - * Whirlpool available flag - * - * @see \phpseclib\Crypt\Base::_hashInlineCryptFunction() - * @var bool - * @access private - */ - static $WHIRLPOOL_AVAILABLE; - - /**#@+ - * @access private - * @see \phpseclib\Crypt\Base::__construct() - */ - /** - * Base value for the internal implementation $engine switch - */ - const ENGINE_INTERNAL = 1; - /** - * Base value for the mcrypt implementation $engine switch - */ - const ENGINE_MCRYPT = 2; - /** - * Base value for the mcrypt implementation $engine switch - */ - const ENGINE_OPENSSL = 3; - /**#@-*/ - - /** - * The Encryption Mode - * - * @see self::__construct() - * @var int - * @access private - */ - var $mode; - - /** - * The Block Length of the block cipher - * - * @var int - * @access private - */ - var $block_size = 16; - - /** - * The Key - * - * @see self::setKey() - * @var string - * @access private - */ - var $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; - - /** - * The Initialization Vector - * - * @see self::setIV() - * @var string - * @access private - */ - var $iv; - - /** - * A "sliding" Initialization Vector - * - * @see self::enableContinuousBuffer() - * @see self::_clearBuffers() - * @var string - * @access private - */ - var $encryptIV; - - /** - * A "sliding" Initialization Vector - * - * @see self::enableContinuousBuffer() - * @see self::_clearBuffers() - * @var string - * @access private - */ - var $decryptIV; - - /** - * Continuous Buffer status - * - * @see self::enableContinuousBuffer() - * @var bool - * @access private - */ - var $continuousBuffer = false; - - /** - * Encryption buffer for CTR, OFB and CFB modes - * - * @see self::encrypt() - * @see self::_clearBuffers() - * @var array - * @access private - */ - var $enbuffer; - - /** - * Decryption buffer for CTR, OFB and CFB modes - * - * @see self::decrypt() - * @see self::_clearBuffers() - * @var array - * @access private - */ - var $debuffer; - - /** - * mcrypt resource for encryption - * - * The mcrypt resource can be recreated every time something needs to be created or it can be created just once. - * Since mcrypt operates in continuous mode, by default, it'll need to be recreated when in non-continuous mode. - * - * @see self::encrypt() - * @var resource - * @access private - */ - var $enmcrypt; - - /** - * mcrypt resource for decryption - * - * The mcrypt resource can be recreated every time something needs to be created or it can be created just once. - * Since mcrypt operates in continuous mode, by default, it'll need to be recreated when in non-continuous mode. - * - * @see self::decrypt() - * @var resource - * @access private - */ - var $demcrypt; - - /** - * Does the enmcrypt resource need to be (re)initialized? - * - * @see \phpseclib\Crypt\Twofish::setKey() - * @see \phpseclib\Crypt\Twofish::setIV() - * @var bool - * @access private - */ - var $enchanged = true; - - /** - * Does the demcrypt resource need to be (re)initialized? - * - * @see \phpseclib\Crypt\Twofish::setKey() - * @see \phpseclib\Crypt\Twofish::setIV() - * @var bool - * @access private - */ - var $dechanged = true; - - /** - * mcrypt resource for CFB mode - * - * mcrypt's CFB mode, in (and only in) buffered context, - * is broken, so phpseclib implements the CFB mode by it self, - * even when the mcrypt php extension is available. - * - * In order to do the CFB-mode work (fast) phpseclib - * use a separate ECB-mode mcrypt resource. - * - * @link http://phpseclib.sourceforge.net/cfb-demo.phps - * @see self::encrypt() - * @see self::decrypt() - * @see self::_setupMcrypt() - * @var resource - * @access private - */ - var $ecb; - - /** - * Optimizing value while CFB-encrypting - * - * Only relevant if $continuousBuffer enabled - * and $engine == self::ENGINE_MCRYPT - * - * It's faster to re-init $enmcrypt if - * $buffer bytes > $cfb_init_len than - * using the $ecb resource furthermore. - * - * This value depends of the chosen cipher - * and the time it would be needed for it's - * initialization [by mcrypt_generic_init()] - * which, typically, depends on the complexity - * on its internaly Key-expanding algorithm. - * - * @see self::encrypt() - * @var int - * @access private - */ - var $cfb_init_len = 600; - - /** - * Does internal cipher state need to be (re)initialized? - * - * @see self::setKey() - * @see self::setIV() - * @see self::disableContinuousBuffer() - * @var bool - * @access private - */ - var $changed = true; - - /** - * Padding status - * - * @see self::enablePadding() - * @var bool - * @access private - */ - var $padding = true; - - /** - * Is the mode one that is paddable? - * - * @see self::__construct() - * @var bool - * @access private - */ - var $paddable = false; - - /** - * Holds which crypt engine internaly should be use, - * which will be determined automatically on __construct() - * - * Currently available $engines are: - * - self::ENGINE_OPENSSL (very fast, php-extension: openssl, extension_loaded('openssl') required) - * - self::ENGINE_MCRYPT (fast, php-extension: mcrypt, extension_loaded('mcrypt') required) - * - self::ENGINE_INTERNAL (slower, pure php-engine, no php-extension required) - * - * @see self::_setEngine() - * @see self::encrypt() - * @see self::decrypt() - * @var int - * @access private - */ - var $engine; - - /** - * Holds the preferred crypt engine - * - * @see self::_setEngine() - * @see self::setPreferredEngine() - * @var int - * @access private - */ - var $preferredEngine; - - /** - * The mcrypt specific name of the cipher - * - * Only used if $engine == self::ENGINE_MCRYPT - * - * @link http://www.php.net/mcrypt_module_open - * @link http://www.php.net/mcrypt_list_algorithms - * @see self::_setupMcrypt() - * @var string - * @access private - */ - var $cipher_name_mcrypt; - - /** - * The openssl specific name of the cipher - * - * Only used if $engine == self::ENGINE_OPENSSL - * - * @link http://www.php.net/openssl-get-cipher-methods - * @var string - * @access private - */ - var $cipher_name_openssl; - - /** - * The openssl specific name of the cipher in ECB mode - * - * If OpenSSL does not support the mode we're trying to use (CTR) - * it can still be emulated with ECB mode. - * - * @link http://www.php.net/openssl-get-cipher-methods - * @var string - * @access private - */ - var $cipher_name_openssl_ecb; - - /** - * The default salt used by setPassword() - * - * @see self::setPassword() - * @var string - * @access private - */ - var $password_default_salt = 'phpseclib/salt'; - - /** - * The name of the performance-optimized callback function - * - * Used by encrypt() / decrypt() - * only if $engine == self::ENGINE_INTERNAL - * - * @see self::encrypt() - * @see self::decrypt() - * @see self::_setupInlineCrypt() - * @see self::$use_inline_crypt - * @var Callback - * @access private - */ - var $inline_crypt; - - /** - * Holds whether performance-optimized $inline_crypt() can/should be used. - * - * @see self::encrypt() - * @see self::decrypt() - * @see self::inline_crypt - * @var mixed - * @access private - */ - var $use_inline_crypt; - - /** - * If OpenSSL can be used in ECB but not in CTR we can emulate CTR - * - * @see self::_openssl_ctr_process() - * @var bool - * @access private - */ - var $openssl_emulate_ctr = false; - - /** - * Determines what options are passed to openssl_encrypt/decrypt - * - * @see self::isValidEngine() - * @var mixed - * @access private - */ - var $openssl_options; - - /** - * Has the key length explicitly been set or should it be derived from the key, itself? - * - * @see self::setKeyLength() - * @var bool - * @access private - */ - var $explicit_key_length = false; - - /** - * Don't truncate / null pad key - * - * @see self::_clearBuffers() - * @var bool - * @access private - */ - var $skip_key_adjustment = false; - - /** - * Default Constructor. - * - * Determines whether or not the mcrypt extension should be used. - * - * $mode could be: - * - * - self::MODE_ECB - * - * - self::MODE_CBC - * - * - self::MODE_CTR - * - * - self::MODE_CFB - * - * - self::MODE_OFB - * - * If not explicitly set, self::MODE_CBC will be used. - * - * @param int $mode - * @access public - */ - function __construct($mode = self::MODE_CBC) - { - // $mode dependent settings - switch ($mode) { - case self::MODE_ECB: - $this->paddable = true; - $this->mode = self::MODE_ECB; - break; - case self::MODE_CTR: - case self::MODE_CFB: - case self::MODE_OFB: - case self::MODE_STREAM: - $this->mode = $mode; - break; - case self::MODE_CBC: - default: - $this->paddable = true; - $this->mode = self::MODE_CBC; - } - - $this->_setEngine(); - - // Determining whether inline crypting can be used by the cipher - if ($this->use_inline_crypt !== false && function_exists('create_function')) { - $this->use_inline_crypt = true; - } - } - - /** - * Sets the initialization vector. (optional) - * - * SetIV is not required when self::MODE_ECB (or ie for AES: \phpseclib\Crypt\AES::MODE_ECB) is being used. If not explicitly set, it'll be assumed - * to be all zero's. - * - * @access public - * @param string $iv - * @internal Can be overwritten by a sub class, but does not have to be - */ - function setIV($iv) - { - if ($this->mode == self::MODE_ECB) { - return; - } - - $this->iv = $iv; - $this->changed = true; - } - - /** - * Sets the key length. - * - * Keys with explicitly set lengths need to be treated accordingly - * - * @access public - * @param int $length - */ - function setKeyLength($length) - { - $this->explicit_key_length = true; - $this->changed = true; - $this->_setEngine(); - } - - /** - * Returns the current key length in bits - * - * @access public - * @return int - */ - function getKeyLength() - { - return $this->key_length << 3; - } - - /** - * Returns the current block length in bits - * - * @access public - * @return int - */ - function getBlockLength() - { - return $this->block_size << 3; - } - - /** - * Sets the key. - * - * The min/max length(s) of the key depends on the cipher which is used. - * If the key not fits the length(s) of the cipher it will paded with null bytes - * up to the closest valid key length. If the key is more than max length, - * we trim the excess bits. - * - * If the key is not explicitly set, it'll be assumed to be all null bytes. - * - * @access public - * @param string $key - * @internal Could, but not must, extend by the child Crypt_* class - */ - function setKey($key) - { - if (!$this->explicit_key_length) { - $this->setKeyLength(strlen($key) << 3); - $this->explicit_key_length = false; - } - - $this->key = $key; - $this->changed = true; - $this->_setEngine(); - } - - /** - * Sets the password. - * - * Depending on what $method is set to, setPassword()'s (optional) parameters are as follows: - * {@link http://en.wikipedia.org/wiki/PBKDF2 pbkdf2} or pbkdf1: - * $hash, $salt, $count, $dkLen - * - * Where $hash (default = sha1) currently supports the following hashes: see: Crypt/Hash.php - * - * @see Crypt/Hash.php - * @param string $password - * @param string $method - * @return bool - * @access public - * @internal Could, but not must, extend by the child Crypt_* class - */ - function setPassword($password, $method = 'pbkdf2') - { - $key = ''; - - switch ($method) { - default: // 'pbkdf2' or 'pbkdf1' - $func_args = func_get_args(); - - // Hash function - $hash = isset($func_args[2]) ? $func_args[2] : 'sha1'; - - // WPA and WPA2 use the SSID as the salt - $salt = isset($func_args[3]) ? $func_args[3] : $this->password_default_salt; - - // RFC2898#section-4.2 uses 1,000 iterations by default - // WPA and WPA2 use 4,096. - $count = isset($func_args[4]) ? $func_args[4] : 1000; - - // Keylength - if (isset($func_args[5])) { - $dkLen = $func_args[5]; - } else { - $dkLen = $method == 'pbkdf1' ? 2 * $this->key_length : $this->key_length; - } - - switch (true) { - case $method == 'pbkdf1': - $hashObj = new Hash(); - $hashObj->setHash($hash); - if ($dkLen > $hashObj->getLength()) { - user_error('Derived key too long'); - return false; - } - $t = $password . $salt; - for ($i = 0; $i < $count; ++$i) { - $t = $hashObj->hash($t); - } - $key = substr($t, 0, $dkLen); - - $this->setKey(substr($key, 0, $dkLen >> 1)); - $this->setIV(substr($key, $dkLen >> 1)); - - return true; - // Determining if php[>=5.5.0]'s hash_pbkdf2() function avail- and useable - case !function_exists('hash_pbkdf2'): - case !function_exists('hash_algos'): - case !in_array($hash, hash_algos()): - $i = 1; - while (strlen($key) < $dkLen) { - $hmac = new Hash(); - $hmac->setHash($hash); - $hmac->setKey($password); - $f = $u = $hmac->hash($salt . pack('N', $i++)); - for ($j = 2; $j <= $count; ++$j) { - $u = $hmac->hash($u); - $f^= $u; - } - $key.= $f; - } - $key = substr($key, 0, $dkLen); - break; - default: - $key = hash_pbkdf2($hash, $password, $salt, $count, $dkLen, true); - } - } - - $this->setKey($key); - - return true; - } - - /** - * Encrypts a message. - * - * $plaintext will be padded with additional bytes such that it's length is a multiple of the block size. Other cipher - * implementations may or may not pad in the same manner. Other common approaches to padding and the reasons why it's - * necessary are discussed in the following - * URL: - * - * {@link http://www.di-mgt.com.au/cryptopad.html http://www.di-mgt.com.au/cryptopad.html} - * - * An alternative to padding is to, separately, send the length of the file. This is what SSH, in fact, does. - * strlen($plaintext) will still need to be a multiple of the block size, however, arbitrary values can be added to make it that - * length. - * - * @see self::decrypt() - * @access public - * @param string $plaintext - * @return string $ciphertext - * @internal Could, but not must, extend by the child Crypt_* class - */ - function encrypt($plaintext) - { - if ($this->paddable) { - $plaintext = $this->_pad($plaintext); - } - - if ($this->engine === self::ENGINE_OPENSSL) { - if ($this->changed) { - $this->_clearBuffers(); - $this->changed = false; - } - switch ($this->mode) { - case self::MODE_STREAM: - return openssl_encrypt($plaintext, $this->cipher_name_openssl, $this->key, $this->openssl_options); - case self::MODE_ECB: - $result = openssl_encrypt($plaintext, $this->cipher_name_openssl, $this->key, $this->openssl_options); - return !defined('OPENSSL_RAW_DATA') ? substr($result, 0, -$this->block_size) : $result; - case self::MODE_CBC: - $result = openssl_encrypt($plaintext, $this->cipher_name_openssl, $this->key, $this->openssl_options, $this->encryptIV); - if ($this->continuousBuffer) { - $this->encryptIV = substr($result, -$this->block_size); - } - return !defined('OPENSSL_RAW_DATA') ? substr($result, 0, -$this->block_size) : $result; - case self::MODE_CTR: - return $this->_openssl_ctr_process($plaintext, $this->encryptIV, $this->enbuffer); - case self::MODE_CFB: - // cfb loosely routines inspired by openssl's: - // {@link http://cvs.openssl.org/fileview?f=openssl/crypto/modes/cfb128.c&v=1.3.2.2.2.1} - $ciphertext = ''; - if ($this->continuousBuffer) { - $iv = &$this->encryptIV; - $pos = &$this->enbuffer['pos']; - } else { - $iv = $this->encryptIV; - $pos = 0; - } - $len = strlen($plaintext); - $i = 0; - if ($pos) { - $orig_pos = $pos; - $max = $this->block_size - $pos; - if ($len >= $max) { - $i = $max; - $len-= $max; - $pos = 0; - } else { - $i = $len; - $pos+= $len; - $len = 0; - } - // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize - $ciphertext = substr($iv, $orig_pos) ^ $plaintext; - $iv = substr_replace($iv, $ciphertext, $orig_pos, $i); - $plaintext = substr($plaintext, $i); - } - - $overflow = $len % $this->block_size; - - if ($overflow) { - $ciphertext.= openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $this->block_size), $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv); - $iv = $this->_string_pop($ciphertext, $this->block_size); - - $size = $len - $overflow; - $block = $iv ^ substr($plaintext, -$overflow); - $iv = substr_replace($iv, $block, 0, $overflow); - $ciphertext.= $block; - $pos = $overflow; - } elseif ($len) { - $ciphertext = openssl_encrypt($plaintext, $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv); - $iv = substr($ciphertext, -$this->block_size); - } - - return $ciphertext; - case self::MODE_OFB: - return $this->_openssl_ofb_process($plaintext, $this->encryptIV, $this->enbuffer); - } - } - - if ($this->engine === self::ENGINE_MCRYPT) { - if ($this->changed) { - $this->_setupMcrypt(); - $this->changed = false; - } - if ($this->enchanged) { - mcrypt_generic_init($this->enmcrypt, $this->key, $this->encryptIV); - $this->enchanged = false; - } - - // re: {@link http://phpseclib.sourceforge.net/cfb-demo.phps} - // using mcrypt's default handing of CFB the above would output two different things. using phpseclib's - // rewritten CFB implementation the above outputs the same thing twice. - if ($this->mode == self::MODE_CFB && $this->continuousBuffer) { - $block_size = $this->block_size; - $iv = &$this->encryptIV; - $pos = &$this->enbuffer['pos']; - $len = strlen($plaintext); - $ciphertext = ''; - $i = 0; - if ($pos) { - $orig_pos = $pos; - $max = $block_size - $pos; - if ($len >= $max) { - $i = $max; - $len-= $max; - $pos = 0; - } else { - $i = $len; - $pos+= $len; - $len = 0; - } - $ciphertext = substr($iv, $orig_pos) ^ $plaintext; - $iv = substr_replace($iv, $ciphertext, $orig_pos, $i); - $this->enbuffer['enmcrypt_init'] = true; - } - if ($len >= $block_size) { - if ($this->enbuffer['enmcrypt_init'] === false || $len > $this->cfb_init_len) { - if ($this->enbuffer['enmcrypt_init'] === true) { - mcrypt_generic_init($this->enmcrypt, $this->key, $iv); - $this->enbuffer['enmcrypt_init'] = false; - } - $ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % $block_size)); - $iv = substr($ciphertext, -$block_size); - $len%= $block_size; - } else { - while ($len >= $block_size) { - $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, $block_size); - $ciphertext.= $iv; - $len-= $block_size; - $i+= $block_size; - } - } - } - - if ($len) { - $iv = mcrypt_generic($this->ecb, $iv); - $block = $iv ^ substr($plaintext, -$len); - $iv = substr_replace($iv, $block, 0, $len); - $ciphertext.= $block; - $pos = $len; - } - - return $ciphertext; - } - - $ciphertext = mcrypt_generic($this->enmcrypt, $plaintext); - - if (!$this->continuousBuffer) { - mcrypt_generic_init($this->enmcrypt, $this->key, $this->encryptIV); - } - - return $ciphertext; - } - - if ($this->changed) { - $this->_setup(); - $this->changed = false; - } - if ($this->use_inline_crypt) { - $inline = $this->inline_crypt; - return $inline('encrypt', $this, $plaintext); - } - - $buffer = &$this->enbuffer; - $block_size = $this->block_size; - $ciphertext = ''; - switch ($this->mode) { - case self::MODE_ECB: - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { - $ciphertext.= $this->_encryptBlock(substr($plaintext, $i, $block_size)); - } - break; - case self::MODE_CBC: - $xor = $this->encryptIV; - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { - $block = substr($plaintext, $i, $block_size); - $block = $this->_encryptBlock($block ^ $xor); - $xor = $block; - $ciphertext.= $block; - } - if ($this->continuousBuffer) { - $this->encryptIV = $xor; - } - break; - case self::MODE_CTR: - $xor = $this->encryptIV; - if (strlen($buffer['ciphertext'])) { - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { - $block = substr($plaintext, $i, $block_size); - if (strlen($block) > strlen($buffer['ciphertext'])) { - $buffer['ciphertext'].= $this->_encryptBlock($xor); - } - $this->_increment_str($xor); - $key = $this->_string_shift($buffer['ciphertext'], $block_size); - $ciphertext.= $block ^ $key; - } - } else { - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { - $block = substr($plaintext, $i, $block_size); - $key = $this->_encryptBlock($xor); - $this->_increment_str($xor); - $ciphertext.= $block ^ $key; - } - } - if ($this->continuousBuffer) { - $this->encryptIV = $xor; - if ($start = strlen($plaintext) % $block_size) { - $buffer['ciphertext'] = substr($key, $start) . $buffer['ciphertext']; - } - } - break; - case self::MODE_CFB: - // cfb loosely routines inspired by openssl's: - // {@link http://cvs.openssl.org/fileview?f=openssl/crypto/modes/cfb128.c&v=1.3.2.2.2.1} - if ($this->continuousBuffer) { - $iv = &$this->encryptIV; - $pos = &$buffer['pos']; - } else { - $iv = $this->encryptIV; - $pos = 0; - } - $len = strlen($plaintext); - $i = 0; - if ($pos) { - $orig_pos = $pos; - $max = $block_size - $pos; - if ($len >= $max) { - $i = $max; - $len-= $max; - $pos = 0; - } else { - $i = $len; - $pos+= $len; - $len = 0; - } - // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize - $ciphertext = substr($iv, $orig_pos) ^ $plaintext; - $iv = substr_replace($iv, $ciphertext, $orig_pos, $i); - } - while ($len >= $block_size) { - $iv = $this->_encryptBlock($iv) ^ substr($plaintext, $i, $block_size); - $ciphertext.= $iv; - $len-= $block_size; - $i+= $block_size; - } - if ($len) { - $iv = $this->_encryptBlock($iv); - $block = $iv ^ substr($plaintext, $i); - $iv = substr_replace($iv, $block, 0, $len); - $ciphertext.= $block; - $pos = $len; - } - break; - case self::MODE_OFB: - $xor = $this->encryptIV; - if (strlen($buffer['xor'])) { - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { - $block = substr($plaintext, $i, $block_size); - if (strlen($block) > strlen($buffer['xor'])) { - $xor = $this->_encryptBlock($xor); - $buffer['xor'].= $xor; - } - $key = $this->_string_shift($buffer['xor'], $block_size); - $ciphertext.= $block ^ $key; - } - } else { - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { - $xor = $this->_encryptBlock($xor); - $ciphertext.= substr($plaintext, $i, $block_size) ^ $xor; - } - $key = $xor; - } - if ($this->continuousBuffer) { - $this->encryptIV = $xor; - if ($start = strlen($plaintext) % $block_size) { - $buffer['xor'] = substr($key, $start) . $buffer['xor']; - } - } - break; - case self::MODE_STREAM: - $ciphertext = $this->_encryptBlock($plaintext); - break; - } - - return $ciphertext; - } - - /** - * Decrypts a message. - * - * If strlen($ciphertext) is not a multiple of the block size, null bytes will be added to the end of the string until - * it is. - * - * @see self::encrypt() - * @access public - * @param string $ciphertext - * @return string $plaintext - * @internal Could, but not must, extend by the child Crypt_* class - */ - function decrypt($ciphertext) - { - if ($this->paddable) { - // we pad with chr(0) since that's what mcrypt_generic does. to quote from {@link http://www.php.net/function.mcrypt-generic}: - // "The data is padded with "\0" to make sure the length of the data is n * blocksize." - $ciphertext = str_pad($ciphertext, strlen($ciphertext) + ($this->block_size - strlen($ciphertext) % $this->block_size) % $this->block_size, chr(0)); - } - - if ($this->engine === self::ENGINE_OPENSSL) { - if ($this->changed) { - $this->_clearBuffers(); - $this->changed = false; - } - switch ($this->mode) { - case self::MODE_STREAM: - $plaintext = openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options); - break; - case self::MODE_ECB: - if (!defined('OPENSSL_RAW_DATA')) { - $ciphertext.= openssl_encrypt('', $this->cipher_name_openssl_ecb, $this->key, true); - } - $plaintext = openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options); - break; - case self::MODE_CBC: - if (!defined('OPENSSL_RAW_DATA')) { - $padding = str_repeat(chr($this->block_size), $this->block_size) ^ substr($ciphertext, -$this->block_size); - $ciphertext.= substr(openssl_encrypt($padding, $this->cipher_name_openssl_ecb, $this->key, true), 0, $this->block_size); - } - $plaintext = openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options, $this->decryptIV); - if ($this->continuousBuffer) { - $this->decryptIV = substr($ciphertext, -$this->block_size); - } - break; - case self::MODE_CTR: - $plaintext = $this->_openssl_ctr_process($ciphertext, $this->decryptIV, $this->debuffer); - break; - case self::MODE_CFB: - // cfb loosely routines inspired by openssl's: - // {@link http://cvs.openssl.org/fileview?f=openssl/crypto/modes/cfb128.c&v=1.3.2.2.2.1} - $plaintext = ''; - if ($this->continuousBuffer) { - $iv = &$this->decryptIV; - $pos = &$this->buffer['pos']; - } else { - $iv = $this->decryptIV; - $pos = 0; - } - $len = strlen($ciphertext); - $i = 0; - if ($pos) { - $orig_pos = $pos; - $max = $this->block_size - $pos; - if ($len >= $max) { - $i = $max; - $len-= $max; - $pos = 0; - } else { - $i = $len; - $pos+= $len; - $len = 0; - } - // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $this->blocksize - $plaintext = substr($iv, $orig_pos) ^ $ciphertext; - $iv = substr_replace($iv, substr($ciphertext, 0, $i), $orig_pos, $i); - $ciphertext = substr($ciphertext, $i); - } - $overflow = $len % $this->block_size; - if ($overflow) { - $plaintext.= openssl_decrypt(substr($ciphertext, 0, -$overflow), $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv); - if ($len - $overflow) { - $iv = substr($ciphertext, -$overflow - $this->block_size, -$overflow); - } - $iv = openssl_encrypt(str_repeat("\0", $this->block_size), $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv); - $plaintext.= $iv ^ substr($ciphertext, -$overflow); - $iv = substr_replace($iv, substr($ciphertext, -$overflow), 0, $overflow); - $pos = $overflow; - } elseif ($len) { - $plaintext.= openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, $this->openssl_options, $iv); - $iv = substr($ciphertext, -$this->block_size); - } - break; - case self::MODE_OFB: - $plaintext = $this->_openssl_ofb_process($ciphertext, $this->decryptIV, $this->debuffer); - } - - return $this->paddable ? $this->_unpad($plaintext) : $plaintext; - } - - if ($this->engine === self::ENGINE_MCRYPT) { - $block_size = $this->block_size; - if ($this->changed) { - $this->_setupMcrypt(); - $this->changed = false; - } - if ($this->dechanged) { - mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV); - $this->dechanged = false; - } - - if ($this->mode == self::MODE_CFB && $this->continuousBuffer) { - $iv = &$this->decryptIV; - $pos = &$this->debuffer['pos']; - $len = strlen($ciphertext); - $plaintext = ''; - $i = 0; - if ($pos) { - $orig_pos = $pos; - $max = $block_size - $pos; - if ($len >= $max) { - $i = $max; - $len-= $max; - $pos = 0; - } else { - $i = $len; - $pos+= $len; - $len = 0; - } - // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize - $plaintext = substr($iv, $orig_pos) ^ $ciphertext; - $iv = substr_replace($iv, substr($ciphertext, 0, $i), $orig_pos, $i); - } - if ($len >= $block_size) { - $cb = substr($ciphertext, $i, $len - $len % $block_size); - $plaintext.= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb; - $iv = substr($cb, -$block_size); - $len%= $block_size; - } - if ($len) { - $iv = mcrypt_generic($this->ecb, $iv); - $plaintext.= $iv ^ substr($ciphertext, -$len); - $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len); - $pos = $len; - } - - return $plaintext; - } - - $plaintext = mdecrypt_generic($this->demcrypt, $ciphertext); - - if (!$this->continuousBuffer) { - mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV); - } - - return $this->paddable ? $this->_unpad($plaintext) : $plaintext; - } - - if ($this->changed) { - $this->_setup(); - $this->changed = false; - } - if ($this->use_inline_crypt) { - $inline = $this->inline_crypt; - return $inline('decrypt', $this, $ciphertext); - } - - $block_size = $this->block_size; - - $buffer = &$this->debuffer; - $plaintext = ''; - switch ($this->mode) { - case self::MODE_ECB: - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { - $plaintext.= $this->_decryptBlock(substr($ciphertext, $i, $block_size)); - } - break; - case self::MODE_CBC: - $xor = $this->decryptIV; - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { - $block = substr($ciphertext, $i, $block_size); - $plaintext.= $this->_decryptBlock($block) ^ $xor; - $xor = $block; - } - if ($this->continuousBuffer) { - $this->decryptIV = $xor; - } - break; - case self::MODE_CTR: - $xor = $this->decryptIV; - if (strlen($buffer['ciphertext'])) { - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { - $block = substr($ciphertext, $i, $block_size); - if (strlen($block) > strlen($buffer['ciphertext'])) { - $buffer['ciphertext'].= $this->_encryptBlock($xor); - $this->_increment_str($xor); - } - $key = $this->_string_shift($buffer['ciphertext'], $block_size); - $plaintext.= $block ^ $key; - } - } else { - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { - $block = substr($ciphertext, $i, $block_size); - $key = $this->_encryptBlock($xor); - $this->_increment_str($xor); - $plaintext.= $block ^ $key; - } - } - if ($this->continuousBuffer) { - $this->decryptIV = $xor; - if ($start = strlen($ciphertext) % $block_size) { - $buffer['ciphertext'] = substr($key, $start) . $buffer['ciphertext']; - } - } - break; - case self::MODE_CFB: - if ($this->continuousBuffer) { - $iv = &$this->decryptIV; - $pos = &$buffer['pos']; - } else { - $iv = $this->decryptIV; - $pos = 0; - } - $len = strlen($ciphertext); - $i = 0; - if ($pos) { - $orig_pos = $pos; - $max = $block_size - $pos; - if ($len >= $max) { - $i = $max; - $len-= $max; - $pos = 0; - } else { - $i = $len; - $pos+= $len; - $len = 0; - } - // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize - $plaintext = substr($iv, $orig_pos) ^ $ciphertext; - $iv = substr_replace($iv, substr($ciphertext, 0, $i), $orig_pos, $i); - } - while ($len >= $block_size) { - $iv = $this->_encryptBlock($iv); - $cb = substr($ciphertext, $i, $block_size); - $plaintext.= $iv ^ $cb; - $iv = $cb; - $len-= $block_size; - $i+= $block_size; - } - if ($len) { - $iv = $this->_encryptBlock($iv); - $plaintext.= $iv ^ substr($ciphertext, $i); - $iv = substr_replace($iv, substr($ciphertext, $i), 0, $len); - $pos = $len; - } - break; - case self::MODE_OFB: - $xor = $this->decryptIV; - if (strlen($buffer['xor'])) { - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { - $block = substr($ciphertext, $i, $block_size); - if (strlen($block) > strlen($buffer['xor'])) { - $xor = $this->_encryptBlock($xor); - $buffer['xor'].= $xor; - } - $key = $this->_string_shift($buffer['xor'], $block_size); - $plaintext.= $block ^ $key; - } - } else { - for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) { - $xor = $this->_encryptBlock($xor); - $plaintext.= substr($ciphertext, $i, $block_size) ^ $xor; - } - $key = $xor; - } - if ($this->continuousBuffer) { - $this->decryptIV = $xor; - if ($start = strlen($ciphertext) % $block_size) { - $buffer['xor'] = substr($key, $start) . $buffer['xor']; - } - } - break; - case self::MODE_STREAM: - $plaintext = $this->_decryptBlock($ciphertext); - break; - } - return $this->paddable ? $this->_unpad($plaintext) : $plaintext; - } - - /** - * OpenSSL CTR Processor - * - * PHP's OpenSSL bindings do not operate in continuous mode so we'll wrap around it. Since the keystream - * for CTR is the same for both encrypting and decrypting this function is re-used by both Base::encrypt() - * and Base::decrypt(). Also, OpenSSL doesn't implement CTR for all of it's symmetric ciphers so this - * function will emulate CTR with ECB when necesary. - * - * @see self::encrypt() - * @see self::decrypt() - * @param string $plaintext - * @param string $encryptIV - * @param array $buffer - * @return string - * @access private - */ - function _openssl_ctr_process($plaintext, &$encryptIV, &$buffer) - { - $ciphertext = ''; - - $block_size = $this->block_size; - $key = $this->key; - - if ($this->openssl_emulate_ctr) { - $xor = $encryptIV; - if (strlen($buffer['ciphertext'])) { - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { - $block = substr($plaintext, $i, $block_size); - if (strlen($block) > strlen($buffer['ciphertext'])) { - $result = openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, $this->openssl_options); - $result = !defined('OPENSSL_RAW_DATA') ? substr($result, 0, -$this->block_size) : $result; - $buffer['ciphertext'].= $result; - } - $this->_increment_str($xor); - $otp = $this->_string_shift($buffer['ciphertext'], $block_size); - $ciphertext.= $block ^ $otp; - } - } else { - for ($i = 0; $i < strlen($plaintext); $i+=$block_size) { - $block = substr($plaintext, $i, $block_size); - $otp = openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, $this->openssl_options); - $otp = !defined('OPENSSL_RAW_DATA') ? substr($otp, 0, -$this->block_size) : $otp; - $this->_increment_str($xor); - $ciphertext.= $block ^ $otp; - } - } - if ($this->continuousBuffer) { - $encryptIV = $xor; - if ($start = strlen($plaintext) % $block_size) { - $buffer['ciphertext'] = substr($key, $start) . $buffer['ciphertext']; - } - } - - return $ciphertext; - } - - if (strlen($buffer['ciphertext'])) { - $ciphertext = $plaintext ^ $this->_string_shift($buffer['ciphertext'], strlen($plaintext)); - $plaintext = substr($plaintext, strlen($ciphertext)); - - if (!strlen($plaintext)) { - return $ciphertext; - } - } - - $overflow = strlen($plaintext) % $block_size; - if ($overflow) { - $plaintext2 = $this->_string_pop($plaintext, $overflow); // ie. trim $plaintext to a multiple of $block_size and put rest of $plaintext in $plaintext2 - $encrypted = openssl_encrypt($plaintext . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, $this->openssl_options, $encryptIV); - $temp = $this->_string_pop($encrypted, $block_size); - $ciphertext.= $encrypted . ($plaintext2 ^ $temp); - if ($this->continuousBuffer) { - $buffer['ciphertext'] = substr($temp, $overflow); - $encryptIV = $temp; - } - } elseif (!strlen($buffer['ciphertext'])) { - $ciphertext.= openssl_encrypt($plaintext . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, $this->openssl_options, $encryptIV); - $temp = $this->_string_pop($ciphertext, $block_size); - if ($this->continuousBuffer) { - $encryptIV = $temp; - } - } - if ($this->continuousBuffer) { - if (!defined('OPENSSL_RAW_DATA')) { - $encryptIV.= openssl_encrypt('', $this->cipher_name_openssl_ecb, $key, $this->openssl_options); - } - $encryptIV = openssl_decrypt($encryptIV, $this->cipher_name_openssl_ecb, $key, $this->openssl_options); - if ($overflow) { - $this->_increment_str($encryptIV); - } - } - - return $ciphertext; - } - - /** - * OpenSSL OFB Processor - * - * PHP's OpenSSL bindings do not operate in continuous mode so we'll wrap around it. Since the keystream - * for OFB is the same for both encrypting and decrypting this function is re-used by both Base::encrypt() - * and Base::decrypt(). - * - * @see self::encrypt() - * @see self::decrypt() - * @param string $plaintext - * @param string $encryptIV - * @param array $buffer - * @return string - * @access private - */ - function _openssl_ofb_process($plaintext, &$encryptIV, &$buffer) - { - if (strlen($buffer['xor'])) { - $ciphertext = $plaintext ^ $buffer['xor']; - $buffer['xor'] = substr($buffer['xor'], strlen($ciphertext)); - $plaintext = substr($plaintext, strlen($ciphertext)); - } else { - $ciphertext = ''; - } - - $block_size = $this->block_size; - - $len = strlen($plaintext); - $key = $this->key; - $overflow = $len % $block_size; - - if (strlen($plaintext)) { - if ($overflow) { - $ciphertext.= openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, $this->openssl_options, $encryptIV); - $xor = $this->_string_pop($ciphertext, $block_size); - if ($this->continuousBuffer) { - $encryptIV = $xor; - } - $ciphertext.= $this->_string_shift($xor, $overflow) ^ substr($plaintext, -$overflow); - if ($this->continuousBuffer) { - $buffer['xor'] = $xor; - } - } else { - $ciphertext = openssl_encrypt($plaintext, $this->cipher_name_openssl, $key, $this->openssl_options, $encryptIV); - if ($this->continuousBuffer) { - $encryptIV = substr($ciphertext, -$block_size) ^ substr($plaintext, -$block_size); - } - } - } - - return $ciphertext; - } - - /** - * phpseclib <-> OpenSSL Mode Mapper - * - * May need to be overwritten by classes extending this one in some cases - * - * @return int - * @access private - */ - function _openssl_translate_mode() - { - switch ($this->mode) { - case self::MODE_ECB: - return 'ecb'; - case self::MODE_CBC: - return 'cbc'; - case self::MODE_CTR: - return 'ctr'; - case self::MODE_CFB: - return 'cfb'; - case self::MODE_OFB: - return 'ofb'; - } - } - - /** - * Pad "packets". - * - * Block ciphers working by encrypting between their specified [$this->]block_size at a time - * If you ever need to encrypt or decrypt something that isn't of the proper length, it becomes necessary to - * pad the input so that it is of the proper length. - * - * Padding is enabled by default. Sometimes, however, it is undesirable to pad strings. Such is the case in SSH, - * where "packets" are padded with random bytes before being encrypted. Unpad these packets and you risk stripping - * away characters that shouldn't be stripped away. (SSH knows how many bytes are added because the length is - * transmitted separately) - * - * @see self::disablePadding() - * @access public - */ - function enablePadding() - { - $this->padding = true; - } - - /** - * Do not pad packets. - * - * @see self::enablePadding() - * @access public - */ - function disablePadding() - { - $this->padding = false; - } - - /** - * Treat consecutive "packets" as if they are a continuous buffer. - * - * Say you have a 32-byte plaintext $plaintext. Using the default behavior, the two following code snippets - * will yield different outputs: - * - * <code> - * echo $rijndael->encrypt(substr($plaintext, 0, 16)); - * echo $rijndael->encrypt(substr($plaintext, 16, 16)); - * </code> - * <code> - * echo $rijndael->encrypt($plaintext); - * </code> - * - * The solution is to enable the continuous buffer. Although this will resolve the above discrepancy, it creates - * another, as demonstrated with the following: - * - * <code> - * $rijndael->encrypt(substr($plaintext, 0, 16)); - * echo $rijndael->decrypt($rijndael->encrypt(substr($plaintext, 16, 16))); - * </code> - * <code> - * echo $rijndael->decrypt($rijndael->encrypt(substr($plaintext, 16, 16))); - * </code> - * - * With the continuous buffer disabled, these would yield the same output. With it enabled, they yield different - * outputs. The reason is due to the fact that the initialization vector's change after every encryption / - * decryption round when the continuous buffer is enabled. When it's disabled, they remain constant. - * - * Put another way, when the continuous buffer is enabled, the state of the \phpseclib\Crypt\*() object changes after each - * encryption / decryption round, whereas otherwise, it'd remain constant. For this reason, it's recommended that - * continuous buffers not be used. They do offer better security and are, in fact, sometimes required (SSH uses them), - * however, they are also less intuitive and more likely to cause you problems. - * - * @see self::disableContinuousBuffer() - * @access public - * @internal Could, but not must, extend by the child Crypt_* class - */ - function enableContinuousBuffer() - { - if ($this->mode == self::MODE_ECB) { - return; - } - - $this->continuousBuffer = true; - - $this->_setEngine(); - } - - /** - * Treat consecutive packets as if they are a discontinuous buffer. - * - * The default behavior. - * - * @see self::enableContinuousBuffer() - * @access public - * @internal Could, but not must, extend by the child Crypt_* class - */ - function disableContinuousBuffer() - { - if ($this->mode == self::MODE_ECB) { - return; - } - if (!$this->continuousBuffer) { - return; - } - - $this->continuousBuffer = false; - $this->changed = true; - - $this->_setEngine(); - } - - /** - * Test for engine validity - * - * @see self::__construct() - * @param int $engine - * @access public - * @return bool - */ - function isValidEngine($engine) - { - switch ($engine) { - case self::ENGINE_OPENSSL: - if ($this->mode == self::MODE_STREAM && $this->continuousBuffer) { - return false; - } - $this->openssl_emulate_ctr = false; - $result = $this->cipher_name_openssl && - extension_loaded('openssl') && - // PHP 5.3.0 - 5.3.2 did not let you set IV's - version_compare(PHP_VERSION, '5.3.3', '>='); - if (!$result) { - return false; - } - - // prior to PHP 5.4.0 OPENSSL_RAW_DATA and OPENSSL_ZERO_PADDING were not defined. instead of expecting an integer - // $options openssl_encrypt expected a boolean $raw_data. - if (!defined('OPENSSL_RAW_DATA')) { - $this->openssl_options = true; - } else { - $this->openssl_options = OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING; - } - - $methods = openssl_get_cipher_methods(); - if (in_array($this->cipher_name_openssl, $methods)) { - return true; - } - // not all of openssl's symmetric cipher's support ctr. for those - // that don't we'll emulate it - switch ($this->mode) { - case self::MODE_CTR: - if (in_array($this->cipher_name_openssl_ecb, $methods)) { - $this->openssl_emulate_ctr = true; - return true; - } - } - return false; - case self::ENGINE_MCRYPT: - return $this->cipher_name_mcrypt && - extension_loaded('mcrypt') && - in_array($this->cipher_name_mcrypt, mcrypt_list_algorithms()); - case self::ENGINE_INTERNAL: - return true; - } - - return false; - } - - /** - * Sets the preferred crypt engine - * - * Currently, $engine could be: - * - * - \phpseclib\Crypt\Base::ENGINE_OPENSSL [very fast] - * - * - \phpseclib\Crypt\Base::ENGINE_MCRYPT [fast] - * - * - \phpseclib\Crypt\Base::ENGINE_INTERNAL [slow] - * - * If the preferred crypt engine is not available the fastest available one will be used - * - * @see self::__construct() - * @param int $engine - * @access public - */ - function setPreferredEngine($engine) - { - switch ($engine) { - //case self::ENGINE_OPENSSL; - case self::ENGINE_MCRYPT: - case self::ENGINE_INTERNAL: - $this->preferredEngine = $engine; - break; - default: - $this->preferredEngine = self::ENGINE_OPENSSL; - } - - $this->_setEngine(); - } - - /** - * Returns the engine currently being utilized - * - * @see self::_setEngine() - * @access public - */ - function getEngine() - { - return $this->engine; - } - - /** - * Sets the engine as appropriate - * - * @see self::__construct() - * @access private - */ - function _setEngine() - { - $this->engine = null; - - $candidateEngines = array( - $this->preferredEngine, - self::ENGINE_OPENSSL, - self::ENGINE_MCRYPT - ); - foreach ($candidateEngines as $engine) { - if ($this->isValidEngine($engine)) { - $this->engine = $engine; - break; - } - } - if (!$this->engine) { - $this->engine = self::ENGINE_INTERNAL; - } - - if ($this->engine != self::ENGINE_MCRYPT && $this->enmcrypt) { - // Closing the current mcrypt resource(s). _mcryptSetup() will, if needed, - // (re)open them with the module named in $this->cipher_name_mcrypt - mcrypt_module_close($this->enmcrypt); - mcrypt_module_close($this->demcrypt); - $this->enmcrypt = null; - $this->demcrypt = null; - - if ($this->ecb) { - mcrypt_module_close($this->ecb); - $this->ecb = null; - } - } - - $this->changed = true; - } - - /** - * Encrypts a block - * - * Note: Must be extended by the child \phpseclib\Crypt\* class - * - * @access private - * @param string $in - * @return string - */ - abstract function _encryptBlock($in); - - /** - * Decrypts a block - * - * Note: Must be extended by the child \phpseclib\Crypt\* class - * - * @access private - * @param string $in - * @return string - */ - abstract function _decryptBlock($in); - - /** - * Setup the key (expansion) - * - * Only used if $engine == self::ENGINE_INTERNAL - * - * Note: Must extend by the child \phpseclib\Crypt\* class - * - * @see self::_setup() - * @access private - */ - abstract function _setupKey(); - - /** - * Setup the self::ENGINE_INTERNAL $engine - * - * (re)init, if necessary, the internal cipher $engine and flush all $buffers - * Used (only) if $engine == self::ENGINE_INTERNAL - * - * _setup() will be called each time if $changed === true - * typically this happens when using one or more of following public methods: - * - * - setKey() - * - * - setIV() - * - * - disableContinuousBuffer() - * - * - First run of encrypt() / decrypt() with no init-settings - * - * @see self::setKey() - * @see self::setIV() - * @see self::disableContinuousBuffer() - * @access private - * @internal _setup() is always called before en/decryption. - * @internal Could, but not must, extend by the child Crypt_* class - */ - function _setup() - { - $this->_clearBuffers(); - $this->_setupKey(); - - if ($this->use_inline_crypt) { - $this->_setupInlineCrypt(); - } - } - - /** - * Setup the self::ENGINE_MCRYPT $engine - * - * (re)init, if necessary, the (ext)mcrypt resources and flush all $buffers - * Used (only) if $engine = self::ENGINE_MCRYPT - * - * _setupMcrypt() will be called each time if $changed === true - * typically this happens when using one or more of following public methods: - * - * - setKey() - * - * - setIV() - * - * - disableContinuousBuffer() - * - * - First run of encrypt() / decrypt() - * - * @see self::setKey() - * @see self::setIV() - * @see self::disableContinuousBuffer() - * @access private - * @internal Could, but not must, extend by the child Crypt_* class - */ - function _setupMcrypt() - { - $this->_clearBuffers(); - $this->enchanged = $this->dechanged = true; - - if (!isset($this->enmcrypt)) { - static $mcrypt_modes = array( - self::MODE_CTR => 'ctr', - self::MODE_ECB => MCRYPT_MODE_ECB, - self::MODE_CBC => MCRYPT_MODE_CBC, - self::MODE_CFB => 'ncfb', - self::MODE_OFB => MCRYPT_MODE_NOFB, - self::MODE_STREAM => MCRYPT_MODE_STREAM, - ); - - $this->demcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); - $this->enmcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], ''); - - // we need the $ecb mcrypt resource (only) in MODE_CFB with enableContinuousBuffer() - // to workaround mcrypt's broken ncfb implementation in buffered mode - // see: {@link http://phpseclib.sourceforge.net/cfb-demo.phps} - if ($this->mode == self::MODE_CFB) { - $this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, ''); - } - } // else should mcrypt_generic_deinit be called? - - if ($this->mode == self::MODE_CFB) { - mcrypt_generic_init($this->ecb, $this->key, str_repeat("\0", $this->block_size)); - } - } - - /** - * Pads a string - * - * Pads a string using the RSA PKCS padding standards so that its length is a multiple of the blocksize. - * $this->block_size - (strlen($text) % $this->block_size) bytes are added, each of which is equal to - * chr($this->block_size - (strlen($text) % $this->block_size) - * - * If padding is disabled and $text is not a multiple of the blocksize, the string will be padded regardless - * and padding will, hence forth, be enabled. - * - * @see self::_unpad() - * @param string $text - * @access private - * @return string - */ - function _pad($text) - { - $length = strlen($text); - - if (!$this->padding) { - if ($length % $this->block_size == 0) { - return $text; - } else { - user_error("The plaintext's length ($length) is not a multiple of the block size ({$this->block_size})"); - $this->padding = true; - } - } - - $pad = $this->block_size - ($length % $this->block_size); - - return str_pad($text, $length + $pad, chr($pad)); - } - - /** - * Unpads a string. - * - * If padding is enabled and the reported padding length is invalid the encryption key will be assumed to be wrong - * and false will be returned. - * - * @see self::_pad() - * @param string $text - * @access private - * @return string - */ - function _unpad($text) - { - if (!$this->padding) { - return $text; - } - - $length = ord($text[strlen($text) - 1]); - - if (!$length || $length > $this->block_size) { - return false; - } - - return substr($text, 0, -$length); - } - - /** - * Clears internal buffers - * - * Clearing/resetting the internal buffers is done everytime - * after disableContinuousBuffer() or on cipher $engine (re)init - * ie after setKey() or setIV() - * - * @access public - * @internal Could, but not must, extend by the child Crypt_* class - */ - function _clearBuffers() - { - $this->enbuffer = $this->debuffer = array('ciphertext' => '', 'xor' => '', 'pos' => 0, 'enmcrypt_init' => true); - - // mcrypt's handling of invalid's $iv: - // $this->encryptIV = $this->decryptIV = strlen($this->iv) == $this->block_size ? $this->iv : str_repeat("\0", $this->block_size); - $this->encryptIV = $this->decryptIV = str_pad(substr($this->iv, 0, $this->block_size), $this->block_size, "\0"); - - if (!$this->skip_key_adjustment) { - $this->key = str_pad(substr($this->key, 0, $this->key_length), $this->key_length, "\0"); - } - } - - /** - * String Shift - * - * Inspired by array_shift - * - * @param string $string - * @param int $index - * @access private - * @return string - */ - function _string_shift(&$string, $index = 1) - { - $substr = substr($string, 0, $index); - $string = substr($string, $index); - return $substr; - } - - /** - * String Pop - * - * Inspired by array_pop - * - * @param string $string - * @param int $index - * @access private - * @return string - */ - function _string_pop(&$string, $index = 1) - { - $substr = substr($string, -$index); - $string = substr($string, 0, -$index); - return $substr; - } - - /** - * Increment the current string - * - * @see self::decrypt() - * @see self::encrypt() - * @param string $var - * @access private - */ - function _increment_str(&$var) - { - for ($i = 4; $i <= strlen($var); $i+= 4) { - $temp = substr($var, -$i, 4); - switch ($temp) { - case "\xFF\xFF\xFF\xFF": - $var = substr_replace($var, "\x00\x00\x00\x00", -$i, 4); - break; - case "\x7F\xFF\xFF\xFF": - $var = substr_replace($var, "\x80\x00\x00\x00", -$i, 4); - return; - default: - $temp = unpack('Nnum', $temp); - $var = substr_replace($var, pack('N', $temp['num'] + 1), -$i, 4); - return; - } - } - - $remainder = strlen($var) % 4; - - if ($remainder == 0) { - return; - } - - $temp = unpack('Nnum', str_pad(substr($var, 0, $remainder), 4, "\0", STR_PAD_LEFT)); - $temp = substr(pack('N', $temp['num'] + 1), -$remainder); - $var = substr_replace($var, $temp, 0, $remainder); - } - - /** - * Setup the performance-optimized function for de/encrypt() - * - * Stores the created (or existing) callback function-name - * in $this->inline_crypt - * - * Internally for phpseclib developers: - * - * _setupInlineCrypt() would be called only if: - * - * - $engine == self::ENGINE_INTERNAL and - * - * - $use_inline_crypt === true - * - * - each time on _setup(), after(!) _setupKey() - * - * - * This ensures that _setupInlineCrypt() has always a - * full ready2go initializated internal cipher $engine state - * where, for example, the keys allready expanded, - * keys/block_size calculated and such. - * - * It is, each time if called, the responsibility of _setupInlineCrypt(): - * - * - to set $this->inline_crypt to a valid and fully working callback function - * as a (faster) replacement for encrypt() / decrypt() - * - * - NOT to create unlimited callback functions (for memory reasons!) - * no matter how often _setupInlineCrypt() would be called. At some - * point of amount they must be generic re-useable. - * - * - the code of _setupInlineCrypt() it self, - * and the generated callback code, - * must be, in following order: - * - 100% safe - * - 100% compatible to encrypt()/decrypt() - * - using only php5+ features/lang-constructs/php-extensions if - * compatibility (down to php4) or fallback is provided - * - readable/maintainable/understandable/commented and... not-cryptic-styled-code :-) - * - >= 10% faster than encrypt()/decrypt() [which is, by the way, - * the reason for the existence of _setupInlineCrypt() :-)] - * - memory-nice - * - short (as good as possible) - * - * Note: - _setupInlineCrypt() is using _createInlineCryptFunction() to create the full callback function code. - * - In case of using inline crypting, _setupInlineCrypt() must extend by the child \phpseclib\Crypt\* class. - * - The following variable names are reserved: - * - $_* (all variable names prefixed with an underscore) - * - $self (object reference to it self. Do not use $this, but $self instead) - * - $in (the content of $in has to en/decrypt by the generated code) - * - The callback function should not use the 'return' statement, but en/decrypt'ing the content of $in only - * - * - * @see self::_setup() - * @see self::_createInlineCryptFunction() - * @see self::encrypt() - * @see self::decrypt() - * @access private - * @internal If a Crypt_* class providing inline crypting it must extend _setupInlineCrypt() - */ - function _setupInlineCrypt() - { - // If, for any reason, an extending \phpseclib\Crypt\Base() \phpseclib\Crypt\* class - // not using inline crypting then it must be ensured that: $this->use_inline_crypt = false - // ie in the class var declaration of $use_inline_crypt in general for the \phpseclib\Crypt\* class, - // in the constructor at object instance-time - // or, if it's runtime-specific, at runtime - - $this->use_inline_crypt = false; - } - - /** - * Creates the performance-optimized function for en/decrypt() - * - * Internally for phpseclib developers: - * - * _createInlineCryptFunction(): - * - * - merge the $cipher_code [setup'ed by _setupInlineCrypt()] - * with the current [$this->]mode of operation code - * - * - create the $inline function, which called by encrypt() / decrypt() - * as its replacement to speed up the en/decryption operations. - * - * - return the name of the created $inline callback function - * - * - used to speed up en/decryption - * - * - * - * The main reason why can speed up things [up to 50%] this way are: - * - * - using variables more effective then regular. - * (ie no use of expensive arrays but integers $k_0, $k_1 ... - * or even, for example, the pure $key[] values hardcoded) - * - * - avoiding 1000's of function calls of ie _encryptBlock() - * but inlining the crypt operations. - * in the mode of operation for() loop. - * - * - full loop unroll the (sometimes key-dependent) rounds - * avoiding this way ++$i counters and runtime-if's etc... - * - * The basic code architectur of the generated $inline en/decrypt() - * lambda function, in pseudo php, is: - * - * <code> - * +----------------------------------------------------------------------------------------------+ - * | callback $inline = create_function: | - * | lambda_function_0001_crypt_ECB($action, $text) | - * | { | - * | INSERT PHP CODE OF: | - * | $cipher_code['init_crypt']; // general init code. | - * | // ie: $sbox'es declarations used for | - * | // encrypt and decrypt'ing. | - * | | - * | switch ($action) { | - * | case 'encrypt': | - * | INSERT PHP CODE OF: | - * | $cipher_code['init_encrypt']; // encrypt sepcific init code. | - * | ie: specified $key or $box | - * | declarations for encrypt'ing. | - * | | - * | foreach ($ciphertext) { | - * | $in = $block_size of $ciphertext; | - * | | - * | INSERT PHP CODE OF: | - * | $cipher_code['encrypt_block']; // encrypt's (string) $in, which is always: | - * | // strlen($in) == $this->block_size | - * | // here comes the cipher algorithm in action | - * | // for encryption. | - * | // $cipher_code['encrypt_block'] has to | - * | // encrypt the content of the $in variable | - * | | - * | $plaintext .= $in; | - * | } | - * | return $plaintext; | - * | | - * | case 'decrypt': | - * | INSERT PHP CODE OF: | - * | $cipher_code['init_decrypt']; // decrypt sepcific init code | - * | ie: specified $key or $box | - * | declarations for decrypt'ing. | - * | foreach ($plaintext) { | - * | $in = $block_size of $plaintext; | - * | | - * | INSERT PHP CODE OF: | - * | $cipher_code['decrypt_block']; // decrypt's (string) $in, which is always | - * | // strlen($in) == $this->block_size | - * | // here comes the cipher algorithm in action | - * | // for decryption. | - * | // $cipher_code['decrypt_block'] has to | - * | // decrypt the content of the $in variable | - * | $ciphertext .= $in; | - * | } | - * | return $ciphertext; | - * | } | - * | } | - * +----------------------------------------------------------------------------------------------+ - * </code> - * - * See also the \phpseclib\Crypt\*::_setupInlineCrypt()'s for - * productive inline $cipher_code's how they works. - * - * Structure of: - * <code> - * $cipher_code = array( - * 'init_crypt' => (string) '', // optional - * 'init_encrypt' => (string) '', // optional - * 'init_decrypt' => (string) '', // optional - * 'encrypt_block' => (string) '', // required - * 'decrypt_block' => (string) '' // required - * ); - * </code> - * - * @see self::_setupInlineCrypt() - * @see self::encrypt() - * @see self::decrypt() - * @param array $cipher_code - * @access private - * @return string (the name of the created callback function) - */ - function _createInlineCryptFunction($cipher_code) - { - $block_size = $this->block_size; - - // optional - $init_crypt = isset($cipher_code['init_crypt']) ? $cipher_code['init_crypt'] : ''; - $init_encrypt = isset($cipher_code['init_encrypt']) ? $cipher_code['init_encrypt'] : ''; - $init_decrypt = isset($cipher_code['init_decrypt']) ? $cipher_code['init_decrypt'] : ''; - // required - $encrypt_block = $cipher_code['encrypt_block']; - $decrypt_block = $cipher_code['decrypt_block']; - - // Generating mode of operation inline code, - // merged with the $cipher_code algorithm - // for encrypt- and decryption. - switch ($this->mode) { - case self::MODE_ECB: - $encrypt = $init_encrypt . ' - $_ciphertext = ""; - $_plaintext_len = strlen($_text); - - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { - $in = substr($_text, $_i, '.$block_size.'); - '.$encrypt_block.' - $_ciphertext.= $in; - } - - return $_ciphertext; - '; - - $decrypt = $init_decrypt . ' - $_plaintext = ""; - $_text = str_pad($_text, strlen($_text) + ('.$block_size.' - strlen($_text) % '.$block_size.') % '.$block_size.', chr(0)); - $_ciphertext_len = strlen($_text); - - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { - $in = substr($_text, $_i, '.$block_size.'); - '.$decrypt_block.' - $_plaintext.= $in; - } - - return $self->_unpad($_plaintext); - '; - break; - case self::MODE_CTR: - $encrypt = $init_encrypt . ' - $_ciphertext = ""; - $_plaintext_len = strlen($_text); - $_xor = $self->encryptIV; - $_buffer = &$self->enbuffer; - if (strlen($_buffer["ciphertext"])) { - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { - $_block = substr($_text, $_i, '.$block_size.'); - if (strlen($_block) > strlen($_buffer["ciphertext"])) { - $in = $_xor; - '.$encrypt_block.' - $self->_increment_str($_xor); - $_buffer["ciphertext"].= $in; - } - $_key = $self->_string_shift($_buffer["ciphertext"], '.$block_size.'); - $_ciphertext.= $_block ^ $_key; - } - } else { - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { - $_block = substr($_text, $_i, '.$block_size.'); - $in = $_xor; - '.$encrypt_block.' - $self->_increment_str($_xor); - $_key = $in; - $_ciphertext.= $_block ^ $_key; - } - } - if ($self->continuousBuffer) { - $self->encryptIV = $_xor; - if ($_start = $_plaintext_len % '.$block_size.') { - $_buffer["ciphertext"] = substr($_key, $_start) . $_buffer["ciphertext"]; - } - } - - return $_ciphertext; - '; - - $decrypt = $init_encrypt . ' - $_plaintext = ""; - $_ciphertext_len = strlen($_text); - $_xor = $self->decryptIV; - $_buffer = &$self->debuffer; - - if (strlen($_buffer["ciphertext"])) { - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { - $_block = substr($_text, $_i, '.$block_size.'); - if (strlen($_block) > strlen($_buffer["ciphertext"])) { - $in = $_xor; - '.$encrypt_block.' - $self->_increment_str($_xor); - $_buffer["ciphertext"].= $in; - } - $_key = $self->_string_shift($_buffer["ciphertext"], '.$block_size.'); - $_plaintext.= $_block ^ $_key; - } - } else { - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { - $_block = substr($_text, $_i, '.$block_size.'); - $in = $_xor; - '.$encrypt_block.' - $self->_increment_str($_xor); - $_key = $in; - $_plaintext.= $_block ^ $_key; - } - } - if ($self->continuousBuffer) { - $self->decryptIV = $_xor; - if ($_start = $_ciphertext_len % '.$block_size.') { - $_buffer["ciphertext"] = substr($_key, $_start) . $_buffer["ciphertext"]; - } - } - - return $_plaintext; - '; - break; - case self::MODE_CFB: - $encrypt = $init_encrypt . ' - $_ciphertext = ""; - $_buffer = &$self->enbuffer; - - if ($self->continuousBuffer) { - $_iv = &$self->encryptIV; - $_pos = &$_buffer["pos"]; - } else { - $_iv = $self->encryptIV; - $_pos = 0; - } - $_len = strlen($_text); - $_i = 0; - if ($_pos) { - $_orig_pos = $_pos; - $_max = '.$block_size.' - $_pos; - if ($_len >= $_max) { - $_i = $_max; - $_len-= $_max; - $_pos = 0; - } else { - $_i = $_len; - $_pos+= $_len; - $_len = 0; - } - $_ciphertext = substr($_iv, $_orig_pos) ^ $_text; - $_iv = substr_replace($_iv, $_ciphertext, $_orig_pos, $_i); - } - while ($_len >= '.$block_size.') { - $in = $_iv; - '.$encrypt_block.'; - $_iv = $in ^ substr($_text, $_i, '.$block_size.'); - $_ciphertext.= $_iv; - $_len-= '.$block_size.'; - $_i+= '.$block_size.'; - } - if ($_len) { - $in = $_iv; - '.$encrypt_block.' - $_iv = $in; - $_block = $_iv ^ substr($_text, $_i); - $_iv = substr_replace($_iv, $_block, 0, $_len); - $_ciphertext.= $_block; - $_pos = $_len; - } - return $_ciphertext; - '; - - $decrypt = $init_encrypt . ' - $_plaintext = ""; - $_buffer = &$self->debuffer; - - if ($self->continuousBuffer) { - $_iv = &$self->decryptIV; - $_pos = &$_buffer["pos"]; - } else { - $_iv = $self->decryptIV; - $_pos = 0; - } - $_len = strlen($_text); - $_i = 0; - if ($_pos) { - $_orig_pos = $_pos; - $_max = '.$block_size.' - $_pos; - if ($_len >= $_max) { - $_i = $_max; - $_len-= $_max; - $_pos = 0; - } else { - $_i = $_len; - $_pos+= $_len; - $_len = 0; - } - $_plaintext = substr($_iv, $_orig_pos) ^ $_text; - $_iv = substr_replace($_iv, substr($_text, 0, $_i), $_orig_pos, $_i); - } - while ($_len >= '.$block_size.') { - $in = $_iv; - '.$encrypt_block.' - $_iv = $in; - $cb = substr($_text, $_i, '.$block_size.'); - $_plaintext.= $_iv ^ $cb; - $_iv = $cb; - $_len-= '.$block_size.'; - $_i+= '.$block_size.'; - } - if ($_len) { - $in = $_iv; - '.$encrypt_block.' - $_iv = $in; - $_plaintext.= $_iv ^ substr($_text, $_i); - $_iv = substr_replace($_iv, substr($_text, $_i), 0, $_len); - $_pos = $_len; - } - - return $_plaintext; - '; - break; - case self::MODE_OFB: - $encrypt = $init_encrypt . ' - $_ciphertext = ""; - $_plaintext_len = strlen($_text); - $_xor = $self->encryptIV; - $_buffer = &$self->enbuffer; - - if (strlen($_buffer["xor"])) { - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { - $_block = substr($_text, $_i, '.$block_size.'); - if (strlen($_block) > strlen($_buffer["xor"])) { - $in = $_xor; - '.$encrypt_block.' - $_xor = $in; - $_buffer["xor"].= $_xor; - } - $_key = $self->_string_shift($_buffer["xor"], '.$block_size.'); - $_ciphertext.= $_block ^ $_key; - } - } else { - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { - $in = $_xor; - '.$encrypt_block.' - $_xor = $in; - $_ciphertext.= substr($_text, $_i, '.$block_size.') ^ $_xor; - } - $_key = $_xor; - } - if ($self->continuousBuffer) { - $self->encryptIV = $_xor; - if ($_start = $_plaintext_len % '.$block_size.') { - $_buffer["xor"] = substr($_key, $_start) . $_buffer["xor"]; - } - } - return $_ciphertext; - '; - - $decrypt = $init_encrypt . ' - $_plaintext = ""; - $_ciphertext_len = strlen($_text); - $_xor = $self->decryptIV; - $_buffer = &$self->debuffer; - - if (strlen($_buffer["xor"])) { - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { - $_block = substr($_text, $_i, '.$block_size.'); - if (strlen($_block) > strlen($_buffer["xor"])) { - $in = $_xor; - '.$encrypt_block.' - $_xor = $in; - $_buffer["xor"].= $_xor; - } - $_key = $self->_string_shift($_buffer["xor"], '.$block_size.'); - $_plaintext.= $_block ^ $_key; - } - } else { - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { - $in = $_xor; - '.$encrypt_block.' - $_xor = $in; - $_plaintext.= substr($_text, $_i, '.$block_size.') ^ $_xor; - } - $_key = $_xor; - } - if ($self->continuousBuffer) { - $self->decryptIV = $_xor; - if ($_start = $_ciphertext_len % '.$block_size.') { - $_buffer["xor"] = substr($_key, $_start) . $_buffer["xor"]; - } - } - return $_plaintext; - '; - break; - case self::MODE_STREAM: - $encrypt = $init_encrypt . ' - $_ciphertext = ""; - '.$encrypt_block.' - return $_ciphertext; - '; - $decrypt = $init_decrypt . ' - $_plaintext = ""; - '.$decrypt_block.' - return $_plaintext; - '; - break; - // case self::MODE_CBC: - default: - $encrypt = $init_encrypt . ' - $_ciphertext = ""; - $_plaintext_len = strlen($_text); - - $in = $self->encryptIV; - - for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') { - $in = substr($_text, $_i, '.$block_size.') ^ $in; - '.$encrypt_block.' - $_ciphertext.= $in; - } - - if ($self->continuousBuffer) { - $self->encryptIV = $in; - } - - return $_ciphertext; - '; - - $decrypt = $init_decrypt . ' - $_plaintext = ""; - $_text = str_pad($_text, strlen($_text) + ('.$block_size.' - strlen($_text) % '.$block_size.') % '.$block_size.', chr(0)); - $_ciphertext_len = strlen($_text); - - $_iv = $self->decryptIV; - - for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') { - $in = $_block = substr($_text, $_i, '.$block_size.'); - '.$decrypt_block.' - $_plaintext.= $in ^ $_iv; - $_iv = $_block; - } - - if ($self->continuousBuffer) { - $self->decryptIV = $_iv; - } - - return $self->_unpad($_plaintext); - '; - break; - } - - // Create the $inline function and return its name as string. Ready to run! - return create_function('$_action, &$self, $_text', $init_crypt . 'if ($_action == "encrypt") { ' . $encrypt . ' } else { ' . $decrypt . ' }'); - } - - /** - * Holds the lambda_functions table (classwide) - * - * Each name of the lambda function, created from - * _setupInlineCrypt() && _createInlineCryptFunction() - * is stored, classwide (!), here for reusing. - * - * The string-based index of $function is a classwide - * uniqe value representing, at least, the $mode of - * operation (or more... depends of the optimizing level) - * for which $mode the lambda function was created. - * - * @access private - * @return array &$functions - */ - function &_getLambdaFunctions() - { - static $functions = array(); - return $functions; - } - - /** - * Generates a digest from $bytes - * - * @see self::_setupInlineCrypt() - * @access private - * @param $bytes - * @return string - */ - function _hashInlineCryptFunction($bytes) - { - if (!isset(self::$WHIRLPOOL_AVAILABLE)) { - self::$WHIRLPOOL_AVAILABLE = extension_loaded('hash') && in_array('whirlpool', hash_algos()); - } - - $result = ''; - $hash = $bytes; - - switch (true) { - case self::$WHIRLPOOL_AVAILABLE: - foreach (str_split($bytes, 64) as $t) { - $hash = hash('whirlpool', $hash, true); - $result .= $t ^ $hash; - } - return $result . hash('whirlpool', $hash, true); - default: - $len = strlen($bytes); - for ($i = 0; $i < $len; $i+=20) { - $t = substr($bytes, $i, 20); - $hash = pack('H*', sha1($hash)); - $result .= $t ^ $hash; - } - return $result . pack('H*', sha1($hash)); - } - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php deleted file mode 100755 index 138afe530aec45d882407ef3fe7d42a0be92ed8d..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php +++ /dev/null @@ -1,576 +0,0 @@ -<?php - -/** - * Pure-PHP implementation of Blowfish. - * - * Uses mcrypt, if available, and an internal implementation, otherwise. - * - * PHP version 5 - * - * Useful resources are as follows: - * - * - {@link http://en.wikipedia.org/wiki/Blowfish_(cipher) Wikipedia description of Blowfish} - * - * Here's a short example of how to use this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $blowfish = new \phpseclib\Crypt\Blowfish(); - * - * $blowfish->setKey('12345678901234567890123456789012'); - * - * $plaintext = str_repeat('a', 1024); - * - * echo $blowfish->decrypt($blowfish->encrypt($plaintext)); - * ?> - * </code> - * - * @category Crypt - * @package Blowfish - * @author Jim Wigginton <terrafrost@php.net> - * @author Hans-Juergen Petrich <petrich@tronic-media.com> - * @copyright 2007 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Crypt; - -use phpseclib\Crypt\Base; - -/** - * Pure-PHP implementation of Blowfish. - * - * @package Blowfish - * @author Jim Wigginton <terrafrost@php.net> - * @author Hans-Juergen Petrich <petrich@tronic-media.com> - * @access public - */ -class Blowfish extends Base -{ - /** - * Block Length of the cipher - * - * @see \phpseclib\Crypt\Base::block_size - * @var int - * @access private - */ - var $block_size = 8; - - /** - * The mcrypt specific name of the cipher - * - * @see \phpseclib\Crypt\Base::cipher_name_mcrypt - * @var string - * @access private - */ - var $cipher_name_mcrypt = 'blowfish'; - - /** - * Optimizing value while CFB-encrypting - * - * @see \phpseclib\Crypt\Base::cfb_init_len - * @var int - * @access private - */ - var $cfb_init_len = 500; - - /** - * The fixed subkeys boxes ($sbox0 - $sbox3) with 256 entries each - * - * S-Box 0 - * - * @access private - * @var array - */ - var $sbox0 = array( - 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, - 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, - 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, - 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e, - 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, - 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a, - 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677, - 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, - 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239, - 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0, - 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, - 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe, - 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d, - 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, - 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463, - 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09, - 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, - 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8, - 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82, - 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, - 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b, - 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8, - 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, - 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c, - 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1, - 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, - 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf, - 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af, - 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, - 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, - 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915, - 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a - ); - - /** - * S-Box 1 - * - * @access private - * @var array - */ - var $sbox1 = array( - 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266, - 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, - 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1, - 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1, - 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, - 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd, - 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7, - 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, - 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af, - 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87, - 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, - 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd, - 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509, - 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, - 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a, - 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960, - 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, - 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84, - 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf, - 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, - 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7, - 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281, - 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, - 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73, - 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0, - 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, - 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, - 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061, - 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, - 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, - 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340, - 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7 - ); - - /** - * S-Box 2 - * - * @access private - * @var array - */ - var $sbox2 = array( - 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068, - 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, - 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, - 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb, - 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, - 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b, - 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb, - 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, - 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, - 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc, - 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, - 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, - 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728, - 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, - 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d, - 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b, - 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, - 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, - 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9, - 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, - 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, - 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61, - 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, - 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c, - 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633, - 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, - 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, - 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62, - 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, - 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, - 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, - 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0 - ); - - /** - * S-Box 3 - * - * @access private - * @var array - */ - var $sbox3 = array( - 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe, - 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, - 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6, - 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22, - 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, - 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59, - 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51, - 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, - 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28, - 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd, - 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, - 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f, - 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32, - 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, - 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb, - 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47, - 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, - 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048, - 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd, - 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, - 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f, - 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525, - 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, - 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e, - 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d, - 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, - 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc, - 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a, - 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, - 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060, - 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, - 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 - ); - - /** - * P-Array consists of 18 32-bit subkeys - * - * @var array - * @access private - */ - var $parray = array( - 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, - 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, - 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b - ); - - /** - * The BCTX-working Array - * - * Holds the expanded key [p] and the key-depended s-boxes [sb] - * - * @var array - * @access private - */ - var $bctx; - - /** - * Holds the last used key - * - * @var array - * @access private - */ - var $kl; - - /** - * The Key Length (in bytes) - * - * @see \phpseclib\Crypt\Base::setKeyLength() - * @var int - * @access private - * @internal The max value is 256 / 8 = 32, the min value is 128 / 8 = 16. Exists in conjunction with $Nk - * because the encryption / decryption / key schedule creation requires this number and not $key_length. We could - * derive this from $key_length or vice versa, but that'd mean we'd have to do multiple shift operations, so in lieu - * of that, we'll just precompute it once. - */ - var $key_length = 16; - - /** - * Sets the key length. - * - * Key lengths can be between 32 and 448 bits. - * - * @access public - * @param int $length - */ - function setKeyLength($length) - { - if ($length < 32) { - $this->key_length = 7; - } elseif ($length > 448) { - $this->key_length = 56; - } else { - $this->key_length = $length >> 3; - } - - parent::setKeyLength($length); - } - - /** - * Test for engine validity - * - * This is mainly just a wrapper to set things up for \phpseclib\Crypt\Base::isValidEngine() - * - * @see \phpseclib\Crypt\Base::isValidEngine() - * @param int $engine - * @access public - * @return bool - */ - function isValidEngine($engine) - { - if ($engine == self::ENGINE_OPENSSL) { - if ($this->key_length != 16) { - return false; - } - $this->cipher_name_openssl_ecb = 'bf-ecb'; - $this->cipher_name_openssl = 'bf-' . $this->_openssl_translate_mode(); - } - - return parent::isValidEngine($engine); - } - - /** - * Setup the key (expansion) - * - * @see \phpseclib\Crypt\Base::_setupKey() - * @access private - */ - function _setupKey() - { - if (isset($this->kl['key']) && $this->key === $this->kl['key']) { - // already expanded - return; - } - $this->kl = array('key' => $this->key); - - /* key-expanding p[] and S-Box building sb[] */ - $this->bctx = array( - 'p' => array(), - 'sb' => array( - $this->sbox0, - $this->sbox1, - $this->sbox2, - $this->sbox3 - ) - ); - - // unpack binary string in unsigned chars - $key = array_values(unpack('C*', $this->key)); - $keyl = count($key); - for ($j = 0, $i = 0; $i < 18; ++$i) { - // xor P1 with the first 32-bits of the key, xor P2 with the second 32-bits ... - for ($data = 0, $k = 0; $k < 4; ++$k) { - $data = ($data << 8) | $key[$j]; - if (++$j >= $keyl) { - $j = 0; - } - } - $this->bctx['p'][] = $this->parray[$i] ^ $data; - } - - // encrypt the zero-string, replace P1 and P2 with the encrypted data, - // encrypt P3 and P4 with the new P1 and P2, do it with all P-array and subkeys - $data = "\0\0\0\0\0\0\0\0"; - for ($i = 0; $i < 18; $i += 2) { - list($l, $r) = array_values(unpack('N*', $data = $this->_encryptBlock($data))); - $this->bctx['p'][$i ] = $l; - $this->bctx['p'][$i + 1] = $r; - } - for ($i = 0; $i < 4; ++$i) { - for ($j = 0; $j < 256; $j += 2) { - list($l, $r) = array_values(unpack('N*', $data = $this->_encryptBlock($data))); - $this->bctx['sb'][$i][$j ] = $l; - $this->bctx['sb'][$i][$j + 1] = $r; - } - } - } - - /** - * Encrypts a block - * - * @access private - * @param string $in - * @return string - */ - function _encryptBlock($in) - { - $p = $this->bctx["p"]; - // extract($this->bctx["sb"], EXTR_PREFIX_ALL, "sb"); // slower - $sb_0 = $this->bctx["sb"][0]; - $sb_1 = $this->bctx["sb"][1]; - $sb_2 = $this->bctx["sb"][2]; - $sb_3 = $this->bctx["sb"][3]; - - $in = unpack("N*", $in); - $l = $in[1]; - $r = $in[2]; - - for ($i = 0; $i < 16; $i+= 2) { - $l^= $p[$i]; - $r^= ($sb_0[$l >> 24 & 0xff] + - $sb_1[$l >> 16 & 0xff] ^ - $sb_2[$l >> 8 & 0xff]) + - $sb_3[$l & 0xff]; - - $r^= $p[$i + 1]; - $l^= ($sb_0[$r >> 24 & 0xff] + - $sb_1[$r >> 16 & 0xff] ^ - $sb_2[$r >> 8 & 0xff]) + - $sb_3[$r & 0xff]; - } - return pack("N*", $r ^ $p[17], $l ^ $p[16]); - } - - /** - * Decrypts a block - * - * @access private - * @param string $in - * @return string - */ - function _decryptBlock($in) - { - $p = $this->bctx["p"]; - $sb_0 = $this->bctx["sb"][0]; - $sb_1 = $this->bctx["sb"][1]; - $sb_2 = $this->bctx["sb"][2]; - $sb_3 = $this->bctx["sb"][3]; - - $in = unpack("N*", $in); - $l = $in[1]; - $r = $in[2]; - - for ($i = 17; $i > 2; $i-= 2) { - $l^= $p[$i]; - $r^= ($sb_0[$l >> 24 & 0xff] + - $sb_1[$l >> 16 & 0xff] ^ - $sb_2[$l >> 8 & 0xff]) + - $sb_3[$l & 0xff]; - - $r^= $p[$i - 1]; - $l^= ($sb_0[$r >> 24 & 0xff] + - $sb_1[$r >> 16 & 0xff] ^ - $sb_2[$r >> 8 & 0xff]) + - $sb_3[$r & 0xff]; - } - return pack("N*", $r ^ $p[0], $l ^ $p[1]); - } - - /** - * Setup the performance-optimized function for de/encrypt() - * - * @see \phpseclib\Crypt\Base::_setupInlineCrypt() - * @access private - */ - function _setupInlineCrypt() - { - $lambda_functions =& self::_getLambdaFunctions(); - - // We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function. - // (Currently, for Blowfish, one generated $lambda_function cost on php5.5@32bit ~100kb unfreeable mem and ~180kb on php5.5@64bit) - // After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one. - $gen_hi_opt_code = (bool)(count($lambda_functions) < 10); - - // Generation of a unique hash for our generated code - $code_hash = "Crypt_Blowfish, {$this->mode}"; - if ($gen_hi_opt_code) { - $code_hash = str_pad($code_hash, 32) . $this->_hashInlineCryptFunction($this->key); - } - - if (!isset($lambda_functions[$code_hash])) { - switch (true) { - case $gen_hi_opt_code: - $p = $this->bctx['p']; - $init_crypt = ' - static $sb_0, $sb_1, $sb_2, $sb_3; - if (!$sb_0) { - $sb_0 = $self->bctx["sb"][0]; - $sb_1 = $self->bctx["sb"][1]; - $sb_2 = $self->bctx["sb"][2]; - $sb_3 = $self->bctx["sb"][3]; - } - '; - break; - default: - $p = array(); - for ($i = 0; $i < 18; ++$i) { - $p[] = '$p_' . $i; - } - $init_crypt = ' - list($sb_0, $sb_1, $sb_2, $sb_3) = $self->bctx["sb"]; - list(' . implode(',', $p) . ') = $self->bctx["p"]; - - '; - } - - // Generating encrypt code: - $encrypt_block = ' - $in = unpack("N*", $in); - $l = $in[1]; - $r = $in[2]; - '; - for ($i = 0; $i < 16; $i+= 2) { - $encrypt_block.= ' - $l^= ' . $p[$i] . '; - $r^= ($sb_0[$l >> 24 & 0xff] + - $sb_1[$l >> 16 & 0xff] ^ - $sb_2[$l >> 8 & 0xff]) + - $sb_3[$l & 0xff]; - - $r^= ' . $p[$i + 1] . '; - $l^= ($sb_0[$r >> 24 & 0xff] + - $sb_1[$r >> 16 & 0xff] ^ - $sb_2[$r >> 8 & 0xff]) + - $sb_3[$r & 0xff]; - '; - } - $encrypt_block.= ' - $in = pack("N*", - $r ^ ' . $p[17] . ', - $l ^ ' . $p[16] . ' - ); - '; - - // Generating decrypt code: - $decrypt_block = ' - $in = unpack("N*", $in); - $l = $in[1]; - $r = $in[2]; - '; - - for ($i = 17; $i > 2; $i-= 2) { - $decrypt_block.= ' - $l^= ' . $p[$i] . '; - $r^= ($sb_0[$l >> 24 & 0xff] + - $sb_1[$l >> 16 & 0xff] ^ - $sb_2[$l >> 8 & 0xff]) + - $sb_3[$l & 0xff]; - - $r^= ' . $p[$i - 1] . '; - $l^= ($sb_0[$r >> 24 & 0xff] + - $sb_1[$r >> 16 & 0xff] ^ - $sb_2[$r >> 8 & 0xff]) + - $sb_3[$r & 0xff]; - '; - } - - $decrypt_block.= ' - $in = pack("N*", - $r ^ ' . $p[0] . ', - $l ^ ' . $p[1] . ' - ); - '; - - $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( - array( - 'init_crypt' => $init_crypt, - 'init_encrypt' => '', - 'init_decrypt' => '', - 'encrypt_block' => $encrypt_block, - 'decrypt_block' => $decrypt_block - ) - ); - } - $this->inline_crypt = $lambda_functions[$code_hash]; - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/DES.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/DES.php deleted file mode 100755 index 93e583a72d4277423e2210af78283a161733a8a7..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/DES.php +++ /dev/null @@ -1,1445 +0,0 @@ -<?php - -/** - * Pure-PHP implementation of DES. - * - * Uses mcrypt, if available, and an internal implementation, otherwise. - * - * PHP version 5 - * - * Useful resources are as follows: - * - * - {@link http://en.wikipedia.org/wiki/DES_supplementary_material Wikipedia: DES supplementary material} - * - {@link http://www.itl.nist.gov/fipspubs/fip46-2.htm FIPS 46-2 - (DES), Data Encryption Standard} - * - {@link http://www.cs.eku.edu/faculty/styer/460/Encrypt/JS-DES.html JavaScript DES Example} - * - * Here's a short example of how to use this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $des = new \phpseclib\Crypt\DES(); - * - * $des->setKey('abcdefgh'); - * - * $size = 10 * 1024; - * $plaintext = ''; - * for ($i = 0; $i < $size; $i++) { - * $plaintext.= 'a'; - * } - * - * echo $des->decrypt($des->encrypt($plaintext)); - * ?> - * </code> - * - * @category Crypt - * @package DES - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2007 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Crypt; - -use phpseclib\Crypt\Base; - -/** - * Pure-PHP implementation of DES. - * - * @package DES - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class DES extends Base -{ - /**#@+ - * @access private - * @see \phpseclib\Crypt\DES::_setupKey() - * @see \phpseclib\Crypt\DES::_processBlock() - */ - /** - * Contains $keys[self::ENCRYPT] - */ - const ENCRYPT = 0; - /** - * Contains $keys[self::DECRYPT] - */ - const DECRYPT = 1; - /**#@-*/ - - /** - * Block Length of the cipher - * - * @see \phpseclib\Crypt\Base::block_size - * @var int - * @access private - */ - var $block_size = 8; - - /** - * Key Length (in bytes) - * - * @see \phpseclib\Crypt\Base::setKeyLength() - * @var int - * @access private - */ - var $key_length = 8; - - /** - * The mcrypt specific name of the cipher - * - * @see \phpseclib\Crypt\Base::cipher_name_mcrypt - * @var string - * @access private - */ - var $cipher_name_mcrypt = 'des'; - - /** - * The OpenSSL names of the cipher / modes - * - * @see \phpseclib\Crypt\Base::openssl_mode_names - * @var array - * @access private - */ - var $openssl_mode_names = array( - self::MODE_ECB => 'des-ecb', - self::MODE_CBC => 'des-cbc', - self::MODE_CFB => 'des-cfb', - self::MODE_OFB => 'des-ofb' - // self::MODE_CTR is undefined for DES - ); - - /** - * Optimizing value while CFB-encrypting - * - * @see \phpseclib\Crypt\Base::cfb_init_len - * @var int - * @access private - */ - var $cfb_init_len = 500; - - /** - * Switch for DES/3DES encryption - * - * Used only if $engine == self::ENGINE_INTERNAL - * - * @see self::_setupKey() - * @see self::_processBlock() - * @var int - * @access private - */ - var $des_rounds = 1; - - /** - * max possible size of $key - * - * @see self::setKey() - * @var string - * @access private - */ - var $key_length_max = 8; - - /** - * The Key Schedule - * - * @see self::_setupKey() - * @var array - * @access private - */ - var $keys; - - /** - * Shuffle table. - * - * For each byte value index, the entry holds an 8-byte string - * with each byte containing all bits in the same state as the - * corresponding bit in the index value. - * - * @see self::_processBlock() - * @see self::_setupKey() - * @var array - * @access private - */ - var $shuffle = array( - "\x00\x00\x00\x00\x00\x00\x00\x00", "\x00\x00\x00\x00\x00\x00\x00\xFF", - "\x00\x00\x00\x00\x00\x00\xFF\x00", "\x00\x00\x00\x00\x00\x00\xFF\xFF", - "\x00\x00\x00\x00\x00\xFF\x00\x00", "\x00\x00\x00\x00\x00\xFF\x00\xFF", - "\x00\x00\x00\x00\x00\xFF\xFF\x00", "\x00\x00\x00\x00\x00\xFF\xFF\xFF", - "\x00\x00\x00\x00\xFF\x00\x00\x00", "\x00\x00\x00\x00\xFF\x00\x00\xFF", - "\x00\x00\x00\x00\xFF\x00\xFF\x00", "\x00\x00\x00\x00\xFF\x00\xFF\xFF", - "\x00\x00\x00\x00\xFF\xFF\x00\x00", "\x00\x00\x00\x00\xFF\xFF\x00\xFF", - "\x00\x00\x00\x00\xFF\xFF\xFF\x00", "\x00\x00\x00\x00\xFF\xFF\xFF\xFF", - "\x00\x00\x00\xFF\x00\x00\x00\x00", "\x00\x00\x00\xFF\x00\x00\x00\xFF", - "\x00\x00\x00\xFF\x00\x00\xFF\x00", "\x00\x00\x00\xFF\x00\x00\xFF\xFF", - "\x00\x00\x00\xFF\x00\xFF\x00\x00", "\x00\x00\x00\xFF\x00\xFF\x00\xFF", - "\x00\x00\x00\xFF\x00\xFF\xFF\x00", "\x00\x00\x00\xFF\x00\xFF\xFF\xFF", - "\x00\x00\x00\xFF\xFF\x00\x00\x00", "\x00\x00\x00\xFF\xFF\x00\x00\xFF", - "\x00\x00\x00\xFF\xFF\x00\xFF\x00", "\x00\x00\x00\xFF\xFF\x00\xFF\xFF", - "\x00\x00\x00\xFF\xFF\xFF\x00\x00", "\x00\x00\x00\xFF\xFF\xFF\x00\xFF", - "\x00\x00\x00\xFF\xFF\xFF\xFF\x00", "\x00\x00\x00\xFF\xFF\xFF\xFF\xFF", - "\x00\x00\xFF\x00\x00\x00\x00\x00", "\x00\x00\xFF\x00\x00\x00\x00\xFF", - "\x00\x00\xFF\x00\x00\x00\xFF\x00", "\x00\x00\xFF\x00\x00\x00\xFF\xFF", - "\x00\x00\xFF\x00\x00\xFF\x00\x00", "\x00\x00\xFF\x00\x00\xFF\x00\xFF", - "\x00\x00\xFF\x00\x00\xFF\xFF\x00", "\x00\x00\xFF\x00\x00\xFF\xFF\xFF", - "\x00\x00\xFF\x00\xFF\x00\x00\x00", "\x00\x00\xFF\x00\xFF\x00\x00\xFF", - "\x00\x00\xFF\x00\xFF\x00\xFF\x00", "\x00\x00\xFF\x00\xFF\x00\xFF\xFF", - "\x00\x00\xFF\x00\xFF\xFF\x00\x00", "\x00\x00\xFF\x00\xFF\xFF\x00\xFF", - "\x00\x00\xFF\x00\xFF\xFF\xFF\x00", "\x00\x00\xFF\x00\xFF\xFF\xFF\xFF", - "\x00\x00\xFF\xFF\x00\x00\x00\x00", "\x00\x00\xFF\xFF\x00\x00\x00\xFF", - "\x00\x00\xFF\xFF\x00\x00\xFF\x00", "\x00\x00\xFF\xFF\x00\x00\xFF\xFF", - "\x00\x00\xFF\xFF\x00\xFF\x00\x00", "\x00\x00\xFF\xFF\x00\xFF\x00\xFF", - "\x00\x00\xFF\xFF\x00\xFF\xFF\x00", "\x00\x00\xFF\xFF\x00\xFF\xFF\xFF", - "\x00\x00\xFF\xFF\xFF\x00\x00\x00", "\x00\x00\xFF\xFF\xFF\x00\x00\xFF", - "\x00\x00\xFF\xFF\xFF\x00\xFF\x00", "\x00\x00\xFF\xFF\xFF\x00\xFF\xFF", - "\x00\x00\xFF\xFF\xFF\xFF\x00\x00", "\x00\x00\xFF\xFF\xFF\xFF\x00\xFF", - "\x00\x00\xFF\xFF\xFF\xFF\xFF\x00", "\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF", - "\x00\xFF\x00\x00\x00\x00\x00\x00", "\x00\xFF\x00\x00\x00\x00\x00\xFF", - "\x00\xFF\x00\x00\x00\x00\xFF\x00", "\x00\xFF\x00\x00\x00\x00\xFF\xFF", - "\x00\xFF\x00\x00\x00\xFF\x00\x00", "\x00\xFF\x00\x00\x00\xFF\x00\xFF", - "\x00\xFF\x00\x00\x00\xFF\xFF\x00", "\x00\xFF\x00\x00\x00\xFF\xFF\xFF", - "\x00\xFF\x00\x00\xFF\x00\x00\x00", "\x00\xFF\x00\x00\xFF\x00\x00\xFF", - "\x00\xFF\x00\x00\xFF\x00\xFF\x00", "\x00\xFF\x00\x00\xFF\x00\xFF\xFF", - "\x00\xFF\x00\x00\xFF\xFF\x00\x00", "\x00\xFF\x00\x00\xFF\xFF\x00\xFF", - "\x00\xFF\x00\x00\xFF\xFF\xFF\x00", "\x00\xFF\x00\x00\xFF\xFF\xFF\xFF", - "\x00\xFF\x00\xFF\x00\x00\x00\x00", "\x00\xFF\x00\xFF\x00\x00\x00\xFF", - "\x00\xFF\x00\xFF\x00\x00\xFF\x00", "\x00\xFF\x00\xFF\x00\x00\xFF\xFF", - "\x00\xFF\x00\xFF\x00\xFF\x00\x00", "\x00\xFF\x00\xFF\x00\xFF\x00\xFF", - "\x00\xFF\x00\xFF\x00\xFF\xFF\x00", "\x00\xFF\x00\xFF\x00\xFF\xFF\xFF", - "\x00\xFF\x00\xFF\xFF\x00\x00\x00", "\x00\xFF\x00\xFF\xFF\x00\x00\xFF", - "\x00\xFF\x00\xFF\xFF\x00\xFF\x00", "\x00\xFF\x00\xFF\xFF\x00\xFF\xFF", - "\x00\xFF\x00\xFF\xFF\xFF\x00\x00", "\x00\xFF\x00\xFF\xFF\xFF\x00\xFF", - "\x00\xFF\x00\xFF\xFF\xFF\xFF\x00", "\x00\xFF\x00\xFF\xFF\xFF\xFF\xFF", - "\x00\xFF\xFF\x00\x00\x00\x00\x00", "\x00\xFF\xFF\x00\x00\x00\x00\xFF", - "\x00\xFF\xFF\x00\x00\x00\xFF\x00", "\x00\xFF\xFF\x00\x00\x00\xFF\xFF", - "\x00\xFF\xFF\x00\x00\xFF\x00\x00", "\x00\xFF\xFF\x00\x00\xFF\x00\xFF", - "\x00\xFF\xFF\x00\x00\xFF\xFF\x00", "\x00\xFF\xFF\x00\x00\xFF\xFF\xFF", - "\x00\xFF\xFF\x00\xFF\x00\x00\x00", "\x00\xFF\xFF\x00\xFF\x00\x00\xFF", - "\x00\xFF\xFF\x00\xFF\x00\xFF\x00", "\x00\xFF\xFF\x00\xFF\x00\xFF\xFF", - "\x00\xFF\xFF\x00\xFF\xFF\x00\x00", "\x00\xFF\xFF\x00\xFF\xFF\x00\xFF", - "\x00\xFF\xFF\x00\xFF\xFF\xFF\x00", "\x00\xFF\xFF\x00\xFF\xFF\xFF\xFF", - "\x00\xFF\xFF\xFF\x00\x00\x00\x00", "\x00\xFF\xFF\xFF\x00\x00\x00\xFF", - "\x00\xFF\xFF\xFF\x00\x00\xFF\x00", "\x00\xFF\xFF\xFF\x00\x00\xFF\xFF", - "\x00\xFF\xFF\xFF\x00\xFF\x00\x00", "\x00\xFF\xFF\xFF\x00\xFF\x00\xFF", - "\x00\xFF\xFF\xFF\x00\xFF\xFF\x00", "\x00\xFF\xFF\xFF\x00\xFF\xFF\xFF", - "\x00\xFF\xFF\xFF\xFF\x00\x00\x00", "\x00\xFF\xFF\xFF\xFF\x00\x00\xFF", - "\x00\xFF\xFF\xFF\xFF\x00\xFF\x00", "\x00\xFF\xFF\xFF\xFF\x00\xFF\xFF", - "\x00\xFF\xFF\xFF\xFF\xFF\x00\x00", "\x00\xFF\xFF\xFF\xFF\xFF\x00\xFF", - "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00", "\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF", - "\xFF\x00\x00\x00\x00\x00\x00\x00", "\xFF\x00\x00\x00\x00\x00\x00\xFF", - "\xFF\x00\x00\x00\x00\x00\xFF\x00", "\xFF\x00\x00\x00\x00\x00\xFF\xFF", - "\xFF\x00\x00\x00\x00\xFF\x00\x00", "\xFF\x00\x00\x00\x00\xFF\x00\xFF", - "\xFF\x00\x00\x00\x00\xFF\xFF\x00", "\xFF\x00\x00\x00\x00\xFF\xFF\xFF", - "\xFF\x00\x00\x00\xFF\x00\x00\x00", "\xFF\x00\x00\x00\xFF\x00\x00\xFF", - "\xFF\x00\x00\x00\xFF\x00\xFF\x00", "\xFF\x00\x00\x00\xFF\x00\xFF\xFF", - "\xFF\x00\x00\x00\xFF\xFF\x00\x00", "\xFF\x00\x00\x00\xFF\xFF\x00\xFF", - "\xFF\x00\x00\x00\xFF\xFF\xFF\x00", "\xFF\x00\x00\x00\xFF\xFF\xFF\xFF", - "\xFF\x00\x00\xFF\x00\x00\x00\x00", "\xFF\x00\x00\xFF\x00\x00\x00\xFF", - "\xFF\x00\x00\xFF\x00\x00\xFF\x00", "\xFF\x00\x00\xFF\x00\x00\xFF\xFF", - "\xFF\x00\x00\xFF\x00\xFF\x00\x00", "\xFF\x00\x00\xFF\x00\xFF\x00\xFF", - "\xFF\x00\x00\xFF\x00\xFF\xFF\x00", "\xFF\x00\x00\xFF\x00\xFF\xFF\xFF", - "\xFF\x00\x00\xFF\xFF\x00\x00\x00", "\xFF\x00\x00\xFF\xFF\x00\x00\xFF", - "\xFF\x00\x00\xFF\xFF\x00\xFF\x00", "\xFF\x00\x00\xFF\xFF\x00\xFF\xFF", - "\xFF\x00\x00\xFF\xFF\xFF\x00\x00", "\xFF\x00\x00\xFF\xFF\xFF\x00\xFF", - "\xFF\x00\x00\xFF\xFF\xFF\xFF\x00", "\xFF\x00\x00\xFF\xFF\xFF\xFF\xFF", - "\xFF\x00\xFF\x00\x00\x00\x00\x00", "\xFF\x00\xFF\x00\x00\x00\x00\xFF", - "\xFF\x00\xFF\x00\x00\x00\xFF\x00", "\xFF\x00\xFF\x00\x00\x00\xFF\xFF", - "\xFF\x00\xFF\x00\x00\xFF\x00\x00", "\xFF\x00\xFF\x00\x00\xFF\x00\xFF", - "\xFF\x00\xFF\x00\x00\xFF\xFF\x00", "\xFF\x00\xFF\x00\x00\xFF\xFF\xFF", - "\xFF\x00\xFF\x00\xFF\x00\x00\x00", "\xFF\x00\xFF\x00\xFF\x00\x00\xFF", - "\xFF\x00\xFF\x00\xFF\x00\xFF\x00", "\xFF\x00\xFF\x00\xFF\x00\xFF\xFF", - "\xFF\x00\xFF\x00\xFF\xFF\x00\x00", "\xFF\x00\xFF\x00\xFF\xFF\x00\xFF", - "\xFF\x00\xFF\x00\xFF\xFF\xFF\x00", "\xFF\x00\xFF\x00\xFF\xFF\xFF\xFF", - "\xFF\x00\xFF\xFF\x00\x00\x00\x00", "\xFF\x00\xFF\xFF\x00\x00\x00\xFF", - "\xFF\x00\xFF\xFF\x00\x00\xFF\x00", "\xFF\x00\xFF\xFF\x00\x00\xFF\xFF", - "\xFF\x00\xFF\xFF\x00\xFF\x00\x00", "\xFF\x00\xFF\xFF\x00\xFF\x00\xFF", - "\xFF\x00\xFF\xFF\x00\xFF\xFF\x00", "\xFF\x00\xFF\xFF\x00\xFF\xFF\xFF", - "\xFF\x00\xFF\xFF\xFF\x00\x00\x00", "\xFF\x00\xFF\xFF\xFF\x00\x00\xFF", - "\xFF\x00\xFF\xFF\xFF\x00\xFF\x00", "\xFF\x00\xFF\xFF\xFF\x00\xFF\xFF", - "\xFF\x00\xFF\xFF\xFF\xFF\x00\x00", "\xFF\x00\xFF\xFF\xFF\xFF\x00\xFF", - "\xFF\x00\xFF\xFF\xFF\xFF\xFF\x00", "\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF", - "\xFF\xFF\x00\x00\x00\x00\x00\x00", "\xFF\xFF\x00\x00\x00\x00\x00\xFF", - "\xFF\xFF\x00\x00\x00\x00\xFF\x00", "\xFF\xFF\x00\x00\x00\x00\xFF\xFF", - "\xFF\xFF\x00\x00\x00\xFF\x00\x00", "\xFF\xFF\x00\x00\x00\xFF\x00\xFF", - "\xFF\xFF\x00\x00\x00\xFF\xFF\x00", "\xFF\xFF\x00\x00\x00\xFF\xFF\xFF", - "\xFF\xFF\x00\x00\xFF\x00\x00\x00", "\xFF\xFF\x00\x00\xFF\x00\x00\xFF", - "\xFF\xFF\x00\x00\xFF\x00\xFF\x00", "\xFF\xFF\x00\x00\xFF\x00\xFF\xFF", - "\xFF\xFF\x00\x00\xFF\xFF\x00\x00", "\xFF\xFF\x00\x00\xFF\xFF\x00\xFF", - "\xFF\xFF\x00\x00\xFF\xFF\xFF\x00", "\xFF\xFF\x00\x00\xFF\xFF\xFF\xFF", - "\xFF\xFF\x00\xFF\x00\x00\x00\x00", "\xFF\xFF\x00\xFF\x00\x00\x00\xFF", - "\xFF\xFF\x00\xFF\x00\x00\xFF\x00", "\xFF\xFF\x00\xFF\x00\x00\xFF\xFF", - "\xFF\xFF\x00\xFF\x00\xFF\x00\x00", "\xFF\xFF\x00\xFF\x00\xFF\x00\xFF", - "\xFF\xFF\x00\xFF\x00\xFF\xFF\x00", "\xFF\xFF\x00\xFF\x00\xFF\xFF\xFF", - "\xFF\xFF\x00\xFF\xFF\x00\x00\x00", "\xFF\xFF\x00\xFF\xFF\x00\x00\xFF", - "\xFF\xFF\x00\xFF\xFF\x00\xFF\x00", "\xFF\xFF\x00\xFF\xFF\x00\xFF\xFF", - "\xFF\xFF\x00\xFF\xFF\xFF\x00\x00", "\xFF\xFF\x00\xFF\xFF\xFF\x00\xFF", - "\xFF\xFF\x00\xFF\xFF\xFF\xFF\x00", "\xFF\xFF\x00\xFF\xFF\xFF\xFF\xFF", - "\xFF\xFF\xFF\x00\x00\x00\x00\x00", "\xFF\xFF\xFF\x00\x00\x00\x00\xFF", - "\xFF\xFF\xFF\x00\x00\x00\xFF\x00", "\xFF\xFF\xFF\x00\x00\x00\xFF\xFF", - "\xFF\xFF\xFF\x00\x00\xFF\x00\x00", "\xFF\xFF\xFF\x00\x00\xFF\x00\xFF", - "\xFF\xFF\xFF\x00\x00\xFF\xFF\x00", "\xFF\xFF\xFF\x00\x00\xFF\xFF\xFF", - "\xFF\xFF\xFF\x00\xFF\x00\x00\x00", "\xFF\xFF\xFF\x00\xFF\x00\x00\xFF", - "\xFF\xFF\xFF\x00\xFF\x00\xFF\x00", "\xFF\xFF\xFF\x00\xFF\x00\xFF\xFF", - "\xFF\xFF\xFF\x00\xFF\xFF\x00\x00", "\xFF\xFF\xFF\x00\xFF\xFF\x00\xFF", - "\xFF\xFF\xFF\x00\xFF\xFF\xFF\x00", "\xFF\xFF\xFF\x00\xFF\xFF\xFF\xFF", - "\xFF\xFF\xFF\xFF\x00\x00\x00\x00", "\xFF\xFF\xFF\xFF\x00\x00\x00\xFF", - "\xFF\xFF\xFF\xFF\x00\x00\xFF\x00", "\xFF\xFF\xFF\xFF\x00\x00\xFF\xFF", - "\xFF\xFF\xFF\xFF\x00\xFF\x00\x00", "\xFF\xFF\xFF\xFF\x00\xFF\x00\xFF", - "\xFF\xFF\xFF\xFF\x00\xFF\xFF\x00", "\xFF\xFF\xFF\xFF\x00\xFF\xFF\xFF", - "\xFF\xFF\xFF\xFF\xFF\x00\x00\x00", "\xFF\xFF\xFF\xFF\xFF\x00\x00\xFF", - "\xFF\xFF\xFF\xFF\xFF\x00\xFF\x00", "\xFF\xFF\xFF\xFF\xFF\x00\xFF\xFF", - "\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00", "\xFF\xFF\xFF\xFF\xFF\xFF\x00\xFF", - "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00", "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" - ); - - /** - * IP mapping helper table. - * - * Indexing this table with each source byte performs the initial bit permutation. - * - * @var array - * @access private - */ - var $ipmap = array( - 0x00, 0x10, 0x01, 0x11, 0x20, 0x30, 0x21, 0x31, - 0x02, 0x12, 0x03, 0x13, 0x22, 0x32, 0x23, 0x33, - 0x40, 0x50, 0x41, 0x51, 0x60, 0x70, 0x61, 0x71, - 0x42, 0x52, 0x43, 0x53, 0x62, 0x72, 0x63, 0x73, - 0x04, 0x14, 0x05, 0x15, 0x24, 0x34, 0x25, 0x35, - 0x06, 0x16, 0x07, 0x17, 0x26, 0x36, 0x27, 0x37, - 0x44, 0x54, 0x45, 0x55, 0x64, 0x74, 0x65, 0x75, - 0x46, 0x56, 0x47, 0x57, 0x66, 0x76, 0x67, 0x77, - 0x80, 0x90, 0x81, 0x91, 0xA0, 0xB0, 0xA1, 0xB1, - 0x82, 0x92, 0x83, 0x93, 0xA2, 0xB2, 0xA3, 0xB3, - 0xC0, 0xD0, 0xC1, 0xD1, 0xE0, 0xF0, 0xE1, 0xF1, - 0xC2, 0xD2, 0xC3, 0xD3, 0xE2, 0xF2, 0xE3, 0xF3, - 0x84, 0x94, 0x85, 0x95, 0xA4, 0xB4, 0xA5, 0xB5, - 0x86, 0x96, 0x87, 0x97, 0xA6, 0xB6, 0xA7, 0xB7, - 0xC4, 0xD4, 0xC5, 0xD5, 0xE4, 0xF4, 0xE5, 0xF5, - 0xC6, 0xD6, 0xC7, 0xD7, 0xE6, 0xF6, 0xE7, 0xF7, - 0x08, 0x18, 0x09, 0x19, 0x28, 0x38, 0x29, 0x39, - 0x0A, 0x1A, 0x0B, 0x1B, 0x2A, 0x3A, 0x2B, 0x3B, - 0x48, 0x58, 0x49, 0x59, 0x68, 0x78, 0x69, 0x79, - 0x4A, 0x5A, 0x4B, 0x5B, 0x6A, 0x7A, 0x6B, 0x7B, - 0x0C, 0x1C, 0x0D, 0x1D, 0x2C, 0x3C, 0x2D, 0x3D, - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4C, 0x5C, 0x4D, 0x5D, 0x6C, 0x7C, 0x6D, 0x7D, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x88, 0x98, 0x89, 0x99, 0xA8, 0xB8, 0xA9, 0xB9, - 0x8A, 0x9A, 0x8B, 0x9B, 0xAA, 0xBA, 0xAB, 0xBB, - 0xC8, 0xD8, 0xC9, 0xD9, 0xE8, 0xF8, 0xE9, 0xF9, - 0xCA, 0xDA, 0xCB, 0xDB, 0xEA, 0xFA, 0xEB, 0xFB, - 0x8C, 0x9C, 0x8D, 0x9D, 0xAC, 0xBC, 0xAD, 0xBD, - 0x8E, 0x9E, 0x8F, 0x9F, 0xAE, 0xBE, 0xAF, 0xBF, - 0xCC, 0xDC, 0xCD, 0xDD, 0xEC, 0xFC, 0xED, 0xFD, - 0xCE, 0xDE, 0xCF, 0xDF, 0xEE, 0xFE, 0xEF, 0xFF - ); - - /** - * Inverse IP mapping helper table. - * Indexing this table with a byte value reverses the bit order. - * - * @var array - * @access private - */ - var $invipmap = array( - 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, - 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, - 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, - 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, - 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, - 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, - 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, - 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, - 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, - 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, - 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, - 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, - 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, - 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, - 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, - 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, - 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, - 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, - 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, - 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, - 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, - 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, - 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, - 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, - 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, - 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, - 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, - 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, - 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, - 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, - 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, - 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF - ); - - /** - * Pre-permuted S-box1 - * - * Each box ($sbox1-$sbox8) has been vectorized, then each value pre-permuted using the - * P table: concatenation can then be replaced by exclusive ORs. - * - * @var array - * @access private - */ - var $sbox1 = array( - 0x00808200, 0x00000000, 0x00008000, 0x00808202, - 0x00808002, 0x00008202, 0x00000002, 0x00008000, - 0x00000200, 0x00808200, 0x00808202, 0x00000200, - 0x00800202, 0x00808002, 0x00800000, 0x00000002, - 0x00000202, 0x00800200, 0x00800200, 0x00008200, - 0x00008200, 0x00808000, 0x00808000, 0x00800202, - 0x00008002, 0x00800002, 0x00800002, 0x00008002, - 0x00000000, 0x00000202, 0x00008202, 0x00800000, - 0x00008000, 0x00808202, 0x00000002, 0x00808000, - 0x00808200, 0x00800000, 0x00800000, 0x00000200, - 0x00808002, 0x00008000, 0x00008200, 0x00800002, - 0x00000200, 0x00000002, 0x00800202, 0x00008202, - 0x00808202, 0x00008002, 0x00808000, 0x00800202, - 0x00800002, 0x00000202, 0x00008202, 0x00808200, - 0x00000202, 0x00800200, 0x00800200, 0x00000000, - 0x00008002, 0x00008200, 0x00000000, 0x00808002 - ); - - /** - * Pre-permuted S-box2 - * - * @var array - * @access private - */ - var $sbox2 = array( - 0x40084010, 0x40004000, 0x00004000, 0x00084010, - 0x00080000, 0x00000010, 0x40080010, 0x40004010, - 0x40000010, 0x40084010, 0x40084000, 0x40000000, - 0x40004000, 0x00080000, 0x00000010, 0x40080010, - 0x00084000, 0x00080010, 0x40004010, 0x00000000, - 0x40000000, 0x00004000, 0x00084010, 0x40080000, - 0x00080010, 0x40000010, 0x00000000, 0x00084000, - 0x00004010, 0x40084000, 0x40080000, 0x00004010, - 0x00000000, 0x00084010, 0x40080010, 0x00080000, - 0x40004010, 0x40080000, 0x40084000, 0x00004000, - 0x40080000, 0x40004000, 0x00000010, 0x40084010, - 0x00084010, 0x00000010, 0x00004000, 0x40000000, - 0x00004010, 0x40084000, 0x00080000, 0x40000010, - 0x00080010, 0x40004010, 0x40000010, 0x00080010, - 0x00084000, 0x00000000, 0x40004000, 0x00004010, - 0x40000000, 0x40080010, 0x40084010, 0x00084000 - ); - - /** - * Pre-permuted S-box3 - * - * @var array - * @access private - */ - var $sbox3 = array( - 0x00000104, 0x04010100, 0x00000000, 0x04010004, - 0x04000100, 0x00000000, 0x00010104, 0x04000100, - 0x00010004, 0x04000004, 0x04000004, 0x00010000, - 0x04010104, 0x00010004, 0x04010000, 0x00000104, - 0x04000000, 0x00000004, 0x04010100, 0x00000100, - 0x00010100, 0x04010000, 0x04010004, 0x00010104, - 0x04000104, 0x00010100, 0x00010000, 0x04000104, - 0x00000004, 0x04010104, 0x00000100, 0x04000000, - 0x04010100, 0x04000000, 0x00010004, 0x00000104, - 0x00010000, 0x04010100, 0x04000100, 0x00000000, - 0x00000100, 0x00010004, 0x04010104, 0x04000100, - 0x04000004, 0x00000100, 0x00000000, 0x04010004, - 0x04000104, 0x00010000, 0x04000000, 0x04010104, - 0x00000004, 0x00010104, 0x00010100, 0x04000004, - 0x04010000, 0x04000104, 0x00000104, 0x04010000, - 0x00010104, 0x00000004, 0x04010004, 0x00010100 - ); - - /** - * Pre-permuted S-box4 - * - * @var array - * @access private - */ - var $sbox4 = array( - 0x80401000, 0x80001040, 0x80001040, 0x00000040, - 0x00401040, 0x80400040, 0x80400000, 0x80001000, - 0x00000000, 0x00401000, 0x00401000, 0x80401040, - 0x80000040, 0x00000000, 0x00400040, 0x80400000, - 0x80000000, 0x00001000, 0x00400000, 0x80401000, - 0x00000040, 0x00400000, 0x80001000, 0x00001040, - 0x80400040, 0x80000000, 0x00001040, 0x00400040, - 0x00001000, 0x00401040, 0x80401040, 0x80000040, - 0x00400040, 0x80400000, 0x00401000, 0x80401040, - 0x80000040, 0x00000000, 0x00000000, 0x00401000, - 0x00001040, 0x00400040, 0x80400040, 0x80000000, - 0x80401000, 0x80001040, 0x80001040, 0x00000040, - 0x80401040, 0x80000040, 0x80000000, 0x00001000, - 0x80400000, 0x80001000, 0x00401040, 0x80400040, - 0x80001000, 0x00001040, 0x00400000, 0x80401000, - 0x00000040, 0x00400000, 0x00001000, 0x00401040 - ); - - /** - * Pre-permuted S-box5 - * - * @var array - * @access private - */ - var $sbox5 = array( - 0x00000080, 0x01040080, 0x01040000, 0x21000080, - 0x00040000, 0x00000080, 0x20000000, 0x01040000, - 0x20040080, 0x00040000, 0x01000080, 0x20040080, - 0x21000080, 0x21040000, 0x00040080, 0x20000000, - 0x01000000, 0x20040000, 0x20040000, 0x00000000, - 0x20000080, 0x21040080, 0x21040080, 0x01000080, - 0x21040000, 0x20000080, 0x00000000, 0x21000000, - 0x01040080, 0x01000000, 0x21000000, 0x00040080, - 0x00040000, 0x21000080, 0x00000080, 0x01000000, - 0x20000000, 0x01040000, 0x21000080, 0x20040080, - 0x01000080, 0x20000000, 0x21040000, 0x01040080, - 0x20040080, 0x00000080, 0x01000000, 0x21040000, - 0x21040080, 0x00040080, 0x21000000, 0x21040080, - 0x01040000, 0x00000000, 0x20040000, 0x21000000, - 0x00040080, 0x01000080, 0x20000080, 0x00040000, - 0x00000000, 0x20040000, 0x01040080, 0x20000080 - ); - - /** - * Pre-permuted S-box6 - * - * @var array - * @access private - */ - var $sbox6 = array( - 0x10000008, 0x10200000, 0x00002000, 0x10202008, - 0x10200000, 0x00000008, 0x10202008, 0x00200000, - 0x10002000, 0x00202008, 0x00200000, 0x10000008, - 0x00200008, 0x10002000, 0x10000000, 0x00002008, - 0x00000000, 0x00200008, 0x10002008, 0x00002000, - 0x00202000, 0x10002008, 0x00000008, 0x10200008, - 0x10200008, 0x00000000, 0x00202008, 0x10202000, - 0x00002008, 0x00202000, 0x10202000, 0x10000000, - 0x10002000, 0x00000008, 0x10200008, 0x00202000, - 0x10202008, 0x00200000, 0x00002008, 0x10000008, - 0x00200000, 0x10002000, 0x10000000, 0x00002008, - 0x10000008, 0x10202008, 0x00202000, 0x10200000, - 0x00202008, 0x10202000, 0x00000000, 0x10200008, - 0x00000008, 0x00002000, 0x10200000, 0x00202008, - 0x00002000, 0x00200008, 0x10002008, 0x00000000, - 0x10202000, 0x10000000, 0x00200008, 0x10002008 - ); - - /** - * Pre-permuted S-box7 - * - * @var array - * @access private - */ - var $sbox7 = array( - 0x00100000, 0x02100001, 0x02000401, 0x00000000, - 0x00000400, 0x02000401, 0x00100401, 0x02100400, - 0x02100401, 0x00100000, 0x00000000, 0x02000001, - 0x00000001, 0x02000000, 0x02100001, 0x00000401, - 0x02000400, 0x00100401, 0x00100001, 0x02000400, - 0x02000001, 0x02100000, 0x02100400, 0x00100001, - 0x02100000, 0x00000400, 0x00000401, 0x02100401, - 0x00100400, 0x00000001, 0x02000000, 0x00100400, - 0x02000000, 0x00100400, 0x00100000, 0x02000401, - 0x02000401, 0x02100001, 0x02100001, 0x00000001, - 0x00100001, 0x02000000, 0x02000400, 0x00100000, - 0x02100400, 0x00000401, 0x00100401, 0x02100400, - 0x00000401, 0x02000001, 0x02100401, 0x02100000, - 0x00100400, 0x00000000, 0x00000001, 0x02100401, - 0x00000000, 0x00100401, 0x02100000, 0x00000400, - 0x02000001, 0x02000400, 0x00000400, 0x00100001 - ); - - /** - * Pre-permuted S-box8 - * - * @var array - * @access private - */ - var $sbox8 = array( - 0x08000820, 0x00000800, 0x00020000, 0x08020820, - 0x08000000, 0x08000820, 0x00000020, 0x08000000, - 0x00020020, 0x08020000, 0x08020820, 0x00020800, - 0x08020800, 0x00020820, 0x00000800, 0x00000020, - 0x08020000, 0x08000020, 0x08000800, 0x00000820, - 0x00020800, 0x00020020, 0x08020020, 0x08020800, - 0x00000820, 0x00000000, 0x00000000, 0x08020020, - 0x08000020, 0x08000800, 0x00020820, 0x00020000, - 0x00020820, 0x00020000, 0x08020800, 0x00000800, - 0x00000020, 0x08020020, 0x00000800, 0x00020820, - 0x08000800, 0x00000020, 0x08000020, 0x08020000, - 0x08020020, 0x08000000, 0x00020000, 0x08000820, - 0x00000000, 0x08020820, 0x00020020, 0x08000020, - 0x08020000, 0x08000800, 0x08000820, 0x00000000, - 0x08020820, 0x00020800, 0x00020800, 0x00000820, - 0x00000820, 0x00020020, 0x08000000, 0x08020800 - ); - - /** - * Test for engine validity - * - * This is mainly just a wrapper to set things up for \phpseclib\Crypt\Base::isValidEngine() - * - * @see \phpseclib\Crypt\Base::isValidEngine() - * @param int $engine - * @access public - * @return bool - */ - function isValidEngine($engine) - { - if ($this->key_length_max == 8) { - if ($engine == self::ENGINE_OPENSSL) { - $this->cipher_name_openssl_ecb = 'des-ecb'; - $this->cipher_name_openssl = 'des-' . $this->_openssl_translate_mode(); - } - } - - return parent::isValidEngine($engine); - } - - /** - * Sets the key. - * - * Keys can be of any length. DES, itself, uses 64-bit keys (eg. strlen($key) == 8), however, we - * only use the first eight, if $key has more then eight characters in it, and pad $key with the - * null byte if it is less then eight characters long. - * - * DES also requires that every eighth bit be a parity bit, however, we'll ignore that. - * - * If the key is not explicitly set, it'll be assumed to be all zero's. - * - * @see \phpseclib\Crypt\Base::setKey() - * @access public - * @param string $key - */ - function setKey($key) - { - // We check/cut here only up to max length of the key. - // Key padding to the proper length will be done in _setupKey() - if (strlen($key) > $this->key_length_max) { - $key = substr($key, 0, $this->key_length_max); - } - - // Sets the key - parent::setKey($key); - } - - /** - * Encrypts a block - * - * @see \phpseclib\Crypt\Base::_encryptBlock() - * @see \phpseclib\Crypt\Base::encrypt() - * @see self::encrypt() - * @access private - * @param string $in - * @return string - */ - function _encryptBlock($in) - { - return $this->_processBlock($in, self::ENCRYPT); - } - - /** - * Decrypts a block - * - * @see \phpseclib\Crypt\Base::_decryptBlock() - * @see \phpseclib\Crypt\Base::decrypt() - * @see self::decrypt() - * @access private - * @param string $in - * @return string - */ - function _decryptBlock($in) - { - return $this->_processBlock($in, self::DECRYPT); - } - - /** - * Encrypts or decrypts a 64-bit block - * - * $mode should be either self::ENCRYPT or self::DECRYPT. See - * {@link http://en.wikipedia.org/wiki/Image:Feistel.png Feistel.png} to get a general - * idea of what this function does. - * - * @see self::_encryptBlock() - * @see self::_decryptBlock() - * @access private - * @param string $block - * @param int $mode - * @return string - */ - function _processBlock($block, $mode) - { - static $sbox1, $sbox2, $sbox3, $sbox4, $sbox5, $sbox6, $sbox7, $sbox8, $shuffleip, $shuffleinvip; - if (!$sbox1) { - $sbox1 = array_map("intval", $this->sbox1); - $sbox2 = array_map("intval", $this->sbox2); - $sbox3 = array_map("intval", $this->sbox3); - $sbox4 = array_map("intval", $this->sbox4); - $sbox5 = array_map("intval", $this->sbox5); - $sbox6 = array_map("intval", $this->sbox6); - $sbox7 = array_map("intval", $this->sbox7); - $sbox8 = array_map("intval", $this->sbox8); - /* Merge $shuffle with $[inv]ipmap */ - for ($i = 0; $i < 256; ++$i) { - $shuffleip[] = $this->shuffle[$this->ipmap[$i]]; - $shuffleinvip[] = $this->shuffle[$this->invipmap[$i]]; - } - } - - $keys = $this->keys[$mode]; - $ki = -1; - - // Do the initial IP permutation. - $t = unpack('Nl/Nr', $block); - list($l, $r) = array($t['l'], $t['r']); - $block = ($shuffleip[ $r & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | - ($shuffleip[($r >> 8) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | - ($shuffleip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | - ($shuffleip[($r >> 24) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") | - ($shuffleip[ $l & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | - ($shuffleip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | - ($shuffleip[($l >> 16) & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | - ($shuffleip[($l >> 24) & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); - - // Extract L0 and R0. - $t = unpack('Nl/Nr', $block); - list($l, $r) = array($t['l'], $t['r']); - - for ($des_round = 0; $des_round < $this->des_rounds; ++$des_round) { - // Perform the 16 steps. - for ($i = 0; $i < 16; $i++) { - // start of "the Feistel (F) function" - see the following URL: - // http://en.wikipedia.org/wiki/Image:Data_Encryption_Standard_InfoBox_Diagram.png - // Merge key schedule. - $b1 = (($r >> 3) & 0x1FFFFFFF) ^ ($r << 29) ^ $keys[++$ki]; - $b2 = (($r >> 31) & 0x00000001) ^ ($r << 1) ^ $keys[++$ki]; - - // S-box indexing. - $t = $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] ^ - $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^ - $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ - $sbox7[ $b1 & 0x3F] ^ $sbox8[ $b2 & 0x3F] ^ $l; - // end of "the Feistel (F) function" - - $l = $r; - $r = $t; - } - - // Last step should not permute L & R. - $t = $l; - $l = $r; - $r = $t; - } - - // Perform the inverse IP permutation. - return ($shuffleinvip[($r >> 24) & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | - ($shuffleinvip[($l >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | - ($shuffleinvip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | - ($shuffleinvip[($l >> 16) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") | - ($shuffleinvip[($r >> 8) & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | - ($shuffleinvip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | - ($shuffleinvip[ $r & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | - ($shuffleinvip[ $l & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); - } - - /** - * Creates the key schedule - * - * @see \phpseclib\Crypt\Base::_setupKey() - * @access private - */ - function _setupKey() - { - if (isset($this->kl['key']) && $this->key === $this->kl['key'] && $this->des_rounds === $this->kl['des_rounds']) { - // already expanded - return; - } - $this->kl = array('key' => $this->key, 'des_rounds' => $this->des_rounds); - - static $shifts = array( // number of key bits shifted per round - 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 - ); - - static $pc1map = array( - 0x00, 0x00, 0x08, 0x08, 0x04, 0x04, 0x0C, 0x0C, - 0x02, 0x02, 0x0A, 0x0A, 0x06, 0x06, 0x0E, 0x0E, - 0x10, 0x10, 0x18, 0x18, 0x14, 0x14, 0x1C, 0x1C, - 0x12, 0x12, 0x1A, 0x1A, 0x16, 0x16, 0x1E, 0x1E, - 0x20, 0x20, 0x28, 0x28, 0x24, 0x24, 0x2C, 0x2C, - 0x22, 0x22, 0x2A, 0x2A, 0x26, 0x26, 0x2E, 0x2E, - 0x30, 0x30, 0x38, 0x38, 0x34, 0x34, 0x3C, 0x3C, - 0x32, 0x32, 0x3A, 0x3A, 0x36, 0x36, 0x3E, 0x3E, - 0x40, 0x40, 0x48, 0x48, 0x44, 0x44, 0x4C, 0x4C, - 0x42, 0x42, 0x4A, 0x4A, 0x46, 0x46, 0x4E, 0x4E, - 0x50, 0x50, 0x58, 0x58, 0x54, 0x54, 0x5C, 0x5C, - 0x52, 0x52, 0x5A, 0x5A, 0x56, 0x56, 0x5E, 0x5E, - 0x60, 0x60, 0x68, 0x68, 0x64, 0x64, 0x6C, 0x6C, - 0x62, 0x62, 0x6A, 0x6A, 0x66, 0x66, 0x6E, 0x6E, - 0x70, 0x70, 0x78, 0x78, 0x74, 0x74, 0x7C, 0x7C, - 0x72, 0x72, 0x7A, 0x7A, 0x76, 0x76, 0x7E, 0x7E, - 0x80, 0x80, 0x88, 0x88, 0x84, 0x84, 0x8C, 0x8C, - 0x82, 0x82, 0x8A, 0x8A, 0x86, 0x86, 0x8E, 0x8E, - 0x90, 0x90, 0x98, 0x98, 0x94, 0x94, 0x9C, 0x9C, - 0x92, 0x92, 0x9A, 0x9A, 0x96, 0x96, 0x9E, 0x9E, - 0xA0, 0xA0, 0xA8, 0xA8, 0xA4, 0xA4, 0xAC, 0xAC, - 0xA2, 0xA2, 0xAA, 0xAA, 0xA6, 0xA6, 0xAE, 0xAE, - 0xB0, 0xB0, 0xB8, 0xB8, 0xB4, 0xB4, 0xBC, 0xBC, - 0xB2, 0xB2, 0xBA, 0xBA, 0xB6, 0xB6, 0xBE, 0xBE, - 0xC0, 0xC0, 0xC8, 0xC8, 0xC4, 0xC4, 0xCC, 0xCC, - 0xC2, 0xC2, 0xCA, 0xCA, 0xC6, 0xC6, 0xCE, 0xCE, - 0xD0, 0xD0, 0xD8, 0xD8, 0xD4, 0xD4, 0xDC, 0xDC, - 0xD2, 0xD2, 0xDA, 0xDA, 0xD6, 0xD6, 0xDE, 0xDE, - 0xE0, 0xE0, 0xE8, 0xE8, 0xE4, 0xE4, 0xEC, 0xEC, - 0xE2, 0xE2, 0xEA, 0xEA, 0xE6, 0xE6, 0xEE, 0xEE, - 0xF0, 0xF0, 0xF8, 0xF8, 0xF4, 0xF4, 0xFC, 0xFC, - 0xF2, 0xF2, 0xFA, 0xFA, 0xF6, 0xF6, 0xFE, 0xFE - ); - - // Mapping tables for the PC-2 transformation. - static $pc2mapc1 = array( - 0x00000000, 0x00000400, 0x00200000, 0x00200400, - 0x00000001, 0x00000401, 0x00200001, 0x00200401, - 0x02000000, 0x02000400, 0x02200000, 0x02200400, - 0x02000001, 0x02000401, 0x02200001, 0x02200401 - ); - static $pc2mapc2 = array( - 0x00000000, 0x00000800, 0x08000000, 0x08000800, - 0x00010000, 0x00010800, 0x08010000, 0x08010800, - 0x00000000, 0x00000800, 0x08000000, 0x08000800, - 0x00010000, 0x00010800, 0x08010000, 0x08010800, - 0x00000100, 0x00000900, 0x08000100, 0x08000900, - 0x00010100, 0x00010900, 0x08010100, 0x08010900, - 0x00000100, 0x00000900, 0x08000100, 0x08000900, - 0x00010100, 0x00010900, 0x08010100, 0x08010900, - 0x00000010, 0x00000810, 0x08000010, 0x08000810, - 0x00010010, 0x00010810, 0x08010010, 0x08010810, - 0x00000010, 0x00000810, 0x08000010, 0x08000810, - 0x00010010, 0x00010810, 0x08010010, 0x08010810, - 0x00000110, 0x00000910, 0x08000110, 0x08000910, - 0x00010110, 0x00010910, 0x08010110, 0x08010910, - 0x00000110, 0x00000910, 0x08000110, 0x08000910, - 0x00010110, 0x00010910, 0x08010110, 0x08010910, - 0x00040000, 0x00040800, 0x08040000, 0x08040800, - 0x00050000, 0x00050800, 0x08050000, 0x08050800, - 0x00040000, 0x00040800, 0x08040000, 0x08040800, - 0x00050000, 0x00050800, 0x08050000, 0x08050800, - 0x00040100, 0x00040900, 0x08040100, 0x08040900, - 0x00050100, 0x00050900, 0x08050100, 0x08050900, - 0x00040100, 0x00040900, 0x08040100, 0x08040900, - 0x00050100, 0x00050900, 0x08050100, 0x08050900, - 0x00040010, 0x00040810, 0x08040010, 0x08040810, - 0x00050010, 0x00050810, 0x08050010, 0x08050810, - 0x00040010, 0x00040810, 0x08040010, 0x08040810, - 0x00050010, 0x00050810, 0x08050010, 0x08050810, - 0x00040110, 0x00040910, 0x08040110, 0x08040910, - 0x00050110, 0x00050910, 0x08050110, 0x08050910, - 0x00040110, 0x00040910, 0x08040110, 0x08040910, - 0x00050110, 0x00050910, 0x08050110, 0x08050910, - 0x01000000, 0x01000800, 0x09000000, 0x09000800, - 0x01010000, 0x01010800, 0x09010000, 0x09010800, - 0x01000000, 0x01000800, 0x09000000, 0x09000800, - 0x01010000, 0x01010800, 0x09010000, 0x09010800, - 0x01000100, 0x01000900, 0x09000100, 0x09000900, - 0x01010100, 0x01010900, 0x09010100, 0x09010900, - 0x01000100, 0x01000900, 0x09000100, 0x09000900, - 0x01010100, 0x01010900, 0x09010100, 0x09010900, - 0x01000010, 0x01000810, 0x09000010, 0x09000810, - 0x01010010, 0x01010810, 0x09010010, 0x09010810, - 0x01000010, 0x01000810, 0x09000010, 0x09000810, - 0x01010010, 0x01010810, 0x09010010, 0x09010810, - 0x01000110, 0x01000910, 0x09000110, 0x09000910, - 0x01010110, 0x01010910, 0x09010110, 0x09010910, - 0x01000110, 0x01000910, 0x09000110, 0x09000910, - 0x01010110, 0x01010910, 0x09010110, 0x09010910, - 0x01040000, 0x01040800, 0x09040000, 0x09040800, - 0x01050000, 0x01050800, 0x09050000, 0x09050800, - 0x01040000, 0x01040800, 0x09040000, 0x09040800, - 0x01050000, 0x01050800, 0x09050000, 0x09050800, - 0x01040100, 0x01040900, 0x09040100, 0x09040900, - 0x01050100, 0x01050900, 0x09050100, 0x09050900, - 0x01040100, 0x01040900, 0x09040100, 0x09040900, - 0x01050100, 0x01050900, 0x09050100, 0x09050900, - 0x01040010, 0x01040810, 0x09040010, 0x09040810, - 0x01050010, 0x01050810, 0x09050010, 0x09050810, - 0x01040010, 0x01040810, 0x09040010, 0x09040810, - 0x01050010, 0x01050810, 0x09050010, 0x09050810, - 0x01040110, 0x01040910, 0x09040110, 0x09040910, - 0x01050110, 0x01050910, 0x09050110, 0x09050910, - 0x01040110, 0x01040910, 0x09040110, 0x09040910, - 0x01050110, 0x01050910, 0x09050110, 0x09050910 - ); - static $pc2mapc3 = array( - 0x00000000, 0x00000004, 0x00001000, 0x00001004, - 0x00000000, 0x00000004, 0x00001000, 0x00001004, - 0x10000000, 0x10000004, 0x10001000, 0x10001004, - 0x10000000, 0x10000004, 0x10001000, 0x10001004, - 0x00000020, 0x00000024, 0x00001020, 0x00001024, - 0x00000020, 0x00000024, 0x00001020, 0x00001024, - 0x10000020, 0x10000024, 0x10001020, 0x10001024, - 0x10000020, 0x10000024, 0x10001020, 0x10001024, - 0x00080000, 0x00080004, 0x00081000, 0x00081004, - 0x00080000, 0x00080004, 0x00081000, 0x00081004, - 0x10080000, 0x10080004, 0x10081000, 0x10081004, - 0x10080000, 0x10080004, 0x10081000, 0x10081004, - 0x00080020, 0x00080024, 0x00081020, 0x00081024, - 0x00080020, 0x00080024, 0x00081020, 0x00081024, - 0x10080020, 0x10080024, 0x10081020, 0x10081024, - 0x10080020, 0x10080024, 0x10081020, 0x10081024, - 0x20000000, 0x20000004, 0x20001000, 0x20001004, - 0x20000000, 0x20000004, 0x20001000, 0x20001004, - 0x30000000, 0x30000004, 0x30001000, 0x30001004, - 0x30000000, 0x30000004, 0x30001000, 0x30001004, - 0x20000020, 0x20000024, 0x20001020, 0x20001024, - 0x20000020, 0x20000024, 0x20001020, 0x20001024, - 0x30000020, 0x30000024, 0x30001020, 0x30001024, - 0x30000020, 0x30000024, 0x30001020, 0x30001024, - 0x20080000, 0x20080004, 0x20081000, 0x20081004, - 0x20080000, 0x20080004, 0x20081000, 0x20081004, - 0x30080000, 0x30080004, 0x30081000, 0x30081004, - 0x30080000, 0x30080004, 0x30081000, 0x30081004, - 0x20080020, 0x20080024, 0x20081020, 0x20081024, - 0x20080020, 0x20080024, 0x20081020, 0x20081024, - 0x30080020, 0x30080024, 0x30081020, 0x30081024, - 0x30080020, 0x30080024, 0x30081020, 0x30081024, - 0x00000002, 0x00000006, 0x00001002, 0x00001006, - 0x00000002, 0x00000006, 0x00001002, 0x00001006, - 0x10000002, 0x10000006, 0x10001002, 0x10001006, - 0x10000002, 0x10000006, 0x10001002, 0x10001006, - 0x00000022, 0x00000026, 0x00001022, 0x00001026, - 0x00000022, 0x00000026, 0x00001022, 0x00001026, - 0x10000022, 0x10000026, 0x10001022, 0x10001026, - 0x10000022, 0x10000026, 0x10001022, 0x10001026, - 0x00080002, 0x00080006, 0x00081002, 0x00081006, - 0x00080002, 0x00080006, 0x00081002, 0x00081006, - 0x10080002, 0x10080006, 0x10081002, 0x10081006, - 0x10080002, 0x10080006, 0x10081002, 0x10081006, - 0x00080022, 0x00080026, 0x00081022, 0x00081026, - 0x00080022, 0x00080026, 0x00081022, 0x00081026, - 0x10080022, 0x10080026, 0x10081022, 0x10081026, - 0x10080022, 0x10080026, 0x10081022, 0x10081026, - 0x20000002, 0x20000006, 0x20001002, 0x20001006, - 0x20000002, 0x20000006, 0x20001002, 0x20001006, - 0x30000002, 0x30000006, 0x30001002, 0x30001006, - 0x30000002, 0x30000006, 0x30001002, 0x30001006, - 0x20000022, 0x20000026, 0x20001022, 0x20001026, - 0x20000022, 0x20000026, 0x20001022, 0x20001026, - 0x30000022, 0x30000026, 0x30001022, 0x30001026, - 0x30000022, 0x30000026, 0x30001022, 0x30001026, - 0x20080002, 0x20080006, 0x20081002, 0x20081006, - 0x20080002, 0x20080006, 0x20081002, 0x20081006, - 0x30080002, 0x30080006, 0x30081002, 0x30081006, - 0x30080002, 0x30080006, 0x30081002, 0x30081006, - 0x20080022, 0x20080026, 0x20081022, 0x20081026, - 0x20080022, 0x20080026, 0x20081022, 0x20081026, - 0x30080022, 0x30080026, 0x30081022, 0x30081026, - 0x30080022, 0x30080026, 0x30081022, 0x30081026 - ); - static $pc2mapc4 = array( - 0x00000000, 0x00100000, 0x00000008, 0x00100008, - 0x00000200, 0x00100200, 0x00000208, 0x00100208, - 0x00000000, 0x00100000, 0x00000008, 0x00100008, - 0x00000200, 0x00100200, 0x00000208, 0x00100208, - 0x04000000, 0x04100000, 0x04000008, 0x04100008, - 0x04000200, 0x04100200, 0x04000208, 0x04100208, - 0x04000000, 0x04100000, 0x04000008, 0x04100008, - 0x04000200, 0x04100200, 0x04000208, 0x04100208, - 0x00002000, 0x00102000, 0x00002008, 0x00102008, - 0x00002200, 0x00102200, 0x00002208, 0x00102208, - 0x00002000, 0x00102000, 0x00002008, 0x00102008, - 0x00002200, 0x00102200, 0x00002208, 0x00102208, - 0x04002000, 0x04102000, 0x04002008, 0x04102008, - 0x04002200, 0x04102200, 0x04002208, 0x04102208, - 0x04002000, 0x04102000, 0x04002008, 0x04102008, - 0x04002200, 0x04102200, 0x04002208, 0x04102208, - 0x00000000, 0x00100000, 0x00000008, 0x00100008, - 0x00000200, 0x00100200, 0x00000208, 0x00100208, - 0x00000000, 0x00100000, 0x00000008, 0x00100008, - 0x00000200, 0x00100200, 0x00000208, 0x00100208, - 0x04000000, 0x04100000, 0x04000008, 0x04100008, - 0x04000200, 0x04100200, 0x04000208, 0x04100208, - 0x04000000, 0x04100000, 0x04000008, 0x04100008, - 0x04000200, 0x04100200, 0x04000208, 0x04100208, - 0x00002000, 0x00102000, 0x00002008, 0x00102008, - 0x00002200, 0x00102200, 0x00002208, 0x00102208, - 0x00002000, 0x00102000, 0x00002008, 0x00102008, - 0x00002200, 0x00102200, 0x00002208, 0x00102208, - 0x04002000, 0x04102000, 0x04002008, 0x04102008, - 0x04002200, 0x04102200, 0x04002208, 0x04102208, - 0x04002000, 0x04102000, 0x04002008, 0x04102008, - 0x04002200, 0x04102200, 0x04002208, 0x04102208, - 0x00020000, 0x00120000, 0x00020008, 0x00120008, - 0x00020200, 0x00120200, 0x00020208, 0x00120208, - 0x00020000, 0x00120000, 0x00020008, 0x00120008, - 0x00020200, 0x00120200, 0x00020208, 0x00120208, - 0x04020000, 0x04120000, 0x04020008, 0x04120008, - 0x04020200, 0x04120200, 0x04020208, 0x04120208, - 0x04020000, 0x04120000, 0x04020008, 0x04120008, - 0x04020200, 0x04120200, 0x04020208, 0x04120208, - 0x00022000, 0x00122000, 0x00022008, 0x00122008, - 0x00022200, 0x00122200, 0x00022208, 0x00122208, - 0x00022000, 0x00122000, 0x00022008, 0x00122008, - 0x00022200, 0x00122200, 0x00022208, 0x00122208, - 0x04022000, 0x04122000, 0x04022008, 0x04122008, - 0x04022200, 0x04122200, 0x04022208, 0x04122208, - 0x04022000, 0x04122000, 0x04022008, 0x04122008, - 0x04022200, 0x04122200, 0x04022208, 0x04122208, - 0x00020000, 0x00120000, 0x00020008, 0x00120008, - 0x00020200, 0x00120200, 0x00020208, 0x00120208, - 0x00020000, 0x00120000, 0x00020008, 0x00120008, - 0x00020200, 0x00120200, 0x00020208, 0x00120208, - 0x04020000, 0x04120000, 0x04020008, 0x04120008, - 0x04020200, 0x04120200, 0x04020208, 0x04120208, - 0x04020000, 0x04120000, 0x04020008, 0x04120008, - 0x04020200, 0x04120200, 0x04020208, 0x04120208, - 0x00022000, 0x00122000, 0x00022008, 0x00122008, - 0x00022200, 0x00122200, 0x00022208, 0x00122208, - 0x00022000, 0x00122000, 0x00022008, 0x00122008, - 0x00022200, 0x00122200, 0x00022208, 0x00122208, - 0x04022000, 0x04122000, 0x04022008, 0x04122008, - 0x04022200, 0x04122200, 0x04022208, 0x04122208, - 0x04022000, 0x04122000, 0x04022008, 0x04122008, - 0x04022200, 0x04122200, 0x04022208, 0x04122208 - ); - static $pc2mapd1 = array( - 0x00000000, 0x00000001, 0x08000000, 0x08000001, - 0x00200000, 0x00200001, 0x08200000, 0x08200001, - 0x00000002, 0x00000003, 0x08000002, 0x08000003, - 0x00200002, 0x00200003, 0x08200002, 0x08200003 - ); - static $pc2mapd2 = array( - 0x00000000, 0x00100000, 0x00000800, 0x00100800, - 0x00000000, 0x00100000, 0x00000800, 0x00100800, - 0x04000000, 0x04100000, 0x04000800, 0x04100800, - 0x04000000, 0x04100000, 0x04000800, 0x04100800, - 0x00000004, 0x00100004, 0x00000804, 0x00100804, - 0x00000004, 0x00100004, 0x00000804, 0x00100804, - 0x04000004, 0x04100004, 0x04000804, 0x04100804, - 0x04000004, 0x04100004, 0x04000804, 0x04100804, - 0x00000000, 0x00100000, 0x00000800, 0x00100800, - 0x00000000, 0x00100000, 0x00000800, 0x00100800, - 0x04000000, 0x04100000, 0x04000800, 0x04100800, - 0x04000000, 0x04100000, 0x04000800, 0x04100800, - 0x00000004, 0x00100004, 0x00000804, 0x00100804, - 0x00000004, 0x00100004, 0x00000804, 0x00100804, - 0x04000004, 0x04100004, 0x04000804, 0x04100804, - 0x04000004, 0x04100004, 0x04000804, 0x04100804, - 0x00000200, 0x00100200, 0x00000A00, 0x00100A00, - 0x00000200, 0x00100200, 0x00000A00, 0x00100A00, - 0x04000200, 0x04100200, 0x04000A00, 0x04100A00, - 0x04000200, 0x04100200, 0x04000A00, 0x04100A00, - 0x00000204, 0x00100204, 0x00000A04, 0x00100A04, - 0x00000204, 0x00100204, 0x00000A04, 0x00100A04, - 0x04000204, 0x04100204, 0x04000A04, 0x04100A04, - 0x04000204, 0x04100204, 0x04000A04, 0x04100A04, - 0x00000200, 0x00100200, 0x00000A00, 0x00100A00, - 0x00000200, 0x00100200, 0x00000A00, 0x00100A00, - 0x04000200, 0x04100200, 0x04000A00, 0x04100A00, - 0x04000200, 0x04100200, 0x04000A00, 0x04100A00, - 0x00000204, 0x00100204, 0x00000A04, 0x00100A04, - 0x00000204, 0x00100204, 0x00000A04, 0x00100A04, - 0x04000204, 0x04100204, 0x04000A04, 0x04100A04, - 0x04000204, 0x04100204, 0x04000A04, 0x04100A04, - 0x00020000, 0x00120000, 0x00020800, 0x00120800, - 0x00020000, 0x00120000, 0x00020800, 0x00120800, - 0x04020000, 0x04120000, 0x04020800, 0x04120800, - 0x04020000, 0x04120000, 0x04020800, 0x04120800, - 0x00020004, 0x00120004, 0x00020804, 0x00120804, - 0x00020004, 0x00120004, 0x00020804, 0x00120804, - 0x04020004, 0x04120004, 0x04020804, 0x04120804, - 0x04020004, 0x04120004, 0x04020804, 0x04120804, - 0x00020000, 0x00120000, 0x00020800, 0x00120800, - 0x00020000, 0x00120000, 0x00020800, 0x00120800, - 0x04020000, 0x04120000, 0x04020800, 0x04120800, - 0x04020000, 0x04120000, 0x04020800, 0x04120800, - 0x00020004, 0x00120004, 0x00020804, 0x00120804, - 0x00020004, 0x00120004, 0x00020804, 0x00120804, - 0x04020004, 0x04120004, 0x04020804, 0x04120804, - 0x04020004, 0x04120004, 0x04020804, 0x04120804, - 0x00020200, 0x00120200, 0x00020A00, 0x00120A00, - 0x00020200, 0x00120200, 0x00020A00, 0x00120A00, - 0x04020200, 0x04120200, 0x04020A00, 0x04120A00, - 0x04020200, 0x04120200, 0x04020A00, 0x04120A00, - 0x00020204, 0x00120204, 0x00020A04, 0x00120A04, - 0x00020204, 0x00120204, 0x00020A04, 0x00120A04, - 0x04020204, 0x04120204, 0x04020A04, 0x04120A04, - 0x04020204, 0x04120204, 0x04020A04, 0x04120A04, - 0x00020200, 0x00120200, 0x00020A00, 0x00120A00, - 0x00020200, 0x00120200, 0x00020A00, 0x00120A00, - 0x04020200, 0x04120200, 0x04020A00, 0x04120A00, - 0x04020200, 0x04120200, 0x04020A00, 0x04120A00, - 0x00020204, 0x00120204, 0x00020A04, 0x00120A04, - 0x00020204, 0x00120204, 0x00020A04, 0x00120A04, - 0x04020204, 0x04120204, 0x04020A04, 0x04120A04, - 0x04020204, 0x04120204, 0x04020A04, 0x04120A04 - ); - static $pc2mapd3 = array( - 0x00000000, 0x00010000, 0x02000000, 0x02010000, - 0x00000020, 0x00010020, 0x02000020, 0x02010020, - 0x00040000, 0x00050000, 0x02040000, 0x02050000, - 0x00040020, 0x00050020, 0x02040020, 0x02050020, - 0x00002000, 0x00012000, 0x02002000, 0x02012000, - 0x00002020, 0x00012020, 0x02002020, 0x02012020, - 0x00042000, 0x00052000, 0x02042000, 0x02052000, - 0x00042020, 0x00052020, 0x02042020, 0x02052020, - 0x00000000, 0x00010000, 0x02000000, 0x02010000, - 0x00000020, 0x00010020, 0x02000020, 0x02010020, - 0x00040000, 0x00050000, 0x02040000, 0x02050000, - 0x00040020, 0x00050020, 0x02040020, 0x02050020, - 0x00002000, 0x00012000, 0x02002000, 0x02012000, - 0x00002020, 0x00012020, 0x02002020, 0x02012020, - 0x00042000, 0x00052000, 0x02042000, 0x02052000, - 0x00042020, 0x00052020, 0x02042020, 0x02052020, - 0x00000010, 0x00010010, 0x02000010, 0x02010010, - 0x00000030, 0x00010030, 0x02000030, 0x02010030, - 0x00040010, 0x00050010, 0x02040010, 0x02050010, - 0x00040030, 0x00050030, 0x02040030, 0x02050030, - 0x00002010, 0x00012010, 0x02002010, 0x02012010, - 0x00002030, 0x00012030, 0x02002030, 0x02012030, - 0x00042010, 0x00052010, 0x02042010, 0x02052010, - 0x00042030, 0x00052030, 0x02042030, 0x02052030, - 0x00000010, 0x00010010, 0x02000010, 0x02010010, - 0x00000030, 0x00010030, 0x02000030, 0x02010030, - 0x00040010, 0x00050010, 0x02040010, 0x02050010, - 0x00040030, 0x00050030, 0x02040030, 0x02050030, - 0x00002010, 0x00012010, 0x02002010, 0x02012010, - 0x00002030, 0x00012030, 0x02002030, 0x02012030, - 0x00042010, 0x00052010, 0x02042010, 0x02052010, - 0x00042030, 0x00052030, 0x02042030, 0x02052030, - 0x20000000, 0x20010000, 0x22000000, 0x22010000, - 0x20000020, 0x20010020, 0x22000020, 0x22010020, - 0x20040000, 0x20050000, 0x22040000, 0x22050000, - 0x20040020, 0x20050020, 0x22040020, 0x22050020, - 0x20002000, 0x20012000, 0x22002000, 0x22012000, - 0x20002020, 0x20012020, 0x22002020, 0x22012020, - 0x20042000, 0x20052000, 0x22042000, 0x22052000, - 0x20042020, 0x20052020, 0x22042020, 0x22052020, - 0x20000000, 0x20010000, 0x22000000, 0x22010000, - 0x20000020, 0x20010020, 0x22000020, 0x22010020, - 0x20040000, 0x20050000, 0x22040000, 0x22050000, - 0x20040020, 0x20050020, 0x22040020, 0x22050020, - 0x20002000, 0x20012000, 0x22002000, 0x22012000, - 0x20002020, 0x20012020, 0x22002020, 0x22012020, - 0x20042000, 0x20052000, 0x22042000, 0x22052000, - 0x20042020, 0x20052020, 0x22042020, 0x22052020, - 0x20000010, 0x20010010, 0x22000010, 0x22010010, - 0x20000030, 0x20010030, 0x22000030, 0x22010030, - 0x20040010, 0x20050010, 0x22040010, 0x22050010, - 0x20040030, 0x20050030, 0x22040030, 0x22050030, - 0x20002010, 0x20012010, 0x22002010, 0x22012010, - 0x20002030, 0x20012030, 0x22002030, 0x22012030, - 0x20042010, 0x20052010, 0x22042010, 0x22052010, - 0x20042030, 0x20052030, 0x22042030, 0x22052030, - 0x20000010, 0x20010010, 0x22000010, 0x22010010, - 0x20000030, 0x20010030, 0x22000030, 0x22010030, - 0x20040010, 0x20050010, 0x22040010, 0x22050010, - 0x20040030, 0x20050030, 0x22040030, 0x22050030, - 0x20002010, 0x20012010, 0x22002010, 0x22012010, - 0x20002030, 0x20012030, 0x22002030, 0x22012030, - 0x20042010, 0x20052010, 0x22042010, 0x22052010, - 0x20042030, 0x20052030, 0x22042030, 0x22052030 - ); - static $pc2mapd4 = array( - 0x00000000, 0x00000400, 0x01000000, 0x01000400, - 0x00000000, 0x00000400, 0x01000000, 0x01000400, - 0x00000100, 0x00000500, 0x01000100, 0x01000500, - 0x00000100, 0x00000500, 0x01000100, 0x01000500, - 0x10000000, 0x10000400, 0x11000000, 0x11000400, - 0x10000000, 0x10000400, 0x11000000, 0x11000400, - 0x10000100, 0x10000500, 0x11000100, 0x11000500, - 0x10000100, 0x10000500, 0x11000100, 0x11000500, - 0x00080000, 0x00080400, 0x01080000, 0x01080400, - 0x00080000, 0x00080400, 0x01080000, 0x01080400, - 0x00080100, 0x00080500, 0x01080100, 0x01080500, - 0x00080100, 0x00080500, 0x01080100, 0x01080500, - 0x10080000, 0x10080400, 0x11080000, 0x11080400, - 0x10080000, 0x10080400, 0x11080000, 0x11080400, - 0x10080100, 0x10080500, 0x11080100, 0x11080500, - 0x10080100, 0x10080500, 0x11080100, 0x11080500, - 0x00000008, 0x00000408, 0x01000008, 0x01000408, - 0x00000008, 0x00000408, 0x01000008, 0x01000408, - 0x00000108, 0x00000508, 0x01000108, 0x01000508, - 0x00000108, 0x00000508, 0x01000108, 0x01000508, - 0x10000008, 0x10000408, 0x11000008, 0x11000408, - 0x10000008, 0x10000408, 0x11000008, 0x11000408, - 0x10000108, 0x10000508, 0x11000108, 0x11000508, - 0x10000108, 0x10000508, 0x11000108, 0x11000508, - 0x00080008, 0x00080408, 0x01080008, 0x01080408, - 0x00080008, 0x00080408, 0x01080008, 0x01080408, - 0x00080108, 0x00080508, 0x01080108, 0x01080508, - 0x00080108, 0x00080508, 0x01080108, 0x01080508, - 0x10080008, 0x10080408, 0x11080008, 0x11080408, - 0x10080008, 0x10080408, 0x11080008, 0x11080408, - 0x10080108, 0x10080508, 0x11080108, 0x11080508, - 0x10080108, 0x10080508, 0x11080108, 0x11080508, - 0x00001000, 0x00001400, 0x01001000, 0x01001400, - 0x00001000, 0x00001400, 0x01001000, 0x01001400, - 0x00001100, 0x00001500, 0x01001100, 0x01001500, - 0x00001100, 0x00001500, 0x01001100, 0x01001500, - 0x10001000, 0x10001400, 0x11001000, 0x11001400, - 0x10001000, 0x10001400, 0x11001000, 0x11001400, - 0x10001100, 0x10001500, 0x11001100, 0x11001500, - 0x10001100, 0x10001500, 0x11001100, 0x11001500, - 0x00081000, 0x00081400, 0x01081000, 0x01081400, - 0x00081000, 0x00081400, 0x01081000, 0x01081400, - 0x00081100, 0x00081500, 0x01081100, 0x01081500, - 0x00081100, 0x00081500, 0x01081100, 0x01081500, - 0x10081000, 0x10081400, 0x11081000, 0x11081400, - 0x10081000, 0x10081400, 0x11081000, 0x11081400, - 0x10081100, 0x10081500, 0x11081100, 0x11081500, - 0x10081100, 0x10081500, 0x11081100, 0x11081500, - 0x00001008, 0x00001408, 0x01001008, 0x01001408, - 0x00001008, 0x00001408, 0x01001008, 0x01001408, - 0x00001108, 0x00001508, 0x01001108, 0x01001508, - 0x00001108, 0x00001508, 0x01001108, 0x01001508, - 0x10001008, 0x10001408, 0x11001008, 0x11001408, - 0x10001008, 0x10001408, 0x11001008, 0x11001408, - 0x10001108, 0x10001508, 0x11001108, 0x11001508, - 0x10001108, 0x10001508, 0x11001108, 0x11001508, - 0x00081008, 0x00081408, 0x01081008, 0x01081408, - 0x00081008, 0x00081408, 0x01081008, 0x01081408, - 0x00081108, 0x00081508, 0x01081108, 0x01081508, - 0x00081108, 0x00081508, 0x01081108, 0x01081508, - 0x10081008, 0x10081408, 0x11081008, 0x11081408, - 0x10081008, 0x10081408, 0x11081008, 0x11081408, - 0x10081108, 0x10081508, 0x11081108, 0x11081508, - 0x10081108, 0x10081508, 0x11081108, 0x11081508 - ); - - $keys = array(); - for ($des_round = 0; $des_round < $this->des_rounds; ++$des_round) { - // pad the key and remove extra characters as appropriate. - $key = str_pad(substr($this->key, $des_round * 8, 8), 8, "\0"); - - // Perform the PC/1 transformation and compute C and D. - $t = unpack('Nl/Nr', $key); - list($l, $r) = array($t['l'], $t['r']); - $key = ($this->shuffle[$pc1map[ $r & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x00") | - ($this->shuffle[$pc1map[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") | - ($this->shuffle[$pc1map[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x00") | - ($this->shuffle[$pc1map[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x00") | - ($this->shuffle[$pc1map[ $l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x00") | - ($this->shuffle[$pc1map[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x00") | - ($this->shuffle[$pc1map[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x00") | - ($this->shuffle[$pc1map[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x00"); - $key = unpack('Nc/Nd', $key); - $c = ( $key['c'] >> 4) & 0x0FFFFFFF; - $d = (($key['d'] >> 4) & 0x0FFFFFF0) | ($key['c'] & 0x0F); - - $keys[$des_round] = array( - self::ENCRYPT => array(), - self::DECRYPT => array_fill(0, 32, 0) - ); - for ($i = 0, $ki = 31; $i < 16; ++$i, $ki-= 2) { - $c <<= $shifts[$i]; - $c = ($c | ($c >> 28)) & 0x0FFFFFFF; - $d <<= $shifts[$i]; - $d = ($d | ($d >> 28)) & 0x0FFFFFFF; - - // Perform the PC-2 transformation. - $cp = $pc2mapc1[ $c >> 24 ] | $pc2mapc2[($c >> 16) & 0xFF] | - $pc2mapc3[($c >> 8) & 0xFF] | $pc2mapc4[ $c & 0xFF]; - $dp = $pc2mapd1[ $d >> 24 ] | $pc2mapd2[($d >> 16) & 0xFF] | - $pc2mapd3[($d >> 8) & 0xFF] | $pc2mapd4[ $d & 0xFF]; - - // Reorder: odd bytes/even bytes. Push the result in key schedule. - $val1 = ( $cp & 0xFF000000) | (($cp << 8) & 0x00FF0000) | - (($dp >> 16) & 0x0000FF00) | (($dp >> 8) & 0x000000FF); - $val2 = (($cp << 8) & 0xFF000000) | (($cp << 16) & 0x00FF0000) | - (($dp >> 8) & 0x0000FF00) | ( $dp & 0x000000FF); - $keys[$des_round][self::ENCRYPT][ ] = $val1; - $keys[$des_round][self::DECRYPT][$ki - 1] = $val1; - $keys[$des_round][self::ENCRYPT][ ] = $val2; - $keys[$des_round][self::DECRYPT][$ki ] = $val2; - } - } - - switch ($this->des_rounds) { - case 3: // 3DES keys - $this->keys = array( - self::ENCRYPT => array_merge( - $keys[0][self::ENCRYPT], - $keys[1][self::DECRYPT], - $keys[2][self::ENCRYPT] - ), - self::DECRYPT => array_merge( - $keys[2][self::DECRYPT], - $keys[1][self::ENCRYPT], - $keys[0][self::DECRYPT] - ) - ); - break; - // case 1: // DES keys - default: - $this->keys = array( - self::ENCRYPT => $keys[0][self::ENCRYPT], - self::DECRYPT => $keys[0][self::DECRYPT] - ); - } - } - - /** - * Setup the performance-optimized function for de/encrypt() - * - * @see \phpseclib\Crypt\Base::_setupInlineCrypt() - * @access private - */ - function _setupInlineCrypt() - { - $lambda_functions =& self::_getLambdaFunctions(); - - // Engine configuration for: - // - DES ($des_rounds == 1) or - // - 3DES ($des_rounds == 3) - $des_rounds = $this->des_rounds; - - // We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function. - // (Currently, for DES, one generated $lambda_function cost on php5.5@32bit ~135kb unfreeable mem and ~230kb on php5.5@64bit) - // (Currently, for TripleDES, one generated $lambda_function cost on php5.5@32bit ~240kb unfreeable mem and ~340kb on php5.5@64bit) - // After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one - $gen_hi_opt_code = (bool)( count($lambda_functions) < 10 ); - - // Generation of a uniqe hash for our generated code - $code_hash = "Crypt_DES, $des_rounds, {$this->mode}"; - if ($gen_hi_opt_code) { - // For hi-optimized code, we create for each combination of - // $mode, $des_rounds and $this->key its own encrypt/decrypt function. - // After max 10 hi-optimized functions, we create generic - // (still very fast.. but not ultra) functions for each $mode/$des_rounds - // Currently 2 * 5 generic functions will be then max. possible. - $code_hash = str_pad($code_hash, 32) . $this->_hashInlineCryptFunction($this->key); - } - - // Is there a re-usable $lambda_functions in there? If not, we have to create it. - if (!isset($lambda_functions[$code_hash])) { - // Init code for both, encrypt and decrypt. - $init_crypt = 'static $sbox1, $sbox2, $sbox3, $sbox4, $sbox5, $sbox6, $sbox7, $sbox8, $shuffleip, $shuffleinvip; - if (!$sbox1) { - $sbox1 = array_map("intval", $self->sbox1); - $sbox2 = array_map("intval", $self->sbox2); - $sbox3 = array_map("intval", $self->sbox3); - $sbox4 = array_map("intval", $self->sbox4); - $sbox5 = array_map("intval", $self->sbox5); - $sbox6 = array_map("intval", $self->sbox6); - $sbox7 = array_map("intval", $self->sbox7); - $sbox8 = array_map("intval", $self->sbox8);' - /* Merge $shuffle with $[inv]ipmap */ . ' - for ($i = 0; $i < 256; ++$i) { - $shuffleip[] = $self->shuffle[$self->ipmap[$i]]; - $shuffleinvip[] = $self->shuffle[$self->invipmap[$i]]; - } - } - '; - - switch (true) { - case $gen_hi_opt_code: - // In Hi-optimized code mode, we use our [3]DES key schedule as hardcoded integers. - // No futher initialisation of the $keys schedule is necessary. - // That is the extra performance boost. - $k = array( - self::ENCRYPT => $this->keys[self::ENCRYPT], - self::DECRYPT => $this->keys[self::DECRYPT] - ); - $init_encrypt = ''; - $init_decrypt = ''; - break; - default: - // In generic optimized code mode, we have to use, as the best compromise [currently], - // our key schedule as $ke/$kd arrays. (with hardcoded indexes...) - $k = array( - self::ENCRYPT => array(), - self::DECRYPT => array() - ); - for ($i = 0, $c = count($this->keys[self::ENCRYPT]); $i < $c; ++$i) { - $k[self::ENCRYPT][$i] = '$ke[' . $i . ']'; - $k[self::DECRYPT][$i] = '$kd[' . $i . ']'; - } - $init_encrypt = '$ke = $self->keys[self::ENCRYPT];'; - $init_decrypt = '$kd = $self->keys[self::DECRYPT];'; - break; - } - - // Creating code for en- and decryption. - $crypt_block = array(); - foreach (array(self::ENCRYPT, self::DECRYPT) as $c) { - /* Do the initial IP permutation. */ - $crypt_block[$c] = ' - $in = unpack("N*", $in); - $l = $in[1]; - $r = $in[2]; - $in = unpack("N*", - ($shuffleip[ $r & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | - ($shuffleip[($r >> 8) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | - ($shuffleip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | - ($shuffleip[($r >> 24) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") | - ($shuffleip[ $l & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | - ($shuffleip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | - ($shuffleip[($l >> 16) & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | - ($shuffleip[($l >> 24) & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01") - ); - ' . /* Extract L0 and R0 */ ' - $l = $in[1]; - $r = $in[2]; - '; - - $l = '$l'; - $r = '$r'; - - // Perform DES or 3DES. - for ($ki = -1, $des_round = 0; $des_round < $des_rounds; ++$des_round) { - // Perform the 16 steps. - for ($i = 0; $i < 16; ++$i) { - // start of "the Feistel (F) function" - see the following URL: - // http://en.wikipedia.org/wiki/Image:Data_Encryption_Standard_InfoBox_Diagram.png - // Merge key schedule. - $crypt_block[$c].= ' - $b1 = ((' . $r . ' >> 3) & 0x1FFFFFFF) ^ (' . $r . ' << 29) ^ ' . $k[$c][++$ki] . '; - $b2 = ((' . $r . ' >> 31) & 0x00000001) ^ (' . $r . ' << 1) ^ ' . $k[$c][++$ki] . ';' . - /* S-box indexing. */ - $l . ' = $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] ^ - $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^ - $sbox5[($b1 >> 8) & 0x3F] ^ $sbox6[($b2 >> 8) & 0x3F] ^ - $sbox7[ $b1 & 0x3F] ^ $sbox8[ $b2 & 0x3F] ^ ' . $l . '; - '; - // end of "the Feistel (F) function" - - // swap L & R - list($l, $r) = array($r, $l); - } - list($l, $r) = array($r, $l); - } - - // Perform the inverse IP permutation. - $crypt_block[$c].= '$in = - ($shuffleinvip[($l >> 24) & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | - ($shuffleinvip[($r >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | - ($shuffleinvip[($l >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | - ($shuffleinvip[($r >> 16) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") | - ($shuffleinvip[($l >> 8) & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") | - ($shuffleinvip[($r >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") | - ($shuffleinvip[ $l & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") | - ($shuffleinvip[ $r & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01"); - '; - } - - // Creates the inline-crypt function - $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( - array( - 'init_crypt' => $init_crypt, - 'init_encrypt' => $init_encrypt, - 'init_decrypt' => $init_decrypt, - 'encrypt_block' => $crypt_block[self::ENCRYPT], - 'decrypt_block' => $crypt_block[self::DECRYPT] - ) - ); - } - - // Set the inline-crypt function as callback in: $this->inline_crypt - $this->inline_crypt = $lambda_functions[$code_hash]; - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Hash.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Hash.php deleted file mode 100755 index 7047ae2a5efa1f191af407370ff318923f249186..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Hash.php +++ /dev/null @@ -1,825 +0,0 @@ -<?php - -/** - * Pure-PHP implementations of keyed-hash message authentication codes (HMACs) and various cryptographic hashing functions. - * - * Uses hash() or mhash() if available and an internal implementation, otherwise. Currently supports the following: - * - * md2, md5, md5-96, sha1, sha1-96, sha256, sha256-96, sha384, and sha512, sha512-96 - * - * If {@link self::setKey() setKey()} is called, {@link self::hash() hash()} will return the HMAC as opposed to - * the hash. If no valid algorithm is provided, sha1 will be used. - * - * PHP version 5 - * - * {@internal The variable names are the same as those in - * {@link http://tools.ietf.org/html/rfc2104#section-2 RFC2104}.}} - * - * Here's a short example of how to use this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $hash = new \phpseclib\Crypt\Hash('sha1'); - * - * $hash->setKey('abcdefg'); - * - * echo base64_encode($hash->hash('abcdefg')); - * ?> - * </code> - * - * @category Crypt - * @package Hash - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2007 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Crypt; - -use phpseclib\Math\BigInteger; - -/** - * Pure-PHP implementations of keyed-hash message authentication codes (HMACs) and various cryptographic hashing functions. - * - * @package Hash - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class Hash -{ - /**#@+ - * @access private - * @see \phpseclib\Crypt\Hash::__construct() - */ - /** - * Toggles the internal implementation - */ - const MODE_INTERNAL = 1; - /** - * Toggles the mhash() implementation, which has been deprecated on PHP 5.3.0+. - */ - const MODE_MHASH = 2; - /** - * Toggles the hash() implementation, which works on PHP 5.1.2+. - */ - const MODE_HASH = 3; - /**#@-*/ - - /** - * Hash Parameter - * - * @see self::setHash() - * @var int - * @access private - */ - var $hashParam; - - /** - * Byte-length of compression blocks / key (Internal HMAC) - * - * @see self::setAlgorithm() - * @var int - * @access private - */ - var $b; - - /** - * Byte-length of hash output (Internal HMAC) - * - * @see self::setHash() - * @var int - * @access private - */ - var $l = false; - - /** - * Hash Algorithm - * - * @see self::setHash() - * @var string - * @access private - */ - var $hash; - - /** - * Key - * - * @see self::setKey() - * @var string - * @access private - */ - var $key = false; - - /** - * Outer XOR (Internal HMAC) - * - * @see self::setKey() - * @var string - * @access private - */ - var $opad; - - /** - * Inner XOR (Internal HMAC) - * - * @see self::setKey() - * @var string - * @access private - */ - var $ipad; - - /** - * Default Constructor. - * - * @param string $hash - * @return \phpseclib\Crypt\Hash - * @access public - */ - function __construct($hash = 'sha1') - { - if (!defined('CRYPT_HASH_MODE')) { - switch (true) { - case extension_loaded('hash'): - define('CRYPT_HASH_MODE', self::MODE_HASH); - break; - case extension_loaded('mhash'): - define('CRYPT_HASH_MODE', self::MODE_MHASH); - break; - default: - define('CRYPT_HASH_MODE', self::MODE_INTERNAL); - } - } - - $this->setHash($hash); - } - - /** - * Sets the key for HMACs - * - * Keys can be of any length. - * - * @access public - * @param string $key - */ - function setKey($key = false) - { - $this->key = $key; - } - - /** - * Gets the hash function. - * - * As set by the constructor or by the setHash() method. - * - * @access public - * @return string - */ - function getHash() - { - return $this->hashParam; - } - - /** - * Sets the hash function. - * - * @access public - * @param string $hash - */ - function setHash($hash) - { - $this->hashParam = $hash = strtolower($hash); - switch ($hash) { - case 'md5-96': - case 'sha1-96': - case 'sha256-96': - case 'sha512-96': - $hash = substr($hash, 0, -3); - $this->l = 12; // 96 / 8 = 12 - break; - case 'md2': - case 'md5': - $this->l = 16; - break; - case 'sha1': - $this->l = 20; - break; - case 'sha256': - $this->l = 32; - break; - case 'sha384': - $this->l = 48; - break; - case 'sha512': - $this->l = 64; - } - - switch ($hash) { - case 'md2': - $mode = CRYPT_HASH_MODE == self::MODE_HASH && in_array('md2', hash_algos()) ? - self::MODE_HASH : self::MODE_INTERNAL; - break; - case 'sha384': - case 'sha512': - $mode = CRYPT_HASH_MODE == self::MODE_MHASH ? self::MODE_INTERNAL : CRYPT_HASH_MODE; - break; - default: - $mode = CRYPT_HASH_MODE; - } - - switch ($mode) { - case self::MODE_MHASH: - switch ($hash) { - case 'md5': - $this->hash = MHASH_MD5; - break; - case 'sha256': - $this->hash = MHASH_SHA256; - break; - case 'sha1': - default: - $this->hash = MHASH_SHA1; - } - return; - case self::MODE_HASH: - switch ($hash) { - case 'md5': - $this->hash = 'md5'; - return; - case 'md2': - case 'sha256': - case 'sha384': - case 'sha512': - $this->hash = $hash; - return; - case 'sha1': - default: - $this->hash = 'sha1'; - } - return; - } - - switch ($hash) { - case 'md2': - $this->b = 16; - $this->hash = array($this, '_md2'); - break; - case 'md5': - $this->b = 64; - $this->hash = array($this, '_md5'); - break; - case 'sha256': - $this->b = 64; - $this->hash = array($this, '_sha256'); - break; - case 'sha384': - case 'sha512': - $this->b = 128; - $this->hash = array($this, '_sha512'); - break; - case 'sha1': - default: - $this->b = 64; - $this->hash = array($this, '_sha1'); - } - - $this->ipad = str_repeat(chr(0x36), $this->b); - $this->opad = str_repeat(chr(0x5C), $this->b); - } - - /** - * Compute the HMAC. - * - * @access public - * @param string $text - * @return string - */ - function hash($text) - { - $mode = is_array($this->hash) ? self::MODE_INTERNAL : CRYPT_HASH_MODE; - - if (!empty($this->key) || is_string($this->key)) { - switch ($mode) { - case self::MODE_MHASH: - $output = mhash($this->hash, $text, $this->key); - break; - case self::MODE_HASH: - $output = hash_hmac($this->hash, $text, $this->key, true); - break; - case self::MODE_INTERNAL: - /* "Applications that use keys longer than B bytes will first hash the key using H and then use the - resultant L byte string as the actual key to HMAC." - - -- http://tools.ietf.org/html/rfc2104#section-2 */ - $key = strlen($this->key) > $this->b ? call_user_func($this->hash, $this->key) : $this->key; - - $key = str_pad($key, $this->b, chr(0)); // step 1 - $temp = $this->ipad ^ $key; // step 2 - $temp .= $text; // step 3 - $temp = call_user_func($this->hash, $temp); // step 4 - $output = $this->opad ^ $key; // step 5 - $output.= $temp; // step 6 - $output = call_user_func($this->hash, $output); // step 7 - } - } else { - switch ($mode) { - case self::MODE_MHASH: - $output = mhash($this->hash, $text); - break; - case self::MODE_HASH: - $output = hash($this->hash, $text, true); - break; - case self::MODE_INTERNAL: - $output = call_user_func($this->hash, $text); - } - } - - return substr($output, 0, $this->l); - } - - /** - * Returns the hash length (in bytes) - * - * @access public - * @return int - */ - function getLength() - { - return $this->l; - } - - /** - * Wrapper for MD5 - * - * @access private - * @param string $m - */ - function _md5($m) - { - return pack('H*', md5($m)); - } - - /** - * Wrapper for SHA1 - * - * @access private - * @param string $m - */ - function _sha1($m) - { - return pack('H*', sha1($m)); - } - - /** - * Pure-PHP implementation of MD2 - * - * See {@link http://tools.ietf.org/html/rfc1319 RFC1319}. - * - * @access private - * @param string $m - */ - function _md2($m) - { - static $s = array( - 41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, - 19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, - 76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, - 138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251, - 245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63, - 148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50, - 39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165, - 181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210, - 150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157, - 112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27, - 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15, - 85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, - 234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65, - 129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123, - 8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233, - 203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228, - 166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237, - 31, 26, 219, 153, 141, 51, 159, 17, 131, 20 - ); - - // Step 1. Append Padding Bytes - $pad = 16 - (strlen($m) & 0xF); - $m.= str_repeat(chr($pad), $pad); - - $length = strlen($m); - - // Step 2. Append Checksum - $c = str_repeat(chr(0), 16); - $l = chr(0); - for ($i = 0; $i < $length; $i+= 16) { - for ($j = 0; $j < 16; $j++) { - // RFC1319 incorrectly states that C[j] should be set to S[c xor L] - //$c[$j] = chr($s[ord($m[$i + $j] ^ $l)]); - // per <http://www.rfc-editor.org/errata_search.php?rfc=1319>, however, C[j] should be set to S[c xor L] xor C[j] - $c[$j] = chr($s[ord($m[$i + $j] ^ $l)] ^ ord($c[$j])); - $l = $c[$j]; - } - } - $m.= $c; - - $length+= 16; - - // Step 3. Initialize MD Buffer - $x = str_repeat(chr(0), 48); - - // Step 4. Process Message in 16-Byte Blocks - for ($i = 0; $i < $length; $i+= 16) { - for ($j = 0; $j < 16; $j++) { - $x[$j + 16] = $m[$i + $j]; - $x[$j + 32] = $x[$j + 16] ^ $x[$j]; - } - $t = chr(0); - for ($j = 0; $j < 18; $j++) { - for ($k = 0; $k < 48; $k++) { - $x[$k] = $t = $x[$k] ^ chr($s[ord($t)]); - //$t = $x[$k] = $x[$k] ^ chr($s[ord($t)]); - } - $t = chr(ord($t) + $j); - } - } - - // Step 5. Output - return substr($x, 0, 16); - } - - /** - * Pure-PHP implementation of SHA256 - * - * See {@link http://en.wikipedia.org/wiki/SHA_hash_functions#SHA-256_.28a_SHA-2_variant.29_pseudocode SHA-256 (a SHA-2 variant) pseudocode - Wikipedia}. - * - * @access private - * @param string $m - */ - function _sha256($m) - { - if (extension_loaded('suhosin')) { - return pack('H*', sha256($m)); - } - - // Initialize variables - $hash = array( - 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 - ); - // Initialize table of round constants - // (first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311) - static $k = array( - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, - 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, - 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, - 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 - ); - - // Pre-processing - $length = strlen($m); - // to round to nearest 56 mod 64, we'll add 64 - (length + (64 - 56)) % 64 - $m.= str_repeat(chr(0), 64 - (($length + 8) & 0x3F)); - $m[$length] = chr(0x80); - // we don't support hashing strings 512MB long - $m.= pack('N2', 0, $length << 3); - - // Process the message in successive 512-bit chunks - $chunks = str_split($m, 64); - foreach ($chunks as $chunk) { - $w = array(); - for ($i = 0; $i < 16; $i++) { - extract(unpack('Ntemp', $this->_string_shift($chunk, 4))); - $w[] = $temp; - } - - // Extend the sixteen 32-bit words into sixty-four 32-bit words - for ($i = 16; $i < 64; $i++) { - // @codingStandardsIgnoreStart - $s0 = $this->_rightRotate($w[$i - 15], 7) ^ - $this->_rightRotate($w[$i - 15], 18) ^ - $this->_rightShift( $w[$i - 15], 3); - $s1 = $this->_rightRotate($w[$i - 2], 17) ^ - $this->_rightRotate($w[$i - 2], 19) ^ - $this->_rightShift( $w[$i - 2], 10); - // @codingStandardsIgnoreEnd - $w[$i] = $this->_add($w[$i - 16], $s0, $w[$i - 7], $s1); - - } - - // Initialize hash value for this chunk - list($a, $b, $c, $d, $e, $f, $g, $h) = $hash; - - // Main loop - for ($i = 0; $i < 64; $i++) { - $s0 = $this->_rightRotate($a, 2) ^ - $this->_rightRotate($a, 13) ^ - $this->_rightRotate($a, 22); - $maj = ($a & $b) ^ - ($a & $c) ^ - ($b & $c); - $t2 = $this->_add($s0, $maj); - - $s1 = $this->_rightRotate($e, 6) ^ - $this->_rightRotate($e, 11) ^ - $this->_rightRotate($e, 25); - $ch = ($e & $f) ^ - ($this->_not($e) & $g); - $t1 = $this->_add($h, $s1, $ch, $k[$i], $w[$i]); - - $h = $g; - $g = $f; - $f = $e; - $e = $this->_add($d, $t1); - $d = $c; - $c = $b; - $b = $a; - $a = $this->_add($t1, $t2); - } - - // Add this chunk's hash to result so far - $hash = array( - $this->_add($hash[0], $a), - $this->_add($hash[1], $b), - $this->_add($hash[2], $c), - $this->_add($hash[3], $d), - $this->_add($hash[4], $e), - $this->_add($hash[5], $f), - $this->_add($hash[6], $g), - $this->_add($hash[7], $h) - ); - } - - // Produce the final hash value (big-endian) - return pack('N8', $hash[0], $hash[1], $hash[2], $hash[3], $hash[4], $hash[5], $hash[6], $hash[7]); - } - - /** - * Pure-PHP implementation of SHA384 and SHA512 - * - * @access private - * @param string $m - */ - function _sha512($m) - { - static $init384, $init512, $k; - - if (!isset($k)) { - // Initialize variables - $init384 = array( // initial values for SHA384 - 'cbbb9d5dc1059ed8', '629a292a367cd507', '9159015a3070dd17', '152fecd8f70e5939', - '67332667ffc00b31', '8eb44a8768581511', 'db0c2e0d64f98fa7', '47b5481dbefa4fa4' - ); - $init512 = array( // initial values for SHA512 - '6a09e667f3bcc908', 'bb67ae8584caa73b', '3c6ef372fe94f82b', 'a54ff53a5f1d36f1', - '510e527fade682d1', '9b05688c2b3e6c1f', '1f83d9abfb41bd6b', '5be0cd19137e2179' - ); - - for ($i = 0; $i < 8; $i++) { - $init384[$i] = new BigInteger($init384[$i], 16); - $init384[$i]->setPrecision(64); - $init512[$i] = new BigInteger($init512[$i], 16); - $init512[$i]->setPrecision(64); - } - - // Initialize table of round constants - // (first 64 bits of the fractional parts of the cube roots of the first 80 primes 2..409) - $k = array( - '428a2f98d728ae22', '7137449123ef65cd', 'b5c0fbcfec4d3b2f', 'e9b5dba58189dbbc', - '3956c25bf348b538', '59f111f1b605d019', '923f82a4af194f9b', 'ab1c5ed5da6d8118', - 'd807aa98a3030242', '12835b0145706fbe', '243185be4ee4b28c', '550c7dc3d5ffb4e2', - '72be5d74f27b896f', '80deb1fe3b1696b1', '9bdc06a725c71235', 'c19bf174cf692694', - 'e49b69c19ef14ad2', 'efbe4786384f25e3', '0fc19dc68b8cd5b5', '240ca1cc77ac9c65', - '2de92c6f592b0275', '4a7484aa6ea6e483', '5cb0a9dcbd41fbd4', '76f988da831153b5', - '983e5152ee66dfab', 'a831c66d2db43210', 'b00327c898fb213f', 'bf597fc7beef0ee4', - 'c6e00bf33da88fc2', 'd5a79147930aa725', '06ca6351e003826f', '142929670a0e6e70', - '27b70a8546d22ffc', '2e1b21385c26c926', '4d2c6dfc5ac42aed', '53380d139d95b3df', - '650a73548baf63de', '766a0abb3c77b2a8', '81c2c92e47edaee6', '92722c851482353b', - 'a2bfe8a14cf10364', 'a81a664bbc423001', 'c24b8b70d0f89791', 'c76c51a30654be30', - 'd192e819d6ef5218', 'd69906245565a910', 'f40e35855771202a', '106aa07032bbd1b8', - '19a4c116b8d2d0c8', '1e376c085141ab53', '2748774cdf8eeb99', '34b0bcb5e19b48a8', - '391c0cb3c5c95a63', '4ed8aa4ae3418acb', '5b9cca4f7763e373', '682e6ff3d6b2b8a3', - '748f82ee5defb2fc', '78a5636f43172f60', '84c87814a1f0ab72', '8cc702081a6439ec', - '90befffa23631e28', 'a4506cebde82bde9', 'bef9a3f7b2c67915', 'c67178f2e372532b', - 'ca273eceea26619c', 'd186b8c721c0c207', 'eada7dd6cde0eb1e', 'f57d4f7fee6ed178', - '06f067aa72176fba', '0a637dc5a2c898a6', '113f9804bef90dae', '1b710b35131c471b', - '28db77f523047d84', '32caab7b40c72493', '3c9ebe0a15c9bebc', '431d67c49c100d4c', - '4cc5d4becb3e42b6', '597f299cfc657e2a', '5fcb6fab3ad6faec', '6c44198c4a475817' - ); - - for ($i = 0; $i < 80; $i++) { - $k[$i] = new BigInteger($k[$i], 16); - } - } - - $hash = $this->l == 48 ? $init384 : $init512; - - // Pre-processing - $length = strlen($m); - // to round to nearest 112 mod 128, we'll add 128 - (length + (128 - 112)) % 128 - $m.= str_repeat(chr(0), 128 - (($length + 16) & 0x7F)); - $m[$length] = chr(0x80); - // we don't support hashing strings 512MB long - $m.= pack('N4', 0, 0, 0, $length << 3); - - // Process the message in successive 1024-bit chunks - $chunks = str_split($m, 128); - foreach ($chunks as $chunk) { - $w = array(); - for ($i = 0; $i < 16; $i++) { - $temp = new BigInteger($this->_string_shift($chunk, 8), 256); - $temp->setPrecision(64); - $w[] = $temp; - } - - // Extend the sixteen 32-bit words into eighty 32-bit words - for ($i = 16; $i < 80; $i++) { - $temp = array( - $w[$i - 15]->bitwise_rightRotate(1), - $w[$i - 15]->bitwise_rightRotate(8), - $w[$i - 15]->bitwise_rightShift(7) - ); - $s0 = $temp[0]->bitwise_xor($temp[1]); - $s0 = $s0->bitwise_xor($temp[2]); - $temp = array( - $w[$i - 2]->bitwise_rightRotate(19), - $w[$i - 2]->bitwise_rightRotate(61), - $w[$i - 2]->bitwise_rightShift(6) - ); - $s1 = $temp[0]->bitwise_xor($temp[1]); - $s1 = $s1->bitwise_xor($temp[2]); - $w[$i] = $w[$i - 16]->copy(); - $w[$i] = $w[$i]->add($s0); - $w[$i] = $w[$i]->add($w[$i - 7]); - $w[$i] = $w[$i]->add($s1); - } - - // Initialize hash value for this chunk - $a = $hash[0]->copy(); - $b = $hash[1]->copy(); - $c = $hash[2]->copy(); - $d = $hash[3]->copy(); - $e = $hash[4]->copy(); - $f = $hash[5]->copy(); - $g = $hash[6]->copy(); - $h = $hash[7]->copy(); - - // Main loop - for ($i = 0; $i < 80; $i++) { - $temp = array( - $a->bitwise_rightRotate(28), - $a->bitwise_rightRotate(34), - $a->bitwise_rightRotate(39) - ); - $s0 = $temp[0]->bitwise_xor($temp[1]); - $s0 = $s0->bitwise_xor($temp[2]); - $temp = array( - $a->bitwise_and($b), - $a->bitwise_and($c), - $b->bitwise_and($c) - ); - $maj = $temp[0]->bitwise_xor($temp[1]); - $maj = $maj->bitwise_xor($temp[2]); - $t2 = $s0->add($maj); - - $temp = array( - $e->bitwise_rightRotate(14), - $e->bitwise_rightRotate(18), - $e->bitwise_rightRotate(41) - ); - $s1 = $temp[0]->bitwise_xor($temp[1]); - $s1 = $s1->bitwise_xor($temp[2]); - $temp = array( - $e->bitwise_and($f), - $g->bitwise_and($e->bitwise_not()) - ); - $ch = $temp[0]->bitwise_xor($temp[1]); - $t1 = $h->add($s1); - $t1 = $t1->add($ch); - $t1 = $t1->add($k[$i]); - $t1 = $t1->add($w[$i]); - - $h = $g->copy(); - $g = $f->copy(); - $f = $e->copy(); - $e = $d->add($t1); - $d = $c->copy(); - $c = $b->copy(); - $b = $a->copy(); - $a = $t1->add($t2); - } - - // Add this chunk's hash to result so far - $hash = array( - $hash[0]->add($a), - $hash[1]->add($b), - $hash[2]->add($c), - $hash[3]->add($d), - $hash[4]->add($e), - $hash[5]->add($f), - $hash[6]->add($g), - $hash[7]->add($h) - ); - } - - // Produce the final hash value (big-endian) - // (\phpseclib\Crypt\Hash::hash() trims the output for hashes but not for HMACs. as such, we trim the output here) - $temp = $hash[0]->toBytes() . $hash[1]->toBytes() . $hash[2]->toBytes() . $hash[3]->toBytes() . - $hash[4]->toBytes() . $hash[5]->toBytes(); - if ($this->l != 48) { - $temp.= $hash[6]->toBytes() . $hash[7]->toBytes(); - } - - return $temp; - } - - /** - * Right Rotate - * - * @access private - * @param int $int - * @param int $amt - * @see self::_sha256() - * @return int - */ - function _rightRotate($int, $amt) - { - $invamt = 32 - $amt; - $mask = (1 << $invamt) - 1; - return (($int << $invamt) & 0xFFFFFFFF) | (($int >> $amt) & $mask); - } - - /** - * Right Shift - * - * @access private - * @param int $int - * @param int $amt - * @see self::_sha256() - * @return int - */ - function _rightShift($int, $amt) - { - $mask = (1 << (32 - $amt)) - 1; - return ($int >> $amt) & $mask; - } - - /** - * Not - * - * @access private - * @param int $int - * @see self::_sha256() - * @return int - */ - function _not($int) - { - return ~$int & 0xFFFFFFFF; - } - - /** - * Add - * - * _sha256() adds multiple unsigned 32-bit integers. Since PHP doesn't support unsigned integers and since the - * possibility of overflow exists, care has to be taken. BigInteger could be used but this should be faster. - * - * @param int $... - * @return int - * @see self::_sha256() - * @access private - */ - function _add() - { - static $mod; - if (!isset($mod)) { - $mod = pow(2, 32); - } - - $result = 0; - $arguments = func_get_args(); - foreach ($arguments as $argument) { - $result+= $argument < 0 ? ($argument & 0x7FFFFFFF) + 0x80000000 : $argument; - } - - return fmod($result, $mod); - } - - /** - * String Shift - * - * Inspired by array_shift - * - * @param string $string - * @param int $index - * @return string - * @access private - */ - function _string_shift(&$string, $index = 1) - { - $substr = substr($string, 0, $index); - $string = substr($string, $index); - return $substr; - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC2.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC2.php deleted file mode 100755 index bfe3bca44b973f689c4eabe68458c7eec54cd359..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC2.php +++ /dev/null @@ -1,683 +0,0 @@ -<?php - -/** - * Pure-PHP implementation of RC2. - * - * Uses mcrypt, if available, and an internal implementation, otherwise. - * - * PHP version 5 - * - * Useful resources are as follows: - * - * - {@link http://tools.ietf.org/html/rfc2268} - * - * Here's a short example of how to use this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $rc2 = new \phpseclib\Crypt\RC2(); - * - * $rc2->setKey('abcdefgh'); - * - * $plaintext = str_repeat('a', 1024); - * - * echo $rc2->decrypt($rc2->encrypt($plaintext)); - * ?> - * </code> - * - * @category Crypt - * @package RC2 - * @author Patrick Monnerat <pm@datasphere.ch> - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Crypt; - -use phpseclib\Crypt\Base; - -/** - * Pure-PHP implementation of RC2. - * - * @package RC2 - * @access public - */ -class RC2 extends Base -{ - /** - * Block Length of the cipher - * - * @see \phpseclib\Crypt\Base::block_size - * @var int - * @access private - */ - var $block_size = 8; - - /** - * The Key - * - * @see \phpseclib\Crypt\Base::key - * @see self::setKey() - * @var string - * @access private - */ - var $key; - - /** - * The Original (unpadded) Key - * - * @see \phpseclib\Crypt\Base::key - * @see self::setKey() - * @see self::encrypt() - * @see self::decrypt() - * @var string - * @access private - */ - var $orig_key; - - /** - * Don't truncate / null pad key - * - * @see \phpseclib\Crypt\Base::_clearBuffers() - * @var bool - * @access private - */ - var $skip_key_adjustment = true; - - /** - * Key Length (in bytes) - * - * @see \phpseclib\Crypt\RC2::setKeyLength() - * @var int - * @access private - */ - var $key_length = 16; // = 128 bits - - /** - * The mcrypt specific name of the cipher - * - * @see \phpseclib\Crypt\Base::cipher_name_mcrypt - * @var string - * @access private - */ - var $cipher_name_mcrypt = 'rc2'; - - /** - * Optimizing value while CFB-encrypting - * - * @see \phpseclib\Crypt\Base::cfb_init_len - * @var int - * @access private - */ - var $cfb_init_len = 500; - - /** - * The key length in bits. - * - * @see self::setKeyLength() - * @see self::setKey() - * @var int - * @access private - * @internal Should be in range [1..1024]. - * @internal Changing this value after setting the key has no effect. - */ - var $default_key_length = 1024; - - /** - * The key length in bits. - * - * @see self::isValidEnine() - * @see self::setKey() - * @var int - * @access private - * @internal Should be in range [1..1024]. - */ - var $current_key_length; - - /** - * The Key Schedule - * - * @see self::_setupKey() - * @var array - * @access private - */ - var $keys; - - /** - * Key expansion randomization table. - * Twice the same 256-value sequence to save a modulus in key expansion. - * - * @see self::setKey() - * @var array - * @access private - */ - var $pitable = array( - 0xD9, 0x78, 0xF9, 0xC4, 0x19, 0xDD, 0xB5, 0xED, - 0x28, 0xE9, 0xFD, 0x79, 0x4A, 0xA0, 0xD8, 0x9D, - 0xC6, 0x7E, 0x37, 0x83, 0x2B, 0x76, 0x53, 0x8E, - 0x62, 0x4C, 0x64, 0x88, 0x44, 0x8B, 0xFB, 0xA2, - 0x17, 0x9A, 0x59, 0xF5, 0x87, 0xB3, 0x4F, 0x13, - 0x61, 0x45, 0x6D, 0x8D, 0x09, 0x81, 0x7D, 0x32, - 0xBD, 0x8F, 0x40, 0xEB, 0x86, 0xB7, 0x7B, 0x0B, - 0xF0, 0x95, 0x21, 0x22, 0x5C, 0x6B, 0x4E, 0x82, - 0x54, 0xD6, 0x65, 0x93, 0xCE, 0x60, 0xB2, 0x1C, - 0x73, 0x56, 0xC0, 0x14, 0xA7, 0x8C, 0xF1, 0xDC, - 0x12, 0x75, 0xCA, 0x1F, 0x3B, 0xBE, 0xE4, 0xD1, - 0x42, 0x3D, 0xD4, 0x30, 0xA3, 0x3C, 0xB6, 0x26, - 0x6F, 0xBF, 0x0E, 0xDA, 0x46, 0x69, 0x07, 0x57, - 0x27, 0xF2, 0x1D, 0x9B, 0xBC, 0x94, 0x43, 0x03, - 0xF8, 0x11, 0xC7, 0xF6, 0x90, 0xEF, 0x3E, 0xE7, - 0x06, 0xC3, 0xD5, 0x2F, 0xC8, 0x66, 0x1E, 0xD7, - 0x08, 0xE8, 0xEA, 0xDE, 0x80, 0x52, 0xEE, 0xF7, - 0x84, 0xAA, 0x72, 0xAC, 0x35, 0x4D, 0x6A, 0x2A, - 0x96, 0x1A, 0xD2, 0x71, 0x5A, 0x15, 0x49, 0x74, - 0x4B, 0x9F, 0xD0, 0x5E, 0x04, 0x18, 0xA4, 0xEC, - 0xC2, 0xE0, 0x41, 0x6E, 0x0F, 0x51, 0xCB, 0xCC, - 0x24, 0x91, 0xAF, 0x50, 0xA1, 0xF4, 0x70, 0x39, - 0x99, 0x7C, 0x3A, 0x85, 0x23, 0xB8, 0xB4, 0x7A, - 0xFC, 0x02, 0x36, 0x5B, 0x25, 0x55, 0x97, 0x31, - 0x2D, 0x5D, 0xFA, 0x98, 0xE3, 0x8A, 0x92, 0xAE, - 0x05, 0xDF, 0x29, 0x10, 0x67, 0x6C, 0xBA, 0xC9, - 0xD3, 0x00, 0xE6, 0xCF, 0xE1, 0x9E, 0xA8, 0x2C, - 0x63, 0x16, 0x01, 0x3F, 0x58, 0xE2, 0x89, 0xA9, - 0x0D, 0x38, 0x34, 0x1B, 0xAB, 0x33, 0xFF, 0xB0, - 0xBB, 0x48, 0x0C, 0x5F, 0xB9, 0xB1, 0xCD, 0x2E, - 0xC5, 0xF3, 0xDB, 0x47, 0xE5, 0xA5, 0x9C, 0x77, - 0x0A, 0xA6, 0x20, 0x68, 0xFE, 0x7F, 0xC1, 0xAD, - 0xD9, 0x78, 0xF9, 0xC4, 0x19, 0xDD, 0xB5, 0xED, - 0x28, 0xE9, 0xFD, 0x79, 0x4A, 0xA0, 0xD8, 0x9D, - 0xC6, 0x7E, 0x37, 0x83, 0x2B, 0x76, 0x53, 0x8E, - 0x62, 0x4C, 0x64, 0x88, 0x44, 0x8B, 0xFB, 0xA2, - 0x17, 0x9A, 0x59, 0xF5, 0x87, 0xB3, 0x4F, 0x13, - 0x61, 0x45, 0x6D, 0x8D, 0x09, 0x81, 0x7D, 0x32, - 0xBD, 0x8F, 0x40, 0xEB, 0x86, 0xB7, 0x7B, 0x0B, - 0xF0, 0x95, 0x21, 0x22, 0x5C, 0x6B, 0x4E, 0x82, - 0x54, 0xD6, 0x65, 0x93, 0xCE, 0x60, 0xB2, 0x1C, - 0x73, 0x56, 0xC0, 0x14, 0xA7, 0x8C, 0xF1, 0xDC, - 0x12, 0x75, 0xCA, 0x1F, 0x3B, 0xBE, 0xE4, 0xD1, - 0x42, 0x3D, 0xD4, 0x30, 0xA3, 0x3C, 0xB6, 0x26, - 0x6F, 0xBF, 0x0E, 0xDA, 0x46, 0x69, 0x07, 0x57, - 0x27, 0xF2, 0x1D, 0x9B, 0xBC, 0x94, 0x43, 0x03, - 0xF8, 0x11, 0xC7, 0xF6, 0x90, 0xEF, 0x3E, 0xE7, - 0x06, 0xC3, 0xD5, 0x2F, 0xC8, 0x66, 0x1E, 0xD7, - 0x08, 0xE8, 0xEA, 0xDE, 0x80, 0x52, 0xEE, 0xF7, - 0x84, 0xAA, 0x72, 0xAC, 0x35, 0x4D, 0x6A, 0x2A, - 0x96, 0x1A, 0xD2, 0x71, 0x5A, 0x15, 0x49, 0x74, - 0x4B, 0x9F, 0xD0, 0x5E, 0x04, 0x18, 0xA4, 0xEC, - 0xC2, 0xE0, 0x41, 0x6E, 0x0F, 0x51, 0xCB, 0xCC, - 0x24, 0x91, 0xAF, 0x50, 0xA1, 0xF4, 0x70, 0x39, - 0x99, 0x7C, 0x3A, 0x85, 0x23, 0xB8, 0xB4, 0x7A, - 0xFC, 0x02, 0x36, 0x5B, 0x25, 0x55, 0x97, 0x31, - 0x2D, 0x5D, 0xFA, 0x98, 0xE3, 0x8A, 0x92, 0xAE, - 0x05, 0xDF, 0x29, 0x10, 0x67, 0x6C, 0xBA, 0xC9, - 0xD3, 0x00, 0xE6, 0xCF, 0xE1, 0x9E, 0xA8, 0x2C, - 0x63, 0x16, 0x01, 0x3F, 0x58, 0xE2, 0x89, 0xA9, - 0x0D, 0x38, 0x34, 0x1B, 0xAB, 0x33, 0xFF, 0xB0, - 0xBB, 0x48, 0x0C, 0x5F, 0xB9, 0xB1, 0xCD, 0x2E, - 0xC5, 0xF3, 0xDB, 0x47, 0xE5, 0xA5, 0x9C, 0x77, - 0x0A, 0xA6, 0x20, 0x68, 0xFE, 0x7F, 0xC1, 0xAD - ); - - /** - * Inverse key expansion randomization table. - * - * @see self::setKey() - * @var array - * @access private - */ - var $invpitable = array( - 0xD1, 0xDA, 0xB9, 0x6F, 0x9C, 0xC8, 0x78, 0x66, - 0x80, 0x2C, 0xF8, 0x37, 0xEA, 0xE0, 0x62, 0xA4, - 0xCB, 0x71, 0x50, 0x27, 0x4B, 0x95, 0xD9, 0x20, - 0x9D, 0x04, 0x91, 0xE3, 0x47, 0x6A, 0x7E, 0x53, - 0xFA, 0x3A, 0x3B, 0xB4, 0xA8, 0xBC, 0x5F, 0x68, - 0x08, 0xCA, 0x8F, 0x14, 0xD7, 0xC0, 0xEF, 0x7B, - 0x5B, 0xBF, 0x2F, 0xE5, 0xE2, 0x8C, 0xBA, 0x12, - 0xE1, 0xAF, 0xB2, 0x54, 0x5D, 0x59, 0x76, 0xDB, - 0x32, 0xA2, 0x58, 0x6E, 0x1C, 0x29, 0x64, 0xF3, - 0xE9, 0x96, 0x0C, 0x98, 0x19, 0x8D, 0x3E, 0x26, - 0xAB, 0xA5, 0x85, 0x16, 0x40, 0xBD, 0x49, 0x67, - 0xDC, 0x22, 0x94, 0xBB, 0x3C, 0xC1, 0x9B, 0xEB, - 0x45, 0x28, 0x18, 0xD8, 0x1A, 0x42, 0x7D, 0xCC, - 0xFB, 0x65, 0x8E, 0x3D, 0xCD, 0x2A, 0xA3, 0x60, - 0xAE, 0x93, 0x8A, 0x48, 0x97, 0x51, 0x15, 0xF7, - 0x01, 0x0B, 0xB7, 0x36, 0xB1, 0x2E, 0x11, 0xFD, - 0x84, 0x2D, 0x3F, 0x13, 0x88, 0xB3, 0x34, 0x24, - 0x1B, 0xDE, 0xC5, 0x1D, 0x4D, 0x2B, 0x17, 0x31, - 0x74, 0xA9, 0xC6, 0x43, 0x6D, 0x39, 0x90, 0xBE, - 0xC3, 0xB0, 0x21, 0x6B, 0xF6, 0x0F, 0xD5, 0x99, - 0x0D, 0xAC, 0x1F, 0x5C, 0x9E, 0xF5, 0xF9, 0x4C, - 0xD6, 0xDF, 0x89, 0xE4, 0x8B, 0xFF, 0xC7, 0xAA, - 0xE7, 0xED, 0x46, 0x25, 0xB6, 0x06, 0x5E, 0x35, - 0xB5, 0xEC, 0xCE, 0xE8, 0x6C, 0x30, 0x55, 0x61, - 0x4A, 0xFE, 0xA0, 0x79, 0x03, 0xF0, 0x10, 0x72, - 0x7C, 0xCF, 0x52, 0xA6, 0xA7, 0xEE, 0x44, 0xD3, - 0x9A, 0x57, 0x92, 0xD0, 0x5A, 0x7A, 0x41, 0x7F, - 0x0E, 0x00, 0x63, 0xF2, 0x4F, 0x05, 0x83, 0xC9, - 0xA1, 0xD4, 0xDD, 0xC4, 0x56, 0xF4, 0xD2, 0x77, - 0x81, 0x09, 0x82, 0x33, 0x9F, 0x07, 0x86, 0x75, - 0x38, 0x4E, 0x69, 0xF1, 0xAD, 0x23, 0x73, 0x87, - 0x70, 0x02, 0xC2, 0x1E, 0xB8, 0x0A, 0xFC, 0xE6 - ); - - /** - * Test for engine validity - * - * This is mainly just a wrapper to set things up for \phpseclib\Crypt\Base::isValidEngine() - * - * @see \phpseclib\Crypt\Base::__construct() - * @param int $engine - * @access public - * @return bool - */ - function isValidEngine($engine) - { - switch ($engine) { - case self::ENGINE_OPENSSL: - if ($this->current_key_length != 128 || strlen($this->orig_key) < 16) { - return false; - } - $this->cipher_name_openssl_ecb = 'rc2-ecb'; - $this->cipher_name_openssl = 'rc2-' . $this->_openssl_translate_mode(); - } - - return parent::isValidEngine($engine); - } - - /** - * Sets the key length. - * - * Valid key lengths are 1 to 1024. - * Calling this function after setting the key has no effect until the next - * \phpseclib\Crypt\RC2::setKey() call. - * - * @access public - * @param int $length in bits - */ - function setKeyLength($length) - { - if ($length >= 1 && $length <= 1024) { - $this->default_key_length = $length; - } - } - - /** - * Returns the current key length - * - * @access public - * @return int - */ - function getKeyLength() - { - return $this->current_key_length; - } - - /** - * Sets the key. - * - * Keys can be of any length. RC2, itself, uses 1 to 1024 bit keys (eg. - * strlen($key) <= 128), however, we only use the first 128 bytes if $key - * has more then 128 bytes in it, and set $key to a single null byte if - * it is empty. - * - * If the key is not explicitly set, it'll be assumed to be a single - * null byte. - * - * @see \phpseclib\Crypt\Base::setKey() - * @access public - * @param string $key - * @param int $t1 optional Effective key length in bits. - */ - function setKey($key, $t1 = 0) - { - $this->orig_key = $key; - - if ($t1 <= 0) { - $t1 = $this->default_key_length; - } elseif ($t1 > 1024) { - $t1 = 1024; - } - $this->current_key_length = $t1; - // Key byte count should be 1..128. - $key = strlen($key) ? substr($key, 0, 128) : "\x00"; - $t = strlen($key); - - // The mcrypt RC2 implementation only supports effective key length - // of 1024 bits. It is however possible to handle effective key - // lengths in range 1..1024 by expanding the key and applying - // inverse pitable mapping to the first byte before submitting it - // to mcrypt. - - // Key expansion. - $l = array_values(unpack('C*', $key)); - $t8 = ($t1 + 7) >> 3; - $tm = 0xFF >> (8 * $t8 - $t1); - - // Expand key. - $pitable = $this->pitable; - for ($i = $t; $i < 128; $i++) { - $l[$i] = $pitable[$l[$i - 1] + $l[$i - $t]]; - } - $i = 128 - $t8; - $l[$i] = $pitable[$l[$i] & $tm]; - while ($i--) { - $l[$i] = $pitable[$l[$i + 1] ^ $l[$i + $t8]]; - } - - // Prepare the key for mcrypt. - $l[0] = $this->invpitable[$l[0]]; - array_unshift($l, 'C*'); - - parent::setKey(call_user_func_array('pack', $l)); - } - - /** - * Encrypts a message. - * - * Mostly a wrapper for \phpseclib\Crypt\Base::encrypt, with some additional OpenSSL handling code - * - * @see self::decrypt() - * @access public - * @param string $plaintext - * @return string $ciphertext - */ - function encrypt($plaintext) - { - if ($this->engine == self::ENGINE_OPENSSL) { - $temp = $this->key; - $this->key = $this->orig_key; - $result = parent::encrypt($plaintext); - $this->key = $temp; - return $result; - } - - return parent::encrypt($plaintext); - } - - /** - * Decrypts a message. - * - * Mostly a wrapper for \phpseclib\Crypt\Base::decrypt, with some additional OpenSSL handling code - * - * @see self::encrypt() - * @access public - * @param string $ciphertext - * @return string $plaintext - */ - function decrypt($ciphertext) - { - if ($this->engine == self::ENGINE_OPENSSL) { - $temp = $this->key; - $this->key = $this->orig_key; - $result = parent::decrypt($ciphertext); - $this->key = $temp; - return $result; - } - - return parent::encrypt($ciphertext); - } - - /** - * Encrypts a block - * - * @see \phpseclib\Crypt\Base::_encryptBlock() - * @see \phpseclib\Crypt\Base::encrypt() - * @access private - * @param string $in - * @return string - */ - function _encryptBlock($in) - { - list($r0, $r1, $r2, $r3) = array_values(unpack('v*', $in)); - $keys = $this->keys; - $limit = 20; - $actions = array($limit => 44, 44 => 64); - $j = 0; - - for (;;) { - // Mixing round. - $r0 = (($r0 + $keys[$j++] + ((($r1 ^ $r2) & $r3) ^ $r1)) & 0xFFFF) << 1; - $r0 |= $r0 >> 16; - $r1 = (($r1 + $keys[$j++] + ((($r2 ^ $r3) & $r0) ^ $r2)) & 0xFFFF) << 2; - $r1 |= $r1 >> 16; - $r2 = (($r2 + $keys[$j++] + ((($r3 ^ $r0) & $r1) ^ $r3)) & 0xFFFF) << 3; - $r2 |= $r2 >> 16; - $r3 = (($r3 + $keys[$j++] + ((($r0 ^ $r1) & $r2) ^ $r0)) & 0xFFFF) << 5; - $r3 |= $r3 >> 16; - - if ($j === $limit) { - if ($limit === 64) { - break; - } - - // Mashing round. - $r0 += $keys[$r3 & 0x3F]; - $r1 += $keys[$r0 & 0x3F]; - $r2 += $keys[$r1 & 0x3F]; - $r3 += $keys[$r2 & 0x3F]; - $limit = $actions[$limit]; - } - } - - return pack('vvvv', $r0, $r1, $r2, $r3); - } - - /** - * Decrypts a block - * - * @see \phpseclib\Crypt\Base::_decryptBlock() - * @see \phpseclib\Crypt\Base::decrypt() - * @access private - * @param string $in - * @return string - */ - function _decryptBlock($in) - { - list($r0, $r1, $r2, $r3) = array_values(unpack('v*', $in)); - $keys = $this->keys; - $limit = 44; - $actions = array($limit => 20, 20 => 0); - $j = 64; - - for (;;) { - // R-mixing round. - $r3 = ($r3 | ($r3 << 16)) >> 5; - $r3 = ($r3 - $keys[--$j] - ((($r0 ^ $r1) & $r2) ^ $r0)) & 0xFFFF; - $r2 = ($r2 | ($r2 << 16)) >> 3; - $r2 = ($r2 - $keys[--$j] - ((($r3 ^ $r0) & $r1) ^ $r3)) & 0xFFFF; - $r1 = ($r1 | ($r1 << 16)) >> 2; - $r1 = ($r1 - $keys[--$j] - ((($r2 ^ $r3) & $r0) ^ $r2)) & 0xFFFF; - $r0 = ($r0 | ($r0 << 16)) >> 1; - $r0 = ($r0 - $keys[--$j] - ((($r1 ^ $r2) & $r3) ^ $r1)) & 0xFFFF; - - if ($j === $limit) { - if ($limit === 0) { - break; - } - - // R-mashing round. - $r3 = ($r3 - $keys[$r2 & 0x3F]) & 0xFFFF; - $r2 = ($r2 - $keys[$r1 & 0x3F]) & 0xFFFF; - $r1 = ($r1 - $keys[$r0 & 0x3F]) & 0xFFFF; - $r0 = ($r0 - $keys[$r3 & 0x3F]) & 0xFFFF; - $limit = $actions[$limit]; - } - } - - return pack('vvvv', $r0, $r1, $r2, $r3); - } - - /** - * Setup the \phpseclib\Crypt\Base::ENGINE_MCRYPT $engine - * - * @see \phpseclib\Crypt\Base::_setupMcrypt() - * @access private - */ - function _setupMcrypt() - { - if (!isset($this->key)) { - $this->setKey(''); - } - - parent::_setupMcrypt(); - } - - /** - * Creates the key schedule - * - * @see \phpseclib\Crypt\Base::_setupKey() - * @access private - */ - function _setupKey() - { - if (!isset($this->key)) { - $this->setKey(''); - } - - // Key has already been expanded in \phpseclib\Crypt\RC2::setKey(): - // Only the first value must be altered. - $l = unpack('Ca/Cb/v*', $this->key); - array_unshift($l, $this->pitable[$l['a']] | ($l['b'] << 8)); - unset($l['a']); - unset($l['b']); - $this->keys = $l; - } - - /** - * Setup the performance-optimized function for de/encrypt() - * - * @see \phpseclib\Crypt\Base::_setupInlineCrypt() - * @access private - */ - function _setupInlineCrypt() - { - $lambda_functions =& self::_getLambdaFunctions(); - - // The first 10 generated $lambda_functions will use the $keys hardcoded as integers - // for the mixing rounds, for better inline crypt performance [~20% faster]. - // But for memory reason we have to limit those ultra-optimized $lambda_functions to an amount of 10. - // (Currently, for Crypt_RC2, one generated $lambda_function cost on php5.5@32bit ~60kb unfreeable mem and ~100kb on php5.5@64bit) - $gen_hi_opt_code = (bool)(count($lambda_functions) < 10); - - // Generation of a uniqe hash for our generated code - $code_hash = "Crypt_RC2, {$this->mode}"; - if ($gen_hi_opt_code) { - $code_hash = str_pad($code_hash, 32) . $this->_hashInlineCryptFunction($this->key); - } - - // Is there a re-usable $lambda_functions in there? - // If not, we have to create it. - if (!isset($lambda_functions[$code_hash])) { - // Init code for both, encrypt and decrypt. - $init_crypt = '$keys = $self->keys;'; - - switch (true) { - case $gen_hi_opt_code: - $keys = $this->keys; - default: - $keys = array(); - foreach ($this->keys as $k => $v) { - $keys[$k] = '$keys[' . $k . ']'; - } - } - - // $in is the current 8 bytes block which has to be en/decrypt - $encrypt_block = $decrypt_block = ' - $in = unpack("v4", $in); - $r0 = $in[1]; - $r1 = $in[2]; - $r2 = $in[3]; - $r3 = $in[4]; - '; - - // Create code for encryption. - $limit = 20; - $actions = array($limit => 44, 44 => 64); - $j = 0; - - for (;;) { - // Mixing round. - $encrypt_block .= ' - $r0 = (($r0 + ' . $keys[$j++] . ' + - ((($r1 ^ $r2) & $r3) ^ $r1)) & 0xFFFF) << 1; - $r0 |= $r0 >> 16; - $r1 = (($r1 + ' . $keys[$j++] . ' + - ((($r2 ^ $r3) & $r0) ^ $r2)) & 0xFFFF) << 2; - $r1 |= $r1 >> 16; - $r2 = (($r2 + ' . $keys[$j++] . ' + - ((($r3 ^ $r0) & $r1) ^ $r3)) & 0xFFFF) << 3; - $r2 |= $r2 >> 16; - $r3 = (($r3 + ' . $keys[$j++] . ' + - ((($r0 ^ $r1) & $r2) ^ $r0)) & 0xFFFF) << 5; - $r3 |= $r3 >> 16;'; - - if ($j === $limit) { - if ($limit === 64) { - break; - } - - // Mashing round. - $encrypt_block .= ' - $r0 += $keys[$r3 & 0x3F]; - $r1 += $keys[$r0 & 0x3F]; - $r2 += $keys[$r1 & 0x3F]; - $r3 += $keys[$r2 & 0x3F];'; - $limit = $actions[$limit]; - } - } - - $encrypt_block .= '$in = pack("v4", $r0, $r1, $r2, $r3);'; - - // Create code for decryption. - $limit = 44; - $actions = array($limit => 20, 20 => 0); - $j = 64; - - for (;;) { - // R-mixing round. - $decrypt_block .= ' - $r3 = ($r3 | ($r3 << 16)) >> 5; - $r3 = ($r3 - ' . $keys[--$j] . ' - - ((($r0 ^ $r1) & $r2) ^ $r0)) & 0xFFFF; - $r2 = ($r2 | ($r2 << 16)) >> 3; - $r2 = ($r2 - ' . $keys[--$j] . ' - - ((($r3 ^ $r0) & $r1) ^ $r3)) & 0xFFFF; - $r1 = ($r1 | ($r1 << 16)) >> 2; - $r1 = ($r1 - ' . $keys[--$j] . ' - - ((($r2 ^ $r3) & $r0) ^ $r2)) & 0xFFFF; - $r0 = ($r0 | ($r0 << 16)) >> 1; - $r0 = ($r0 - ' . $keys[--$j] . ' - - ((($r1 ^ $r2) & $r3) ^ $r1)) & 0xFFFF;'; - - if ($j === $limit) { - if ($limit === 0) { - break; - } - - // R-mashing round. - $decrypt_block .= ' - $r3 = ($r3 - $keys[$r2 & 0x3F]) & 0xFFFF; - $r2 = ($r2 - $keys[$r1 & 0x3F]) & 0xFFFF; - $r1 = ($r1 - $keys[$r0 & 0x3F]) & 0xFFFF; - $r0 = ($r0 - $keys[$r3 & 0x3F]) & 0xFFFF;'; - $limit = $actions[$limit]; - } - } - - $decrypt_block .= '$in = pack("v4", $r0, $r1, $r2, $r3);'; - - // Creates the inline-crypt function - $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( - array( - 'init_crypt' => $init_crypt, - 'encrypt_block' => $encrypt_block, - 'decrypt_block' => $decrypt_block - ) - ); - } - - // Set the inline-crypt function as callback in: $this->inline_crypt - $this->inline_crypt = $lambda_functions[$code_hash]; - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC4.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC4.php deleted file mode 100755 index b24129d2cb6aed0ee2f1b5ec9b1491b66eb98806..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC4.php +++ /dev/null @@ -1,341 +0,0 @@ -<?php - -/** - * Pure-PHP implementation of RC4. - * - * Uses mcrypt, if available, and an internal implementation, otherwise. - * - * PHP version 5 - * - * Useful resources are as follows: - * - * - {@link http://www.mozilla.org/projects/security/pki/nss/draft-kaukonen-cipher-arcfour-03.txt ARCFOUR Algorithm} - * - {@link http://en.wikipedia.org/wiki/RC4 - Wikipedia: RC4} - * - * RC4 is also known as ARCFOUR or ARC4. The reason is elaborated upon at Wikipedia. This class is named RC4 and not - * ARCFOUR or ARC4 because RC4 is how it is referred to in the SSH1 specification. - * - * Here's a short example of how to use this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $rc4 = new \phpseclib\Crypt\RC4(); - * - * $rc4->setKey('abcdefgh'); - * - * $size = 10 * 1024; - * $plaintext = ''; - * for ($i = 0; $i < $size; $i++) { - * $plaintext.= 'a'; - * } - * - * echo $rc4->decrypt($rc4->encrypt($plaintext)); - * ?> - * </code> - * - * @category Crypt - * @package RC4 - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2007 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Crypt; - -use phpseclib\Crypt\Base; - -/** - * Pure-PHP implementation of RC4. - * - * @package RC4 - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class RC4 extends Base -{ - /**#@+ - * @access private - * @see \phpseclib\Crypt\RC4::_crypt() - */ - const ENCRYPT = 0; - const DECRYPT = 1; - /**#@-*/ - - /** - * Block Length of the cipher - * - * RC4 is a stream cipher - * so we the block_size to 0 - * - * @see \phpseclib\Crypt\Base::block_size - * @var int - * @access private - */ - var $block_size = 0; - - /** - * Key Length (in bytes) - * - * @see \phpseclib\Crypt\RC4::setKeyLength() - * @var int - * @access private - */ - var $key_length = 128; // = 1024 bits - - /** - * The mcrypt specific name of the cipher - * - * @see \phpseclib\Crypt\Base::cipher_name_mcrypt - * @var string - * @access private - */ - var $cipher_name_mcrypt = 'arcfour'; - - /** - * Holds whether performance-optimized $inline_crypt() can/should be used. - * - * @see \phpseclib\Crypt\Base::inline_crypt - * @var mixed - * @access private - */ - var $use_inline_crypt = false; // currently not available - - /** - * The Key - * - * @see self::setKey() - * @var string - * @access private - */ - var $key = "\0"; - - /** - * The Key Stream for decryption and encryption - * - * @see self::setKey() - * @var array - * @access private - */ - var $stream; - - /** - * Default Constructor. - * - * Determines whether or not the mcrypt extension should be used. - * - * @see \phpseclib\Crypt\Base::__construct() - * @return \phpseclib\Crypt\RC4 - * @access public - */ - function __construct() - { - parent::__construct(Base::MODE_STREAM); - } - - /** - * Test for engine validity - * - * This is mainly just a wrapper to set things up for \phpseclib\Crypt\Base::isValidEngine() - * - * @see \phpseclib\Crypt\Base::__construct() - * @param int $engine - * @access public - * @return bool - */ - function isValidEngine($engine) - { - switch ($engine) { - case Base::ENGINE_OPENSSL: - switch (strlen($this->key)) { - case 5: - $this->cipher_name_openssl = 'rc4-40'; - break; - case 8: - $this->cipher_name_openssl = 'rc4-64'; - break; - case 16: - $this->cipher_name_openssl = 'rc4'; - break; - default: - return false; - } - } - - return parent::isValidEngine($engine); - } - - /** - * Dummy function. - * - * Some protocols, such as WEP, prepend an "initialization vector" to the key, effectively creating a new key [1]. - * If you need to use an initialization vector in this manner, feel free to prepend it to the key, yourself, before - * calling setKey(). - * - * [1] WEP's initialization vectors (IV's) are used in a somewhat insecure way. Since, in that protocol, - * the IV's are relatively easy to predict, an attack described by - * {@link http://www.drizzle.com/~aboba/IEEE/rc4_ksaproc.pdf Scott Fluhrer, Itsik Mantin, and Adi Shamir} - * can be used to quickly guess at the rest of the key. The following links elaborate: - * - * {@link http://www.rsa.com/rsalabs/node.asp?id=2009 http://www.rsa.com/rsalabs/node.asp?id=2009} - * {@link http://en.wikipedia.org/wiki/Related_key_attack http://en.wikipedia.org/wiki/Related_key_attack} - * - * @param string $iv - * @see self::setKey() - * @access public - */ - function setIV($iv) - { - } - - /** - * Sets the key length - * - * Keys can be between 1 and 256 bytes long. - * - * @access public - * @param int $length - */ - function setKeyLength($length) - { - if ($length < 8) { - $this->key_length = 1; - } elseif ($length > 2048) { - $this->key_length = 248; - } else { - $this->key_length = $length >> 3; - } - - parent::setKeyLength($length); - } - - /** - * Encrypts a message. - * - * @see \phpseclib\Crypt\Base::decrypt() - * @see self::_crypt() - * @access public - * @param string $plaintext - * @return string $ciphertext - */ - function encrypt($plaintext) - { - if ($this->engine != Base::ENGINE_INTERNAL) { - return parent::encrypt($plaintext); - } - return $this->_crypt($plaintext, self::ENCRYPT); - } - - /** - * Decrypts a message. - * - * $this->decrypt($this->encrypt($plaintext)) == $this->encrypt($this->encrypt($plaintext)). - * At least if the continuous buffer is disabled. - * - * @see \phpseclib\Crypt\Base::encrypt() - * @see self::_crypt() - * @access public - * @param string $ciphertext - * @return string $plaintext - */ - function decrypt($ciphertext) - { - if ($this->engine != Base::ENGINE_INTERNAL) { - return parent::decrypt($ciphertext); - } - return $this->_crypt($ciphertext, self::DECRYPT); - } - - /** - * Encrypts a block - * - * @access private - * @param string $in - */ - function _encryptBlock($in) - { - // RC4 does not utilize this method - } - - /** - * Decrypts a block - * - * @access private - * @param string $in - */ - function _decryptBlock($in) - { - // RC4 does not utilize this method - } - - /** - * Setup the key (expansion) - * - * @see \phpseclib\Crypt\Base::_setupKey() - * @access private - */ - function _setupKey() - { - $key = $this->key; - $keyLength = strlen($key); - $keyStream = range(0, 255); - $j = 0; - for ($i = 0; $i < 256; $i++) { - $j = ($j + $keyStream[$i] + ord($key[$i % $keyLength])) & 255; - $temp = $keyStream[$i]; - $keyStream[$i] = $keyStream[$j]; - $keyStream[$j] = $temp; - } - - $this->stream = array(); - $this->stream[self::DECRYPT] = $this->stream[self::ENCRYPT] = array( - 0, // index $i - 0, // index $j - $keyStream - ); - } - - /** - * Encrypts or decrypts a message. - * - * @see self::encrypt() - * @see self::decrypt() - * @access private - * @param string $text - * @param int $mode - * @return string $text - */ - function _crypt($text, $mode) - { - if ($this->changed) { - $this->_setup(); - $this->changed = false; - } - - $stream = &$this->stream[$mode]; - if ($this->continuousBuffer) { - $i = &$stream[0]; - $j = &$stream[1]; - $keyStream = &$stream[2]; - } else { - $i = $stream[0]; - $j = $stream[1]; - $keyStream = $stream[2]; - } - - $len = strlen($text); - for ($k = 0; $k < $len; ++$k) { - $i = ($i + 1) & 255; - $ksi = $keyStream[$i]; - $j = ($j + $ksi) & 255; - $ksj = $keyStream[$j]; - - $keyStream[$i] = $ksj; - $keyStream[$j] = $ksi; - $text[$k] = $text[$k] ^ chr($keyStream[($ksj + $ksi) & 255]); - } - - return $text; - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA.php deleted file mode 100755 index ba2a8d834eb2a9da6d1abd7c241bec451e462e31..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA.php +++ /dev/null @@ -1,3044 +0,0 @@ -<?php - -/** - * Pure-PHP PKCS#1 (v2.1) compliant implementation of RSA. - * - * PHP version 5 - * - * Here's an example of how to encrypt and decrypt text with this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $rsa = new \phpseclib\Crypt\RSA(); - * extract($rsa->createKey()); - * - * $plaintext = 'terrafrost'; - * - * $rsa->loadKey($privatekey); - * $ciphertext = $rsa->encrypt($plaintext); - * - * $rsa->loadKey($publickey); - * echo $rsa->decrypt($ciphertext); - * ?> - * </code> - * - * Here's an example of how to create signatures and verify signatures with this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $rsa = new \phpseclib\Crypt\RSA(); - * extract($rsa->createKey()); - * - * $plaintext = 'terrafrost'; - * - * $rsa->loadKey($privatekey); - * $signature = $rsa->sign($plaintext); - * - * $rsa->loadKey($publickey); - * echo $rsa->verify($plaintext, $signature) ? 'verified' : 'unverified'; - * ?> - * </code> - * - * @category Crypt - * @package RSA - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2009 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Crypt; - -use phpseclib\Crypt\AES; -use phpseclib\Crypt\Base; -use phpseclib\Crypt\DES; -use phpseclib\Crypt\Hash; -use phpseclib\Crypt\Random; -use phpseclib\Crypt\RSA; -use phpseclib\Crypt\TripleDES; -use phpseclib\Math\BigInteger; - -/** - * Pure-PHP PKCS#1 compliant implementation of RSA. - * - * @package RSA - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class RSA -{ - /**#@+ - * @access public - * @see self::encrypt() - * @see self::decrypt() - */ - /** - * Use {@link http://en.wikipedia.org/wiki/Optimal_Asymmetric_Encryption_Padding Optimal Asymmetric Encryption Padding} - * (OAEP) for encryption / decryption. - * - * Uses sha1 by default. - * - * @see self::setHash() - * @see self::setMGFHash() - */ - const ENCRYPTION_OAEP = 1; - /** - * Use PKCS#1 padding. - * - * Although self::ENCRYPTION_OAEP offers more security, including PKCS#1 padding is necessary for purposes of backwards - * compatibility with protocols (like SSH-1) written before OAEP's introduction. - */ - const ENCRYPTION_PKCS1 = 2; - /** - * Do not use any padding - * - * Although this method is not recommended it can none-the-less sometimes be useful if you're trying to decrypt some legacy - * stuff, if you're trying to diagnose why an encrypted message isn't decrypting, etc. - */ - const ENCRYPTION_NONE = 3; - /**#@-*/ - - /**#@+ - * @access public - * @see self::sign() - * @see self::verify() - * @see self::setHash() - */ - /** - * Use the Probabilistic Signature Scheme for signing - * - * Uses sha1 by default. - * - * @see self::setSaltLength() - * @see self::setMGFHash() - */ - const SIGNATURE_PSS = 1; - /** - * Use the PKCS#1 scheme by default. - * - * Although self::SIGNATURE_PSS offers more security, including PKCS#1 signing is necessary for purposes of backwards - * compatibility with protocols (like SSH-2) written before PSS's introduction. - */ - const SIGNATURE_PKCS1 = 2; - /**#@-*/ - - /**#@+ - * @access private - * @see \phpseclib\Crypt\RSA::createKey() - */ - /** - * ASN1 Integer - */ - const ASN1_INTEGER = 2; - /** - * ASN1 Bit String - */ - const ASN1_BITSTRING = 3; - /** - * ASN1 Octet String - */ - const ASN1_OCTETSTRING = 4; - /** - * ASN1 Object Identifier - */ - const ASN1_OBJECT = 6; - /** - * ASN1 Sequence (with the constucted bit set) - */ - const ASN1_SEQUENCE = 48; - /**#@-*/ - - /**#@+ - * @access private - * @see \phpseclib\Crypt\RSA::__construct() - */ - /** - * To use the pure-PHP implementation - */ - const MODE_INTERNAL = 1; - /** - * To use the OpenSSL library - * - * (if enabled; otherwise, the internal implementation will be used) - */ - const MODE_OPENSSL = 2; - /**#@-*/ - - /**#@+ - * @access public - * @see \phpseclib\Crypt\RSA::createKey() - * @see \phpseclib\Crypt\RSA::setPrivateKeyFormat() - */ - /** - * PKCS#1 formatted private key - * - * Used by OpenSSH - */ - const PRIVATE_FORMAT_PKCS1 = 0; - /** - * PuTTY formatted private key - */ - const PRIVATE_FORMAT_PUTTY = 1; - /** - * XML formatted private key - */ - const PRIVATE_FORMAT_XML = 2; - /** - * PKCS#8 formatted private key - */ - const PRIVATE_FORMAT_PKCS8 = 8; - /**#@-*/ - - /**#@+ - * @access public - * @see \phpseclib\Crypt\RSA::createKey() - * @see \phpseclib\Crypt\RSA::setPublicKeyFormat() - */ - /** - * Raw public key - * - * An array containing two \phpseclib\Math\BigInteger objects. - * - * The exponent can be indexed with any of the following: - * - * 0, e, exponent, publicExponent - * - * The modulus can be indexed with any of the following: - * - * 1, n, modulo, modulus - */ - const PUBLIC_FORMAT_RAW = 3; - /** - * PKCS#1 formatted public key (raw) - * - * Used by File/X509.php - * - * Has the following header: - * - * -----BEGIN RSA PUBLIC KEY----- - * - * Analogous to ssh-keygen's pem format (as specified by -m) - */ - const PUBLIC_FORMAT_PKCS1 = 4; - const PUBLIC_FORMAT_PKCS1_RAW = 4; - /** - * XML formatted public key - */ - const PUBLIC_FORMAT_XML = 5; - /** - * OpenSSH formatted public key - * - * Place in $HOME/.ssh/authorized_keys - */ - const PUBLIC_FORMAT_OPENSSH = 6; - /** - * PKCS#1 formatted public key (encapsulated) - * - * Used by PHP's openssl_public_encrypt() and openssl's rsautl (when -pubin is set) - * - * Has the following header: - * - * -----BEGIN PUBLIC KEY----- - * - * Analogous to ssh-keygen's pkcs8 format (as specified by -m). Although PKCS8 - * is specific to private keys it's basically creating a DER-encoded wrapper - * for keys. This just extends that same concept to public keys (much like ssh-keygen) - */ - const PUBLIC_FORMAT_PKCS8 = 7; - /**#@-*/ - - /** - * Precomputed Zero - * - * @var array - * @access private - */ - var $zero; - - /** - * Precomputed One - * - * @var array - * @access private - */ - var $one; - - /** - * Private Key Format - * - * @var int - * @access private - */ - var $privateKeyFormat = self::PRIVATE_FORMAT_PKCS1; - - /** - * Public Key Format - * - * @var int - * @access public - */ - var $publicKeyFormat = self::PUBLIC_FORMAT_PKCS8; - - /** - * Modulus (ie. n) - * - * @var \phpseclib\Math\BigInteger - * @access private - */ - var $modulus; - - /** - * Modulus length - * - * @var \phpseclib\Math\BigInteger - * @access private - */ - var $k; - - /** - * Exponent (ie. e or d) - * - * @var \phpseclib\Math\BigInteger - * @access private - */ - var $exponent; - - /** - * Primes for Chinese Remainder Theorem (ie. p and q) - * - * @var array - * @access private - */ - var $primes; - - /** - * Exponents for Chinese Remainder Theorem (ie. dP and dQ) - * - * @var array - * @access private - */ - var $exponents; - - /** - * Coefficients for Chinese Remainder Theorem (ie. qInv) - * - * @var array - * @access private - */ - var $coefficients; - - /** - * Hash name - * - * @var string - * @access private - */ - var $hashName; - - /** - * Hash function - * - * @var \phpseclib\Crypt\Hash - * @access private - */ - var $hash; - - /** - * Length of hash function output - * - * @var int - * @access private - */ - var $hLen; - - /** - * Length of salt - * - * @var int - * @access private - */ - var $sLen; - - /** - * Hash function for the Mask Generation Function - * - * @var \phpseclib\Crypt\Hash - * @access private - */ - var $mgfHash; - - /** - * Length of MGF hash function output - * - * @var int - * @access private - */ - var $mgfHLen; - - /** - * Encryption mode - * - * @var int - * @access private - */ - var $encryptionMode = self::ENCRYPTION_OAEP; - - /** - * Signature mode - * - * @var int - * @access private - */ - var $signatureMode = self::SIGNATURE_PSS; - - /** - * Public Exponent - * - * @var mixed - * @access private - */ - var $publicExponent = false; - - /** - * Password - * - * @var string - * @access private - */ - var $password = false; - - /** - * Components - * - * For use with parsing XML formatted keys. PHP's XML Parser functions use utilized - instead of PHP's DOM functions - - * because PHP's XML Parser functions work on PHP4 whereas PHP's DOM functions - although surperior - don't. - * - * @see self::_start_element_handler() - * @var array - * @access private - */ - var $components = array(); - - /** - * Current String - * - * For use with parsing XML formatted keys. - * - * @see self::_character_handler() - * @see self::_stop_element_handler() - * @var mixed - * @access private - */ - var $current; - - /** - * OpenSSL configuration file name. - * - * Set to null to use system configuration file. - * @see self::createKey() - * @var mixed - * @Access public - */ - var $configFile; - - /** - * Public key comment field. - * - * @var string - * @access private - */ - var $comment = 'phpseclib-generated-key'; - - /** - * The constructor - * - * If you want to make use of the openssl extension, you'll need to set the mode manually, yourself. The reason - * \phpseclib\Crypt\RSA doesn't do it is because OpenSSL doesn't fail gracefully. openssl_pkey_new(), in particular, requires - * openssl.cnf be present somewhere and, unfortunately, the only real way to find out is too late. - * - * @return \phpseclib\Crypt\RSA - * @access public - */ - function __construct() - { - $this->configFile = dirname(__FILE__) . '/../openssl.cnf'; - - if (!defined('CRYPT_RSA_MODE')) { - switch (true) { - // Math/BigInteger's openssl requirements are a little less stringent than Crypt/RSA's. in particular, - // Math/BigInteger doesn't require an openssl.cfg file whereas Crypt/RSA does. so if Math/BigInteger - // can't use OpenSSL it can be pretty trivially assumed, then, that Crypt/RSA can't either. - case defined('MATH_BIGINTEGER_OPENSSL_DISABLE'): - define('CRYPT_RSA_MODE', self::MODE_INTERNAL); - break; - case extension_loaded('openssl') && file_exists($this->configFile): - // some versions of XAMPP have mismatched versions of OpenSSL which causes it not to work - ob_start(); - @phpinfo(); - $content = ob_get_contents(); - ob_end_clean(); - - preg_match_all('#OpenSSL (Header|Library) Version(.*)#im', $content, $matches); - - $versions = array(); - if (!empty($matches[1])) { - for ($i = 0; $i < count($matches[1]); $i++) { - $fullVersion = trim(str_replace('=>', '', strip_tags($matches[2][$i]))); - - // Remove letter part in OpenSSL version - if (!preg_match('/(\d+\.\d+\.\d+)/i', $fullVersion, $m)) { - $versions[$matches[1][$i]] = $fullVersion; - } else { - $versions[$matches[1][$i]] = $m[0]; - } - } - } - - // it doesn't appear that OpenSSL versions were reported upon until PHP 5.3+ - switch (true) { - case !isset($versions['Header']): - case !isset($versions['Library']): - case $versions['Header'] == $versions['Library']: - define('CRYPT_RSA_MODE', self::MODE_OPENSSL); - break; - default: - define('CRYPT_RSA_MODE', self::MODE_INTERNAL); - define('MATH_BIGINTEGER_OPENSSL_DISABLE', true); - } - break; - default: - define('CRYPT_RSA_MODE', self::MODE_INTERNAL); - } - } - - $this->zero = new BigInteger(); - $this->one = new BigInteger(1); - - $this->hash = new Hash('sha1'); - $this->hLen = $this->hash->getLength(); - $this->hashName = 'sha1'; - $this->mgfHash = new Hash('sha1'); - $this->mgfHLen = $this->mgfHash->getLength(); - } - - /** - * Create public / private key pair - * - * Returns an array with the following three elements: - * - 'privatekey': The private key. - * - 'publickey': The public key. - * - 'partialkey': A partially computed key (if the execution time exceeded $timeout). - * Will need to be passed back to \phpseclib\Crypt\RSA::createKey() as the third parameter for further processing. - * - * @access public - * @param int $bits - * @param int $timeout - * @param array $p - */ - function createKey($bits = 1024, $timeout = false, $partial = array()) - { - if (!defined('CRYPT_RSA_EXPONENT')) { - // http://en.wikipedia.org/wiki/65537_%28number%29 - define('CRYPT_RSA_EXPONENT', '65537'); - } - // per <http://cseweb.ucsd.edu/~hovav/dist/survey.pdf#page=5>, this number ought not result in primes smaller - // than 256 bits. as a consequence if the key you're trying to create is 1024 bits and you've set CRYPT_RSA_SMALLEST_PRIME - // to 384 bits then you're going to get a 384 bit prime and a 640 bit prime (384 + 1024 % 384). at least if - // CRYPT_RSA_MODE is set to self::MODE_INTERNAL. if CRYPT_RSA_MODE is set to self::MODE_OPENSSL then - // CRYPT_RSA_SMALLEST_PRIME is ignored (ie. multi-prime RSA support is more intended as a way to speed up RSA key - // generation when there's a chance neither gmp nor OpenSSL are installed) - if (!defined('CRYPT_RSA_SMALLEST_PRIME')) { - define('CRYPT_RSA_SMALLEST_PRIME', 4096); - } - - // OpenSSL uses 65537 as the exponent and requires RSA keys be 384 bits minimum - if (CRYPT_RSA_MODE == self::MODE_OPENSSL && $bits >= 384 && CRYPT_RSA_EXPONENT == 65537) { - $config = array(); - if (isset($this->configFile)) { - $config['config'] = $this->configFile; - } - $rsa = openssl_pkey_new(array('private_key_bits' => $bits) + $config); - openssl_pkey_export($rsa, $privatekey, null, $config); - $publickey = openssl_pkey_get_details($rsa); - $publickey = $publickey['key']; - - $privatekey = call_user_func_array(array($this, '_convertPrivateKey'), array_values($this->_parseKey($privatekey, self::PRIVATE_FORMAT_PKCS1))); - $publickey = call_user_func_array(array($this, '_convertPublicKey'), array_values($this->_parseKey($publickey, self::PUBLIC_FORMAT_PKCS1))); - - // clear the buffer of error strings stemming from a minimalistic openssl.cnf - while (openssl_error_string() !== false) { - } - - return array( - 'privatekey' => $privatekey, - 'publickey' => $publickey, - 'partialkey' => false - ); - } - - static $e; - if (!isset($e)) { - $e = new BigInteger(CRYPT_RSA_EXPONENT); - } - - extract($this->_generateMinMax($bits)); - $absoluteMin = $min; - $temp = $bits >> 1; // divide by two to see how many bits P and Q would be - if ($temp > CRYPT_RSA_SMALLEST_PRIME) { - $num_primes = floor($bits / CRYPT_RSA_SMALLEST_PRIME); - $temp = CRYPT_RSA_SMALLEST_PRIME; - } else { - $num_primes = 2; - } - extract($this->_generateMinMax($temp + $bits % $temp)); - $finalMax = $max; - extract($this->_generateMinMax($temp)); - - $generator = new BigInteger(); - - $n = $this->one->copy(); - if (!empty($partial)) { - extract(unserialize($partial)); - } else { - $exponents = $coefficients = $primes = array(); - $lcm = array( - 'top' => $this->one->copy(), - 'bottom' => false - ); - } - - $start = time(); - $i0 = count($primes) + 1; - - do { - for ($i = $i0; $i <= $num_primes; $i++) { - if ($timeout !== false) { - $timeout-= time() - $start; - $start = time(); - if ($timeout <= 0) { - return array( - 'privatekey' => '', - 'publickey' => '', - 'partialkey' => serialize(array( - 'primes' => $primes, - 'coefficients' => $coefficients, - 'lcm' => $lcm, - 'exponents' => $exponents - )) - ); - } - } - - if ($i == $num_primes) { - list($min, $temp) = $absoluteMin->divide($n); - if (!$temp->equals($this->zero)) { - $min = $min->add($this->one); // ie. ceil() - } - $primes[$i] = $generator->randomPrime($min, $finalMax, $timeout); - } else { - $primes[$i] = $generator->randomPrime($min, $max, $timeout); - } - - if ($primes[$i] === false) { // if we've reached the timeout - if (count($primes) > 1) { - $partialkey = ''; - } else { - array_pop($primes); - $partialkey = serialize(array( - 'primes' => $primes, - 'coefficients' => $coefficients, - 'lcm' => $lcm, - 'exponents' => $exponents - )); - } - - return array( - 'privatekey' => '', - 'publickey' => '', - 'partialkey' => $partialkey - ); - } - - // the first coefficient is calculated differently from the rest - // ie. instead of being $primes[1]->modInverse($primes[2]), it's $primes[2]->modInverse($primes[1]) - if ($i > 2) { - $coefficients[$i] = $n->modInverse($primes[$i]); - } - - $n = $n->multiply($primes[$i]); - - $temp = $primes[$i]->subtract($this->one); - - // textbook RSA implementations use Euler's totient function instead of the least common multiple. - // see http://en.wikipedia.org/wiki/Euler%27s_totient_function - $lcm['top'] = $lcm['top']->multiply($temp); - $lcm['bottom'] = $lcm['bottom'] === false ? $temp : $lcm['bottom']->gcd($temp); - - $exponents[$i] = $e->modInverse($temp); - } - - list($temp) = $lcm['top']->divide($lcm['bottom']); - $gcd = $temp->gcd($e); - $i0 = 1; - } while (!$gcd->equals($this->one)); - - $d = $e->modInverse($temp); - - $coefficients[2] = $primes[2]->modInverse($primes[1]); - - // from <http://tools.ietf.org/html/rfc3447#appendix-A.1.2>: - // RSAPrivateKey ::= SEQUENCE { - // version Version, - // modulus INTEGER, -- n - // publicExponent INTEGER, -- e - // privateExponent INTEGER, -- d - // prime1 INTEGER, -- p - // prime2 INTEGER, -- q - // exponent1 INTEGER, -- d mod (p-1) - // exponent2 INTEGER, -- d mod (q-1) - // coefficient INTEGER, -- (inverse of q) mod p - // otherPrimeInfos OtherPrimeInfos OPTIONAL - // } - - return array( - 'privatekey' => $this->_convertPrivateKey($n, $e, $d, $primes, $exponents, $coefficients), - 'publickey' => $this->_convertPublicKey($n, $e), - 'partialkey' => false - ); - } - - /** - * Convert a private key to the appropriate format. - * - * @access private - * @see self::setPrivateKeyFormat() - * @param string $RSAPrivateKey - * @return string - */ - function _convertPrivateKey($n, $e, $d, $primes, $exponents, $coefficients) - { - $signed = $this->privateKeyFormat != self::PRIVATE_FORMAT_XML; - $num_primes = count($primes); - $raw = array( - 'version' => $num_primes == 2 ? chr(0) : chr(1), // two-prime vs. multi - 'modulus' => $n->toBytes($signed), - 'publicExponent' => $e->toBytes($signed), - 'privateExponent' => $d->toBytes($signed), - 'prime1' => $primes[1]->toBytes($signed), - 'prime2' => $primes[2]->toBytes($signed), - 'exponent1' => $exponents[1]->toBytes($signed), - 'exponent2' => $exponents[2]->toBytes($signed), - 'coefficient' => $coefficients[2]->toBytes($signed) - ); - - // if the format in question does not support multi-prime rsa and multi-prime rsa was used, - // call _convertPublicKey() instead. - switch ($this->privateKeyFormat) { - case self::PRIVATE_FORMAT_XML: - if ($num_primes != 2) { - return false; - } - return "<RSAKeyValue>\r\n" . - ' <Modulus>' . base64_encode($raw['modulus']) . "</Modulus>\r\n" . - ' <Exponent>' . base64_encode($raw['publicExponent']) . "</Exponent>\r\n" . - ' <P>' . base64_encode($raw['prime1']) . "</P>\r\n" . - ' <Q>' . base64_encode($raw['prime2']) . "</Q>\r\n" . - ' <DP>' . base64_encode($raw['exponent1']) . "</DP>\r\n" . - ' <DQ>' . base64_encode($raw['exponent2']) . "</DQ>\r\n" . - ' <InverseQ>' . base64_encode($raw['coefficient']) . "</InverseQ>\r\n" . - ' <D>' . base64_encode($raw['privateExponent']) . "</D>\r\n" . - '</RSAKeyValue>'; - break; - case self::PRIVATE_FORMAT_PUTTY: - if ($num_primes != 2) { - return false; - } - $key = "PuTTY-User-Key-File-2: ssh-rsa\r\nEncryption: "; - $encryption = (!empty($this->password) || is_string($this->password)) ? 'aes256-cbc' : 'none'; - $key.= $encryption; - $key.= "\r\nComment: " . $this->comment . "\r\n"; - $public = pack( - 'Na*Na*Na*', - strlen('ssh-rsa'), - 'ssh-rsa', - strlen($raw['publicExponent']), - $raw['publicExponent'], - strlen($raw['modulus']), - $raw['modulus'] - ); - $source = pack( - 'Na*Na*Na*Na*', - strlen('ssh-rsa'), - 'ssh-rsa', - strlen($encryption), - $encryption, - strlen($this->comment), - $this->comment, - strlen($public), - $public - ); - $public = base64_encode($public); - $key.= "Public-Lines: " . ((strlen($public) + 63) >> 6) . "\r\n"; - $key.= chunk_split($public, 64); - $private = pack( - 'Na*Na*Na*Na*', - strlen($raw['privateExponent']), - $raw['privateExponent'], - strlen($raw['prime1']), - $raw['prime1'], - strlen($raw['prime2']), - $raw['prime2'], - strlen($raw['coefficient']), - $raw['coefficient'] - ); - if (empty($this->password) && !is_string($this->password)) { - $source.= pack('Na*', strlen($private), $private); - $hashkey = 'putty-private-key-file-mac-key'; - } else { - $private.= Random::string(16 - (strlen($private) & 15)); - $source.= pack('Na*', strlen($private), $private); - $sequence = 0; - $symkey = ''; - while (strlen($symkey) < 32) { - $temp = pack('Na*', $sequence++, $this->password); - $symkey.= pack('H*', sha1($temp)); - } - $symkey = substr($symkey, 0, 32); - $crypto = new AES(); - - $crypto->setKey($symkey); - $crypto->disablePadding(); - $private = $crypto->encrypt($private); - $hashkey = 'putty-private-key-file-mac-key' . $this->password; - } - - $private = base64_encode($private); - $key.= 'Private-Lines: ' . ((strlen($private) + 63) >> 6) . "\r\n"; - $key.= chunk_split($private, 64); - $hash = new Hash('sha1'); - $hash->setKey(pack('H*', sha1($hashkey))); - $key.= 'Private-MAC: ' . bin2hex($hash->hash($source)) . "\r\n"; - - return $key; - default: // eg. self::PRIVATE_FORMAT_PKCS1 - $components = array(); - foreach ($raw as $name => $value) { - $components[$name] = pack('Ca*a*', self::ASN1_INTEGER, $this->_encodeLength(strlen($value)), $value); - } - - $RSAPrivateKey = implode('', $components); - - if ($num_primes > 2) { - $OtherPrimeInfos = ''; - for ($i = 3; $i <= $num_primes; $i++) { - // OtherPrimeInfos ::= SEQUENCE SIZE(1..MAX) OF OtherPrimeInfo - // - // OtherPrimeInfo ::= SEQUENCE { - // prime INTEGER, -- ri - // exponent INTEGER, -- di - // coefficient INTEGER -- ti - // } - $OtherPrimeInfo = pack('Ca*a*', self::ASN1_INTEGER, $this->_encodeLength(strlen($primes[$i]->toBytes(true))), $primes[$i]->toBytes(true)); - $OtherPrimeInfo.= pack('Ca*a*', self::ASN1_INTEGER, $this->_encodeLength(strlen($exponents[$i]->toBytes(true))), $exponents[$i]->toBytes(true)); - $OtherPrimeInfo.= pack('Ca*a*', self::ASN1_INTEGER, $this->_encodeLength(strlen($coefficients[$i]->toBytes(true))), $coefficients[$i]->toBytes(true)); - $OtherPrimeInfos.= pack('Ca*a*', self::ASN1_SEQUENCE, $this->_encodeLength(strlen($OtherPrimeInfo)), $OtherPrimeInfo); - } - $RSAPrivateKey.= pack('Ca*a*', self::ASN1_SEQUENCE, $this->_encodeLength(strlen($OtherPrimeInfos)), $OtherPrimeInfos); - } - - $RSAPrivateKey = pack('Ca*a*', self::ASN1_SEQUENCE, $this->_encodeLength(strlen($RSAPrivateKey)), $RSAPrivateKey); - - if ($this->privateKeyFormat == self::PRIVATE_FORMAT_PKCS8) { - $rsaOID = pack('H*', '300d06092a864886f70d0101010500'); // hex version of MA0GCSqGSIb3DQEBAQUA - $RSAPrivateKey = pack( - 'Ca*a*Ca*a*', - self::ASN1_INTEGER, - "\01\00", - $rsaOID, - 4, - $this->_encodeLength(strlen($RSAPrivateKey)), - $RSAPrivateKey - ); - $RSAPrivateKey = pack('Ca*a*', self::ASN1_SEQUENCE, $this->_encodeLength(strlen($RSAPrivateKey)), $RSAPrivateKey); - if (!empty($this->password) || is_string($this->password)) { - $salt = Random::string(8); - $iterationCount = 2048; - - $crypto = new DES(); - $crypto->setPassword($this->password, 'pbkdf1', 'md5', $salt, $iterationCount); - $RSAPrivateKey = $crypto->encrypt($RSAPrivateKey); - - $parameters = pack( - 'Ca*a*Ca*N', - self::ASN1_OCTETSTRING, - $this->_encodeLength(strlen($salt)), - $salt, - self::ASN1_INTEGER, - $this->_encodeLength(4), - $iterationCount - ); - $pbeWithMD5AndDES_CBC = "\x2a\x86\x48\x86\xf7\x0d\x01\x05\x03"; - - $encryptionAlgorithm = pack( - 'Ca*a*Ca*a*', - self::ASN1_OBJECT, - $this->_encodeLength(strlen($pbeWithMD5AndDES_CBC)), - $pbeWithMD5AndDES_CBC, - self::ASN1_SEQUENCE, - $this->_encodeLength(strlen($parameters)), - $parameters - ); - - $RSAPrivateKey = pack( - 'Ca*a*Ca*a*', - self::ASN1_SEQUENCE, - $this->_encodeLength(strlen($encryptionAlgorithm)), - $encryptionAlgorithm, - self::ASN1_OCTETSTRING, - $this->_encodeLength(strlen($RSAPrivateKey)), - $RSAPrivateKey - ); - - $RSAPrivateKey = pack('Ca*a*', self::ASN1_SEQUENCE, $this->_encodeLength(strlen($RSAPrivateKey)), $RSAPrivateKey); - - $RSAPrivateKey = "-----BEGIN ENCRYPTED PRIVATE KEY-----\r\n" . - chunk_split(base64_encode($RSAPrivateKey), 64) . - '-----END ENCRYPTED PRIVATE KEY-----'; - } else { - $RSAPrivateKey = "-----BEGIN PRIVATE KEY-----\r\n" . - chunk_split(base64_encode($RSAPrivateKey), 64) . - '-----END PRIVATE KEY-----'; - } - return $RSAPrivateKey; - } - - if (!empty($this->password) || is_string($this->password)) { - $iv = Random::string(8); - $symkey = pack('H*', md5($this->password . $iv)); // symkey is short for symmetric key - $symkey.= substr(pack('H*', md5($symkey . $this->password . $iv)), 0, 8); - $des = new TripleDES(); - $des->setKey($symkey); - $des->setIV($iv); - $iv = strtoupper(bin2hex($iv)); - $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n" . - "Proc-Type: 4,ENCRYPTED\r\n" . - "DEK-Info: DES-EDE3-CBC,$iv\r\n" . - "\r\n" . - chunk_split(base64_encode($des->encrypt($RSAPrivateKey)), 64) . - '-----END RSA PRIVATE KEY-----'; - } else { - $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n" . - chunk_split(base64_encode($RSAPrivateKey), 64) . - '-----END RSA PRIVATE KEY-----'; - } - - return $RSAPrivateKey; - } - } - - /** - * Convert a public key to the appropriate format - * - * @access private - * @see self::setPublicKeyFormat() - * @param string $RSAPrivateKey - * @return string - */ - function _convertPublicKey($n, $e) - { - $signed = $this->publicKeyFormat != self::PUBLIC_FORMAT_XML; - - $modulus = $n->toBytes($signed); - $publicExponent = $e->toBytes($signed); - - switch ($this->publicKeyFormat) { - case self::PUBLIC_FORMAT_RAW: - return array('e' => $e->copy(), 'n' => $n->copy()); - case self::PUBLIC_FORMAT_XML: - return "<RSAKeyValue>\r\n" . - ' <Modulus>' . base64_encode($modulus) . "</Modulus>\r\n" . - ' <Exponent>' . base64_encode($publicExponent) . "</Exponent>\r\n" . - '</RSAKeyValue>'; - break; - case self::PUBLIC_FORMAT_OPENSSH: - // from <http://tools.ietf.org/html/rfc4253#page-15>: - // string "ssh-rsa" - // mpint e - // mpint n - $RSAPublicKey = pack('Na*Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($publicExponent), $publicExponent, strlen($modulus), $modulus); - $RSAPublicKey = 'ssh-rsa ' . base64_encode($RSAPublicKey) . ' ' . $this->comment; - - return $RSAPublicKey; - default: // eg. self::PUBLIC_FORMAT_PKCS1_RAW or self::PUBLIC_FORMAT_PKCS1 - // from <http://tools.ietf.org/html/rfc3447#appendix-A.1.1>: - // RSAPublicKey ::= SEQUENCE { - // modulus INTEGER, -- n - // publicExponent INTEGER -- e - // } - $components = array( - 'modulus' => pack('Ca*a*', self::ASN1_INTEGER, $this->_encodeLength(strlen($modulus)), $modulus), - 'publicExponent' => pack('Ca*a*', self::ASN1_INTEGER, $this->_encodeLength(strlen($publicExponent)), $publicExponent) - ); - - $RSAPublicKey = pack( - 'Ca*a*a*', - self::ASN1_SEQUENCE, - $this->_encodeLength(strlen($components['modulus']) + strlen($components['publicExponent'])), - $components['modulus'], - $components['publicExponent'] - ); - - if ($this->publicKeyFormat == self::PUBLIC_FORMAT_PKCS1_RAW) { - $RSAPublicKey = "-----BEGIN RSA PUBLIC KEY-----\r\n" . - chunk_split(base64_encode($RSAPublicKey), 64) . - '-----END RSA PUBLIC KEY-----'; - } else { - // sequence(oid(1.2.840.113549.1.1.1), null)) = rsaEncryption. - $rsaOID = pack('H*', '300d06092a864886f70d0101010500'); // hex version of MA0GCSqGSIb3DQEBAQUA - $RSAPublicKey = chr(0) . $RSAPublicKey; - $RSAPublicKey = chr(3) . $this->_encodeLength(strlen($RSAPublicKey)) . $RSAPublicKey; - - $RSAPublicKey = pack( - 'Ca*a*', - self::ASN1_SEQUENCE, - $this->_encodeLength(strlen($rsaOID . $RSAPublicKey)), - $rsaOID . $RSAPublicKey - ); - - $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . - chunk_split(base64_encode($RSAPublicKey), 64) . - '-----END PUBLIC KEY-----'; - } - - return $RSAPublicKey; - } - } - - /** - * Break a public or private key down into its constituant components - * - * @access private - * @see self::_convertPublicKey() - * @see self::_convertPrivateKey() - * @param string $key - * @param int $type - * @return array - */ - function _parseKey($key, $type) - { - if ($type != self::PUBLIC_FORMAT_RAW && !is_string($key)) { - return false; - } - - switch ($type) { - case self::PUBLIC_FORMAT_RAW: - if (!is_array($key)) { - return false; - } - $components = array(); - switch (true) { - case isset($key['e']): - $components['publicExponent'] = $key['e']->copy(); - break; - case isset($key['exponent']): - $components['publicExponent'] = $key['exponent']->copy(); - break; - case isset($key['publicExponent']): - $components['publicExponent'] = $key['publicExponent']->copy(); - break; - case isset($key[0]): - $components['publicExponent'] = $key[0]->copy(); - } - switch (true) { - case isset($key['n']): - $components['modulus'] = $key['n']->copy(); - break; - case isset($key['modulo']): - $components['modulus'] = $key['modulo']->copy(); - break; - case isset($key['modulus']): - $components['modulus'] = $key['modulus']->copy(); - break; - case isset($key[1]): - $components['modulus'] = $key[1]->copy(); - } - return isset($components['modulus']) && isset($components['publicExponent']) ? $components : false; - case self::PRIVATE_FORMAT_PKCS1: - case self::PRIVATE_FORMAT_PKCS8: - case self::PUBLIC_FORMAT_PKCS1: - /* Although PKCS#1 proposes a format that public and private keys can use, encrypting them is - "outside the scope" of PKCS#1. PKCS#1 then refers you to PKCS#12 and PKCS#15 if you're wanting to - protect private keys, however, that's not what OpenSSL* does. OpenSSL protects private keys by adding - two new "fields" to the key - DEK-Info and Proc-Type. These fields are discussed here: - - http://tools.ietf.org/html/rfc1421#section-4.6.1.1 - http://tools.ietf.org/html/rfc1421#section-4.6.1.3 - - DES-EDE3-CBC as an algorithm, however, is not discussed anywhere, near as I can tell. - DES-CBC and DES-EDE are discussed in RFC1423, however, DES-EDE3-CBC isn't, nor is its key derivation - function. As is, the definitive authority on this encoding scheme isn't the IETF but rather OpenSSL's - own implementation. ie. the implementation *is* the standard and any bugs that may exist in that - implementation are part of the standard, as well. - - * OpenSSL is the de facto standard. It's utilized by OpenSSH and other projects */ - if (preg_match('#DEK-Info: (.+),(.+)#', $key, $matches)) { - $iv = pack('H*', trim($matches[2])); - $symkey = pack('H*', md5($this->password . substr($iv, 0, 8))); // symkey is short for symmetric key - $symkey.= pack('H*', md5($symkey . $this->password . substr($iv, 0, 8))); - // remove the Proc-Type / DEK-Info sections as they're no longer needed - $key = preg_replace('#^(?:Proc-Type|DEK-Info): .*#m', '', $key); - $ciphertext = $this->_extractBER($key); - if ($ciphertext === false) { - $ciphertext = $key; - } - switch ($matches[1]) { - case 'AES-256-CBC': - $crypto = new AES(); - break; - case 'AES-128-CBC': - $symkey = substr($symkey, 0, 16); - $crypto = new AES(); - break; - case 'DES-EDE3-CFB': - $crypto = new TripleDES(Base::MODE_CFB); - break; - case 'DES-EDE3-CBC': - $symkey = substr($symkey, 0, 24); - $crypto = new TripleDES(); - break; - case 'DES-CBC': - $crypto = new DES(); - break; - default: - return false; - } - $crypto->setKey($symkey); - $crypto->setIV($iv); - $decoded = $crypto->decrypt($ciphertext); - } else { - $decoded = $this->_extractBER($key); - } - - if ($decoded !== false) { - $key = $decoded; - } - - $components = array(); - - if (ord($this->_string_shift($key)) != self::ASN1_SEQUENCE) { - return false; - } - if ($this->_decodeLength($key) != strlen($key)) { - return false; - } - - $tag = ord($this->_string_shift($key)); - /* intended for keys for which OpenSSL's asn1parse returns the following: - - 0:d=0 hl=4 l= 631 cons: SEQUENCE - 4:d=1 hl=2 l= 1 prim: INTEGER :00 - 7:d=1 hl=2 l= 13 cons: SEQUENCE - 9:d=2 hl=2 l= 9 prim: OBJECT :rsaEncryption - 20:d=2 hl=2 l= 0 prim: NULL - 22:d=1 hl=4 l= 609 prim: OCTET STRING - - ie. PKCS8 keys*/ - - if ($tag == self::ASN1_INTEGER && substr($key, 0, 3) == "\x01\x00\x30") { - $this->_string_shift($key, 3); - $tag = self::ASN1_SEQUENCE; - } - - if ($tag == self::ASN1_SEQUENCE) { - $temp = $this->_string_shift($key, $this->_decodeLength($key)); - if (ord($this->_string_shift($temp)) != self::ASN1_OBJECT) { - return false; - } - $length = $this->_decodeLength($temp); - switch ($this->_string_shift($temp, $length)) { - case "\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01": // rsaEncryption - break; - case "\x2a\x86\x48\x86\xf7\x0d\x01\x05\x03": // pbeWithMD5AndDES-CBC - /* - PBEParameter ::= SEQUENCE { - salt OCTET STRING (SIZE(8)), - iterationCount INTEGER } - */ - if (ord($this->_string_shift($temp)) != self::ASN1_SEQUENCE) { - return false; - } - if ($this->_decodeLength($temp) != strlen($temp)) { - return false; - } - $this->_string_shift($temp); // assume it's an octet string - $salt = $this->_string_shift($temp, $this->_decodeLength($temp)); - if (ord($this->_string_shift($temp)) != self::ASN1_INTEGER) { - return false; - } - $this->_decodeLength($temp); - list(, $iterationCount) = unpack('N', str_pad($temp, 4, chr(0), STR_PAD_LEFT)); - $this->_string_shift($key); // assume it's an octet string - $length = $this->_decodeLength($key); - if (strlen($key) != $length) { - return false; - } - - $crypto = new DES(); - $crypto->setPassword($this->password, 'pbkdf1', 'md5', $salt, $iterationCount); - $key = $crypto->decrypt($key); - if ($key === false) { - return false; - } - return $this->_parseKey($key, self::PRIVATE_FORMAT_PKCS1); - default: - return false; - } - /* intended for keys for which OpenSSL's asn1parse returns the following: - - 0:d=0 hl=4 l= 290 cons: SEQUENCE - 4:d=1 hl=2 l= 13 cons: SEQUENCE - 6:d=2 hl=2 l= 9 prim: OBJECT :rsaEncryption - 17:d=2 hl=2 l= 0 prim: NULL - 19:d=1 hl=4 l= 271 prim: BIT STRING */ - $tag = ord($this->_string_shift($key)); // skip over the BIT STRING / OCTET STRING tag - $this->_decodeLength($key); // skip over the BIT STRING / OCTET STRING length - // "The initial octet shall encode, as an unsigned binary integer wtih bit 1 as the least significant bit, the number of - // unused bits in the final subsequent octet. The number shall be in the range zero to seven." - // -- http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf (section 8.6.2.2) - if ($tag == self::ASN1_BITSTRING) { - $this->_string_shift($key); - } - if (ord($this->_string_shift($key)) != self::ASN1_SEQUENCE) { - return false; - } - if ($this->_decodeLength($key) != strlen($key)) { - return false; - } - $tag = ord($this->_string_shift($key)); - } - if ($tag != self::ASN1_INTEGER) { - return false; - } - - $length = $this->_decodeLength($key); - $temp = $this->_string_shift($key, $length); - if (strlen($temp) != 1 || ord($temp) > 2) { - $components['modulus'] = new BigInteger($temp, 256); - $this->_string_shift($key); // skip over self::ASN1_INTEGER - $length = $this->_decodeLength($key); - $components[$type == self::PUBLIC_FORMAT_PKCS1 ? 'publicExponent' : 'privateExponent'] = new BigInteger($this->_string_shift($key, $length), 256); - - return $components; - } - if (ord($this->_string_shift($key)) != self::ASN1_INTEGER) { - return false; - } - $length = $this->_decodeLength($key); - $components['modulus'] = new BigInteger($this->_string_shift($key, $length), 256); - $this->_string_shift($key); - $length = $this->_decodeLength($key); - $components['publicExponent'] = new BigInteger($this->_string_shift($key, $length), 256); - $this->_string_shift($key); - $length = $this->_decodeLength($key); - $components['privateExponent'] = new BigInteger($this->_string_shift($key, $length), 256); - $this->_string_shift($key); - $length = $this->_decodeLength($key); - $components['primes'] = array(1 => new BigInteger($this->_string_shift($key, $length), 256)); - $this->_string_shift($key); - $length = $this->_decodeLength($key); - $components['primes'][] = new BigInteger($this->_string_shift($key, $length), 256); - $this->_string_shift($key); - $length = $this->_decodeLength($key); - $components['exponents'] = array(1 => new BigInteger($this->_string_shift($key, $length), 256)); - $this->_string_shift($key); - $length = $this->_decodeLength($key); - $components['exponents'][] = new BigInteger($this->_string_shift($key, $length), 256); - $this->_string_shift($key); - $length = $this->_decodeLength($key); - $components['coefficients'] = array(2 => new BigInteger($this->_string_shift($key, $length), 256)); - - if (!empty($key)) { - if (ord($this->_string_shift($key)) != self::ASN1_SEQUENCE) { - return false; - } - $this->_decodeLength($key); - while (!empty($key)) { - if (ord($this->_string_shift($key)) != self::ASN1_SEQUENCE) { - return false; - } - $this->_decodeLength($key); - $key = substr($key, 1); - $length = $this->_decodeLength($key); - $components['primes'][] = new BigInteger($this->_string_shift($key, $length), 256); - $this->_string_shift($key); - $length = $this->_decodeLength($key); - $components['exponents'][] = new BigInteger($this->_string_shift($key, $length), 256); - $this->_string_shift($key); - $length = $this->_decodeLength($key); - $components['coefficients'][] = new BigInteger($this->_string_shift($key, $length), 256); - } - } - - return $components; - case self::PUBLIC_FORMAT_OPENSSH: - $parts = explode(' ', $key, 3); - - $key = isset($parts[1]) ? base64_decode($parts[1]) : false; - if ($key === false) { - return false; - } - - $comment = isset($parts[2]) ? $parts[2] : false; - - $cleanup = substr($key, 0, 11) == "\0\0\0\7ssh-rsa"; - - if (strlen($key) <= 4) { - return false; - } - extract(unpack('Nlength', $this->_string_shift($key, 4))); - $publicExponent = new BigInteger($this->_string_shift($key, $length), -256); - if (strlen($key) <= 4) { - return false; - } - extract(unpack('Nlength', $this->_string_shift($key, 4))); - $modulus = new BigInteger($this->_string_shift($key, $length), -256); - - if ($cleanup && strlen($key)) { - if (strlen($key) <= 4) { - return false; - } - extract(unpack('Nlength', $this->_string_shift($key, 4))); - $realModulus = new BigInteger($this->_string_shift($key, $length), -256); - return strlen($key) ? false : array( - 'modulus' => $realModulus, - 'publicExponent' => $modulus, - 'comment' => $comment - ); - } else { - return strlen($key) ? false : array( - 'modulus' => $modulus, - 'publicExponent' => $publicExponent, - 'comment' => $comment - ); - } - // http://www.w3.org/TR/xmldsig-core/#sec-RSAKeyValue - // http://en.wikipedia.org/wiki/XML_Signature - case self::PRIVATE_FORMAT_XML: - case self::PUBLIC_FORMAT_XML: - $this->components = array(); - - $xml = xml_parser_create('UTF-8'); - xml_set_object($xml, $this); - xml_set_element_handler($xml, '_start_element_handler', '_stop_element_handler'); - xml_set_character_data_handler($xml, '_data_handler'); - // add <xml></xml> to account for "dangling" tags like <BitStrength>...</BitStrength> that are sometimes added - if (!xml_parse($xml, '<xml>' . $key . '</xml>')) { - return false; - } - - return isset($this->components['modulus']) && isset($this->components['publicExponent']) ? $this->components : false; - // from PuTTY's SSHPUBK.C - case self::PRIVATE_FORMAT_PUTTY: - $components = array(); - $key = preg_split('#\r\n|\r|\n#', $key); - $type = trim(preg_replace('#PuTTY-User-Key-File-2: (.+)#', '$1', $key[0])); - if ($type != 'ssh-rsa') { - return false; - } - $encryption = trim(preg_replace('#Encryption: (.+)#', '$1', $key[1])); - $comment = trim(preg_replace('#Comment: (.+)#', '$1', $key[2])); - - $publicLength = trim(preg_replace('#Public-Lines: (\d+)#', '$1', $key[3])); - $public = base64_decode(implode('', array_map('trim', array_slice($key, 4, $publicLength)))); - $public = substr($public, 11); - extract(unpack('Nlength', $this->_string_shift($public, 4))); - $components['publicExponent'] = new BigInteger($this->_string_shift($public, $length), -256); - extract(unpack('Nlength', $this->_string_shift($public, 4))); - $components['modulus'] = new BigInteger($this->_string_shift($public, $length), -256); - - $privateLength = trim(preg_replace('#Private-Lines: (\d+)#', '$1', $key[$publicLength + 4])); - $private = base64_decode(implode('', array_map('trim', array_slice($key, $publicLength + 5, $privateLength)))); - - switch ($encryption) { - case 'aes256-cbc': - $symkey = ''; - $sequence = 0; - while (strlen($symkey) < 32) { - $temp = pack('Na*', $sequence++, $this->password); - $symkey.= pack('H*', sha1($temp)); - } - $symkey = substr($symkey, 0, 32); - $crypto = new AES(); - } - - if ($encryption != 'none') { - $crypto->setKey($symkey); - $crypto->disablePadding(); - $private = $crypto->decrypt($private); - if ($private === false) { - return false; - } - } - - extract(unpack('Nlength', $this->_string_shift($private, 4))); - if (strlen($private) < $length) { - return false; - } - $components['privateExponent'] = new BigInteger($this->_string_shift($private, $length), -256); - extract(unpack('Nlength', $this->_string_shift($private, 4))); - if (strlen($private) < $length) { - return false; - } - $components['primes'] = array(1 => new BigInteger($this->_string_shift($private, $length), -256)); - extract(unpack('Nlength', $this->_string_shift($private, 4))); - if (strlen($private) < $length) { - return false; - } - $components['primes'][] = new BigInteger($this->_string_shift($private, $length), -256); - - $temp = $components['primes'][1]->subtract($this->one); - $components['exponents'] = array(1 => $components['publicExponent']->modInverse($temp)); - $temp = $components['primes'][2]->subtract($this->one); - $components['exponents'][] = $components['publicExponent']->modInverse($temp); - - extract(unpack('Nlength', $this->_string_shift($private, 4))); - if (strlen($private) < $length) { - return false; - } - $components['coefficients'] = array(2 => new BigInteger($this->_string_shift($private, $length), -256)); - - return $components; - } - } - - /** - * Returns the key size - * - * More specifically, this returns the size of the modulo in bits. - * - * @access public - * @return int - */ - function getSize() - { - return !isset($this->modulus) ? 0 : strlen($this->modulus->toBits()); - } - - /** - * Start Element Handler - * - * Called by xml_set_element_handler() - * - * @access private - * @param resource $parser - * @param string $name - * @param array $attribs - */ - function _start_element_handler($parser, $name, $attribs) - { - //$name = strtoupper($name); - switch ($name) { - case 'MODULUS': - $this->current = &$this->components['modulus']; - break; - case 'EXPONENT': - $this->current = &$this->components['publicExponent']; - break; - case 'P': - $this->current = &$this->components['primes'][1]; - break; - case 'Q': - $this->current = &$this->components['primes'][2]; - break; - case 'DP': - $this->current = &$this->components['exponents'][1]; - break; - case 'DQ': - $this->current = &$this->components['exponents'][2]; - break; - case 'INVERSEQ': - $this->current = &$this->components['coefficients'][2]; - break; - case 'D': - $this->current = &$this->components['privateExponent']; - } - $this->current = ''; - } - - /** - * Stop Element Handler - * - * Called by xml_set_element_handler() - * - * @access private - * @param resource $parser - * @param string $name - */ - function _stop_element_handler($parser, $name) - { - if (isset($this->current)) { - $this->current = new BigInteger(base64_decode($this->current), 256); - unset($this->current); - } - } - - /** - * Data Handler - * - * Called by xml_set_character_data_handler() - * - * @access private - * @param resource $parser - * @param string $data - */ - function _data_handler($parser, $data) - { - if (!isset($this->current) || is_object($this->current)) { - return; - } - $this->current.= trim($data); - } - - /** - * Loads a public or private key - * - * Returns true on success and false on failure (ie. an incorrect password was provided or the key was malformed) - * - * @access public - * @param string $key - * @param int $type optional - */ - function loadKey($key, $type = false) - { - if ($key instanceof RSA) { - $this->privateKeyFormat = $key->privateKeyFormat; - $this->publicKeyFormat = $key->publicKeyFormat; - $this->k = $key->k; - $this->hLen = $key->hLen; - $this->sLen = $key->sLen; - $this->mgfHLen = $key->mgfHLen; - $this->encryptionMode = $key->encryptionMode; - $this->signatureMode = $key->signatureMode; - $this->password = $key->password; - $this->configFile = $key->configFile; - $this->comment = $key->comment; - - if (is_object($key->hash)) { - $this->hash = new Hash($key->hash->getHash()); - } - if (is_object($key->mgfHash)) { - $this->mgfHash = new Hash($key->mgfHash->getHash()); - } - - if (is_object($key->modulus)) { - $this->modulus = $key->modulus->copy(); - } - if (is_object($key->exponent)) { - $this->exponent = $key->exponent->copy(); - } - if (is_object($key->publicExponent)) { - $this->publicExponent = $key->publicExponent->copy(); - } - - $this->primes = array(); - $this->exponents = array(); - $this->coefficients = array(); - - foreach ($this->primes as $prime) { - $this->primes[] = $prime->copy(); - } - foreach ($this->exponents as $exponent) { - $this->exponents[] = $exponent->copy(); - } - foreach ($this->coefficients as $coefficient) { - $this->coefficients[] = $coefficient->copy(); - } - - return true; - } - - if ($type === false) { - $types = array( - self::PUBLIC_FORMAT_RAW, - self::PRIVATE_FORMAT_PKCS1, - self::PRIVATE_FORMAT_XML, - self::PRIVATE_FORMAT_PUTTY, - self::PUBLIC_FORMAT_OPENSSH - ); - foreach ($types as $type) { - $components = $this->_parseKey($key, $type); - if ($components !== false) { - break; - } - } - } else { - $components = $this->_parseKey($key, $type); - } - - if ($components === false) { - return false; - } - - if (isset($components['comment']) && $components['comment'] !== false) { - $this->comment = $components['comment']; - } - $this->modulus = $components['modulus']; - $this->k = strlen($this->modulus->toBytes()); - $this->exponent = isset($components['privateExponent']) ? $components['privateExponent'] : $components['publicExponent']; - if (isset($components['primes'])) { - $this->primes = $components['primes']; - $this->exponents = $components['exponents']; - $this->coefficients = $components['coefficients']; - $this->publicExponent = $components['publicExponent']; - } else { - $this->primes = array(); - $this->exponents = array(); - $this->coefficients = array(); - $this->publicExponent = false; - } - - switch ($type) { - case self::PUBLIC_FORMAT_OPENSSH: - case self::PUBLIC_FORMAT_RAW: - $this->setPublicKey(); - break; - case self::PRIVATE_FORMAT_PKCS1: - switch (true) { - case strpos($key, '-BEGIN PUBLIC KEY-') !== false: - case strpos($key, '-BEGIN RSA PUBLIC KEY-') !== false: - $this->setPublicKey(); - } - } - - return true; - } - - /** - * Sets the password - * - * Private keys can be encrypted with a password. To unset the password, pass in the empty string or false. - * Or rather, pass in $password such that empty($password) && !is_string($password) is true. - * - * @see self::createKey() - * @see self::loadKey() - * @access public - * @param string $password - */ - function setPassword($password = false) - { - $this->password = $password; - } - - /** - * Defines the public key - * - * Some private key formats define the public exponent and some don't. Those that don't define it are problematic when - * used in certain contexts. For example, in SSH-2, RSA authentication works by sending the public key along with a - * message signed by the private key to the server. The SSH-2 server looks the public key up in an index of public keys - * and if it's present then proceeds to verify the signature. Problem is, if your private key doesn't include the public - * exponent this won't work unless you manually add the public exponent. phpseclib tries to guess if the key being used - * is the public key but in the event that it guesses incorrectly you might still want to explicitly set the key as being - * public. - * - * Do note that when a new key is loaded the index will be cleared. - * - * Returns true on success, false on failure - * - * @see self::getPublicKey() - * @access public - * @param string $key optional - * @param int $type optional - * @return bool - */ - function setPublicKey($key = false, $type = false) - { - // if a public key has already been loaded return false - if (!empty($this->publicExponent)) { - return false; - } - - if ($key === false && !empty($this->modulus)) { - $this->publicExponent = $this->exponent; - return true; - } - - if ($type === false) { - $types = array( - self::PUBLIC_FORMAT_RAW, - self::PUBLIC_FORMAT_PKCS1, - self::PUBLIC_FORMAT_XML, - self::PUBLIC_FORMAT_OPENSSH - ); - foreach ($types as $type) { - $components = $this->_parseKey($key, $type); - if ($components !== false) { - break; - } - } - } else { - $components = $this->_parseKey($key, $type); - } - - if ($components === false) { - return false; - } - - if (empty($this->modulus) || !$this->modulus->equals($components['modulus'])) { - $this->modulus = $components['modulus']; - $this->exponent = $this->publicExponent = $components['publicExponent']; - return true; - } - - $this->publicExponent = $components['publicExponent']; - - return true; - } - - /** - * Defines the private key - * - * If phpseclib guessed a private key was a public key and loaded it as such it might be desirable to force - * phpseclib to treat the key as a private key. This function will do that. - * - * Do note that when a new key is loaded the index will be cleared. - * - * Returns true on success, false on failure - * - * @see self::getPublicKey() - * @access public - * @param string $key optional - * @param int $type optional - * @return bool - */ - function setPrivateKey($key = false, $type = false) - { - if ($key === false && !empty($this->publicExponent)) { - unset($this->publicExponent); - return true; - } - - $rsa = new RSA(); - if (!$rsa->loadKey($key, $type)) { - return false; - } - unset($rsa->publicExponent); - - // don't overwrite the old key if the new key is invalid - $this->loadKey($rsa); - return true; - } - - /** - * Returns the public key - * - * The public key is only returned under two circumstances - if the private key had the public key embedded within it - * or if the public key was set via setPublicKey(). If the currently loaded key is supposed to be the public key this - * function won't return it since this library, for the most part, doesn't distinguish between public and private keys. - * - * @see self::getPublicKey() - * @access public - * @param string $key - * @param int $type optional - */ - function getPublicKey($type = self::PUBLIC_FORMAT_PKCS8) - { - if (empty($this->modulus) || empty($this->publicExponent)) { - return false; - } - - $oldFormat = $this->publicKeyFormat; - $this->publicKeyFormat = $type; - $temp = $this->_convertPublicKey($this->modulus, $this->publicExponent); - $this->publicKeyFormat = $oldFormat; - return $temp; - } - - /** - * Returns the public key's fingerprint - * - * The public key's fingerprint is returned, which is equivalent to running `ssh-keygen -lf rsa.pub`. If there is - * no public key currently loaded, false is returned. - * Example output (md5): "c1:b1:30:29:d7:b8:de:6c:97:77:10:d7:46:41:63:87" (as specified by RFC 4716) - * - * @access public - * @param string $algorithm The hashing algorithm to be used. Valid options are 'md5' and 'sha256'. False is returned - * for invalid values. - * @return mixed - */ - public function getPublicKeyFingerprint($algorithm = 'md5') - { - if (empty($this->modulus) || empty($this->publicExponent)) { - return false; - } - - $modulus = $this->modulus->toBytes(true); - $publicExponent = $this->publicExponent->toBytes(true); - - $RSAPublicKey = pack('Na*Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($publicExponent), $publicExponent, strlen($modulus), $modulus); - - switch ($algorithm) { - case 'sha256': - $hash = new Hash('sha256'); - $base = base64_encode($hash->hash($RSAPublicKey)); - return substr($base, 0, strlen($base) - 1); - case 'md5': - return substr(chunk_split(md5($RSAPublicKey), 2, ':'), 0, -1); - default: - return false; - } - } - - /** - * Returns the private key - * - * The private key is only returned if the currently loaded key contains the constituent prime numbers. - * - * @see self::getPublicKey() - * @access public - * @param string $key - * @param int $type optional - * @return mixed - */ - function getPrivateKey($type = self::PUBLIC_FORMAT_PKCS1) - { - if (empty($this->primes)) { - return false; - } - - $oldFormat = $this->privateKeyFormat; - $this->privateKeyFormat = $type; - $temp = $this->_convertPrivateKey($this->modulus, $this->publicExponent, $this->exponent, $this->primes, $this->exponents, $this->coefficients); - $this->privateKeyFormat = $oldFormat; - return $temp; - } - - /** - * Returns a minimalistic private key - * - * Returns the private key without the prime number constituants. Structurally identical to a public key that - * hasn't been set as the public key - * - * @see self::getPrivateKey() - * @access private - * @param string $key - * @param int $type optional - */ - function _getPrivatePublicKey($mode = self::PUBLIC_FORMAT_PKCS8) - { - if (empty($this->modulus) || empty($this->exponent)) { - return false; - } - - $oldFormat = $this->publicKeyFormat; - $this->publicKeyFormat = $mode; - $temp = $this->_convertPublicKey($this->modulus, $this->exponent); - $this->publicKeyFormat = $oldFormat; - return $temp; - } - - /** - * __toString() magic method - * - * @access public - * @return string - */ - function __toString() - { - $key = $this->getPrivateKey($this->privateKeyFormat); - if ($key !== false) { - return $key; - } - $key = $this->_getPrivatePublicKey($this->publicKeyFormat); - return $key !== false ? $key : ''; - } - - /** - * __clone() magic method - * - * @access public - * @return Crypt_RSA - */ - function __clone() - { - $key = new RSA(); - $key->loadKey($this); - return $key; - } - - /** - * Generates the smallest and largest numbers requiring $bits bits - * - * @access private - * @param int $bits - * @return array - */ - function _generateMinMax($bits) - { - $bytes = $bits >> 3; - $min = str_repeat(chr(0), $bytes); - $max = str_repeat(chr(0xFF), $bytes); - $msb = $bits & 7; - if ($msb) { - $min = chr(1 << ($msb - 1)) . $min; - $max = chr((1 << $msb) - 1) . $max; - } else { - $min[0] = chr(0x80); - } - - return array( - 'min' => new BigInteger($min, 256), - 'max' => new BigInteger($max, 256) - ); - } - - /** - * DER-decode the length - * - * DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See - * {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information. - * - * @access private - * @param string $string - * @return int - */ - function _decodeLength(&$string) - { - $length = ord($this->_string_shift($string)); - if ($length & 0x80) { // definite length, long form - $length&= 0x7F; - $temp = $this->_string_shift($string, $length); - list(, $length) = unpack('N', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)); - } - return $length; - } - - /** - * DER-encode the length - * - * DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See - * {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information. - * - * @access private - * @param int $length - * @return string - */ - function _encodeLength($length) - { - if ($length <= 0x7F) { - return chr($length); - } - - $temp = ltrim(pack('N', $length), chr(0)); - return pack('Ca*', 0x80 | strlen($temp), $temp); - } - - /** - * String Shift - * - * Inspired by array_shift - * - * @param string $string - * @param int $index - * @return string - * @access private - */ - function _string_shift(&$string, $index = 1) - { - $substr = substr($string, 0, $index); - $string = substr($string, $index); - return $substr; - } - - /** - * Determines the private key format - * - * @see self::createKey() - * @access public - * @param int $format - */ - function setPrivateKeyFormat($format) - { - $this->privateKeyFormat = $format; - } - - /** - * Determines the public key format - * - * @see self::createKey() - * @access public - * @param int $format - */ - function setPublicKeyFormat($format) - { - $this->publicKeyFormat = $format; - } - - /** - * Determines which hashing function should be used - * - * Used with signature production / verification and (if the encryption mode is self::ENCRYPTION_OAEP) encryption and - * decryption. If $hash isn't supported, sha1 is used. - * - * @access public - * @param string $hash - */ - function setHash($hash) - { - // \phpseclib\Crypt\Hash supports algorithms that PKCS#1 doesn't support. md5-96 and sha1-96, for example. - switch ($hash) { - case 'md2': - case 'md5': - case 'sha1': - case 'sha256': - case 'sha384': - case 'sha512': - $this->hash = new Hash($hash); - $this->hashName = $hash; - break; - default: - $this->hash = new Hash('sha1'); - $this->hashName = 'sha1'; - } - $this->hLen = $this->hash->getLength(); - } - - /** - * Determines which hashing function should be used for the mask generation function - * - * The mask generation function is used by self::ENCRYPTION_OAEP and self::SIGNATURE_PSS and although it's - * best if Hash and MGFHash are set to the same thing this is not a requirement. - * - * @access public - * @param string $hash - */ - function setMGFHash($hash) - { - // \phpseclib\Crypt\Hash supports algorithms that PKCS#1 doesn't support. md5-96 and sha1-96, for example. - switch ($hash) { - case 'md2': - case 'md5': - case 'sha1': - case 'sha256': - case 'sha384': - case 'sha512': - $this->mgfHash = new Hash($hash); - break; - default: - $this->mgfHash = new Hash('sha1'); - } - $this->mgfHLen = $this->mgfHash->getLength(); - } - - /** - * Determines the salt length - * - * To quote from {@link http://tools.ietf.org/html/rfc3447#page-38 RFC3447#page-38}: - * - * Typical salt lengths in octets are hLen (the length of the output - * of the hash function Hash) and 0. - * - * @access public - * @param int $format - */ - function setSaltLength($sLen) - { - $this->sLen = $sLen; - } - - /** - * Integer-to-Octet-String primitive - * - * See {@link http://tools.ietf.org/html/rfc3447#section-4.1 RFC3447#section-4.1}. - * - * @access private - * @param \phpseclib\Math\BigInteger $x - * @param int $xLen - * @return string - */ - function _i2osp($x, $xLen) - { - $x = $x->toBytes(); - if (strlen($x) > $xLen) { - user_error('Integer too large'); - return false; - } - return str_pad($x, $xLen, chr(0), STR_PAD_LEFT); - } - - /** - * Octet-String-to-Integer primitive - * - * See {@link http://tools.ietf.org/html/rfc3447#section-4.2 RFC3447#section-4.2}. - * - * @access private - * @param string $x - * @return \phpseclib\Math\BigInteger - */ - function _os2ip($x) - { - return new BigInteger($x, 256); - } - - /** - * Exponentiate with or without Chinese Remainder Theorem - * - * See {@link http://tools.ietf.org/html/rfc3447#section-5.1.1 RFC3447#section-5.1.2}. - * - * @access private - * @param \phpseclib\Math\BigInteger $x - * @return \phpseclib\Math\BigInteger - */ - function _exponentiate($x) - { - if (empty($this->primes) || empty($this->coefficients) || empty($this->exponents)) { - return $x->modPow($this->exponent, $this->modulus); - } - - $num_primes = count($this->primes); - - if (defined('CRYPT_RSA_DISABLE_BLINDING')) { - $m_i = array( - 1 => $x->modPow($this->exponents[1], $this->primes[1]), - 2 => $x->modPow($this->exponents[2], $this->primes[2]) - ); - $h = $m_i[1]->subtract($m_i[2]); - $h = $h->multiply($this->coefficients[2]); - list(, $h) = $h->divide($this->primes[1]); - $m = $m_i[2]->add($h->multiply($this->primes[2])); - - $r = $this->primes[1]; - for ($i = 3; $i <= $num_primes; $i++) { - $m_i = $x->modPow($this->exponents[$i], $this->primes[$i]); - - $r = $r->multiply($this->primes[$i - 1]); - - $h = $m_i->subtract($m); - $h = $h->multiply($this->coefficients[$i]); - list(, $h) = $h->divide($this->primes[$i]); - - $m = $m->add($r->multiply($h)); - } - } else { - $smallest = $this->primes[1]; - for ($i = 2; $i <= $num_primes; $i++) { - if ($smallest->compare($this->primes[$i]) > 0) { - $smallest = $this->primes[$i]; - } - } - - $one = new BigInteger(1); - - $r = $one->random($one, $smallest->subtract($one)); - - $m_i = array( - 1 => $this->_blind($x, $r, 1), - 2 => $this->_blind($x, $r, 2) - ); - $h = $m_i[1]->subtract($m_i[2]); - $h = $h->multiply($this->coefficients[2]); - list(, $h) = $h->divide($this->primes[1]); - $m = $m_i[2]->add($h->multiply($this->primes[2])); - - $r = $this->primes[1]; - for ($i = 3; $i <= $num_primes; $i++) { - $m_i = $this->_blind($x, $r, $i); - - $r = $r->multiply($this->primes[$i - 1]); - - $h = $m_i->subtract($m); - $h = $h->multiply($this->coefficients[$i]); - list(, $h) = $h->divide($this->primes[$i]); - - $m = $m->add($r->multiply($h)); - } - } - - return $m; - } - - /** - * Performs RSA Blinding - * - * Protects against timing attacks by employing RSA Blinding. - * Returns $x->modPow($this->exponents[$i], $this->primes[$i]) - * - * @access private - * @param \phpseclib\Math\BigInteger $x - * @param \phpseclib\Math\BigInteger $r - * @param int $i - * @return \phpseclib\Math\BigInteger - */ - function _blind($x, $r, $i) - { - $x = $x->multiply($r->modPow($this->publicExponent, $this->primes[$i])); - $x = $x->modPow($this->exponents[$i], $this->primes[$i]); - - $r = $r->modInverse($this->primes[$i]); - $x = $x->multiply($r); - list(, $x) = $x->divide($this->primes[$i]); - - return $x; - } - - /** - * Performs blinded RSA equality testing - * - * Protects against a particular type of timing attack described. - * - * See {@link http://codahale.com/a-lesson-in-timing-attacks/ A Lesson In Timing Attacks (or, Don't use MessageDigest.isEquals)} - * - * Thanks for the heads up singpolyma! - * - * @access private - * @param string $x - * @param string $y - * @return bool - */ - function _equals($x, $y) - { - if (strlen($x) != strlen($y)) { - return false; - } - - $result = 0; - for ($i = 0; $i < strlen($x); $i++) { - $result |= ord($x[$i]) ^ ord($y[$i]); - } - - return $result == 0; - } - - /** - * RSAEP - * - * See {@link http://tools.ietf.org/html/rfc3447#section-5.1.1 RFC3447#section-5.1.1}. - * - * @access private - * @param \phpseclib\Math\BigInteger $m - * @return \phpseclib\Math\BigInteger - */ - function _rsaep($m) - { - if ($m->compare($this->zero) < 0 || $m->compare($this->modulus) > 0) { - user_error('Message representative out of range'); - return false; - } - return $this->_exponentiate($m); - } - - /** - * RSADP - * - * See {@link http://tools.ietf.org/html/rfc3447#section-5.1.2 RFC3447#section-5.1.2}. - * - * @access private - * @param \phpseclib\Math\BigInteger $c - * @return \phpseclib\Math\BigInteger - */ - function _rsadp($c) - { - if ($c->compare($this->zero) < 0 || $c->compare($this->modulus) > 0) { - user_error('Ciphertext representative out of range'); - return false; - } - return $this->_exponentiate($c); - } - - /** - * RSASP1 - * - * See {@link http://tools.ietf.org/html/rfc3447#section-5.2.1 RFC3447#section-5.2.1}. - * - * @access private - * @param \phpseclib\Math\BigInteger $m - * @return \phpseclib\Math\BigInteger - */ - function _rsasp1($m) - { - if ($m->compare($this->zero) < 0 || $m->compare($this->modulus) > 0) { - user_error('Message representative out of range'); - return false; - } - return $this->_exponentiate($m); - } - - /** - * RSAVP1 - * - * See {@link http://tools.ietf.org/html/rfc3447#section-5.2.2 RFC3447#section-5.2.2}. - * - * @access private - * @param \phpseclib\Math\BigInteger $s - * @return \phpseclib\Math\BigInteger - */ - function _rsavp1($s) - { - if ($s->compare($this->zero) < 0 || $s->compare($this->modulus) > 0) { - user_error('Signature representative out of range'); - return false; - } - return $this->_exponentiate($s); - } - - /** - * MGF1 - * - * See {@link http://tools.ietf.org/html/rfc3447#appendix-B.2.1 RFC3447#appendix-B.2.1}. - * - * @access private - * @param string $mgfSeed - * @param int $mgfLen - * @return string - */ - function _mgf1($mgfSeed, $maskLen) - { - // if $maskLen would yield strings larger than 4GB, PKCS#1 suggests a "Mask too long" error be output. - - $t = ''; - $count = ceil($maskLen / $this->mgfHLen); - for ($i = 0; $i < $count; $i++) { - $c = pack('N', $i); - $t.= $this->mgfHash->hash($mgfSeed . $c); - } - - return substr($t, 0, $maskLen); - } - - /** - * RSAES-OAEP-ENCRYPT - * - * See {@link http://tools.ietf.org/html/rfc3447#section-7.1.1 RFC3447#section-7.1.1} and - * {http://en.wikipedia.org/wiki/Optimal_Asymmetric_Encryption_Padding OAES}. - * - * @access private - * @param string $m - * @param string $l - * @return string - */ - function _rsaes_oaep_encrypt($m, $l = '') - { - $mLen = strlen($m); - - // Length checking - - // if $l is larger than two million terrabytes and you're using sha1, PKCS#1 suggests a "Label too long" error - // be output. - - if ($mLen > $this->k - 2 * $this->hLen - 2) { - user_error('Message too long'); - return false; - } - - // EME-OAEP encoding - - $lHash = $this->hash->hash($l); - $ps = str_repeat(chr(0), $this->k - $mLen - 2 * $this->hLen - 2); - $db = $lHash . $ps . chr(1) . $m; - $seed = Random::string($this->hLen); - $dbMask = $this->_mgf1($seed, $this->k - $this->hLen - 1); - $maskedDB = $db ^ $dbMask; - $seedMask = $this->_mgf1($maskedDB, $this->hLen); - $maskedSeed = $seed ^ $seedMask; - $em = chr(0) . $maskedSeed . $maskedDB; - - // RSA encryption - - $m = $this->_os2ip($em); - $c = $this->_rsaep($m); - $c = $this->_i2osp($c, $this->k); - - // Output the ciphertext C - - return $c; - } - - /** - * RSAES-OAEP-DECRYPT - * - * See {@link http://tools.ietf.org/html/rfc3447#section-7.1.2 RFC3447#section-7.1.2}. The fact that the error - * messages aren't distinguishable from one another hinders debugging, but, to quote from RFC3447#section-7.1.2: - * - * Note. Care must be taken to ensure that an opponent cannot - * distinguish the different error conditions in Step 3.g, whether by - * error message or timing, or, more generally, learn partial - * information about the encoded message EM. Otherwise an opponent may - * be able to obtain useful information about the decryption of the - * ciphertext C, leading to a chosen-ciphertext attack such as the one - * observed by Manger [36]. - * - * As for $l... to quote from {@link http://tools.ietf.org/html/rfc3447#page-17 RFC3447#page-17}: - * - * Both the encryption and the decryption operations of RSAES-OAEP take - * the value of a label L as input. In this version of PKCS #1, L is - * the empty string; other uses of the label are outside the scope of - * this document. - * - * @access private - * @param string $c - * @param string $l - * @return string - */ - function _rsaes_oaep_decrypt($c, $l = '') - { - // Length checking - - // if $l is larger than two million terrabytes and you're using sha1, PKCS#1 suggests a "Label too long" error - // be output. - - if (strlen($c) != $this->k || $this->k < 2 * $this->hLen + 2) { - user_error('Decryption error'); - return false; - } - - // RSA decryption - - $c = $this->_os2ip($c); - $m = $this->_rsadp($c); - if ($m === false) { - user_error('Decryption error'); - return false; - } - $em = $this->_i2osp($m, $this->k); - - // EME-OAEP decoding - - $lHash = $this->hash->hash($l); - $y = ord($em[0]); - $maskedSeed = substr($em, 1, $this->hLen); - $maskedDB = substr($em, $this->hLen + 1); - $seedMask = $this->_mgf1($maskedDB, $this->hLen); - $seed = $maskedSeed ^ $seedMask; - $dbMask = $this->_mgf1($seed, $this->k - $this->hLen - 1); - $db = $maskedDB ^ $dbMask; - $lHash2 = substr($db, 0, $this->hLen); - $m = substr($db, $this->hLen); - if ($lHash != $lHash2) { - user_error('Decryption error'); - return false; - } - $m = ltrim($m, chr(0)); - if (ord($m[0]) != 1) { - user_error('Decryption error'); - return false; - } - - // Output the message M - - return substr($m, 1); - } - - /** - * Raw Encryption / Decryption - * - * Doesn't use padding and is not recommended. - * - * @access private - * @param string $m - * @return string - */ - function _raw_encrypt($m) - { - $temp = $this->_os2ip($m); - $temp = $this->_rsaep($temp); - return $this->_i2osp($temp, $this->k); - } - - /** - * RSAES-PKCS1-V1_5-ENCRYPT - * - * See {@link http://tools.ietf.org/html/rfc3447#section-7.2.1 RFC3447#section-7.2.1}. - * - * @access private - * @param string $m - * @return string - */ - function _rsaes_pkcs1_v1_5_encrypt($m) - { - $mLen = strlen($m); - - // Length checking - - if ($mLen > $this->k - 11) { - user_error('Message too long'); - return false; - } - - // EME-PKCS1-v1_5 encoding - - $psLen = $this->k - $mLen - 3; - $ps = ''; - while (strlen($ps) != $psLen) { - $temp = Random::string($psLen - strlen($ps)); - $temp = str_replace("\x00", '', $temp); - $ps.= $temp; - } - $type = 2; - // see the comments of _rsaes_pkcs1_v1_5_decrypt() to understand why this is being done - if (defined('CRYPT_RSA_PKCS15_COMPAT') && (!isset($this->publicExponent) || $this->exponent !== $this->publicExponent)) { - $type = 1; - // "The padding string PS shall consist of k-3-||D|| octets. ... for block type 01, they shall have value FF" - $ps = str_repeat("\xFF", $psLen); - } - $em = chr(0) . chr($type) . $ps . chr(0) . $m; - - // RSA encryption - $m = $this->_os2ip($em); - $c = $this->_rsaep($m); - $c = $this->_i2osp($c, $this->k); - - // Output the ciphertext C - - return $c; - } - - /** - * RSAES-PKCS1-V1_5-DECRYPT - * - * See {@link http://tools.ietf.org/html/rfc3447#section-7.2.2 RFC3447#section-7.2.2}. - * - * For compatibility purposes, this function departs slightly from the description given in RFC3447. - * The reason being that RFC2313#section-8.1 (PKCS#1 v1.5) states that ciphertext's encrypted by the - * private key should have the second byte set to either 0 or 1 and that ciphertext's encrypted by the - * public key should have the second byte set to 2. In RFC3447 (PKCS#1 v2.1), the second byte is supposed - * to be 2 regardless of which key is used. For compatibility purposes, we'll just check to make sure the - * second byte is 2 or less. If it is, we'll accept the decrypted string as valid. - * - * As a consequence of this, a private key encrypted ciphertext produced with \phpseclib\Crypt\RSA may not decrypt - * with a strictly PKCS#1 v1.5 compliant RSA implementation. Public key encrypted ciphertext's should but - * not private key encrypted ciphertext's. - * - * @access private - * @param string $c - * @return string - */ - function _rsaes_pkcs1_v1_5_decrypt($c) - { - // Length checking - - if (strlen($c) != $this->k) { // or if k < 11 - user_error('Decryption error'); - return false; - } - - // RSA decryption - - $c = $this->_os2ip($c); - $m = $this->_rsadp($c); - - if ($m === false) { - user_error('Decryption error'); - return false; - } - $em = $this->_i2osp($m, $this->k); - - // EME-PKCS1-v1_5 decoding - - if (ord($em[0]) != 0 || ord($em[1]) > 2) { - user_error('Decryption error'); - return false; - } - - $ps = substr($em, 2, strpos($em, chr(0), 2) - 2); - $m = substr($em, strlen($ps) + 3); - - if (strlen($ps) < 8) { - user_error('Decryption error'); - return false; - } - - // Output M - - return $m; - } - - /** - * EMSA-PSS-ENCODE - * - * See {@link http://tools.ietf.org/html/rfc3447#section-9.1.1 RFC3447#section-9.1.1}. - * - * @access private - * @param string $m - * @param int $emBits - */ - function _emsa_pss_encode($m, $emBits) - { - // if $m is larger than two million terrabytes and you're using sha1, PKCS#1 suggests a "Label too long" error - // be output. - - $emLen = ($emBits + 1) >> 3; // ie. ceil($emBits / 8) - $sLen = $this->sLen ? $this->sLen : $this->hLen; - - $mHash = $this->hash->hash($m); - if ($emLen < $this->hLen + $sLen + 2) { - user_error('Encoding error'); - return false; - } - - $salt = Random::string($sLen); - $m2 = "\0\0\0\0\0\0\0\0" . $mHash . $salt; - $h = $this->hash->hash($m2); - $ps = str_repeat(chr(0), $emLen - $sLen - $this->hLen - 2); - $db = $ps . chr(1) . $salt; - $dbMask = $this->_mgf1($h, $emLen - $this->hLen - 1); - $maskedDB = $db ^ $dbMask; - $maskedDB[0] = ~chr(0xFF << ($emBits & 7)) & $maskedDB[0]; - $em = $maskedDB . $h . chr(0xBC); - - return $em; - } - - /** - * EMSA-PSS-VERIFY - * - * See {@link http://tools.ietf.org/html/rfc3447#section-9.1.2 RFC3447#section-9.1.2}. - * - * @access private - * @param string $m - * @param string $em - * @param int $emBits - * @return string - */ - function _emsa_pss_verify($m, $em, $emBits) - { - // if $m is larger than two million terrabytes and you're using sha1, PKCS#1 suggests a "Label too long" error - // be output. - - $emLen = ($emBits + 1) >> 3; // ie. ceil($emBits / 8); - $sLen = $this->sLen ? $this->sLen : $this->hLen; - - $mHash = $this->hash->hash($m); - if ($emLen < $this->hLen + $sLen + 2) { - return false; - } - - if ($em[strlen($em) - 1] != chr(0xBC)) { - return false; - } - - $maskedDB = substr($em, 0, -$this->hLen - 1); - $h = substr($em, -$this->hLen - 1, $this->hLen); - $temp = chr(0xFF << ($emBits & 7)); - if ((~$maskedDB[0] & $temp) != $temp) { - return false; - } - $dbMask = $this->_mgf1($h, $emLen - $this->hLen - 1); - $db = $maskedDB ^ $dbMask; - $db[0] = ~chr(0xFF << ($emBits & 7)) & $db[0]; - $temp = $emLen - $this->hLen - $sLen - 2; - if (substr($db, 0, $temp) != str_repeat(chr(0), $temp) || ord($db[$temp]) != 1) { - return false; - } - $salt = substr($db, $temp + 1); // should be $sLen long - $m2 = "\0\0\0\0\0\0\0\0" . $mHash . $salt; - $h2 = $this->hash->hash($m2); - return $this->_equals($h, $h2); - } - - /** - * RSASSA-PSS-SIGN - * - * See {@link http://tools.ietf.org/html/rfc3447#section-8.1.1 RFC3447#section-8.1.1}. - * - * @access private - * @param string $m - * @return string - */ - function _rsassa_pss_sign($m) - { - // EMSA-PSS encoding - - $em = $this->_emsa_pss_encode($m, 8 * $this->k - 1); - - // RSA signature - - $m = $this->_os2ip($em); - $s = $this->_rsasp1($m); - $s = $this->_i2osp($s, $this->k); - - // Output the signature S - - return $s; - } - - /** - * RSASSA-PSS-VERIFY - * - * See {@link http://tools.ietf.org/html/rfc3447#section-8.1.2 RFC3447#section-8.1.2}. - * - * @access private - * @param string $m - * @param string $s - * @return string - */ - function _rsassa_pss_verify($m, $s) - { - // Length checking - - if (strlen($s) != $this->k) { - user_error('Invalid signature'); - return false; - } - - // RSA verification - - $modBits = 8 * $this->k; - - $s2 = $this->_os2ip($s); - $m2 = $this->_rsavp1($s2); - if ($m2 === false) { - user_error('Invalid signature'); - return false; - } - $em = $this->_i2osp($m2, $modBits >> 3); - if ($em === false) { - user_error('Invalid signature'); - return false; - } - - // EMSA-PSS verification - - return $this->_emsa_pss_verify($m, $em, $modBits - 1); - } - - /** - * EMSA-PKCS1-V1_5-ENCODE - * - * See {@link http://tools.ietf.org/html/rfc3447#section-9.2 RFC3447#section-9.2}. - * - * @access private - * @param string $m - * @param int $emLen - * @return string - */ - function _emsa_pkcs1_v1_5_encode($m, $emLen) - { - $h = $this->hash->hash($m); - if ($h === false) { - return false; - } - - // see http://tools.ietf.org/html/rfc3447#page-43 - switch ($this->hashName) { - case 'md2': - $t = pack('H*', '3020300c06082a864886f70d020205000410'); - break; - case 'md5': - $t = pack('H*', '3020300c06082a864886f70d020505000410'); - break; - case 'sha1': - $t = pack('H*', '3021300906052b0e03021a05000414'); - break; - case 'sha256': - $t = pack('H*', '3031300d060960864801650304020105000420'); - break; - case 'sha384': - $t = pack('H*', '3041300d060960864801650304020205000430'); - break; - case 'sha512': - $t = pack('H*', '3051300d060960864801650304020305000440'); - } - $t.= $h; - $tLen = strlen($t); - - if ($emLen < $tLen + 11) { - user_error('Intended encoded message length too short'); - return false; - } - - $ps = str_repeat(chr(0xFF), $emLen - $tLen - 3); - - $em = "\0\1$ps\0$t"; - - return $em; - } - - /** - * RSASSA-PKCS1-V1_5-SIGN - * - * See {@link http://tools.ietf.org/html/rfc3447#section-8.2.1 RFC3447#section-8.2.1}. - * - * @access private - * @param string $m - * @return string - */ - function _rsassa_pkcs1_v1_5_sign($m) - { - // EMSA-PKCS1-v1_5 encoding - - $em = $this->_emsa_pkcs1_v1_5_encode($m, $this->k); - if ($em === false) { - user_error('RSA modulus too short'); - return false; - } - - // RSA signature - - $m = $this->_os2ip($em); - $s = $this->_rsasp1($m); - $s = $this->_i2osp($s, $this->k); - - // Output the signature S - - return $s; - } - - /** - * RSASSA-PKCS1-V1_5-VERIFY - * - * See {@link http://tools.ietf.org/html/rfc3447#section-8.2.2 RFC3447#section-8.2.2}. - * - * @access private - * @param string $m - * @return string - */ - function _rsassa_pkcs1_v1_5_verify($m, $s) - { - // Length checking - - if (strlen($s) != $this->k) { - user_error('Invalid signature'); - return false; - } - - // RSA verification - - $s = $this->_os2ip($s); - $m2 = $this->_rsavp1($s); - if ($m2 === false) { - user_error('Invalid signature'); - return false; - } - $em = $this->_i2osp($m2, $this->k); - if ($em === false) { - user_error('Invalid signature'); - return false; - } - - // EMSA-PKCS1-v1_5 encoding - - $em2 = $this->_emsa_pkcs1_v1_5_encode($m, $this->k); - if ($em2 === false) { - user_error('RSA modulus too short'); - return false; - } - - // Compare - return $this->_equals($em, $em2); - } - - /** - * Set Encryption Mode - * - * Valid values include self::ENCRYPTION_OAEP and self::ENCRYPTION_PKCS1. - * - * @access public - * @param int $mode - */ - function setEncryptionMode($mode) - { - $this->encryptionMode = $mode; - } - - /** - * Set Signature Mode - * - * Valid values include self::SIGNATURE_PSS and self::SIGNATURE_PKCS1 - * - * @access public - * @param int $mode - */ - function setSignatureMode($mode) - { - $this->signatureMode = $mode; - } - - /** - * Set public key comment. - * - * @access public - * @param string $comment - */ - function setComment($comment) - { - $this->comment = $comment; - } - - /** - * Get public key comment. - * - * @access public - * @return string - */ - function getComment() - { - return $this->comment; - } - - /** - * Encryption - * - * Both self::ENCRYPTION_OAEP and self::ENCRYPTION_PKCS1 both place limits on how long $plaintext can be. - * If $plaintext exceeds those limits it will be broken up so that it does and the resultant ciphertext's will - * be concatenated together. - * - * @see self::decrypt() - * @access public - * @param string $plaintext - * @return string - */ - function encrypt($plaintext) - { - switch ($this->encryptionMode) { - case self::ENCRYPTION_NONE: - $plaintext = str_split($plaintext, $this->k); - $ciphertext = ''; - foreach ($plaintext as $m) { - $ciphertext.= $this->_raw_encrypt($m); - } - return $ciphertext; - case self::ENCRYPTION_PKCS1: - $length = $this->k - 11; - if ($length <= 0) { - return false; - } - - $plaintext = str_split($plaintext, $length); - $ciphertext = ''; - foreach ($plaintext as $m) { - $ciphertext.= $this->_rsaes_pkcs1_v1_5_encrypt($m); - } - return $ciphertext; - //case self::ENCRYPTION_OAEP: - default: - $length = $this->k - 2 * $this->hLen - 2; - if ($length <= 0) { - return false; - } - - $plaintext = str_split($plaintext, $length); - $ciphertext = ''; - foreach ($plaintext as $m) { - $ciphertext.= $this->_rsaes_oaep_encrypt($m); - } - return $ciphertext; - } - } - - /** - * Decryption - * - * @see self::encrypt() - * @access public - * @param string $plaintext - * @return string - */ - function decrypt($ciphertext) - { - if ($this->k <= 0) { - return false; - } - - $ciphertext = str_split($ciphertext, $this->k); - $ciphertext[count($ciphertext) - 1] = str_pad($ciphertext[count($ciphertext) - 1], $this->k, chr(0), STR_PAD_LEFT); - - $plaintext = ''; - - switch ($this->encryptionMode) { - case self::ENCRYPTION_NONE: - $decrypt = '_raw_encrypt'; - break; - case self::ENCRYPTION_PKCS1: - $decrypt = '_rsaes_pkcs1_v1_5_decrypt'; - break; - //case self::ENCRYPTION_OAEP: - default: - $decrypt = '_rsaes_oaep_decrypt'; - } - - foreach ($ciphertext as $c) { - $temp = $this->$decrypt($c); - if ($temp === false) { - return false; - } - $plaintext.= $temp; - } - - return $plaintext; - } - - /** - * Create a signature - * - * @see self::verify() - * @access public - * @param string $message - * @return string - */ - function sign($message) - { - if (empty($this->modulus) || empty($this->exponent)) { - return false; - } - - switch ($this->signatureMode) { - case self::SIGNATURE_PKCS1: - return $this->_rsassa_pkcs1_v1_5_sign($message); - //case self::SIGNATURE_PSS: - default: - return $this->_rsassa_pss_sign($message); - } - } - - /** - * Verifies a signature - * - * @see self::sign() - * @access public - * @param string $message - * @param string $signature - * @return bool - */ - function verify($message, $signature) - { - if (empty($this->modulus) || empty($this->exponent)) { - return false; - } - - switch ($this->signatureMode) { - case self::SIGNATURE_PKCS1: - return $this->_rsassa_pkcs1_v1_5_verify($message, $signature); - //case self::SIGNATURE_PSS: - default: - return $this->_rsassa_pss_verify($message, $signature); - } - } - - /** - * Extract raw BER from Base64 encoding - * - * @access private - * @param string $str - * @return string - */ - function _extractBER($str) - { - /* X.509 certs are assumed to be base64 encoded but sometimes they'll have additional things in them - * above and beyond the ceritificate. - * ie. some may have the following preceding the -----BEGIN CERTIFICATE----- line: - * - * Bag Attributes - * localKeyID: 01 00 00 00 - * subject=/O=organization/OU=org unit/CN=common name - * issuer=/O=organization/CN=common name - */ - $temp = preg_replace('#.*?^-+[^-]+-+[\r\n ]*$#ms', '', $str, 1); - // remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff - $temp = preg_replace('#-+[^-]+-+#', '', $temp); - // remove new lines - $temp = str_replace(array("\r", "\n", ' '), '', $temp); - $temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? base64_decode($temp) : false; - return $temp != false ? $temp : $str; - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php deleted file mode 100755 index 586bd6c4d54044a97fa645b15989d440310a54e5..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php +++ /dev/null @@ -1,243 +0,0 @@ -<?php - -/** - * Random Number Generator - * - * PHP version 5 - * - * Here's a short example of how to use this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * echo bin2hex(\phpseclib\Crypt\Random::string(8)); - * ?> - * </code> - * - * @category Crypt - * @package Random - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2007 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Crypt; - -use phpseclib\Crypt\AES; -use phpseclib\Crypt\Base; -use phpseclib\Crypt\Blowfish; -use phpseclib\Crypt\DES; -use phpseclib\Crypt\RC4; -use phpseclib\Crypt\TripleDES; -use phpseclib\Crypt\Twofish; - -/** - * Pure-PHP Random Number Generator - * - * @package Random - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class Random -{ - /** - * Generate a random string. - * - * Although microoptimizations are generally discouraged as they impair readability this function is ripe with - * microoptimizations because this function has the potential of being called a huge number of times. - * eg. for RSA key generation. - * - * @param int $length - * @return string - */ - static function string($length) - { - if (version_compare(PHP_VERSION, '7.0.0', '>=')) { - try { - return \random_bytes($length); - } catch (\Throwable $e) { - // If a sufficient source of randomness is unavailable, random_bytes() will throw an - // object that implements the Throwable interface (Exception, TypeError, Error). - // We don't actually need to do anything here. The string() method should just continue - // as normal. Note, however, that if we don't have a sufficient source of randomness for - // random_bytes(), most of the other calls here will fail too, so we'll end up using - // the PHP implementation. - } - } - - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - // method 1. prior to PHP 5.3 this would call rand() on windows hence the function_exists('class_alias') call. - // ie. class_alias is a function that was introduced in PHP 5.3 - if (extension_loaded('mcrypt') && function_exists('class_alias')) { - return mcrypt_create_iv($length); - } - // method 2. openssl_random_pseudo_bytes was introduced in PHP 5.3.0 but prior to PHP 5.3.4 there was, - // to quote <http://php.net/ChangeLog-5.php#5.3.4>, "possible blocking behavior". as of 5.3.4 - // openssl_random_pseudo_bytes and mcrypt_create_iv do the exact same thing on Windows. ie. they both - // call php_win32_get_random_bytes(): - // - // https://github.com/php/php-src/blob/7014a0eb6d1611151a286c0ff4f2238f92c120d6/ext/openssl/openssl.c#L5008 - // https://github.com/php/php-src/blob/7014a0eb6d1611151a286c0ff4f2238f92c120d6/ext/mcrypt/mcrypt.c#L1392 - // - // php_win32_get_random_bytes() is defined thusly: - // - // https://github.com/php/php-src/blob/7014a0eb6d1611151a286c0ff4f2238f92c120d6/win32/winutil.c#L80 - // - // we're calling it, all the same, in the off chance that the mcrypt extension is not available - if (extension_loaded('openssl') && version_compare(PHP_VERSION, '5.3.4', '>=')) { - return openssl_random_pseudo_bytes($length); - } - } else { - // method 1. the fastest - if (extension_loaded('openssl')) { - return openssl_random_pseudo_bytes($length); - } - // method 2 - static $fp = true; - if ($fp === true) { - // warning's will be output unles the error suppression operator is used. errors such as - // "open_basedir restriction in effect", "Permission denied", "No such file or directory", etc. - $fp = @fopen('/dev/urandom', 'rb'); - } - if ($fp !== true && $fp !== false) { // surprisingly faster than !is_bool() or is_resource() - return fread($fp, $length); - } - // method 3. pretty much does the same thing as method 2 per the following url: - // https://github.com/php/php-src/blob/7014a0eb6d1611151a286c0ff4f2238f92c120d6/ext/mcrypt/mcrypt.c#L1391 - // surprisingly slower than method 2. maybe that's because mcrypt_create_iv does a bunch of error checking that we're - // not doing. regardless, this'll only be called if this PHP script couldn't open /dev/urandom due to open_basedir - // restrictions or some such - if (extension_loaded('mcrypt')) { - return mcrypt_create_iv($length, MCRYPT_DEV_URANDOM); - } - } - // at this point we have no choice but to use a pure-PHP CSPRNG - - // cascade entropy across multiple PHP instances by fixing the session and collecting all - // environmental variables, including the previous session data and the current session - // data. - // - // mt_rand seeds itself by looking at the PID and the time, both of which are (relatively) - // easy to guess at. linux uses mouse clicks, keyboard timings, etc, as entropy sources, but - // PHP isn't low level to be able to use those as sources and on a web server there's not likely - // going to be a ton of keyboard or mouse action. web servers do have one thing that we can use - // however, a ton of people visiting the website. obviously you don't want to base your seeding - // soley on parameters a potential attacker sends but (1) not everything in $_SERVER is controlled - // by the user and (2) this isn't just looking at the data sent by the current user - it's based - // on the data sent by all users. one user requests the page and a hash of their info is saved. - // another user visits the page and the serialization of their data is utilized along with the - // server envirnment stuff and a hash of the previous http request data (which itself utilizes - // a hash of the session data before that). certainly an attacker should be assumed to have - // full control over his own http requests. he, however, is not going to have control over - // everyone's http requests. - static $crypto = false, $v; - if ($crypto === false) { - // save old session data - $old_session_id = session_id(); - $old_use_cookies = ini_get('session.use_cookies'); - $old_session_cache_limiter = session_cache_limiter(); - $_OLD_SESSION = isset($_SESSION) ? $_SESSION : false; - if ($old_session_id != '') { - session_write_close(); - } - - session_id(1); - ini_set('session.use_cookies', 0); - session_cache_limiter(''); - session_start(); - - $v = $seed = $_SESSION['seed'] = pack('H*', sha1( - serialize($_SERVER) . - serialize($_POST) . - serialize($_GET) . - serialize($_COOKIE) . - serialize($GLOBALS) . - serialize($_SESSION) . - serialize($_OLD_SESSION) - )); - if (!isset($_SESSION['count'])) { - $_SESSION['count'] = 0; - } - $_SESSION['count']++; - - session_write_close(); - - // restore old session data - if ($old_session_id != '') { - session_id($old_session_id); - session_start(); - ini_set('session.use_cookies', $old_use_cookies); - session_cache_limiter($old_session_cache_limiter); - } else { - if ($_OLD_SESSION !== false) { - $_SESSION = $_OLD_SESSION; - unset($_OLD_SESSION); - } else { - unset($_SESSION); - } - } - - // in SSH2 a shared secret and an exchange hash are generated through the key exchange process. - // the IV client to server is the hash of that "nonce" with the letter A and for the encryption key it's the letter C. - // if the hash doesn't produce enough a key or an IV that's long enough concat successive hashes of the - // original hash and the current hash. we'll be emulating that. for more info see the following URL: - // - // http://tools.ietf.org/html/rfc4253#section-7.2 - // - // see the is_string($crypto) part for an example of how to expand the keys - $key = pack('H*', sha1($seed . 'A')); - $iv = pack('H*', sha1($seed . 'C')); - - // ciphers are used as per the nist.gov link below. also, see this link: - // - // http://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator#Designs_based_on_cryptographic_primitives - switch (true) { - case class_exists('\phpseclib\Crypt\AES'): - $crypto = new AES(Base::MODE_CTR); - break; - case class_exists('\phpseclib\Crypt\Twofish'): - $crypto = new Twofish(Base::MODE_CTR); - break; - case class_exists('\phpseclib\Crypt\Blowfish'): - $crypto = new Blowfish(Base::MODE_CTR); - break; - case class_exists('\phpseclib\Crypt\TripleDES'): - $crypto = new TripleDES(Base::MODE_CTR); - break; - case class_exists('\phpseclib\Crypt\DES'): - $crypto = new DES(Base::MODE_CTR); - break; - case class_exists('\phpseclib\Crypt\RC4'): - $crypto = new RC4(); - break; - default: - user_error(__CLASS__ . ' requires at least one symmetric cipher be loaded'); - return false; - } - - $crypto->setKey($key); - $crypto->setIV($iv); - $crypto->enableContinuousBuffer(); - } - - //return $crypto->encrypt(str_repeat("\0", $length)); - - // the following is based off of ANSI X9.31: - // - // http://csrc.nist.gov/groups/STM/cavp/documents/rng/931rngext.pdf - // - // OpenSSL uses that same standard for it's random numbers: - // - // http://www.opensource.apple.com/source/OpenSSL/OpenSSL-38/openssl/fips-1.0/rand/fips_rand.c - // (do a search for "ANS X9.31 A.2.4") - $result = ''; - while (strlen($result) < $length) { - $i = $crypto->encrypt(microtime()); // strlen(microtime()) == 21 - $r = $crypto->encrypt($i ^ $v); // strlen($v) == 20 - $v = $crypto->encrypt($r ^ $i); // strlen($r) == 20 - $result.= $r; - } - return substr($result, 0, $length); - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php deleted file mode 100755 index e97239321c4355e22077653a3af8e5dab4aaee78..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php +++ /dev/null @@ -1,938 +0,0 @@ -<?php - -/** - * Pure-PHP implementation of Rijndael. - * - * Uses mcrypt, if available/possible, and an internal implementation, otherwise. - * - * PHP version 5 - * - * If {@link self::setBlockLength() setBlockLength()} isn't called, it'll be assumed to be 128 bits. If - * {@link self::setKeyLength() setKeyLength()} isn't called, it'll be calculated from - * {@link self::setKey() setKey()}. ie. if the key is 128-bits, the key length will be 128-bits. If it's - * 136-bits it'll be null-padded to 192-bits and 192 bits will be the key length until - * {@link self::setKey() setKey()} is called, again, at which point, it'll be recalculated. - * - * Not all Rijndael implementations may support 160-bits or 224-bits as the block length / key length. mcrypt, for example, - * does not. AES, itself, only supports block lengths of 128 and key lengths of 128, 192, and 256. - * {@link http://csrc.nist.gov/archive/aes/rijndael/Rijndael-ammended.pdf#page=10 Rijndael-ammended.pdf#page=10} defines the - * algorithm for block lengths of 192 and 256 but not for block lengths / key lengths of 160 and 224. Indeed, 160 and 224 - * are first defined as valid key / block lengths in - * {@link http://csrc.nist.gov/archive/aes/rijndael/Rijndael-ammended.pdf#page=44 Rijndael-ammended.pdf#page=44}: - * Extensions: Other block and Cipher Key lengths. - * Note: Use of 160/224-bit Keys must be explicitly set by setKeyLength(160) respectively setKeyLength(224). - * - * {@internal The variable names are the same as those in - * {@link http://www.csrc.nist.gov/publications/fips/fips197/fips-197.pdf#page=10 fips-197.pdf#page=10}.}} - * - * Here's a short example of how to use this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $rijndael = new \phpseclib\Crypt\Rijndael(); - * - * $rijndael->setKey('abcdefghijklmnop'); - * - * $size = 10 * 1024; - * $plaintext = ''; - * for ($i = 0; $i < $size; $i++) { - * $plaintext.= 'a'; - * } - * - * echo $rijndael->decrypt($rijndael->encrypt($plaintext)); - * ?> - * </code> - * - * @category Crypt - * @package Rijndael - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2008 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Crypt; - -use phpseclib\Crypt\Base; - -/** - * Pure-PHP implementation of Rijndael. - * - * @package Rijndael - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class Rijndael extends Base -{ - /** - * The mcrypt specific name of the cipher - * - * Mcrypt is useable for 128/192/256-bit $block_size/$key_length. For 160/224 not. - * \phpseclib\Crypt\Rijndael determines automatically whether mcrypt is useable - * or not for the current $block_size/$key_length. - * In case of, $cipher_name_mcrypt will be set dynamically at run time accordingly. - * - * @see \phpseclib\Crypt\Base::cipher_name_mcrypt - * @see \phpseclib\Crypt\Base::engine - * @see self::isValidEngine() - * @var string - * @access private - */ - var $cipher_name_mcrypt = 'rijndael-128'; - - /** - * The default salt used by setPassword() - * - * @see \phpseclib\Crypt\Base::password_default_salt - * @see \phpseclib\Crypt\Base::setPassword() - * @var string - * @access private - */ - var $password_default_salt = 'phpseclib'; - - /** - * The Key Schedule - * - * @see self::_setup() - * @var array - * @access private - */ - var $w; - - /** - * The Inverse Key Schedule - * - * @see self::_setup() - * @var array - * @access private - */ - var $dw; - - /** - * The Block Length divided by 32 - * - * @see self::setBlockLength() - * @var int - * @access private - * @internal The max value is 256 / 32 = 8, the min value is 128 / 32 = 4. Exists in conjunction with $block_size - * because the encryption / decryption / key schedule creation requires this number and not $block_size. We could - * derive this from $block_size or vice versa, but that'd mean we'd have to do multiple shift operations, so in lieu - * of that, we'll just precompute it once. - */ - var $Nb = 4; - - /** - * The Key Length (in bytes) - * - * @see self::setKeyLength() - * @var int - * @access private - * @internal The max value is 256 / 8 = 32, the min value is 128 / 8 = 16. Exists in conjunction with $Nk - * because the encryption / decryption / key schedule creation requires this number and not $key_length. We could - * derive this from $key_length or vice versa, but that'd mean we'd have to do multiple shift operations, so in lieu - * of that, we'll just precompute it once. - */ - var $key_length = 16; - - /** - * The Key Length divided by 32 - * - * @see self::setKeyLength() - * @var int - * @access private - * @internal The max value is 256 / 32 = 8, the min value is 128 / 32 = 4 - */ - var $Nk = 4; - - /** - * The Number of Rounds - * - * @var int - * @access private - * @internal The max value is 14, the min value is 10. - */ - var $Nr; - - /** - * Shift offsets - * - * @var array - * @access private - */ - var $c; - - /** - * Holds the last used key- and block_size information - * - * @var array - * @access private - */ - var $kl; - - /** - * Sets the key length. - * - * Valid key lengths are 128, 160, 192, 224, and 256. If the length is less than 128, it will be rounded up to - * 128. If the length is greater than 128 and invalid, it will be rounded down to the closest valid amount. - * - * Note: phpseclib extends Rijndael (and AES) for using 160- and 224-bit keys but they are officially not defined - * and the most (if not all) implementations are not able using 160/224-bit keys but round/pad them up to - * 192/256 bits as, for example, mcrypt will do. - * - * That said, if you want be compatible with other Rijndael and AES implementations, - * you should not setKeyLength(160) or setKeyLength(224). - * - * Additional: In case of 160- and 224-bit keys, phpseclib will/can, for that reason, not use - * the mcrypt php extension, even if available. - * This results then in slower encryption. - * - * @access public - * @param int $length - */ - function setKeyLength($length) - { - switch (true) { - case $length <= 128: - $this->key_length = 16; - break; - case $length <= 160: - $this->key_length = 20; - break; - case $length <= 192: - $this->key_length = 24; - break; - case $length <= 224: - $this->key_length = 28; - break; - default: - $this->key_length = 32; - } - - parent::setKeyLength($length); - } - - /** - * Sets the block length - * - * Valid block lengths are 128, 160, 192, 224, and 256. If the length is less than 128, it will be rounded up to - * 128. If the length is greater than 128 and invalid, it will be rounded down to the closest valid amount. - * - * @access public - * @param int $length - */ - function setBlockLength($length) - { - $length >>= 5; - if ($length > 8) { - $length = 8; - } elseif ($length < 4) { - $length = 4; - } - $this->Nb = $length; - $this->block_size = $length << 2; - $this->changed = true; - $this->_setEngine(); - } - - /** - * Test for engine validity - * - * This is mainly just a wrapper to set things up for \phpseclib\Crypt\Base::isValidEngine() - * - * @see \phpseclib\Crypt\Base::__construct() - * @param int $engine - * @access public - * @return bool - */ - function isValidEngine($engine) - { - switch ($engine) { - case self::ENGINE_OPENSSL: - if ($this->block_size != 16) { - return false; - } - $this->cipher_name_openssl_ecb = 'aes-' . ($this->key_length << 3) . '-ecb'; - $this->cipher_name_openssl = 'aes-' . ($this->key_length << 3) . '-' . $this->_openssl_translate_mode(); - break; - case self::ENGINE_MCRYPT: - $this->cipher_name_mcrypt = 'rijndael-' . ($this->block_size << 3); - if ($this->key_length % 8) { // is it a 160/224-bit key? - // mcrypt is not usable for them, only for 128/192/256-bit keys - return false; - } - } - - return parent::isValidEngine($engine); - } - - /** - * Encrypts a block - * - * @access private - * @param string $in - * @return string - */ - function _encryptBlock($in) - { - static $tables; - if (empty($tables)) { - $tables = &$this->_getTables(); - } - $t0 = $tables[0]; - $t1 = $tables[1]; - $t2 = $tables[2]; - $t3 = $tables[3]; - $sbox = $tables[4]; - - $state = array(); - $words = unpack('N*', $in); - - $c = $this->c; - $w = $this->w; - $Nb = $this->Nb; - $Nr = $this->Nr; - - // addRoundKey - $wc = $Nb - 1; - foreach ($words as $word) { - $state[] = $word ^ $w[++$wc]; - } - - // fips-197.pdf#page=19, "Figure 5. Pseudo Code for the Cipher", states that this loop has four components - - // subBytes, shiftRows, mixColumns, and addRoundKey. fips-197.pdf#page=30, "Implementation Suggestions Regarding - // Various Platforms" suggests that performs enhanced implementations are described in Rijndael-ammended.pdf. - // Rijndael-ammended.pdf#page=20, "Implementation aspects / 32-bit processor", discusses such an optimization. - // Unfortunately, the description given there is not quite correct. Per aes.spec.v316.pdf#page=19 [1], - // equation (7.4.7) is supposed to use addition instead of subtraction, so we'll do that here, as well. - - // [1] http://fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.v316.pdf - $temp = array(); - for ($round = 1; $round < $Nr; ++$round) { - $i = 0; // $c[0] == 0 - $j = $c[1]; - $k = $c[2]; - $l = $c[3]; - - while ($i < $Nb) { - $temp[$i] = $t0[$state[$i] >> 24 & 0x000000FF] ^ - $t1[$state[$j] >> 16 & 0x000000FF] ^ - $t2[$state[$k] >> 8 & 0x000000FF] ^ - $t3[$state[$l] & 0x000000FF] ^ - $w[++$wc]; - ++$i; - $j = ($j + 1) % $Nb; - $k = ($k + 1) % $Nb; - $l = ($l + 1) % $Nb; - } - $state = $temp; - } - - // subWord - for ($i = 0; $i < $Nb; ++$i) { - $state[$i] = $sbox[$state[$i] & 0x000000FF] | - ($sbox[$state[$i] >> 8 & 0x000000FF] << 8) | - ($sbox[$state[$i] >> 16 & 0x000000FF] << 16) | - ($sbox[$state[$i] >> 24 & 0x000000FF] << 24); - } - - // shiftRows + addRoundKey - $i = 0; // $c[0] == 0 - $j = $c[1]; - $k = $c[2]; - $l = $c[3]; - while ($i < $Nb) { - $temp[$i] = ($state[$i] & 0xFF000000) ^ - ($state[$j] & 0x00FF0000) ^ - ($state[$k] & 0x0000FF00) ^ - ($state[$l] & 0x000000FF) ^ - $w[$i]; - ++$i; - $j = ($j + 1) % $Nb; - $k = ($k + 1) % $Nb; - $l = ($l + 1) % $Nb; - } - - switch ($Nb) { - case 8: - return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5], $temp[6], $temp[7]); - case 7: - return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5], $temp[6]); - case 6: - return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5]); - case 5: - return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4]); - default: - return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3]); - } - } - - /** - * Decrypts a block - * - * @access private - * @param string $in - * @return string - */ - function _decryptBlock($in) - { - static $invtables; - if (empty($invtables)) { - $invtables = &$this->_getInvTables(); - } - $dt0 = $invtables[0]; - $dt1 = $invtables[1]; - $dt2 = $invtables[2]; - $dt3 = $invtables[3]; - $isbox = $invtables[4]; - - $state = array(); - $words = unpack('N*', $in); - - $c = $this->c; - $dw = $this->dw; - $Nb = $this->Nb; - $Nr = $this->Nr; - - // addRoundKey - $wc = $Nb - 1; - foreach ($words as $word) { - $state[] = $word ^ $dw[++$wc]; - } - - $temp = array(); - for ($round = $Nr - 1; $round > 0; --$round) { - $i = 0; // $c[0] == 0 - $j = $Nb - $c[1]; - $k = $Nb - $c[2]; - $l = $Nb - $c[3]; - - while ($i < $Nb) { - $temp[$i] = $dt0[$state[$i] >> 24 & 0x000000FF] ^ - $dt1[$state[$j] >> 16 & 0x000000FF] ^ - $dt2[$state[$k] >> 8 & 0x000000FF] ^ - $dt3[$state[$l] & 0x000000FF] ^ - $dw[++$wc]; - ++$i; - $j = ($j + 1) % $Nb; - $k = ($k + 1) % $Nb; - $l = ($l + 1) % $Nb; - } - $state = $temp; - } - - // invShiftRows + invSubWord + addRoundKey - $i = 0; // $c[0] == 0 - $j = $Nb - $c[1]; - $k = $Nb - $c[2]; - $l = $Nb - $c[3]; - - while ($i < $Nb) { - $word = ($state[$i] & 0xFF000000) | - ($state[$j] & 0x00FF0000) | - ($state[$k] & 0x0000FF00) | - ($state[$l] & 0x000000FF); - - $temp[$i] = $dw[$i] ^ ($isbox[$word & 0x000000FF] | - ($isbox[$word >> 8 & 0x000000FF] << 8) | - ($isbox[$word >> 16 & 0x000000FF] << 16) | - ($isbox[$word >> 24 & 0x000000FF] << 24)); - ++$i; - $j = ($j + 1) % $Nb; - $k = ($k + 1) % $Nb; - $l = ($l + 1) % $Nb; - } - - switch ($Nb) { - case 8: - return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5], $temp[6], $temp[7]); - case 7: - return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5], $temp[6]); - case 6: - return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5]); - case 5: - return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4]); - default: - return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3]); - } - } - - /** - * Setup the key (expansion) - * - * @see \phpseclib\Crypt\Base::_setupKey() - * @access private - */ - function _setupKey() - { - // Each number in $rcon is equal to the previous number multiplied by two in Rijndael's finite field. - // See http://en.wikipedia.org/wiki/Finite_field_arithmetic#Multiplicative_inverse - static $rcon = array(0, - 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, - 0x20000000, 0x40000000, 0x80000000, 0x1B000000, 0x36000000, - 0x6C000000, 0xD8000000, 0xAB000000, 0x4D000000, 0x9A000000, - 0x2F000000, 0x5E000000, 0xBC000000, 0x63000000, 0xC6000000, - 0x97000000, 0x35000000, 0x6A000000, 0xD4000000, 0xB3000000, - 0x7D000000, 0xFA000000, 0xEF000000, 0xC5000000, 0x91000000 - ); - - if (isset($this->kl['key']) && $this->key === $this->kl['key'] && $this->key_length === $this->kl['key_length'] && $this->block_size === $this->kl['block_size']) { - // already expanded - return; - } - $this->kl = array('key' => $this->key, 'key_length' => $this->key_length, 'block_size' => $this->block_size); - - $this->Nk = $this->key_length >> 2; - // see Rijndael-ammended.pdf#page=44 - $this->Nr = max($this->Nk, $this->Nb) + 6; - - // shift offsets for Nb = 5, 7 are defined in Rijndael-ammended.pdf#page=44, - // "Table 8: Shift offsets in Shiftrow for the alternative block lengths" - // shift offsets for Nb = 4, 6, 8 are defined in Rijndael-ammended.pdf#page=14, - // "Table 2: Shift offsets for different block lengths" - switch ($this->Nb) { - case 4: - case 5: - case 6: - $this->c = array(0, 1, 2, 3); - break; - case 7: - $this->c = array(0, 1, 2, 4); - break; - case 8: - $this->c = array(0, 1, 3, 4); - } - - $w = array_values(unpack('N*words', $this->key)); - - $length = $this->Nb * ($this->Nr + 1); - for ($i = $this->Nk; $i < $length; $i++) { - $temp = $w[$i - 1]; - if ($i % $this->Nk == 0) { - // according to <http://php.net/language.types.integer>, "the size of an integer is platform-dependent". - // on a 32-bit machine, it's 32-bits, and on a 64-bit machine, it's 64-bits. on a 32-bit machine, - // 0xFFFFFFFF << 8 == 0xFFFFFF00, but on a 64-bit machine, it equals 0xFFFFFFFF00. as such, doing 'and' - // with 0xFFFFFFFF (or 0xFFFFFF00) on a 32-bit machine is unnecessary, but on a 64-bit machine, it is. - $temp = (($temp << 8) & 0xFFFFFF00) | (($temp >> 24) & 0x000000FF); // rotWord - $temp = $this->_subWord($temp) ^ $rcon[$i / $this->Nk]; - } elseif ($this->Nk > 6 && $i % $this->Nk == 4) { - $temp = $this->_subWord($temp); - } - $w[$i] = $w[$i - $this->Nk] ^ $temp; - } - - // convert the key schedule from a vector of $Nb * ($Nr + 1) length to a matrix with $Nr + 1 rows and $Nb columns - // and generate the inverse key schedule. more specifically, - // according to <http://csrc.nist.gov/archive/aes/rijndael/Rijndael-ammended.pdf#page=23> (section 5.3.3), - // "The key expansion for the Inverse Cipher is defined as follows: - // 1. Apply the Key Expansion. - // 2. Apply InvMixColumn to all Round Keys except the first and the last one." - // also, see fips-197.pdf#page=27, "5.3.5 Equivalent Inverse Cipher" - list($dt0, $dt1, $dt2, $dt3) = $this->_getInvTables(); - $temp = $this->w = $this->dw = array(); - for ($i = $row = $col = 0; $i < $length; $i++, $col++) { - if ($col == $this->Nb) { - if ($row == 0) { - $this->dw[0] = $this->w[0]; - } else { - // subWord + invMixColumn + invSubWord = invMixColumn - $j = 0; - while ($j < $this->Nb) { - $dw = $this->_subWord($this->w[$row][$j]); - $temp[$j] = $dt0[$dw >> 24 & 0x000000FF] ^ - $dt1[$dw >> 16 & 0x000000FF] ^ - $dt2[$dw >> 8 & 0x000000FF] ^ - $dt3[$dw & 0x000000FF]; - $j++; - } - $this->dw[$row] = $temp; - } - - $col = 0; - $row++; - } - $this->w[$row][$col] = $w[$i]; - } - - $this->dw[$row] = $this->w[$row]; - - // Converting to 1-dim key arrays (both ascending) - $this->dw = array_reverse($this->dw); - $w = array_pop($this->w); - $dw = array_pop($this->dw); - foreach ($this->w as $r => $wr) { - foreach ($wr as $c => $wc) { - $w[] = $wc; - $dw[] = $this->dw[$r][$c]; - } - } - $this->w = $w; - $this->dw = $dw; - } - - /** - * Performs S-Box substitutions - * - * @access private - * @param int $word - */ - function _subWord($word) - { - static $sbox; - if (empty($sbox)) { - list(, , , , $sbox) = $this->_getTables(); - } - - return $sbox[$word & 0x000000FF] | - ($sbox[$word >> 8 & 0x000000FF] << 8) | - ($sbox[$word >> 16 & 0x000000FF] << 16) | - ($sbox[$word >> 24 & 0x000000FF] << 24); - } - - /** - * Provides the mixColumns and sboxes tables - * - * @see self::_encryptBlock() - * @see self::_setupInlineCrypt() - * @see self::_subWord() - * @access private - * @return array &$tables - */ - function &_getTables() - { - static $tables; - if (empty($tables)) { - // according to <http://csrc.nist.gov/archive/aes/rijndael/Rijndael-ammended.pdf#page=19> (section 5.2.1), - // precomputed tables can be used in the mixColumns phase. in that example, they're assigned t0...t3, so - // those are the names we'll use. - $t3 = array_map('intval', array( - // with array_map('intval', ...) we ensure we have only int's and not - // some slower floats converted by php automatically on high values - 0x6363A5C6, 0x7C7C84F8, 0x777799EE, 0x7B7B8DF6, 0xF2F20DFF, 0x6B6BBDD6, 0x6F6FB1DE, 0xC5C55491, - 0x30305060, 0x01010302, 0x6767A9CE, 0x2B2B7D56, 0xFEFE19E7, 0xD7D762B5, 0xABABE64D, 0x76769AEC, - 0xCACA458F, 0x82829D1F, 0xC9C94089, 0x7D7D87FA, 0xFAFA15EF, 0x5959EBB2, 0x4747C98E, 0xF0F00BFB, - 0xADADEC41, 0xD4D467B3, 0xA2A2FD5F, 0xAFAFEA45, 0x9C9CBF23, 0xA4A4F753, 0x727296E4, 0xC0C05B9B, - 0xB7B7C275, 0xFDFD1CE1, 0x9393AE3D, 0x26266A4C, 0x36365A6C, 0x3F3F417E, 0xF7F702F5, 0xCCCC4F83, - 0x34345C68, 0xA5A5F451, 0xE5E534D1, 0xF1F108F9, 0x717193E2, 0xD8D873AB, 0x31315362, 0x15153F2A, - 0x04040C08, 0xC7C75295, 0x23236546, 0xC3C35E9D, 0x18182830, 0x9696A137, 0x05050F0A, 0x9A9AB52F, - 0x0707090E, 0x12123624, 0x80809B1B, 0xE2E23DDF, 0xEBEB26CD, 0x2727694E, 0xB2B2CD7F, 0x75759FEA, - 0x09091B12, 0x83839E1D, 0x2C2C7458, 0x1A1A2E34, 0x1B1B2D36, 0x6E6EB2DC, 0x5A5AEEB4, 0xA0A0FB5B, - 0x5252F6A4, 0x3B3B4D76, 0xD6D661B7, 0xB3B3CE7D, 0x29297B52, 0xE3E33EDD, 0x2F2F715E, 0x84849713, - 0x5353F5A6, 0xD1D168B9, 0x00000000, 0xEDED2CC1, 0x20206040, 0xFCFC1FE3, 0xB1B1C879, 0x5B5BEDB6, - 0x6A6ABED4, 0xCBCB468D, 0xBEBED967, 0x39394B72, 0x4A4ADE94, 0x4C4CD498, 0x5858E8B0, 0xCFCF4A85, - 0xD0D06BBB, 0xEFEF2AC5, 0xAAAAE54F, 0xFBFB16ED, 0x4343C586, 0x4D4DD79A, 0x33335566, 0x85859411, - 0x4545CF8A, 0xF9F910E9, 0x02020604, 0x7F7F81FE, 0x5050F0A0, 0x3C3C4478, 0x9F9FBA25, 0xA8A8E34B, - 0x5151F3A2, 0xA3A3FE5D, 0x4040C080, 0x8F8F8A05, 0x9292AD3F, 0x9D9DBC21, 0x38384870, 0xF5F504F1, - 0xBCBCDF63, 0xB6B6C177, 0xDADA75AF, 0x21216342, 0x10103020, 0xFFFF1AE5, 0xF3F30EFD, 0xD2D26DBF, - 0xCDCD4C81, 0x0C0C1418, 0x13133526, 0xECEC2FC3, 0x5F5FE1BE, 0x9797A235, 0x4444CC88, 0x1717392E, - 0xC4C45793, 0xA7A7F255, 0x7E7E82FC, 0x3D3D477A, 0x6464ACC8, 0x5D5DE7BA, 0x19192B32, 0x737395E6, - 0x6060A0C0, 0x81819819, 0x4F4FD19E, 0xDCDC7FA3, 0x22226644, 0x2A2A7E54, 0x9090AB3B, 0x8888830B, - 0x4646CA8C, 0xEEEE29C7, 0xB8B8D36B, 0x14143C28, 0xDEDE79A7, 0x5E5EE2BC, 0x0B0B1D16, 0xDBDB76AD, - 0xE0E03BDB, 0x32325664, 0x3A3A4E74, 0x0A0A1E14, 0x4949DB92, 0x06060A0C, 0x24246C48, 0x5C5CE4B8, - 0xC2C25D9F, 0xD3D36EBD, 0xACACEF43, 0x6262A6C4, 0x9191A839, 0x9595A431, 0xE4E437D3, 0x79798BF2, - 0xE7E732D5, 0xC8C8438B, 0x3737596E, 0x6D6DB7DA, 0x8D8D8C01, 0xD5D564B1, 0x4E4ED29C, 0xA9A9E049, - 0x6C6CB4D8, 0x5656FAAC, 0xF4F407F3, 0xEAEA25CF, 0x6565AFCA, 0x7A7A8EF4, 0xAEAEE947, 0x08081810, - 0xBABAD56F, 0x787888F0, 0x25256F4A, 0x2E2E725C, 0x1C1C2438, 0xA6A6F157, 0xB4B4C773, 0xC6C65197, - 0xE8E823CB, 0xDDDD7CA1, 0x74749CE8, 0x1F1F213E, 0x4B4BDD96, 0xBDBDDC61, 0x8B8B860D, 0x8A8A850F, - 0x707090E0, 0x3E3E427C, 0xB5B5C471, 0x6666AACC, 0x4848D890, 0x03030506, 0xF6F601F7, 0x0E0E121C, - 0x6161A3C2, 0x35355F6A, 0x5757F9AE, 0xB9B9D069, 0x86869117, 0xC1C15899, 0x1D1D273A, 0x9E9EB927, - 0xE1E138D9, 0xF8F813EB, 0x9898B32B, 0x11113322, 0x6969BBD2, 0xD9D970A9, 0x8E8E8907, 0x9494A733, - 0x9B9BB62D, 0x1E1E223C, 0x87879215, 0xE9E920C9, 0xCECE4987, 0x5555FFAA, 0x28287850, 0xDFDF7AA5, - 0x8C8C8F03, 0xA1A1F859, 0x89898009, 0x0D0D171A, 0xBFBFDA65, 0xE6E631D7, 0x4242C684, 0x6868B8D0, - 0x4141C382, 0x9999B029, 0x2D2D775A, 0x0F0F111E, 0xB0B0CB7B, 0x5454FCA8, 0xBBBBD66D, 0x16163A2C - )); - - foreach ($t3 as $t3i) { - $t0[] = (($t3i << 24) & 0xFF000000) | (($t3i >> 8) & 0x00FFFFFF); - $t1[] = (($t3i << 16) & 0xFFFF0000) | (($t3i >> 16) & 0x0000FFFF); - $t2[] = (($t3i << 8) & 0xFFFFFF00) | (($t3i >> 24) & 0x000000FF); - } - - $tables = array( - // The Precomputed mixColumns tables t0 - t3 - $t0, - $t1, - $t2, - $t3, - // The SubByte S-Box - array( - 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, - 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, - 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15, - 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75, - 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84, - 0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF, - 0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8, - 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2, - 0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73, - 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB, - 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79, - 0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08, - 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A, - 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E, - 0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF, - 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16 - ) - ); - } - return $tables; - } - - /** - * Provides the inverse mixColumns and inverse sboxes tables - * - * @see self::_decryptBlock() - * @see self::_setupInlineCrypt() - * @see self::_setupKey() - * @access private - * @return array &$tables - */ - function &_getInvTables() - { - static $tables; - if (empty($tables)) { - $dt3 = array_map('intval', array( - 0xF4A75051, 0x4165537E, 0x17A4C31A, 0x275E963A, 0xAB6BCB3B, 0x9D45F11F, 0xFA58ABAC, 0xE303934B, - 0x30FA5520, 0x766DF6AD, 0xCC769188, 0x024C25F5, 0xE5D7FC4F, 0x2ACBD7C5, 0x35448026, 0x62A38FB5, - 0xB15A49DE, 0xBA1B6725, 0xEA0E9845, 0xFEC0E15D, 0x2F7502C3, 0x4CF01281, 0x4697A38D, 0xD3F9C66B, - 0x8F5FE703, 0x929C9515, 0x6D7AEBBF, 0x5259DA95, 0xBE832DD4, 0x7421D358, 0xE0692949, 0xC9C8448E, - 0xC2896A75, 0x8E7978F4, 0x583E6B99, 0xB971DD27, 0xE14FB6BE, 0x88AD17F0, 0x20AC66C9, 0xCE3AB47D, - 0xDF4A1863, 0x1A3182E5, 0x51336097, 0x537F4562, 0x6477E0B1, 0x6BAE84BB, 0x81A01CFE, 0x082B94F9, - 0x48685870, 0x45FD198F, 0xDE6C8794, 0x7BF8B752, 0x73D323AB, 0x4B02E272, 0x1F8F57E3, 0x55AB2A66, - 0xEB2807B2, 0xB5C2032F, 0xC57B9A86, 0x3708A5D3, 0x2887F230, 0xBFA5B223, 0x036ABA02, 0x16825CED, - 0xCF1C2B8A, 0x79B492A7, 0x07F2F0F3, 0x69E2A14E, 0xDAF4CD65, 0x05BED506, 0x34621FD1, 0xA6FE8AC4, - 0x2E539D34, 0xF355A0A2, 0x8AE13205, 0xF6EB75A4, 0x83EC390B, 0x60EFAA40, 0x719F065E, 0x6E1051BD, - 0x218AF93E, 0xDD063D96, 0x3E05AEDD, 0xE6BD464D, 0x548DB591, 0xC45D0571, 0x06D46F04, 0x5015FF60, - 0x98FB2419, 0xBDE997D6, 0x4043CC89, 0xD99E7767, 0xE842BDB0, 0x898B8807, 0x195B38E7, 0xC8EEDB79, - 0x7C0A47A1, 0x420FE97C, 0x841EC9F8, 0x00000000, 0x80868309, 0x2BED4832, 0x1170AC1E, 0x5A724E6C, - 0x0EFFFBFD, 0x8538560F, 0xAED51E3D, 0x2D392736, 0x0FD9640A, 0x5CA62168, 0x5B54D19B, 0x362E3A24, - 0x0A67B10C, 0x57E70F93, 0xEE96D2B4, 0x9B919E1B, 0xC0C54F80, 0xDC20A261, 0x774B695A, 0x121A161C, - 0x93BA0AE2, 0xA02AE5C0, 0x22E0433C, 0x1B171D12, 0x090D0B0E, 0x8BC7ADF2, 0xB6A8B92D, 0x1EA9C814, - 0xF1198557, 0x75074CAF, 0x99DDBBEE, 0x7F60FDA3, 0x01269FF7, 0x72F5BC5C, 0x663BC544, 0xFB7E345B, - 0x4329768B, 0x23C6DCCB, 0xEDFC68B6, 0xE4F163B8, 0x31DCCAD7, 0x63851042, 0x97224013, 0xC6112084, - 0x4A247D85, 0xBB3DF8D2, 0xF93211AE, 0x29A16DC7, 0x9E2F4B1D, 0xB230F3DC, 0x8652EC0D, 0xC1E3D077, - 0xB3166C2B, 0x70B999A9, 0x9448FA11, 0xE9642247, 0xFC8CC4A8, 0xF03F1AA0, 0x7D2CD856, 0x3390EF22, - 0x494EC787, 0x38D1C1D9, 0xCAA2FE8C, 0xD40B3698, 0xF581CFA6, 0x7ADE28A5, 0xB78E26DA, 0xADBFA43F, - 0x3A9DE42C, 0x78920D50, 0x5FCC9B6A, 0x7E466254, 0x8D13C2F6, 0xD8B8E890, 0x39F75E2E, 0xC3AFF582, - 0x5D80BE9F, 0xD0937C69, 0xD52DA96F, 0x2512B3CF, 0xAC993BC8, 0x187DA710, 0x9C636EE8, 0x3BBB7BDB, - 0x267809CD, 0x5918F46E, 0x9AB701EC, 0x4F9AA883, 0x956E65E6, 0xFFE67EAA, 0xBCCF0821, 0x15E8E6EF, - 0xE79BD9BA, 0x6F36CE4A, 0x9F09D4EA, 0xB07CD629, 0xA4B2AF31, 0x3F23312A, 0xA59430C6, 0xA266C035, - 0x4EBC3774, 0x82CAA6FC, 0x90D0B0E0, 0xA7D81533, 0x04984AF1, 0xECDAF741, 0xCD500E7F, 0x91F62F17, - 0x4DD68D76, 0xEFB04D43, 0xAA4D54CC, 0x9604DFE4, 0xD1B5E39E, 0x6A881B4C, 0x2C1FB8C1, 0x65517F46, - 0x5EEA049D, 0x8C355D01, 0x877473FA, 0x0B412EFB, 0x671D5AB3, 0xDBD25292, 0x105633E9, 0xD647136D, - 0xD7618C9A, 0xA10C7A37, 0xF8148E59, 0x133C89EB, 0xA927EECE, 0x61C935B7, 0x1CE5EDE1, 0x47B13C7A, - 0xD2DF599C, 0xF2733F55, 0x14CE7918, 0xC737BF73, 0xF7CDEA53, 0xFDAA5B5F, 0x3D6F14DF, 0x44DB8678, - 0xAFF381CA, 0x68C43EB9, 0x24342C38, 0xA3405FC2, 0x1DC37216, 0xE2250CBC, 0x3C498B28, 0x0D9541FF, - 0xA8017139, 0x0CB3DE08, 0xB4E49CD8, 0x56C19064, 0xCB84617B, 0x32B670D5, 0x6C5C7448, 0xB85742D0 - )); - - foreach ($dt3 as $dt3i) { - $dt0[] = (($dt3i << 24) & 0xFF000000) | (($dt3i >> 8) & 0x00FFFFFF); - $dt1[] = (($dt3i << 16) & 0xFFFF0000) | (($dt3i >> 16) & 0x0000FFFF); - $dt2[] = (($dt3i << 8) & 0xFFFFFF00) | (($dt3i >> 24) & 0x000000FF); - }; - - $tables = array( - // The Precomputed inverse mixColumns tables dt0 - dt3 - $dt0, - $dt1, - $dt2, - $dt3, - // The inverse SubByte S-Box - array( - 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB, - 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87, 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, - 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D, 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E, - 0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, 0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25, - 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92, - 0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA, 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84, - 0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06, - 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02, 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B, - 0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA, 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73, - 0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E, - 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B, - 0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4, - 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F, - 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF, - 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61, - 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D - ) - ); - } - return $tables; - } - - /** - * Setup the performance-optimized function for de/encrypt() - * - * @see \phpseclib\Crypt\Base::_setupInlineCrypt() - * @access private - */ - function _setupInlineCrypt() - { - // Note: _setupInlineCrypt() will be called only if $this->changed === true - // So here we are'nt under the same heavy timing-stress as we are in _de/encryptBlock() or de/encrypt(). - // However...the here generated function- $code, stored as php callback in $this->inline_crypt, must work as fast as even possible. - - $lambda_functions =& self::_getLambdaFunctions(); - - // We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function. - // (Currently, for Crypt_Rijndael/AES, one generated $lambda_function cost on php5.5@32bit ~80kb unfreeable mem and ~130kb on php5.5@64bit) - // After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one. - $gen_hi_opt_code = (bool)(count($lambda_functions) < 10); - - // Generation of a uniqe hash for our generated code - $code_hash = "Crypt_Rijndael, {$this->mode}, {$this->Nr}, {$this->Nb}"; - if ($gen_hi_opt_code) { - $code_hash = str_pad($code_hash, 32) . $this->_hashInlineCryptFunction($this->key); - } - - if (!isset($lambda_functions[$code_hash])) { - switch (true) { - case $gen_hi_opt_code: - // The hi-optimized $lambda_functions will use the key-words hardcoded for better performance. - $w = $this->w; - $dw = $this->dw; - $init_encrypt = ''; - $init_decrypt = ''; - break; - default: - for ($i = 0, $cw = count($this->w); $i < $cw; ++$i) { - $w[] = '$w[' . $i . ']'; - $dw[] = '$dw[' . $i . ']'; - } - $init_encrypt = '$w = $self->w;'; - $init_decrypt = '$dw = $self->dw;'; - } - - $Nr = $this->Nr; - $Nb = $this->Nb; - $c = $this->c; - - // Generating encrypt code: - $init_encrypt.= ' - static $tables; - if (empty($tables)) { - $tables = &$self->_getTables(); - } - $t0 = $tables[0]; - $t1 = $tables[1]; - $t2 = $tables[2]; - $t3 = $tables[3]; - $sbox = $tables[4]; - '; - - $s = 'e'; - $e = 's'; - $wc = $Nb - 1; - - // Preround: addRoundKey - $encrypt_block = '$in = unpack("N*", $in);'."\n"; - for ($i = 0; $i < $Nb; ++$i) { - $encrypt_block .= '$s'.$i.' = $in['.($i + 1).'] ^ '.$w[++$wc].";\n"; - } - - // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey - for ($round = 1; $round < $Nr; ++$round) { - list($s, $e) = array($e, $s); - for ($i = 0; $i < $Nb; ++$i) { - $encrypt_block.= - '$'.$e.$i.' = - $t0[($'.$s.$i .' >> 24) & 0xff] ^ - $t1[($'.$s.(($i + $c[1]) % $Nb).' >> 16) & 0xff] ^ - $t2[($'.$s.(($i + $c[2]) % $Nb).' >> 8) & 0xff] ^ - $t3[ $'.$s.(($i + $c[3]) % $Nb).' & 0xff] ^ - '.$w[++$wc].";\n"; - } - } - - // Finalround: subWord + shiftRows + addRoundKey - for ($i = 0; $i < $Nb; ++$i) { - $encrypt_block.= - '$'.$e.$i.' = - $sbox[ $'.$e.$i.' & 0xff] | - ($sbox[($'.$e.$i.' >> 8) & 0xff] << 8) | - ($sbox[($'.$e.$i.' >> 16) & 0xff] << 16) | - ($sbox[($'.$e.$i.' >> 24) & 0xff] << 24);'."\n"; - } - $encrypt_block .= '$in = pack("N*"'."\n"; - for ($i = 0; $i < $Nb; ++$i) { - $encrypt_block.= ', - ($'.$e.$i .' & '.((int)0xFF000000).') ^ - ($'.$e.(($i + $c[1]) % $Nb).' & 0x00FF0000 ) ^ - ($'.$e.(($i + $c[2]) % $Nb).' & 0x0000FF00 ) ^ - ($'.$e.(($i + $c[3]) % $Nb).' & 0x000000FF ) ^ - '.$w[$i]."\n"; - } - $encrypt_block .= ');'; - - // Generating decrypt code: - $init_decrypt.= ' - static $invtables; - if (empty($invtables)) { - $invtables = &$self->_getInvTables(); - } - $dt0 = $invtables[0]; - $dt1 = $invtables[1]; - $dt2 = $invtables[2]; - $dt3 = $invtables[3]; - $isbox = $invtables[4]; - '; - - $s = 'e'; - $e = 's'; - $wc = $Nb - 1; - - // Preround: addRoundKey - $decrypt_block = '$in = unpack("N*", $in);'."\n"; - for ($i = 0; $i < $Nb; ++$i) { - $decrypt_block .= '$s'.$i.' = $in['.($i + 1).'] ^ '.$dw[++$wc].';'."\n"; - } - - // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey - for ($round = 1; $round < $Nr; ++$round) { - list($s, $e) = array($e, $s); - for ($i = 0; $i < $Nb; ++$i) { - $decrypt_block.= - '$'.$e.$i.' = - $dt0[($'.$s.$i .' >> 24) & 0xff] ^ - $dt1[($'.$s.(($Nb + $i - $c[1]) % $Nb).' >> 16) & 0xff] ^ - $dt2[($'.$s.(($Nb + $i - $c[2]) % $Nb).' >> 8) & 0xff] ^ - $dt3[ $'.$s.(($Nb + $i - $c[3]) % $Nb).' & 0xff] ^ - '.$dw[++$wc].";\n"; - } - } - - // Finalround: subWord + shiftRows + addRoundKey - for ($i = 0; $i < $Nb; ++$i) { - $decrypt_block.= - '$'.$e.$i.' = - $isbox[ $'.$e.$i.' & 0xff] | - ($isbox[($'.$e.$i.' >> 8) & 0xff] << 8) | - ($isbox[($'.$e.$i.' >> 16) & 0xff] << 16) | - ($isbox[($'.$e.$i.' >> 24) & 0xff] << 24);'."\n"; - } - $decrypt_block .= '$in = pack("N*"'."\n"; - for ($i = 0; $i < $Nb; ++$i) { - $decrypt_block.= ', - ($'.$e.$i. ' & '.((int)0xFF000000).') ^ - ($'.$e.(($Nb + $i - $c[1]) % $Nb).' & 0x00FF0000 ) ^ - ($'.$e.(($Nb + $i - $c[2]) % $Nb).' & 0x0000FF00 ) ^ - ($'.$e.(($Nb + $i - $c[3]) % $Nb).' & 0x000000FF ) ^ - '.$dw[$i]."\n"; - } - $decrypt_block .= ');'; - - $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( - array( - 'init_crypt' => '', - 'init_encrypt' => $init_encrypt, - 'init_decrypt' => $init_decrypt, - 'encrypt_block' => $encrypt_block, - 'decrypt_block' => $decrypt_block - ) - ); - } - $this->inline_crypt = $lambda_functions[$code_hash]; - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php deleted file mode 100755 index 91c5bc62f01e94f6f179a0b2e8b4577a949fdda3..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php +++ /dev/null @@ -1,463 +0,0 @@ -<?php - -/** - * Pure-PHP implementation of Triple DES. - * - * Uses mcrypt, if available, and an internal implementation, otherwise. Operates in the EDE3 mode (encrypt-decrypt-encrypt). - * - * PHP version 5 - * - * Here's a short example of how to use this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $des = new \phpseclib\Crypt\TripleDES(); - * - * $des->setKey('abcdefghijklmnopqrstuvwx'); - * - * $size = 10 * 1024; - * $plaintext = ''; - * for ($i = 0; $i < $size; $i++) { - * $plaintext.= 'a'; - * } - * - * echo $des->decrypt($des->encrypt($plaintext)); - * ?> - * </code> - * - * @category Crypt - * @package TripleDES - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2007 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Crypt; - -use phpseclib\Crypt\Base; -use phpseclib\Crypt\DES; - -/** - * Pure-PHP implementation of Triple DES. - * - * @package TripleDES - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class TripleDES extends DES -{ - /** - * Encrypt / decrypt using inner chaining - * - * Inner chaining is used by SSH-1 and is generally considered to be less secure then outer chaining (self::MODE_CBC3). - */ - const MODE_3CBC = -2; - - /** - * Encrypt / decrypt using outer chaining - * - * Outer chaining is used by SSH-2 and when the mode is set to \phpseclib\Crypt\Base::MODE_CBC. - */ - const MODE_CBC3 = Base::MODE_CBC; - - /** - * Key Length (in bytes) - * - * @see \phpseclib\Crypt\TripleDES::setKeyLength() - * @var int - * @access private - */ - var $key_length = 24; - - /** - * The default salt used by setPassword() - * - * @see \phpseclib\Crypt\Base::password_default_salt - * @see \phpseclib\Crypt\Base::setPassword() - * @var string - * @access private - */ - var $password_default_salt = 'phpseclib'; - - /** - * The mcrypt specific name of the cipher - * - * @see \phpseclib\Crypt\DES::cipher_name_mcrypt - * @see \phpseclib\Crypt\Base::cipher_name_mcrypt - * @var string - * @access private - */ - var $cipher_name_mcrypt = 'tripledes'; - - /** - * Optimizing value while CFB-encrypting - * - * @see \phpseclib\Crypt\Base::cfb_init_len - * @var int - * @access private - */ - var $cfb_init_len = 750; - - /** - * max possible size of $key - * - * @see self::setKey() - * @see \phpseclib\Crypt\DES::setKey() - * @var string - * @access private - */ - var $key_length_max = 24; - - /** - * Internal flag whether using self::MODE_3CBC or not - * - * @var bool - * @access private - */ - var $mode_3cbc; - - /** - * The \phpseclib\Crypt\DES objects - * - * Used only if $mode_3cbc === true - * - * @var array - * @access private - */ - var $des; - - /** - * Default Constructor. - * - * Determines whether or not the mcrypt extension should be used. - * - * $mode could be: - * - * - \phpseclib\Crypt\Base::MODE_ECB - * - * - \phpseclib\Crypt\Base::MODE_CBC - * - * - \phpseclib\Crypt\Base::MODE_CTR - * - * - \phpseclib\Crypt\Base::MODE_CFB - * - * - \phpseclib\Crypt\Base::MODE_OFB - * - * - \phpseclib\Crypt\TripleDES::MODE_3CBC - * - * If not explicitly set, \phpseclib\Crypt\Base::MODE_CBC will be used. - * - * @see \phpseclib\Crypt\DES::__construct() - * @see \phpseclib\Crypt\Base::__construct() - * @param int $mode - * @access public - */ - function __construct($mode = Base::MODE_CBC) - { - switch ($mode) { - // In case of self::MODE_3CBC, we init as CRYPT_DES_MODE_CBC - // and additional flag us internally as 3CBC - case self::MODE_3CBC: - parent::__construct(Base::MODE_CBC); - $this->mode_3cbc = true; - - // This three $des'es will do the 3CBC work (if $key > 64bits) - $this->des = array( - new DES(Base::MODE_CBC), - new DES(Base::MODE_CBC), - new DES(Base::MODE_CBC), - ); - - // we're going to be doing the padding, ourselves, so disable it in the \phpseclib\Crypt\DES objects - $this->des[0]->disablePadding(); - $this->des[1]->disablePadding(); - $this->des[2]->disablePadding(); - break; - // If not 3CBC, we init as usual - default: - parent::__construct($mode); - } - } - - /** - * Test for engine validity - * - * This is mainly just a wrapper to set things up for \phpseclib\Crypt\Base::isValidEngine() - * - * @see \phpseclib\Crypt\Base::__construct() - * @param int $engine - * @access public - * @return bool - */ - function isValidEngine($engine) - { - if ($engine == self::ENGINE_OPENSSL) { - $this->cipher_name_openssl_ecb = 'des-ede3'; - $mode = $this->_openssl_translate_mode(); - $this->cipher_name_openssl = $mode == 'ecb' ? 'des-ede3' : 'des-ede3-' . $mode; - } - - return parent::isValidEngine($engine); - } - - /** - * Sets the initialization vector. (optional) - * - * SetIV is not required when \phpseclib\Crypt\Base::MODE_ECB is being used. If not explicitly set, it'll be assumed - * to be all zero's. - * - * @see \phpseclib\Crypt\Base::setIV() - * @access public - * @param string $iv - */ - function setIV($iv) - { - parent::setIV($iv); - if ($this->mode_3cbc) { - $this->des[0]->setIV($iv); - $this->des[1]->setIV($iv); - $this->des[2]->setIV($iv); - } - } - - /** - * Sets the key length. - * - * Valid key lengths are 64, 128 and 192 - * - * @see \phpseclib\Crypt\Base:setKeyLength() - * @access public - * @param int $length - */ - function setKeyLength($length) - { - $length >>= 3; - switch (true) { - case $length <= 8: - $this->key_length = 8; - break; - case $length <= 16: - $this->key_length = 16; - break; - default: - $this->key_length = 24; - } - - parent::setKeyLength($length); - } - - /** - * Sets the key. - * - * Keys can be of any length. Triple DES, itself, can use 128-bit (eg. strlen($key) == 16) or - * 192-bit (eg. strlen($key) == 24) keys. This function pads and truncates $key as appropriate. - * - * DES also requires that every eighth bit be a parity bit, however, we'll ignore that. - * - * If the key is not explicitly set, it'll be assumed to be all null bytes. - * - * @access public - * @see \phpseclib\Crypt\DES::setKey() - * @see \phpseclib\Crypt\Base::setKey() - * @param string $key - */ - function setKey($key) - { - $length = $this->explicit_key_length ? $this->key_length : strlen($key); - if ($length > 8) { - $key = str_pad(substr($key, 0, 24), 24, chr(0)); - // if $key is between 64 and 128-bits, use the first 64-bits as the last, per this: - // http://php.net/function.mcrypt-encrypt#47973 - $key = $length <= 16 ? substr_replace($key, substr($key, 0, 8), 16) : substr($key, 0, 24); - } else { - $key = str_pad($key, 8, chr(0)); - } - parent::setKey($key); - - // And in case of self::MODE_3CBC: - // if key <= 64bits we not need the 3 $des to work, - // because we will then act as regular DES-CBC with just a <= 64bit key. - // So only if the key > 64bits (> 8 bytes) we will call setKey() for the 3 $des. - if ($this->mode_3cbc && $length > 8) { - $this->des[0]->setKey(substr($key, 0, 8)); - $this->des[1]->setKey(substr($key, 8, 8)); - $this->des[2]->setKey(substr($key, 16, 8)); - } - } - - /** - * Encrypts a message. - * - * @see \phpseclib\Crypt\Base::encrypt() - * @access public - * @param string $plaintext - * @return string $cipertext - */ - function encrypt($plaintext) - { - // parent::en/decrypt() is able to do all the work for all modes and keylengths, - // except for: self::MODE_3CBC (inner chaining CBC) with a key > 64bits - - // if the key is smaller then 8, do what we'd normally do - if ($this->mode_3cbc && strlen($this->key) > 8) { - return $this->des[2]->encrypt( - $this->des[1]->decrypt( - $this->des[0]->encrypt( - $this->_pad($plaintext) - ) - ) - ); - } - - return parent::encrypt($plaintext); - } - - /** - * Decrypts a message. - * - * @see \phpseclib\Crypt\Base::decrypt() - * @access public - * @param string $ciphertext - * @return string $plaintext - */ - function decrypt($ciphertext) - { - if ($this->mode_3cbc && strlen($this->key) > 8) { - return $this->_unpad( - $this->des[0]->decrypt( - $this->des[1]->encrypt( - $this->des[2]->decrypt( - str_pad($ciphertext, (strlen($ciphertext) + 7) & 0xFFFFFFF8, "\0") - ) - ) - ) - ); - } - - return parent::decrypt($ciphertext); - } - - /** - * Treat consecutive "packets" as if they are a continuous buffer. - * - * Say you have a 16-byte plaintext $plaintext. Using the default behavior, the two following code snippets - * will yield different outputs: - * - * <code> - * echo $des->encrypt(substr($plaintext, 0, 8)); - * echo $des->encrypt(substr($plaintext, 8, 8)); - * </code> - * <code> - * echo $des->encrypt($plaintext); - * </code> - * - * The solution is to enable the continuous buffer. Although this will resolve the above discrepancy, it creates - * another, as demonstrated with the following: - * - * <code> - * $des->encrypt(substr($plaintext, 0, 8)); - * echo $des->decrypt($des->encrypt(substr($plaintext, 8, 8))); - * </code> - * <code> - * echo $des->decrypt($des->encrypt(substr($plaintext, 8, 8))); - * </code> - * - * With the continuous buffer disabled, these would yield the same output. With it enabled, they yield different - * outputs. The reason is due to the fact that the initialization vector's change after every encryption / - * decryption round when the continuous buffer is enabled. When it's disabled, they remain constant. - * - * Put another way, when the continuous buffer is enabled, the state of the \phpseclib\Crypt\DES() object changes after each - * encryption / decryption round, whereas otherwise, it'd remain constant. For this reason, it's recommended that - * continuous buffers not be used. They do offer better security and are, in fact, sometimes required (SSH uses them), - * however, they are also less intuitive and more likely to cause you problems. - * - * @see \phpseclib\Crypt\Base::enableContinuousBuffer() - * @see self::disableContinuousBuffer() - * @access public - */ - function enableContinuousBuffer() - { - parent::enableContinuousBuffer(); - if ($this->mode_3cbc) { - $this->des[0]->enableContinuousBuffer(); - $this->des[1]->enableContinuousBuffer(); - $this->des[2]->enableContinuousBuffer(); - } - } - - /** - * Treat consecutive packets as if they are a discontinuous buffer. - * - * The default behavior. - * - * @see \phpseclib\Crypt\Base::disableContinuousBuffer() - * @see self::enableContinuousBuffer() - * @access public - */ - function disableContinuousBuffer() - { - parent::disableContinuousBuffer(); - if ($this->mode_3cbc) { - $this->des[0]->disableContinuousBuffer(); - $this->des[1]->disableContinuousBuffer(); - $this->des[2]->disableContinuousBuffer(); - } - } - - /** - * Creates the key schedule - * - * @see \phpseclib\Crypt\DES::_setupKey() - * @see \phpseclib\Crypt\Base::_setupKey() - * @access private - */ - function _setupKey() - { - switch (true) { - // if $key <= 64bits we configure our internal pure-php cipher engine - // to act as regular [1]DES, not as 3DES. mcrypt.so::tripledes does the same. - case strlen($this->key) <= 8: - $this->des_rounds = 1; - break; - - // otherwise, if $key > 64bits, we configure our engine to work as 3DES. - default: - $this->des_rounds = 3; - - // (only) if 3CBC is used we have, of course, to setup the $des[0-2] keys also separately. - if ($this->mode_3cbc) { - $this->des[0]->_setupKey(); - $this->des[1]->_setupKey(); - $this->des[2]->_setupKey(); - - // because $des[0-2] will, now, do all the work we can return here - // not need unnecessary stress parent::_setupKey() with our, now unused, $key. - return; - } - } - // setup our key - parent::_setupKey(); - } - - /** - * Sets the internal crypt engine - * - * @see \phpseclib\Crypt\Base::__construct() - * @see \phpseclib\Crypt\Base::setPreferredEngine() - * @param int $engine - * @access public - * @return int - */ - function setPreferredEngine($engine) - { - if ($this->mode_3cbc) { - $this->des[0]->setPreferredEngine($engine); - $this->des[1]->setPreferredEngine($engine); - $this->des[2]->setPreferredEngine($engine); - } - - return parent::setPreferredEngine($engine); - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php deleted file mode 100755 index 623e9a6a5ae71dc4044764bb48cc1b6b2c50c290..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php +++ /dev/null @@ -1,810 +0,0 @@ -<?php - -/** - * Pure-PHP implementation of Twofish. - * - * Uses mcrypt, if available, and an internal implementation, otherwise. - * - * PHP version 5 - * - * Useful resources are as follows: - * - * - {@link http://en.wikipedia.org/wiki/Twofish Wikipedia description of Twofish} - * - * Here's a short example of how to use this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $twofish = new \phpseclib\Crypt\Twofish(); - * - * $twofish->setKey('12345678901234567890123456789012'); - * - * $plaintext = str_repeat('a', 1024); - * - * echo $twofish->decrypt($twofish->encrypt($plaintext)); - * ?> - * </code> - * - * @category Crypt - * @package Twofish - * @author Jim Wigginton <terrafrost@php.net> - * @author Hans-Juergen Petrich <petrich@tronic-media.com> - * @copyright 2007 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Crypt; - -use phpseclib\Crypt\Base; - -/** - * Pure-PHP implementation of Twofish. - * - * @package Twofish - * @author Jim Wigginton <terrafrost@php.net> - * @author Hans-Juergen Petrich <petrich@tronic-media.com> - * @access public - */ -class Twofish extends Base -{ - /** - * The mcrypt specific name of the cipher - * - * @see \phpseclib\Crypt\Base::cipher_name_mcrypt - * @var string - * @access private - */ - var $cipher_name_mcrypt = 'twofish'; - - /** - * Optimizing value while CFB-encrypting - * - * @see \phpseclib\Crypt\Base::cfb_init_len - * @var int - * @access private - */ - var $cfb_init_len = 800; - - /** - * Q-Table - * - * @var array - * @access private - */ - var $q0 = array( - 0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, - 0x9A, 0x92, 0x80, 0x78, 0xE4, 0xDD, 0xD1, 0x38, - 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C, - 0x43, 0x75, 0x37, 0x26, 0xFA, 0x13, 0x94, 0x48, - 0xF2, 0xD0, 0x8B, 0x30, 0x84, 0x54, 0xDF, 0x23, - 0x19, 0x5B, 0x3D, 0x59, 0xF3, 0xAE, 0xA2, 0x82, - 0x63, 0x01, 0x83, 0x2E, 0xD9, 0x51, 0x9B, 0x7C, - 0xA6, 0xEB, 0xA5, 0xBE, 0x16, 0x0C, 0xE3, 0x61, - 0xC0, 0x8C, 0x3A, 0xF5, 0x73, 0x2C, 0x25, 0x0B, - 0xBB, 0x4E, 0x89, 0x6B, 0x53, 0x6A, 0xB4, 0xF1, - 0xE1, 0xE6, 0xBD, 0x45, 0xE2, 0xF4, 0xB6, 0x66, - 0xCC, 0x95, 0x03, 0x56, 0xD4, 0x1C, 0x1E, 0xD7, - 0xFB, 0xC3, 0x8E, 0xB5, 0xE9, 0xCF, 0xBF, 0xBA, - 0xEA, 0x77, 0x39, 0xAF, 0x33, 0xC9, 0x62, 0x71, - 0x81, 0x79, 0x09, 0xAD, 0x24, 0xCD, 0xF9, 0xD8, - 0xE5, 0xC5, 0xB9, 0x4D, 0x44, 0x08, 0x86, 0xE7, - 0xA1, 0x1D, 0xAA, 0xED, 0x06, 0x70, 0xB2, 0xD2, - 0x41, 0x7B, 0xA0, 0x11, 0x31, 0xC2, 0x27, 0x90, - 0x20, 0xF6, 0x60, 0xFF, 0x96, 0x5C, 0xB1, 0xAB, - 0x9E, 0x9C, 0x52, 0x1B, 0x5F, 0x93, 0x0A, 0xEF, - 0x91, 0x85, 0x49, 0xEE, 0x2D, 0x4F, 0x8F, 0x3B, - 0x47, 0x87, 0x6D, 0x46, 0xD6, 0x3E, 0x69, 0x64, - 0x2A, 0xCE, 0xCB, 0x2F, 0xFC, 0x97, 0x05, 0x7A, - 0xAC, 0x7F, 0xD5, 0x1A, 0x4B, 0x0E, 0xA7, 0x5A, - 0x28, 0x14, 0x3F, 0x29, 0x88, 0x3C, 0x4C, 0x02, - 0xB8, 0xDA, 0xB0, 0x17, 0x55, 0x1F, 0x8A, 0x7D, - 0x57, 0xC7, 0x8D, 0x74, 0xB7, 0xC4, 0x9F, 0x72, - 0x7E, 0x15, 0x22, 0x12, 0x58, 0x07, 0x99, 0x34, - 0x6E, 0x50, 0xDE, 0x68, 0x65, 0xBC, 0xDB, 0xF8, - 0xC8, 0xA8, 0x2B, 0x40, 0xDC, 0xFE, 0x32, 0xA4, - 0xCA, 0x10, 0x21, 0xF0, 0xD3, 0x5D, 0x0F, 0x00, - 0x6F, 0x9D, 0x36, 0x42, 0x4A, 0x5E, 0xC1, 0xE0 - ); - - /** - * Q-Table - * - * @var array - * @access private - */ - var $q1 = array( - 0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8, - 0x4A, 0xD3, 0xE6, 0x6B, 0x45, 0x7D, 0xE8, 0x4B, - 0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1, - 0x30, 0x0F, 0xF8, 0x1B, 0x87, 0xFA, 0x06, 0x3F, - 0x5E, 0xBA, 0xAE, 0x5B, 0x8A, 0x00, 0xBC, 0x9D, - 0x6D, 0xC1, 0xB1, 0x0E, 0x80, 0x5D, 0xD2, 0xD5, - 0xA0, 0x84, 0x07, 0x14, 0xB5, 0x90, 0x2C, 0xA3, - 0xB2, 0x73, 0x4C, 0x54, 0x92, 0x74, 0x36, 0x51, - 0x38, 0xB0, 0xBD, 0x5A, 0xFC, 0x60, 0x62, 0x96, - 0x6C, 0x42, 0xF7, 0x10, 0x7C, 0x28, 0x27, 0x8C, - 0x13, 0x95, 0x9C, 0xC7, 0x24, 0x46, 0x3B, 0x70, - 0xCA, 0xE3, 0x85, 0xCB, 0x11, 0xD0, 0x93, 0xB8, - 0xA6, 0x83, 0x20, 0xFF, 0x9F, 0x77, 0xC3, 0xCC, - 0x03, 0x6F, 0x08, 0xBF, 0x40, 0xE7, 0x2B, 0xE2, - 0x79, 0x0C, 0xAA, 0x82, 0x41, 0x3A, 0xEA, 0xB9, - 0xE4, 0x9A, 0xA4, 0x97, 0x7E, 0xDA, 0x7A, 0x17, - 0x66, 0x94, 0xA1, 0x1D, 0x3D, 0xF0, 0xDE, 0xB3, - 0x0B, 0x72, 0xA7, 0x1C, 0xEF, 0xD1, 0x53, 0x3E, - 0x8F, 0x33, 0x26, 0x5F, 0xEC, 0x76, 0x2A, 0x49, - 0x81, 0x88, 0xEE, 0x21, 0xC4, 0x1A, 0xEB, 0xD9, - 0xC5, 0x39, 0x99, 0xCD, 0xAD, 0x31, 0x8B, 0x01, - 0x18, 0x23, 0xDD, 0x1F, 0x4E, 0x2D, 0xF9, 0x48, - 0x4F, 0xF2, 0x65, 0x8E, 0x78, 0x5C, 0x58, 0x19, - 0x8D, 0xE5, 0x98, 0x57, 0x67, 0x7F, 0x05, 0x64, - 0xAF, 0x63, 0xB6, 0xFE, 0xF5, 0xB7, 0x3C, 0xA5, - 0xCE, 0xE9, 0x68, 0x44, 0xE0, 0x4D, 0x43, 0x69, - 0x29, 0x2E, 0xAC, 0x15, 0x59, 0xA8, 0x0A, 0x9E, - 0x6E, 0x47, 0xDF, 0x34, 0x35, 0x6A, 0xCF, 0xDC, - 0x22, 0xC9, 0xC0, 0x9B, 0x89, 0xD4, 0xED, 0xAB, - 0x12, 0xA2, 0x0D, 0x52, 0xBB, 0x02, 0x2F, 0xA9, - 0xD7, 0x61, 0x1E, 0xB4, 0x50, 0x04, 0xF6, 0xC2, - 0x16, 0x25, 0x86, 0x56, 0x55, 0x09, 0xBE, 0x91 - ); - - /** - * M-Table - * - * @var array - * @access private - */ - var $m0 = array( - 0xBCBC3275, 0xECEC21F3, 0x202043C6, 0xB3B3C9F4, 0xDADA03DB, 0x02028B7B, 0xE2E22BFB, 0x9E9EFAC8, - 0xC9C9EC4A, 0xD4D409D3, 0x18186BE6, 0x1E1E9F6B, 0x98980E45, 0xB2B2387D, 0xA6A6D2E8, 0x2626B74B, - 0x3C3C57D6, 0x93938A32, 0x8282EED8, 0x525298FD, 0x7B7BD437, 0xBBBB3771, 0x5B5B97F1, 0x474783E1, - 0x24243C30, 0x5151E20F, 0xBABAC6F8, 0x4A4AF31B, 0xBFBF4887, 0x0D0D70FA, 0xB0B0B306, 0x7575DE3F, - 0xD2D2FD5E, 0x7D7D20BA, 0x666631AE, 0x3A3AA35B, 0x59591C8A, 0x00000000, 0xCDCD93BC, 0x1A1AE09D, - 0xAEAE2C6D, 0x7F7FABC1, 0x2B2BC7B1, 0xBEBEB90E, 0xE0E0A080, 0x8A8A105D, 0x3B3B52D2, 0x6464BAD5, - 0xD8D888A0, 0xE7E7A584, 0x5F5FE807, 0x1B1B1114, 0x2C2CC2B5, 0xFCFCB490, 0x3131272C, 0x808065A3, - 0x73732AB2, 0x0C0C8173, 0x79795F4C, 0x6B6B4154, 0x4B4B0292, 0x53536974, 0x94948F36, 0x83831F51, - 0x2A2A3638, 0xC4C49CB0, 0x2222C8BD, 0xD5D5F85A, 0xBDBDC3FC, 0x48487860, 0xFFFFCE62, 0x4C4C0796, - 0x4141776C, 0xC7C7E642, 0xEBEB24F7, 0x1C1C1410, 0x5D5D637C, 0x36362228, 0x6767C027, 0xE9E9AF8C, - 0x4444F913, 0x1414EA95, 0xF5F5BB9C, 0xCFCF18C7, 0x3F3F2D24, 0xC0C0E346, 0x7272DB3B, 0x54546C70, - 0x29294CCA, 0xF0F035E3, 0x0808FE85, 0xC6C617CB, 0xF3F34F11, 0x8C8CE4D0, 0xA4A45993, 0xCACA96B8, - 0x68683BA6, 0xB8B84D83, 0x38382820, 0xE5E52EFF, 0xADAD569F, 0x0B0B8477, 0xC8C81DC3, 0x9999FFCC, - 0x5858ED03, 0x19199A6F, 0x0E0E0A08, 0x95957EBF, 0x70705040, 0xF7F730E7, 0x6E6ECF2B, 0x1F1F6EE2, - 0xB5B53D79, 0x09090F0C, 0x616134AA, 0x57571682, 0x9F9F0B41, 0x9D9D803A, 0x111164EA, 0x2525CDB9, - 0xAFAFDDE4, 0x4545089A, 0xDFDF8DA4, 0xA3A35C97, 0xEAEAD57E, 0x353558DA, 0xEDEDD07A, 0x4343FC17, - 0xF8F8CB66, 0xFBFBB194, 0x3737D3A1, 0xFAFA401D, 0xC2C2683D, 0xB4B4CCF0, 0x32325DDE, 0x9C9C71B3, - 0x5656E70B, 0xE3E3DA72, 0x878760A7, 0x15151B1C, 0xF9F93AEF, 0x6363BFD1, 0x3434A953, 0x9A9A853E, - 0xB1B1428F, 0x7C7CD133, 0x88889B26, 0x3D3DA65F, 0xA1A1D7EC, 0xE4E4DF76, 0x8181942A, 0x91910149, - 0x0F0FFB81, 0xEEEEAA88, 0x161661EE, 0xD7D77321, 0x9797F5C4, 0xA5A5A81A, 0xFEFE3FEB, 0x6D6DB5D9, - 0x7878AEC5, 0xC5C56D39, 0x1D1DE599, 0x7676A4CD, 0x3E3EDCAD, 0xCBCB6731, 0xB6B6478B, 0xEFEF5B01, - 0x12121E18, 0x6060C523, 0x6A6AB0DD, 0x4D4DF61F, 0xCECEE94E, 0xDEDE7C2D, 0x55559DF9, 0x7E7E5A48, - 0x2121B24F, 0x03037AF2, 0xA0A02665, 0x5E5E198E, 0x5A5A6678, 0x65654B5C, 0x62624E58, 0xFDFD4519, - 0x0606F48D, 0x404086E5, 0xF2F2BE98, 0x3333AC57, 0x17179067, 0x05058E7F, 0xE8E85E05, 0x4F4F7D64, - 0x89896AAF, 0x10109563, 0x74742FB6, 0x0A0A75FE, 0x5C5C92F5, 0x9B9B74B7, 0x2D2D333C, 0x3030D6A5, - 0x2E2E49CE, 0x494989E9, 0x46467268, 0x77775544, 0xA8A8D8E0, 0x9696044D, 0x2828BD43, 0xA9A92969, - 0xD9D97929, 0x8686912E, 0xD1D187AC, 0xF4F44A15, 0x8D8D1559, 0xD6D682A8, 0xB9B9BC0A, 0x42420D9E, - 0xF6F6C16E, 0x2F2FB847, 0xDDDD06DF, 0x23233934, 0xCCCC6235, 0xF1F1C46A, 0xC1C112CF, 0x8585EBDC, - 0x8F8F9E22, 0x7171A1C9, 0x9090F0C0, 0xAAAA539B, 0x0101F189, 0x8B8BE1D4, 0x4E4E8CED, 0x8E8E6FAB, - 0xABABA212, 0x6F6F3EA2, 0xE6E6540D, 0xDBDBF252, 0x92927BBB, 0xB7B7B602, 0x6969CA2F, 0x3939D9A9, - 0xD3D30CD7, 0xA7A72361, 0xA2A2AD1E, 0xC3C399B4, 0x6C6C4450, 0x07070504, 0x04047FF6, 0x272746C2, - 0xACACA716, 0xD0D07625, 0x50501386, 0xDCDCF756, 0x84841A55, 0xE1E15109, 0x7A7A25BE, 0x1313EF91 - ); - - /** - * M-Table - * - * @var array - * @access private - */ - var $m1 = array( - 0xA9D93939, 0x67901717, 0xB3719C9C, 0xE8D2A6A6, 0x04050707, 0xFD985252, 0xA3658080, 0x76DFE4E4, - 0x9A084545, 0x92024B4B, 0x80A0E0E0, 0x78665A5A, 0xE4DDAFAF, 0xDDB06A6A, 0xD1BF6363, 0x38362A2A, - 0x0D54E6E6, 0xC6432020, 0x3562CCCC, 0x98BEF2F2, 0x181E1212, 0xF724EBEB, 0xECD7A1A1, 0x6C774141, - 0x43BD2828, 0x7532BCBC, 0x37D47B7B, 0x269B8888, 0xFA700D0D, 0x13F94444, 0x94B1FBFB, 0x485A7E7E, - 0xF27A0303, 0xD0E48C8C, 0x8B47B6B6, 0x303C2424, 0x84A5E7E7, 0x54416B6B, 0xDF06DDDD, 0x23C56060, - 0x1945FDFD, 0x5BA33A3A, 0x3D68C2C2, 0x59158D8D, 0xF321ECEC, 0xAE316666, 0xA23E6F6F, 0x82165757, - 0x63951010, 0x015BEFEF, 0x834DB8B8, 0x2E918686, 0xD9B56D6D, 0x511F8383, 0x9B53AAAA, 0x7C635D5D, - 0xA63B6868, 0xEB3FFEFE, 0xA5D63030, 0xBE257A7A, 0x16A7ACAC, 0x0C0F0909, 0xE335F0F0, 0x6123A7A7, - 0xC0F09090, 0x8CAFE9E9, 0x3A809D9D, 0xF5925C5C, 0x73810C0C, 0x2C273131, 0x2576D0D0, 0x0BE75656, - 0xBB7B9292, 0x4EE9CECE, 0x89F10101, 0x6B9F1E1E, 0x53A93434, 0x6AC4F1F1, 0xB499C3C3, 0xF1975B5B, - 0xE1834747, 0xE66B1818, 0xBDC82222, 0x450E9898, 0xE26E1F1F, 0xF4C9B3B3, 0xB62F7474, 0x66CBF8F8, - 0xCCFF9999, 0x95EA1414, 0x03ED5858, 0x56F7DCDC, 0xD4E18B8B, 0x1C1B1515, 0x1EADA2A2, 0xD70CD3D3, - 0xFB2BE2E2, 0xC31DC8C8, 0x8E195E5E, 0xB5C22C2C, 0xE9894949, 0xCF12C1C1, 0xBF7E9595, 0xBA207D7D, - 0xEA641111, 0x77840B0B, 0x396DC5C5, 0xAF6A8989, 0x33D17C7C, 0xC9A17171, 0x62CEFFFF, 0x7137BBBB, - 0x81FB0F0F, 0x793DB5B5, 0x0951E1E1, 0xADDC3E3E, 0x242D3F3F, 0xCDA47676, 0xF99D5555, 0xD8EE8282, - 0xE5864040, 0xC5AE7878, 0xB9CD2525, 0x4D049696, 0x44557777, 0x080A0E0E, 0x86135050, 0xE730F7F7, - 0xA1D33737, 0x1D40FAFA, 0xAA346161, 0xED8C4E4E, 0x06B3B0B0, 0x706C5454, 0xB22A7373, 0xD2523B3B, - 0x410B9F9F, 0x7B8B0202, 0xA088D8D8, 0x114FF3F3, 0x3167CBCB, 0xC2462727, 0x27C06767, 0x90B4FCFC, - 0x20283838, 0xF67F0404, 0x60784848, 0xFF2EE5E5, 0x96074C4C, 0x5C4B6565, 0xB1C72B2B, 0xAB6F8E8E, - 0x9E0D4242, 0x9CBBF5F5, 0x52F2DBDB, 0x1BF34A4A, 0x5FA63D3D, 0x9359A4A4, 0x0ABCB9B9, 0xEF3AF9F9, - 0x91EF1313, 0x85FE0808, 0x49019191, 0xEE611616, 0x2D7CDEDE, 0x4FB22121, 0x8F42B1B1, 0x3BDB7272, - 0x47B82F2F, 0x8748BFBF, 0x6D2CAEAE, 0x46E3C0C0, 0xD6573C3C, 0x3E859A9A, 0x6929A9A9, 0x647D4F4F, - 0x2A948181, 0xCE492E2E, 0xCB17C6C6, 0x2FCA6969, 0xFCC3BDBD, 0x975CA3A3, 0x055EE8E8, 0x7AD0EDED, - 0xAC87D1D1, 0x7F8E0505, 0xD5BA6464, 0x1AA8A5A5, 0x4BB72626, 0x0EB9BEBE, 0xA7608787, 0x5AF8D5D5, - 0x28223636, 0x14111B1B, 0x3FDE7575, 0x2979D9D9, 0x88AAEEEE, 0x3C332D2D, 0x4C5F7979, 0x02B6B7B7, - 0xB896CACA, 0xDA583535, 0xB09CC4C4, 0x17FC4343, 0x551A8484, 0x1FF64D4D, 0x8A1C5959, 0x7D38B2B2, - 0x57AC3333, 0xC718CFCF, 0x8DF40606, 0x74695353, 0xB7749B9B, 0xC4F59797, 0x9F56ADAD, 0x72DAE3E3, - 0x7ED5EAEA, 0x154AF4F4, 0x229E8F8F, 0x12A2ABAB, 0x584E6262, 0x07E85F5F, 0x99E51D1D, 0x34392323, - 0x6EC1F6F6, 0x50446C6C, 0xDE5D3232, 0x68724646, 0x6526A0A0, 0xBC93CDCD, 0xDB03DADA, 0xF8C6BABA, - 0xC8FA9E9E, 0xA882D6D6, 0x2BCF6E6E, 0x40507070, 0xDCEB8585, 0xFE750A0A, 0x328A9393, 0xA48DDFDF, - 0xCA4C2929, 0x10141C1C, 0x2173D7D7, 0xF0CCB4B4, 0xD309D4D4, 0x5D108A8A, 0x0FE25151, 0x00000000, - 0x6F9A1919, 0x9DE01A1A, 0x368F9494, 0x42E6C7C7, 0x4AECC9C9, 0x5EFDD2D2, 0xC1AB7F7F, 0xE0D8A8A8 - ); - - /** - * M-Table - * - * @var array - * @access private - */ - var $m2 = array( - 0xBC75BC32, 0xECF3EC21, 0x20C62043, 0xB3F4B3C9, 0xDADBDA03, 0x027B028B, 0xE2FBE22B, 0x9EC89EFA, - 0xC94AC9EC, 0xD4D3D409, 0x18E6186B, 0x1E6B1E9F, 0x9845980E, 0xB27DB238, 0xA6E8A6D2, 0x264B26B7, - 0x3CD63C57, 0x9332938A, 0x82D882EE, 0x52FD5298, 0x7B377BD4, 0xBB71BB37, 0x5BF15B97, 0x47E14783, - 0x2430243C, 0x510F51E2, 0xBAF8BAC6, 0x4A1B4AF3, 0xBF87BF48, 0x0DFA0D70, 0xB006B0B3, 0x753F75DE, - 0xD25ED2FD, 0x7DBA7D20, 0x66AE6631, 0x3A5B3AA3, 0x598A591C, 0x00000000, 0xCDBCCD93, 0x1A9D1AE0, - 0xAE6DAE2C, 0x7FC17FAB, 0x2BB12BC7, 0xBE0EBEB9, 0xE080E0A0, 0x8A5D8A10, 0x3BD23B52, 0x64D564BA, - 0xD8A0D888, 0xE784E7A5, 0x5F075FE8, 0x1B141B11, 0x2CB52CC2, 0xFC90FCB4, 0x312C3127, 0x80A38065, - 0x73B2732A, 0x0C730C81, 0x794C795F, 0x6B546B41, 0x4B924B02, 0x53745369, 0x9436948F, 0x8351831F, - 0x2A382A36, 0xC4B0C49C, 0x22BD22C8, 0xD55AD5F8, 0xBDFCBDC3, 0x48604878, 0xFF62FFCE, 0x4C964C07, - 0x416C4177, 0xC742C7E6, 0xEBF7EB24, 0x1C101C14, 0x5D7C5D63, 0x36283622, 0x672767C0, 0xE98CE9AF, - 0x441344F9, 0x149514EA, 0xF59CF5BB, 0xCFC7CF18, 0x3F243F2D, 0xC046C0E3, 0x723B72DB, 0x5470546C, - 0x29CA294C, 0xF0E3F035, 0x088508FE, 0xC6CBC617, 0xF311F34F, 0x8CD08CE4, 0xA493A459, 0xCAB8CA96, - 0x68A6683B, 0xB883B84D, 0x38203828, 0xE5FFE52E, 0xAD9FAD56, 0x0B770B84, 0xC8C3C81D, 0x99CC99FF, - 0x580358ED, 0x196F199A, 0x0E080E0A, 0x95BF957E, 0x70407050, 0xF7E7F730, 0x6E2B6ECF, 0x1FE21F6E, - 0xB579B53D, 0x090C090F, 0x61AA6134, 0x57825716, 0x9F419F0B, 0x9D3A9D80, 0x11EA1164, 0x25B925CD, - 0xAFE4AFDD, 0x459A4508, 0xDFA4DF8D, 0xA397A35C, 0xEA7EEAD5, 0x35DA3558, 0xED7AEDD0, 0x431743FC, - 0xF866F8CB, 0xFB94FBB1, 0x37A137D3, 0xFA1DFA40, 0xC23DC268, 0xB4F0B4CC, 0x32DE325D, 0x9CB39C71, - 0x560B56E7, 0xE372E3DA, 0x87A78760, 0x151C151B, 0xF9EFF93A, 0x63D163BF, 0x345334A9, 0x9A3E9A85, - 0xB18FB142, 0x7C337CD1, 0x8826889B, 0x3D5F3DA6, 0xA1ECA1D7, 0xE476E4DF, 0x812A8194, 0x91499101, - 0x0F810FFB, 0xEE88EEAA, 0x16EE1661, 0xD721D773, 0x97C497F5, 0xA51AA5A8, 0xFEEBFE3F, 0x6DD96DB5, - 0x78C578AE, 0xC539C56D, 0x1D991DE5, 0x76CD76A4, 0x3EAD3EDC, 0xCB31CB67, 0xB68BB647, 0xEF01EF5B, - 0x1218121E, 0x602360C5, 0x6ADD6AB0, 0x4D1F4DF6, 0xCE4ECEE9, 0xDE2DDE7C, 0x55F9559D, 0x7E487E5A, - 0x214F21B2, 0x03F2037A, 0xA065A026, 0x5E8E5E19, 0x5A785A66, 0x655C654B, 0x6258624E, 0xFD19FD45, - 0x068D06F4, 0x40E54086, 0xF298F2BE, 0x335733AC, 0x17671790, 0x057F058E, 0xE805E85E, 0x4F644F7D, - 0x89AF896A, 0x10631095, 0x74B6742F, 0x0AFE0A75, 0x5CF55C92, 0x9BB79B74, 0x2D3C2D33, 0x30A530D6, - 0x2ECE2E49, 0x49E94989, 0x46684672, 0x77447755, 0xA8E0A8D8, 0x964D9604, 0x284328BD, 0xA969A929, - 0xD929D979, 0x862E8691, 0xD1ACD187, 0xF415F44A, 0x8D598D15, 0xD6A8D682, 0xB90AB9BC, 0x429E420D, - 0xF66EF6C1, 0x2F472FB8, 0xDDDFDD06, 0x23342339, 0xCC35CC62, 0xF16AF1C4, 0xC1CFC112, 0x85DC85EB, - 0x8F228F9E, 0x71C971A1, 0x90C090F0, 0xAA9BAA53, 0x018901F1, 0x8BD48BE1, 0x4EED4E8C, 0x8EAB8E6F, - 0xAB12ABA2, 0x6FA26F3E, 0xE60DE654, 0xDB52DBF2, 0x92BB927B, 0xB702B7B6, 0x692F69CA, 0x39A939D9, - 0xD3D7D30C, 0xA761A723, 0xA21EA2AD, 0xC3B4C399, 0x6C506C44, 0x07040705, 0x04F6047F, 0x27C22746, - 0xAC16ACA7, 0xD025D076, 0x50865013, 0xDC56DCF7, 0x8455841A, 0xE109E151, 0x7ABE7A25, 0x139113EF - ); - - /** - * M-Table - * - * @var array - * @access private - */ - var $m3 = array( - 0xD939A9D9, 0x90176790, 0x719CB371, 0xD2A6E8D2, 0x05070405, 0x9852FD98, 0x6580A365, 0xDFE476DF, - 0x08459A08, 0x024B9202, 0xA0E080A0, 0x665A7866, 0xDDAFE4DD, 0xB06ADDB0, 0xBF63D1BF, 0x362A3836, - 0x54E60D54, 0x4320C643, 0x62CC3562, 0xBEF298BE, 0x1E12181E, 0x24EBF724, 0xD7A1ECD7, 0x77416C77, - 0xBD2843BD, 0x32BC7532, 0xD47B37D4, 0x9B88269B, 0x700DFA70, 0xF94413F9, 0xB1FB94B1, 0x5A7E485A, - 0x7A03F27A, 0xE48CD0E4, 0x47B68B47, 0x3C24303C, 0xA5E784A5, 0x416B5441, 0x06DDDF06, 0xC56023C5, - 0x45FD1945, 0xA33A5BA3, 0x68C23D68, 0x158D5915, 0x21ECF321, 0x3166AE31, 0x3E6FA23E, 0x16578216, - 0x95106395, 0x5BEF015B, 0x4DB8834D, 0x91862E91, 0xB56DD9B5, 0x1F83511F, 0x53AA9B53, 0x635D7C63, - 0x3B68A63B, 0x3FFEEB3F, 0xD630A5D6, 0x257ABE25, 0xA7AC16A7, 0x0F090C0F, 0x35F0E335, 0x23A76123, - 0xF090C0F0, 0xAFE98CAF, 0x809D3A80, 0x925CF592, 0x810C7381, 0x27312C27, 0x76D02576, 0xE7560BE7, - 0x7B92BB7B, 0xE9CE4EE9, 0xF10189F1, 0x9F1E6B9F, 0xA93453A9, 0xC4F16AC4, 0x99C3B499, 0x975BF197, - 0x8347E183, 0x6B18E66B, 0xC822BDC8, 0x0E98450E, 0x6E1FE26E, 0xC9B3F4C9, 0x2F74B62F, 0xCBF866CB, - 0xFF99CCFF, 0xEA1495EA, 0xED5803ED, 0xF7DC56F7, 0xE18BD4E1, 0x1B151C1B, 0xADA21EAD, 0x0CD3D70C, - 0x2BE2FB2B, 0x1DC8C31D, 0x195E8E19, 0xC22CB5C2, 0x8949E989, 0x12C1CF12, 0x7E95BF7E, 0x207DBA20, - 0x6411EA64, 0x840B7784, 0x6DC5396D, 0x6A89AF6A, 0xD17C33D1, 0xA171C9A1, 0xCEFF62CE, 0x37BB7137, - 0xFB0F81FB, 0x3DB5793D, 0x51E10951, 0xDC3EADDC, 0x2D3F242D, 0xA476CDA4, 0x9D55F99D, 0xEE82D8EE, - 0x8640E586, 0xAE78C5AE, 0xCD25B9CD, 0x04964D04, 0x55774455, 0x0A0E080A, 0x13508613, 0x30F7E730, - 0xD337A1D3, 0x40FA1D40, 0x3461AA34, 0x8C4EED8C, 0xB3B006B3, 0x6C54706C, 0x2A73B22A, 0x523BD252, - 0x0B9F410B, 0x8B027B8B, 0x88D8A088, 0x4FF3114F, 0x67CB3167, 0x4627C246, 0xC06727C0, 0xB4FC90B4, - 0x28382028, 0x7F04F67F, 0x78486078, 0x2EE5FF2E, 0x074C9607, 0x4B655C4B, 0xC72BB1C7, 0x6F8EAB6F, - 0x0D429E0D, 0xBBF59CBB, 0xF2DB52F2, 0xF34A1BF3, 0xA63D5FA6, 0x59A49359, 0xBCB90ABC, 0x3AF9EF3A, - 0xEF1391EF, 0xFE0885FE, 0x01914901, 0x6116EE61, 0x7CDE2D7C, 0xB2214FB2, 0x42B18F42, 0xDB723BDB, - 0xB82F47B8, 0x48BF8748, 0x2CAE6D2C, 0xE3C046E3, 0x573CD657, 0x859A3E85, 0x29A96929, 0x7D4F647D, - 0x94812A94, 0x492ECE49, 0x17C6CB17, 0xCA692FCA, 0xC3BDFCC3, 0x5CA3975C, 0x5EE8055E, 0xD0ED7AD0, - 0x87D1AC87, 0x8E057F8E, 0xBA64D5BA, 0xA8A51AA8, 0xB7264BB7, 0xB9BE0EB9, 0x6087A760, 0xF8D55AF8, - 0x22362822, 0x111B1411, 0xDE753FDE, 0x79D92979, 0xAAEE88AA, 0x332D3C33, 0x5F794C5F, 0xB6B702B6, - 0x96CAB896, 0x5835DA58, 0x9CC4B09C, 0xFC4317FC, 0x1A84551A, 0xF64D1FF6, 0x1C598A1C, 0x38B27D38, - 0xAC3357AC, 0x18CFC718, 0xF4068DF4, 0x69537469, 0x749BB774, 0xF597C4F5, 0x56AD9F56, 0xDAE372DA, - 0xD5EA7ED5, 0x4AF4154A, 0x9E8F229E, 0xA2AB12A2, 0x4E62584E, 0xE85F07E8, 0xE51D99E5, 0x39233439, - 0xC1F66EC1, 0x446C5044, 0x5D32DE5D, 0x72466872, 0x26A06526, 0x93CDBC93, 0x03DADB03, 0xC6BAF8C6, - 0xFA9EC8FA, 0x82D6A882, 0xCF6E2BCF, 0x50704050, 0xEB85DCEB, 0x750AFE75, 0x8A93328A, 0x8DDFA48D, - 0x4C29CA4C, 0x141C1014, 0x73D72173, 0xCCB4F0CC, 0x09D4D309, 0x108A5D10, 0xE2510FE2, 0x00000000, - 0x9A196F9A, 0xE01A9DE0, 0x8F94368F, 0xE6C742E6, 0xECC94AEC, 0xFDD25EFD, 0xAB7FC1AB, 0xD8A8E0D8 - ); - - /** - * The Key Schedule Array - * - * @var array - * @access private - */ - var $K = array(); - - /** - * The Key depended S-Table 0 - * - * @var array - * @access private - */ - var $S0 = array(); - - /** - * The Key depended S-Table 1 - * - * @var array - * @access private - */ - var $S1 = array(); - - /** - * The Key depended S-Table 2 - * - * @var array - * @access private - */ - var $S2 = array(); - - /** - * The Key depended S-Table 3 - * - * @var array - * @access private - */ - var $S3 = array(); - - /** - * Holds the last used key - * - * @var array - * @access private - */ - var $kl; - - /** - * The Key Length (in bytes) - * - * @see Crypt_Twofish::setKeyLength() - * @var int - * @access private - */ - var $key_length = 16; - - /** - * Sets the key length. - * - * Valid key lengths are 128, 192 or 256 bits - * - * @access public - * @param int $length - */ - function setKeyLength($length) - { - switch (true) { - case $length <= 128: - $this->key_length = 16; - break; - case $length <= 192: - $this->key_length = 24; - break; - default: - $this->key_length = 32; - } - - parent::setKeyLength($length); - } - - /** - * Setup the key (expansion) - * - * @see \phpseclib\Crypt\Base::_setupKey() - * @access private - */ - function _setupKey() - { - if (isset($this->kl['key']) && $this->key === $this->kl['key']) { - // already expanded - return; - } - $this->kl = array('key' => $this->key); - - /* Key expanding and generating the key-depended s-boxes */ - $le_longs = unpack('V*', $this->key); - $key = unpack('C*', $this->key); - $m0 = $this->m0; - $m1 = $this->m1; - $m2 = $this->m2; - $m3 = $this->m3; - $q0 = $this->q0; - $q1 = $this->q1; - - $K = $S0 = $S1 = $S2 = $S3 = array(); - - switch (strlen($this->key)) { - case 16: - list($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[1], $le_longs[2]); - list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[3], $le_longs[4]); - for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { - $A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^ - $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^ - $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^ - $m3[$q1[$q1[$i] ^ $key[12]] ^ $key[4]]; - $B = $m0[$q0[$q0[$j] ^ $key[13]] ^ $key[5]] ^ - $m1[$q0[$q1[$j] ^ $key[14]] ^ $key[6]] ^ - $m2[$q1[$q0[$j] ^ $key[15]] ^ $key[7]] ^ - $m3[$q1[$q1[$j] ^ $key[16]] ^ $key[8]]; - $B = ($B << 8) | ($B >> 24 & 0xff); - $K[] = $A+= $B; - $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); - } - for ($i = 0; $i < 256; ++$i) { - $S0[$i] = $m0[$q0[$q0[$i] ^ $s4] ^ $s0]; - $S1[$i] = $m1[$q0[$q1[$i] ^ $s5] ^ $s1]; - $S2[$i] = $m2[$q1[$q0[$i] ^ $s6] ^ $s2]; - $S3[$i] = $m3[$q1[$q1[$i] ^ $s7] ^ $s3]; - } - break; - case 24: - list($sb, $sa, $s9, $s8) = $this->_mdsrem($le_longs[1], $le_longs[2]); - list($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[3], $le_longs[4]); - list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[5], $le_longs[6]); - for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { - $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ - $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ - $m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ - $m3[$q1[$q1[$q0[$i] ^ $key[20]] ^ $key[12]] ^ $key[4]]; - $B = $m0[$q0[$q0[$q1[$j] ^ $key[21]] ^ $key[13]] ^ $key[5]] ^ - $m1[$q0[$q1[$q1[$j] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^ - $m2[$q1[$q0[$q0[$j] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ - $m3[$q1[$q1[$q0[$j] ^ $key[24]] ^ $key[16]] ^ $key[8]]; - $B = ($B << 8) | ($B >> 24 & 0xff); - $K[] = $A+= $B; - $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); - } - for ($i = 0; $i < 256; ++$i) { - $S0[$i] = $m0[$q0[$q0[$q1[$i] ^ $s8] ^ $s4] ^ $s0]; - $S1[$i] = $m1[$q0[$q1[$q1[$i] ^ $s9] ^ $s5] ^ $s1]; - $S2[$i] = $m2[$q1[$q0[$q0[$i] ^ $sa] ^ $s6] ^ $s2]; - $S3[$i] = $m3[$q1[$q1[$q0[$i] ^ $sb] ^ $s7] ^ $s3]; - } - break; - default: // 32 - list($sf, $se, $sd, $sc) = $this->_mdsrem($le_longs[1], $le_longs[2]); - list($sb, $sa, $s9, $s8) = $this->_mdsrem($le_longs[3], $le_longs[4]); - list($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[5], $le_longs[6]); - list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[7], $le_longs[8]); - for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { - $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ - $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ - $m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ - $m3[$q1[$q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] ^ $key[12]] ^ $key[4]]; - $B = $m0[$q0[$q0[$q1[$q1[$j] ^ $key[29]] ^ $key[21]] ^ $key[13]] ^ $key[5]] ^ - $m1[$q0[$q1[$q1[$q0[$j] ^ $key[30]] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^ - $m2[$q1[$q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ - $m3[$q1[$q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] ^ $key[16]] ^ $key[8]]; - $B = ($B << 8) | ($B >> 24 & 0xff); - $K[] = $A+= $B; - $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); - } - for ($i = 0; $i < 256; ++$i) { - $S0[$i] = $m0[$q0[$q0[$q1[$q1[$i] ^ $sc] ^ $s8] ^ $s4] ^ $s0]; - $S1[$i] = $m1[$q0[$q1[$q1[$q0[$i] ^ $sd] ^ $s9] ^ $s5] ^ $s1]; - $S2[$i] = $m2[$q1[$q0[$q0[$q0[$i] ^ $se] ^ $sa] ^ $s6] ^ $s2]; - $S3[$i] = $m3[$q1[$q1[$q0[$q1[$i] ^ $sf] ^ $sb] ^ $s7] ^ $s3]; - } - } - - $this->K = $K; - $this->S0 = $S0; - $this->S1 = $S1; - $this->S2 = $S2; - $this->S3 = $S3; - } - - /** - * _mdsrem function using by the twofish cipher algorithm - * - * @access private - * @param string $A - * @param string $B - * @return array - */ - function _mdsrem($A, $B) - { - // No gain by unrolling this loop. - for ($i = 0; $i < 8; ++$i) { - // Get most significant coefficient. - $t = 0xff & ($B >> 24); - - // Shift the others up. - $B = ($B << 8) | (0xff & ($A >> 24)); - $A<<= 8; - - $u = $t << 1; - - // Subtract the modular polynomial on overflow. - if ($t & 0x80) { - $u^= 0x14d; - } - - // Remove t * (a * x^2 + 1). - $B ^= $t ^ ($u << 16); - - // Form u = a*t + t/a = t*(a + 1/a). - $u^= 0x7fffffff & ($t >> 1); - - // Add the modular polynomial on underflow. - if ($t & 0x01) { - $u^= 0xa6 ; - } - - // Remove t * (a + 1/a) * (x^3 + x). - $B^= ($u << 24) | ($u << 8); - } - - return array( - 0xff & $B >> 24, - 0xff & $B >> 16, - 0xff & $B >> 8, - 0xff & $B); - } - - /** - * Encrypts a block - * - * @access private - * @param string $in - * @return string - */ - function _encryptBlock($in) - { - $S0 = $this->S0; - $S1 = $this->S1; - $S2 = $this->S2; - $S3 = $this->S3; - $K = $this->K; - - $in = unpack("V4", $in); - $R0 = $K[0] ^ $in[1]; - $R1 = $K[1] ^ $in[2]; - $R2 = $K[2] ^ $in[3]; - $R3 = $K[3] ^ $in[4]; - - $ki = 7; - while ($ki < 39) { - $t0 = $S0[ $R0 & 0xff] ^ - $S1[($R0 >> 8) & 0xff] ^ - $S2[($R0 >> 16) & 0xff] ^ - $S3[($R0 >> 24) & 0xff]; - $t1 = $S0[($R1 >> 24) & 0xff] ^ - $S1[ $R1 & 0xff] ^ - $S2[($R1 >> 8) & 0xff] ^ - $S3[($R1 >> 16) & 0xff]; - $R2^= $t0 + $t1 + $K[++$ki]; - $R2 = ($R2 >> 1 & 0x7fffffff) | ($R2 << 31); - $R3 = ((($R3 >> 31) & 1) | ($R3 << 1)) ^ ($t0 + ($t1 << 1) + $K[++$ki]); - - $t0 = $S0[ $R2 & 0xff] ^ - $S1[($R2 >> 8) & 0xff] ^ - $S2[($R2 >> 16) & 0xff] ^ - $S3[($R2 >> 24) & 0xff]; - $t1 = $S0[($R3 >> 24) & 0xff] ^ - $S1[ $R3 & 0xff] ^ - $S2[($R3 >> 8) & 0xff] ^ - $S3[($R3 >> 16) & 0xff]; - $R0^= ($t0 + $t1 + $K[++$ki]); - $R0 = ($R0 >> 1 & 0x7fffffff) | ($R0 << 31); - $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ ($t0 + ($t1 << 1) + $K[++$ki]); - } - - // @codingStandardsIgnoreStart - return pack("V4", $K[4] ^ $R2, - $K[5] ^ $R3, - $K[6] ^ $R0, - $K[7] ^ $R1); - // @codingStandardsIgnoreEnd - } - - /** - * Decrypts a block - * - * @access private - * @param string $in - * @return string - */ - function _decryptBlock($in) - { - $S0 = $this->S0; - $S1 = $this->S1; - $S2 = $this->S2; - $S3 = $this->S3; - $K = $this->K; - - $in = unpack("V4", $in); - $R0 = $K[4] ^ $in[1]; - $R1 = $K[5] ^ $in[2]; - $R2 = $K[6] ^ $in[3]; - $R3 = $K[7] ^ $in[4]; - - $ki = 40; - while ($ki > 8) { - $t0 = $S0[$R0 & 0xff] ^ - $S1[$R0 >> 8 & 0xff] ^ - $S2[$R0 >> 16 & 0xff] ^ - $S3[$R0 >> 24 & 0xff]; - $t1 = $S0[$R1 >> 24 & 0xff] ^ - $S1[$R1 & 0xff] ^ - $S2[$R1 >> 8 & 0xff] ^ - $S3[$R1 >> 16 & 0xff]; - $R3^= $t0 + ($t1 << 1) + $K[--$ki]; - $R3 = $R3 >> 1 & 0x7fffffff | $R3 << 31; - $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ ($t0 + $t1 + $K[--$ki]); - - $t0 = $S0[$R2 & 0xff] ^ - $S1[$R2 >> 8 & 0xff] ^ - $S2[$R2 >> 16 & 0xff] ^ - $S3[$R2 >> 24 & 0xff]; - $t1 = $S0[$R3 >> 24 & 0xff] ^ - $S1[$R3 & 0xff] ^ - $S2[$R3 >> 8 & 0xff] ^ - $S3[$R3 >> 16 & 0xff]; - $R1^= $t0 + ($t1 << 1) + $K[--$ki]; - $R1 = $R1 >> 1 & 0x7fffffff | $R1 << 31; - $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ ($t0 + $t1 + $K[--$ki]); - } - - // @codingStandardsIgnoreStart - return pack("V4", $K[0] ^ $R2, - $K[1] ^ $R3, - $K[2] ^ $R0, - $K[3] ^ $R1); - // @codingStandardsIgnoreEnd - } - - /** - * Setup the performance-optimized function for de/encrypt() - * - * @see \phpseclib\Crypt\Base::_setupInlineCrypt() - * @access private - */ - function _setupInlineCrypt() - { - $lambda_functions =& self::_getLambdaFunctions(); - - // Max. 10 Ultra-Hi-optimized inline-crypt functions. After that, we'll (still) create very fast code, but not the ultimate fast one. - // (Currently, for Crypt_Twofish, one generated $lambda_function cost on php5.5@32bit ~140kb unfreeable mem and ~240kb on php5.5@64bit) - $gen_hi_opt_code = (bool)(count($lambda_functions) < 10); - - // Generation of a uniqe hash for our generated code - $code_hash = "Crypt_Twofish, {$this->mode}"; - if ($gen_hi_opt_code) { - $code_hash = str_pad($code_hash, 32) . $this->_hashInlineCryptFunction($this->key); - } - - if (!isset($lambda_functions[$code_hash])) { - switch (true) { - case $gen_hi_opt_code: - $K = $this->K; - $init_crypt = ' - static $S0, $S1, $S2, $S3; - if (!$S0) { - for ($i = 0; $i < 256; ++$i) { - $S0[] = (int)$self->S0[$i]; - $S1[] = (int)$self->S1[$i]; - $S2[] = (int)$self->S2[$i]; - $S3[] = (int)$self->S3[$i]; - } - } - '; - break; - default: - $K = array(); - for ($i = 0; $i < 40; ++$i) { - $K[] = '$K_' . $i; - } - $init_crypt = ' - $S0 = $self->S0; - $S1 = $self->S1; - $S2 = $self->S2; - $S3 = $self->S3; - list(' . implode(',', $K) . ') = $self->K; - '; - } - - // Generating encrypt code: - $encrypt_block = ' - $in = unpack("V4", $in); - $R0 = '.$K[0].' ^ $in[1]; - $R1 = '.$K[1].' ^ $in[2]; - $R2 = '.$K[2].' ^ $in[3]; - $R3 = '.$K[3].' ^ $in[4]; - '; - for ($ki = 7, $i = 0; $i < 8; ++$i) { - $encrypt_block.= ' - $t0 = $S0[ $R0 & 0xff] ^ - $S1[($R0 >> 8) & 0xff] ^ - $S2[($R0 >> 16) & 0xff] ^ - $S3[($R0 >> 24) & 0xff]; - $t1 = $S0[($R1 >> 24) & 0xff] ^ - $S1[ $R1 & 0xff] ^ - $S2[($R1 >> 8) & 0xff] ^ - $S3[($R1 >> 16) & 0xff]; - $R2^= ($t0 + $t1 + '.$K[++$ki].'); - $R2 = ($R2 >> 1 & 0x7fffffff) | ($R2 << 31); - $R3 = ((($R3 >> 31) & 1) | ($R3 << 1)) ^ ($t0 + ($t1 << 1) + '.$K[++$ki].'); - - $t0 = $S0[ $R2 & 0xff] ^ - $S1[($R2 >> 8) & 0xff] ^ - $S2[($R2 >> 16) & 0xff] ^ - $S3[($R2 >> 24) & 0xff]; - $t1 = $S0[($R3 >> 24) & 0xff] ^ - $S1[ $R3 & 0xff] ^ - $S2[($R3 >> 8) & 0xff] ^ - $S3[($R3 >> 16) & 0xff]; - $R0^= ($t0 + $t1 + '.$K[++$ki].'); - $R0 = ($R0 >> 1 & 0x7fffffff) | ($R0 << 31); - $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ ($t0 + ($t1 << 1) + '.$K[++$ki].'); - '; - } - $encrypt_block.= ' - $in = pack("V4", '.$K[4].' ^ $R2, - '.$K[5].' ^ $R3, - '.$K[6].' ^ $R0, - '.$K[7].' ^ $R1); - '; - - // Generating decrypt code: - $decrypt_block = ' - $in = unpack("V4", $in); - $R0 = '.$K[4].' ^ $in[1]; - $R1 = '.$K[5].' ^ $in[2]; - $R2 = '.$K[6].' ^ $in[3]; - $R3 = '.$K[7].' ^ $in[4]; - '; - for ($ki = 40, $i = 0; $i < 8; ++$i) { - $decrypt_block.= ' - $t0 = $S0[$R0 & 0xff] ^ - $S1[$R0 >> 8 & 0xff] ^ - $S2[$R0 >> 16 & 0xff] ^ - $S3[$R0 >> 24 & 0xff]; - $t1 = $S0[$R1 >> 24 & 0xff] ^ - $S1[$R1 & 0xff] ^ - $S2[$R1 >> 8 & 0xff] ^ - $S3[$R1 >> 16 & 0xff]; - $R3^= $t0 + ($t1 << 1) + '.$K[--$ki].'; - $R3 = $R3 >> 1 & 0x7fffffff | $R3 << 31; - $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ ($t0 + $t1 + '.$K[--$ki].'); - - $t0 = $S0[$R2 & 0xff] ^ - $S1[$R2 >> 8 & 0xff] ^ - $S2[$R2 >> 16 & 0xff] ^ - $S3[$R2 >> 24 & 0xff]; - $t1 = $S0[$R3 >> 24 & 0xff] ^ - $S1[$R3 & 0xff] ^ - $S2[$R3 >> 8 & 0xff] ^ - $S3[$R3 >> 16 & 0xff]; - $R1^= $t0 + ($t1 << 1) + '.$K[--$ki].'; - $R1 = $R1 >> 1 & 0x7fffffff | $R1 << 31; - $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ ($t0 + $t1 + '.$K[--$ki].'); - '; - } - $decrypt_block.= ' - $in = pack("V4", '.$K[0].' ^ $R2, - '.$K[1].' ^ $R3, - '.$K[2].' ^ $R0, - '.$K[3].' ^ $R1); - '; - - $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( - array( - 'init_crypt' => $init_crypt, - 'init_encrypt' => '', - 'init_decrypt' => '', - 'encrypt_block' => $encrypt_block, - 'decrypt_block' => $decrypt_block - ) - ); - } - $this->inline_crypt = $lambda_functions[$code_hash]; - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/File/ANSI.php b/vendor/phpseclib/phpseclib/phpseclib/File/ANSI.php deleted file mode 100755 index 1f3eecb30a1b44a8df89ad29251523a4b8ab196a..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/File/ANSI.php +++ /dev/null @@ -1,574 +0,0 @@ -<?php - -/** - * Pure-PHP ANSI Decoder - * - * PHP version 5 - * - * If you call read() in \phpseclib\Net\SSH2 you may get {@link http://en.wikipedia.org/wiki/ANSI_escape_code ANSI escape codes} back. - * They'd look like chr(0x1B) . '[00m' or whatever (0x1B = ESC). They tell a - * {@link http://en.wikipedia.org/wiki/Terminal_emulator terminal emulator} how to format the characters, what - * color to display them in, etc. \phpseclib\File\ANSI is a {@link http://en.wikipedia.org/wiki/VT100 VT100} terminal emulator. - * - * @category File - * @package ANSI - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2012 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\File; - -/** - * Pure-PHP ANSI Decoder - * - * @package ANSI - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class ANSI -{ - /** - * Max Width - * - * @var int - * @access private - */ - var $max_x; - - /** - * Max Height - * - * @var int - * @access private - */ - var $max_y; - - /** - * Max History - * - * @var int - * @access private - */ - var $max_history; - - /** - * History - * - * @var array - * @access private - */ - var $history; - - /** - * History Attributes - * - * @var array - * @access private - */ - var $history_attrs; - - /** - * Current Column - * - * @var int - * @access private - */ - var $x; - - /** - * Current Row - * - * @var int - * @access private - */ - var $y; - - /** - * Old Column - * - * @var int - * @access private - */ - var $old_x; - - /** - * Old Row - * - * @var int - * @access private - */ - var $old_y; - - /** - * An empty attribute cell - * - * @var object - * @access private - */ - var $base_attr_cell; - - /** - * The current attribute cell - * - * @var object - * @access private - */ - var $attr_cell; - - /** - * An empty attribute row - * - * @var array - * @access private - */ - var $attr_row; - - /** - * The current screen text - * - * @var array - * @access private - */ - var $screen; - - /** - * The current screen attributes - * - * @var array - * @access private - */ - var $attrs; - - /** - * Current ANSI code - * - * @var string - * @access private - */ - var $ansi; - - /** - * Tokenization - * - * @var array - * @access private - */ - var $tokenization; - - /** - * Default Constructor. - * - * @return \phpseclib\File\ANSI - * @access public - */ - function __construct() - { - $attr_cell = new \stdClass(); - $attr_cell->bold = false; - $attr_cell->underline = false; - $attr_cell->blink = false; - $attr_cell->background = 'black'; - $attr_cell->foreground = 'white'; - $attr_cell->reverse = false; - $this->base_attr_cell = clone $attr_cell; - $this->attr_cell = clone $attr_cell; - - $this->setHistory(200); - $this->setDimensions(80, 24); - } - - /** - * Set terminal width and height - * - * Resets the screen as well - * - * @param int $x - * @param int $y - * @access public - */ - function setDimensions($x, $y) - { - $this->max_x = $x - 1; - $this->max_y = $y - 1; - $this->x = $this->y = 0; - $this->history = $this->history_attrs = array(); - $this->attr_row = array_fill(0, $this->max_x + 2, $this->base_attr_cell); - $this->screen = array_fill(0, $this->max_y + 1, ''); - $this->attrs = array_fill(0, $this->max_y + 1, $this->attr_row); - $this->ansi = ''; - } - - /** - * Set the number of lines that should be logged past the terminal height - * - * @param int $x - * @param int $y - * @access public - */ - function setHistory($history) - { - $this->max_history = $history; - } - - /** - * Load a string - * - * @param string $source - * @access public - */ - function loadString($source) - { - $this->setDimensions($this->max_x + 1, $this->max_y + 1); - $this->appendString($source); - } - - /** - * Appdend a string - * - * @param string $source - * @access public - */ - function appendString($source) - { - $this->tokenization = array(''); - for ($i = 0; $i < strlen($source); $i++) { - if (strlen($this->ansi)) { - $this->ansi.= $source[$i]; - $chr = ord($source[$i]); - // http://en.wikipedia.org/wiki/ANSI_escape_code#Sequence_elements - // single character CSI's not currently supported - switch (true) { - case $this->ansi == "\x1B=": - $this->ansi = ''; - continue 2; - case strlen($this->ansi) == 2 && $chr >= 64 && $chr <= 95 && $chr != ord('['): - case strlen($this->ansi) > 2 && $chr >= 64 && $chr <= 126: - break; - default: - continue 2; - } - $this->tokenization[] = $this->ansi; - $this->tokenization[] = ''; - // http://ascii-table.com/ansi-escape-sequences-vt-100.php - switch ($this->ansi) { - case "\x1B[H": // Move cursor to upper left corner - $this->old_x = $this->x; - $this->old_y = $this->y; - $this->x = $this->y = 0; - break; - case "\x1B[J": // Clear screen from cursor down - $this->history = array_merge($this->history, array_slice(array_splice($this->screen, $this->y + 1), 0, $this->old_y)); - $this->screen = array_merge($this->screen, array_fill($this->y, $this->max_y, '')); - - $this->history_attrs = array_merge($this->history_attrs, array_slice(array_splice($this->attrs, $this->y + 1), 0, $this->old_y)); - $this->attrs = array_merge($this->attrs, array_fill($this->y, $this->max_y, $this->attr_row)); - - if (count($this->history) == $this->max_history) { - array_shift($this->history); - array_shift($this->history_attrs); - } - case "\x1B[K": // Clear screen from cursor right - $this->screen[$this->y] = substr($this->screen[$this->y], 0, $this->x); - - array_splice($this->attrs[$this->y], $this->x + 1, $this->max_x - $this->x, array_fill($this->x, $this->max_x - $this->x - 1, $this->base_attr_cell)); - break; - case "\x1B[2K": // Clear entire line - $this->screen[$this->y] = str_repeat(' ', $this->x); - $this->attrs[$this->y] = $this->attr_row; - break; - case "\x1B[?1h": // set cursor key to application - case "\x1B[?25h": // show the cursor - case "\x1B(B": // set united states g0 character set - break; - case "\x1BE": // Move to next line - $this->_newLine(); - $this->x = 0; - break; - default: - switch (true) { - case preg_match('#\x1B\[(\d+)B#', $this->ansi, $match): // Move cursor down n lines - $this->old_y = $this->y; - $this->y+= $match[1]; - break; - case preg_match('#\x1B\[(\d+);(\d+)H#', $this->ansi, $match): // Move cursor to screen location v,h - $this->old_x = $this->x; - $this->old_y = $this->y; - $this->x = $match[2] - 1; - $this->y = $match[1] - 1; - break; - case preg_match('#\x1B\[(\d+)C#', $this->ansi, $match): // Move cursor right n lines - $this->old_x = $this->x; - $this->x+= $match[1]; - break; - case preg_match('#\x1B\[(\d+)D#', $this->ansi, $match): // Move cursor left n lines - $this->old_x = $this->x; - $this->x-= $match[1]; - break; - case preg_match('#\x1B\[(\d+);(\d+)r#', $this->ansi, $match): // Set top and bottom lines of a window - break; - case preg_match('#\x1B\[(\d*(?:;\d*)*)m#', $this->ansi, $match): // character attributes - $attr_cell = &$this->attr_cell; - $mods = explode(';', $match[1]); - foreach ($mods as $mod) { - switch ($mod) { - case 0: // Turn off character attributes - $attr_cell = clone $this->base_attr_cell; - break; - case 1: // Turn bold mode on - $attr_cell->bold = true; - break; - case 4: // Turn underline mode on - $attr_cell->underline = true; - break; - case 5: // Turn blinking mode on - $attr_cell->blink = true; - break; - case 7: // Turn reverse video on - $attr_cell->reverse = !$attr_cell->reverse; - $temp = $attr_cell->background; - $attr_cell->background = $attr_cell->foreground; - $attr_cell->foreground = $temp; - break; - default: // set colors - //$front = $attr_cell->reverse ? &$attr_cell->background : &$attr_cell->foreground; - $front = &$attr_cell->{ $attr_cell->reverse ? 'background' : 'foreground' }; - //$back = $attr_cell->reverse ? &$attr_cell->foreground : &$attr_cell->background; - $back = &$attr_cell->{ $attr_cell->reverse ? 'foreground' : 'background' }; - switch ($mod) { - // @codingStandardsIgnoreStart - case 30: $front = 'black'; break; - case 31: $front = 'red'; break; - case 32: $front = 'green'; break; - case 33: $front = 'yellow'; break; - case 34: $front = 'blue'; break; - case 35: $front = 'magenta'; break; - case 36: $front = 'cyan'; break; - case 37: $front = 'white'; break; - - case 40: $back = 'black'; break; - case 41: $back = 'red'; break; - case 42: $back = 'green'; break; - case 43: $back = 'yellow'; break; - case 44: $back = 'blue'; break; - case 45: $back = 'magenta'; break; - case 46: $back = 'cyan'; break; - case 47: $back = 'white'; break; - // @codingStandardsIgnoreEnd - - default: - //user_error('Unsupported attribute: ' . $mod); - $this->ansi = ''; - break 2; - } - } - } - break; - default: - //user_error("{$this->ansi} is unsupported\r\n"); - } - } - $this->ansi = ''; - continue; - } - - $this->tokenization[count($this->tokenization) - 1].= $source[$i]; - switch ($source[$i]) { - case "\r": - $this->x = 0; - break; - case "\n": - $this->_newLine(); - break; - case "\x08": // backspace - if ($this->x) { - $this->x--; - $this->attrs[$this->y][$this->x] = clone $this->base_attr_cell; - $this->screen[$this->y] = substr_replace( - $this->screen[$this->y], - $source[$i], - $this->x, - 1 - ); - } - break; - case "\x0F": // shift - break; - case "\x1B": // start ANSI escape code - $this->tokenization[count($this->tokenization) - 1] = substr($this->tokenization[count($this->tokenization) - 1], 0, -1); - //if (!strlen($this->tokenization[count($this->tokenization) - 1])) { - // array_pop($this->tokenization); - //} - $this->ansi.= "\x1B"; - break; - default: - $this->attrs[$this->y][$this->x] = clone $this->attr_cell; - if ($this->x > strlen($this->screen[$this->y])) { - $this->screen[$this->y] = str_repeat(' ', $this->x); - } - $this->screen[$this->y] = substr_replace( - $this->screen[$this->y], - $source[$i], - $this->x, - 1 - ); - - if ($this->x > $this->max_x) { - $this->x = 0; - $this->y++; - } else { - $this->x++; - } - } - } - } - - /** - * Add a new line - * - * Also update the $this->screen and $this->history buffers - * - * @access private - */ - function _newLine() - { - //if ($this->y < $this->max_y) { - // $this->y++; - //} - - while ($this->y >= $this->max_y) { - $this->history = array_merge($this->history, array(array_shift($this->screen))); - $this->screen[] = ''; - - $this->history_attrs = array_merge($this->history_attrs, array(array_shift($this->attrs))); - $this->attrs[] = $this->attr_row; - - if (count($this->history) >= $this->max_history) { - array_shift($this->history); - array_shift($this->history_attrs); - } - - $this->y--; - } - $this->y++; - } - - /** - * Returns the current coordinate without preformating - * - * @access private - * @return string - */ - function _processCoordinate($last_attr, $cur_attr, $char) - { - $output = ''; - - if ($last_attr != $cur_attr) { - $close = $open = ''; - if ($last_attr->foreground != $cur_attr->foreground) { - if ($cur_attr->foreground != 'white') { - $open.= '<span style="color: ' . $cur_attr->foreground . '">'; - } - if ($last_attr->foreground != 'white') { - $close = '</span>' . $close; - } - } - if ($last_attr->background != $cur_attr->background) { - if ($cur_attr->background != 'black') { - $open.= '<span style="background: ' . $cur_attr->background . '">'; - } - if ($last_attr->background != 'black') { - $close = '</span>' . $close; - } - } - if ($last_attr->bold != $cur_attr->bold) { - if ($cur_attr->bold) { - $open.= '<b>'; - } else { - $close = '</b>' . $close; - } - } - if ($last_attr->underline != $cur_attr->underline) { - if ($cur_attr->underline) { - $open.= '<u>'; - } else { - $close = '</u>' . $close; - } - } - if ($last_attr->blink != $cur_attr->blink) { - if ($cur_attr->blink) { - $open.= '<blink>'; - } else { - $close = '</blink>' . $close; - } - } - $output.= $close . $open; - } - - $output.= htmlspecialchars($char); - - return $output; - } - - /** - * Returns the current screen without preformating - * - * @access private - * @return string - */ - function _getScreen() - { - $output = ''; - $last_attr = $this->base_attr_cell; - for ($i = 0; $i <= $this->max_y; $i++) { - for ($j = 0; $j <= $this->max_x; $j++) { - $cur_attr = $this->attrs[$i][$j]; - $output.= $this->_processCoordinate($last_attr, $cur_attr, isset($this->screen[$i][$j]) ? $this->screen[$i][$j] : ''); - $last_attr = $this->attrs[$i][$j]; - } - $output.= "\r\n"; - } - $output = substr($output, 0, -2); - // close any remaining open tags - $output.= $this->_processCoordinate($last_attr, $this->base_attr_cell, ''); - return rtrim($output); - } - - /** - * Returns the current screen - * - * @access public - * @return string - */ - function getScreen() - { - return '<pre width="' . ($this->max_x + 1) . '" style="color: white; background: black">' . $this->_getScreen() . '</pre>'; - } - - /** - * Returns the current screen and the x previous lines - * - * @access public - * @return string - */ - function getHistory() - { - $scrollback = ''; - $last_attr = $this->base_attr_cell; - for ($i = 0; $i < count($this->history); $i++) { - for ($j = 0; $j <= $this->max_x + 1; $j++) { - $cur_attr = $this->history_attrs[$i][$j]; - $scrollback.= $this->_processCoordinate($last_attr, $cur_attr, isset($this->history[$i][$j]) ? $this->history[$i][$j] : ''); - $last_attr = $this->history_attrs[$i][$j]; - } - $scrollback.= "\r\n"; - } - $base_attr_cell = $this->base_attr_cell; - $this->base_attr_cell = $last_attr; - $scrollback.= $this->_getScreen(); - $this->base_attr_cell = $base_attr_cell; - - return '<pre width="' . ($this->max_x + 1) . '" style="color: white; background: black">' . $scrollback . '</span></pre>'; - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/File/ASN1.php b/vendor/phpseclib/phpseclib/phpseclib/File/ASN1.php deleted file mode 100755 index 9405dcf68b640679c668939139e45a09ae3d8c6b..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/File/ASN1.php +++ /dev/null @@ -1,1308 +0,0 @@ -<?php - -/** - * Pure-PHP ASN.1 Parser - * - * PHP version 5 - * - * ASN.1 provides the semantics for data encoded using various schemes. The most commonly - * utilized scheme is DER or the "Distinguished Encoding Rules". PEM's are base64 encoded - * DER blobs. - * - * \phpseclib\File\ASN1 decodes and encodes DER formatted messages and places them in a semantic context. - * - * Uses the 1988 ASN.1 syntax. - * - * @category File - * @package ASN1 - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2012 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\File; - -use phpseclib\File\ASN1\Element; -use phpseclib\Math\BigInteger; - -/** - * Pure-PHP ASN.1 Parser - * - * @package ASN1 - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class ASN1 -{ - /**#@+ - * Tag Classes - * - * @access private - * @link http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#page=12 - */ - const CLASS_UNIVERSAL = 0; - const CLASS_APPLICATION = 1; - const CLASS_CONTEXT_SPECIFIC = 2; - const CLASS_PRIVATE = 3; - /**#@-*/ - - /**#@+ - * Tag Classes - * - * @access private - * @link http://www.obj-sys.com/asn1tutorial/node124.html - */ - const TYPE_BOOLEAN = 1; - const TYPE_INTEGER = 2; - const TYPE_BIT_STRING = 3; - const TYPE_OCTET_STRING = 4; - const TYPE_NULL = 5; - const TYPE_OBJECT_IDENTIFIER = 6; - //const TYPE_OBJECT_DESCRIPTOR = 7; - //const TYPE_INSTANCE_OF = 8; // EXTERNAL - const TYPE_REAL = 9; - const TYPE_ENUMERATED = 10; - //const TYPE_EMBEDDED = 11; - const TYPE_UTF8_STRING = 12; - //const TYPE_RELATIVE_OID = 13; - const TYPE_SEQUENCE = 16; // SEQUENCE OF - const TYPE_SET = 17; // SET OF - /**#@-*/ - /**#@+ - * More Tag Classes - * - * @access private - * @link http://www.obj-sys.com/asn1tutorial/node10.html - */ - const TYPE_NUMERIC_STRING = 18; - const TYPE_PRINTABLE_STRING = 19; - const TYPE_TELETEX_STRING = 20; // T61String - const TYPE_VIDEOTEX_STRING = 21; - const TYPE_IA5_STRING = 22; - const TYPE_UTC_TIME = 23; - const TYPE_GENERALIZED_TIME = 24; - const TYPE_GRAPHIC_STRING = 25; - const TYPE_VISIBLE_STRING = 26; // ISO646String - const TYPE_GENERAL_STRING = 27; - const TYPE_UNIVERSAL_STRING = 28; - //const TYPE_CHARACTER_STRING = 29; - const TYPE_BMP_STRING = 30; - /**#@-*/ - - /**#@+ - * Tag Aliases - * - * These tags are kinda place holders for other tags. - * - * @access private - */ - const TYPE_CHOICE = -1; - const TYPE_ANY = -2; - /**#@-*/ - - /** - * ASN.1 object identifier - * - * @var array - * @access private - * @link http://en.wikipedia.org/wiki/Object_identifier - */ - var $oids = array(); - - /** - * Default date format - * - * @var string - * @access private - * @link http://php.net/class.datetime - */ - var $format = 'D, d M Y H:i:s O'; - - /** - * Default date format - * - * @var array - * @access private - * @see self::setTimeFormat() - * @see self::asn1map() - * @link http://php.net/class.datetime - */ - var $encoded; - - /** - * Filters - * - * If the mapping type is self::TYPE_ANY what do we actually encode it as? - * - * @var array - * @access private - * @see self::_encode_der() - */ - var $filters; - - /** - * Type mapping table for the ANY type. - * - * Structured or unknown types are mapped to a \phpseclib\File\ASN1\Element. - * Unambiguous types get the direct mapping (int/real/bool). - * Others are mapped as a choice, with an extra indexing level. - * - * @var array - * @access public - */ - var $ANYmap = array( - self::TYPE_BOOLEAN => true, - self::TYPE_INTEGER => true, - self::TYPE_BIT_STRING => 'bitString', - self::TYPE_OCTET_STRING => 'octetString', - self::TYPE_NULL => 'null', - self::TYPE_OBJECT_IDENTIFIER => 'objectIdentifier', - self::TYPE_REAL => true, - self::TYPE_ENUMERATED => 'enumerated', - self::TYPE_UTF8_STRING => 'utf8String', - self::TYPE_NUMERIC_STRING => 'numericString', - self::TYPE_PRINTABLE_STRING => 'printableString', - self::TYPE_TELETEX_STRING => 'teletexString', - self::TYPE_VIDEOTEX_STRING => 'videotexString', - self::TYPE_IA5_STRING => 'ia5String', - self::TYPE_UTC_TIME => 'utcTime', - self::TYPE_GENERALIZED_TIME => 'generalTime', - self::TYPE_GRAPHIC_STRING => 'graphicString', - self::TYPE_VISIBLE_STRING => 'visibleString', - self::TYPE_GENERAL_STRING => 'generalString', - self::TYPE_UNIVERSAL_STRING => 'universalString', - //self::TYPE_CHARACTER_STRING => 'characterString', - self::TYPE_BMP_STRING => 'bmpString' - ); - - /** - * String type to character size mapping table. - * - * Non-convertable types are absent from this table. - * size == 0 indicates variable length encoding. - * - * @var array - * @access public - */ - var $stringTypeSize = array( - self::TYPE_UTF8_STRING => 0, - self::TYPE_BMP_STRING => 2, - self::TYPE_UNIVERSAL_STRING => 4, - self::TYPE_PRINTABLE_STRING => 1, - self::TYPE_TELETEX_STRING => 1, - self::TYPE_IA5_STRING => 1, - self::TYPE_VISIBLE_STRING => 1, - ); - - /** - * Parse BER-encoding - * - * Serves a similar purpose to openssl's asn1parse - * - * @param string $encoded - * @return array - * @access public - */ - function decodeBER($encoded) - { - if ($encoded instanceof Element) { - $encoded = $encoded->element; - } - - $this->encoded = $encoded; - // encapsulate in an array for BC with the old decodeBER - return array($this->_decode_ber($encoded)); - } - - /** - * Parse BER-encoding (Helper function) - * - * Sometimes we want to get the BER encoding of a particular tag. $start lets us do that without having to reencode. - * $encoded is passed by reference for the recursive calls done for self::TYPE_BIT_STRING and - * self::TYPE_OCTET_STRING. In those cases, the indefinite length is used. - * - * @param string $encoded - * @param int $start - * @return array - * @access private - */ - function _decode_ber($encoded, $start = 0) - { - $current = array('start' => $start); - - $type = ord($this->_string_shift($encoded)); - $start++; - - $constructed = ($type >> 5) & 1; - - $tag = $type & 0x1F; - if ($tag == 0x1F) { - $tag = 0; - // process septets (since the eighth bit is ignored, it's not an octet) - do { - $loop = ord($encoded[0]) >> 7; - $tag <<= 7; - $tag |= ord($this->_string_shift($encoded)) & 0x7F; - $start++; - } while ($loop); - } - - // Length, as discussed in paragraph 8.1.3 of X.690-0207.pdf#page=13 - $length = ord($this->_string_shift($encoded)); - $start++; - if ($length == 0x80) { // indefinite length - // "[A sender shall] use the indefinite form (see 8.1.3.6) if the encoding is constructed and is not all - // immediately available." -- paragraph 8.1.3.2.c - $length = strlen($encoded); - } elseif ($length & 0x80) { // definite length, long form - // technically, the long form of the length can be represented by up to 126 octets (bytes), but we'll only - // support it up to four. - $length&= 0x7F; - $temp = $this->_string_shift($encoded, $length); - // tags of indefinte length don't really have a header length; this length includes the tag - $current+= array('headerlength' => $length + 2); - $start+= $length; - extract(unpack('Nlength', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4))); - } else { - $current+= array('headerlength' => 2); - } - - if ($length > strlen($encoded)) { - return false; - } - - $content = $this->_string_shift($encoded, $length); - - // at this point $length can be overwritten. it's only accurate for definite length things as is - - /* Class is UNIVERSAL, APPLICATION, PRIVATE, or CONTEXT-SPECIFIC. The UNIVERSAL class is restricted to the ASN.1 - built-in types. It defines an application-independent data type that must be distinguishable from all other - data types. The other three classes are user defined. The APPLICATION class distinguishes data types that - have a wide, scattered use within a particular presentation context. PRIVATE distinguishes data types within - a particular organization or country. CONTEXT-SPECIFIC distinguishes members of a sequence or set, the - alternatives of a CHOICE, or universally tagged set members. Only the class number appears in braces for this - data type; the term CONTEXT-SPECIFIC does not appear. - - -- http://www.obj-sys.com/asn1tutorial/node12.html */ - $class = ($type >> 6) & 3; - switch ($class) { - case self::CLASS_APPLICATION: - case self::CLASS_PRIVATE: - case self::CLASS_CONTEXT_SPECIFIC: - if (!$constructed) { - return array( - 'type' => $class, - 'constant' => $tag, - 'content' => $content, - 'length' => $length + $start - $current['start'] - ); - } - - $newcontent = array(); - $remainingLength = $length; - while ($remainingLength > 0) { - $temp = $this->_decode_ber($content, $start); - $length = $temp['length']; - // end-of-content octets - see paragraph 8.1.5 - if (substr($content, $length, 2) == "\0\0") { - $length+= 2; - $start+= $length; - $newcontent[] = $temp; - break; - } - $start+= $length; - $remainingLength-= $length; - $newcontent[] = $temp; - $this->_string_shift($content, $length); - } - - return array( - 'type' => $class, - 'constant' => $tag, - // the array encapsulation is for BC with the old format - 'content' => $newcontent, - // the only time when $content['headerlength'] isn't defined is when the length is indefinite. - // the absence of $content['headerlength'] is how we know if something is indefinite or not. - // technically, it could be defined to be 2 and then another indicator could be used but whatever. - 'length' => $start - $current['start'] - ) + $current; - } - - $current+= array('type' => $tag); - - // decode UNIVERSAL tags - switch ($tag) { - case self::TYPE_BOOLEAN: - // "The contents octets shall consist of a single octet." -- paragraph 8.2.1 - //if (strlen($content) != 1) { - // return false; - //} - $current['content'] = (bool) ord($content[0]); - break; - case self::TYPE_INTEGER: - case self::TYPE_ENUMERATED: - $current['content'] = new BigInteger($content, -256); - break; - case self::TYPE_REAL: // not currently supported - return false; - case self::TYPE_BIT_STRING: - // The initial octet shall encode, as an unsigned binary integer with bit 1 as the least significant bit, - // the number of unused bits in the final subsequent octet. The number shall be in the range zero to - // seven. - if (!$constructed) { - $current['content'] = $content; - } else { - $temp = $this->_decode_ber($content, $start); - $length-= strlen($content); - $last = count($temp) - 1; - for ($i = 0; $i < $last; $i++) { - // all subtags should be bit strings - //if ($temp[$i]['type'] != self::TYPE_BIT_STRING) { - // return false; - //} - $current['content'].= substr($temp[$i]['content'], 1); - } - // all subtags should be bit strings - //if ($temp[$last]['type'] != self::TYPE_BIT_STRING) { - // return false; - //} - $current['content'] = $temp[$last]['content'][0] . $current['content'] . substr($temp[$i]['content'], 1); - } - break; - case self::TYPE_OCTET_STRING: - if (!$constructed) { - $current['content'] = $content; - } else { - $current['content'] = ''; - $length = 0; - while (substr($content, 0, 2) != "\0\0") { - $temp = $this->_decode_ber($content, $length + $start); - $this->_string_shift($content, $temp['length']); - // all subtags should be octet strings - //if ($temp['type'] != self::TYPE_OCTET_STRING) { - // return false; - //} - $current['content'].= $temp['content']; - $length+= $temp['length']; - } - if (substr($content, 0, 2) == "\0\0") { - $length+= 2; // +2 for the EOC - } - } - break; - case self::TYPE_NULL: - // "The contents octets shall not contain any octets." -- paragraph 8.8.2 - //if (strlen($content)) { - // return false; - //} - break; - case self::TYPE_SEQUENCE: - case self::TYPE_SET: - $offset = 0; - $current['content'] = array(); - while (strlen($content)) { - // if indefinite length construction was used and we have an end-of-content string next - // see paragraphs 8.1.1.3, 8.1.3.2, 8.1.3.6, 8.1.5, and (for an example) 8.6.4.2 - if (!isset($current['headerlength']) && substr($content, 0, 2) == "\0\0") { - $length = $offset + 2; // +2 for the EOC - break 2; - } - $temp = $this->_decode_ber($content, $start + $offset); - $this->_string_shift($content, $temp['length']); - $current['content'][] = $temp; - $offset+= $temp['length']; - } - break; - case self::TYPE_OBJECT_IDENTIFIER: - $temp = ord($this->_string_shift($content)); - $current['content'] = sprintf('%d.%d', floor($temp / 40), $temp % 40); - $valuen = 0; - // process septets - while (strlen($content)) { - $temp = ord($this->_string_shift($content)); - $valuen <<= 7; - $valuen |= $temp & 0x7F; - if (~$temp & 0x80) { - $current['content'].= ".$valuen"; - $valuen = 0; - } - } - // the eighth bit of the last byte should not be 1 - //if ($temp >> 7) { - // return false; - //} - break; - /* Each character string type shall be encoded as if it had been declared: - [UNIVERSAL x] IMPLICIT OCTET STRING - - -- X.690-0207.pdf#page=23 (paragraph 8.21.3) - - Per that, we're not going to do any validation. If there are any illegal characters in the string, - we don't really care */ - case self::TYPE_NUMERIC_STRING: - // 0,1,2,3,4,5,6,7,8,9, and space - case self::TYPE_PRINTABLE_STRING: - // Upper and lower case letters, digits, space, apostrophe, left/right parenthesis, plus sign, comma, - // hyphen, full stop, solidus, colon, equal sign, question mark - case self::TYPE_TELETEX_STRING: - // The Teletex character set in CCITT's T61, space, and delete - // see http://en.wikipedia.org/wiki/Teletex#Character_sets - case self::TYPE_VIDEOTEX_STRING: - // The Videotex character set in CCITT's T.100 and T.101, space, and delete - case self::TYPE_VISIBLE_STRING: - // Printing character sets of international ASCII, and space - case self::TYPE_IA5_STRING: - // International Alphabet 5 (International ASCII) - case self::TYPE_GRAPHIC_STRING: - // All registered G sets, and space - case self::TYPE_GENERAL_STRING: - // All registered C and G sets, space and delete - case self::TYPE_UTF8_STRING: - // ???? - case self::TYPE_BMP_STRING: - $current['content'] = $content; - break; - case self::TYPE_UTC_TIME: - case self::TYPE_GENERALIZED_TIME: - $current['content'] = $this->_decodeTime($content, $tag); - default: - } - - $start+= $length; - - // ie. length is the length of the full TLV encoding - it's not just the length of the value - return $current + array('length' => $start - $current['start']); - } - - /** - * ASN.1 Map - * - * Provides an ASN.1 semantic mapping ($mapping) from a parsed BER-encoding to a human readable format. - * - * "Special" mappings may be applied on a per tag-name basis via $special. - * - * @param array $decoded - * @param array $mapping - * @param array $special - * @return array - * @access public - */ - function asn1map($decoded, $mapping, $special = array()) - { - if (isset($mapping['explicit']) && is_array($decoded['content'])) { - $decoded = $decoded['content'][0]; - } - - switch (true) { - case $mapping['type'] == self::TYPE_ANY: - $intype = $decoded['type']; - if (isset($decoded['constant']) || !isset($this->ANYmap[$intype]) || ($this->encoded[$decoded['start']] & 0x20)) { - return new Element(substr($this->encoded, $decoded['start'], $decoded['length'])); - } - $inmap = $this->ANYmap[$intype]; - if (is_string($inmap)) { - return array($inmap => $this->asn1map($decoded, array('type' => $intype) + $mapping, $special)); - } - break; - case $mapping['type'] == self::TYPE_CHOICE: - foreach ($mapping['children'] as $key => $option) { - switch (true) { - case isset($option['constant']) && $option['constant'] == $decoded['constant']: - case !isset($option['constant']) && $option['type'] == $decoded['type']: - $value = $this->asn1map($decoded, $option, $special); - break; - case !isset($option['constant']) && $option['type'] == self::TYPE_CHOICE: - $v = $this->asn1map($decoded, $option, $special); - if (isset($v)) { - $value = $v; - } - } - if (isset($value)) { - if (isset($special[$key])) { - $value = call_user_func($special[$key], $value); - } - return array($key => $value); - } - } - return null; - case isset($mapping['implicit']): - case isset($mapping['explicit']): - case $decoded['type'] == $mapping['type']: - break; - default: - // if $decoded['type'] and $mapping['type'] are both strings, but different types of strings, - // let it through - switch (true) { - case $decoded['type'] < 18: // self::TYPE_NUMERIC_STRING == 18 - case $decoded['type'] > 30: // self::TYPE_BMP_STRING == 30 - case $mapping['type'] < 18: - case $mapping['type'] > 30: - return null; - } - } - - if (isset($mapping['implicit'])) { - $decoded['type'] = $mapping['type']; - } - - switch ($decoded['type']) { - case self::TYPE_SEQUENCE: - $map = array(); - - // ignore the min and max - if (isset($mapping['min']) && isset($mapping['max'])) { - $child = $mapping['children']; - foreach ($decoded['content'] as $content) { - if (($map[] = $this->asn1map($content, $child, $special)) === null) { - return null; - } - } - - return $map; - } - - $n = count($decoded['content']); - $i = 0; - - foreach ($mapping['children'] as $key => $child) { - $maymatch = $i < $n; // Match only existing input. - if ($maymatch) { - $temp = $decoded['content'][$i]; - - if ($child['type'] != self::TYPE_CHOICE) { - // Get the mapping and input class & constant. - $childClass = $tempClass = self::CLASS_UNIVERSAL; - $constant = null; - if (isset($temp['constant'])) { - $tempClass = isset($temp['class']) ? $temp['class'] : self::CLASS_CONTEXT_SPECIFIC; - } - if (isset($child['class'])) { - $childClass = $child['class']; - $constant = $child['cast']; - } elseif (isset($child['constant'])) { - $childClass = self::CLASS_CONTEXT_SPECIFIC; - $constant = $child['constant']; - } - - if (isset($constant) && isset($temp['constant'])) { - // Can only match if constants and class match. - $maymatch = $constant == $temp['constant'] && $childClass == $tempClass; - } else { - // Can only match if no constant expected and type matches or is generic. - $maymatch = !isset($child['constant']) && array_search($child['type'], array($temp['type'], self::TYPE_ANY, self::TYPE_CHOICE)) !== false; - } - } - } - - if ($maymatch) { - // Attempt submapping. - $candidate = $this->asn1map($temp, $child, $special); - $maymatch = $candidate !== null; - } - - if ($maymatch) { - // Got the match: use it. - if (isset($special[$key])) { - $candidate = call_user_func($special[$key], $candidate); - } - $map[$key] = $candidate; - $i++; - } elseif (isset($child['default'])) { - $map[$key] = $child['default']; // Use default. - } elseif (!isset($child['optional'])) { - return null; // Syntax error. - } - } - - // Fail mapping if all input items have not been consumed. - return $i < $n ? null: $map; - - // the main diff between sets and sequences is the encapsulation of the foreach in another for loop - case self::TYPE_SET: - $map = array(); - - // ignore the min and max - if (isset($mapping['min']) && isset($mapping['max'])) { - $child = $mapping['children']; - foreach ($decoded['content'] as $content) { - if (($map[] = $this->asn1map($content, $child, $special)) === null) { - return null; - } - } - - return $map; - } - - for ($i = 0; $i < count($decoded['content']); $i++) { - $temp = $decoded['content'][$i]; - $tempClass = self::CLASS_UNIVERSAL; - if (isset($temp['constant'])) { - $tempClass = isset($temp['class']) ? $temp['class'] : self::CLASS_CONTEXT_SPECIFIC; - } - - foreach ($mapping['children'] as $key => $child) { - if (isset($map[$key])) { - continue; - } - $maymatch = true; - if ($child['type'] != self::TYPE_CHOICE) { - $childClass = self::CLASS_UNIVERSAL; - $constant = null; - if (isset($child['class'])) { - $childClass = $child['class']; - $constant = $child['cast']; - } elseif (isset($child['constant'])) { - $childClass = self::CLASS_CONTEXT_SPECIFIC; - $constant = $child['constant']; - } - - if (isset($constant) && isset($temp['constant'])) { - // Can only match if constants and class match. - $maymatch = $constant == $temp['constant'] && $childClass == $tempClass; - } else { - // Can only match if no constant expected and type matches or is generic. - $maymatch = !isset($child['constant']) && array_search($child['type'], array($temp['type'], self::TYPE_ANY, self::TYPE_CHOICE)) !== false; - } - } - - if ($maymatch) { - // Attempt submapping. - $candidate = $this->asn1map($temp, $child, $special); - $maymatch = $candidate !== null; - } - - if (!$maymatch) { - break; - } - - // Got the match: use it. - if (isset($special[$key])) { - $candidate = call_user_func($special[$key], $candidate); - } - $map[$key] = $candidate; - break; - } - } - - foreach ($mapping['children'] as $key => $child) { - if (!isset($map[$key])) { - if (isset($child['default'])) { - $map[$key] = $child['default']; - } elseif (!isset($child['optional'])) { - return null; - } - } - } - return $map; - case self::TYPE_OBJECT_IDENTIFIER: - return isset($this->oids[$decoded['content']]) ? $this->oids[$decoded['content']] : $decoded['content']; - case self::TYPE_UTC_TIME: - case self::TYPE_GENERALIZED_TIME: - if (isset($mapping['implicit'])) { - $decoded['content'] = $this->_decodeTime($decoded['content'], $decoded['type']); - } - return @date($this->format, $decoded['content']); - case self::TYPE_BIT_STRING: - if (isset($mapping['mapping'])) { - $offset = ord($decoded['content'][0]); - $size = (strlen($decoded['content']) - 1) * 8 - $offset; - /* - From X.680-0207.pdf#page=46 (21.7): - - "When a "NamedBitList" is used in defining a bitstring type ASN.1 encoding rules are free to add (or remove) - arbitrarily any trailing 0 bits to (or from) values that are being encoded or decoded. Application designers should - therefore ensure that different semantics are not associated with such values which differ only in the number of trailing - 0 bits." - */ - $bits = count($mapping['mapping']) == $size ? array() : array_fill(0, count($mapping['mapping']) - $size, false); - for ($i = strlen($decoded['content']) - 1; $i > 0; $i--) { - $current = ord($decoded['content'][$i]); - for ($j = $offset; $j < 8; $j++) { - $bits[] = (bool) ($current & (1 << $j)); - } - $offset = 0; - } - $values = array(); - $map = array_reverse($mapping['mapping']); - foreach ($map as $i => $value) { - if ($bits[$i]) { - $values[] = $value; - } - } - return $values; - } - case self::TYPE_OCTET_STRING: - return base64_encode($decoded['content']); - case self::TYPE_NULL: - return ''; - case self::TYPE_BOOLEAN: - return $decoded['content']; - case self::TYPE_NUMERIC_STRING: - case self::TYPE_PRINTABLE_STRING: - case self::TYPE_TELETEX_STRING: - case self::TYPE_VIDEOTEX_STRING: - case self::TYPE_IA5_STRING: - case self::TYPE_GRAPHIC_STRING: - case self::TYPE_VISIBLE_STRING: - case self::TYPE_GENERAL_STRING: - case self::TYPE_UNIVERSAL_STRING: - case self::TYPE_UTF8_STRING: - case self::TYPE_BMP_STRING: - return $decoded['content']; - case self::TYPE_INTEGER: - case self::TYPE_ENUMERATED: - $temp = $decoded['content']; - if (isset($mapping['implicit'])) { - $temp = new BigInteger($decoded['content'], -256); - } - if (isset($mapping['mapping'])) { - $temp = (int) $temp->toString(); - return isset($mapping['mapping'][$temp]) ? - $mapping['mapping'][$temp] : - false; - } - return $temp; - } - } - - /** - * ASN.1 Encode - * - * DER-encodes an ASN.1 semantic mapping ($mapping). Some libraries would probably call this function - * an ASN.1 compiler. - * - * "Special" mappings can be applied via $special. - * - * @param string $source - * @param string $mapping - * @param int $idx - * @return string - * @access public - */ - function encodeDER($source, $mapping, $special = array()) - { - $this->location = array(); - return $this->_encode_der($source, $mapping, null, $special); - } - - /** - * ASN.1 Encode (Helper function) - * - * @param string $source - * @param string $mapping - * @param int $idx - * @return string - * @access private - */ - function _encode_der($source, $mapping, $idx = null, $special = array()) - { - if ($source instanceof Element) { - return $source->element; - } - - // do not encode (implicitly optional) fields with value set to default - if (isset($mapping['default']) && $source === $mapping['default']) { - return ''; - } - - if (isset($idx)) { - if (isset($special[$idx])) { - $source = call_user_func($special[$idx], $source); - } - $this->location[] = $idx; - } - - $tag = $mapping['type']; - - switch ($tag) { - case self::TYPE_SET: // Children order is not important, thus process in sequence. - case self::TYPE_SEQUENCE: - $tag|= 0x20; // set the constructed bit - $value = ''; - - // ignore the min and max - if (isset($mapping['min']) && isset($mapping['max'])) { - $child = $mapping['children']; - - foreach ($source as $content) { - $temp = $this->_encode_der($content, $child, null, $special); - if ($temp === false) { - return false; - } - $value.= $temp; - } - break; - } - - foreach ($mapping['children'] as $key => $child) { - if (!array_key_exists($key, $source)) { - if (!isset($child['optional'])) { - return false; - } - continue; - } - - $temp = $this->_encode_der($source[$key], $child, $key, $special); - if ($temp === false) { - return false; - } - - // An empty child encoding means it has been optimized out. - // Else we should have at least one tag byte. - if ($temp === '') { - continue; - } - - // if isset($child['constant']) is true then isset($child['optional']) should be true as well - if (isset($child['constant'])) { - /* - From X.680-0207.pdf#page=58 (30.6): - - "The tagging construction specifies explicit tagging if any of the following holds: - ... - c) the "Tag Type" alternative is used and the value of "TagDefault" for the module is IMPLICIT TAGS or - AUTOMATIC TAGS, but the type defined by "Type" is an untagged choice type, an untagged open type, or - an untagged "DummyReference" (see ITU-T Rec. X.683 | ISO/IEC 8824-4, 8.3)." - */ - if (isset($child['explicit']) || $child['type'] == self::TYPE_CHOICE) { - $subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | $child['constant']); - $temp = $subtag . $this->_encodeLength(strlen($temp)) . $temp; - } else { - $subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | (ord($temp[0]) & 0x20) | $child['constant']); - $temp = $subtag . substr($temp, 1); - } - } - $value.= $temp; - } - break; - case self::TYPE_CHOICE: - $temp = false; - - foreach ($mapping['children'] as $key => $child) { - if (!isset($source[$key])) { - continue; - } - - $temp = $this->_encode_der($source[$key], $child, $key, $special); - if ($temp === false) { - return false; - } - - // An empty child encoding means it has been optimized out. - // Else we should have at least one tag byte. - if ($temp === '') { - continue; - } - - $tag = ord($temp[0]); - - // if isset($child['constant']) is true then isset($child['optional']) should be true as well - if (isset($child['constant'])) { - if (isset($child['explicit']) || $child['type'] == self::TYPE_CHOICE) { - $subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | $child['constant']); - $temp = $subtag . $this->_encodeLength(strlen($temp)) . $temp; - } else { - $subtag = chr((self::CLASS_CONTEXT_SPECIFIC << 6) | (ord($temp[0]) & 0x20) | $child['constant']); - $temp = $subtag . substr($temp, 1); - } - } - } - - if (isset($idx)) { - array_pop($this->location); - } - - if ($temp && isset($mapping['cast'])) { - $temp[0] = chr(($mapping['class'] << 6) | ($tag & 0x20) | $mapping['cast']); - } - - return $temp; - case self::TYPE_INTEGER: - case self::TYPE_ENUMERATED: - if (!isset($mapping['mapping'])) { - if (is_numeric($source)) { - $source = new BigInteger($source); - } - $value = $source->toBytes(true); - } else { - $value = array_search($source, $mapping['mapping']); - if ($value === false) { - return false; - } - $value = new BigInteger($value); - $value = $value->toBytes(true); - } - if (!strlen($value)) { - $value = chr(0); - } - break; - case self::TYPE_UTC_TIME: - case self::TYPE_GENERALIZED_TIME: - $format = $mapping['type'] == self::TYPE_UTC_TIME ? 'y' : 'Y'; - $format.= 'mdHis'; - $value = @gmdate($format, strtotime($source)) . 'Z'; - break; - case self::TYPE_BIT_STRING: - if (isset($mapping['mapping'])) { - $bits = array_fill(0, count($mapping['mapping']), 0); - $size = 0; - for ($i = 0; $i < count($mapping['mapping']); $i++) { - if (in_array($mapping['mapping'][$i], $source)) { - $bits[$i] = 1; - $size = $i; - } - } - - if (isset($mapping['min']) && $mapping['min'] >= 1 && $size < $mapping['min']) { - $size = $mapping['min'] - 1; - } - - $offset = 8 - (($size + 1) & 7); - $offset = $offset !== 8 ? $offset : 0; - - $value = chr($offset); - - for ($i = $size + 1; $i < count($mapping['mapping']); $i++) { - unset($bits[$i]); - } - - $bits = implode('', array_pad($bits, $size + $offset + 1, 0)); - $bytes = explode(' ', rtrim(chunk_split($bits, 8, ' '))); - foreach ($bytes as $byte) { - $value.= chr(bindec($byte)); - } - - break; - } - case self::TYPE_OCTET_STRING: - /* The initial octet shall encode, as an unsigned binary integer with bit 1 as the least significant bit, - the number of unused bits in the final subsequent octet. The number shall be in the range zero to seven. - - -- http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#page=16 */ - $value = base64_decode($source); - break; - case self::TYPE_OBJECT_IDENTIFIER: - $oid = preg_match('#(?:\d+\.)+#', $source) ? $source : array_search($source, $this->oids); - if ($oid === false) { - user_error('Invalid OID'); - return false; - } - $value = ''; - $parts = explode('.', $oid); - $value = chr(40 * $parts[0] + $parts[1]); - for ($i = 2; $i < count($parts); $i++) { - $temp = ''; - if (!$parts[$i]) { - $temp = "\0"; - } else { - while ($parts[$i]) { - $temp = chr(0x80 | ($parts[$i] & 0x7F)) . $temp; - $parts[$i] >>= 7; - } - $temp[strlen($temp) - 1] = $temp[strlen($temp) - 1] & chr(0x7F); - } - $value.= $temp; - } - break; - case self::TYPE_ANY: - $loc = $this->location; - if (isset($idx)) { - array_pop($this->location); - } - - switch (true) { - case !isset($source): - return $this->_encode_der(null, array('type' => self::TYPE_NULL) + $mapping, null, $special); - case is_int($source): - case $source instanceof BigInteger: - return $this->_encode_der($source, array('type' => self::TYPE_INTEGER) + $mapping, null, $special); - case is_float($source): - return $this->_encode_der($source, array('type' => self::TYPE_REAL) + $mapping, null, $special); - case is_bool($source): - return $this->_encode_der($source, array('type' => self::TYPE_BOOLEAN) + $mapping, null, $special); - case is_array($source) && count($source) == 1: - $typename = implode('', array_keys($source)); - $outtype = array_search($typename, $this->ANYmap, true); - if ($outtype !== false) { - return $this->_encode_der($source[$typename], array('type' => $outtype) + $mapping, null, $special); - } - } - - $filters = $this->filters; - foreach ($loc as $part) { - if (!isset($filters[$part])) { - $filters = false; - break; - } - $filters = $filters[$part]; - } - if ($filters === false) { - user_error('No filters defined for ' . implode('/', $loc)); - return false; - } - return $this->_encode_der($source, $filters + $mapping, null, $special); - case self::TYPE_NULL: - $value = ''; - break; - case self::TYPE_NUMERIC_STRING: - case self::TYPE_TELETEX_STRING: - case self::TYPE_PRINTABLE_STRING: - case self::TYPE_UNIVERSAL_STRING: - case self::TYPE_UTF8_STRING: - case self::TYPE_BMP_STRING: - case self::TYPE_IA5_STRING: - case self::TYPE_VISIBLE_STRING: - case self::TYPE_VIDEOTEX_STRING: - case self::TYPE_GRAPHIC_STRING: - case self::TYPE_GENERAL_STRING: - $value = $source; - break; - case self::TYPE_BOOLEAN: - $value = $source ? "\xFF" : "\x00"; - break; - default: - user_error('Mapping provides no type definition for ' . implode('/', $this->location)); - return false; - } - - if (isset($idx)) { - array_pop($this->location); - } - - if (isset($mapping['cast'])) { - if (isset($mapping['explicit']) || $mapping['type'] == self::TYPE_CHOICE) { - $value = chr($tag) . $this->_encodeLength(strlen($value)) . $value; - $tag = ($mapping['class'] << 6) | 0x20 | $mapping['cast']; - } else { - $tag = ($mapping['class'] << 6) | (ord($temp[0]) & 0x20) | $mapping['cast']; - } - } - - return chr($tag) . $this->_encodeLength(strlen($value)) . $value; - } - - /** - * DER-encode the length - * - * DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See - * {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information. - * - * @access private - * @param int $length - * @return string - */ - function _encodeLength($length) - { - if ($length <= 0x7F) { - return chr($length); - } - - $temp = ltrim(pack('N', $length), chr(0)); - return pack('Ca*', 0x80 | strlen($temp), $temp); - } - - /** - * BER-decode the time - * - * Called by _decode_ber() and in the case of implicit tags asn1map(). - * - * @access private - * @param string $content - * @param int $tag - * @return string - */ - function _decodeTime($content, $tag) - { - /* UTCTime: - http://tools.ietf.org/html/rfc5280#section-4.1.2.5.1 - http://www.obj-sys.com/asn1tutorial/node15.html - - GeneralizedTime: - http://tools.ietf.org/html/rfc5280#section-4.1.2.5.2 - http://www.obj-sys.com/asn1tutorial/node14.html */ - - $pattern = $tag == self::TYPE_UTC_TIME ? - '#(..)(..)(..)(..)(..)(..)(.*)#' : - '#(....)(..)(..)(..)(..)(..).*([Z+-].*)$#'; - - preg_match($pattern, $content, $matches); - - list(, $year, $month, $day, $hour, $minute, $second, $timezone) = $matches; - - if ($tag == self::TYPE_UTC_TIME) { - $year = $year >= 50 ? "19$year" : "20$year"; - } - - if ($timezone == 'Z') { - $mktime = 'gmmktime'; - $timezone = 0; - } elseif (preg_match('#([+-])(\d\d)(\d\d)#', $timezone, $matches)) { - $mktime = 'gmmktime'; - $timezone = 60 * $matches[3] + 3600 * $matches[2]; - if ($matches[1] == '-') { - $timezone = -$timezone; - } - } else { - $mktime = 'mktime'; - $timezone = 0; - } - - return @$mktime($hour, $minute, $second, $month, $day, $year) + $timezone; - } - - /** - * Set the time format - * - * Sets the time / date format for asn1map(). - * - * @access public - * @param string $format - */ - function setTimeFormat($format) - { - $this->format = $format; - } - - /** - * Load OIDs - * - * Load the relevant OIDs for a particular ASN.1 semantic mapping. - * - * @access public - * @param array $oids - */ - function loadOIDs($oids) - { - $this->oids = $oids; - } - - /** - * Load filters - * - * See \phpseclib\File\X509, etc, for an example. - * - * @access public - * @param array $filters - */ - function loadFilters($filters) - { - $this->filters = $filters; - } - - /** - * String Shift - * - * Inspired by array_shift - * - * @param string $string - * @param int $index - * @return string - * @access private - */ - function _string_shift(&$string, $index = 1) - { - $substr = substr($string, 0, $index); - $string = substr($string, $index); - return $substr; - } - - /** - * String type conversion - * - * This is a lazy conversion, dealing only with character size. - * No real conversion table is used. - * - * @param string $in - * @param int $from - * @param int $to - * @return string - * @access public - */ - function convert($in, $from = self::TYPE_UTF8_STRING, $to = self::TYPE_UTF8_STRING) - { - if (!isset($this->stringTypeSize[$from]) || !isset($this->stringTypeSize[$to])) { - return false; - } - $insize = $this->stringTypeSize[$from]; - $outsize = $this->stringTypeSize[$to]; - $inlength = strlen($in); - $out = ''; - - for ($i = 0; $i < $inlength;) { - if ($inlength - $i < $insize) { - return false; - } - - // Get an input character as a 32-bit value. - $c = ord($in[$i++]); - switch (true) { - case $insize == 4: - $c = ($c << 8) | ord($in[$i++]); - $c = ($c << 8) | ord($in[$i++]); - case $insize == 2: - $c = ($c << 8) | ord($in[$i++]); - case $insize == 1: - break; - case ($c & 0x80) == 0x00: - break; - case ($c & 0x40) == 0x00: - return false; - default: - $bit = 6; - do { - if ($bit > 25 || $i >= $inlength || (ord($in[$i]) & 0xC0) != 0x80) { - return false; - } - $c = ($c << 6) | (ord($in[$i++]) & 0x3F); - $bit += 5; - $mask = 1 << $bit; - } while ($c & $bit); - $c &= $mask - 1; - break; - } - - // Convert and append the character to output string. - $v = ''; - switch (true) { - case $outsize == 4: - $v .= chr($c & 0xFF); - $c >>= 8; - $v .= chr($c & 0xFF); - $c >>= 8; - case $outsize == 2: - $v .= chr($c & 0xFF); - $c >>= 8; - case $outsize == 1: - $v .= chr($c & 0xFF); - $c >>= 8; - if ($c) { - return false; - } - break; - case ($c & 0x80000000) != 0: - return false; - case $c >= 0x04000000: - $v .= chr(0x80 | ($c & 0x3F)); - $c = ($c >> 6) | 0x04000000; - case $c >= 0x00200000: - $v .= chr(0x80 | ($c & 0x3F)); - $c = ($c >> 6) | 0x00200000; - case $c >= 0x00010000: - $v .= chr(0x80 | ($c & 0x3F)); - $c = ($c >> 6) | 0x00010000; - case $c >= 0x00000800: - $v .= chr(0x80 | ($c & 0x3F)); - $c = ($c >> 6) | 0x00000800; - case $c >= 0x00000080: - $v .= chr(0x80 | ($c & 0x3F)); - $c = ($c >> 6) | 0x000000C0; - default: - $v .= chr($c); - break; - } - $out .= strrev($v); - } - return $out; - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Element.php b/vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Element.php deleted file mode 100755 index 68246e2b5cbd11ad9de8ae35dc49f54feaa273ef..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Element.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php -/** - * Pure-PHP ASN.1 Parser - * - * PHP version 5 - * - * @category File - * @package ASN1 - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2012 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\File\ASN1; - -/** - * ASN.1 Element - * - * Bypass normal encoding rules in phpseclib\File\ASN1::encodeDER() - * - * @package ASN1 - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class Element -{ - /** - * Raw element value - * - * @var string - * @access private - */ - var $element; - - /** - * Constructor - * - * @param string $encoded - * @return \phpseclib\File\ASN1\Element - * @access public - */ - function __construct($encoded) - { - $this->element = $encoded; - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/File/X509.php b/vendor/phpseclib/phpseclib/phpseclib/File/X509.php deleted file mode 100755 index 169a9ed93f4b2d5d3f72fbe391e92766b50543d3..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/File/X509.php +++ /dev/null @@ -1,4617 +0,0 @@ -<?php - -/** - * Pure-PHP X.509 Parser - * - * PHP version 5 - * - * Encode and decode X.509 certificates. - * - * The extensions are from {@link http://tools.ietf.org/html/rfc5280 RFC5280} and - * {@link http://web.archive.org/web/19961027104704/http://www3.netscape.com/eng/security/cert-exts.html Netscape Certificate Extensions}. - * - * Note that loading an X.509 certificate and resaving it may invalidate the signature. The reason being that the signature is based on a - * portion of the certificate that contains optional parameters with default values. ie. if the parameter isn't there the default value is - * used. Problem is, if the parameter is there and it just so happens to have the default value there are two ways that that parameter can - * be encoded. It can be encoded explicitly or left out all together. This would effect the signature value and thus may invalidate the - * the certificate all together unless the certificate is re-signed. - * - * @category File - * @package X509 - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2012 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\File; - -use phpseclib\Crypt\Hash; -use phpseclib\Crypt\RSA; -use phpseclib\Crypt\Random; -use phpseclib\File\ASN1; -use phpseclib\File\ASN1\Element; -use phpseclib\Math\BigInteger; - -/** - * Pure-PHP X.509 Parser - * - * @package X509 - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class X509 -{ - /** - * Flag to only accept signatures signed by certificate authorities - * - * Not really used anymore but retained all the same to suppress E_NOTICEs from old installs - * - * @access public - */ - const VALIDATE_SIGNATURE_BY_CA = 1; - - /**#@+ - * @access public - * @see \phpseclib\File\X509::getDN() - */ - /** - * Return internal array representation - */ - const DN_ARRAY = 0; - /** - * Return string - */ - const DN_STRING = 1; - /** - * Return ASN.1 name string - */ - const DN_ASN1 = 2; - /** - * Return OpenSSL compatible array - */ - const DN_OPENSSL = 3; - /** - * Return canonical ASN.1 RDNs string - */ - const DN_CANON = 4; - /** - * Return name hash for file indexing - */ - const DN_HASH = 5; - /**#@-*/ - - /**#@+ - * @access public - * @see \phpseclib\File\X509::saveX509() - * @see \phpseclib\File\X509::saveCSR() - * @see \phpseclib\File\X509::saveCRL() - */ - /** - * Save as PEM - * - * ie. a base64-encoded PEM with a header and a footer - */ - const FORMAT_PEM = 0; - /** - * Save as DER - */ - const FORMAT_DER = 1; - /** - * Save as a SPKAC - * - * Only works on CSRs. Not currently supported. - */ - const FORMAT_SPKAC = 2; - /** - * Auto-detect the format - * - * Used only by the load*() functions - */ - const FORMAT_AUTO_DETECT = 3; - /**#@-*/ - - /** - * Attribute value disposition. - * If disposition is >= 0, this is the index of the target value. - */ - const ATTR_ALL = -1; // All attribute values (array). - const ATTR_APPEND = -2; // Add a value. - const ATTR_REPLACE = -3; // Clear first, then add a value. - - /** - * ASN.1 syntax for X.509 certificates - * - * @var array - * @access private - */ - var $Certificate; - - /**#@+ - * ASN.1 syntax for various extensions - * - * @access private - */ - var $DirectoryString; - var $PKCS9String; - var $AttributeValue; - var $Extensions; - var $KeyUsage; - var $ExtKeyUsageSyntax; - var $BasicConstraints; - var $KeyIdentifier; - var $CRLDistributionPoints; - var $AuthorityKeyIdentifier; - var $CertificatePolicies; - var $AuthorityInfoAccessSyntax; - var $SubjectAltName; - var $PrivateKeyUsagePeriod; - var $IssuerAltName; - var $PolicyMappings; - var $NameConstraints; - - var $CPSuri; - var $UserNotice; - - var $netscape_cert_type; - var $netscape_comment; - var $netscape_ca_policy_url; - - var $Name; - var $RelativeDistinguishedName; - var $CRLNumber; - var $CRLReason; - var $IssuingDistributionPoint; - var $InvalidityDate; - var $CertificateIssuer; - var $HoldInstructionCode; - var $SignedPublicKeyAndChallenge; - /**#@-*/ - - /** - * ASN.1 syntax for Certificate Signing Requests (RFC2986) - * - * @var array - * @access private - */ - var $CertificationRequest; - - /** - * ASN.1 syntax for Certificate Revocation Lists (RFC5280) - * - * @var array - * @access private - */ - var $CertificateList; - - /** - * Distinguished Name - * - * @var array - * @access private - */ - var $dn; - - /** - * Public key - * - * @var string - * @access private - */ - var $publicKey; - - /** - * Private key - * - * @var string - * @access private - */ - var $privateKey; - - /** - * Object identifiers for X.509 certificates - * - * @var array - * @access private - * @link http://en.wikipedia.org/wiki/Object_identifier - */ - var $oids; - - /** - * The certificate authorities - * - * @var array - * @access private - */ - var $CAs; - - /** - * The currently loaded certificate - * - * @var array - * @access private - */ - var $currentCert; - - /** - * The signature subject - * - * There's no guarantee \phpseclib\File\X509 is going to reencode an X.509 cert in the same way it was originally - * encoded so we take save the portion of the original cert that the signature would have made for. - * - * @var string - * @access private - */ - var $signatureSubject; - - /** - * Certificate Start Date - * - * @var string - * @access private - */ - var $startDate; - - /** - * Certificate End Date - * - * @var string - * @access private - */ - var $endDate; - - /** - * Serial Number - * - * @var string - * @access private - */ - var $serialNumber; - - /** - * Key Identifier - * - * See {@link http://tools.ietf.org/html/rfc5280#section-4.2.1.1 RFC5280#section-4.2.1.1} and - * {@link http://tools.ietf.org/html/rfc5280#section-4.2.1.2 RFC5280#section-4.2.1.2}. - * - * @var string - * @access private - */ - var $currentKeyIdentifier; - - /** - * CA Flag - * - * @var bool - * @access private - */ - var $caFlag = false; - - /** - * SPKAC Challenge - * - * @var string - * @access private - */ - var $challenge; - - /** - * Default Constructor. - * - * @return \phpseclib\File\X509 - * @access public - */ - function __construct() - { - // Explicitly Tagged Module, 1988 Syntax - // http://tools.ietf.org/html/rfc5280#appendix-A.1 - - $this->DirectoryString = array( - 'type' => ASN1::TYPE_CHOICE, - 'children' => array( - 'teletexString' => array('type' => ASN1::TYPE_TELETEX_STRING), - 'printableString' => array('type' => ASN1::TYPE_PRINTABLE_STRING), - 'universalString' => array('type' => ASN1::TYPE_UNIVERSAL_STRING), - 'utf8String' => array('type' => ASN1::TYPE_UTF8_STRING), - 'bmpString' => array('type' => ASN1::TYPE_BMP_STRING) - ) - ); - - $this->PKCS9String = array( - 'type' => ASN1::TYPE_CHOICE, - 'children' => array( - 'ia5String' => array('type' => ASN1::TYPE_IA5_STRING), - 'directoryString' => $this->DirectoryString - ) - ); - - $this->AttributeValue = array('type' => ASN1::TYPE_ANY); - - $AttributeType = array('type' => ASN1::TYPE_OBJECT_IDENTIFIER); - - $AttributeTypeAndValue = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'type' => $AttributeType, - 'value'=> $this->AttributeValue - ) - ); - - /* - In practice, RDNs containing multiple name-value pairs (called "multivalued RDNs") are rare, - but they can be useful at times when either there is no unique attribute in the entry or you - want to ensure that the entry's DN contains some useful identifying information. - - - https://www.opends.org/wiki/page/DefinitionRelativeDistinguishedName - */ - $this->RelativeDistinguishedName = array( - 'type' => ASN1::TYPE_SET, - 'min' => 1, - 'max' => -1, - 'children' => $AttributeTypeAndValue - ); - - // http://tools.ietf.org/html/rfc5280#section-4.1.2.4 - $RDNSequence = array( - 'type' => ASN1::TYPE_SEQUENCE, - // RDNSequence does not define a min or a max, which means it doesn't have one - 'min' => 0, - 'max' => -1, - 'children' => $this->RelativeDistinguishedName - ); - - $this->Name = array( - 'type' => ASN1::TYPE_CHOICE, - 'children' => array( - 'rdnSequence' => $RDNSequence - ) - ); - - // http://tools.ietf.org/html/rfc5280#section-4.1.1.2 - $AlgorithmIdentifier = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'algorithm' => array('type' => ASN1::TYPE_OBJECT_IDENTIFIER), - 'parameters' => array( - 'type' => ASN1::TYPE_ANY, - 'optional' => true - ) - ) - ); - - /* - A certificate using system MUST reject the certificate if it encounters - a critical extension it does not recognize; however, a non-critical - extension may be ignored if it is not recognized. - - http://tools.ietf.org/html/rfc5280#section-4.2 - */ - $Extension = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'extnId' => array('type' => ASN1::TYPE_OBJECT_IDENTIFIER), - 'critical' => array( - 'type' => ASN1::TYPE_BOOLEAN, - 'optional' => true, - 'default' => false - ), - 'extnValue' => array('type' => ASN1::TYPE_OCTET_STRING) - ) - ); - - $this->Extensions = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'min' => 1, - // technically, it's MAX, but we'll assume anything < 0 is MAX - 'max' => -1, - // if 'children' isn't an array then 'min' and 'max' must be defined - 'children' => $Extension - ); - - $SubjectPublicKeyInfo = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'algorithm' => $AlgorithmIdentifier, - 'subjectPublicKey' => array('type' => ASN1::TYPE_BIT_STRING) - ) - ); - - $UniqueIdentifier = array('type' => ASN1::TYPE_BIT_STRING); - - $Time = array( - 'type' => ASN1::TYPE_CHOICE, - 'children' => array( - 'utcTime' => array('type' => ASN1::TYPE_UTC_TIME), - 'generalTime' => array('type' => ASN1::TYPE_GENERALIZED_TIME) - ) - ); - - // http://tools.ietf.org/html/rfc5280#section-4.1.2.5 - $Validity = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'notBefore' => $Time, - 'notAfter' => $Time - ) - ); - - $CertificateSerialNumber = array('type' => ASN1::TYPE_INTEGER); - - $Version = array( - 'type' => ASN1::TYPE_INTEGER, - 'mapping' => array('v1', 'v2', 'v3') - ); - - // assert($TBSCertificate['children']['signature'] == $Certificate['children']['signatureAlgorithm']) - $TBSCertificate = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - // technically, default implies optional, but we'll define it as being optional, none-the-less, just to - // reenforce that fact - 'version' => array( - 'constant' => 0, - 'optional' => true, - 'explicit' => true, - 'default' => 'v1' - ) + $Version, - 'serialNumber' => $CertificateSerialNumber, - 'signature' => $AlgorithmIdentifier, - 'issuer' => $this->Name, - 'validity' => $Validity, - 'subject' => $this->Name, - 'subjectPublicKeyInfo' => $SubjectPublicKeyInfo, - // implicit means that the T in the TLV structure is to be rewritten, regardless of the type - 'issuerUniqueID' => array( - 'constant' => 1, - 'optional' => true, - 'implicit' => true - ) + $UniqueIdentifier, - 'subjectUniqueID' => array( - 'constant' => 2, - 'optional' => true, - 'implicit' => true - ) + $UniqueIdentifier, - // <http://tools.ietf.org/html/rfc2459#page-74> doesn't use the EXPLICIT keyword but if - // it's not IMPLICIT, it's EXPLICIT - 'extensions' => array( - 'constant' => 3, - 'optional' => true, - 'explicit' => true - ) + $this->Extensions - ) - ); - - $this->Certificate = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'tbsCertificate' => $TBSCertificate, - 'signatureAlgorithm' => $AlgorithmIdentifier, - 'signature' => array('type' => ASN1::TYPE_BIT_STRING) - ) - ); - - $this->KeyUsage = array( - 'type' => ASN1::TYPE_BIT_STRING, - 'mapping' => array( - 'digitalSignature', - 'nonRepudiation', - 'keyEncipherment', - 'dataEncipherment', - 'keyAgreement', - 'keyCertSign', - 'cRLSign', - 'encipherOnly', - 'decipherOnly' - ) - ); - - $this->BasicConstraints = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'cA' => array( - 'type' => ASN1::TYPE_BOOLEAN, - 'optional' => true, - 'default' => false - ), - 'pathLenConstraint' => array( - 'type' => ASN1::TYPE_INTEGER, - 'optional' => true - ) - ) - ); - - $this->KeyIdentifier = array('type' => ASN1::TYPE_OCTET_STRING); - - $OrganizationalUnitNames = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'min' => 1, - 'max' => 4, // ub-organizational-units - 'children' => array('type' => ASN1::TYPE_PRINTABLE_STRING) - ); - - $PersonalName = array( - 'type' => ASN1::TYPE_SET, - 'children' => array( - 'surname' => array( - 'type' => ASN1::TYPE_PRINTABLE_STRING, - 'constant' => 0, - 'optional' => true, - 'implicit' => true - ), - 'given-name' => array( - 'type' => ASN1::TYPE_PRINTABLE_STRING, - 'constant' => 1, - 'optional' => true, - 'implicit' => true - ), - 'initials' => array( - 'type' => ASN1::TYPE_PRINTABLE_STRING, - 'constant' => 2, - 'optional' => true, - 'implicit' => true - ), - 'generation-qualifier' => array( - 'type' => ASN1::TYPE_PRINTABLE_STRING, - 'constant' => 3, - 'optional' => true, - 'implicit' => true - ) - ) - ); - - $NumericUserIdentifier = array('type' => ASN1::TYPE_NUMERIC_STRING); - - $OrganizationName = array('type' => ASN1::TYPE_PRINTABLE_STRING); - - $PrivateDomainName = array( - 'type' => ASN1::TYPE_CHOICE, - 'children' => array( - 'numeric' => array('type' => ASN1::TYPE_NUMERIC_STRING), - 'printable' => array('type' => ASN1::TYPE_PRINTABLE_STRING) - ) - ); - - $TerminalIdentifier = array('type' => ASN1::TYPE_PRINTABLE_STRING); - - $NetworkAddress = array('type' => ASN1::TYPE_NUMERIC_STRING); - - $AdministrationDomainName = array( - 'type' => ASN1::TYPE_CHOICE, - // if class isn't present it's assumed to be \phpseclib\File\ASN1::CLASS_UNIVERSAL or - // (if constant is present) \phpseclib\File\ASN1::CLASS_CONTEXT_SPECIFIC - 'class' => ASN1::CLASS_APPLICATION, - 'cast' => 2, - 'children' => array( - 'numeric' => array('type' => ASN1::TYPE_NUMERIC_STRING), - 'printable' => array('type' => ASN1::TYPE_PRINTABLE_STRING) - ) - ); - - $CountryName = array( - 'type' => ASN1::TYPE_CHOICE, - // if class isn't present it's assumed to be \phpseclib\File\ASN1::CLASS_UNIVERSAL or - // (if constant is present) \phpseclib\File\ASN1::CLASS_CONTEXT_SPECIFIC - 'class' => ASN1::CLASS_APPLICATION, - 'cast' => 1, - 'children' => array( - 'x121-dcc-code' => array('type' => ASN1::TYPE_NUMERIC_STRING), - 'iso-3166-alpha2-code' => array('type' => ASN1::TYPE_PRINTABLE_STRING) - ) - ); - - $AnotherName = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'type-id' => array('type' => ASN1::TYPE_OBJECT_IDENTIFIER), - 'value' => array( - 'type' => ASN1::TYPE_ANY, - 'constant' => 0, - 'optional' => true, - 'explicit' => true - ) - ) - ); - - $ExtensionAttribute = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'extension-attribute-type' => array( - 'type' => ASN1::TYPE_PRINTABLE_STRING, - 'constant' => 0, - 'optional' => true, - 'implicit' => true - ), - 'extension-attribute-value' => array( - 'type' => ASN1::TYPE_ANY, - 'constant' => 1, - 'optional' => true, - 'explicit' => true - ) - ) - ); - - $ExtensionAttributes = array( - 'type' => ASN1::TYPE_SET, - 'min' => 1, - 'max' => 256, // ub-extension-attributes - 'children' => $ExtensionAttribute - ); - - $BuiltInDomainDefinedAttribute = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'type' => array('type' => ASN1::TYPE_PRINTABLE_STRING), - 'value' => array('type' => ASN1::TYPE_PRINTABLE_STRING) - ) - ); - - $BuiltInDomainDefinedAttributes = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'min' => 1, - 'max' => 4, // ub-domain-defined-attributes - 'children' => $BuiltInDomainDefinedAttribute - ); - - $BuiltInStandardAttributes = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'country-name' => array('optional' => true) + $CountryName, - 'administration-domain-name' => array('optional' => true) + $AdministrationDomainName, - 'network-address' => array( - 'constant' => 0, - 'optional' => true, - 'implicit' => true - ) + $NetworkAddress, - 'terminal-identifier' => array( - 'constant' => 1, - 'optional' => true, - 'implicit' => true - ) + $TerminalIdentifier, - 'private-domain-name' => array( - 'constant' => 2, - 'optional' => true, - 'explicit' => true - ) + $PrivateDomainName, - 'organization-name' => array( - 'constant' => 3, - 'optional' => true, - 'implicit' => true - ) + $OrganizationName, - 'numeric-user-identifier' => array( - 'constant' => 4, - 'optional' => true, - 'implicit' => true - ) + $NumericUserIdentifier, - 'personal-name' => array( - 'constant' => 5, - 'optional' => true, - 'implicit' => true - ) + $PersonalName, - 'organizational-unit-names' => array( - 'constant' => 6, - 'optional' => true, - 'implicit' => true - ) + $OrganizationalUnitNames - ) - ); - - $ORAddress = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'built-in-standard-attributes' => $BuiltInStandardAttributes, - 'built-in-domain-defined-attributes' => array('optional' => true) + $BuiltInDomainDefinedAttributes, - 'extension-attributes' => array('optional' => true) + $ExtensionAttributes - ) - ); - - $EDIPartyName = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'nameAssigner' => array( - 'constant' => 0, - 'optional' => true, - 'implicit' => true - ) + $this->DirectoryString, - // partyName is technically required but \phpseclib\File\ASN1 doesn't currently support non-optional constants and - // setting it to optional gets the job done in any event. - 'partyName' => array( - 'constant' => 1, - 'optional' => true, - 'implicit' => true - ) + $this->DirectoryString - ) - ); - - $GeneralName = array( - 'type' => ASN1::TYPE_CHOICE, - 'children' => array( - 'otherName' => array( - 'constant' => 0, - 'optional' => true, - 'implicit' => true - ) + $AnotherName, - 'rfc822Name' => array( - 'type' => ASN1::TYPE_IA5_STRING, - 'constant' => 1, - 'optional' => true, - 'implicit' => true - ), - 'dNSName' => array( - 'type' => ASN1::TYPE_IA5_STRING, - 'constant' => 2, - 'optional' => true, - 'implicit' => true - ), - 'x400Address' => array( - 'constant' => 3, - 'optional' => true, - 'implicit' => true - ) + $ORAddress, - 'directoryName' => array( - 'constant' => 4, - 'optional' => true, - 'explicit' => true - ) + $this->Name, - 'ediPartyName' => array( - 'constant' => 5, - 'optional' => true, - 'implicit' => true - ) + $EDIPartyName, - 'uniformResourceIdentifier' => array( - 'type' => ASN1::TYPE_IA5_STRING, - 'constant' => 6, - 'optional' => true, - 'implicit' => true - ), - 'iPAddress' => array( - 'type' => ASN1::TYPE_OCTET_STRING, - 'constant' => 7, - 'optional' => true, - 'implicit' => true - ), - 'registeredID' => array( - 'type' => ASN1::TYPE_OBJECT_IDENTIFIER, - 'constant' => 8, - 'optional' => true, - 'implicit' => true - ) - ) - ); - - $GeneralNames = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'min' => 1, - 'max' => -1, - 'children' => $GeneralName - ); - - $this->IssuerAltName = $GeneralNames; - - $ReasonFlags = array( - 'type' => ASN1::TYPE_BIT_STRING, - 'mapping' => array( - 'unused', - 'keyCompromise', - 'cACompromise', - 'affiliationChanged', - 'superseded', - 'cessationOfOperation', - 'certificateHold', - 'privilegeWithdrawn', - 'aACompromise' - ) - ); - - $DistributionPointName = array( - 'type' => ASN1::TYPE_CHOICE, - 'children' => array( - 'fullName' => array( - 'constant' => 0, - 'optional' => true, - 'implicit' => true - ) + $GeneralNames, - 'nameRelativeToCRLIssuer' => array( - 'constant' => 1, - 'optional' => true, - 'implicit' => true - ) + $this->RelativeDistinguishedName - ) - ); - - $DistributionPoint = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'distributionPoint' => array( - 'constant' => 0, - 'optional' => true, - 'explicit' => true - ) + $DistributionPointName, - 'reasons' => array( - 'constant' => 1, - 'optional' => true, - 'implicit' => true - ) + $ReasonFlags, - 'cRLIssuer' => array( - 'constant' => 2, - 'optional' => true, - 'implicit' => true - ) + $GeneralNames - ) - ); - - $this->CRLDistributionPoints = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'min' => 1, - 'max' => -1, - 'children' => $DistributionPoint - ); - - $this->AuthorityKeyIdentifier = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'keyIdentifier' => array( - 'constant' => 0, - 'optional' => true, - 'implicit' => true - ) + $this->KeyIdentifier, - 'authorityCertIssuer' => array( - 'constant' => 1, - 'optional' => true, - 'implicit' => true - ) + $GeneralNames, - 'authorityCertSerialNumber' => array( - 'constant' => 2, - 'optional' => true, - 'implicit' => true - ) + $CertificateSerialNumber - ) - ); - - $PolicyQualifierId = array('type' => ASN1::TYPE_OBJECT_IDENTIFIER); - - $PolicyQualifierInfo = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'policyQualifierId' => $PolicyQualifierId, - 'qualifier' => array('type' => ASN1::TYPE_ANY) - ) - ); - - $CertPolicyId = array('type' => ASN1::TYPE_OBJECT_IDENTIFIER); - - $PolicyInformation = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'policyIdentifier' => $CertPolicyId, - 'policyQualifiers' => array( - 'type' => ASN1::TYPE_SEQUENCE, - 'min' => 0, - 'max' => -1, - 'optional' => true, - 'children' => $PolicyQualifierInfo - ) - ) - ); - - $this->CertificatePolicies = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'min' => 1, - 'max' => -1, - 'children' => $PolicyInformation - ); - - $this->PolicyMappings = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'min' => 1, - 'max' => -1, - 'children' => array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'issuerDomainPolicy' => $CertPolicyId, - 'subjectDomainPolicy' => $CertPolicyId - ) - ) - ); - - $KeyPurposeId = array('type' => ASN1::TYPE_OBJECT_IDENTIFIER); - - $this->ExtKeyUsageSyntax = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'min' => 1, - 'max' => -1, - 'children' => $KeyPurposeId - ); - - $AccessDescription = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'accessMethod' => array('type' => ASN1::TYPE_OBJECT_IDENTIFIER), - 'accessLocation' => $GeneralName - ) - ); - - $this->AuthorityInfoAccessSyntax = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'min' => 1, - 'max' => -1, - 'children' => $AccessDescription - ); - - $this->SubjectAltName = $GeneralNames; - - $this->PrivateKeyUsagePeriod = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'notBefore' => array( - 'constant' => 0, - 'optional' => true, - 'implicit' => true, - 'type' => ASN1::TYPE_GENERALIZED_TIME), - 'notAfter' => array( - 'constant' => 1, - 'optional' => true, - 'implicit' => true, - 'type' => ASN1::TYPE_GENERALIZED_TIME) - ) - ); - - $BaseDistance = array('type' => ASN1::TYPE_INTEGER); - - $GeneralSubtree = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'base' => $GeneralName, - 'minimum' => array( - 'constant' => 0, - 'optional' => true, - 'implicit' => true, - 'default' => new BigInteger(0) - ) + $BaseDistance, - 'maximum' => array( - 'constant' => 1, - 'optional' => true, - 'implicit' => true, - ) + $BaseDistance - ) - ); - - $GeneralSubtrees = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'min' => 1, - 'max' => -1, - 'children' => $GeneralSubtree - ); - - $this->NameConstraints = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'permittedSubtrees' => array( - 'constant' => 0, - 'optional' => true, - 'implicit' => true - ) + $GeneralSubtrees, - 'excludedSubtrees' => array( - 'constant' => 1, - 'optional' => true, - 'implicit' => true - ) + $GeneralSubtrees - ) - ); - - $this->CPSuri = array('type' => ASN1::TYPE_IA5_STRING); - - $DisplayText = array( - 'type' => ASN1::TYPE_CHOICE, - 'children' => array( - 'ia5String' => array('type' => ASN1::TYPE_IA5_STRING), - 'visibleString' => array('type' => ASN1::TYPE_VISIBLE_STRING), - 'bmpString' => array('type' => ASN1::TYPE_BMP_STRING), - 'utf8String' => array('type' => ASN1::TYPE_UTF8_STRING) - ) - ); - - $NoticeReference = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'organization' => $DisplayText, - 'noticeNumbers' => array( - 'type' => ASN1::TYPE_SEQUENCE, - 'min' => 1, - 'max' => 200, - 'children' => array('type' => ASN1::TYPE_INTEGER) - ) - ) - ); - - $this->UserNotice = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'noticeRef' => array( - 'optional' => true, - 'implicit' => true - ) + $NoticeReference, - 'explicitText' => array( - 'optional' => true, - 'implicit' => true - ) + $DisplayText - ) - ); - - // mapping is from <http://www.mozilla.org/projects/security/pki/nss/tech-notes/tn3.html> - $this->netscape_cert_type = array( - 'type' => ASN1::TYPE_BIT_STRING, - 'mapping' => array( - 'SSLClient', - 'SSLServer', - 'Email', - 'ObjectSigning', - 'Reserved', - 'SSLCA', - 'EmailCA', - 'ObjectSigningCA' - ) - ); - - $this->netscape_comment = array('type' => ASN1::TYPE_IA5_STRING); - $this->netscape_ca_policy_url = array('type' => ASN1::TYPE_IA5_STRING); - - // attribute is used in RFC2986 but we're using the RFC5280 definition - - $Attribute = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'type' => $AttributeType, - 'value'=> array( - 'type' => ASN1::TYPE_SET, - 'min' => 1, - 'max' => -1, - 'children' => $this->AttributeValue - ) - ) - ); - - // adapted from <http://tools.ietf.org/html/rfc2986> - - $Attributes = array( - 'type' => ASN1::TYPE_SET, - 'min' => 1, - 'max' => -1, - 'children' => $Attribute - ); - - $CertificationRequestInfo = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'version' => array( - 'type' => ASN1::TYPE_INTEGER, - 'mapping' => array('v1') - ), - 'subject' => $this->Name, - 'subjectPKInfo' => $SubjectPublicKeyInfo, - 'attributes' => array( - 'constant' => 0, - 'optional' => true, - 'implicit' => true - ) + $Attributes, - ) - ); - - $this->CertificationRequest = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'certificationRequestInfo' => $CertificationRequestInfo, - 'signatureAlgorithm' => $AlgorithmIdentifier, - 'signature' => array('type' => ASN1::TYPE_BIT_STRING) - ) - ); - - $RevokedCertificate = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'userCertificate' => $CertificateSerialNumber, - 'revocationDate' => $Time, - 'crlEntryExtensions' => array( - 'optional' => true - ) + $this->Extensions - ) - ); - - $TBSCertList = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'version' => array( - 'optional' => true, - 'default' => 'v1' - ) + $Version, - 'signature' => $AlgorithmIdentifier, - 'issuer' => $this->Name, - 'thisUpdate' => $Time, - 'nextUpdate' => array( - 'optional' => true - ) + $Time, - 'revokedCertificates' => array( - 'type' => ASN1::TYPE_SEQUENCE, - 'optional' => true, - 'min' => 0, - 'max' => -1, - 'children' => $RevokedCertificate - ), - 'crlExtensions' => array( - 'constant' => 0, - 'optional' => true, - 'explicit' => true - ) + $this->Extensions - ) - ); - - $this->CertificateList = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'tbsCertList' => $TBSCertList, - 'signatureAlgorithm' => $AlgorithmIdentifier, - 'signature' => array('type' => ASN1::TYPE_BIT_STRING) - ) - ); - - $this->CRLNumber = array('type' => ASN1::TYPE_INTEGER); - - $this->CRLReason = array('type' => ASN1::TYPE_ENUMERATED, - 'mapping' => array( - 'unspecified', - 'keyCompromise', - 'cACompromise', - 'affiliationChanged', - 'superseded', - 'cessationOfOperation', - 'certificateHold', - // Value 7 is not used. - 8 => 'removeFromCRL', - 'privilegeWithdrawn', - 'aACompromise' - ) - ); - - $this->IssuingDistributionPoint = array('type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'distributionPoint' => array( - 'constant' => 0, - 'optional' => true, - 'explicit' => true - ) + $DistributionPointName, - 'onlyContainsUserCerts' => array( - 'type' => ASN1::TYPE_BOOLEAN, - 'constant' => 1, - 'optional' => true, - 'default' => false, - 'implicit' => true - ), - 'onlyContainsCACerts' => array( - 'type' => ASN1::TYPE_BOOLEAN, - 'constant' => 2, - 'optional' => true, - 'default' => false, - 'implicit' => true - ), - 'onlySomeReasons' => array( - 'constant' => 3, - 'optional' => true, - 'implicit' => true - ) + $ReasonFlags, - 'indirectCRL' => array( - 'type' => ASN1::TYPE_BOOLEAN, - 'constant' => 4, - 'optional' => true, - 'default' => false, - 'implicit' => true - ), - 'onlyContainsAttributeCerts' => array( - 'type' => ASN1::TYPE_BOOLEAN, - 'constant' => 5, - 'optional' => true, - 'default' => false, - 'implicit' => true - ) - ) - ); - - $this->InvalidityDate = array('type' => ASN1::TYPE_GENERALIZED_TIME); - - $this->CertificateIssuer = $GeneralNames; - - $this->HoldInstructionCode = array('type' => ASN1::TYPE_OBJECT_IDENTIFIER); - - $PublicKeyAndChallenge = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'spki' => $SubjectPublicKeyInfo, - 'challenge' => array('type' => ASN1::TYPE_IA5_STRING) - ) - ); - - $this->SignedPublicKeyAndChallenge = array( - 'type' => ASN1::TYPE_SEQUENCE, - 'children' => array( - 'publicKeyAndChallenge' => $PublicKeyAndChallenge, - 'signatureAlgorithm' => $AlgorithmIdentifier, - 'signature' => array('type' => ASN1::TYPE_BIT_STRING) - ) - ); - - // OIDs from RFC5280 and those RFCs mentioned in RFC5280#section-4.1.1.2 - $this->oids = array( - '1.3.6.1.5.5.7' => 'id-pkix', - '1.3.6.1.5.5.7.1' => 'id-pe', - '1.3.6.1.5.5.7.2' => 'id-qt', - '1.3.6.1.5.5.7.3' => 'id-kp', - '1.3.6.1.5.5.7.48' => 'id-ad', - '1.3.6.1.5.5.7.2.1' => 'id-qt-cps', - '1.3.6.1.5.5.7.2.2' => 'id-qt-unotice', - '1.3.6.1.5.5.7.48.1' =>'id-ad-ocsp', - '1.3.6.1.5.5.7.48.2' => 'id-ad-caIssuers', - '1.3.6.1.5.5.7.48.3' => 'id-ad-timeStamping', - '1.3.6.1.5.5.7.48.5' => 'id-ad-caRepository', - '2.5.4' => 'id-at', - '2.5.4.41' => 'id-at-name', - '2.5.4.4' => 'id-at-surname', - '2.5.4.42' => 'id-at-givenName', - '2.5.4.43' => 'id-at-initials', - '2.5.4.44' => 'id-at-generationQualifier', - '2.5.4.3' => 'id-at-commonName', - '2.5.4.7' => 'id-at-localityName', - '2.5.4.8' => 'id-at-stateOrProvinceName', - '2.5.4.10' => 'id-at-organizationName', - '2.5.4.11' => 'id-at-organizationalUnitName', - '2.5.4.12' => 'id-at-title', - '2.5.4.13' => 'id-at-description', - '2.5.4.46' => 'id-at-dnQualifier', - '2.5.4.6' => 'id-at-countryName', - '2.5.4.5' => 'id-at-serialNumber', - '2.5.4.65' => 'id-at-pseudonym', - '2.5.4.17' => 'id-at-postalCode', - '2.5.4.9' => 'id-at-streetAddress', - '2.5.4.45' => 'id-at-uniqueIdentifier', - '2.5.4.72' => 'id-at-role', - - '0.9.2342.19200300.100.1.25' => 'id-domainComponent', - '1.2.840.113549.1.9' => 'pkcs-9', - '1.2.840.113549.1.9.1' => 'pkcs-9-at-emailAddress', - '2.5.29' => 'id-ce', - '2.5.29.35' => 'id-ce-authorityKeyIdentifier', - '2.5.29.14' => 'id-ce-subjectKeyIdentifier', - '2.5.29.15' => 'id-ce-keyUsage', - '2.5.29.16' => 'id-ce-privateKeyUsagePeriod', - '2.5.29.32' => 'id-ce-certificatePolicies', - '2.5.29.32.0' => 'anyPolicy', - - '2.5.29.33' => 'id-ce-policyMappings', - '2.5.29.17' => 'id-ce-subjectAltName', - '2.5.29.18' => 'id-ce-issuerAltName', - '2.5.29.9' => 'id-ce-subjectDirectoryAttributes', - '2.5.29.19' => 'id-ce-basicConstraints', - '2.5.29.30' => 'id-ce-nameConstraints', - '2.5.29.36' => 'id-ce-policyConstraints', - '2.5.29.31' => 'id-ce-cRLDistributionPoints', - '2.5.29.37' => 'id-ce-extKeyUsage', - '2.5.29.37.0' => 'anyExtendedKeyUsage', - '1.3.6.1.5.5.7.3.1' => 'id-kp-serverAuth', - '1.3.6.1.5.5.7.3.2' => 'id-kp-clientAuth', - '1.3.6.1.5.5.7.3.3' => 'id-kp-codeSigning', - '1.3.6.1.5.5.7.3.4' => 'id-kp-emailProtection', - '1.3.6.1.5.5.7.3.8' => 'id-kp-timeStamping', - '1.3.6.1.5.5.7.3.9' => 'id-kp-OCSPSigning', - '2.5.29.54' => 'id-ce-inhibitAnyPolicy', - '2.5.29.46' => 'id-ce-freshestCRL', - '1.3.6.1.5.5.7.1.1' => 'id-pe-authorityInfoAccess', - '1.3.6.1.5.5.7.1.11' => 'id-pe-subjectInfoAccess', - '2.5.29.20' => 'id-ce-cRLNumber', - '2.5.29.28' => 'id-ce-issuingDistributionPoint', - '2.5.29.27' => 'id-ce-deltaCRLIndicator', - '2.5.29.21' => 'id-ce-cRLReasons', - '2.5.29.29' => 'id-ce-certificateIssuer', - '2.5.29.23' => 'id-ce-holdInstructionCode', - '1.2.840.10040.2' => 'holdInstruction', - '1.2.840.10040.2.1' => 'id-holdinstruction-none', - '1.2.840.10040.2.2' => 'id-holdinstruction-callissuer', - '1.2.840.10040.2.3' => 'id-holdinstruction-reject', - '2.5.29.24' => 'id-ce-invalidityDate', - - '1.2.840.113549.2.2' => 'md2', - '1.2.840.113549.2.5' => 'md5', - '1.3.14.3.2.26' => 'id-sha1', - '1.2.840.10040.4.1' => 'id-dsa', - '1.2.840.10040.4.3' => 'id-dsa-with-sha1', - '1.2.840.113549.1.1' => 'pkcs-1', - '1.2.840.113549.1.1.1' => 'rsaEncryption', - '1.2.840.113549.1.1.2' => 'md2WithRSAEncryption', - '1.2.840.113549.1.1.4' => 'md5WithRSAEncryption', - '1.2.840.113549.1.1.5' => 'sha1WithRSAEncryption', - '1.2.840.10046.2.1' => 'dhpublicnumber', - '2.16.840.1.101.2.1.1.22' => 'id-keyExchangeAlgorithm', - '1.2.840.10045' => 'ansi-X9-62', - '1.2.840.10045.4' => 'id-ecSigType', - '1.2.840.10045.4.1' => 'ecdsa-with-SHA1', - '1.2.840.10045.1' => 'id-fieldType', - '1.2.840.10045.1.1' => 'prime-field', - '1.2.840.10045.1.2' => 'characteristic-two-field', - '1.2.840.10045.1.2.3' => 'id-characteristic-two-basis', - '1.2.840.10045.1.2.3.1' => 'gnBasis', - '1.2.840.10045.1.2.3.2' => 'tpBasis', - '1.2.840.10045.1.2.3.3' => 'ppBasis', - '1.2.840.10045.2' => 'id-publicKeyType', - '1.2.840.10045.2.1' => 'id-ecPublicKey', - '1.2.840.10045.3' => 'ellipticCurve', - '1.2.840.10045.3.0' => 'c-TwoCurve', - '1.2.840.10045.3.0.1' => 'c2pnb163v1', - '1.2.840.10045.3.0.2' => 'c2pnb163v2', - '1.2.840.10045.3.0.3' => 'c2pnb163v3', - '1.2.840.10045.3.0.4' => 'c2pnb176w1', - '1.2.840.10045.3.0.5' => 'c2pnb191v1', - '1.2.840.10045.3.0.6' => 'c2pnb191v2', - '1.2.840.10045.3.0.7' => 'c2pnb191v3', - '1.2.840.10045.3.0.8' => 'c2pnb191v4', - '1.2.840.10045.3.0.9' => 'c2pnb191v5', - '1.2.840.10045.3.0.10' => 'c2pnb208w1', - '1.2.840.10045.3.0.11' => 'c2pnb239v1', - '1.2.840.10045.3.0.12' => 'c2pnb239v2', - '1.2.840.10045.3.0.13' => 'c2pnb239v3', - '1.2.840.10045.3.0.14' => 'c2pnb239v4', - '1.2.840.10045.3.0.15' => 'c2pnb239v5', - '1.2.840.10045.3.0.16' => 'c2pnb272w1', - '1.2.840.10045.3.0.17' => 'c2pnb304w1', - '1.2.840.10045.3.0.18' => 'c2pnb359v1', - '1.2.840.10045.3.0.19' => 'c2pnb368w1', - '1.2.840.10045.3.0.20' => 'c2pnb431r1', - '1.2.840.10045.3.1' => 'primeCurve', - '1.2.840.10045.3.1.1' => 'prime192v1', - '1.2.840.10045.3.1.2' => 'prime192v2', - '1.2.840.10045.3.1.3' => 'prime192v3', - '1.2.840.10045.3.1.4' => 'prime239v1', - '1.2.840.10045.3.1.5' => 'prime239v2', - '1.2.840.10045.3.1.6' => 'prime239v3', - '1.2.840.10045.3.1.7' => 'prime256v1', - '1.2.840.113549.1.1.7' => 'id-RSAES-OAEP', - '1.2.840.113549.1.1.9' => 'id-pSpecified', - '1.2.840.113549.1.1.10' => 'id-RSASSA-PSS', - '1.2.840.113549.1.1.8' => 'id-mgf1', - '1.2.840.113549.1.1.14' => 'sha224WithRSAEncryption', - '1.2.840.113549.1.1.11' => 'sha256WithRSAEncryption', - '1.2.840.113549.1.1.12' => 'sha384WithRSAEncryption', - '1.2.840.113549.1.1.13' => 'sha512WithRSAEncryption', - '2.16.840.1.101.3.4.2.4' => 'id-sha224', - '2.16.840.1.101.3.4.2.1' => 'id-sha256', - '2.16.840.1.101.3.4.2.2' => 'id-sha384', - '2.16.840.1.101.3.4.2.3' => 'id-sha512', - '1.2.643.2.2.4' => 'id-GostR3411-94-with-GostR3410-94', - '1.2.643.2.2.3' => 'id-GostR3411-94-with-GostR3410-2001', - '1.2.643.2.2.20' => 'id-GostR3410-2001', - '1.2.643.2.2.19' => 'id-GostR3410-94', - // Netscape Object Identifiers from "Netscape Certificate Extensions" - '2.16.840.1.113730' => 'netscape', - '2.16.840.1.113730.1' => 'netscape-cert-extension', - '2.16.840.1.113730.1.1' => 'netscape-cert-type', - '2.16.840.1.113730.1.13' => 'netscape-comment', - '2.16.840.1.113730.1.8' => 'netscape-ca-policy-url', - // the following are X.509 extensions not supported by phpseclib - '1.3.6.1.5.5.7.1.12' => 'id-pe-logotype', - '1.2.840.113533.7.65.0' => 'entrustVersInfo', - '2.16.840.1.113733.1.6.9' => 'verisignPrivate', - // for Certificate Signing Requests - // see http://tools.ietf.org/html/rfc2985 - '1.2.840.113549.1.9.2' => 'pkcs-9-at-unstructuredName', // PKCS #9 unstructured name - '1.2.840.113549.1.9.7' => 'pkcs-9-at-challengePassword', // Challenge password for certificate revocations - '1.2.840.113549.1.9.14' => 'pkcs-9-at-extensionRequest' // Certificate extension request - ); - } - - /** - * Load X.509 certificate - * - * Returns an associative array describing the X.509 cert or a false if the cert failed to load - * - * @param string $cert - * @param int $mode - * @access public - * @return mixed - */ - function loadX509($cert, $mode = self::FORMAT_AUTO_DETECT) - { - if (is_array($cert) && isset($cert['tbsCertificate'])) { - unset($this->currentCert); - unset($this->currentKeyIdentifier); - $this->dn = $cert['tbsCertificate']['subject']; - if (!isset($this->dn)) { - return false; - } - $this->currentCert = $cert; - - $currentKeyIdentifier = $this->getExtension('id-ce-subjectKeyIdentifier'); - $this->currentKeyIdentifier = is_string($currentKeyIdentifier) ? $currentKeyIdentifier : null; - - unset($this->signatureSubject); - - return $cert; - } - - $asn1 = new ASN1(); - - if ($mode != self::FORMAT_DER) { - $newcert = $this->_extractBER($cert); - if ($mode == self::FORMAT_PEM && $cert == $newcert) { - return false; - } - $cert = $newcert; - } - - if ($cert === false) { - $this->currentCert = false; - return false; - } - - $asn1->loadOIDs($this->oids); - $decoded = $asn1->decodeBER($cert); - - if (!empty($decoded)) { - $x509 = $asn1->asn1map($decoded[0], $this->Certificate); - } - if (!isset($x509) || $x509 === false) { - $this->currentCert = false; - return false; - } - - $this->signatureSubject = substr($cert, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']); - - $this->_mapInExtensions($x509, 'tbsCertificate/extensions', $asn1); - - $key = &$x509['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']; - $key = $this->_reformatKey($x509['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['algorithm'], $key); - - $this->currentCert = $x509; - $this->dn = $x509['tbsCertificate']['subject']; - - $currentKeyIdentifier = $this->getExtension('id-ce-subjectKeyIdentifier'); - $this->currentKeyIdentifier = is_string($currentKeyIdentifier) ? $currentKeyIdentifier : null; - - return $x509; - } - - /** - * Save X.509 certificate - * - * @param array $cert - * @param int $format optional - * @access public - * @return string - */ - function saveX509($cert, $format = self::FORMAT_PEM) - { - if (!is_array($cert) || !isset($cert['tbsCertificate'])) { - return false; - } - - switch (true) { - // "case !$a: case !$b: break; default: whatever();" is the same thing as "if ($a && $b) whatever()" - case !($algorithm = $this->_subArray($cert, 'tbsCertificate/subjectPublicKeyInfo/algorithm/algorithm')): - case is_object($cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']): - break; - default: - switch ($algorithm) { - case 'rsaEncryption': - $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'] - = base64_encode("\0" . base64_decode(preg_replace('#-.+-|[\r\n]#', '', $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']))); - /* "[For RSA keys] the parameters field MUST have ASN.1 type NULL for this algorithm identifier." - -- https://tools.ietf.org/html/rfc3279#section-2.3.1 - - given that and the fact that RSA keys appear ot be the only key type for which the parameters field can be blank, - it seems like perhaps the ASN.1 description ought not say the parameters field is OPTIONAL, but whatever. - */ - $cert['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['parameters'] = null; - // https://tools.ietf.org/html/rfc3279#section-2.2.1 - $cert['signatureAlgorithm']['parameters'] = null; - $cert['tbsCertificate']['signature']['parameters'] = null; - } - } - - $asn1 = new ASN1(); - $asn1->loadOIDs($this->oids); - - $filters = array(); - $type_utf8_string = array('type' => ASN1::TYPE_UTF8_STRING); - $filters['tbsCertificate']['signature']['parameters'] = $type_utf8_string; - $filters['tbsCertificate']['signature']['issuer']['rdnSequence']['value'] = $type_utf8_string; - $filters['tbsCertificate']['issuer']['rdnSequence']['value'] = $type_utf8_string; - $filters['tbsCertificate']['subject']['rdnSequence']['value'] = $type_utf8_string; - $filters['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['parameters'] = $type_utf8_string; - $filters['signatureAlgorithm']['parameters'] = $type_utf8_string; - $filters['authorityCertIssuer']['directoryName']['rdnSequence']['value'] = $type_utf8_string; - //$filters['policyQualifiers']['qualifier'] = $type_utf8_string; - $filters['distributionPoint']['fullName']['directoryName']['rdnSequence']['value'] = $type_utf8_string; - $filters['directoryName']['rdnSequence']['value'] = $type_utf8_string; - - /* in the case of policyQualifiers/qualifier, the type has to be \phpseclib\File\ASN1::TYPE_IA5_STRING. - \phpseclib\File\ASN1::TYPE_PRINTABLE_STRING will cause OpenSSL's X.509 parser to spit out random - characters. - */ - $filters['policyQualifiers']['qualifier'] - = array('type' => ASN1::TYPE_IA5_STRING); - - $asn1->loadFilters($filters); - - $this->_mapOutExtensions($cert, 'tbsCertificate/extensions', $asn1); - - $cert = $asn1->encodeDER($cert, $this->Certificate); - - switch ($format) { - case self::FORMAT_DER: - return $cert; - // case self::FORMAT_PEM: - default: - return "-----BEGIN CERTIFICATE-----\r\n" . chunk_split(base64_encode($cert), 64) . '-----END CERTIFICATE-----'; - } - } - - /** - * Map extension values from octet string to extension-specific internal - * format. - * - * @param array ref $root - * @param string $path - * @param object $asn1 - * @access private - */ - function _mapInExtensions(&$root, $path, $asn1) - { - $extensions = &$this->_subArray($root, $path); - - if (is_array($extensions)) { - for ($i = 0; $i < count($extensions); $i++) { - $id = $extensions[$i]['extnId']; - $value = &$extensions[$i]['extnValue']; - $value = base64_decode($value); - $decoded = $asn1->decodeBER($value); - /* [extnValue] contains the DER encoding of an ASN.1 value - corresponding to the extension type identified by extnID */ - $map = $this->_getMapping($id); - if (!is_bool($map)) { - $mapped = $asn1->asn1map($decoded[0], $map, array('iPAddress' => array($this, '_decodeIP'))); - $value = $mapped === false ? $decoded[0] : $mapped; - - if ($id == 'id-ce-certificatePolicies') { - for ($j = 0; $j < count($value); $j++) { - if (!isset($value[$j]['policyQualifiers'])) { - continue; - } - for ($k = 0; $k < count($value[$j]['policyQualifiers']); $k++) { - $subid = $value[$j]['policyQualifiers'][$k]['policyQualifierId']; - $map = $this->_getMapping($subid); - $subvalue = &$value[$j]['policyQualifiers'][$k]['qualifier']; - if ($map !== false) { - $decoded = $asn1->decodeBER($subvalue); - $mapped = $asn1->asn1map($decoded[0], $map); - $subvalue = $mapped === false ? $decoded[0] : $mapped; - } - } - } - } - } else { - $value = base64_encode($value); - } - } - } - } - - /** - * Map extension values from extension-specific internal format to - * octet string. - * - * @param array ref $root - * @param string $path - * @param object $asn1 - * @access private - */ - function _mapOutExtensions(&$root, $path, $asn1) - { - $extensions = &$this->_subArray($root, $path); - - if (is_array($extensions)) { - $size = count($extensions); - for ($i = 0; $i < $size; $i++) { - if ($extensions[$i] instanceof Element) { - continue; - } - - $id = $extensions[$i]['extnId']; - $value = &$extensions[$i]['extnValue']; - - switch ($id) { - case 'id-ce-certificatePolicies': - for ($j = 0; $j < count($value); $j++) { - if (!isset($value[$j]['policyQualifiers'])) { - continue; - } - for ($k = 0; $k < count($value[$j]['policyQualifiers']); $k++) { - $subid = $value[$j]['policyQualifiers'][$k]['policyQualifierId']; - $map = $this->_getMapping($subid); - $subvalue = &$value[$j]['policyQualifiers'][$k]['qualifier']; - if ($map !== false) { - // by default \phpseclib\File\ASN1 will try to render qualifier as a \phpseclib\File\ASN1::TYPE_IA5_STRING since it's - // actual type is \phpseclib\File\ASN1::TYPE_ANY - $subvalue = new Element($asn1->encodeDER($subvalue, $map)); - } - } - } - break; - case 'id-ce-authorityKeyIdentifier': // use 00 as the serial number instead of an empty string - if (isset($value['authorityCertSerialNumber'])) { - if ($value['authorityCertSerialNumber']->toBytes() == '') { - $temp = chr((ASN1::CLASS_CONTEXT_SPECIFIC << 6) | 2) . "\1\0"; - $value['authorityCertSerialNumber'] = new Element($temp); - } - } - } - - /* [extnValue] contains the DER encoding of an ASN.1 value - corresponding to the extension type identified by extnID */ - $map = $this->_getMapping($id); - if (is_bool($map)) { - if (!$map) { - user_error($id . ' is not a currently supported extension'); - unset($extensions[$i]); - } - } else { - $temp = $asn1->encodeDER($value, $map, array('iPAddress' => array($this, '_encodeIP'))); - $value = base64_encode($temp); - } - } - } - } - - /** - * Map attribute values from ANY type to attribute-specific internal - * format. - * - * @param array ref $root - * @param string $path - * @param object $asn1 - * @access private - */ - function _mapInAttributes(&$root, $path, $asn1) - { - $attributes = &$this->_subArray($root, $path); - - if (is_array($attributes)) { - for ($i = 0; $i < count($attributes); $i++) { - $id = $attributes[$i]['type']; - /* $value contains the DER encoding of an ASN.1 value - corresponding to the attribute type identified by type */ - $map = $this->_getMapping($id); - if (is_array($attributes[$i]['value'])) { - $values = &$attributes[$i]['value']; - for ($j = 0; $j < count($values); $j++) { - $value = $asn1->encodeDER($values[$j], $this->AttributeValue); - $decoded = $asn1->decodeBER($value); - if (!is_bool($map)) { - $mapped = $asn1->asn1map($decoded[0], $map); - if ($mapped !== false) { - $values[$j] = $mapped; - } - if ($id == 'pkcs-9-at-extensionRequest') { - $this->_mapInExtensions($values, $j, $asn1); - } - } elseif ($map) { - $values[$j] = base64_encode($value); - } - } - } - } - } - } - - /** - * Map attribute values from attribute-specific internal format to - * ANY type. - * - * @param array ref $root - * @param string $path - * @param object $asn1 - * @access private - */ - function _mapOutAttributes(&$root, $path, $asn1) - { - $attributes = &$this->_subArray($root, $path); - - if (is_array($attributes)) { - $size = count($attributes); - for ($i = 0; $i < $size; $i++) { - /* [value] contains the DER encoding of an ASN.1 value - corresponding to the attribute type identified by type */ - $id = $attributes[$i]['type']; - $map = $this->_getMapping($id); - if ($map === false) { - user_error($id . ' is not a currently supported attribute', E_USER_NOTICE); - unset($attributes[$i]); - } elseif (is_array($attributes[$i]['value'])) { - $values = &$attributes[$i]['value']; - for ($j = 0; $j < count($values); $j++) { - switch ($id) { - case 'pkcs-9-at-extensionRequest': - $this->_mapOutExtensions($values, $j, $asn1); - break; - } - - if (!is_bool($map)) { - $temp = $asn1->encodeDER($values[$j], $map); - $decoded = $asn1->decodeBER($temp); - $values[$j] = $asn1->asn1map($decoded[0], $this->AttributeValue); - } - } - } - } - } - } - - /** - * Associate an extension ID to an extension mapping - * - * @param string $extnId - * @access private - * @return mixed - */ - function _getMapping($extnId) - { - if (!is_string($extnId)) { // eg. if it's a \phpseclib\File\ASN1\Element object - return true; - } - - switch ($extnId) { - case 'id-ce-keyUsage': - return $this->KeyUsage; - case 'id-ce-basicConstraints': - return $this->BasicConstraints; - case 'id-ce-subjectKeyIdentifier': - return $this->KeyIdentifier; - case 'id-ce-cRLDistributionPoints': - return $this->CRLDistributionPoints; - case 'id-ce-authorityKeyIdentifier': - return $this->AuthorityKeyIdentifier; - case 'id-ce-certificatePolicies': - return $this->CertificatePolicies; - case 'id-ce-extKeyUsage': - return $this->ExtKeyUsageSyntax; - case 'id-pe-authorityInfoAccess': - return $this->AuthorityInfoAccessSyntax; - case 'id-ce-subjectAltName': - return $this->SubjectAltName; - case 'id-ce-privateKeyUsagePeriod': - return $this->PrivateKeyUsagePeriod; - case 'id-ce-issuerAltName': - return $this->IssuerAltName; - case 'id-ce-policyMappings': - return $this->PolicyMappings; - case 'id-ce-nameConstraints': - return $this->NameConstraints; - - case 'netscape-cert-type': - return $this->netscape_cert_type; - case 'netscape-comment': - return $this->netscape_comment; - case 'netscape-ca-policy-url': - return $this->netscape_ca_policy_url; - - // since id-qt-cps isn't a constructed type it will have already been decoded as a string by the time it gets - // back around to asn1map() and we don't want it decoded again. - //case 'id-qt-cps': - // return $this->CPSuri; - case 'id-qt-unotice': - return $this->UserNotice; - - // the following OIDs are unsupported but we don't want them to give notices when calling saveX509(). - case 'id-pe-logotype': // http://www.ietf.org/rfc/rfc3709.txt - case 'entrustVersInfo': - // http://support.microsoft.com/kb/287547 - case '1.3.6.1.4.1.311.20.2': // szOID_ENROLL_CERTTYPE_EXTENSION - case '1.3.6.1.4.1.311.21.1': // szOID_CERTSRV_CA_VERSION - // "SET Secure Electronic Transaction Specification" - // http://www.maithean.com/docs/set_bk3.pdf - case '2.23.42.7.0': // id-set-hashedRootKey - return true; - - // CSR attributes - case 'pkcs-9-at-unstructuredName': - return $this->PKCS9String; - case 'pkcs-9-at-challengePassword': - return $this->DirectoryString; - case 'pkcs-9-at-extensionRequest': - return $this->Extensions; - - // CRL extensions. - case 'id-ce-cRLNumber': - return $this->CRLNumber; - case 'id-ce-deltaCRLIndicator': - return $this->CRLNumber; - case 'id-ce-issuingDistributionPoint': - return $this->IssuingDistributionPoint; - case 'id-ce-freshestCRL': - return $this->CRLDistributionPoints; - case 'id-ce-cRLReasons': - return $this->CRLReason; - case 'id-ce-invalidityDate': - return $this->InvalidityDate; - case 'id-ce-certificateIssuer': - return $this->CertificateIssuer; - case 'id-ce-holdInstructionCode': - return $this->HoldInstructionCode; - } - - return false; - } - - /** - * Load an X.509 certificate as a certificate authority - * - * @param string $cert - * @access public - * @return bool - */ - function loadCA($cert) - { - $olddn = $this->dn; - $oldcert = $this->currentCert; - $oldsigsubj = $this->signatureSubject; - $oldkeyid = $this->currentKeyIdentifier; - - $cert = $this->loadX509($cert); - if (!$cert) { - $this->dn = $olddn; - $this->currentCert = $oldcert; - $this->signatureSubject = $oldsigsubj; - $this->currentKeyIdentifier = $oldkeyid; - - return false; - } - - /* From RFC5280 "PKIX Certificate and CRL Profile": - - If the keyUsage extension is present, then the subject public key - MUST NOT be used to verify signatures on certificates or CRLs unless - the corresponding keyCertSign or cRLSign bit is set. */ - //$keyUsage = $this->getExtension('id-ce-keyUsage'); - //if ($keyUsage && !in_array('keyCertSign', $keyUsage)) { - // return false; - //} - - /* From RFC5280 "PKIX Certificate and CRL Profile": - - The cA boolean indicates whether the certified public key may be used - to verify certificate signatures. If the cA boolean is not asserted, - then the keyCertSign bit in the key usage extension MUST NOT be - asserted. If the basic constraints extension is not present in a - version 3 certificate, or the extension is present but the cA boolean - is not asserted, then the certified public key MUST NOT be used to - verify certificate signatures. */ - //$basicConstraints = $this->getExtension('id-ce-basicConstraints'); - //if (!$basicConstraints || !$basicConstraints['cA']) { - // return false; - //} - - $this->CAs[] = $cert; - - $this->dn = $olddn; - $this->currentCert = $oldcert; - $this->signatureSubject = $oldsigsubj; - - return true; - } - - /** - * Validate an X.509 certificate against a URL - * - * From RFC2818 "HTTP over TLS": - * - * Matching is performed using the matching rules specified by - * [RFC2459]. If more than one identity of a given type is present in - * the certificate (e.g., more than one dNSName name, a match in any one - * of the set is considered acceptable.) Names may contain the wildcard - * character * which is considered to match any single domain name - * component or component fragment. E.g., *.a.com matches foo.a.com but - * not bar.foo.a.com. f*.com matches foo.com but not bar.com. - * - * @param string $url - * @access public - * @return bool - */ - function validateURL($url) - { - if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) { - return false; - } - - $components = parse_url($url); - if (!isset($components['host'])) { - return false; - } - - if ($names = $this->getExtension('id-ce-subjectAltName')) { - foreach ($names as $key => $value) { - $value = str_replace(array('.', '*'), array('\.', '[^.]*'), $value); - switch ($key) { - case 'dNSName': - /* From RFC2818 "HTTP over TLS": - - If a subjectAltName extension of type dNSName is present, that MUST - be used as the identity. Otherwise, the (most specific) Common Name - field in the Subject field of the certificate MUST be used. Although - the use of the Common Name is existing practice, it is deprecated and - Certification Authorities are encouraged to use the dNSName instead. */ - if (preg_match('#^' . $value . '$#', $components['host'])) { - return true; - } - break; - case 'iPAddress': - /* From RFC2818 "HTTP over TLS": - - In some cases, the URI is specified as an IP address rather than a - hostname. In this case, the iPAddress subjectAltName must be present - in the certificate and must exactly match the IP in the URI. */ - if (preg_match('#(?:\d{1-3}\.){4}#', $components['host'] . '.') && preg_match('#^' . $value . '$#', $components['host'])) { - return true; - } - } - } - return false; - } - - if ($value = $this->getDNProp('id-at-commonName')) { - $value = str_replace(array('.', '*'), array('\.', '[^.]*'), $value[0]); - return preg_match('#^' . $value . '$#', $components['host']); - } - - return false; - } - - /** - * Validate a date - * - * If $date isn't defined it is assumed to be the current date. - * - * @param int $date optional - * @access public - */ - function validateDate($date = null) - { - if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) { - return false; - } - - if (!isset($date)) { - $date = time(); - } - - $notBefore = $this->currentCert['tbsCertificate']['validity']['notBefore']; - $notBefore = isset($notBefore['generalTime']) ? $notBefore['generalTime'] : $notBefore['utcTime']; - - $notAfter = $this->currentCert['tbsCertificate']['validity']['notAfter']; - $notAfter = isset($notAfter['generalTime']) ? $notAfter['generalTime'] : $notAfter['utcTime']; - - switch (true) { - case $date < @strtotime($notBefore): - case $date > @strtotime($notAfter): - return false; - } - - return true; - } - - /** - * Validate a signature - * - * Works on X.509 certs, CSR's and CRL's. - * Returns true if the signature is verified, false if it is not correct or null on error - * - * By default returns false for self-signed certs. Call validateSignature(false) to make this support - * self-signed. - * - * The behavior of this function is inspired by {@link http://php.net/openssl-verify openssl_verify}. - * - * @param bool $caonly optional - * @access public - * @return mixed - */ - function validateSignature($caonly = true) - { - if (!is_array($this->currentCert) || !isset($this->signatureSubject)) { - return null; - } - - /* TODO: - "emailAddress attribute values are not case-sensitive (e.g., "subscriber@example.com" is the same as "SUBSCRIBER@EXAMPLE.COM")." - -- http://tools.ietf.org/html/rfc5280#section-4.1.2.6 - - implement pathLenConstraint in the id-ce-basicConstraints extension */ - - switch (true) { - case isset($this->currentCert['tbsCertificate']): - // self-signed cert - if ($this->currentCert['tbsCertificate']['issuer'] === $this->currentCert['tbsCertificate']['subject']) { - $authorityKey = $this->getExtension('id-ce-authorityKeyIdentifier'); - $subjectKeyID = $this->getExtension('id-ce-subjectKeyIdentifier'); - switch (true) { - case !is_array($authorityKey): - case is_array($authorityKey) && isset($authorityKey['keyIdentifier']) && $authorityKey['keyIdentifier'] === $subjectKeyID: - $signingCert = $this->currentCert; // working cert - } - } - - if (!empty($this->CAs)) { - for ($i = 0; $i < count($this->CAs); $i++) { - // even if the cert is a self-signed one we still want to see if it's a CA; - // if not, we'll conditionally return an error - $ca = $this->CAs[$i]; - if ($this->currentCert['tbsCertificate']['issuer'] === $ca['tbsCertificate']['subject']) { - $authorityKey = $this->getExtension('id-ce-authorityKeyIdentifier'); - $subjectKeyID = $this->getExtension('id-ce-subjectKeyIdentifier', $ca); - switch (true) { - case !is_array($authorityKey): - case is_array($authorityKey) && isset($authorityKey['keyIdentifier']) && $authorityKey['keyIdentifier'] === $subjectKeyID: - $signingCert = $ca; // working cert - break 2; - } - } - } - if (count($this->CAs) == $i && $caonly) { - return false; - } - } elseif (!isset($signingCert) || $caonly) { - return false; - } - return $this->_validateSignature( - $signingCert['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['algorithm'], - $signingCert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'], - $this->currentCert['signatureAlgorithm']['algorithm'], - substr(base64_decode($this->currentCert['signature']), 1), - $this->signatureSubject - ); - case isset($this->currentCert['certificationRequestInfo']): - return $this->_validateSignature( - $this->currentCert['certificationRequestInfo']['subjectPKInfo']['algorithm']['algorithm'], - $this->currentCert['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'], - $this->currentCert['signatureAlgorithm']['algorithm'], - substr(base64_decode($this->currentCert['signature']), 1), - $this->signatureSubject - ); - case isset($this->currentCert['publicKeyAndChallenge']): - return $this->_validateSignature( - $this->currentCert['publicKeyAndChallenge']['spki']['algorithm']['algorithm'], - $this->currentCert['publicKeyAndChallenge']['spki']['subjectPublicKey'], - $this->currentCert['signatureAlgorithm']['algorithm'], - substr(base64_decode($this->currentCert['signature']), 1), - $this->signatureSubject - ); - case isset($this->currentCert['tbsCertList']): - if (!empty($this->CAs)) { - for ($i = 0; $i < count($this->CAs); $i++) { - $ca = $this->CAs[$i]; - if ($this->currentCert['tbsCertList']['issuer'] === $ca['tbsCertificate']['subject']) { - $authorityKey = $this->getExtension('id-ce-authorityKeyIdentifier'); - $subjectKeyID = $this->getExtension('id-ce-subjectKeyIdentifier', $ca); - switch (true) { - case !is_array($authorityKey): - case is_array($authorityKey) && isset($authorityKey['keyIdentifier']) && $authorityKey['keyIdentifier'] === $subjectKeyID: - $signingCert = $ca; // working cert - break 2; - } - } - } - } - if (!isset($signingCert)) { - return false; - } - return $this->_validateSignature( - $signingCert['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['algorithm'], - $signingCert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'], - $this->currentCert['signatureAlgorithm']['algorithm'], - substr(base64_decode($this->currentCert['signature']), 1), - $this->signatureSubject - ); - default: - return false; - } - } - - /** - * Validates a signature - * - * Returns true if the signature is verified, false if it is not correct or null on error - * - * @param string $publicKeyAlgorithm - * @param string $publicKey - * @param string $signatureAlgorithm - * @param string $signature - * @param string $signatureSubject - * @access private - * @return int - */ - function _validateSignature($publicKeyAlgorithm, $publicKey, $signatureAlgorithm, $signature, $signatureSubject) - { - switch ($publicKeyAlgorithm) { - case 'rsaEncryption': - $rsa = new RSA(); - $rsa->loadKey($publicKey); - - switch ($signatureAlgorithm) { - case 'md2WithRSAEncryption': - case 'md5WithRSAEncryption': - case 'sha1WithRSAEncryption': - case 'sha224WithRSAEncryption': - case 'sha256WithRSAEncryption': - case 'sha384WithRSAEncryption': - case 'sha512WithRSAEncryption': - $rsa->setHash(preg_replace('#WithRSAEncryption$#', '', $signatureAlgorithm)); - $rsa->setSignatureMode(RSA::SIGNATURE_PKCS1); - if (!@$rsa->verify($signatureSubject, $signature)) { - return false; - } - break; - default: - return null; - } - break; - default: - return null; - } - - return true; - } - - /** - * Reformat public keys - * - * Reformats a public key to a format supported by phpseclib (if applicable) - * - * @param string $algorithm - * @param string $key - * @access private - * @return string - */ - function _reformatKey($algorithm, $key) - { - switch ($algorithm) { - case 'rsaEncryption': - return - "-----BEGIN RSA PUBLIC KEY-----\r\n" . - // subjectPublicKey is stored as a bit string in X.509 certs. the first byte of a bit string represents how many bits - // in the last byte should be ignored. the following only supports non-zero stuff but as none of the X.509 certs Firefox - // uses as a cert authority actually use a non-zero bit I think it's safe to assume that none do. - chunk_split(base64_encode(substr(base64_decode($key), 1)), 64) . - '-----END RSA PUBLIC KEY-----'; - default: - return $key; - } - } - - /** - * Decodes an IP address - * - * Takes in a base64 encoded "blob" and returns a human readable IP address - * - * @param string $ip - * @access private - * @return string - */ - function _decodeIP($ip) - { - $ip = base64_decode($ip); - list(, $ip) = unpack('N', $ip); - return long2ip($ip); - } - - /** - * Encodes an IP address - * - * Takes a human readable IP address into a base64-encoded "blob" - * - * @param string $ip - * @access private - * @return string - */ - function _encodeIP($ip) - { - return base64_encode(pack('N', ip2long($ip))); - } - - /** - * "Normalizes" a Distinguished Name property - * - * @param string $propName - * @access private - * @return mixed - */ - function _translateDNProp($propName) - { - switch (strtolower($propName)) { - case 'id-at-countryname': - case 'countryname': - case 'c': - return 'id-at-countryName'; - case 'id-at-organizationname': - case 'organizationname': - case 'o': - return 'id-at-organizationName'; - case 'id-at-dnqualifier': - case 'dnqualifier': - return 'id-at-dnQualifier'; - case 'id-at-commonname': - case 'commonname': - case 'cn': - return 'id-at-commonName'; - case 'id-at-stateorprovincename': - case 'stateorprovincename': - case 'state': - case 'province': - case 'provincename': - case 'st': - return 'id-at-stateOrProvinceName'; - case 'id-at-localityname': - case 'localityname': - case 'l': - return 'id-at-localityName'; - case 'id-emailaddress': - case 'emailaddress': - return 'pkcs-9-at-emailAddress'; - case 'id-at-serialnumber': - case 'serialnumber': - return 'id-at-serialNumber'; - case 'id-at-postalcode': - case 'postalcode': - return 'id-at-postalCode'; - case 'id-at-streetaddress': - case 'streetaddress': - return 'id-at-streetAddress'; - case 'id-at-name': - case 'name': - return 'id-at-name'; - case 'id-at-givenname': - case 'givenname': - return 'id-at-givenName'; - case 'id-at-surname': - case 'surname': - case 'sn': - return 'id-at-surname'; - case 'id-at-initials': - case 'initials': - return 'id-at-initials'; - case 'id-at-generationqualifier': - case 'generationqualifier': - return 'id-at-generationQualifier'; - case 'id-at-organizationalunitname': - case 'organizationalunitname': - case 'ou': - return 'id-at-organizationalUnitName'; - case 'id-at-pseudonym': - case 'pseudonym': - return 'id-at-pseudonym'; - case 'id-at-title': - case 'title': - return 'id-at-title'; - case 'id-at-description': - case 'description': - return 'id-at-description'; - case 'id-at-role': - case 'role': - return 'id-at-role'; - case 'id-at-uniqueidentifier': - case 'uniqueidentifier': - case 'x500uniqueidentifier': - return 'id-at-uniqueIdentifier'; - default: - return false; - } - } - - /** - * Set a Distinguished Name property - * - * @param string $propName - * @param mixed $propValue - * @param string $type optional - * @access public - * @return bool - */ - function setDNProp($propName, $propValue, $type = 'utf8String') - { - if (empty($this->dn)) { - $this->dn = array('rdnSequence' => array()); - } - - if (($propName = $this->_translateDNProp($propName)) === false) { - return false; - } - - foreach ((array) $propValue as $v) { - if (!is_array($v) && isset($type)) { - $v = array($type => $v); - } - $this->dn['rdnSequence'][] = array( - array( - 'type' => $propName, - 'value'=> $v - ) - ); - } - - return true; - } - - /** - * Remove Distinguished Name properties - * - * @param string $propName - * @access public - */ - function removeDNProp($propName) - { - if (empty($this->dn)) { - return; - } - - if (($propName = $this->_translateDNProp($propName)) === false) { - return; - } - - $dn = &$this->dn['rdnSequence']; - $size = count($dn); - for ($i = 0; $i < $size; $i++) { - if ($dn[$i][0]['type'] == $propName) { - unset($dn[$i]); - } - } - - $dn = array_values($dn); - } - - /** - * Get Distinguished Name properties - * - * @param string $propName - * @param array $dn optional - * @param bool $withType optional - * @return mixed - * @access public - */ - function getDNProp($propName, $dn = null, $withType = false) - { - if (!isset($dn)) { - $dn = $this->dn; - } - - if (empty($dn)) { - return false; - } - - if (($propName = $this->_translateDNProp($propName)) === false) { - return false; - } - - $dn = $dn['rdnSequence']; - $result = array(); - $asn1 = new ASN1(); - for ($i = 0; $i < count($dn); $i++) { - if ($dn[$i][0]['type'] == $propName) { - $v = $dn[$i][0]['value']; - if (!$withType && is_array($v)) { - foreach ($v as $type => $s) { - $type = array_search($type, $asn1->ANYmap, true); - if ($type !== false && isset($asn1->stringTypeSize[$type])) { - $s = $asn1->convert($s, $type); - if ($s !== false) { - $v = $s; - break; - } - } - } - if (is_array($v)) { - $v = array_pop($v); // Always strip data type. - } - } - $result[] = $v; - } - } - - return $result; - } - - /** - * Set a Distinguished Name - * - * @param mixed $dn - * @param bool $merge optional - * @param string $type optional - * @access public - * @return bool - */ - function setDN($dn, $merge = false, $type = 'utf8String') - { - if (!$merge) { - $this->dn = null; - } - - if (is_array($dn)) { - if (isset($dn['rdnSequence'])) { - $this->dn = $dn; // No merge here. - return true; - } - - // handles stuff generated by openssl_x509_parse() - foreach ($dn as $prop => $value) { - if (!$this->setDNProp($prop, $value, $type)) { - return false; - } - } - return true; - } - - // handles everything else - $results = preg_split('#((?:^|, *|/)(?:C=|O=|OU=|CN=|L=|ST=|SN=|postalCode=|streetAddress=|emailAddress=|serialNumber=|organizationalUnitName=|title=|description=|role=|x500UniqueIdentifier=))#', $dn, -1, PREG_SPLIT_DELIM_CAPTURE); - for ($i = 1; $i < count($results); $i+=2) { - $prop = trim($results[$i], ', =/'); - $value = $results[$i + 1]; - if (!$this->setDNProp($prop, $value, $type)) { - return false; - } - } - - return true; - } - - /** - * Get the Distinguished Name for a certificates subject - * - * @param mixed $format optional - * @param array $dn optional - * @access public - * @return bool - */ - function getDN($format = self::DN_ARRAY, $dn = null) - { - if (!isset($dn)) { - $dn = isset($this->currentCert['tbsCertList']) ? $this->currentCert['tbsCertList']['issuer'] : $this->dn; - } - - switch ((int) $format) { - case self::DN_ARRAY: - return $dn; - case self::DN_ASN1: - $asn1 = new ASN1(); - $asn1->loadOIDs($this->oids); - $filters = array(); - $filters['rdnSequence']['value'] = array('type' => ASN1::TYPE_UTF8_STRING); - $asn1->loadFilters($filters); - return $asn1->encodeDER($dn, $this->Name); - case self::DN_OPENSSL: - $dn = $this->getDN(self::DN_STRING, $dn); - if ($dn === false) { - return false; - } - $attrs = preg_split('#((?:^|, *|/)[a-z][a-z0-9]*=)#i', $dn, -1, PREG_SPLIT_DELIM_CAPTURE); - $dn = array(); - for ($i = 1; $i < count($attrs); $i += 2) { - $prop = trim($attrs[$i], ', =/'); - $value = $attrs[$i + 1]; - if (!isset($dn[$prop])) { - $dn[$prop] = $value; - } else { - $dn[$prop] = array_merge((array) $dn[$prop], array($value)); - } - } - return $dn; - case self::DN_CANON: - // No SEQUENCE around RDNs and all string values normalized as - // trimmed lowercase UTF-8 with all spacing as one blank. - $asn1 = new ASN1(); - $asn1->loadOIDs($this->oids); - $filters = array(); - $filters['value'] = array('type' => ASN1::TYPE_UTF8_STRING); - $asn1->loadFilters($filters); - $result = ''; - foreach ($dn['rdnSequence'] as $rdn) { - foreach ($rdn as $i => $attr) { - $attr = &$rdn[$i]; - if (is_array($attr['value'])) { - foreach ($attr['value'] as $type => $v) { - $type = array_search($type, $asn1->ANYmap, true); - if ($type !== false && isset($asn1->stringTypeSize[$type])) { - $v = $asn1->convert($v, $type); - if ($v !== false) { - $v = preg_replace('/\s+/', ' ', $v); - $attr['value'] = strtolower(trim($v)); - break; - } - } - } - } - } - $result .= $asn1->encodeDER($rdn, $this->RelativeDistinguishedName); - } - return $result; - case self::DN_HASH: - $dn = $this->getDN(self::DN_CANON, $dn); - $hash = new Hash('sha1'); - $hash = $hash->hash($dn); - extract(unpack('Vhash', $hash)); - return strtolower(bin2hex(pack('N', $hash))); - } - - // Default is to return a string. - $start = true; - $output = ''; - $asn1 = new ASN1(); - foreach ($dn['rdnSequence'] as $field) { - $prop = $field[0]['type']; - $value = $field[0]['value']; - - $delim = ', '; - switch ($prop) { - case 'id-at-countryName': - $desc = 'C='; - break; - case 'id-at-stateOrProvinceName': - $desc = 'ST='; - break; - case 'id-at-organizationName': - $desc = 'O='; - break; - case 'id-at-organizationalUnitName': - $desc = 'OU='; - break; - case 'id-at-commonName': - $desc = 'CN='; - break; - case 'id-at-localityName': - $desc = 'L='; - break; - case 'id-at-surname': - $desc = 'SN='; - break; - case 'id-at-uniqueIdentifier': - $delim = '/'; - $desc = 'x500UniqueIdentifier='; - break; - default: - $delim = '/'; - $desc = preg_replace('#.+-([^-]+)$#', '$1', $prop) . '='; - } - - if (!$start) { - $output.= $delim; - } - if (is_array($value)) { - foreach ($value as $type => $v) { - $type = array_search($type, $asn1->ANYmap, true); - if ($type !== false && isset($asn1->stringTypeSize[$type])) { - $v = $asn1->convert($v, $type); - if ($v !== false) { - $value = $v; - break; - } - } - } - if (is_array($value)) { - $value = array_pop($value); // Always strip data type. - } - } - $output.= $desc . $value; - $start = false; - } - - return $output; - } - - /** - * Get the Distinguished Name for a certificate/crl issuer - * - * @param int $format optional - * @access public - * @return mixed - */ - function getIssuerDN($format = self::DN_ARRAY) - { - switch (true) { - case !isset($this->currentCert) || !is_array($this->currentCert): - break; - case isset($this->currentCert['tbsCertificate']): - return $this->getDN($format, $this->currentCert['tbsCertificate']['issuer']); - case isset($this->currentCert['tbsCertList']): - return $this->getDN($format, $this->currentCert['tbsCertList']['issuer']); - } - - return false; - } - - /** - * Get the Distinguished Name for a certificate/csr subject - * Alias of getDN() - * - * @param int $format optional - * @access public - * @return mixed - */ - function getSubjectDN($format = self::DN_ARRAY) - { - switch (true) { - case !empty($this->dn): - return $this->getDN($format); - case !isset($this->currentCert) || !is_array($this->currentCert): - break; - case isset($this->currentCert['tbsCertificate']): - return $this->getDN($format, $this->currentCert['tbsCertificate']['subject']); - case isset($this->currentCert['certificationRequestInfo']): - return $this->getDN($format, $this->currentCert['certificationRequestInfo']['subject']); - } - - return false; - } - - /** - * Get an individual Distinguished Name property for a certificate/crl issuer - * - * @param string $propName - * @param bool $withType optional - * @access public - * @return mixed - */ - function getIssuerDNProp($propName, $withType = false) - { - switch (true) { - case !isset($this->currentCert) || !is_array($this->currentCert): - break; - case isset($this->currentCert['tbsCertificate']): - return $this->getDNProp($propName, $this->currentCert['tbsCertificate']['issuer'], $withType); - case isset($this->currentCert['tbsCertList']): - return $this->getDNProp($propName, $this->currentCert['tbsCertList']['issuer'], $withType); - } - - return false; - } - - /** - * Get an individual Distinguished Name property for a certificate/csr subject - * - * @param string $propName - * @param bool $withType optional - * @access public - * @return mixed - */ - function getSubjectDNProp($propName, $withType = false) - { - switch (true) { - case !empty($this->dn): - return $this->getDNProp($propName, null, $withType); - case !isset($this->currentCert) || !is_array($this->currentCert): - break; - case isset($this->currentCert['tbsCertificate']): - return $this->getDNProp($propName, $this->currentCert['tbsCertificate']['subject'], $withType); - case isset($this->currentCert['certificationRequestInfo']): - return $this->getDNProp($propName, $this->currentCert['certificationRequestInfo']['subject'], $withType); - } - - return false; - } - - /** - * Get the certificate chain for the current cert - * - * @access public - * @return mixed - */ - function getChain() - { - $chain = array($this->currentCert); - - if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) { - return false; - } - if (empty($this->CAs)) { - return $chain; - } - while (true) { - $currentCert = $chain[count($chain) - 1]; - for ($i = 0; $i < count($this->CAs); $i++) { - $ca = $this->CAs[$i]; - if ($currentCert['tbsCertificate']['issuer'] === $ca['tbsCertificate']['subject']) { - $authorityKey = $this->getExtension('id-ce-authorityKeyIdentifier', $currentCert); - $subjectKeyID = $this->getExtension('id-ce-subjectKeyIdentifier', $ca); - switch (true) { - case !is_array($authorityKey): - case is_array($authorityKey) && isset($authorityKey['keyIdentifier']) && $authorityKey['keyIdentifier'] === $subjectKeyID: - if ($currentCert === $ca) { - break 3; - } - $chain[] = $ca; - break 2; - } - } - } - if ($i == count($this->CAs)) { - break; - } - } - foreach ($chain as $key => $value) { - $chain[$key] = new X509(); - $chain[$key]->loadX509($value); - } - return $chain; - } - - /** - * Set public key - * - * Key needs to be a \phpseclib\Crypt\RSA object - * - * @param object $key - * @access public - * @return bool - */ - function setPublicKey($key) - { - $key->setPublicKey(); - $this->publicKey = $key; - } - - /** - * Set private key - * - * Key needs to be a \phpseclib\Crypt\RSA object - * - * @param object $key - * @access public - */ - function setPrivateKey($key) - { - $this->privateKey = $key; - } - - /** - * Set challenge - * - * Used for SPKAC CSR's - * - * @param string $challenge - * @access public - */ - function setChallenge($challenge) - { - $this->challenge = $challenge; - } - - /** - * Gets the public key - * - * Returns a \phpseclib\Crypt\RSA object or a false. - * - * @access public - * @return mixed - */ - function getPublicKey() - { - if (isset($this->publicKey)) { - return $this->publicKey; - } - - if (isset($this->currentCert) && is_array($this->currentCert)) { - foreach (array('tbsCertificate/subjectPublicKeyInfo', 'certificationRequestInfo/subjectPKInfo') as $path) { - $keyinfo = $this->_subArray($this->currentCert, $path); - if (!empty($keyinfo)) { - break; - } - } - } - if (empty($keyinfo)) { - return false; - } - - $key = $keyinfo['subjectPublicKey']; - - switch ($keyinfo['algorithm']['algorithm']) { - case 'rsaEncryption': - $publicKey = new RSA(); - $publicKey->loadKey($key); - $publicKey->setPublicKey(); - break; - default: - return false; - } - - return $publicKey; - } - - /** - * Load a Certificate Signing Request - * - * @param string $csr - * @access public - * @return mixed - */ - function loadCSR($csr, $mode = self::FORMAT_AUTO_DETECT) - { - if (is_array($csr) && isset($csr['certificationRequestInfo'])) { - unset($this->currentCert); - unset($this->currentKeyIdentifier); - unset($this->signatureSubject); - $this->dn = $csr['certificationRequestInfo']['subject']; - if (!isset($this->dn)) { - return false; - } - - $this->currentCert = $csr; - return $csr; - } - - // see http://tools.ietf.org/html/rfc2986 - - $asn1 = new ASN1(); - - if ($mode != self::FORMAT_DER) { - $newcsr = $this->_extractBER($csr); - if ($mode == self::FORMAT_PEM && $csr == $newcsr) { - return false; - } - $csr = $newcsr; - } - $orig = $csr; - - if ($csr === false) { - $this->currentCert = false; - return false; - } - - $asn1->loadOIDs($this->oids); - $decoded = $asn1->decodeBER($csr); - - if (empty($decoded)) { - $this->currentCert = false; - return false; - } - - $csr = $asn1->asn1map($decoded[0], $this->CertificationRequest); - if (!isset($csr) || $csr === false) { - $this->currentCert = false; - return false; - } - - $this->dn = $csr['certificationRequestInfo']['subject']; - $this->_mapInAttributes($csr, 'certificationRequestInfo/attributes', $asn1); - - $this->signatureSubject = substr($orig, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']); - - $algorithm = &$csr['certificationRequestInfo']['subjectPKInfo']['algorithm']['algorithm']; - $key = &$csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']; - $key = $this->_reformatKey($algorithm, $key); - - switch ($algorithm) { - case 'rsaEncryption': - $this->publicKey = new RSA(); - $this->publicKey->loadKey($key); - $this->publicKey->setPublicKey(); - break; - default: - $this->publicKey = null; - } - - $this->currentKeyIdentifier = null; - $this->currentCert = $csr; - - return $csr; - } - - /** - * Save CSR request - * - * @param array $csr - * @param int $format optional - * @access public - * @return string - */ - function saveCSR($csr, $format = self::FORMAT_PEM) - { - if (!is_array($csr) || !isset($csr['certificationRequestInfo'])) { - return false; - } - - switch (true) { - case !($algorithm = $this->_subArray($csr, 'certificationRequestInfo/subjectPKInfo/algorithm/algorithm')): - case is_object($csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']): - break; - default: - switch ($algorithm) { - case 'rsaEncryption': - $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'] - = base64_encode("\0" . base64_decode(preg_replace('#-.+-|[\r\n]#', '', $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']))); - } - } - - $asn1 = new ASN1(); - - $asn1->loadOIDs($this->oids); - - $filters = array(); - $filters['certificationRequestInfo']['subject']['rdnSequence']['value'] - = array('type' => ASN1::TYPE_UTF8_STRING); - - $asn1->loadFilters($filters); - - $this->_mapOutAttributes($csr, 'certificationRequestInfo/attributes', $asn1); - $csr = $asn1->encodeDER($csr, $this->CertificationRequest); - - switch ($format) { - case self::FORMAT_DER: - return $csr; - // case self::FORMAT_PEM: - default: - return "-----BEGIN CERTIFICATE REQUEST-----\r\n" . chunk_split(base64_encode($csr), 64) . '-----END CERTIFICATE REQUEST-----'; - } - } - - /** - * Load a SPKAC CSR - * - * SPKAC's are produced by the HTML5 keygen element: - * - * https://developer.mozilla.org/en-US/docs/HTML/Element/keygen - * - * @param string $csr - * @access public - * @return mixed - */ - function loadSPKAC($spkac) - { - if (is_array($spkac) && isset($spkac['publicKeyAndChallenge'])) { - unset($this->currentCert); - unset($this->currentKeyIdentifier); - unset($this->signatureSubject); - $this->currentCert = $spkac; - return $spkac; - } - - // see http://www.w3.org/html/wg/drafts/html/master/forms.html#signedpublickeyandchallenge - - $asn1 = new ASN1(); - - // OpenSSL produces SPKAC's that are preceeded by the string SPKAC= - $temp = preg_replace('#(?:SPKAC=)|[ \r\n\\\]#', '', $spkac); - $temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? base64_decode($temp) : false; - if ($temp != false) { - $spkac = $temp; - } - $orig = $spkac; - - if ($spkac === false) { - $this->currentCert = false; - return false; - } - - $asn1->loadOIDs($this->oids); - $decoded = $asn1->decodeBER($spkac); - - if (empty($decoded)) { - $this->currentCert = false; - return false; - } - - $spkac = $asn1->asn1map($decoded[0], $this->SignedPublicKeyAndChallenge); - - if (!isset($spkac) || $spkac === false) { - $this->currentCert = false; - return false; - } - - $this->signatureSubject = substr($orig, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']); - - $algorithm = &$spkac['publicKeyAndChallenge']['spki']['algorithm']['algorithm']; - $key = &$spkac['publicKeyAndChallenge']['spki']['subjectPublicKey']; - $key = $this->_reformatKey($algorithm, $key); - - switch ($algorithm) { - case 'rsaEncryption': - $this->publicKey = new RSA(); - $this->publicKey->loadKey($key); - $this->publicKey->setPublicKey(); - break; - default: - $this->publicKey = null; - } - - $this->currentKeyIdentifier = null; - $this->currentCert = $spkac; - - return $spkac; - } - - /** - * Save a SPKAC CSR request - * - * @param array $csr - * @param int $format optional - * @access public - * @return string - */ - function saveSPKAC($spkac, $format = self::FORMAT_PEM) - { - if (!is_array($spkac) || !isset($spkac['publicKeyAndChallenge'])) { - return false; - } - - $algorithm = $this->_subArray($spkac, 'publicKeyAndChallenge/spki/algorithm/algorithm'); - switch (true) { - case !$algorithm: - case is_object($spkac['publicKeyAndChallenge']['spki']['subjectPublicKey']): - break; - default: - switch ($algorithm) { - case 'rsaEncryption': - $spkac['publicKeyAndChallenge']['spki']['subjectPublicKey'] - = base64_encode("\0" . base64_decode(preg_replace('#-.+-|[\r\n]#', '', $spkac['publicKeyAndChallenge']['spki']['subjectPublicKey']))); - } - } - - $asn1 = new ASN1(); - - $asn1->loadOIDs($this->oids); - $spkac = $asn1->encodeDER($spkac, $this->SignedPublicKeyAndChallenge); - - switch ($format) { - case self::FORMAT_DER: - return $spkac; - // case self::FORMAT_PEM: - default: - // OpenSSL's implementation of SPKAC requires the SPKAC be preceeded by SPKAC= and since there are pretty much - // no other SPKAC decoders phpseclib will use that same format - return 'SPKAC=' . base64_encode($spkac); - } - } - - /** - * Load a Certificate Revocation List - * - * @param string $crl - * @access public - * @return mixed - */ - function loadCRL($crl, $mode = self::FORMAT_AUTO_DETECT) - { - if (is_array($crl) && isset($crl['tbsCertList'])) { - $this->currentCert = $crl; - unset($this->signatureSubject); - return $crl; - } - - $asn1 = new ASN1(); - - if ($mode != self::FORMAT_DER) { - $newcrl = $this->_extractBER($crl); - if ($mode == self::FORMAT_PEM && $crl == $newcrl) { - return false; - } - $crl = $newcrl; - } - $orig = $crl; - - if ($crl === false) { - $this->currentCert = false; - return false; - } - - $asn1->loadOIDs($this->oids); - $decoded = $asn1->decodeBER($crl); - - if (empty($decoded)) { - $this->currentCert = false; - return false; - } - - $crl = $asn1->asn1map($decoded[0], $this->CertificateList); - if (!isset($crl) || $crl === false) { - $this->currentCert = false; - return false; - } - - $this->signatureSubject = substr($orig, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']); - - $this->_mapInExtensions($crl, 'tbsCertList/crlExtensions', $asn1); - $rclist = &$this->_subArray($crl, 'tbsCertList/revokedCertificates'); - if (is_array($rclist)) { - foreach ($rclist as $i => $extension) { - $this->_mapInExtensions($rclist, "$i/crlEntryExtensions", $asn1); - } - } - - $this->currentKeyIdentifier = null; - $this->currentCert = $crl; - - return $crl; - } - - /** - * Save Certificate Revocation List. - * - * @param array $crl - * @param int $format optional - * @access public - * @return string - */ - function saveCRL($crl, $format = self::FORMAT_PEM) - { - if (!is_array($crl) || !isset($crl['tbsCertList'])) { - return false; - } - - $asn1 = new ASN1(); - - $asn1->loadOIDs($this->oids); - - $filters = array(); - $filters['tbsCertList']['issuer']['rdnSequence']['value'] - = array('type' => ASN1::TYPE_UTF8_STRING); - $filters['tbsCertList']['signature']['parameters'] - = array('type' => ASN1::TYPE_UTF8_STRING); - $filters['signatureAlgorithm']['parameters'] - = array('type' => ASN1::TYPE_UTF8_STRING); - - if (empty($crl['tbsCertList']['signature']['parameters'])) { - $filters['tbsCertList']['signature']['parameters'] - = array('type' => ASN1::TYPE_NULL); - } - - if (empty($crl['signatureAlgorithm']['parameters'])) { - $filters['signatureAlgorithm']['parameters'] - = array('type' => ASN1::TYPE_NULL); - } - - $asn1->loadFilters($filters); - - $this->_mapOutExtensions($crl, 'tbsCertList/crlExtensions', $asn1); - $rclist = &$this->_subArray($crl, 'tbsCertList/revokedCertificates'); - if (is_array($rclist)) { - foreach ($rclist as $i => $extension) { - $this->_mapOutExtensions($rclist, "$i/crlEntryExtensions", $asn1); - } - } - - $crl = $asn1->encodeDER($crl, $this->CertificateList); - - switch ($format) { - case self::FORMAT_DER: - return $crl; - // case self::FORMAT_PEM: - default: - return "-----BEGIN X509 CRL-----\r\n" . chunk_split(base64_encode($crl), 64) . '-----END X509 CRL-----'; - } - } - - /** - * Helper function to build a time field according to RFC 3280 section - * - 4.1.2.5 Validity - * - 5.1.2.4 This Update - * - 5.1.2.5 Next Update - * - 5.1.2.6 Revoked Certificates - * by choosing utcTime iff year of date given is before 2050 and generalTime else. - * - * @param string $date in format date('D, d M Y H:i:s O') - * @access private - * @return array - */ - function _timeField($date) - { - $year = @gmdate("Y", @strtotime($date)); // the same way ASN1.php parses this - if ($year < 2050) { - return array('utcTime' => $date); - } else { - return array('generalTime' => $date); - } - } - - /** - * Sign an X.509 certificate - * - * $issuer's private key needs to be loaded. - * $subject can be either an existing X.509 cert (if you want to resign it), - * a CSR or something with the DN and public key explicitly set. - * - * @param \phpseclib\File\X509 $issuer - * @param \phpseclib\File\X509 $subject - * @param string $signatureAlgorithm optional - * @access public - * @return mixed - */ - function sign($issuer, $subject, $signatureAlgorithm = 'sha1WithRSAEncryption') - { - if (!is_object($issuer->privateKey) || empty($issuer->dn)) { - return false; - } - - if (isset($subject->publicKey) && !($subjectPublicKey = $subject->_formatSubjectPublicKey())) { - return false; - } - - $currentCert = isset($this->currentCert) ? $this->currentCert : null; - $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: null; - - if (isset($subject->currentCert) && is_array($subject->currentCert) && isset($subject->currentCert['tbsCertificate'])) { - $this->currentCert = $subject->currentCert; - $this->currentCert['tbsCertificate']['signature']['algorithm'] = $signatureAlgorithm; - $this->currentCert['signatureAlgorithm']['algorithm'] = $signatureAlgorithm; - - if (!empty($this->startDate)) { - $this->currentCert['tbsCertificate']['validity']['notBefore'] = $this->_timeField($this->startDate); - } - if (!empty($this->endDate)) { - $this->currentCert['tbsCertificate']['validity']['notAfter'] = $this->_timeField($this->endDate); - } - if (!empty($this->serialNumber)) { - $this->currentCert['tbsCertificate']['serialNumber'] = $this->serialNumber; - } - if (!empty($subject->dn)) { - $this->currentCert['tbsCertificate']['subject'] = $subject->dn; - } - if (!empty($subject->publicKey)) { - $this->currentCert['tbsCertificate']['subjectPublicKeyInfo'] = $subjectPublicKey; - } - $this->removeExtension('id-ce-authorityKeyIdentifier'); - if (isset($subject->domains)) { - $this->removeExtension('id-ce-subjectAltName'); - } - } elseif (isset($subject->currentCert) && is_array($subject->currentCert) && isset($subject->currentCert['tbsCertList'])) { - return false; - } else { - if (!isset($subject->publicKey)) { - return false; - } - - $startDate = !empty($this->startDate) ? $this->startDate : @date('D, d M Y H:i:s O'); - $endDate = !empty($this->endDate) ? $this->endDate : @date('D, d M Y H:i:s O', strtotime('+1 year')); - /* "The serial number MUST be a positive integer" - "Conforming CAs MUST NOT use serialNumber values longer than 20 octets." - -- https://tools.ietf.org/html/rfc5280#section-4.1.2.2 - - for the integer to be positive the leading bit needs to be 0 hence the - application of a bitmap - */ - $serialNumber = !empty($this->serialNumber) ? - $this->serialNumber : - new BigInteger(Random::string(20) & ("\x7F" . str_repeat("\xFF", 19)), 256); - - $this->currentCert = array( - 'tbsCertificate' => - array( - 'version' => 'v3', - 'serialNumber' => $serialNumber, // $this->setserialNumber() - 'signature' => array('algorithm' => $signatureAlgorithm), - 'issuer' => false, // this is going to be overwritten later - 'validity' => array( - 'notBefore' => $this->_timeField($startDate), // $this->setStartDate() - 'notAfter' => $this->_timeField($endDate) // $this->setEndDate() - ), - 'subject' => $subject->dn, - 'subjectPublicKeyInfo' => $subjectPublicKey - ), - 'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm), - 'signature' => false // this is going to be overwritten later - ); - - // Copy extensions from CSR. - $csrexts = $subject->getAttribute('pkcs-9-at-extensionRequest', 0); - - if (!empty($csrexts)) { - $this->currentCert['tbsCertificate']['extensions'] = $csrexts; - } - } - - $this->currentCert['tbsCertificate']['issuer'] = $issuer->dn; - - if (isset($issuer->currentKeyIdentifier)) { - $this->setExtension('id-ce-authorityKeyIdentifier', array( - //'authorityCertIssuer' => array( - // array( - // 'directoryName' => $issuer->dn - // ) - //), - 'keyIdentifier' => $issuer->currentKeyIdentifier - )); - //$extensions = &$this->currentCert['tbsCertificate']['extensions']; - //if (isset($issuer->serialNumber)) { - // $extensions[count($extensions) - 1]['authorityCertSerialNumber'] = $issuer->serialNumber; - //} - //unset($extensions); - } - - if (isset($subject->currentKeyIdentifier)) { - $this->setExtension('id-ce-subjectKeyIdentifier', $subject->currentKeyIdentifier); - } - - $altName = array(); - - if (isset($subject->domains) && count($subject->domains) > 1) { - $altName = array_map(array('X509', '_dnsName'), $subject->domains); - } - - if (isset($subject->ipAddresses) && count($subject->ipAddresses)) { - // should an IP address appear as the CN if no domain name is specified? idk - //$ips = count($subject->domains) ? $subject->ipAddresses : array_slice($subject->ipAddresses, 1); - $ipAddresses = array(); - foreach ($subject->ipAddresses as $ipAddress) { - $encoded = $subject->_ipAddress($ipAddress); - if ($encoded !== false) { - $ipAddresses[] = $encoded; - } - } - if (count($ipAddresses)) { - $altName = array_merge($altName, $ipAddresses); - } - } - - if (!empty($altName)) { - $this->setExtension('id-ce-subjectAltName', $altName); - } - - if ($this->caFlag) { - $keyUsage = $this->getExtension('id-ce-keyUsage'); - if (!$keyUsage) { - $keyUsage = array(); - } - - $this->setExtension( - 'id-ce-keyUsage', - array_values(array_unique(array_merge($keyUsage, array('cRLSign', 'keyCertSign')))) - ); - - $basicConstraints = $this->getExtension('id-ce-basicConstraints'); - if (!$basicConstraints) { - $basicConstraints = array(); - } - - $this->setExtension( - 'id-ce-basicConstraints', - array_unique(array_merge(array('cA' => true), $basicConstraints)), - true - ); - - if (!isset($subject->currentKeyIdentifier)) { - $this->setExtension('id-ce-subjectKeyIdentifier', base64_encode($this->computeKeyIdentifier($this->currentCert)), false, false); - } - } - - // resync $this->signatureSubject - // save $tbsCertificate in case there are any \phpseclib\File\ASN1\Element objects in it - $tbsCertificate = $this->currentCert['tbsCertificate']; - $this->loadX509($this->saveX509($this->currentCert)); - - $result = $this->_sign($issuer->privateKey, $signatureAlgorithm); - $result['tbsCertificate'] = $tbsCertificate; - - $this->currentCert = $currentCert; - $this->signatureSubject = $signatureSubject; - - return $result; - } - - /** - * Sign a CSR - * - * @access public - * @return mixed - */ - function signCSR($signatureAlgorithm = 'sha1WithRSAEncryption') - { - if (!is_object($this->privateKey) || empty($this->dn)) { - return false; - } - - $origPublicKey = $this->publicKey; - $class = get_class($this->privateKey); - $this->publicKey = new $class(); - $this->publicKey->loadKey($this->privateKey->getPublicKey()); - $this->publicKey->setPublicKey(); - if (!($publicKey = $this->_formatSubjectPublicKey())) { - return false; - } - $this->publicKey = $origPublicKey; - - $currentCert = isset($this->currentCert) ? $this->currentCert : null; - $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: null; - - if (isset($this->currentCert) && is_array($this->currentCert) && isset($this->currentCert['certificationRequestInfo'])) { - $this->currentCert['signatureAlgorithm']['algorithm'] = $signatureAlgorithm; - if (!empty($this->dn)) { - $this->currentCert['certificationRequestInfo']['subject'] = $this->dn; - } - $this->currentCert['certificationRequestInfo']['subjectPKInfo'] = $publicKey; - } else { - $this->currentCert = array( - 'certificationRequestInfo' => - array( - 'version' => 'v1', - 'subject' => $this->dn, - 'subjectPKInfo' => $publicKey - ), - 'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm), - 'signature' => false // this is going to be overwritten later - ); - } - - // resync $this->signatureSubject - // save $certificationRequestInfo in case there are any \phpseclib\File\ASN1\Element objects in it - $certificationRequestInfo = $this->currentCert['certificationRequestInfo']; - $this->loadCSR($this->saveCSR($this->currentCert)); - - $result = $this->_sign($this->privateKey, $signatureAlgorithm); - $result['certificationRequestInfo'] = $certificationRequestInfo; - - $this->currentCert = $currentCert; - $this->signatureSubject = $signatureSubject; - - return $result; - } - - /** - * Sign a SPKAC - * - * @access public - * @return mixed - */ - function signSPKAC($signatureAlgorithm = 'sha1WithRSAEncryption') - { - if (!is_object($this->privateKey)) { - return false; - } - - $origPublicKey = $this->publicKey; - $class = get_class($this->privateKey); - $this->publicKey = new $class(); - $this->publicKey->loadKey($this->privateKey->getPublicKey()); - $this->publicKey->setPublicKey(); - $publicKey = $this->_formatSubjectPublicKey(); - if (!$publicKey) { - return false; - } - $this->publicKey = $origPublicKey; - - $currentCert = isset($this->currentCert) ? $this->currentCert : null; - $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: null; - - // re-signing a SPKAC seems silly but since everything else supports re-signing why not? - if (isset($this->currentCert) && is_array($this->currentCert) && isset($this->currentCert['publicKeyAndChallenge'])) { - $this->currentCert['signatureAlgorithm']['algorithm'] = $signatureAlgorithm; - $this->currentCert['publicKeyAndChallenge']['spki'] = $publicKey; - if (!empty($this->challenge)) { - // the bitwise AND ensures that the output is a valid IA5String - $this->currentCert['publicKeyAndChallenge']['challenge'] = $this->challenge & str_repeat("\x7F", strlen($this->challenge)); - } - } else { - $this->currentCert = array( - 'publicKeyAndChallenge' => - array( - 'spki' => $publicKey, - // quoting <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/keygen>, - // "A challenge string that is submitted along with the public key. Defaults to an empty string if not specified." - // both Firefox and OpenSSL ("openssl spkac -key private.key") behave this way - // we could alternatively do this instead if we ignored the specs: - // Random::string(8) & str_repeat("\x7F", 8) - 'challenge' => !empty($this->challenge) ? $this->challenge : '' - ), - 'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm), - 'signature' => false // this is going to be overwritten later - ); - } - - // resync $this->signatureSubject - // save $publicKeyAndChallenge in case there are any \phpseclib\File\ASN1\Element objects in it - $publicKeyAndChallenge = $this->currentCert['publicKeyAndChallenge']; - $this->loadSPKAC($this->saveSPKAC($this->currentCert)); - - $result = $this->_sign($this->privateKey, $signatureAlgorithm); - $result['publicKeyAndChallenge'] = $publicKeyAndChallenge; - - $this->currentCert = $currentCert; - $this->signatureSubject = $signatureSubject; - - return $result; - } - - /** - * Sign a CRL - * - * $issuer's private key needs to be loaded. - * - * @param \phpseclib\File\X509 $issuer - * @param \phpseclib\File\X509 $crl - * @param string $signatureAlgorithm optional - * @access public - * @return mixed - */ - function signCRL($issuer, $crl, $signatureAlgorithm = 'sha1WithRSAEncryption') - { - if (!is_object($issuer->privateKey) || empty($issuer->dn)) { - return false; - } - - $currentCert = isset($this->currentCert) ? $this->currentCert : null; - $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null; - $thisUpdate = !empty($this->startDate) ? $this->startDate : @date('D, d M Y H:i:s O'); - - if (isset($crl->currentCert) && is_array($crl->currentCert) && isset($crl->currentCert['tbsCertList'])) { - $this->currentCert = $crl->currentCert; - $this->currentCert['tbsCertList']['signature']['algorithm'] = $signatureAlgorithm; - $this->currentCert['signatureAlgorithm']['algorithm'] = $signatureAlgorithm; - } else { - $this->currentCert = array( - 'tbsCertList' => - array( - 'version' => 'v2', - 'signature' => array('algorithm' => $signatureAlgorithm), - 'issuer' => false, // this is going to be overwritten later - 'thisUpdate' => $this->_timeField($thisUpdate) // $this->setStartDate() - ), - 'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm), - 'signature' => false // this is going to be overwritten later - ); - } - - $tbsCertList = &$this->currentCert['tbsCertList']; - $tbsCertList['issuer'] = $issuer->dn; - $tbsCertList['thisUpdate'] = $this->_timeField($thisUpdate); - - if (!empty($this->endDate)) { - $tbsCertList['nextUpdate'] = $this->_timeField($this->endDate); // $this->setEndDate() - } else { - unset($tbsCertList['nextUpdate']); - } - - if (!empty($this->serialNumber)) { - $crlNumber = $this->serialNumber; - } else { - $crlNumber = $this->getExtension('id-ce-cRLNumber'); - // "The CRL number is a non-critical CRL extension that conveys a - // monotonically increasing sequence number for a given CRL scope and - // CRL issuer. This extension allows users to easily determine when a - // particular CRL supersedes another CRL." - // -- https://tools.ietf.org/html/rfc5280#section-5.2.3 - $crlNumber = $crlNumber !== false ? $crlNumber->add(new BigInteger(1)) : null; - } - - $this->removeExtension('id-ce-authorityKeyIdentifier'); - $this->removeExtension('id-ce-issuerAltName'); - - // Be sure version >= v2 if some extension found. - $version = isset($tbsCertList['version']) ? $tbsCertList['version'] : 0; - if (!$version) { - if (!empty($tbsCertList['crlExtensions'])) { - $version = 1; // v2. - } elseif (!empty($tbsCertList['revokedCertificates'])) { - foreach ($tbsCertList['revokedCertificates'] as $cert) { - if (!empty($cert['crlEntryExtensions'])) { - $version = 1; // v2. - } - } - } - - if ($version) { - $tbsCertList['version'] = $version; - } - } - - // Store additional extensions. - if (!empty($tbsCertList['version'])) { // At least v2. - if (!empty($crlNumber)) { - $this->setExtension('id-ce-cRLNumber', $crlNumber); - } - - if (isset($issuer->currentKeyIdentifier)) { - $this->setExtension('id-ce-authorityKeyIdentifier', array( - //'authorityCertIssuer' => array( - // array( - // 'directoryName' => $issuer->dn - // ) - //), - 'keyIdentifier' => $issuer->currentKeyIdentifier - )); - //$extensions = &$tbsCertList['crlExtensions']; - //if (isset($issuer->serialNumber)) { - // $extensions[count($extensions) - 1]['authorityCertSerialNumber'] = $issuer->serialNumber; - //} - //unset($extensions); - } - - $issuerAltName = $this->getExtension('id-ce-subjectAltName', $issuer->currentCert); - - if ($issuerAltName !== false) { - $this->setExtension('id-ce-issuerAltName', $issuerAltName); - } - } - - if (empty($tbsCertList['revokedCertificates'])) { - unset($tbsCertList['revokedCertificates']); - } - - unset($tbsCertList); - - // resync $this->signatureSubject - // save $tbsCertList in case there are any \phpseclib\File\ASN1\Element objects in it - $tbsCertList = $this->currentCert['tbsCertList']; - $this->loadCRL($this->saveCRL($this->currentCert)); - - $result = $this->_sign($issuer->privateKey, $signatureAlgorithm); - $result['tbsCertList'] = $tbsCertList; - - $this->currentCert = $currentCert; - $this->signatureSubject = $signatureSubject; - - return $result; - } - - /** - * X.509 certificate signing helper function. - * - * @param object $key - * @param \phpseclib\File\X509 $subject - * @param string $signatureAlgorithm - * @access public - * @return mixed - */ - function _sign($key, $signatureAlgorithm) - { - if ($key instanceof RSA) { - switch ($signatureAlgorithm) { - case 'md2WithRSAEncryption': - case 'md5WithRSAEncryption': - case 'sha1WithRSAEncryption': - case 'sha224WithRSAEncryption': - case 'sha256WithRSAEncryption': - case 'sha384WithRSAEncryption': - case 'sha512WithRSAEncryption': - $key->setHash(preg_replace('#WithRSAEncryption$#', '', $signatureAlgorithm)); - $key->setSignatureMode(RSA::SIGNATURE_PKCS1); - - $this->currentCert['signature'] = base64_encode("\0" . $key->sign($this->signatureSubject)); - return $this->currentCert; - } - } - - return false; - } - - /** - * Set certificate start date - * - * @param string $date - * @access public - */ - function setStartDate($date) - { - $this->startDate = @date('D, d M Y H:i:s O', @strtotime($date)); - } - - /** - * Set certificate end date - * - * @param string $date - * @access public - */ - function setEndDate($date) - { - /* - To indicate that a certificate has no well-defined expiration date, - the notAfter SHOULD be assigned the GeneralizedTime value of - 99991231235959Z. - - -- http://tools.ietf.org/html/rfc5280#section-4.1.2.5 - */ - if (strtolower($date) == 'lifetime') { - $temp = '99991231235959Z'; - $asn1 = new ASN1(); - $temp = chr(ASN1::TYPE_GENERALIZED_TIME) . $asn1->_encodeLength(strlen($temp)) . $temp; - $this->endDate = new Element($temp); - } else { - $this->endDate = @date('D, d M Y H:i:s O', @strtotime($date)); - } - } - - /** - * Set Serial Number - * - * @param string $serial - * @param $base optional - * @access public - */ - function setSerialNumber($serial, $base = -256) - { - $this->serialNumber = new BigInteger($serial, $base); - } - - /** - * Turns the certificate into a certificate authority - * - * @access public - */ - function makeCA() - { - $this->caFlag = true; - } - - /** - * Get a reference to a subarray - * - * @param array $root - * @param string $path absolute path with / as component separator - * @param bool $create optional - * @access private - * @return array|false - */ - function &_subArray(&$root, $path, $create = false) - { - $false = false; - - if (!is_array($root)) { - return $false; - } - - foreach (explode('/', $path) as $i) { - if (!is_array($root)) { - return $false; - } - - if (!isset($root[$i])) { - if (!$create) { - return $false; - } - - $root[$i] = array(); - } - - $root = &$root[$i]; - } - - return $root; - } - - /** - * Get a reference to an extension subarray - * - * @param array $root - * @param string $path optional absolute path with / as component separator - * @param bool $create optional - * @access private - * @return array|false - */ - function &_extensions(&$root, $path = null, $create = false) - { - if (!isset($root)) { - $root = $this->currentCert; - } - - switch (true) { - case !empty($path): - case !is_array($root): - break; - case isset($root['tbsCertificate']): - $path = 'tbsCertificate/extensions'; - break; - case isset($root['tbsCertList']): - $path = 'tbsCertList/crlExtensions'; - break; - case isset($root['certificationRequestInfo']): - $pth = 'certificationRequestInfo/attributes'; - $attributes = &$this->_subArray($root, $pth, $create); - - if (is_array($attributes)) { - foreach ($attributes as $key => $value) { - if ($value['type'] == 'pkcs-9-at-extensionRequest') { - $path = "$pth/$key/value/0"; - break 2; - } - } - if ($create) { - $key = count($attributes); - $attributes[] = array('type' => 'pkcs-9-at-extensionRequest', 'value' => array()); - $path = "$pth/$key/value/0"; - } - } - break; - } - - $extensions = &$this->_subArray($root, $path, $create); - - if (!is_array($extensions)) { - $false = false; - return $false; - } - - return $extensions; - } - - /** - * Remove an Extension - * - * @param string $id - * @param string $path optional - * @access private - * @return bool - */ - function _removeExtension($id, $path = null) - { - $extensions = &$this->_extensions($this->currentCert, $path); - - if (!is_array($extensions)) { - return false; - } - - $result = false; - foreach ($extensions as $key => $value) { - if ($value['extnId'] == $id) { - unset($extensions[$key]); - $result = true; - } - } - - $extensions = array_values($extensions); - return $result; - } - - /** - * Get an Extension - * - * Returns the extension if it exists and false if not - * - * @param string $id - * @param array $cert optional - * @param string $path optional - * @access private - * @return mixed - */ - function _getExtension($id, $cert = null, $path = null) - { - $extensions = $this->_extensions($cert, $path); - - if (!is_array($extensions)) { - return false; - } - - foreach ($extensions as $key => $value) { - if ($value['extnId'] == $id) { - return $value['extnValue']; - } - } - - return false; - } - - /** - * Returns a list of all extensions in use - * - * @param array $cert optional - * @param string $path optional - * @access private - * @return array - */ - function _getExtensions($cert = null, $path = null) - { - $exts = $this->_extensions($cert, $path); - $extensions = array(); - - if (is_array($exts)) { - foreach ($exts as $extension) { - $extensions[] = $extension['extnId']; - } - } - - return $extensions; - } - - /** - * Set an Extension - * - * @param string $id - * @param mixed $value - * @param bool $critical optional - * @param bool $replace optional - * @param string $path optional - * @access private - * @return bool - */ - function _setExtension($id, $value, $critical = false, $replace = true, $path = null) - { - $extensions = &$this->_extensions($this->currentCert, $path, true); - - if (!is_array($extensions)) { - return false; - } - - $newext = array('extnId' => $id, 'critical' => $critical, 'extnValue' => $value); - - foreach ($extensions as $key => $value) { - if ($value['extnId'] == $id) { - if (!$replace) { - return false; - } - - $extensions[$key] = $newext; - return true; - } - } - - $extensions[] = $newext; - return true; - } - - /** - * Remove a certificate, CSR or CRL Extension - * - * @param string $id - * @access public - * @return bool - */ - function removeExtension($id) - { - return $this->_removeExtension($id); - } - - /** - * Get a certificate, CSR or CRL Extension - * - * Returns the extension if it exists and false if not - * - * @param string $id - * @param array $cert optional - * @access public - * @return mixed - */ - function getExtension($id, $cert = null) - { - return $this->_getExtension($id, $cert); - } - - /** - * Returns a list of all extensions in use in certificate, CSR or CRL - * - * @param array $cert optional - * @access public - * @return array - */ - function getExtensions($cert = null) - { - return $this->_getExtensions($cert); - } - - /** - * Set a certificate, CSR or CRL Extension - * - * @param string $id - * @param mixed $value - * @param bool $critical optional - * @param bool $replace optional - * @access public - * @return bool - */ - function setExtension($id, $value, $critical = false, $replace = true) - { - return $this->_setExtension($id, $value, $critical, $replace); - } - - /** - * Remove a CSR attribute. - * - * @param string $id - * @param int $disposition optional - * @access public - * @return bool - */ - function removeAttribute($id, $disposition = self::ATTR_ALL) - { - $attributes = &$this->_subArray($this->currentCert, 'certificationRequestInfo/attributes'); - - if (!is_array($attributes)) { - return false; - } - - $result = false; - foreach ($attributes as $key => $attribute) { - if ($attribute['type'] == $id) { - $n = count($attribute['value']); - switch (true) { - case $disposition == self::ATTR_APPEND: - case $disposition == self::ATTR_REPLACE: - return false; - case $disposition >= $n: - $disposition -= $n; - break; - case $disposition == self::ATTR_ALL: - case $n == 1: - unset($attributes[$key]); - $result = true; - break; - default: - unset($attributes[$key]['value'][$disposition]); - $attributes[$key]['value'] = array_values($attributes[$key]['value']); - $result = true; - break; - } - if ($result && $disposition != self::ATTR_ALL) { - break; - } - } - } - - $attributes = array_values($attributes); - return $result; - } - - /** - * Get a CSR attribute - * - * Returns the attribute if it exists and false if not - * - * @param string $id - * @param int $disposition optional - * @param array $csr optional - * @access public - * @return mixed - */ - function getAttribute($id, $disposition = self::ATTR_ALL, $csr = null) - { - if (empty($csr)) { - $csr = $this->currentCert; - } - - $attributes = $this->_subArray($csr, 'certificationRequestInfo/attributes'); - - if (!is_array($attributes)) { - return false; - } - - foreach ($attributes as $key => $attribute) { - if ($attribute['type'] == $id) { - $n = count($attribute['value']); - switch (true) { - case $disposition == self::ATTR_APPEND: - case $disposition == self::ATTR_REPLACE: - return false; - case $disposition == self::ATTR_ALL: - return $attribute['value']; - case $disposition >= $n: - $disposition -= $n; - break; - default: - return $attribute['value'][$disposition]; - } - } - } - - return false; - } - - /** - * Returns a list of all CSR attributes in use - * - * @param array $csr optional - * @access public - * @return array - */ - function getAttributes($csr = null) - { - if (empty($csr)) { - $csr = $this->currentCert; - } - - $attributes = $this->_subArray($csr, 'certificationRequestInfo/attributes'); - $attrs = array(); - - if (is_array($attributes)) { - foreach ($attributes as $attribute) { - $attrs[] = $attribute['type']; - } - } - - return $attrs; - } - - /** - * Set a CSR attribute - * - * @param string $id - * @param mixed $value - * @param bool $disposition optional - * @access public - * @return bool - */ - function setAttribute($id, $value, $disposition = self::ATTR_ALL) - { - $attributes = &$this->_subArray($this->currentCert, 'certificationRequestInfo/attributes', true); - - if (!is_array($attributes)) { - return false; - } - - switch ($disposition) { - case self::ATTR_REPLACE: - $disposition = self::ATTR_APPEND; - case self::ATTR_ALL: - $this->removeAttribute($id); - break; - } - - foreach ($attributes as $key => $attribute) { - if ($attribute['type'] == $id) { - $n = count($attribute['value']); - switch (true) { - case $disposition == self::ATTR_APPEND: - $last = $key; - break; - case $disposition >= $n: - $disposition -= $n; - break; - default: - $attributes[$key]['value'][$disposition] = $value; - return true; - } - } - } - - switch (true) { - case $disposition >= 0: - return false; - case isset($last): - $attributes[$last]['value'][] = $value; - break; - default: - $attributes[] = array('type' => $id, 'value' => $disposition == self::ATTR_ALL ? $value: array($value)); - break; - } - - return true; - } - - /** - * Sets the subject key identifier - * - * This is used by the id-ce-authorityKeyIdentifier and the id-ce-subjectKeyIdentifier extensions. - * - * @param string $value - * @access public - */ - function setKeyIdentifier($value) - { - if (empty($value)) { - unset($this->currentKeyIdentifier); - } else { - $this->currentKeyIdentifier = base64_encode($value); - } - } - - /** - * Compute a public key identifier. - * - * Although key identifiers may be set to any unique value, this function - * computes key identifiers from public key according to the two - * recommended methods (4.2.1.2 RFC 3280). - * Highly polymorphic: try to accept all possible forms of key: - * - Key object - * - \phpseclib\File\X509 object with public or private key defined - * - Certificate or CSR array - * - \phpseclib\File\ASN1\Element object - * - PEM or DER string - * - * @param mixed $key optional - * @param int $method optional - * @access public - * @return string binary key identifier - */ - function computeKeyIdentifier($key = null, $method = 1) - { - if (is_null($key)) { - $key = $this; - } - - switch (true) { - case is_string($key): - break; - case is_array($key) && isset($key['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']): - return $this->computeKeyIdentifier($key['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'], $method); - case is_array($key) && isset($key['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']): - return $this->computeKeyIdentifier($key['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'], $method); - case !is_object($key): - return false; - case $key instanceof Element: - // Assume the element is a bitstring-packed key. - $asn1 = new ASN1(); - $decoded = $asn1->decodeBER($key->element); - if (empty($decoded)) { - return false; - } - $raw = $asn1->asn1map($decoded[0], array('type' => ASN1::TYPE_BIT_STRING)); - if (empty($raw)) { - return false; - } - $raw = base64_decode($raw); - // If the key is private, compute identifier from its corresponding public key. - $key = new RSA(); - if (!$key->loadKey($raw)) { - return false; // Not an unencrypted RSA key. - } - if ($key->getPrivateKey() !== false) { // If private. - return $this->computeKeyIdentifier($key, $method); - } - $key = $raw; // Is a public key. - break; - case $key instanceof X509: - if (isset($key->publicKey)) { - return $this->computeKeyIdentifier($key->publicKey, $method); - } - if (isset($key->privateKey)) { - return $this->computeKeyIdentifier($key->privateKey, $method); - } - if (isset($key->currentCert['tbsCertificate']) || isset($key->currentCert['certificationRequestInfo'])) { - return $this->computeKeyIdentifier($key->currentCert, $method); - } - return false; - default: // Should be a key object (i.e.: \phpseclib\Crypt\RSA). - $key = $key->getPublicKey(RSA::PUBLIC_FORMAT_PKCS1); - break; - } - - // If in PEM format, convert to binary. - $key = $this->_extractBER($key); - - // Now we have the key string: compute its sha-1 sum. - $hash = new Hash('sha1'); - $hash = $hash->hash($key); - - if ($method == 2) { - $hash = substr($hash, -8); - $hash[0] = chr((ord($hash[0]) & 0x0F) | 0x40); - } - - return $hash; - } - - /** - * Format a public key as appropriate - * - * @access private - * @return array - */ - function _formatSubjectPublicKey() - { - if ($this->publicKey instanceof RSA) { - // the following two return statements do the same thing. i dunno.. i just prefer the later for some reason. - // the former is a good example of how to do fuzzing on the public key - //return new Element(base64_decode(preg_replace('#-.+-|[\r\n]#', '', $this->publicKey->getPublicKey()))); - return array( - 'algorithm' => array('algorithm' => 'rsaEncryption'), - 'subjectPublicKey' => $this->publicKey->getPublicKey(RSA::PUBLIC_FORMAT_PKCS1) - ); - } - - return false; - } - - /** - * Set the domain name's which the cert is to be valid for - * - * @access public - * @return array - */ - function setDomain() - { - $this->domains = func_get_args(); - $this->removeDNProp('id-at-commonName'); - $this->setDNProp('id-at-commonName', $this->domains[0]); - } - - /** - * Set the IP Addresses's which the cert is to be valid for - * - * @access public - * @param string $ipAddress optional - */ - function setIPAddress() - { - $this->ipAddresses = func_get_args(); - /* - if (!isset($this->domains)) { - $this->removeDNProp('id-at-commonName'); - $this->setDNProp('id-at-commonName', $this->ipAddresses[0]); - } - */ - } - - /** - * Helper function to build domain array - * - * @access private - * @param string $domain - * @return array - */ - function _dnsName($domain) - { - return array('dNSName' => $domain); - } - - /** - * Helper function to build IP Address array - * - * (IPv6 is not currently supported) - * - * @access private - * @param string $address - * @return array - */ - function _iPAddress($address) - { - return array('iPAddress' => $address); - } - - /** - * Get the index of a revoked certificate. - * - * @param array $rclist - * @param string $serial - * @param bool $create optional - * @access private - * @return int|false - */ - function _revokedCertificate(&$rclist, $serial, $create = false) - { - $serial = new BigInteger($serial); - - foreach ($rclist as $i => $rc) { - if (!($serial->compare($rc['userCertificate']))) { - return $i; - } - } - - if (!$create) { - return false; - } - - $i = count($rclist); - $rclist[] = array('userCertificate' => $serial, - 'revocationDate' => $this->_timeField(@date('D, d M Y H:i:s O'))); - return $i; - } - - /** - * Revoke a certificate. - * - * @param string $serial - * @param string $date optional - * @access public - * @return bool - */ - function revoke($serial, $date = null) - { - if (isset($this->currentCert['tbsCertList'])) { - if (is_array($rclist = &$this->_subArray($this->currentCert, 'tbsCertList/revokedCertificates', true))) { - if ($this->_revokedCertificate($rclist, $serial) === false) { // If not yet revoked - if (($i = $this->_revokedCertificate($rclist, $serial, true)) !== false) { - if (!empty($date)) { - $rclist[$i]['revocationDate'] = $this->_timeField($date); - } - - return true; - } - } - } - } - - return false; - } - - /** - * Unrevoke a certificate. - * - * @param string $serial - * @access public - * @return bool - */ - function unrevoke($serial) - { - if (is_array($rclist = &$this->_subArray($this->currentCert, 'tbsCertList/revokedCertificates'))) { - if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) { - unset($rclist[$i]); - $rclist = array_values($rclist); - return true; - } - } - - return false; - } - - /** - * Get a revoked certificate. - * - * @param string $serial - * @access public - * @return mixed - */ - function getRevoked($serial) - { - if (is_array($rclist = $this->_subArray($this->currentCert, 'tbsCertList/revokedCertificates'))) { - if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) { - return $rclist[$i]; - } - } - - return false; - } - - /** - * List revoked certificates - * - * @param array $crl optional - * @access public - * @return array - */ - function listRevoked($crl = null) - { - if (!isset($crl)) { - $crl = $this->currentCert; - } - - if (!isset($crl['tbsCertList'])) { - return false; - } - - $result = array(); - - if (is_array($rclist = $this->_subArray($crl, 'tbsCertList/revokedCertificates'))) { - foreach ($rclist as $rc) { - $result[] = $rc['userCertificate']->toString(); - } - } - - return $result; - } - - /** - * Remove a Revoked Certificate Extension - * - * @param string $serial - * @param string $id - * @access public - * @return bool - */ - function removeRevokedCertificateExtension($serial, $id) - { - if (is_array($rclist = &$this->_subArray($this->currentCert, 'tbsCertList/revokedCertificates'))) { - if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) { - return $this->_removeExtension($id, "tbsCertList/revokedCertificates/$i/crlEntryExtensions"); - } - } - - return false; - } - - /** - * Get a Revoked Certificate Extension - * - * Returns the extension if it exists and false if not - * - * @param string $serial - * @param string $id - * @param array $crl optional - * @access public - * @return mixed - */ - function getRevokedCertificateExtension($serial, $id, $crl = null) - { - if (!isset($crl)) { - $crl = $this->currentCert; - } - - if (is_array($rclist = $this->_subArray($crl, 'tbsCertList/revokedCertificates'))) { - if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) { - return $this->_getExtension($id, $crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions"); - } - } - - return false; - } - - /** - * Returns a list of all extensions in use for a given revoked certificate - * - * @param string $serial - * @param array $crl optional - * @access public - * @return array - */ - function getRevokedCertificateExtensions($serial, $crl = null) - { - if (!isset($crl)) { - $crl = $this->currentCert; - } - - if (is_array($rclist = $this->_subArray($crl, 'tbsCertList/revokedCertificates'))) { - if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) { - return $this->_getExtensions($crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions"); - } - } - - return false; - } - - /** - * Set a Revoked Certificate Extension - * - * @param string $serial - * @param string $id - * @param mixed $value - * @param bool $critical optional - * @param bool $replace optional - * @access public - * @return bool - */ - function setRevokedCertificateExtension($serial, $id, $value, $critical = false, $replace = true) - { - if (isset($this->currentCert['tbsCertList'])) { - if (is_array($rclist = &$this->_subArray($this->currentCert, 'tbsCertList/revokedCertificates', true))) { - if (($i = $this->_revokedCertificate($rclist, $serial, true)) !== false) { - return $this->_setExtension($id, $value, $critical, $replace, "tbsCertList/revokedCertificates/$i/crlEntryExtensions"); - } - } - } - - return false; - } - - /** - * Extract raw BER from Base64 encoding - * - * @access private - * @param string $str - * @return string - */ - function _extractBER($str) - { - /* X.509 certs are assumed to be base64 encoded but sometimes they'll have additional things in them - * above and beyond the ceritificate. - * ie. some may have the following preceding the -----BEGIN CERTIFICATE----- line: - * - * Bag Attributes - * localKeyID: 01 00 00 00 - * subject=/O=organization/OU=org unit/CN=common name - * issuer=/O=organization/CN=common name - */ - $temp = preg_replace('#.*?^-+[^-]+-+[\r\n ]*$#ms', '', $str, 1); - // remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff - $temp = preg_replace('#-+[^-]+-+#', '', $temp); - // remove new lines - $temp = str_replace(array("\r", "\n", ' '), '', $temp); - $temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? base64_decode($temp) : false; - return $temp != false ? $temp : $str; - } - - /** - * Returns the OID corresponding to a name - * - * What's returned in the associative array returned by loadX509() (or load*()) is either a name or an OID if - * no OID to name mapping is available. The problem with this is that what may be an unmapped OID in one version - * of phpseclib may not be unmapped in the next version, so apps that are looking at this OID may not be able - * to work from version to version. - * - * This method will return the OID if a name is passed to it and if no mapping is avialable it'll assume that - * what's being passed to it already is an OID and return that instead. A few examples. - * - * getOID('2.16.840.1.101.3.4.2.1') == '2.16.840.1.101.3.4.2.1' - * getOID('id-sha256') == '2.16.840.1.101.3.4.2.1' - * getOID('zzz') == 'zzz' - * - * @access public - * @return string - */ - function getOID($name) - { - static $reverseMap; - if (!isset($reverseMap)) { - $reverseMap = array_flip($this->oids); - } - return isset($reverseMap[$name]) ? $reverseMap[$name] : $name; - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger.php b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger.php deleted file mode 100755 index 7abead33a9ceab4f9dd80f1c4685c93ac136e930..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger.php +++ /dev/null @@ -1,3754 +0,0 @@ -<?php - -/** - * Pure-PHP arbitrary precision integer arithmetic library. - * - * Supports base-2, base-10, base-16, and base-256 numbers. Uses the GMP or BCMath extensions, if available, - * and an internal implementation, otherwise. - * - * PHP version 5 - * - * {@internal (all DocBlock comments regarding implementation - such as the one that follows - refer to the - * {@link self::MODE_INTERNAL self::MODE_INTERNAL} mode) - * - * BigInteger uses base-2**26 to perform operations such as multiplication and division and - * base-2**52 (ie. two base 2**26 digits) to perform addition and subtraction. Because the largest possible - * value when multiplying two base-2**26 numbers together is a base-2**52 number, double precision floating - * point numbers - numbers that should be supported on most hardware and whose significand is 53 bits - are - * used. As a consequence, bitwise operators such as >> and << cannot be used, nor can the modulo operator %, - * which only supports integers. Although this fact will slow this library down, the fact that such a high - * base is being used should more than compensate. - * - * Numbers are stored in {@link http://en.wikipedia.org/wiki/Endianness little endian} format. ie. - * (new \phpseclib\Math\BigInteger(pow(2, 26)))->value = array(0, 1) - * - * Useful resources are as follows: - * - * - {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf Handbook of Applied Cryptography (HAC)} - * - {@link http://math.libtomcrypt.com/files/tommath.pdf Multi-Precision Math (MPM)} - * - Java's BigInteger classes. See /j2se/src/share/classes/java/math in jdk-1_5_0-src-jrl.zip - * - * Here's an example of how to use this library: - * <code> - * <?php - * $a = new \phpseclib\Math\BigInteger(2); - * $b = new \phpseclib\Math\BigInteger(3); - * - * $c = $a->add($b); - * - * echo $c->toString(); // outputs 5 - * ?> - * </code> - * - * @category Math - * @package BigInteger - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2006 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://pear.php.net/package/Math_BigInteger - */ - -namespace phpseclib\Math; - -use phpseclib\Crypt\Random; - -/** - * Pure-PHP arbitrary precision integer arithmetic library. Supports base-2, base-10, base-16, and base-256 - * numbers. - * - * @package BigInteger - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class BigInteger -{ - /**#@+ - * Reduction constants - * - * @access private - * @see BigInteger::_reduce() - */ - /** - * @see BigInteger::_montgomery() - * @see BigInteger::_prepMontgomery() - */ - const MONTGOMERY = 0; - /** - * @see BigInteger::_barrett() - */ - const BARRETT = 1; - /** - * @see BigInteger::_mod2() - */ - const POWEROF2 = 2; - /** - * @see BigInteger::_remainder() - */ - const CLASSIC = 3; - /** - * @see BigInteger::__clone() - */ - const NONE = 4; - /**#@-*/ - - /**#@+ - * Array constants - * - * Rather than create a thousands and thousands of new BigInteger objects in repeated function calls to add() and - * multiply() or whatever, we'll just work directly on arrays, taking them in as parameters and returning them. - * - * @access private - */ - /** - * $result[self::VALUE] contains the value. - */ - const VALUE = 0; - /** - * $result[self::SIGN] contains the sign. - */ - const SIGN = 1; - /**#@-*/ - - /**#@+ - * @access private - * @see BigInteger::_montgomery() - * @see BigInteger::_barrett() - */ - /** - * Cache constants - * - * $cache[self::VARIABLE] tells us whether or not the cached data is still valid. - */ - const VARIABLE = 0; - /** - * $cache[self::DATA] contains the cached data. - */ - const DATA = 1; - /**#@-*/ - - /**#@+ - * Mode constants. - * - * @access private - * @see BigInteger::__construct() - */ - /** - * To use the pure-PHP implementation - */ - const MODE_INTERNAL = 1; - /** - * To use the BCMath library - * - * (if enabled; otherwise, the internal implementation will be used) - */ - const MODE_BCMATH = 2; - /** - * To use the GMP library - * - * (if present; otherwise, either the BCMath or the internal implementation will be used) - */ - const MODE_GMP = 3; - /**#@-*/ - - /** - * Karatsuba Cutoff - * - * At what point do we switch between Karatsuba multiplication and schoolbook long multiplication? - * - * @access private - */ - const KARATSUBA_CUTOFF = 25; - - /**#@+ - * Static properties used by the pure-PHP implementation. - * - * @see __construct() - */ - protected static $base; - protected static $baseFull; - protected static $maxDigit; - protected static $msb; - - /** - * $max10 in greatest $max10Len satisfying - * $max10 = 10**$max10Len <= 2**$base. - */ - protected static $max10; - - /** - * $max10Len in greatest $max10Len satisfying - * $max10 = 10**$max10Len <= 2**$base. - */ - protected static $max10Len; - protected static $maxDigit2; - /**#@-*/ - - /** - * Holds the BigInteger's value. - * - * @var array - * @access private - */ - var $value; - - /** - * Holds the BigInteger's magnitude. - * - * @var bool - * @access private - */ - var $is_negative = false; - - /** - * Precision - * - * @see self::setPrecision() - * @access private - */ - var $precision = -1; - - /** - * Precision Bitmask - * - * @see self::setPrecision() - * @access private - */ - var $bitmask = false; - - /** - * Mode independent value used for serialization. - * - * If the bcmath or gmp extensions are installed $this->value will be a non-serializable resource, hence the need for - * a variable that'll be serializable regardless of whether or not extensions are being used. Unlike $this->value, - * however, $this->hex is only calculated when $this->__sleep() is called. - * - * @see self::__sleep() - * @see self::__wakeup() - * @var string - * @access private - */ - var $hex; - - /** - * Converts base-2, base-10, base-16, and binary strings (base-256) to BigIntegers. - * - * If the second parameter - $base - is negative, then it will be assumed that the number's are encoded using - * two's compliment. The sole exception to this is -10, which is treated the same as 10 is. - * - * Here's an example: - * <code> - * <?php - * $a = new \phpseclib\Math\BigInteger('0x32', 16); // 50 in base-16 - * - * echo $a->toString(); // outputs 50 - * ?> - * </code> - * - * @param $x base-10 number or base-$base number if $base set. - * @param int $base - * @return \phpseclib\Math\BigInteger - * @access public - */ - function __construct($x = 0, $base = 10) - { - if (!defined('MATH_BIGINTEGER_MODE')) { - switch (true) { - case extension_loaded('gmp'): - define('MATH_BIGINTEGER_MODE', self::MODE_GMP); - break; - case extension_loaded('bcmath'): - define('MATH_BIGINTEGER_MODE', self::MODE_BCMATH); - break; - default: - define('MATH_BIGINTEGER_MODE', self::MODE_INTERNAL); - } - } - - if (extension_loaded('openssl') && !defined('MATH_BIGINTEGER_OPENSSL_DISABLE') && !defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) { - // some versions of XAMPP have mismatched versions of OpenSSL which causes it not to work - ob_start(); - @phpinfo(); - $content = ob_get_contents(); - ob_end_clean(); - - preg_match_all('#OpenSSL (Header|Library) Version(.*)#im', $content, $matches); - - $versions = array(); - if (!empty($matches[1])) { - for ($i = 0; $i < count($matches[1]); $i++) { - $fullVersion = trim(str_replace('=>', '', strip_tags($matches[2][$i]))); - - // Remove letter part in OpenSSL version - if (!preg_match('/(\d+\.\d+\.\d+)/i', $fullVersion, $m)) { - $versions[$matches[1][$i]] = $fullVersion; - } else { - $versions[$matches[1][$i]] = $m[0]; - } - } - } - - // it doesn't appear that OpenSSL versions were reported upon until PHP 5.3+ - switch (true) { - case !isset($versions['Header']): - case !isset($versions['Library']): - case $versions['Header'] == $versions['Library']: - define('MATH_BIGINTEGER_OPENSSL_ENABLED', true); - break; - default: - define('MATH_BIGINTEGER_OPENSSL_DISABLE', true); - } - } - - if (!defined('PHP_INT_SIZE')) { - define('PHP_INT_SIZE', 4); - } - - if (empty(self::$base) && MATH_BIGINTEGER_MODE == self::MODE_INTERNAL) { - switch (PHP_INT_SIZE) { - case 8: // use 64-bit integers if int size is 8 bytes - self::$base = 31; - self::$baseFull = 0x80000000; - self::$maxDigit = 0x7FFFFFFF; - self::$msb = 0x40000000; - self::$max10 = 1000000000; - self::$max10Len = 9; - self::$maxDigit2 = pow(2, 62); - break; - //case 4: // use 64-bit floats if int size is 4 bytes - default: - self::$base = 26; - self::$baseFull = 0x4000000; - self::$maxDigit = 0x3FFFFFF; - self::$msb = 0x2000000; - self::$max10 = 10000000; - self::$max10Len = 7; - self::$maxDigit2 = pow(2, 52); // pow() prevents truncation - } - } - - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - switch (true) { - case is_resource($x) && get_resource_type($x) == 'GMP integer': - // PHP 5.6 switched GMP from using resources to objects - case $x instanceof \GMP: - $this->value = $x; - return; - } - $this->value = gmp_init(0); - break; - case self::MODE_BCMATH: - $this->value = '0'; - break; - default: - $this->value = array(); - } - - // '0' counts as empty() but when the base is 256 '0' is equal to ord('0') or 48 - // '0' is the only value like this per http://php.net/empty - if (empty($x) && (abs($base) != 256 || $x !== '0')) { - return; - } - - switch ($base) { - case -256: - if (ord($x[0]) & 0x80) { - $x = ~$x; - $this->is_negative = true; - } - case 256: - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - $sign = $this->is_negative ? '-' : ''; - $this->value = gmp_init($sign . '0x' . bin2hex($x)); - break; - case self::MODE_BCMATH: - // round $len to the nearest 4 (thanks, DavidMJ!) - $len = (strlen($x) + 3) & 0xFFFFFFFC; - - $x = str_pad($x, $len, chr(0), STR_PAD_LEFT); - - for ($i = 0; $i < $len; $i+= 4) { - $this->value = bcmul($this->value, '4294967296', 0); // 4294967296 == 2**32 - $this->value = bcadd($this->value, 0x1000000 * ord($x[$i]) + ((ord($x[$i + 1]) << 16) | (ord($x[$i + 2]) << 8) | ord($x[$i + 3])), 0); - } - - if ($this->is_negative) { - $this->value = '-' . $this->value; - } - - break; - // converts a base-2**8 (big endian / msb) number to base-2**26 (little endian / lsb) - default: - while (strlen($x)) { - $this->value[] = $this->_bytes2int($this->_base256_rshift($x, self::$base)); - } - } - - if ($this->is_negative) { - if (MATH_BIGINTEGER_MODE != self::MODE_INTERNAL) { - $this->is_negative = false; - } - $temp = $this->add(new static('-1')); - $this->value = $temp->value; - } - break; - case 16: - case -16: - if ($base > 0 && $x[0] == '-') { - $this->is_negative = true; - $x = substr($x, 1); - } - - $x = preg_replace('#^(?:0x)?([A-Fa-f0-9]*).*#', '$1', $x); - - $is_negative = false; - if ($base < 0 && hexdec($x[0]) >= 8) { - $this->is_negative = $is_negative = true; - $x = bin2hex(~pack('H*', $x)); - } - - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - $temp = $this->is_negative ? '-0x' . $x : '0x' . $x; - $this->value = gmp_init($temp); - $this->is_negative = false; - break; - case self::MODE_BCMATH: - $x = (strlen($x) & 1) ? '0' . $x : $x; - $temp = new static(pack('H*', $x), 256); - $this->value = $this->is_negative ? '-' . $temp->value : $temp->value; - $this->is_negative = false; - break; - default: - $x = (strlen($x) & 1) ? '0' . $x : $x; - $temp = new static(pack('H*', $x), 256); - $this->value = $temp->value; - } - - if ($is_negative) { - $temp = $this->add(new static('-1')); - $this->value = $temp->value; - } - break; - case 10: - case -10: - // (?<!^)(?:-).*: find any -'s that aren't at the beginning and then any characters that follow that - // (?<=^|-)0*: find any 0's that are preceded by the start of the string or by a - (ie. octals) - // [^-0-9].*: find any non-numeric characters and then any characters that follow that - $x = preg_replace('#(?<!^)(?:-).*|(?<=^|-)0*|[^-0-9].*#', '', $x); - - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - $this->value = gmp_init($x); - break; - case self::MODE_BCMATH: - // explicitly casting $x to a string is necessary, here, since doing $x[0] on -1 yields different - // results then doing it on '-1' does (modInverse does $x[0]) - $this->value = $x === '-' ? '0' : (string) $x; - break; - default: - $temp = new static(); - - $multiplier = new static(); - $multiplier->value = array(self::$max10); - - if ($x[0] == '-') { - $this->is_negative = true; - $x = substr($x, 1); - } - - $x = str_pad($x, strlen($x) + ((self::$max10Len - 1) * strlen($x)) % self::$max10Len, 0, STR_PAD_LEFT); - while (strlen($x)) { - $temp = $temp->multiply($multiplier); - $temp = $temp->add(new static($this->_int2bytes(substr($x, 0, self::$max10Len)), 256)); - $x = substr($x, self::$max10Len); - } - - $this->value = $temp->value; - } - break; - case 2: // base-2 support originally implemented by Lluis Pamies - thanks! - case -2: - if ($base > 0 && $x[0] == '-') { - $this->is_negative = true; - $x = substr($x, 1); - } - - $x = preg_replace('#^([01]*).*#', '$1', $x); - $x = str_pad($x, strlen($x) + (3 * strlen($x)) % 4, 0, STR_PAD_LEFT); - - $str = '0x'; - while (strlen($x)) { - $part = substr($x, 0, 4); - $str.= dechex(bindec($part)); - $x = substr($x, 4); - } - - if ($this->is_negative) { - $str = '-' . $str; - } - - $temp = new static($str, 8 * $base); // ie. either -16 or +16 - $this->value = $temp->value; - $this->is_negative = $temp->is_negative; - - break; - default: - // base not supported, so we'll let $this == 0 - } - } - - /** - * Converts a BigInteger to a byte string (eg. base-256). - * - * Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're - * saved as two's compliment. - * - * Here's an example: - * <code> - * <?php - * $a = new \phpseclib\Math\BigInteger('65'); - * - * echo $a->toBytes(); // outputs chr(65) - * ?> - * </code> - * - * @param bool $twos_compliment - * @return string - * @access public - * @internal Converts a base-2**26 number to base-2**8 - */ - function toBytes($twos_compliment = false) - { - if ($twos_compliment) { - $comparison = $this->compare(new static()); - if ($comparison == 0) { - return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : ''; - } - - $temp = $comparison < 0 ? $this->add(new static(1)) : $this->copy(); - $bytes = $temp->toBytes(); - - if (empty($bytes)) { // eg. if the number we're trying to convert is -1 - $bytes = chr(0); - } - - if (ord($bytes[0]) & 0x80) { - $bytes = chr(0) . $bytes; - } - - return $comparison < 0 ? ~$bytes : $bytes; - } - - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - if (gmp_cmp($this->value, gmp_init(0)) == 0) { - return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : ''; - } - - $temp = gmp_strval(gmp_abs($this->value), 16); - $temp = (strlen($temp) & 1) ? '0' . $temp : $temp; - $temp = pack('H*', $temp); - - return $this->precision > 0 ? - substr(str_pad($temp, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) : - ltrim($temp, chr(0)); - case self::MODE_BCMATH: - if ($this->value === '0') { - return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : ''; - } - - $value = ''; - $current = $this->value; - - if ($current[0] == '-') { - $current = substr($current, 1); - } - - while (bccomp($current, '0', 0) > 0) { - $temp = bcmod($current, '16777216'); - $value = chr($temp >> 16) . chr($temp >> 8) . chr($temp) . $value; - $current = bcdiv($current, '16777216', 0); - } - - return $this->precision > 0 ? - substr(str_pad($value, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) : - ltrim($value, chr(0)); - } - - if (!count($this->value)) { - return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : ''; - } - $result = $this->_int2bytes($this->value[count($this->value) - 1]); - - $temp = $this->copy(); - - for ($i = count($temp->value) - 2; $i >= 0; --$i) { - $temp->_base256_lshift($result, self::$base); - $result = $result | str_pad($temp->_int2bytes($temp->value[$i]), strlen($result), chr(0), STR_PAD_LEFT); - } - - return $this->precision > 0 ? - str_pad(substr($result, -(($this->precision + 7) >> 3)), ($this->precision + 7) >> 3, chr(0), STR_PAD_LEFT) : - $result; - } - - /** - * Converts a BigInteger to a hex string (eg. base-16)). - * - * Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're - * saved as two's compliment. - * - * Here's an example: - * <code> - * <?php - * $a = new \phpseclib\Math\BigInteger('65'); - * - * echo $a->toHex(); // outputs '41' - * ?> - * </code> - * - * @param bool $twos_compliment - * @return string - * @access public - * @internal Converts a base-2**26 number to base-2**8 - */ - function toHex($twos_compliment = false) - { - return bin2hex($this->toBytes($twos_compliment)); - } - - /** - * Converts a BigInteger to a bit string (eg. base-2). - * - * Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're - * saved as two's compliment. - * - * Here's an example: - * <code> - * <?php - * $a = new \phpseclib\Math\BigInteger('65'); - * - * echo $a->toBits(); // outputs '1000001' - * ?> - * </code> - * - * @param bool $twos_compliment - * @return string - * @access public - * @internal Converts a base-2**26 number to base-2**2 - */ - function toBits($twos_compliment = false) - { - $hex = $this->toHex($twos_compliment); - $bits = ''; - for ($i = strlen($hex) - 8, $start = strlen($hex) & 7; $i >= $start; $i-=8) { - $bits = str_pad(decbin(hexdec(substr($hex, $i, 8))), 32, '0', STR_PAD_LEFT) . $bits; - } - if ($start) { // hexdec('') == 0 - $bits = str_pad(decbin(hexdec(substr($hex, 0, $start))), 8, '0', STR_PAD_LEFT) . $bits; - } - $result = $this->precision > 0 ? substr($bits, -$this->precision) : ltrim($bits, '0'); - - if ($twos_compliment && $this->compare(new static()) > 0 && $this->precision <= 0) { - return '0' . $result; - } - - return $result; - } - - /** - * Converts a BigInteger to a base-10 number. - * - * Here's an example: - * <code> - * <?php - * $a = new \phpseclib\Math\BigInteger('50'); - * - * echo $a->toString(); // outputs 50 - * ?> - * </code> - * - * @return string - * @access public - * @internal Converts a base-2**26 number to base-10**7 (which is pretty much base-10) - */ - function toString() - { - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - return gmp_strval($this->value); - case self::MODE_BCMATH: - if ($this->value === '0') { - return '0'; - } - - return ltrim($this->value, '0'); - } - - if (!count($this->value)) { - return '0'; - } - - $temp = $this->copy(); - $temp->is_negative = false; - - $divisor = new static(); - $divisor->value = array(self::$max10); - $result = ''; - while (count($temp->value)) { - list($temp, $mod) = $temp->divide($divisor); - $result = str_pad(isset($mod->value[0]) ? $mod->value[0] : '', self::$max10Len, '0', STR_PAD_LEFT) . $result; - } - $result = ltrim($result, '0'); - if (empty($result)) { - $result = '0'; - } - - if ($this->is_negative) { - $result = '-' . $result; - } - - return $result; - } - - /** - * Copy an object - * - * PHP5 passes objects by reference while PHP4 passes by value. As such, we need a function to guarantee - * that all objects are passed by value, when appropriate. More information can be found here: - * - * {@link http://php.net/language.oop5.basic#51624} - * - * @access public - * @see self::__clone() - * @return \phpseclib\Math\BigInteger - */ - function copy() - { - $temp = new static(); - $temp->value = $this->value; - $temp->is_negative = $this->is_negative; - $temp->precision = $this->precision; - $temp->bitmask = $this->bitmask; - return $temp; - } - - /** - * __toString() magic method - * - * Will be called, automatically, if you're supporting just PHP5. If you're supporting PHP4, you'll need to call - * toString(). - * - * @access public - * @internal Implemented per a suggestion by Techie-Michael - thanks! - */ - function __toString() - { - return $this->toString(); - } - - /** - * __clone() magic method - * - * Although you can call BigInteger::__toString() directly in PHP5, you cannot call BigInteger::__clone() directly - * in PHP5. You can in PHP4 since it's not a magic method, but in PHP5, you have to call it by using the PHP5 - * only syntax of $y = clone $x. As such, if you're trying to write an application that works on both PHP4 and - * PHP5, call BigInteger::copy(), instead. - * - * @access public - * @see self::copy() - * @return \phpseclib\Math\BigInteger - */ - function __clone() - { - return $this->copy(); - } - - /** - * __sleep() magic method - * - * Will be called, automatically, when serialize() is called on a BigInteger object. - * - * @see self::__wakeup() - * @access public - */ - function __sleep() - { - $this->hex = $this->toHex(true); - $vars = array('hex'); - if ($this->precision > 0) { - $vars[] = 'precision'; - } - return $vars; - } - - /** - * __wakeup() magic method - * - * Will be called, automatically, when unserialize() is called on a BigInteger object. - * - * @see self::__sleep() - * @access public - */ - function __wakeup() - { - $temp = new static($this->hex, -16); - $this->value = $temp->value; - $this->is_negative = $temp->is_negative; - if ($this->precision > 0) { - // recalculate $this->bitmask - $this->setPrecision($this->precision); - } - } - - /** - * __debugInfo() magic method - * - * Will be called, automatically, when print_r() or var_dump() are called - * - * @access public - */ - function __debugInfo() - { - $opts = array(); - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - $engine = 'gmp'; - break; - case self::MODE_BCMATH: - $engine = 'bcmath'; - break; - case self::MODE_INTERNAL: - $engine = 'internal'; - $opts[] = PHP_INT_SIZE == 8 ? '64-bit' : '32-bit'; - } - if (MATH_BIGINTEGER_MODE != self::MODE_GMP && defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) { - $opts[] = 'OpenSSL'; - } - if (!empty($opts)) { - $engine.= ' (' . implode($opts, ', ') . ')'; - } - return array( - 'value' => '0x' . $this->toHex(true), - 'engine' => $engine - ); - } - - /** - * Adds two BigIntegers. - * - * Here's an example: - * <code> - * <?php - * $a = new \phpseclib\Math\BigInteger('10'); - * $b = new \phpseclib\Math\BigInteger('20'); - * - * $c = $a->add($b); - * - * echo $c->toString(); // outputs 30 - * ?> - * </code> - * - * @param \phpseclib\Math\BigInteger $y - * @return \phpseclib\Math\BigInteger - * @access public - * @internal Performs base-2**52 addition - */ - function add($y) - { - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - $temp = new static(); - $temp->value = gmp_add($this->value, $y->value); - - return $this->_normalize($temp); - case self::MODE_BCMATH: - $temp = new static(); - $temp->value = bcadd($this->value, $y->value, 0); - - return $this->_normalize($temp); - } - - $temp = $this->_add($this->value, $this->is_negative, $y->value, $y->is_negative); - - $result = new static(); - $result->value = $temp[self::VALUE]; - $result->is_negative = $temp[self::SIGN]; - - return $this->_normalize($result); - } - - /** - * Performs addition. - * - * @param array $x_value - * @param bool $x_negative - * @param array $y_value - * @param bool $y_negative - * @return array - * @access private - */ - function _add($x_value, $x_negative, $y_value, $y_negative) - { - $x_size = count($x_value); - $y_size = count($y_value); - - if ($x_size == 0) { - return array( - self::VALUE => $y_value, - self::SIGN => $y_negative - ); - } elseif ($y_size == 0) { - return array( - self::VALUE => $x_value, - self::SIGN => $x_negative - ); - } - - // subtract, if appropriate - if ($x_negative != $y_negative) { - if ($x_value == $y_value) { - return array( - self::VALUE => array(), - self::SIGN => false - ); - } - - $temp = $this->_subtract($x_value, false, $y_value, false); - $temp[self::SIGN] = $this->_compare($x_value, false, $y_value, false) > 0 ? - $x_negative : $y_negative; - - return $temp; - } - - if ($x_size < $y_size) { - $size = $x_size; - $value = $y_value; - } else { - $size = $y_size; - $value = $x_value; - } - - $value[count($value)] = 0; // just in case the carry adds an extra digit - - $carry = 0; - for ($i = 0, $j = 1; $j < $size; $i+=2, $j+=2) { - $sum = $x_value[$j] * self::$baseFull + $x_value[$i] + $y_value[$j] * self::$baseFull + $y_value[$i] + $carry; - $carry = $sum >= self::$maxDigit2; // eg. floor($sum / 2**52); only possible values (in any base) are 0 and 1 - $sum = $carry ? $sum - self::$maxDigit2 : $sum; - - $temp = self::$base === 26 ? intval($sum / 0x4000000) : ($sum >> 31); - - $value[$i] = (int) ($sum - self::$baseFull * $temp); // eg. a faster alternative to fmod($sum, 0x4000000) - $value[$j] = $temp; - } - - if ($j == $size) { // ie. if $y_size is odd - $sum = $x_value[$i] + $y_value[$i] + $carry; - $carry = $sum >= self::$baseFull; - $value[$i] = $carry ? $sum - self::$baseFull : $sum; - ++$i; // ie. let $i = $j since we've just done $value[$i] - } - - if ($carry) { - for (; $value[$i] == self::$maxDigit; ++$i) { - $value[$i] = 0; - } - ++$value[$i]; - } - - return array( - self::VALUE => $this->_trim($value), - self::SIGN => $x_negative - ); - } - - /** - * Subtracts two BigIntegers. - * - * Here's an example: - * <code> - * <?php - * $a = new \phpseclib\Math\BigInteger('10'); - * $b = new \phpseclib\Math\BigInteger('20'); - * - * $c = $a->subtract($b); - * - * echo $c->toString(); // outputs -10 - * ?> - * </code> - * - * @param \phpseclib\Math\BigInteger $y - * @return \phpseclib\Math\BigInteger - * @access public - * @internal Performs base-2**52 subtraction - */ - function subtract($y) - { - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - $temp = new static(); - $temp->value = gmp_sub($this->value, $y->value); - - return $this->_normalize($temp); - case self::MODE_BCMATH: - $temp = new static(); - $temp->value = bcsub($this->value, $y->value, 0); - - return $this->_normalize($temp); - } - - $temp = $this->_subtract($this->value, $this->is_negative, $y->value, $y->is_negative); - - $result = new static(); - $result->value = $temp[self::VALUE]; - $result->is_negative = $temp[self::SIGN]; - - return $this->_normalize($result); - } - - /** - * Performs subtraction. - * - * @param array $x_value - * @param bool $x_negative - * @param array $y_value - * @param bool $y_negative - * @return array - * @access private - */ - function _subtract($x_value, $x_negative, $y_value, $y_negative) - { - $x_size = count($x_value); - $y_size = count($y_value); - - if ($x_size == 0) { - return array( - self::VALUE => $y_value, - self::SIGN => !$y_negative - ); - } elseif ($y_size == 0) { - return array( - self::VALUE => $x_value, - self::SIGN => $x_negative - ); - } - - // add, if appropriate (ie. -$x - +$y or +$x - -$y) - if ($x_negative != $y_negative) { - $temp = $this->_add($x_value, false, $y_value, false); - $temp[self::SIGN] = $x_negative; - - return $temp; - } - - $diff = $this->_compare($x_value, $x_negative, $y_value, $y_negative); - - if (!$diff) { - return array( - self::VALUE => array(), - self::SIGN => false - ); - } - - // switch $x and $y around, if appropriate. - if ((!$x_negative && $diff < 0) || ($x_negative && $diff > 0)) { - $temp = $x_value; - $x_value = $y_value; - $y_value = $temp; - - $x_negative = !$x_negative; - - $x_size = count($x_value); - $y_size = count($y_value); - } - - // at this point, $x_value should be at least as big as - if not bigger than - $y_value - - $carry = 0; - for ($i = 0, $j = 1; $j < $y_size; $i+=2, $j+=2) { - $sum = $x_value[$j] * self::$baseFull + $x_value[$i] - $y_value[$j] * self::$baseFull - $y_value[$i] - $carry; - $carry = $sum < 0; // eg. floor($sum / 2**52); only possible values (in any base) are 0 and 1 - $sum = $carry ? $sum + self::$maxDigit2 : $sum; - - $temp = self::$base === 26 ? intval($sum / 0x4000000) : ($sum >> 31); - - $x_value[$i] = (int) ($sum - self::$baseFull * $temp); - $x_value[$j] = $temp; - } - - if ($j == $y_size) { // ie. if $y_size is odd - $sum = $x_value[$i] - $y_value[$i] - $carry; - $carry = $sum < 0; - $x_value[$i] = $carry ? $sum + self::$baseFull : $sum; - ++$i; - } - - if ($carry) { - for (; !$x_value[$i]; ++$i) { - $x_value[$i] = self::$maxDigit; - } - --$x_value[$i]; - } - - return array( - self::VALUE => $this->_trim($x_value), - self::SIGN => $x_negative - ); - } - - /** - * Multiplies two BigIntegers - * - * Here's an example: - * <code> - * <?php - * $a = new \phpseclib\Math\BigInteger('10'); - * $b = new \phpseclib\Math\BigInteger('20'); - * - * $c = $a->multiply($b); - * - * echo $c->toString(); // outputs 200 - * ?> - * </code> - * - * @param \phpseclib\Math\BigInteger $x - * @return \phpseclib\Math\BigInteger - * @access public - */ - function multiply($x) - { - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - $temp = new static(); - $temp->value = gmp_mul($this->value, $x->value); - - return $this->_normalize($temp); - case self::MODE_BCMATH: - $temp = new static(); - $temp->value = bcmul($this->value, $x->value, 0); - - return $this->_normalize($temp); - } - - $temp = $this->_multiply($this->value, $this->is_negative, $x->value, $x->is_negative); - - $product = new static(); - $product->value = $temp[self::VALUE]; - $product->is_negative = $temp[self::SIGN]; - - return $this->_normalize($product); - } - - /** - * Performs multiplication. - * - * @param array $x_value - * @param bool $x_negative - * @param array $y_value - * @param bool $y_negative - * @return array - * @access private - */ - function _multiply($x_value, $x_negative, $y_value, $y_negative) - { - //if ( $x_value == $y_value ) { - // return array( - // self::VALUE => $this->_square($x_value), - // self::SIGN => $x_sign != $y_value - // ); - //} - - $x_length = count($x_value); - $y_length = count($y_value); - - if (!$x_length || !$y_length) { // a 0 is being multiplied - return array( - self::VALUE => array(), - self::SIGN => false - ); - } - - return array( - self::VALUE => min($x_length, $y_length) < 2 * self::KARATSUBA_CUTOFF ? - $this->_trim($this->_regularMultiply($x_value, $y_value)) : - $this->_trim($this->_karatsuba($x_value, $y_value)), - self::SIGN => $x_negative != $y_negative - ); - } - - /** - * Performs long multiplication on two BigIntegers - * - * Modeled after 'multiply' in MutableBigInteger.java. - * - * @param array $x_value - * @param array $y_value - * @return array - * @access private - */ - function _regularMultiply($x_value, $y_value) - { - $x_length = count($x_value); - $y_length = count($y_value); - - if (!$x_length || !$y_length) { // a 0 is being multiplied - return array(); - } - - if ($x_length < $y_length) { - $temp = $x_value; - $x_value = $y_value; - $y_value = $temp; - - $x_length = count($x_value); - $y_length = count($y_value); - } - - $product_value = $this->_array_repeat(0, $x_length + $y_length); - - // the following for loop could be removed if the for loop following it - // (the one with nested for loops) initially set $i to 0, but - // doing so would also make the result in one set of unnecessary adds, - // since on the outermost loops first pass, $product->value[$k] is going - // to always be 0 - - $carry = 0; - - for ($j = 0; $j < $x_length; ++$j) { // ie. $i = 0 - $temp = $x_value[$j] * $y_value[0] + $carry; // $product_value[$k] == 0 - $carry = self::$base === 26 ? intval($temp / 0x4000000) : ($temp >> 31); - $product_value[$j] = (int) ($temp - self::$baseFull * $carry); - } - - $product_value[$j] = $carry; - - // the above for loop is what the previous comment was talking about. the - // following for loop is the "one with nested for loops" - for ($i = 1; $i < $y_length; ++$i) { - $carry = 0; - - for ($j = 0, $k = $i; $j < $x_length; ++$j, ++$k) { - $temp = $product_value[$k] + $x_value[$j] * $y_value[$i] + $carry; - $carry = self::$base === 26 ? intval($temp / 0x4000000) : ($temp >> 31); - $product_value[$k] = (int) ($temp - self::$baseFull * $carry); - } - - $product_value[$k] = $carry; - } - - return $product_value; - } - - /** - * Performs Karatsuba multiplication on two BigIntegers - * - * See {@link http://en.wikipedia.org/wiki/Karatsuba_algorithm Karatsuba algorithm} and - * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=120 MPM 5.2.3}. - * - * @param array $x_value - * @param array $y_value - * @return array - * @access private - */ - function _karatsuba($x_value, $y_value) - { - $m = min(count($x_value) >> 1, count($y_value) >> 1); - - if ($m < self::KARATSUBA_CUTOFF) { - return $this->_regularMultiply($x_value, $y_value); - } - - $x1 = array_slice($x_value, $m); - $x0 = array_slice($x_value, 0, $m); - $y1 = array_slice($y_value, $m); - $y0 = array_slice($y_value, 0, $m); - - $z2 = $this->_karatsuba($x1, $y1); - $z0 = $this->_karatsuba($x0, $y0); - - $z1 = $this->_add($x1, false, $x0, false); - $temp = $this->_add($y1, false, $y0, false); - $z1 = $this->_karatsuba($z1[self::VALUE], $temp[self::VALUE]); - $temp = $this->_add($z2, false, $z0, false); - $z1 = $this->_subtract($z1, false, $temp[self::VALUE], false); - - $z2 = array_merge(array_fill(0, 2 * $m, 0), $z2); - $z1[self::VALUE] = array_merge(array_fill(0, $m, 0), $z1[self::VALUE]); - - $xy = $this->_add($z2, false, $z1[self::VALUE], $z1[self::SIGN]); - $xy = $this->_add($xy[self::VALUE], $xy[self::SIGN], $z0, false); - - return $xy[self::VALUE]; - } - - /** - * Performs squaring - * - * @param array $x - * @return array - * @access private - */ - function _square($x = false) - { - return count($x) < 2 * self::KARATSUBA_CUTOFF ? - $this->_trim($this->_baseSquare($x)) : - $this->_trim($this->_karatsubaSquare($x)); - } - - /** - * Performs traditional squaring on two BigIntegers - * - * Squaring can be done faster than multiplying a number by itself can be. See - * {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=7 HAC 14.2.4} / - * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=141 MPM 5.3} for more information. - * - * @param array $value - * @return array - * @access private - */ - function _baseSquare($value) - { - if (empty($value)) { - return array(); - } - $square_value = $this->_array_repeat(0, 2 * count($value)); - - for ($i = 0, $max_index = count($value) - 1; $i <= $max_index; ++$i) { - $i2 = $i << 1; - - $temp = $square_value[$i2] + $value[$i] * $value[$i]; - $carry = self::$base === 26 ? intval($temp / 0x4000000) : ($temp >> 31); - $square_value[$i2] = (int) ($temp - self::$baseFull * $carry); - - // note how we start from $i+1 instead of 0 as we do in multiplication. - for ($j = $i + 1, $k = $i2 + 1; $j <= $max_index; ++$j, ++$k) { - $temp = $square_value[$k] + 2 * $value[$j] * $value[$i] + $carry; - $carry = self::$base === 26 ? intval($temp / 0x4000000) : ($temp >> 31); - $square_value[$k] = (int) ($temp - self::$baseFull * $carry); - } - - // the following line can yield values larger 2**15. at this point, PHP should switch - // over to floats. - $square_value[$i + $max_index + 1] = $carry; - } - - return $square_value; - } - - /** - * Performs Karatsuba "squaring" on two BigIntegers - * - * See {@link http://en.wikipedia.org/wiki/Karatsuba_algorithm Karatsuba algorithm} and - * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=151 MPM 5.3.4}. - * - * @param array $value - * @return array - * @access private - */ - function _karatsubaSquare($value) - { - $m = count($value) >> 1; - - if ($m < self::KARATSUBA_CUTOFF) { - return $this->_baseSquare($value); - } - - $x1 = array_slice($value, $m); - $x0 = array_slice($value, 0, $m); - - $z2 = $this->_karatsubaSquare($x1); - $z0 = $this->_karatsubaSquare($x0); - - $z1 = $this->_add($x1, false, $x0, false); - $z1 = $this->_karatsubaSquare($z1[self::VALUE]); - $temp = $this->_add($z2, false, $z0, false); - $z1 = $this->_subtract($z1, false, $temp[self::VALUE], false); - - $z2 = array_merge(array_fill(0, 2 * $m, 0), $z2); - $z1[self::VALUE] = array_merge(array_fill(0, $m, 0), $z1[self::VALUE]); - - $xx = $this->_add($z2, false, $z1[self::VALUE], $z1[self::SIGN]); - $xx = $this->_add($xx[self::VALUE], $xx[self::SIGN], $z0, false); - - return $xx[self::VALUE]; - } - - /** - * Divides two BigIntegers. - * - * Returns an array whose first element contains the quotient and whose second element contains the - * "common residue". If the remainder would be positive, the "common residue" and the remainder are the - * same. If the remainder would be negative, the "common residue" is equal to the sum of the remainder - * and the divisor (basically, the "common residue" is the first positive modulo). - * - * Here's an example: - * <code> - * <?php - * $a = new \phpseclib\Math\BigInteger('10'); - * $b = new \phpseclib\Math\BigInteger('20'); - * - * list($quotient, $remainder) = $a->divide($b); - * - * echo $quotient->toString(); // outputs 0 - * echo "\r\n"; - * echo $remainder->toString(); // outputs 10 - * ?> - * </code> - * - * @param \phpseclib\Math\BigInteger $y - * @return array - * @access public - * @internal This function is based off of {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=9 HAC 14.20}. - */ - function divide($y) - { - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - $quotient = new static(); - $remainder = new static(); - - list($quotient->value, $remainder->value) = gmp_div_qr($this->value, $y->value); - - if (gmp_sign($remainder->value) < 0) { - $remainder->value = gmp_add($remainder->value, gmp_abs($y->value)); - } - - return array($this->_normalize($quotient), $this->_normalize($remainder)); - case self::MODE_BCMATH: - $quotient = new static(); - $remainder = new static(); - - $quotient->value = bcdiv($this->value, $y->value, 0); - $remainder->value = bcmod($this->value, $y->value); - - if ($remainder->value[0] == '-') { - $remainder->value = bcadd($remainder->value, $y->value[0] == '-' ? substr($y->value, 1) : $y->value, 0); - } - - return array($this->_normalize($quotient), $this->_normalize($remainder)); - } - - if (count($y->value) == 1) { - list($q, $r) = $this->_divide_digit($this->value, $y->value[0]); - $quotient = new static(); - $remainder = new static(); - $quotient->value = $q; - $remainder->value = array($r); - $quotient->is_negative = $this->is_negative != $y->is_negative; - return array($this->_normalize($quotient), $this->_normalize($remainder)); - } - - static $zero; - if (!isset($zero)) { - $zero = new static(); - } - - $x = $this->copy(); - $y = $y->copy(); - - $x_sign = $x->is_negative; - $y_sign = $y->is_negative; - - $x->is_negative = $y->is_negative = false; - - $diff = $x->compare($y); - - if (!$diff) { - $temp = new static(); - $temp->value = array(1); - $temp->is_negative = $x_sign != $y_sign; - return array($this->_normalize($temp), $this->_normalize(new static())); - } - - if ($diff < 0) { - // if $x is negative, "add" $y. - if ($x_sign) { - $x = $y->subtract($x); - } - return array($this->_normalize(new static()), $this->_normalize($x)); - } - - // normalize $x and $y as described in HAC 14.23 / 14.24 - $msb = $y->value[count($y->value) - 1]; - for ($shift = 0; !($msb & self::$msb); ++$shift) { - $msb <<= 1; - } - $x->_lshift($shift); - $y->_lshift($shift); - $y_value = &$y->value; - - $x_max = count($x->value) - 1; - $y_max = count($y->value) - 1; - - $quotient = new static(); - $quotient_value = &$quotient->value; - $quotient_value = $this->_array_repeat(0, $x_max - $y_max + 1); - - static $temp, $lhs, $rhs; - if (!isset($temp)) { - $temp = new static(); - $lhs = new static(); - $rhs = new static(); - } - $temp_value = &$temp->value; - $rhs_value = &$rhs->value; - - // $temp = $y << ($x_max - $y_max-1) in base 2**26 - $temp_value = array_merge($this->_array_repeat(0, $x_max - $y_max), $y_value); - - while ($x->compare($temp) >= 0) { - // calculate the "common residue" - ++$quotient_value[$x_max - $y_max]; - $x = $x->subtract($temp); - $x_max = count($x->value) - 1; - } - - for ($i = $x_max; $i >= $y_max + 1; --$i) { - $x_value = &$x->value; - $x_window = array( - isset($x_value[$i]) ? $x_value[$i] : 0, - isset($x_value[$i - 1]) ? $x_value[$i - 1] : 0, - isset($x_value[$i - 2]) ? $x_value[$i - 2] : 0 - ); - $y_window = array( - $y_value[$y_max], - ($y_max > 0) ? $y_value[$y_max - 1] : 0 - ); - - $q_index = $i - $y_max - 1; - if ($x_window[0] == $y_window[0]) { - $quotient_value[$q_index] = self::$maxDigit; - } else { - $quotient_value[$q_index] = $this->_safe_divide( - $x_window[0] * self::$baseFull + $x_window[1], - $y_window[0] - ); - } - - $temp_value = array($y_window[1], $y_window[0]); - - $lhs->value = array($quotient_value[$q_index]); - $lhs = $lhs->multiply($temp); - - $rhs_value = array($x_window[2], $x_window[1], $x_window[0]); - - while ($lhs->compare($rhs) > 0) { - --$quotient_value[$q_index]; - - $lhs->value = array($quotient_value[$q_index]); - $lhs = $lhs->multiply($temp); - } - - $adjust = $this->_array_repeat(0, $q_index); - $temp_value = array($quotient_value[$q_index]); - $temp = $temp->multiply($y); - $temp_value = &$temp->value; - $temp_value = array_merge($adjust, $temp_value); - - $x = $x->subtract($temp); - - if ($x->compare($zero) < 0) { - $temp_value = array_merge($adjust, $y_value); - $x = $x->add($temp); - - --$quotient_value[$q_index]; - } - - $x_max = count($x_value) - 1; - } - - // unnormalize the remainder - $x->_rshift($shift); - - $quotient->is_negative = $x_sign != $y_sign; - - // calculate the "common residue", if appropriate - if ($x_sign) { - $y->_rshift($shift); - $x = $y->subtract($x); - } - - return array($this->_normalize($quotient), $this->_normalize($x)); - } - - /** - * Divides a BigInteger by a regular integer - * - * abc / x = a00 / x + b0 / x + c / x - * - * @param array $dividend - * @param array $divisor - * @return array - * @access private - */ - function _divide_digit($dividend, $divisor) - { - $carry = 0; - $result = array(); - - for ($i = count($dividend) - 1; $i >= 0; --$i) { - $temp = self::$baseFull * $carry + $dividend[$i]; - $result[$i] = $this->_safe_divide($temp, $divisor); - $carry = (int) ($temp - $divisor * $result[$i]); - } - - return array($result, $carry); - } - - /** - * Performs modular exponentiation. - * - * Here's an example: - * <code> - * <?php - * $a = new \phpseclib\Math\BigInteger('10'); - * $b = new \phpseclib\Math\BigInteger('20'); - * $c = new \phpseclib\Math\BigInteger('30'); - * - * $c = $a->modPow($b, $c); - * - * echo $c->toString(); // outputs 10 - * ?> - * </code> - * - * @param \phpseclib\Math\BigInteger $e - * @param \phpseclib\Math\BigInteger $n - * @return \phpseclib\Math\BigInteger - * @access public - * @internal The most naive approach to modular exponentiation has very unreasonable requirements, and - * and although the approach involving repeated squaring does vastly better, it, too, is impractical - * for our purposes. The reason being that division - by far the most complicated and time-consuming - * of the basic operations (eg. +,-,*,/) - occurs multiple times within it. - * - * Modular reductions resolve this issue. Although an individual modular reduction takes more time - * then an individual division, when performed in succession (with the same modulo), they're a lot faster. - * - * The two most commonly used modular reductions are Barrett and Montgomery reduction. Montgomery reduction, - * although faster, only works when the gcd of the modulo and of the base being used is 1. In RSA, when the - * base is a power of two, the modulo - a product of two primes - is always going to have a gcd of 1 (because - * the product of two odd numbers is odd), but what about when RSA isn't used? - * - * In contrast, Barrett reduction has no such constraint. As such, some bigint implementations perform a - * Barrett reduction after every operation in the modpow function. Others perform Barrett reductions when the - * modulo is even and Montgomery reductions when the modulo is odd. BigInteger.java's modPow method, however, - * uses a trick involving the Chinese Remainder Theorem to factor the even modulo into two numbers - one odd and - * the other, a power of two - and recombine them, later. This is the method that this modPow function uses. - * {@link http://islab.oregonstate.edu/papers/j34monex.pdf Montgomery Reduction with Even Modulus} elaborates. - */ - function modPow($e, $n) - { - $n = $this->bitmask !== false && $this->bitmask->compare($n) < 0 ? $this->bitmask : $n->abs(); - - if ($e->compare(new static()) < 0) { - $e = $e->abs(); - - $temp = $this->modInverse($n); - if ($temp === false) { - return false; - } - - return $this->_normalize($temp->modPow($e, $n)); - } - - if (MATH_BIGINTEGER_MODE == self::MODE_GMP) { - $temp = new static(); - $temp->value = gmp_powm($this->value, $e->value, $n->value); - - return $this->_normalize($temp); - } - - if ($this->compare(new static()) < 0 || $this->compare($n) > 0) { - list(, $temp) = $this->divide($n); - return $temp->modPow($e, $n); - } - - if (defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) { - $components = array( - 'modulus' => $n->toBytes(true), - 'publicExponent' => $e->toBytes(true) - ); - - $components = array( - 'modulus' => pack('Ca*a*', 2, $this->_encodeASN1Length(strlen($components['modulus'])), $components['modulus']), - 'publicExponent' => pack('Ca*a*', 2, $this->_encodeASN1Length(strlen($components['publicExponent'])), $components['publicExponent']) - ); - - $RSAPublicKey = pack( - 'Ca*a*a*', - 48, - $this->_encodeASN1Length(strlen($components['modulus']) + strlen($components['publicExponent'])), - $components['modulus'], - $components['publicExponent'] - ); - - $rsaOID = pack('H*', '300d06092a864886f70d0101010500'); // hex version of MA0GCSqGSIb3DQEBAQUA - $RSAPublicKey = chr(0) . $RSAPublicKey; - $RSAPublicKey = chr(3) . $this->_encodeASN1Length(strlen($RSAPublicKey)) . $RSAPublicKey; - - $encapsulated = pack( - 'Ca*a*', - 48, - $this->_encodeASN1Length(strlen($rsaOID . $RSAPublicKey)), - $rsaOID . $RSAPublicKey - ); - - $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . - chunk_split(base64_encode($encapsulated)) . - '-----END PUBLIC KEY-----'; - - $plaintext = str_pad($this->toBytes(), strlen($n->toBytes(true)) - 1, "\0", STR_PAD_LEFT); - - if (openssl_public_encrypt($plaintext, $result, $RSAPublicKey, OPENSSL_NO_PADDING)) { - return new static($result, 256); - } - } - - if (MATH_BIGINTEGER_MODE == self::MODE_BCMATH) { - $temp = new static(); - $temp->value = bcpowmod($this->value, $e->value, $n->value, 0); - - return $this->_normalize($temp); - } - - if (empty($e->value)) { - $temp = new static(); - $temp->value = array(1); - return $this->_normalize($temp); - } - - if ($e->value == array(1)) { - list(, $temp) = $this->divide($n); - return $this->_normalize($temp); - } - - if ($e->value == array(2)) { - $temp = new static(); - $temp->value = $this->_square($this->value); - list(, $temp) = $temp->divide($n); - return $this->_normalize($temp); - } - - return $this->_normalize($this->_slidingWindow($e, $n, self::BARRETT)); - - // the following code, although not callable, can be run independently of the above code - // although the above code performed better in my benchmarks the following could might - // perform better under different circumstances. in lieu of deleting it it's just been - // made uncallable - - // is the modulo odd? - if ($n->value[0] & 1) { - return $this->_normalize($this->_slidingWindow($e, $n, self::MONTGOMERY)); - } - // if it's not, it's even - - // find the lowest set bit (eg. the max pow of 2 that divides $n) - for ($i = 0; $i < count($n->value); ++$i) { - if ($n->value[$i]) { - $temp = decbin($n->value[$i]); - $j = strlen($temp) - strrpos($temp, '1') - 1; - $j+= 26 * $i; - break; - } - } - // at this point, 2^$j * $n/(2^$j) == $n - - $mod1 = $n->copy(); - $mod1->_rshift($j); - $mod2 = new static(); - $mod2->value = array(1); - $mod2->_lshift($j); - - $part1 = ($mod1->value != array(1)) ? $this->_slidingWindow($e, $mod1, self::MONTGOMERY) : new static(); - $part2 = $this->_slidingWindow($e, $mod2, self::POWEROF2); - - $y1 = $mod2->modInverse($mod1); - $y2 = $mod1->modInverse($mod2); - - $result = $part1->multiply($mod2); - $result = $result->multiply($y1); - - $temp = $part2->multiply($mod1); - $temp = $temp->multiply($y2); - - $result = $result->add($temp); - list(, $result) = $result->divide($n); - - return $this->_normalize($result); - } - - /** - * Performs modular exponentiation. - * - * Alias for modPow(). - * - * @param \phpseclib\Math\BigInteger $e - * @param \phpseclib\Math\BigInteger $n - * @return \phpseclib\Math\BigInteger - * @access public - */ - function powMod($e, $n) - { - return $this->modPow($e, $n); - } - - /** - * Sliding Window k-ary Modular Exponentiation - * - * Based on {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=27 HAC 14.85} / - * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=210 MPM 7.7}. In a departure from those algorithims, - * however, this function performs a modular reduction after every multiplication and squaring operation. - * As such, this function has the same preconditions that the reductions being used do. - * - * @param \phpseclib\Math\BigInteger $e - * @param \phpseclib\Math\BigInteger $n - * @param int $mode - * @return \phpseclib\Math\BigInteger - * @access private - */ - function _slidingWindow($e, $n, $mode) - { - static $window_ranges = array(7, 25, 81, 241, 673, 1793); // from BigInteger.java's oddModPow function - //static $window_ranges = array(0, 7, 36, 140, 450, 1303, 3529); // from MPM 7.3.1 - - $e_value = $e->value; - $e_length = count($e_value) - 1; - $e_bits = decbin($e_value[$e_length]); - for ($i = $e_length - 1; $i >= 0; --$i) { - $e_bits.= str_pad(decbin($e_value[$i]), self::$base, '0', STR_PAD_LEFT); - } - - $e_length = strlen($e_bits); - - // calculate the appropriate window size. - // $window_size == 3 if $window_ranges is between 25 and 81, for example. - for ($i = 0, $window_size = 1; $e_length > $window_ranges[$i] && $i < count($window_ranges); ++$window_size, ++$i) { - } - - $n_value = $n->value; - - // precompute $this^0 through $this^$window_size - $powers = array(); - $powers[1] = $this->_prepareReduce($this->value, $n_value, $mode); - $powers[2] = $this->_squareReduce($powers[1], $n_value, $mode); - - // we do every other number since substr($e_bits, $i, $j+1) (see below) is supposed to end - // in a 1. ie. it's supposed to be odd. - $temp = 1 << ($window_size - 1); - for ($i = 1; $i < $temp; ++$i) { - $i2 = $i << 1; - $powers[$i2 + 1] = $this->_multiplyReduce($powers[$i2 - 1], $powers[2], $n_value, $mode); - } - - $result = array(1); - $result = $this->_prepareReduce($result, $n_value, $mode); - - for ($i = 0; $i < $e_length;) { - if (!$e_bits[$i]) { - $result = $this->_squareReduce($result, $n_value, $mode); - ++$i; - } else { - for ($j = $window_size - 1; $j > 0; --$j) { - if (!empty($e_bits[$i + $j])) { - break; - } - } - - // eg. the length of substr($e_bits, $i, $j + 1) - for ($k = 0; $k <= $j; ++$k) { - $result = $this->_squareReduce($result, $n_value, $mode); - } - - $result = $this->_multiplyReduce($result, $powers[bindec(substr($e_bits, $i, $j + 1))], $n_value, $mode); - - $i += $j + 1; - } - } - - $temp = new static(); - $temp->value = $this->_reduce($result, $n_value, $mode); - - return $temp; - } - - /** - * Modular reduction - * - * For most $modes this will return the remainder. - * - * @see self::_slidingWindow() - * @access private - * @param array $x - * @param array $n - * @param int $mode - * @return array - */ - function _reduce($x, $n, $mode) - { - switch ($mode) { - case self::MONTGOMERY: - return $this->_montgomery($x, $n); - case self::BARRETT: - return $this->_barrett($x, $n); - case self::POWEROF2: - $lhs = new static(); - $lhs->value = $x; - $rhs = new static(); - $rhs->value = $n; - return $x->_mod2($n); - case self::CLASSIC: - $lhs = new static(); - $lhs->value = $x; - $rhs = new static(); - $rhs->value = $n; - list(, $temp) = $lhs->divide($rhs); - return $temp->value; - case self::NONE: - return $x; - default: - // an invalid $mode was provided - } - } - - /** - * Modular reduction preperation - * - * @see self::_slidingWindow() - * @access private - * @param array $x - * @param array $n - * @param int $mode - * @return array - */ - function _prepareReduce($x, $n, $mode) - { - if ($mode == self::MONTGOMERY) { - return $this->_prepMontgomery($x, $n); - } - return $this->_reduce($x, $n, $mode); - } - - /** - * Modular multiply - * - * @see self::_slidingWindow() - * @access private - * @param array $x - * @param array $y - * @param array $n - * @param int $mode - * @return array - */ - function _multiplyReduce($x, $y, $n, $mode) - { - if ($mode == self::MONTGOMERY) { - return $this->_montgomeryMultiply($x, $y, $n); - } - $temp = $this->_multiply($x, false, $y, false); - return $this->_reduce($temp[self::VALUE], $n, $mode); - } - - /** - * Modular square - * - * @see self::_slidingWindow() - * @access private - * @param array $x - * @param array $n - * @param int $mode - * @return array - */ - function _squareReduce($x, $n, $mode) - { - if ($mode == self::MONTGOMERY) { - return $this->_montgomeryMultiply($x, $x, $n); - } - return $this->_reduce($this->_square($x), $n, $mode); - } - - /** - * Modulos for Powers of Two - * - * Calculates $x%$n, where $n = 2**$e, for some $e. Since this is basically the same as doing $x & ($n-1), - * we'll just use this function as a wrapper for doing that. - * - * @see self::_slidingWindow() - * @access private - * @param \phpseclib\Math\BigInteger - * @return \phpseclib\Math\BigInteger - */ - function _mod2($n) - { - $temp = new static(); - $temp->value = array(1); - return $this->bitwise_and($n->subtract($temp)); - } - - /** - * Barrett Modular Reduction - * - * See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=14 HAC 14.3.3} / - * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=165 MPM 6.2.5} for more information. Modified slightly, - * so as not to require negative numbers (initially, this script didn't support negative numbers). - * - * Employs "folding", as described at - * {@link http://www.cosic.esat.kuleuven.be/publications/thesis-149.pdf#page=66 thesis-149.pdf#page=66}. To quote from - * it, "the idea [behind folding] is to find a value x' such that x (mod m) = x' (mod m), with x' being smaller than x." - * - * Unfortunately, the "Barrett Reduction with Folding" algorithm described in thesis-149.pdf is not, as written, all that - * usable on account of (1) its not using reasonable radix points as discussed in - * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=162 MPM 6.2.2} and (2) the fact that, even with reasonable - * radix points, it only works when there are an even number of digits in the denominator. The reason for (2) is that - * (x >> 1) + (x >> 1) != x / 2 + x / 2. If x is even, they're the same, but if x is odd, they're not. See the in-line - * comments for details. - * - * @see self::_slidingWindow() - * @access private - * @param array $n - * @param array $m - * @return array - */ - function _barrett($n, $m) - { - static $cache = array( - self::VARIABLE => array(), - self::DATA => array() - ); - - $m_length = count($m); - - // if ($this->_compare($n, $this->_square($m)) >= 0) { - if (count($n) > 2 * $m_length) { - $lhs = new static(); - $rhs = new static(); - $lhs->value = $n; - $rhs->value = $m; - list(, $temp) = $lhs->divide($rhs); - return $temp->value; - } - - // if (m.length >> 1) + 2 <= m.length then m is too small and n can't be reduced - if ($m_length < 5) { - return $this->_regularBarrett($n, $m); - } - - // n = 2 * m.length - - if (($key = array_search($m, $cache[self::VARIABLE])) === false) { - $key = count($cache[self::VARIABLE]); - $cache[self::VARIABLE][] = $m; - - $lhs = new static(); - $lhs_value = &$lhs->value; - $lhs_value = $this->_array_repeat(0, $m_length + ($m_length >> 1)); - $lhs_value[] = 1; - $rhs = new static(); - $rhs->value = $m; - - list($u, $m1) = $lhs->divide($rhs); - $u = $u->value; - $m1 = $m1->value; - - $cache[self::DATA][] = array( - 'u' => $u, // m.length >> 1 (technically (m.length >> 1) + 1) - 'm1'=> $m1 // m.length - ); - } else { - extract($cache[self::DATA][$key]); - } - - $cutoff = $m_length + ($m_length >> 1); - $lsd = array_slice($n, 0, $cutoff); // m.length + (m.length >> 1) - $msd = array_slice($n, $cutoff); // m.length >> 1 - $lsd = $this->_trim($lsd); - $temp = $this->_multiply($msd, false, $m1, false); - $n = $this->_add($lsd, false, $temp[self::VALUE], false); // m.length + (m.length >> 1) + 1 - - if ($m_length & 1) { - return $this->_regularBarrett($n[self::VALUE], $m); - } - - // (m.length + (m.length >> 1) + 1) - (m.length - 1) == (m.length >> 1) + 2 - $temp = array_slice($n[self::VALUE], $m_length - 1); - // if even: ((m.length >> 1) + 2) + (m.length >> 1) == m.length + 2 - // if odd: ((m.length >> 1) + 2) + (m.length >> 1) == (m.length - 1) + 2 == m.length + 1 - $temp = $this->_multiply($temp, false, $u, false); - // if even: (m.length + 2) - ((m.length >> 1) + 1) = m.length - (m.length >> 1) + 1 - // if odd: (m.length + 1) - ((m.length >> 1) + 1) = m.length - (m.length >> 1) - $temp = array_slice($temp[self::VALUE], ($m_length >> 1) + 1); - // if even: (m.length - (m.length >> 1) + 1) + m.length = 2 * m.length - (m.length >> 1) + 1 - // if odd: (m.length - (m.length >> 1)) + m.length = 2 * m.length - (m.length >> 1) - $temp = $this->_multiply($temp, false, $m, false); - - // at this point, if m had an odd number of digits, we'd be subtracting a 2 * m.length - (m.length >> 1) digit - // number from a m.length + (m.length >> 1) + 1 digit number. ie. there'd be an extra digit and the while loop - // following this comment would loop a lot (hence our calling _regularBarrett() in that situation). - - $result = $this->_subtract($n[self::VALUE], false, $temp[self::VALUE], false); - - while ($this->_compare($result[self::VALUE], $result[self::SIGN], $m, false) >= 0) { - $result = $this->_subtract($result[self::VALUE], $result[self::SIGN], $m, false); - } - - return $result[self::VALUE]; - } - - /** - * (Regular) Barrett Modular Reduction - * - * For numbers with more than four digits BigInteger::_barrett() is faster. The difference between that and this - * is that this function does not fold the denominator into a smaller form. - * - * @see self::_slidingWindow() - * @access private - * @param array $x - * @param array $n - * @return array - */ - function _regularBarrett($x, $n) - { - static $cache = array( - self::VARIABLE => array(), - self::DATA => array() - ); - - $n_length = count($n); - - if (count($x) > 2 * $n_length) { - $lhs = new static(); - $rhs = new static(); - $lhs->value = $x; - $rhs->value = $n; - list(, $temp) = $lhs->divide($rhs); - return $temp->value; - } - - if (($key = array_search($n, $cache[self::VARIABLE])) === false) { - $key = count($cache[self::VARIABLE]); - $cache[self::VARIABLE][] = $n; - $lhs = new static(); - $lhs_value = &$lhs->value; - $lhs_value = $this->_array_repeat(0, 2 * $n_length); - $lhs_value[] = 1; - $rhs = new static(); - $rhs->value = $n; - list($temp, ) = $lhs->divide($rhs); // m.length - $cache[self::DATA][] = $temp->value; - } - - // 2 * m.length - (m.length - 1) = m.length + 1 - $temp = array_slice($x, $n_length - 1); - // (m.length + 1) + m.length = 2 * m.length + 1 - $temp = $this->_multiply($temp, false, $cache[self::DATA][$key], false); - // (2 * m.length + 1) - (m.length - 1) = m.length + 2 - $temp = array_slice($temp[self::VALUE], $n_length + 1); - - // m.length + 1 - $result = array_slice($x, 0, $n_length + 1); - // m.length + 1 - $temp = $this->_multiplyLower($temp, false, $n, false, $n_length + 1); - // $temp == array_slice($temp->_multiply($temp, false, $n, false)->value, 0, $n_length + 1) - - if ($this->_compare($result, false, $temp[self::VALUE], $temp[self::SIGN]) < 0) { - $corrector_value = $this->_array_repeat(0, $n_length + 1); - $corrector_value[count($corrector_value)] = 1; - $result = $this->_add($result, false, $corrector_value, false); - $result = $result[self::VALUE]; - } - - // at this point, we're subtracting a number with m.length + 1 digits from another number with m.length + 1 digits - $result = $this->_subtract($result, false, $temp[self::VALUE], $temp[self::SIGN]); - while ($this->_compare($result[self::VALUE], $result[self::SIGN], $n, false) > 0) { - $result = $this->_subtract($result[self::VALUE], $result[self::SIGN], $n, false); - } - - return $result[self::VALUE]; - } - - /** - * Performs long multiplication up to $stop digits - * - * If you're going to be doing array_slice($product->value, 0, $stop), some cycles can be saved. - * - * @see self::_regularBarrett() - * @param array $x_value - * @param bool $x_negative - * @param array $y_value - * @param bool $y_negative - * @param int $stop - * @return array - * @access private - */ - function _multiplyLower($x_value, $x_negative, $y_value, $y_negative, $stop) - { - $x_length = count($x_value); - $y_length = count($y_value); - - if (!$x_length || !$y_length) { // a 0 is being multiplied - return array( - self::VALUE => array(), - self::SIGN => false - ); - } - - if ($x_length < $y_length) { - $temp = $x_value; - $x_value = $y_value; - $y_value = $temp; - - $x_length = count($x_value); - $y_length = count($y_value); - } - - $product_value = $this->_array_repeat(0, $x_length + $y_length); - - // the following for loop could be removed if the for loop following it - // (the one with nested for loops) initially set $i to 0, but - // doing so would also make the result in one set of unnecessary adds, - // since on the outermost loops first pass, $product->value[$k] is going - // to always be 0 - - $carry = 0; - - for ($j = 0; $j < $x_length; ++$j) { // ie. $i = 0, $k = $i - $temp = $x_value[$j] * $y_value[0] + $carry; // $product_value[$k] == 0 - $carry = self::$base === 26 ? intval($temp / 0x4000000) : ($temp >> 31); - $product_value[$j] = (int) ($temp - self::$baseFull * $carry); - } - - if ($j < $stop) { - $product_value[$j] = $carry; - } - - // the above for loop is what the previous comment was talking about. the - // following for loop is the "one with nested for loops" - - for ($i = 1; $i < $y_length; ++$i) { - $carry = 0; - - for ($j = 0, $k = $i; $j < $x_length && $k < $stop; ++$j, ++$k) { - $temp = $product_value[$k] + $x_value[$j] * $y_value[$i] + $carry; - $carry = self::$base === 26 ? intval($temp / 0x4000000) : ($temp >> 31); - $product_value[$k] = (int) ($temp - self::$baseFull * $carry); - } - - if ($k < $stop) { - $product_value[$k] = $carry; - } - } - - return array( - self::VALUE => $this->_trim($product_value), - self::SIGN => $x_negative != $y_negative - ); - } - - /** - * Montgomery Modular Reduction - * - * ($x->_prepMontgomery($n))->_montgomery($n) yields $x % $n. - * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=170 MPM 6.3} provides insights on how this can be - * improved upon (basically, by using the comba method). gcd($n, 2) must be equal to one for this function - * to work correctly. - * - * @see self::_prepMontgomery() - * @see self::_slidingWindow() - * @access private - * @param array $x - * @param array $n - * @return array - */ - function _montgomery($x, $n) - { - static $cache = array( - self::VARIABLE => array(), - self::DATA => array() - ); - - if (($key = array_search($n, $cache[self::VARIABLE])) === false) { - $key = count($cache[self::VARIABLE]); - $cache[self::VARIABLE][] = $x; - $cache[self::DATA][] = $this->_modInverse67108864($n); - } - - $k = count($n); - - $result = array(self::VALUE => $x); - - for ($i = 0; $i < $k; ++$i) { - $temp = $result[self::VALUE][$i] * $cache[self::DATA][$key]; - $temp = $temp - self::$baseFull * (self::$base === 26 ? intval($temp / 0x4000000) : ($temp >> 31)); - $temp = $this->_regularMultiply(array($temp), $n); - $temp = array_merge($this->_array_repeat(0, $i), $temp); - $result = $this->_add($result[self::VALUE], false, $temp, false); - } - - $result[self::VALUE] = array_slice($result[self::VALUE], $k); - - if ($this->_compare($result, false, $n, false) >= 0) { - $result = $this->_subtract($result[self::VALUE], false, $n, false); - } - - return $result[self::VALUE]; - } - - /** - * Montgomery Multiply - * - * Interleaves the montgomery reduction and long multiplication algorithms together as described in - * {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=13 HAC 14.36} - * - * @see self::_prepMontgomery() - * @see self::_montgomery() - * @access private - * @param array $x - * @param array $y - * @param array $m - * @return array - */ - function _montgomeryMultiply($x, $y, $m) - { - $temp = $this->_multiply($x, false, $y, false); - return $this->_montgomery($temp[self::VALUE], $m); - - // the following code, although not callable, can be run independently of the above code - // although the above code performed better in my benchmarks the following could might - // perform better under different circumstances. in lieu of deleting it it's just been - // made uncallable - - static $cache = array( - self::VARIABLE => array(), - self::DATA => array() - ); - - if (($key = array_search($m, $cache[self::VARIABLE])) === false) { - $key = count($cache[self::VARIABLE]); - $cache[self::VARIABLE][] = $m; - $cache[self::DATA][] = $this->_modInverse67108864($m); - } - - $n = max(count($x), count($y), count($m)); - $x = array_pad($x, $n, 0); - $y = array_pad($y, $n, 0); - $m = array_pad($m, $n, 0); - $a = array(self::VALUE => $this->_array_repeat(0, $n + 1)); - for ($i = 0; $i < $n; ++$i) { - $temp = $a[self::VALUE][0] + $x[$i] * $y[0]; - $temp = $temp - self::$baseFull * (self::$base === 26 ? intval($temp / 0x4000000) : ($temp >> 31)); - $temp = $temp * $cache[self::DATA][$key]; - $temp = $temp - self::$baseFull * (self::$base === 26 ? intval($temp / 0x4000000) : ($temp >> 31)); - $temp = $this->_add($this->_regularMultiply(array($x[$i]), $y), false, $this->_regularMultiply(array($temp), $m), false); - $a = $this->_add($a[self::VALUE], false, $temp[self::VALUE], false); - $a[self::VALUE] = array_slice($a[self::VALUE], 1); - } - if ($this->_compare($a[self::VALUE], false, $m, false) >= 0) { - $a = $this->_subtract($a[self::VALUE], false, $m, false); - } - return $a[self::VALUE]; - } - - /** - * Prepare a number for use in Montgomery Modular Reductions - * - * @see self::_montgomery() - * @see self::_slidingWindow() - * @access private - * @param array $x - * @param array $n - * @return array - */ - function _prepMontgomery($x, $n) - { - $lhs = new static(); - $lhs->value = array_merge($this->_array_repeat(0, count($n)), $x); - $rhs = new static(); - $rhs->value = $n; - - list(, $temp) = $lhs->divide($rhs); - return $temp->value; - } - - /** - * Modular Inverse of a number mod 2**26 (eg. 67108864) - * - * Based off of the bnpInvDigit function implemented and justified in the following URL: - * - * {@link http://www-cs-students.stanford.edu/~tjw/jsbn/jsbn.js} - * - * The following URL provides more info: - * - * {@link http://groups.google.com/group/sci.crypt/msg/7a137205c1be7d85} - * - * As for why we do all the bitmasking... strange things can happen when converting from floats to ints. For - * instance, on some computers, var_dump((int) -4294967297) yields int(-1) and on others, it yields - * int(-2147483648). To avoid problems stemming from this, we use bitmasks to guarantee that ints aren't - * auto-converted to floats. The outermost bitmask is present because without it, there's no guarantee that - * the "residue" returned would be the so-called "common residue". We use fmod, in the last step, because the - * maximum possible $x is 26 bits and the maximum $result is 16 bits. Thus, we have to be able to handle up to - * 40 bits, which only 64-bit floating points will support. - * - * Thanks to Pedro Gimeno Fortea for input! - * - * @see self::_montgomery() - * @access private - * @param array $x - * @return int - */ - function _modInverse67108864($x) // 2**26 == 67,108,864 - { - $x = -$x[0]; - $result = $x & 0x3; // x**-1 mod 2**2 - $result = ($result * (2 - $x * $result)) & 0xF; // x**-1 mod 2**4 - $result = ($result * (2 - ($x & 0xFF) * $result)) & 0xFF; // x**-1 mod 2**8 - $result = ($result * ((2 - ($x & 0xFFFF) * $result) & 0xFFFF)) & 0xFFFF; // x**-1 mod 2**16 - $result = fmod($result * (2 - fmod($x * $result, self::$baseFull)), self::$baseFull); // x**-1 mod 2**26 - return $result & self::$maxDigit; - } - - /** - * Calculates modular inverses. - * - * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses. - * - * Here's an example: - * <code> - * <?php - * $a = new \phpseclib\Math\BigInteger(30); - * $b = new \phpseclib\Math\BigInteger(17); - * - * $c = $a->modInverse($b); - * echo $c->toString(); // outputs 4 - * - * echo "\r\n"; - * - * $d = $a->multiply($c); - * list(, $d) = $d->divide($b); - * echo $d; // outputs 1 (as per the definition of modular inverse) - * ?> - * </code> - * - * @param \phpseclib\Math\BigInteger $n - * @return \phpseclib\Math\BigInteger|false - * @access public - * @internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=21 HAC 14.64} for more information. - */ - function modInverse($n) - { - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - $temp = new static(); - $temp->value = gmp_invert($this->value, $n->value); - - return ($temp->value === false) ? false : $this->_normalize($temp); - } - - static $zero, $one; - if (!isset($zero)) { - $zero = new static(); - $one = new static(1); - } - - // $x mod -$n == $x mod $n. - $n = $n->abs(); - - if ($this->compare($zero) < 0) { - $temp = $this->abs(); - $temp = $temp->modInverse($n); - return $this->_normalize($n->subtract($temp)); - } - - extract($this->extendedGCD($n)); - - if (!$gcd->equals($one)) { - return false; - } - - $x = $x->compare($zero) < 0 ? $x->add($n) : $x; - - return $this->compare($zero) < 0 ? $this->_normalize($n->subtract($x)) : $this->_normalize($x); - } - - /** - * Calculates the greatest common divisor and Bezout's identity. - * - * Say you have 693 and 609. The GCD is 21. Bezout's identity states that there exist integers x and y such that - * 693*x + 609*y == 21. In point of fact, there are actually an infinite number of x and y combinations and which - * combination is returned is dependant upon which mode is in use. See - * {@link http://en.wikipedia.org/wiki/B%C3%A9zout%27s_identity Bezout's identity - Wikipedia} for more information. - * - * Here's an example: - * <code> - * <?php - * $a = new \phpseclib\Math\BigInteger(693); - * $b = new \phpseclib\Math\BigInteger(609); - * - * extract($a->extendedGCD($b)); - * - * echo $gcd->toString() . "\r\n"; // outputs 21 - * echo $a->toString() * $x->toString() + $b->toString() * $y->toString(); // outputs 21 - * ?> - * </code> - * - * @param \phpseclib\Math\BigInteger $n - * @return \phpseclib\Math\BigInteger - * @access public - * @internal Calculates the GCD using the binary xGCD algorithim described in - * {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=19 HAC 14.61}. As the text above 14.61 notes, - * the more traditional algorithim requires "relatively costly multiple-precision divisions". - */ - function extendedGCD($n) - { - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - extract(gmp_gcdext($this->value, $n->value)); - - return array( - 'gcd' => $this->_normalize(new static($g)), - 'x' => $this->_normalize(new static($s)), - 'y' => $this->_normalize(new static($t)) - ); - case self::MODE_BCMATH: - // it might be faster to use the binary xGCD algorithim here, as well, but (1) that algorithim works - // best when the base is a power of 2 and (2) i don't think it'd make much difference, anyway. as is, - // the basic extended euclidean algorithim is what we're using. - - $u = $this->value; - $v = $n->value; - - $a = '1'; - $b = '0'; - $c = '0'; - $d = '1'; - - while (bccomp($v, '0', 0) != 0) { - $q = bcdiv($u, $v, 0); - - $temp = $u; - $u = $v; - $v = bcsub($temp, bcmul($v, $q, 0), 0); - - $temp = $a; - $a = $c; - $c = bcsub($temp, bcmul($a, $q, 0), 0); - - $temp = $b; - $b = $d; - $d = bcsub($temp, bcmul($b, $q, 0), 0); - } - - return array( - 'gcd' => $this->_normalize(new static($u)), - 'x' => $this->_normalize(new static($a)), - 'y' => $this->_normalize(new static($b)) - ); - } - - $y = $n->copy(); - $x = $this->copy(); - $g = new static(); - $g->value = array(1); - - while (!(($x->value[0] & 1)|| ($y->value[0] & 1))) { - $x->_rshift(1); - $y->_rshift(1); - $g->_lshift(1); - } - - $u = $x->copy(); - $v = $y->copy(); - - $a = new static(); - $b = new static(); - $c = new static(); - $d = new static(); - - $a->value = $d->value = $g->value = array(1); - $b->value = $c->value = array(); - - while (!empty($u->value)) { - while (!($u->value[0] & 1)) { - $u->_rshift(1); - if ((!empty($a->value) && ($a->value[0] & 1)) || (!empty($b->value) && ($b->value[0] & 1))) { - $a = $a->add($y); - $b = $b->subtract($x); - } - $a->_rshift(1); - $b->_rshift(1); - } - - while (!($v->value[0] & 1)) { - $v->_rshift(1); - if ((!empty($d->value) && ($d->value[0] & 1)) || (!empty($c->value) && ($c->value[0] & 1))) { - $c = $c->add($y); - $d = $d->subtract($x); - } - $c->_rshift(1); - $d->_rshift(1); - } - - if ($u->compare($v) >= 0) { - $u = $u->subtract($v); - $a = $a->subtract($c); - $b = $b->subtract($d); - } else { - $v = $v->subtract($u); - $c = $c->subtract($a); - $d = $d->subtract($b); - } - } - - return array( - 'gcd' => $this->_normalize($g->multiply($v)), - 'x' => $this->_normalize($c), - 'y' => $this->_normalize($d) - ); - } - - /** - * Calculates the greatest common divisor - * - * Say you have 693 and 609. The GCD is 21. - * - * Here's an example: - * <code> - * <?php - * $a = new \phpseclib\Math\BigInteger(693); - * $b = new \phpseclib\Math\BigInteger(609); - * - * $gcd = a->extendedGCD($b); - * - * echo $gcd->toString() . "\r\n"; // outputs 21 - * ?> - * </code> - * - * @param \phpseclib\Math\BigInteger $n - * @return \phpseclib\Math\BigInteger - * @access public - */ - function gcd($n) - { - extract($this->extendedGCD($n)); - return $gcd; - } - - /** - * Absolute value. - * - * @return \phpseclib\Math\BigInteger - * @access public - */ - function abs() - { - $temp = new static(); - - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - $temp->value = gmp_abs($this->value); - break; - case self::MODE_BCMATH: - $temp->value = (bccomp($this->value, '0', 0) < 0) ? substr($this->value, 1) : $this->value; - break; - default: - $temp->value = $this->value; - } - - return $temp; - } - - /** - * Compares two numbers. - * - * Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this is - * demonstrated thusly: - * - * $x > $y: $x->compare($y) > 0 - * $x < $y: $x->compare($y) < 0 - * $x == $y: $x->compare($y) == 0 - * - * Note how the same comparison operator is used. If you want to test for equality, use $x->equals($y). - * - * @param \phpseclib\Math\BigInteger $y - * @return int < 0 if $this is less than $y; > 0 if $this is greater than $y, and 0 if they are equal. - * @access public - * @see self::equals() - * @internal Could return $this->subtract($x), but that's not as fast as what we do do. - */ - function compare($y) - { - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - return gmp_cmp($this->value, $y->value); - case self::MODE_BCMATH: - return bccomp($this->value, $y->value, 0); - } - - return $this->_compare($this->value, $this->is_negative, $y->value, $y->is_negative); - } - - /** - * Compares two numbers. - * - * @param array $x_value - * @param bool $x_negative - * @param array $y_value - * @param bool $y_negative - * @return int - * @see self::compare() - * @access private - */ - function _compare($x_value, $x_negative, $y_value, $y_negative) - { - if ($x_negative != $y_negative) { - return (!$x_negative && $y_negative) ? 1 : -1; - } - - $result = $x_negative ? -1 : 1; - - if (count($x_value) != count($y_value)) { - return (count($x_value) > count($y_value)) ? $result : -$result; - } - $size = max(count($x_value), count($y_value)); - - $x_value = array_pad($x_value, $size, 0); - $y_value = array_pad($y_value, $size, 0); - - for ($i = count($x_value) - 1; $i >= 0; --$i) { - if ($x_value[$i] != $y_value[$i]) { - return ($x_value[$i] > $y_value[$i]) ? $result : -$result; - } - } - - return 0; - } - - /** - * Tests the equality of two numbers. - * - * If you need to see if one number is greater than or less than another number, use BigInteger::compare() - * - * @param \phpseclib\Math\BigInteger $x - * @return bool - * @access public - * @see self::compare() - */ - function equals($x) - { - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - return gmp_cmp($this->value, $x->value) == 0; - default: - return $this->value === $x->value && $this->is_negative == $x->is_negative; - } - } - - /** - * Set Precision - * - * Some bitwise operations give different results depending on the precision being used. Examples include left - * shift, not, and rotates. - * - * @param int $bits - * @access public - */ - function setPrecision($bits) - { - $this->precision = $bits; - if (MATH_BIGINTEGER_MODE != self::MODE_BCMATH) { - $this->bitmask = new static(chr((1 << ($bits & 0x7)) - 1) . str_repeat(chr(0xFF), $bits >> 3), 256); - } else { - $this->bitmask = new static(bcpow('2', $bits, 0)); - } - - $temp = $this->_normalize($this); - $this->value = $temp->value; - } - - /** - * Logical And - * - * @param \phpseclib\Math\BigInteger $x - * @access public - * @internal Implemented per a request by Lluis Pamies i Juarez <lluis _a_ pamies.cat> - * @return \phpseclib\Math\BigInteger - */ - function bitwise_and($x) - { - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - $temp = new static(); - $temp->value = gmp_and($this->value, $x->value); - - return $this->_normalize($temp); - case self::MODE_BCMATH: - $left = $this->toBytes(); - $right = $x->toBytes(); - - $length = max(strlen($left), strlen($right)); - - $left = str_pad($left, $length, chr(0), STR_PAD_LEFT); - $right = str_pad($right, $length, chr(0), STR_PAD_LEFT); - - return $this->_normalize(new static($left & $right, 256)); - } - - $result = $this->copy(); - - $length = min(count($x->value), count($this->value)); - - $result->value = array_slice($result->value, 0, $length); - - for ($i = 0; $i < $length; ++$i) { - $result->value[$i]&= $x->value[$i]; - } - - return $this->_normalize($result); - } - - /** - * Logical Or - * - * @param \phpseclib\Math\BigInteger $x - * @access public - * @internal Implemented per a request by Lluis Pamies i Juarez <lluis _a_ pamies.cat> - * @return \phpseclib\Math\BigInteger - */ - function bitwise_or($x) - { - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - $temp = new static(); - $temp->value = gmp_or($this->value, $x->value); - - return $this->_normalize($temp); - case self::MODE_BCMATH: - $left = $this->toBytes(); - $right = $x->toBytes(); - - $length = max(strlen($left), strlen($right)); - - $left = str_pad($left, $length, chr(0), STR_PAD_LEFT); - $right = str_pad($right, $length, chr(0), STR_PAD_LEFT); - - return $this->_normalize(new static($left | $right, 256)); - } - - $length = max(count($this->value), count($x->value)); - $result = $this->copy(); - $result->value = array_pad($result->value, $length, 0); - $x->value = array_pad($x->value, $length, 0); - - for ($i = 0; $i < $length; ++$i) { - $result->value[$i]|= $x->value[$i]; - } - - return $this->_normalize($result); - } - - /** - * Logical Exclusive-Or - * - * @param \phpseclib\Math\BigInteger $x - * @access public - * @internal Implemented per a request by Lluis Pamies i Juarez <lluis _a_ pamies.cat> - * @return \phpseclib\Math\BigInteger - */ - function bitwise_xor($x) - { - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - $temp = new static(); - $temp->value = gmp_xor($this->value, $x->value); - - return $this->_normalize($temp); - case self::MODE_BCMATH: - $left = $this->toBytes(); - $right = $x->toBytes(); - - $length = max(strlen($left), strlen($right)); - - $left = str_pad($left, $length, chr(0), STR_PAD_LEFT); - $right = str_pad($right, $length, chr(0), STR_PAD_LEFT); - - return $this->_normalize(new static($left ^ $right, 256)); - } - - $length = max(count($this->value), count($x->value)); - $result = $this->copy(); - $result->value = array_pad($result->value, $length, 0); - $x->value = array_pad($x->value, $length, 0); - - for ($i = 0; $i < $length; ++$i) { - $result->value[$i]^= $x->value[$i]; - } - - return $this->_normalize($result); - } - - /** - * Logical Not - * - * @access public - * @internal Implemented per a request by Lluis Pamies i Juarez <lluis _a_ pamies.cat> - * @return \phpseclib\Math\BigInteger - */ - function bitwise_not() - { - // calculuate "not" without regard to $this->precision - // (will always result in a smaller number. ie. ~1 isn't 1111 1110 - it's 0) - $temp = $this->toBytes(); - if ($temp == '') { - return ''; - } - $pre_msb = decbin(ord($temp[0])); - $temp = ~$temp; - $msb = decbin(ord($temp[0])); - if (strlen($msb) == 8) { - $msb = substr($msb, strpos($msb, '0')); - } - $temp[0] = chr(bindec($msb)); - - // see if we need to add extra leading 1's - $current_bits = strlen($pre_msb) + 8 * strlen($temp) - 8; - $new_bits = $this->precision - $current_bits; - if ($new_bits <= 0) { - return $this->_normalize(new static($temp, 256)); - } - - // generate as many leading 1's as we need to. - $leading_ones = chr((1 << ($new_bits & 0x7)) - 1) . str_repeat(chr(0xFF), $new_bits >> 3); - $this->_base256_lshift($leading_ones, $current_bits); - - $temp = str_pad($temp, strlen($leading_ones), chr(0), STR_PAD_LEFT); - - return $this->_normalize(new static($leading_ones | $temp, 256)); - } - - /** - * Logical Right Shift - * - * Shifts BigInteger's by $shift bits, effectively dividing by 2**$shift. - * - * @param int $shift - * @return \phpseclib\Math\BigInteger - * @access public - * @internal The only version that yields any speed increases is the internal version. - */ - function bitwise_rightShift($shift) - { - $temp = new static(); - - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - static $two; - - if (!isset($two)) { - $two = gmp_init('2'); - } - - $temp->value = gmp_div_q($this->value, gmp_pow($two, $shift)); - - break; - case self::MODE_BCMATH: - $temp->value = bcdiv($this->value, bcpow('2', $shift, 0), 0); - - break; - default: // could just replace _lshift with this, but then all _lshift() calls would need to be rewritten - // and I don't want to do that... - $temp->value = $this->value; - $temp->_rshift($shift); - } - - return $this->_normalize($temp); - } - - /** - * Logical Left Shift - * - * Shifts BigInteger's by $shift bits, effectively multiplying by 2**$shift. - * - * @param int $shift - * @return \phpseclib\Math\BigInteger - * @access public - * @internal The only version that yields any speed increases is the internal version. - */ - function bitwise_leftShift($shift) - { - $temp = new static(); - - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - static $two; - - if (!isset($two)) { - $two = gmp_init('2'); - } - - $temp->value = gmp_mul($this->value, gmp_pow($two, $shift)); - - break; - case self::MODE_BCMATH: - $temp->value = bcmul($this->value, bcpow('2', $shift, 0), 0); - - break; - default: // could just replace _rshift with this, but then all _lshift() calls would need to be rewritten - // and I don't want to do that... - $temp->value = $this->value; - $temp->_lshift($shift); - } - - return $this->_normalize($temp); - } - - /** - * Logical Left Rotate - * - * Instead of the top x bits being dropped they're appended to the shifted bit string. - * - * @param int $shift - * @return \phpseclib\Math\BigInteger - * @access public - */ - function bitwise_leftRotate($shift) - { - $bits = $this->toBytes(); - - if ($this->precision > 0) { - $precision = $this->precision; - if (MATH_BIGINTEGER_MODE == self::MODE_BCMATH) { - $mask = $this->bitmask->subtract(new static(1)); - $mask = $mask->toBytes(); - } else { - $mask = $this->bitmask->toBytes(); - } - } else { - $temp = ord($bits[0]); - for ($i = 0; $temp >> $i; ++$i) { - } - $precision = 8 * strlen($bits) - 8 + $i; - $mask = chr((1 << ($precision & 0x7)) - 1) . str_repeat(chr(0xFF), $precision >> 3); - } - - if ($shift < 0) { - $shift+= $precision; - } - $shift%= $precision; - - if (!$shift) { - return $this->copy(); - } - - $left = $this->bitwise_leftShift($shift); - $left = $left->bitwise_and(new static($mask, 256)); - $right = $this->bitwise_rightShift($precision - $shift); - $result = MATH_BIGINTEGER_MODE != self::MODE_BCMATH ? $left->bitwise_or($right) : $left->add($right); - return $this->_normalize($result); - } - - /** - * Logical Right Rotate - * - * Instead of the bottom x bits being dropped they're prepended to the shifted bit string. - * - * @param int $shift - * @return \phpseclib\Math\BigInteger - * @access public - */ - function bitwise_rightRotate($shift) - { - return $this->bitwise_leftRotate(-$shift); - } - - /** - * Generates a random BigInteger - * - * Byte length is equal to $length. Uses \phpseclib\Crypt\Random if it's loaded and mt_rand if it's not. - * - * @param int $length - * @return \phpseclib\Math\BigInteger - * @access private - */ - function _random_number_helper($size) - { - if (class_exists('\phpseclib\Crypt\Random')) { - $random = Random::string($size); - } else { - $random = ''; - - if ($size & 1) { - $random.= chr(mt_rand(0, 255)); - } - - $blocks = $size >> 1; - for ($i = 0; $i < $blocks; ++$i) { - // mt_rand(-2147483648, 0x7FFFFFFF) always produces -2147483648 on some systems - $random.= pack('n', mt_rand(0, 0xFFFF)); - } - } - - return new static($random, 256); - } - - /** - * Generate a random number - * - * Returns a random number between $min and $max where $min and $max - * can be defined using one of the two methods: - * - * $min->random($max) - * $max->random($min) - * - * @param \phpseclib\Math\BigInteger $arg1 - * @param \phpseclib\Math\BigInteger $arg2 - * @return \phpseclib\Math\BigInteger - * @access public - * @internal The API for creating random numbers used to be $a->random($min, $max), where $a was a BigInteger object. - * That method is still supported for BC purposes. - */ - function random($arg1, $arg2 = false) - { - if ($arg1 === false) { - return false; - } - - if ($arg2 === false) { - $max = $arg1; - $min = $this; - } else { - $min = $arg1; - $max = $arg2; - } - - $compare = $max->compare($min); - - if (!$compare) { - return $this->_normalize($min); - } elseif ($compare < 0) { - // if $min is bigger then $max, swap $min and $max - $temp = $max; - $max = $min; - $min = $temp; - } - - static $one; - if (!isset($one)) { - $one = new static(1); - } - - $max = $max->subtract($min->subtract($one)); - $size = strlen(ltrim($max->toBytes(), chr(0))); - - /* - doing $random % $max doesn't work because some numbers will be more likely to occur than others. - eg. if $max is 140 and $random's max is 255 then that'd mean both $random = 5 and $random = 145 - would produce 5 whereas the only value of random that could produce 139 would be 139. ie. - not all numbers would be equally likely. some would be more likely than others. - - creating a whole new random number until you find one that is within the range doesn't work - because, for sufficiently small ranges, the likelihood that you'd get a number within that range - would be pretty small. eg. with $random's max being 255 and if your $max being 1 the probability - would be pretty high that $random would be greater than $max. - - phpseclib works around this using the technique described here: - - http://crypto.stackexchange.com/questions/5708/creating-a-small-number-from-a-cryptographically-secure-random-string - */ - $random_max = new static(chr(1) . str_repeat("\0", $size), 256); - $random = $this->_random_number_helper($size); - - list($max_multiple) = $random_max->divide($max); - $max_multiple = $max_multiple->multiply($max); - - while ($random->compare($max_multiple) >= 0) { - $random = $random->subtract($max_multiple); - $random_max = $random_max->subtract($max_multiple); - $random = $random->bitwise_leftShift(8); - $random = $random->add($this->_random_number_helper(1)); - $random_max = $random_max->bitwise_leftShift(8); - list($max_multiple) = $random_max->divide($max); - $max_multiple = $max_multiple->multiply($max); - } - list(, $random) = $random->divide($max); - - return $this->_normalize($random->add($min)); - } - - /** - * Generate a random prime number. - * - * If there's not a prime within the given range, false will be returned. - * If more than $timeout seconds have elapsed, give up and return false. - * - * @param \phpseclib\Math\BigInteger $arg1 - * @param \phpseclib\Math\BigInteger $arg2 - * @param int $timeout - * @return Math_BigInteger|false - * @access public - * @internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap4.pdf#page=15 HAC 4.44}. - */ - function randomPrime($arg1, $arg2 = false, $timeout = false) - { - if ($arg1 === false) { - return false; - } - - if ($arg2 === false) { - $max = $arg1; - $min = $this; - } else { - $min = $arg1; - $max = $arg2; - } - - $compare = $max->compare($min); - - if (!$compare) { - return $min->isPrime() ? $min : false; - } elseif ($compare < 0) { - // if $min is bigger then $max, swap $min and $max - $temp = $max; - $max = $min; - $min = $temp; - } - - static $one, $two; - if (!isset($one)) { - $one = new static(1); - $two = new static(2); - } - - $start = time(); - - $x = $this->random($min, $max); - - // gmp_nextprime() requires PHP 5 >= 5.2.0 per <http://php.net/gmp-nextprime>. - if (MATH_BIGINTEGER_MODE == self::MODE_GMP && extension_loaded('gmp')) { - $p = new static(); - $p->value = gmp_nextprime($x->value); - - if ($p->compare($max) <= 0) { - return $p; - } - - if (!$min->equals($x)) { - $x = $x->subtract($one); - } - - return $x->randomPrime($min, $x); - } - - if ($x->equals($two)) { - return $x; - } - - $x->_make_odd(); - if ($x->compare($max) > 0) { - // if $x > $max then $max is even and if $min == $max then no prime number exists between the specified range - if ($min->equals($max)) { - return false; - } - $x = $min->copy(); - $x->_make_odd(); - } - - $initial_x = $x->copy(); - - while (true) { - if ($timeout !== false && time() - $start > $timeout) { - return false; - } - - if ($x->isPrime()) { - return $x; - } - - $x = $x->add($two); - - if ($x->compare($max) > 0) { - $x = $min->copy(); - if ($x->equals($two)) { - return $x; - } - $x->_make_odd(); - } - - if ($x->equals($initial_x)) { - return false; - } - } - } - - /** - * Make the current number odd - * - * If the current number is odd it'll be unchanged. If it's even, one will be added to it. - * - * @see self::randomPrime() - * @access private - */ - function _make_odd() - { - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - gmp_setbit($this->value, 0); - break; - case self::MODE_BCMATH: - if ($this->value[strlen($this->value) - 1] % 2 == 0) { - $this->value = bcadd($this->value, '1'); - } - break; - default: - $this->value[0] |= 1; - } - } - - /** - * Checks a numer to see if it's prime - * - * Assuming the $t parameter is not set, this function has an error rate of 2**-80. The main motivation for the - * $t parameter is distributability. BigInteger::randomPrime() can be distributed across multiple pageloads - * on a website instead of just one. - * - * @param \phpseclib\Math\BigInteger $t - * @return bool - * @access public - * @internal Uses the - * {@link http://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test Miller-Rabin primality test}. See - * {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap4.pdf#page=8 HAC 4.24}. - */ - function isPrime($t = false) - { - $length = strlen($this->toBytes()); - - if (!$t) { - // see HAC 4.49 "Note (controlling the error probability)" - // @codingStandardsIgnoreStart - if ($length >= 163) { $t = 2; } // floor(1300 / 8) - else if ($length >= 106) { $t = 3; } // floor( 850 / 8) - else if ($length >= 81 ) { $t = 4; } // floor( 650 / 8) - else if ($length >= 68 ) { $t = 5; } // floor( 550 / 8) - else if ($length >= 56 ) { $t = 6; } // floor( 450 / 8) - else if ($length >= 50 ) { $t = 7; } // floor( 400 / 8) - else if ($length >= 43 ) { $t = 8; } // floor( 350 / 8) - else if ($length >= 37 ) { $t = 9; } // floor( 300 / 8) - else if ($length >= 31 ) { $t = 12; } // floor( 250 / 8) - else if ($length >= 25 ) { $t = 15; } // floor( 200 / 8) - else if ($length >= 18 ) { $t = 18; } // floor( 150 / 8) - else { $t = 27; } - // @codingStandardsIgnoreEnd - } - - // ie. gmp_testbit($this, 0) - // ie. isEven() or !isOdd() - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - return gmp_prob_prime($this->value, $t) != 0; - case self::MODE_BCMATH: - if ($this->value === '2') { - return true; - } - if ($this->value[strlen($this->value) - 1] % 2 == 0) { - return false; - } - break; - default: - if ($this->value == array(2)) { - return true; - } - if (~$this->value[0] & 1) { - return false; - } - } - - static $primes, $zero, $one, $two; - - if (!isset($primes)) { - $primes = array( - 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, - 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, - 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, - 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, - 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, - 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, - 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, - 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, - 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, - 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, - 953, 967, 971, 977, 983, 991, 997 - ); - - if (MATH_BIGINTEGER_MODE != self::MODE_INTERNAL) { - for ($i = 0; $i < count($primes); ++$i) { - $primes[$i] = new static($primes[$i]); - } - } - - $zero = new static(); - $one = new static(1); - $two = new static(2); - } - - if ($this->equals($one)) { - return false; - } - - // see HAC 4.4.1 "Random search for probable primes" - if (MATH_BIGINTEGER_MODE != self::MODE_INTERNAL) { - foreach ($primes as $prime) { - list(, $r) = $this->divide($prime); - if ($r->equals($zero)) { - return $this->equals($prime); - } - } - } else { - $value = $this->value; - foreach ($primes as $prime) { - list(, $r) = $this->_divide_digit($value, $prime); - if (!$r) { - return count($value) == 1 && $value[0] == $prime; - } - } - } - - $n = $this->copy(); - $n_1 = $n->subtract($one); - $n_2 = $n->subtract($two); - - $r = $n_1->copy(); - $r_value = $r->value; - // ie. $s = gmp_scan1($n, 0) and $r = gmp_div_q($n, gmp_pow(gmp_init('2'), $s)); - if (MATH_BIGINTEGER_MODE == self::MODE_BCMATH) { - $s = 0; - // if $n was 1, $r would be 0 and this would be an infinite loop, hence our $this->equals($one) check earlier - while ($r->value[strlen($r->value) - 1] % 2 == 0) { - $r->value = bcdiv($r->value, '2', 0); - ++$s; - } - } else { - for ($i = 0, $r_length = count($r_value); $i < $r_length; ++$i) { - $temp = ~$r_value[$i] & 0xFFFFFF; - for ($j = 1; ($temp >> $j) & 1; ++$j) { - } - if ($j != 25) { - break; - } - } - $s = 26 * $i + $j - 1; - $r->_rshift($s); - } - - for ($i = 0; $i < $t; ++$i) { - $a = $this->random($two, $n_2); - $y = $a->modPow($r, $n); - - if (!$y->equals($one) && !$y->equals($n_1)) { - for ($j = 1; $j < $s && !$y->equals($n_1); ++$j) { - $y = $y->modPow($two, $n); - if ($y->equals($one)) { - return false; - } - } - - if (!$y->equals($n_1)) { - return false; - } - } - } - return true; - } - - /** - * Logical Left Shift - * - * Shifts BigInteger's by $shift bits. - * - * @param int $shift - * @access private - */ - function _lshift($shift) - { - if ($shift == 0) { - return; - } - - $num_digits = (int) ($shift / self::$base); - $shift %= self::$base; - $shift = 1 << $shift; - - $carry = 0; - - for ($i = 0; $i < count($this->value); ++$i) { - $temp = $this->value[$i] * $shift + $carry; - $carry = self::$base === 26 ? intval($temp / 0x4000000) : ($temp >> 31); - $this->value[$i] = (int) ($temp - $carry * self::$baseFull); - } - - if ($carry) { - $this->value[count($this->value)] = $carry; - } - - while ($num_digits--) { - array_unshift($this->value, 0); - } - } - - /** - * Logical Right Shift - * - * Shifts BigInteger's by $shift bits. - * - * @param int $shift - * @access private - */ - function _rshift($shift) - { - if ($shift == 0) { - return; - } - - $num_digits = (int) ($shift / self::$base); - $shift %= self::$base; - $carry_shift = self::$base - $shift; - $carry_mask = (1 << $shift) - 1; - - if ($num_digits) { - $this->value = array_slice($this->value, $num_digits); - } - - $carry = 0; - - for ($i = count($this->value) - 1; $i >= 0; --$i) { - $temp = $this->value[$i] >> $shift | $carry; - $carry = ($this->value[$i] & $carry_mask) << $carry_shift; - $this->value[$i] = $temp; - } - - $this->value = $this->_trim($this->value); - } - - /** - * Normalize - * - * Removes leading zeros and truncates (if necessary) to maintain the appropriate precision - * - * @param \phpseclib\Math\BigInteger - * @return \phpseclib\Math\BigInteger - * @see self::_trim() - * @access private - */ - function _normalize($result) - { - $result->precision = $this->precision; - $result->bitmask = $this->bitmask; - - switch (MATH_BIGINTEGER_MODE) { - case self::MODE_GMP: - if ($this->bitmask !== false) { - $result->value = gmp_and($result->value, $result->bitmask->value); - } - - return $result; - case self::MODE_BCMATH: - if (!empty($result->bitmask->value)) { - $result->value = bcmod($result->value, $result->bitmask->value); - } - - return $result; - } - - $value = &$result->value; - - if (!count($value)) { - return $result; - } - - $value = $this->_trim($value); - - if (!empty($result->bitmask->value)) { - $length = min(count($value), count($this->bitmask->value)); - $value = array_slice($value, 0, $length); - - for ($i = 0; $i < $length; ++$i) { - $value[$i] = $value[$i] & $this->bitmask->value[$i]; - } - } - - return $result; - } - - /** - * Trim - * - * Removes leading zeros - * - * @param array $value - * @return \phpseclib\Math\BigInteger - * @access private - */ - function _trim($value) - { - for ($i = count($value) - 1; $i >= 0; --$i) { - if ($value[$i]) { - break; - } - unset($value[$i]); - } - - return $value; - } - - /** - * Array Repeat - * - * @param $input Array - * @param $multiplier mixed - * @return array - * @access private - */ - function _array_repeat($input, $multiplier) - { - return ($multiplier) ? array_fill(0, $multiplier, $input) : array(); - } - - /** - * Logical Left Shift - * - * Shifts binary strings $shift bits, essentially multiplying by 2**$shift. - * - * @param $x String - * @param $shift Integer - * @return string - * @access private - */ - function _base256_lshift(&$x, $shift) - { - if ($shift == 0) { - return; - } - - $num_bytes = $shift >> 3; // eg. floor($shift/8) - $shift &= 7; // eg. $shift % 8 - - $carry = 0; - for ($i = strlen($x) - 1; $i >= 0; --$i) { - $temp = ord($x[$i]) << $shift | $carry; - $x[$i] = chr($temp); - $carry = $temp >> 8; - } - $carry = ($carry != 0) ? chr($carry) : ''; - $x = $carry . $x . str_repeat(chr(0), $num_bytes); - } - - /** - * Logical Right Shift - * - * Shifts binary strings $shift bits, essentially dividing by 2**$shift and returning the remainder. - * - * @param $x String - * @param $shift Integer - * @return string - * @access private - */ - function _base256_rshift(&$x, $shift) - { - if ($shift == 0) { - $x = ltrim($x, chr(0)); - return ''; - } - - $num_bytes = $shift >> 3; // eg. floor($shift/8) - $shift &= 7; // eg. $shift % 8 - - $remainder = ''; - if ($num_bytes) { - $start = $num_bytes > strlen($x) ? -strlen($x) : -$num_bytes; - $remainder = substr($x, $start); - $x = substr($x, 0, -$num_bytes); - } - - $carry = 0; - $carry_shift = 8 - $shift; - for ($i = 0; $i < strlen($x); ++$i) { - $temp = (ord($x[$i]) >> $shift) | $carry; - $carry = (ord($x[$i]) << $carry_shift) & 0xFF; - $x[$i] = chr($temp); - } - $x = ltrim($x, chr(0)); - - $remainder = chr($carry >> $carry_shift) . $remainder; - - return ltrim($remainder, chr(0)); - } - - // one quirk about how the following functions are implemented is that PHP defines N to be an unsigned long - // at 32-bits, while java's longs are 64-bits. - - /** - * Converts 32-bit integers to bytes. - * - * @param int $x - * @return string - * @access private - */ - function _int2bytes($x) - { - return ltrim(pack('N', $x), chr(0)); - } - - /** - * Converts bytes to 32-bit integers - * - * @param string $x - * @return int - * @access private - */ - function _bytes2int($x) - { - $temp = unpack('Nint', str_pad($x, 4, chr(0), STR_PAD_LEFT)); - return $temp['int']; - } - - /** - * DER-encode an integer - * - * The ability to DER-encode integers is needed to create RSA public keys for use with OpenSSL - * - * @see self::modPow() - * @access private - * @param int $length - * @return string - */ - function _encodeASN1Length($length) - { - if ($length <= 0x7F) { - return chr($length); - } - - $temp = ltrim(pack('N', $length), chr(0)); - return pack('Ca*', 0x80 | strlen($temp), $temp); - } - - /** - * Single digit division - * - * Even if int64 is being used the division operator will return a float64 value - * if the dividend is not evenly divisible by the divisor. Since a float64 doesn't - * have the precision of int64 this is a problem so, when int64 is being used, - * we'll guarantee that the dividend is divisible by first subtracting the remainder. - * - * @access private - * @param int $x - * @param int $y - * @return int - */ - function _safe_divide($x, $y) - { - if (self::$base === 26) { - return (int) ($x / $y); - } - - // self::$base === 31 - return ($x - ($x % $y)) / $y; - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Net/SCP.php b/vendor/phpseclib/phpseclib/phpseclib/Net/SCP.php deleted file mode 100755 index 4db288573bb226dbc58c56e53b1b097f87d0fef1..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Net/SCP.php +++ /dev/null @@ -1,339 +0,0 @@ -<?php - -/** - * Pure-PHP implementation of SCP. - * - * PHP version 5 - * - * The API for this library is modeled after the API from PHP's {@link http://php.net/book.ftp FTP extension}. - * - * Here's a short example of how to use this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $ssh = new \phpseclib\Net\SSH2('www.domain.tld'); - * if (!$ssh->login('username', 'password')) { - * exit('bad login'); - * } - * $scp = new \phpseclib\Net\SCP($ssh); - * - * $scp->put('abcd', str_repeat('x', 1024*1024)); - * ?> - * </code> - * - * @category Net - * @package SCP - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2010 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Net; - -use phpseclib\Net\SSH1; -use phpseclib\Net\SSH2; - -/** - * Pure-PHP implementations of SCP. - * - * @package SCP - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class SCP -{ - /**#@+ - * @access public - * @see \phpseclib\Net\SCP::put() - */ - /** - * Reads data from a local file. - */ - const SOURCE_LOCAL_FILE = 1; - /** - * Reads data from a string. - */ - const SOURCE_STRING = 2; - /**#@-*/ - - /**#@+ - * @access private - * @see \phpseclib\Net\SCP::_send() - * @see \phpseclib\Net\SCP::_receive() - */ - /** - * SSH1 is being used. - */ - const MODE_SSH1 = 1; - /** - * SSH2 is being used. - */ - const MODE_SSH2 = 2; - /**#@-*/ - - /** - * SSH Object - * - * @var object - * @access private - */ - var $ssh; - - /** - * Packet Size - * - * @var int - * @access private - */ - var $packet_size; - - /** - * Mode - * - * @var int - * @access private - */ - var $mode; - - /** - * Default Constructor. - * - * Connects to an SSH server - * - * @param string $host - * @param int $port - * @param int $timeout - * @return \phpseclib\Net\SCP - * @access public - */ - function __construct($ssh) - { - if ($ssh instanceof SSH2) { - $this->mode = self::MODE_SSH2; - } elseif ($ssh instanceof SSH1) { - $this->packet_size = 50000; - $this->mode = self::MODE_SSH1; - } else { - return; - } - - $this->ssh = $ssh; - } - - /** - * Uploads a file to the SCP server. - * - * By default, \phpseclib\Net\SCP::put() does not read from the local filesystem. $data is dumped directly into $remote_file. - * So, for example, if you set $data to 'filename.ext' and then do \phpseclib\Net\SCP::get(), you will get a file, twelve bytes - * long, containing 'filename.ext' as its contents. - * - * Setting $mode to self::SOURCE_LOCAL_FILE will change the above behavior. With self::SOURCE_LOCAL_FILE, $remote_file will - * contain as many bytes as filename.ext does on your local filesystem. If your filename.ext is 1MB then that is how - * large $remote_file will be, as well. - * - * Currently, only binary mode is supported. As such, if the line endings need to be adjusted, you will need to take - * care of that, yourself. - * - * @param string $remote_file - * @param string $data - * @param int $mode - * @param callable $callback - * @return bool - * @access public - */ - function put($remote_file, $data, $mode = self::SOURCE_STRING, $callback = null) - { - if (!isset($this->ssh)) { - return false; - } - - if (!$this->ssh->exec('scp -t ' . escapeshellarg($remote_file), false)) { // -t = to - return false; - } - - $temp = $this->_receive(); - if ($temp !== chr(0)) { - return false; - } - - if ($this->mode == self::MODE_SSH2) { - $this->packet_size = $this->ssh->packet_size_client_to_server[SSH2::CHANNEL_EXEC] - 4; - } - - $remote_file = basename($remote_file); - - if ($mode == self::SOURCE_STRING) { - $size = strlen($data); - } else { - if (!is_file($data)) { - user_error("$data is not a valid file", E_USER_NOTICE); - return false; - } - - $fp = @fopen($data, 'rb'); - if (!$fp) { - return false; - } - $size = filesize($data); - } - - $this->_send('C0644 ' . $size . ' ' . $remote_file . "\n"); - - $temp = $this->_receive(); - if ($temp !== chr(0)) { - return false; - } - - $sent = 0; - while ($sent < $size) { - $temp = $mode & self::SOURCE_STRING ? substr($data, $sent, $this->packet_size) : fread($fp, $this->packet_size); - $this->_send($temp); - $sent+= strlen($temp); - - if (is_callable($callback)) { - call_user_func($callback, $sent); - } - } - $this->_close(); - - if ($mode != self::SOURCE_STRING) { - fclose($fp); - } - - return true; - } - - /** - * Downloads a file from the SCP server. - * - * Returns a string containing the contents of $remote_file if $local_file is left undefined or a boolean false if - * the operation was unsuccessful. If $local_file is defined, returns true or false depending on the success of the - * operation - * - * @param string $remote_file - * @param string $local_file - * @return mixed - * @access public - */ - function get($remote_file, $local_file = false) - { - if (!isset($this->ssh)) { - return false; - } - - if (!$this->ssh->exec('scp -f ' . escapeshellarg($remote_file), false)) { // -f = from - return false; - } - - $this->_send("\0"); - - if (!preg_match('#(?<perms>[^ ]+) (?<size>\d+) (?<name>.+)#', rtrim($this->_receive()), $info)) { - return false; - } - - $this->_send("\0"); - - $size = 0; - - if ($local_file !== false) { - $fp = @fopen($local_file, 'wb'); - if (!$fp) { - return false; - } - } - - $content = ''; - while ($size < $info['size']) { - $data = $this->_receive(); - // SCP usually seems to split stuff out into 16k chunks - $size+= strlen($data); - - if ($local_file === false) { - $content.= $data; - } else { - fputs($fp, $data); - } - } - - $this->_close(); - - if ($local_file !== false) { - fclose($fp); - return true; - } - - return $content; - } - - /** - * Sends a packet to an SSH server - * - * @param string $data - * @access private - */ - function _send($data) - { - switch ($this->mode) { - case self::MODE_SSH2: - $this->ssh->_send_channel_packet(SSH2::CHANNEL_EXEC, $data); - break; - case self::MODE_SSH1: - $data = pack('CNa*', NET_SSH1_CMSG_STDIN_DATA, strlen($data), $data); - $this->ssh->_send_binary_packet($data); - } - } - - /** - * Receives a packet from an SSH server - * - * @return string - * @access private - */ - function _receive() - { - switch ($this->mode) { - case self::MODE_SSH2: - return $this->ssh->_get_channel_packet(SSH2::CHANNEL_EXEC, true); - case self::MODE_SSH1: - if (!$this->ssh->bitmap) { - return false; - } - while (true) { - $response = $this->ssh->_get_binary_packet(); - switch ($response[SSH1::RESPONSE_TYPE]) { - case NET_SSH1_SMSG_STDOUT_DATA: - extract(unpack('Nlength', $response[SSH1::RESPONSE_DATA])); - return $this->ssh->_string_shift($response[SSH1::RESPONSE_DATA], $length); - case NET_SSH1_SMSG_STDERR_DATA: - break; - case NET_SSH1_SMSG_EXITSTATUS: - $this->ssh->_send_binary_packet(chr(NET_SSH1_CMSG_EXIT_CONFIRMATION)); - fclose($this->ssh->fsock); - $this->ssh->bitmap = 0; - return false; - default: - user_error('Unknown packet received', E_USER_NOTICE); - return false; - } - } - } - } - - /** - * Closes the connection to an SSH server - * - * @access private - */ - function _close() - { - switch ($this->mode) { - case self::MODE_SSH2: - $this->ssh->_close_channel(SSH2::CHANNEL_EXEC, true); - break; - case self::MODE_SSH1: - $this->ssh->disconnect(); - } - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php b/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php deleted file mode 100755 index 707808bb9ba530dfd99e8b9e65645783d326e77c..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php +++ /dev/null @@ -1,2844 +0,0 @@ -<?php - -/** - * Pure-PHP implementation of SFTP. - * - * PHP version 5 - * - * Currently only supports SFTPv2 and v3, which, according to wikipedia.org, "is the most widely used version, - * implemented by the popular OpenSSH SFTP server". If you want SFTPv4/5/6 support, provide me with access - * to an SFTPv4/5/6 server. - * - * The API for this library is modeled after the API from PHP's {@link http://php.net/book.ftp FTP extension}. - * - * Here's a short example of how to use this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $sftp = new \phpseclib\Net\SFTP('www.domain.tld'); - * if (!$sftp->login('username', 'password')) { - * exit('Login Failed'); - * } - * - * echo $sftp->pwd() . "\r\n"; - * $sftp->put('filename.ext', 'hello, world!'); - * print_r($sftp->nlist()); - * ?> - * </code> - * - * @category Net - * @package SFTP - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2009 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Net; - -use phpseclib\Net\SSH2; - -/** - * Pure-PHP implementations of SFTP. - * - * @package SFTP - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class SFTP extends SSH2 -{ - /** - * SFTP channel constant - * - * \phpseclib\Net\SSH2::exec() uses 0 and \phpseclib\Net\SSH2::read() / \phpseclib\Net\SSH2::write() use 1. - * - * @see \phpseclib\Net\SSH2::_send_channel_packet() - * @see \phpseclib\Net\SSH2::_get_channel_packet() - * @access private - */ - const CHANNEL = 0x100; - - /**#@+ - * @access public - * @see \phpseclib\Net\SFTP::put() - */ - /** - * Reads data from a local file. - */ - const SOURCE_LOCAL_FILE = 1; - /** - * Reads data from a string. - */ - // this value isn't really used anymore but i'm keeping it reserved for historical reasons - const SOURCE_STRING = 2; - /** - * Reads data from callback: - * function callback($length) returns string to proceed, null for EOF - */ - const SOURCE_CALLBACK = 16; - /** - * Resumes an upload - */ - const RESUME = 4; - /** - * Append a local file to an already existing remote file - */ - const RESUME_START = 8; - /**#@-*/ - - /** - * Packet Types - * - * @see self::__construct() - * @var array - * @access private - */ - var $packet_types = array(); - - /** - * Status Codes - * - * @see self::__construct() - * @var array - * @access private - */ - var $status_codes = array(); - - /** - * The Request ID - * - * The request ID exists in the off chance that a packet is sent out-of-order. Of course, this library doesn't support - * concurrent actions, so it's somewhat academic, here. - * - * @var int - * @see self::_send_sftp_packet() - * @access private - */ - var $request_id = false; - - /** - * The Packet Type - * - * The request ID exists in the off chance that a packet is sent out-of-order. Of course, this library doesn't support - * concurrent actions, so it's somewhat academic, here. - * - * @var int - * @see self::_get_sftp_packet() - * @access private - */ - var $packet_type = -1; - - /** - * Packet Buffer - * - * @var string - * @see self::_get_sftp_packet() - * @access private - */ - var $packet_buffer = ''; - - /** - * Extensions supported by the server - * - * @var array - * @see self::_initChannel() - * @access private - */ - var $extensions = array(); - - /** - * Server SFTP version - * - * @var int - * @see self::_initChannel() - * @access private - */ - var $version; - - /** - * Current working directory - * - * @var string - * @see self::_realpath() - * @see self::chdir() - * @access private - */ - var $pwd = false; - - /** - * Packet Type Log - * - * @see self::getLog() - * @var array - * @access private - */ - var $packet_type_log = array(); - - /** - * Packet Log - * - * @see self::getLog() - * @var array - * @access private - */ - var $packet_log = array(); - - /** - * Error information - * - * @see self::getSFTPErrors() - * @see self::getLastSFTPError() - * @var string - * @access private - */ - var $sftp_errors = array(); - - /** - * Stat Cache - * - * Rather than always having to open a directory and close it immediately there after to see if a file is a directory - * we'll cache the results. - * - * @see self::_update_stat_cache() - * @see self::_remove_from_stat_cache() - * @see self::_query_stat_cache() - * @var array - * @access private - */ - var $stat_cache = array(); - - /** - * Max SFTP Packet Size - * - * @see self::__construct() - * @see self::get() - * @var array - * @access private - */ - var $max_sftp_packet; - - /** - * Stat Cache Flag - * - * @see self::disableStatCache() - * @see self::enableStatCache() - * @var bool - * @access private - */ - var $use_stat_cache = true; - - /** - * Sort Options - * - * @see self::_comparator() - * @see self::setListOrder() - * @var array - * @access private - */ - var $sortOptions = array(); - - /** - * Default Constructor. - * - * Connects to an SFTP server - * - * @param string $host - * @param int $port - * @param int $timeout - * @return \phpseclib\Net\SFTP - * @access public - */ - function __construct($host, $port = 22, $timeout = 10) - { - parent::__construct($host, $port, $timeout); - - $this->max_sftp_packet = 1 << 15; - - $this->packet_types = array( - 1 => 'NET_SFTP_INIT', - 2 => 'NET_SFTP_VERSION', - /* the format of SSH_FXP_OPEN changed between SFTPv4 and SFTPv5+: - SFTPv5+: http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.1.1 - pre-SFTPv5 : http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-6.3 */ - 3 => 'NET_SFTP_OPEN', - 4 => 'NET_SFTP_CLOSE', - 5 => 'NET_SFTP_READ', - 6 => 'NET_SFTP_WRITE', - 7 => 'NET_SFTP_LSTAT', - 9 => 'NET_SFTP_SETSTAT', - 11 => 'NET_SFTP_OPENDIR', - 12 => 'NET_SFTP_READDIR', - 13 => 'NET_SFTP_REMOVE', - 14 => 'NET_SFTP_MKDIR', - 15 => 'NET_SFTP_RMDIR', - 16 => 'NET_SFTP_REALPATH', - 17 => 'NET_SFTP_STAT', - /* the format of SSH_FXP_RENAME changed between SFTPv4 and SFTPv5+: - SFTPv5+: http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.3 - pre-SFTPv5 : http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-6.5 */ - 18 => 'NET_SFTP_RENAME', - 19 => 'NET_SFTP_READLINK', - 20 => 'NET_SFTP_SYMLINK', - - 101=> 'NET_SFTP_STATUS', - 102=> 'NET_SFTP_HANDLE', - /* the format of SSH_FXP_NAME changed between SFTPv3 and SFTPv4+: - SFTPv4+: http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.4 - pre-SFTPv4 : http://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-7 */ - 103=> 'NET_SFTP_DATA', - 104=> 'NET_SFTP_NAME', - 105=> 'NET_SFTP_ATTRS', - - 200=> 'NET_SFTP_EXTENDED' - ); - $this->status_codes = array( - 0 => 'NET_SFTP_STATUS_OK', - 1 => 'NET_SFTP_STATUS_EOF', - 2 => 'NET_SFTP_STATUS_NO_SUCH_FILE', - 3 => 'NET_SFTP_STATUS_PERMISSION_DENIED', - 4 => 'NET_SFTP_STATUS_FAILURE', - 5 => 'NET_SFTP_STATUS_BAD_MESSAGE', - 6 => 'NET_SFTP_STATUS_NO_CONNECTION', - 7 => 'NET_SFTP_STATUS_CONNECTION_LOST', - 8 => 'NET_SFTP_STATUS_OP_UNSUPPORTED', - 9 => 'NET_SFTP_STATUS_INVALID_HANDLE', - 10 => 'NET_SFTP_STATUS_NO_SUCH_PATH', - 11 => 'NET_SFTP_STATUS_FILE_ALREADY_EXISTS', - 12 => 'NET_SFTP_STATUS_WRITE_PROTECT', - 13 => 'NET_SFTP_STATUS_NO_MEDIA', - 14 => 'NET_SFTP_STATUS_NO_SPACE_ON_FILESYSTEM', - 15 => 'NET_SFTP_STATUS_QUOTA_EXCEEDED', - 16 => 'NET_SFTP_STATUS_UNKNOWN_PRINCIPAL', - 17 => 'NET_SFTP_STATUS_LOCK_CONFLICT', - 18 => 'NET_SFTP_STATUS_DIR_NOT_EMPTY', - 19 => 'NET_SFTP_STATUS_NOT_A_DIRECTORY', - 20 => 'NET_SFTP_STATUS_INVALID_FILENAME', - 21 => 'NET_SFTP_STATUS_LINK_LOOP', - 22 => 'NET_SFTP_STATUS_CANNOT_DELETE', - 23 => 'NET_SFTP_STATUS_INVALID_PARAMETER', - 24 => 'NET_SFTP_STATUS_FILE_IS_A_DIRECTORY', - 25 => 'NET_SFTP_STATUS_BYTE_RANGE_LOCK_CONFLICT', - 26 => 'NET_SFTP_STATUS_BYTE_RANGE_LOCK_REFUSED', - 27 => 'NET_SFTP_STATUS_DELETE_PENDING', - 28 => 'NET_SFTP_STATUS_FILE_CORRUPT', - 29 => 'NET_SFTP_STATUS_OWNER_INVALID', - 30 => 'NET_SFTP_STATUS_GROUP_INVALID', - 31 => 'NET_SFTP_STATUS_NO_MATCHING_BYTE_RANGE_LOCK' - ); - // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-7.1 - // the order, in this case, matters quite a lot - see \phpseclib\Net\SFTP::_parseAttributes() to understand why - $this->attributes = array( - 0x00000001 => 'NET_SFTP_ATTR_SIZE', - 0x00000002 => 'NET_SFTP_ATTR_UIDGID', // defined in SFTPv3, removed in SFTPv4+ - 0x00000004 => 'NET_SFTP_ATTR_PERMISSIONS', - 0x00000008 => 'NET_SFTP_ATTR_ACCESSTIME', - // 0x80000000 will yield a floating point on 32-bit systems and converting floating points to integers - // yields inconsistent behavior depending on how php is compiled. so we left shift -1 (which, in - // two's compliment, consists of all 1 bits) by 31. on 64-bit systems this'll yield 0xFFFFFFFF80000000. - // that's not a problem, however, and 'anded' and a 32-bit number, as all the leading 1 bits are ignored. - -1 << 31 => 'NET_SFTP_ATTR_EXTENDED' - ); - // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-6.3 - // the flag definitions change somewhat in SFTPv5+. if SFTPv5+ support is added to this library, maybe name - // the array for that $this->open5_flags and similarily alter the constant names. - $this->open_flags = array( - 0x00000001 => 'NET_SFTP_OPEN_READ', - 0x00000002 => 'NET_SFTP_OPEN_WRITE', - 0x00000004 => 'NET_SFTP_OPEN_APPEND', - 0x00000008 => 'NET_SFTP_OPEN_CREATE', - 0x00000010 => 'NET_SFTP_OPEN_TRUNCATE', - 0x00000020 => 'NET_SFTP_OPEN_EXCL' - ); - // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-5.2 - // see \phpseclib\Net\SFTP::_parseLongname() for an explanation - $this->file_types = array( - 1 => 'NET_SFTP_TYPE_REGULAR', - 2 => 'NET_SFTP_TYPE_DIRECTORY', - 3 => 'NET_SFTP_TYPE_SYMLINK', - 4 => 'NET_SFTP_TYPE_SPECIAL', - 5 => 'NET_SFTP_TYPE_UNKNOWN', - // the followin types were first defined for use in SFTPv5+ - // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-05#section-5.2 - 6 => 'NET_SFTP_TYPE_SOCKET', - 7 => 'NET_SFTP_TYPE_CHAR_DEVICE', - 8 => 'NET_SFTP_TYPE_BLOCK_DEVICE', - 9 => 'NET_SFTP_TYPE_FIFO' - ); - $this->_define_array( - $this->packet_types, - $this->status_codes, - $this->attributes, - $this->open_flags, - $this->file_types - ); - - if (!defined('NET_SFTP_QUEUE_SIZE')) { - define('NET_SFTP_QUEUE_SIZE', 50); - } - } - - /** - * Login - * - * @param string $username - * @param string $password - * @return bool - * @access public - */ - function login($username) - { - $args = func_get_args(); - if (!call_user_func_array(array(&$this, '_login'), $args)) { - return false; - } - - $this->window_size_server_to_client[self::CHANNEL] = $this->window_size; - - $packet = pack( - 'CNa*N3', - NET_SSH2_MSG_CHANNEL_OPEN, - strlen('session'), - 'session', - self::CHANNEL, - $this->window_size, - 0x4000 - ); - - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $this->channel_status[self::CHANNEL] = NET_SSH2_MSG_CHANNEL_OPEN; - - $response = $this->_get_channel_packet(self::CHANNEL); - if ($response === false) { - return false; - } - - $packet = pack( - 'CNNa*CNa*', - NET_SSH2_MSG_CHANNEL_REQUEST, - $this->server_channels[self::CHANNEL], - strlen('subsystem'), - 'subsystem', - 1, - strlen('sftp'), - 'sftp' - ); - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $this->channel_status[self::CHANNEL] = NET_SSH2_MSG_CHANNEL_REQUEST; - - $response = $this->_get_channel_packet(self::CHANNEL); - if ($response === false) { - // from PuTTY's psftp.exe - $command = "test -x /usr/lib/sftp-server && exec /usr/lib/sftp-server\n" . - "test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n" . - "exec sftp-server"; - // we don't do $this->exec($command, false) because exec() operates on a different channel and plus the SSH_MSG_CHANNEL_OPEN that exec() does - // is redundant - $packet = pack( - 'CNNa*CNa*', - NET_SSH2_MSG_CHANNEL_REQUEST, - $this->server_channels[self::CHANNEL], - strlen('exec'), - 'exec', - 1, - strlen($command), - $command - ); - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $this->channel_status[self::CHANNEL] = NET_SSH2_MSG_CHANNEL_REQUEST; - - $response = $this->_get_channel_packet(self::CHANNEL); - if ($response === false) { - return false; - } - } - - $this->channel_status[self::CHANNEL] = NET_SSH2_MSG_CHANNEL_DATA; - - if (!$this->_send_sftp_packet(NET_SFTP_INIT, "\0\0\0\3")) { - return false; - } - - $response = $this->_get_sftp_packet(); - if ($this->packet_type != NET_SFTP_VERSION) { - user_error('Expected SSH_FXP_VERSION'); - return false; - } - - extract(unpack('Nversion', $this->_string_shift($response, 4))); - $this->version = $version; - while (!empty($response)) { - extract(unpack('Nlength', $this->_string_shift($response, 4))); - $key = $this->_string_shift($response, $length); - extract(unpack('Nlength', $this->_string_shift($response, 4))); - $value = $this->_string_shift($response, $length); - $this->extensions[$key] = $value; - } - - /* - SFTPv4+ defines a 'newline' extension. SFTPv3 seems to have unofficial support for it via 'newline@vandyke.com', - however, I'm not sure what 'newline@vandyke.com' is supposed to do (the fact that it's unofficial means that it's - not in the official SFTPv3 specs) and 'newline@vandyke.com' / 'newline' are likely not drop-in substitutes for - one another due to the fact that 'newline' comes with a SSH_FXF_TEXT bitmask whereas it seems unlikely that - 'newline@vandyke.com' would. - */ - /* - if (isset($this->extensions['newline@vandyke.com'])) { - $this->extensions['newline'] = $this->extensions['newline@vandyke.com']; - unset($this->extensions['newline@vandyke.com']); - } - */ - - $this->request_id = 1; - - /* - A Note on SFTPv4/5/6 support: - <http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-5.1> states the following: - - "If the client wishes to interoperate with servers that support noncontiguous version - numbers it SHOULD send '3'" - - Given that the server only sends its version number after the client has already done so, the above - seems to be suggesting that v3 should be the default version. This makes sense given that v3 is the - most popular. - - <http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-5.5> states the following; - - "If the server did not send the "versions" extension, or the version-from-list was not included, the - server MAY send a status response describing the failure, but MUST then close the channel without - processing any further requests." - - So what do you do if you have a client whose initial SSH_FXP_INIT packet says it implements v3 and - a server whose initial SSH_FXP_VERSION reply says it implements v4 and only v4? If it only implements - v4, the "versions" extension is likely not going to have been sent so version re-negotiation as discussed - in draft-ietf-secsh-filexfer-13 would be quite impossible. As such, what \phpseclib\Net\SFTP would do is close the - channel and reopen it with a new and updated SSH_FXP_INIT packet. - */ - switch ($this->version) { - case 2: - case 3: - break; - default: - return false; - } - - $this->pwd = $this->_realpath('.'); - - $this->_update_stat_cache($this->pwd, array()); - - return true; - } - - /** - * Disable the stat cache - * - * @access public - */ - function disableStatCache() - { - $this->use_stat_cache = false; - } - - /** - * Enable the stat cache - * - * @access public - */ - function enableStatCache() - { - $this->use_stat_cache = true; - } - - /** - * Clear the stat cache - * - * @access public - */ - function clearStatCache() - { - $this->stat_cache = array(); - } - - /** - * Returns the current directory name - * - * @return mixed - * @access public - */ - function pwd() - { - return $this->pwd; - } - - /** - * Logs errors - * - * @param string $response - * @param int $status - * @access public - */ - function _logError($response, $status = -1) - { - if ($status == -1) { - extract(unpack('Nstatus', $this->_string_shift($response, 4))); - } - - $error = $this->status_codes[$status]; - - if ($this->version > 2) { - extract(unpack('Nlength', $this->_string_shift($response, 4))); - $this->sftp_errors[] = $error . ': ' . $this->_string_shift($response, $length); - } else { - $this->sftp_errors[] = $error; - } - } - - /** - * Canonicalize the Server-Side Path Name - * - * SFTP doesn't provide a mechanism by which the current working directory can be changed, so we'll emulate it. Returns - * the absolute (canonicalized) path. - * - * @see self::chdir() - * @param string $path - * @return mixed - * @access private - */ - function _realpath($path) - { - if ($this->pwd === false) { - // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.9 - if (!$this->_send_sftp_packet(NET_SFTP_REALPATH, pack('Na*', strlen($path), $path))) { - return false; - } - - $response = $this->_get_sftp_packet(); - switch ($this->packet_type) { - case NET_SFTP_NAME: - // although SSH_FXP_NAME is implemented differently in SFTPv3 than it is in SFTPv4+, the following - // should work on all SFTP versions since the only part of the SSH_FXP_NAME packet the following looks - // at is the first part and that part is defined the same in SFTP versions 3 through 6. - $this->_string_shift($response, 4); // skip over the count - it should be 1, anyway - extract(unpack('Nlength', $this->_string_shift($response, 4))); - return $this->_string_shift($response, $length); - case NET_SFTP_STATUS: - $this->_logError($response); - return false; - default: - user_error('Expected SSH_FXP_NAME or SSH_FXP_STATUS'); - return false; - } - } - - if ($path[0] != '/') { - $path = $this->pwd . '/' . $path; - } - - $path = explode('/', $path); - $new = array(); - foreach ($path as $dir) { - if (!strlen($dir)) { - continue; - } - switch ($dir) { - case '..': - array_pop($new); - case '.': - break; - default: - $new[] = $dir; - } - } - - return '/' . implode('/', $new); - } - - /** - * Changes the current directory - * - * @param string $dir - * @return bool - * @access public - */ - function chdir($dir) - { - if (!($this->bitmap & SSH2::MASK_LOGIN)) { - return false; - } - - // assume current dir if $dir is empty - if ($dir === '') { - $dir = './'; - // suffix a slash if needed - } elseif ($dir[strlen($dir) - 1] != '/') { - $dir.= '/'; - } - - $dir = $this->_realpath($dir); - - // confirm that $dir is, in fact, a valid directory - if ($this->use_stat_cache && is_array($this->_query_stat_cache($dir))) { - $this->pwd = $dir; - return true; - } - - // we could do a stat on the alleged $dir to see if it's a directory but that doesn't tell us - // the currently logged in user has the appropriate permissions or not. maybe you could see if - // the file's uid / gid match the currently logged in user's uid / gid but how there's no easy - // way to get those with SFTP - - if (!$this->_send_sftp_packet(NET_SFTP_OPENDIR, pack('Na*', strlen($dir), $dir))) { - return false; - } - - // see \phpseclib\Net\SFTP::nlist() for a more thorough explanation of the following - $response = $this->_get_sftp_packet(); - switch ($this->packet_type) { - case NET_SFTP_HANDLE: - $handle = substr($response, 4); - break; - case NET_SFTP_STATUS: - $this->_logError($response); - return false; - default: - user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS'); - return false; - } - - if (!$this->_close_handle($handle)) { - return false; - } - - $this->_update_stat_cache($dir, array()); - - $this->pwd = $dir; - return true; - } - - /** - * Returns a list of files in the given directory - * - * @param string $dir - * @param bool $recursive - * @return mixed - * @access public - */ - function nlist($dir = '.', $recursive = false) - { - return $this->_nlist_helper($dir, $recursive, ''); - } - - /** - * Helper method for nlist - * - * @param string $dir - * @param bool $recursive - * @param string $relativeDir - * @return mixed - * @access private - */ - function _nlist_helper($dir, $recursive, $relativeDir) - { - $files = $this->_list($dir, false); - - if (!$recursive) { - return $files; - } - - $result = array(); - foreach ($files as $value) { - if ($value == '.' || $value == '..') { - if ($relativeDir == '') { - $result[] = $value; - } - continue; - } - if (is_array($this->_query_stat_cache($this->_realpath($dir . '/' . $value)))) { - $temp = $this->_nlist_helper($dir . '/' . $value, true, $relativeDir . $value . '/'); - $result = array_merge($result, $temp); - } else { - $result[] = $relativeDir . $value; - } - } - - return $result; - } - - /** - * Returns a detailed list of files in the given directory - * - * @param string $dir - * @param bool $recursive - * @return mixed - * @access public - */ - function rawlist($dir = '.', $recursive = false) - { - $files = $this->_list($dir, true); - if (!$recursive || $files === false) { - return $files; - } - - static $depth = 0; - - foreach ($files as $key => $value) { - if ($depth != 0 && $key == '..') { - unset($files[$key]); - continue; - } - if ($key != '.' && $key != '..' && is_array($this->_query_stat_cache($this->_realpath($dir . '/' . $key)))) { - $depth++; - $files[$key] = $this->rawlist($dir . '/' . $key, true); - $depth--; - } else { - $files[$key] = (object) $value; - } - } - - return $files; - } - - /** - * Reads a list, be it detailed or not, of files in the given directory - * - * @param string $dir - * @param bool $raw - * @return mixed - * @access private - */ - function _list($dir, $raw = true) - { - if (!($this->bitmap & SSH2::MASK_LOGIN)) { - return false; - } - - $dir = $this->_realpath($dir . '/'); - if ($dir === false) { - return false; - } - - // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.1.2 - if (!$this->_send_sftp_packet(NET_SFTP_OPENDIR, pack('Na*', strlen($dir), $dir))) { - return false; - } - - $response = $this->_get_sftp_packet(); - switch ($this->packet_type) { - case NET_SFTP_HANDLE: - // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.2 - // since 'handle' is the last field in the SSH_FXP_HANDLE packet, we'll just remove the first four bytes that - // represent the length of the string and leave it at that - $handle = substr($response, 4); - break; - case NET_SFTP_STATUS: - // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED - $this->_logError($response); - return false; - default: - user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS'); - return false; - } - - $this->_update_stat_cache($dir, array()); - - $contents = array(); - while (true) { - // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.2.2 - // why multiple SSH_FXP_READDIR packets would be sent when the response to a single one can span arbitrarily many - // SSH_MSG_CHANNEL_DATA messages is not known to me. - if (!$this->_send_sftp_packet(NET_SFTP_READDIR, pack('Na*', strlen($handle), $handle))) { - return false; - } - - $response = $this->_get_sftp_packet(); - switch ($this->packet_type) { - case NET_SFTP_NAME: - extract(unpack('Ncount', $this->_string_shift($response, 4))); - for ($i = 0; $i < $count; $i++) { - extract(unpack('Nlength', $this->_string_shift($response, 4))); - $shortname = $this->_string_shift($response, $length); - extract(unpack('Nlength', $this->_string_shift($response, 4))); - $longname = $this->_string_shift($response, $length); - $attributes = $this->_parseAttributes($response); - if (!isset($attributes['type'])) { - $fileType = $this->_parseLongname($longname); - if ($fileType) { - $attributes['type'] = $fileType; - } - } - $contents[$shortname] = $attributes + array('filename' => $shortname); - - if (isset($attributes['type']) && $attributes['type'] == NET_SFTP_TYPE_DIRECTORY && ($shortname != '.' && $shortname != '..')) { - $this->_update_stat_cache($dir . '/' . $shortname, array()); - } else { - if ($shortname == '..') { - $temp = $this->_realpath($dir . '/..') . '/.'; - } else { - $temp = $dir . '/' . $shortname; - } - $this->_update_stat_cache($temp, (object) array('lstat' => $attributes)); - } - // SFTPv6 has an optional boolean end-of-list field, but we'll ignore that, since the - // final SSH_FXP_STATUS packet should tell us that, already. - } - break; - case NET_SFTP_STATUS: - extract(unpack('Nstatus', $this->_string_shift($response, 4))); - if ($status != NET_SFTP_STATUS_EOF) { - $this->_logError($response, $status); - return false; - } - break 2; - default: - user_error('Expected SSH_FXP_NAME or SSH_FXP_STATUS'); - return false; - } - } - - if (!$this->_close_handle($handle)) { - return false; - } - - if (count($this->sortOptions)) { - uasort($contents, array(&$this, '_comparator')); - } - - return $raw ? $contents : array_keys($contents); - } - - /** - * Compares two rawlist entries using parameters set by setListOrder() - * - * Intended for use with uasort() - * - * @param array $a - * @param array $b - * @return int - * @access private - */ - function _comparator($a, $b) - { - switch (true) { - case $a['filename'] === '.' || $b['filename'] === '.': - if ($a['filename'] === $b['filename']) { - return 0; - } - return $a['filename'] === '.' ? -1 : 1; - case $a['filename'] === '..' || $b['filename'] === '..': - if ($a['filename'] === $b['filename']) { - return 0; - } - return $a['filename'] === '..' ? -1 : 1; - case isset($a['type']) && $a['type'] === NET_SFTP_TYPE_DIRECTORY: - if (!isset($b['type'])) { - return 1; - } - if ($b['type'] !== $a['type']) { - return -1; - } - break; - case isset($b['type']) && $b['type'] === NET_SFTP_TYPE_DIRECTORY: - return 1; - } - foreach ($this->sortOptions as $sort => $order) { - if (!isset($a[$sort]) || !isset($b[$sort])) { - if (isset($a[$sort])) { - return -1; - } - if (isset($b[$sort])) { - return 1; - } - return 0; - } - switch ($sort) { - case 'filename': - $result = strcasecmp($a['filename'], $b['filename']); - if ($result) { - return $order === SORT_DESC ? -$result : $result; - } - break; - case 'permissions': - case 'mode': - $a[$sort]&= 07777; - $b[$sort]&= 07777; - default: - if ($a[$sort] === $b[$sort]) { - break; - } - return $order === SORT_ASC ? $a[$sort] - $b[$sort] : $b[$sort] - $a[$sort]; - } - } - } - - /** - * Defines how nlist() and rawlist() will be sorted - if at all. - * - * If sorting is enabled directories and files will be sorted independently with - * directories appearing before files in the resultant array that is returned. - * - * Any parameter returned by stat is a valid sort parameter for this function. - * Filename comparisons are case insensitive. - * - * Examples: - * - * $sftp->setListOrder('filename', SORT_ASC); - * $sftp->setListOrder('size', SORT_DESC, 'filename', SORT_ASC); - * $sftp->setListOrder(true); - * Separates directories from files but doesn't do any sorting beyond that - * $sftp->setListOrder(); - * Don't do any sort of sorting - * - * @access public - */ - function setListOrder() - { - $this->sortOptions = array(); - $args = func_get_args(); - if (empty($args)) { - return; - } - $len = count($args) & 0x7FFFFFFE; - for ($i = 0; $i < $len; $i+=2) { - $this->sortOptions[$args[$i]] = $args[$i + 1]; - } - if (!count($this->sortOptions)) { - $this->sortOptions = array('bogus' => true); - } - } - - /** - * Returns the file size, in bytes, or false, on failure - * - * Files larger than 4GB will show up as being exactly 4GB. - * - * @param string $filename - * @return mixed - * @access public - */ - function size($filename) - { - if (!($this->bitmap & SSH2::MASK_LOGIN)) { - return false; - } - - $result = $this->stat($filename); - if ($result === false) { - return false; - } - return isset($result['size']) ? $result['size'] : -1; - } - - /** - * Save files / directories to cache - * - * @param string $path - * @param mixed $value - * @access private - */ - function _update_stat_cache($path, $value) - { - if ($this->use_stat_cache === false) { - return; - } - - // preg_replace('#^/|/(?=/)|/$#', '', $dir) == str_replace('//', '/', trim($path, '/')) - $dirs = explode('/', preg_replace('#^/|/(?=/)|/$#', '', $path)); - - $temp = &$this->stat_cache; - $max = count($dirs) - 1; - foreach ($dirs as $i => $dir) { - // if $temp is an object that means one of two things. - // 1. a file was deleted and changed to a directory behind phpseclib's back - // 2. it's a symlink. when lstat is done it's unclear what it's a symlink to - if (is_object($temp)) { - $temp = array(); - } - if (!isset($temp[$dir])) { - $temp[$dir] = array(); - } - if ($i === $max) { - if (is_object($temp[$dir])) { - if (!isset($value->stat) && isset($temp[$dir]->stat)) { - $value->stat = $temp[$dir]->stat; - } - if (!isset($value->lstat) && isset($temp[$dir]->lstat)) { - $value->lstat = $temp[$dir]->lstat; - } - } - $temp[$dir] = $value; - break; - } - $temp = &$temp[$dir]; - } - } - - /** - * Remove files / directories from cache - * - * @param string $path - * @return bool - * @access private - */ - function _remove_from_stat_cache($path) - { - $dirs = explode('/', preg_replace('#^/|/(?=/)|/$#', '', $path)); - - $temp = &$this->stat_cache; - $max = count($dirs) - 1; - foreach ($dirs as $i => $dir) { - if ($i === $max) { - unset($temp[$dir]); - return true; - } - if (!isset($temp[$dir])) { - return false; - } - $temp = &$temp[$dir]; - } - } - - /** - * Checks cache for path - * - * Mainly used by file_exists - * - * @param string $dir - * @return mixed - * @access private - */ - function _query_stat_cache($path) - { - $dirs = explode('/', preg_replace('#^/|/(?=/)|/$#', '', $path)); - - $temp = &$this->stat_cache; - foreach ($dirs as $dir) { - if (!isset($temp[$dir])) { - return null; - } - $temp = &$temp[$dir]; - } - return $temp; - } - - /** - * Returns general information about a file. - * - * Returns an array on success and false otherwise. - * - * @param string $filename - * @return mixed - * @access public - */ - function stat($filename) - { - if (!($this->bitmap & SSH2::MASK_LOGIN)) { - return false; - } - - $filename = $this->_realpath($filename); - if ($filename === false) { - return false; - } - - if ($this->use_stat_cache) { - $result = $this->_query_stat_cache($filename); - if (is_array($result) && isset($result['.']) && isset($result['.']->stat)) { - return $result['.']->stat; - } - if (is_object($result) && isset($result->stat)) { - return $result->stat; - } - } - - $stat = $this->_stat($filename, NET_SFTP_STAT); - if ($stat === false) { - $this->_remove_from_stat_cache($filename); - return false; - } - if (isset($stat['type'])) { - if ($stat['type'] == NET_SFTP_TYPE_DIRECTORY) { - $filename.= '/.'; - } - $this->_update_stat_cache($filename, (object) array('stat' => $stat)); - return $stat; - } - - $pwd = $this->pwd; - $stat['type'] = $this->chdir($filename) ? - NET_SFTP_TYPE_DIRECTORY : - NET_SFTP_TYPE_REGULAR; - $this->pwd = $pwd; - - if ($stat['type'] == NET_SFTP_TYPE_DIRECTORY) { - $filename.= '/.'; - } - $this->_update_stat_cache($filename, (object) array('stat' => $stat)); - - return $stat; - } - - /** - * Returns general information about a file or symbolic link. - * - * Returns an array on success and false otherwise. - * - * @param string $filename - * @return mixed - * @access public - */ - function lstat($filename) - { - if (!($this->bitmap & SSH2::MASK_LOGIN)) { - return false; - } - - $filename = $this->_realpath($filename); - if ($filename === false) { - return false; - } - - if ($this->use_stat_cache) { - $result = $this->_query_stat_cache($filename); - if (is_array($result) && isset($result['.']) && isset($result['.']->lstat)) { - return $result['.']->lstat; - } - if (is_object($result) && isset($result->lstat)) { - return $result->lstat; - } - } - - $lstat = $this->_stat($filename, NET_SFTP_LSTAT); - if ($lstat === false) { - $this->_remove_from_stat_cache($filename); - return false; - } - if (isset($lstat['type'])) { - if ($lstat['type'] == NET_SFTP_TYPE_DIRECTORY) { - $filename.= '/.'; - } - $this->_update_stat_cache($filename, (object) array('lstat' => $lstat)); - return $lstat; - } - - $stat = $this->_stat($filename, NET_SFTP_STAT); - - if ($lstat != $stat) { - $lstat = array_merge($lstat, array('type' => NET_SFTP_TYPE_SYMLINK)); - $this->_update_stat_cache($filename, (object) array('lstat' => $lstat)); - return $stat; - } - - $pwd = $this->pwd; - $lstat['type'] = $this->chdir($filename) ? - NET_SFTP_TYPE_DIRECTORY : - NET_SFTP_TYPE_REGULAR; - $this->pwd = $pwd; - - if ($lstat['type'] == NET_SFTP_TYPE_DIRECTORY) { - $filename.= '/.'; - } - $this->_update_stat_cache($filename, (object) array('lstat' => $lstat)); - - return $lstat; - } - - /** - * Returns general information about a file or symbolic link - * - * Determines information without calling \phpseclib\Net\SFTP::_realpath(). - * The second parameter can be either NET_SFTP_STAT or NET_SFTP_LSTAT. - * - * @param string $filename - * @param int $type - * @return mixed - * @access private - */ - function _stat($filename, $type) - { - // SFTPv4+ adds an additional 32-bit integer field - flags - to the following: - $packet = pack('Na*', strlen($filename), $filename); - if (!$this->_send_sftp_packet($type, $packet)) { - return false; - } - - $response = $this->_get_sftp_packet(); - switch ($this->packet_type) { - case NET_SFTP_ATTRS: - return $this->_parseAttributes($response); - case NET_SFTP_STATUS: - $this->_logError($response); - return false; - } - - user_error('Expected SSH_FXP_ATTRS or SSH_FXP_STATUS'); - return false; - } - - /** - * Truncates a file to a given length - * - * @param string $filename - * @param int $new_size - * @return bool - * @access public - */ - function truncate($filename, $new_size) - { - $attr = pack('N3', NET_SFTP_ATTR_SIZE, $new_size / 4294967296, $new_size); // 4294967296 == 0x100000000 == 1<<32 - - return $this->_setstat($filename, $attr, false); - } - - /** - * Sets access and modification time of file. - * - * If the file does not exist, it will be created. - * - * @param string $filename - * @param int $time - * @param int $atime - * @return bool - * @access public - */ - function touch($filename, $time = null, $atime = null) - { - if (!($this->bitmap & SSH2::MASK_LOGIN)) { - return false; - } - - $filename = $this->_realpath($filename); - if ($filename === false) { - return false; - } - - if (!isset($time)) { - $time = time(); - } - if (!isset($atime)) { - $atime = $time; - } - - $flags = NET_SFTP_OPEN_WRITE | NET_SFTP_OPEN_CREATE | NET_SFTP_OPEN_EXCL; - $attr = pack('N3', NET_SFTP_ATTR_ACCESSTIME, $time, $atime); - $packet = pack('Na*Na*', strlen($filename), $filename, $flags, $attr); - if (!$this->_send_sftp_packet(NET_SFTP_OPEN, $packet)) { - return false; - } - - $response = $this->_get_sftp_packet(); - switch ($this->packet_type) { - case NET_SFTP_HANDLE: - return $this->_close_handle(substr($response, 4)); - case NET_SFTP_STATUS: - $this->_logError($response); - break; - default: - user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS'); - return false; - } - - return $this->_setstat($filename, $attr, false); - } - - /** - * Changes file or directory owner - * - * Returns true on success or false on error. - * - * @param string $filename - * @param int $uid - * @param bool $recursive - * @return bool - * @access public - */ - function chown($filename, $uid, $recursive = false) - { - // quoting from <http://www.kernel.org/doc/man-pages/online/pages/man2/chown.2.html>, - // "if the owner or group is specified as -1, then that ID is not changed" - $attr = pack('N3', NET_SFTP_ATTR_UIDGID, $uid, -1); - - return $this->_setstat($filename, $attr, $recursive); - } - - /** - * Changes file or directory group - * - * Returns true on success or false on error. - * - * @param string $filename - * @param int $gid - * @param bool $recursive - * @return bool - * @access public - */ - function chgrp($filename, $gid, $recursive = false) - { - $attr = pack('N3', NET_SFTP_ATTR_UIDGID, -1, $gid); - - return $this->_setstat($filename, $attr, $recursive); - } - - /** - * Set permissions on a file. - * - * Returns the new file permissions on success or false on error. - * If $recursive is true than this just returns true or false. - * - * @param int $mode - * @param string $filename - * @param bool $recursive - * @return mixed - * @access public - */ - function chmod($mode, $filename, $recursive = false) - { - if (is_string($mode) && is_int($filename)) { - $temp = $mode; - $mode = $filename; - $filename = $temp; - } - - $attr = pack('N2', NET_SFTP_ATTR_PERMISSIONS, $mode & 07777); - if (!$this->_setstat($filename, $attr, $recursive)) { - return false; - } - if ($recursive) { - return true; - } - - $filename = $this->_realPath($filename); - // rather than return what the permissions *should* be, we'll return what they actually are. this will also - // tell us if the file actually exists. - // incidentally, SFTPv4+ adds an additional 32-bit integer field - flags - to the following: - $packet = pack('Na*', strlen($filename), $filename); - if (!$this->_send_sftp_packet(NET_SFTP_STAT, $packet)) { - return false; - } - - $response = $this->_get_sftp_packet(); - switch ($this->packet_type) { - case NET_SFTP_ATTRS: - $attrs = $this->_parseAttributes($response); - return $attrs['permissions']; - case NET_SFTP_STATUS: - $this->_logError($response); - return false; - } - - user_error('Expected SSH_FXP_ATTRS or SSH_FXP_STATUS'); - return false; - } - - /** - * Sets information about a file - * - * @param string $filename - * @param string $attr - * @param bool $recursive - * @return bool - * @access private - */ - function _setstat($filename, $attr, $recursive) - { - if (!($this->bitmap & SSH2::MASK_LOGIN)) { - return false; - } - - $filename = $this->_realpath($filename); - if ($filename === false) { - return false; - } - - $this->_remove_from_stat_cache($filename); - - if ($recursive) { - $i = 0; - $result = $this->_setstat_recursive($filename, $attr, $i); - $this->_read_put_responses($i); - return $result; - } - - // SFTPv4+ has an additional byte field - type - that would need to be sent, as well. setting it to - // SSH_FILEXFER_TYPE_UNKNOWN might work. if not, we'd have to do an SSH_FXP_STAT before doing an SSH_FXP_SETSTAT. - if (!$this->_send_sftp_packet(NET_SFTP_SETSTAT, pack('Na*a*', strlen($filename), $filename, $attr))) { - return false; - } - - /* - "Because some systems must use separate system calls to set various attributes, it is possible that a failure - response will be returned, but yet some of the attributes may be have been successfully modified. If possible, - servers SHOULD avoid this situation; however, clients MUST be aware that this is possible." - - -- http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.6 - */ - $response = $this->_get_sftp_packet(); - if ($this->packet_type != NET_SFTP_STATUS) { - user_error('Expected SSH_FXP_STATUS'); - return false; - } - - extract(unpack('Nstatus', $this->_string_shift($response, 4))); - if ($status != NET_SFTP_STATUS_OK) { - $this->_logError($response, $status); - return false; - } - - return true; - } - - /** - * Recursively sets information on directories on the SFTP server - * - * Minimizes directory lookups and SSH_FXP_STATUS requests for speed. - * - * @param string $path - * @param string $attr - * @param int $i - * @return bool - * @access private - */ - function _setstat_recursive($path, $attr, &$i) - { - if (!$this->_read_put_responses($i)) { - return false; - } - $i = 0; - $entries = $this->_list($path, true); - - if ($entries === false) { - return $this->_setstat($path, $attr, false); - } - - // normally $entries would have at least . and .. but it might not if the directories - // permissions didn't allow reading - if (empty($entries)) { - return false; - } - - unset($entries['.'], $entries['..']); - foreach ($entries as $filename => $props) { - if (!isset($props['type'])) { - return false; - } - - $temp = $path . '/' . $filename; - if ($props['type'] == NET_SFTP_TYPE_DIRECTORY) { - if (!$this->_setstat_recursive($temp, $attr, $i)) { - return false; - } - } else { - if (!$this->_send_sftp_packet(NET_SFTP_SETSTAT, pack('Na*a*', strlen($temp), $temp, $attr))) { - return false; - } - - $i++; - - if ($i >= NET_SFTP_QUEUE_SIZE) { - if (!$this->_read_put_responses($i)) { - return false; - } - $i = 0; - } - } - } - - if (!$this->_send_sftp_packet(NET_SFTP_SETSTAT, pack('Na*a*', strlen($path), $path, $attr))) { - return false; - } - - $i++; - - if ($i >= NET_SFTP_QUEUE_SIZE) { - if (!$this->_read_put_responses($i)) { - return false; - } - $i = 0; - } - - return true; - } - - /** - * Return the target of a symbolic link - * - * @param string $link - * @return mixed - * @access public - */ - function readlink($link) - { - if (!($this->bitmap & SSH2::MASK_LOGIN)) { - return false; - } - - $link = $this->_realpath($link); - - if (!$this->_send_sftp_packet(NET_SFTP_READLINK, pack('Na*', strlen($link), $link))) { - return false; - } - - $response = $this->_get_sftp_packet(); - switch ($this->packet_type) { - case NET_SFTP_NAME: - break; - case NET_SFTP_STATUS: - $this->_logError($response); - return false; - default: - user_error('Expected SSH_FXP_NAME or SSH_FXP_STATUS'); - return false; - } - - extract(unpack('Ncount', $this->_string_shift($response, 4))); - // the file isn't a symlink - if (!$count) { - return false; - } - - extract(unpack('Nlength', $this->_string_shift($response, 4))); - return $this->_string_shift($response, $length); - } - - /** - * Create a symlink - * - * symlink() creates a symbolic link to the existing target with the specified name link. - * - * @param string $target - * @param string $link - * @return bool - * @access public - */ - function symlink($target, $link) - { - if (!($this->bitmap & SSH2::MASK_LOGIN)) { - return false; - } - - $target = $this->_realpath($target); - $link = $this->_realpath($link); - - $packet = pack('Na*Na*', strlen($target), $target, strlen($link), $link); - if (!$this->_send_sftp_packet(NET_SFTP_SYMLINK, $packet)) { - return false; - } - - $response = $this->_get_sftp_packet(); - if ($this->packet_type != NET_SFTP_STATUS) { - user_error('Expected SSH_FXP_STATUS'); - return false; - } - - extract(unpack('Nstatus', $this->_string_shift($response, 4))); - if ($status != NET_SFTP_STATUS_OK) { - $this->_logError($response, $status); - return false; - } - - return true; - } - - /** - * Creates a directory. - * - * @param string $dir - * @return bool - * @access public - */ - function mkdir($dir, $mode = -1, $recursive = false) - { - if (!($this->bitmap & SSH2::MASK_LOGIN)) { - return false; - } - - $dir = $this->_realpath($dir); - // by not providing any permissions, hopefully the server will use the logged in users umask - their - // default permissions. - $attr = $mode == -1 ? "\0\0\0\0" : pack('N2', NET_SFTP_ATTR_PERMISSIONS, $mode & 07777); - - if ($recursive) { - $dirs = explode('/', preg_replace('#/(?=/)|/$#', '', $dir)); - if (empty($dirs[0])) { - array_shift($dirs); - $dirs[0] = '/' . $dirs[0]; - } - for ($i = 0; $i < count($dirs); $i++) { - $temp = array_slice($dirs, 0, $i + 1); - $temp = implode('/', $temp); - $result = $this->_mkdir_helper($temp, $attr); - } - return $result; - } - - return $this->_mkdir_helper($dir, $attr); - } - - /** - * Helper function for directory creation - * - * @param string $dir - * @return bool - * @access private - */ - function _mkdir_helper($dir, $attr) - { - if (!$this->_send_sftp_packet(NET_SFTP_MKDIR, pack('Na*a*', strlen($dir), $dir, $attr))) { - return false; - } - - $response = $this->_get_sftp_packet(); - if ($this->packet_type != NET_SFTP_STATUS) { - user_error('Expected SSH_FXP_STATUS'); - return false; - } - - extract(unpack('Nstatus', $this->_string_shift($response, 4))); - if ($status != NET_SFTP_STATUS_OK) { - $this->_logError($response, $status); - return false; - } - - return true; - } - - /** - * Removes a directory. - * - * @param string $dir - * @return bool - * @access public - */ - function rmdir($dir) - { - if (!($this->bitmap & SSH2::MASK_LOGIN)) { - return false; - } - - $dir = $this->_realpath($dir); - if ($dir === false) { - return false; - } - - if (!$this->_send_sftp_packet(NET_SFTP_RMDIR, pack('Na*', strlen($dir), $dir))) { - return false; - } - - $response = $this->_get_sftp_packet(); - if ($this->packet_type != NET_SFTP_STATUS) { - user_error('Expected SSH_FXP_STATUS'); - return false; - } - - extract(unpack('Nstatus', $this->_string_shift($response, 4))); - if ($status != NET_SFTP_STATUS_OK) { - // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED? - $this->_logError($response, $status); - return false; - } - - $this->_remove_from_stat_cache($dir); - // the following will do a soft delete, which would be useful if you deleted a file - // and then tried to do a stat on the deleted file. the above, in contrast, does - // a hard delete - //$this->_update_stat_cache($dir, false); - - return true; - } - - /** - * Uploads a file to the SFTP server. - * - * By default, \phpseclib\Net\SFTP::put() does not read from the local filesystem. $data is dumped directly into $remote_file. - * So, for example, if you set $data to 'filename.ext' and then do \phpseclib\Net\SFTP::get(), you will get a file, twelve bytes - * long, containing 'filename.ext' as its contents. - * - * Setting $mode to self::SOURCE_LOCAL_FILE will change the above behavior. With self::SOURCE_LOCAL_FILE, $remote_file will - * contain as many bytes as filename.ext does on your local filesystem. If your filename.ext is 1MB then that is how - * large $remote_file will be, as well. - * - * Setting $mode to self::SOURCE_CALLBACK will use $data as callback function, which gets only one parameter -- number of bytes to return, and returns a string if there is some data or null if there is no more data - * - * If $data is a resource then it'll be used as a resource instead. - * - * Currently, only binary mode is supported. As such, if the line endings need to be adjusted, you will need to take - * care of that, yourself. - * - * $mode can take an additional two parameters - self::RESUME and self::RESUME_START. These are bitwise AND'd with - * $mode. So if you want to resume upload of a 300mb file on the local file system you'd set $mode to the following: - * - * self::SOURCE_LOCAL_FILE | self::RESUME - * - * If you wanted to simply append the full contents of a local file to the full contents of a remote file you'd replace - * self::RESUME with self::RESUME_START. - * - * If $mode & (self::RESUME | self::RESUME_START) then self::RESUME_START will be assumed. - * - * $start and $local_start give you more fine grained control over this process and take precident over self::RESUME - * when they're non-negative. ie. $start could let you write at the end of a file (like self::RESUME) or in the middle - * of one. $local_start could let you start your reading from the end of a file (like self::RESUME_START) or in the - * middle of one. - * - * Setting $local_start to > 0 or $mode | self::RESUME_START doesn't do anything unless $mode | self::SOURCE_LOCAL_FILE. - * - * @param string $remote_file - * @param string|resource $data - * @param int $mode - * @param int $start - * @param int $local_start - * @param callable|null $progressCallback - * @return bool - * @access public - * @internal ASCII mode for SFTPv4/5/6 can be supported by adding a new function - \phpseclib\Net\SFTP::setMode(). - */ - function put($remote_file, $data, $mode = self::SOURCE_STRING, $start = -1, $local_start = -1, $progressCallback = null) - { - if (!($this->bitmap & SSH2::MASK_LOGIN)) { - return false; - } - - $remote_file = $this->_realpath($remote_file); - if ($remote_file === false) { - return false; - } - - $this->_remove_from_stat_cache($remote_file); - - $flags = NET_SFTP_OPEN_WRITE | NET_SFTP_OPEN_CREATE; - // according to the SFTP specs, NET_SFTP_OPEN_APPEND should "force all writes to append data at the end of the file." - // in practice, it doesn't seem to do that. - //$flags|= ($mode & self::RESUME) ? NET_SFTP_OPEN_APPEND : NET_SFTP_OPEN_TRUNCATE; - - if ($start >= 0) { - $offset = $start; - } elseif ($mode & self::RESUME) { - // if NET_SFTP_OPEN_APPEND worked as it should _size() wouldn't need to be called - $size = $this->size($remote_file); - $offset = $size !== false ? $size : 0; - } else { - $offset = 0; - $flags|= NET_SFTP_OPEN_TRUNCATE; - } - - $packet = pack('Na*N2', strlen($remote_file), $remote_file, $flags, 0); - if (!$this->_send_sftp_packet(NET_SFTP_OPEN, $packet)) { - return false; - } - - $response = $this->_get_sftp_packet(); - switch ($this->packet_type) { - case NET_SFTP_HANDLE: - $handle = substr($response, 4); - break; - case NET_SFTP_STATUS: - $this->_logError($response); - return false; - default: - user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS'); - return false; - } - - // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.2.3 - $dataCallback = false; - switch (true) { - case $mode & self::SOURCE_CALLBACK: - if (!is_callable($data)) { - user_error("\$data should be is_callable() if you specify SOURCE_CALLBACK flag"); - } - $dataCallback = $data; - // do nothing - break; - case is_resource($data): - $mode = $mode & ~self::SOURCE_LOCAL_FILE; - $fp = $data; - break; - case $mode & self::SOURCE_LOCAL_FILE: - if (!is_file($data)) { - user_error("$data is not a valid file"); - return false; - } - $fp = @fopen($data, 'rb'); - if (!$fp) { - return false; - } - } - - if (isset($fp)) { - $stat = fstat($fp); - $size = $stat['size']; - - if ($local_start >= 0) { - fseek($fp, $local_start); - $size-= $local_start; - } - } elseif ($dataCallback) { - $size = 0; - } else { - $size = strlen($data); - } - - $sent = 0; - $size = $size < 0 ? ($size & 0x7FFFFFFF) + 0x80000000 : $size; - - $sftp_packet_size = 4096; // PuTTY uses 4096 - // make the SFTP packet be exactly 4096 bytes by including the bytes in the NET_SFTP_WRITE packets "header" - $sftp_packet_size-= strlen($handle) + 25; - $i = 0; - while ($dataCallback || $sent < $size) { - if ($dataCallback) { - $temp = call_user_func($dataCallback, $sftp_packet_size); - if (is_null($temp)) { - break; - } - } else { - $temp = isset($fp) ? fread($fp, $sftp_packet_size) : substr($data, $sent, $sftp_packet_size); - } - $subtemp = $offset + $sent; - $packet = pack('Na*N3a*', strlen($handle), $handle, $subtemp / 4294967296, $subtemp, strlen($temp), $temp); - if (!$this->_send_sftp_packet(NET_SFTP_WRITE, $packet)) { - if ($mode & self::SOURCE_LOCAL_FILE) { - fclose($fp); - } - return false; - } - $sent+= strlen($temp); - if (is_callable($progressCallback)) { - call_user_func($progressCallback, $sent); - } - - $i++; - - if ($i == NET_SFTP_QUEUE_SIZE) { - if (!$this->_read_put_responses($i)) { - $i = 0; - break; - } - $i = 0; - } - } - - if (!$this->_read_put_responses($i)) { - if ($mode & self::SOURCE_LOCAL_FILE) { - fclose($fp); - } - $this->_close_handle($handle); - return false; - } - - if ($mode & self::SOURCE_LOCAL_FILE) { - fclose($fp); - } - - return $this->_close_handle($handle); - } - - /** - * Reads multiple successive SSH_FXP_WRITE responses - * - * Sending an SSH_FXP_WRITE packet and immediately reading its response isn't as efficient as blindly sending out $i - * SSH_FXP_WRITEs, in succession, and then reading $i responses. - * - * @param int $i - * @return bool - * @access private - */ - function _read_put_responses($i) - { - while ($i--) { - $response = $this->_get_sftp_packet(); - if ($this->packet_type != NET_SFTP_STATUS) { - user_error('Expected SSH_FXP_STATUS'); - return false; - } - - extract(unpack('Nstatus', $this->_string_shift($response, 4))); - if ($status != NET_SFTP_STATUS_OK) { - $this->_logError($response, $status); - break; - } - } - - return $i < 0; - } - - /** - * Close handle - * - * @param string $handle - * @return bool - * @access private - */ - function _close_handle($handle) - { - if (!$this->_send_sftp_packet(NET_SFTP_CLOSE, pack('Na*', strlen($handle), $handle))) { - return false; - } - - // "The client MUST release all resources associated with the handle regardless of the status." - // -- http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.1.3 - $response = $this->_get_sftp_packet(); - if ($this->packet_type != NET_SFTP_STATUS) { - user_error('Expected SSH_FXP_STATUS'); - return false; - } - - extract(unpack('Nstatus', $this->_string_shift($response, 4))); - if ($status != NET_SFTP_STATUS_OK) { - $this->_logError($response, $status); - return false; - } - - return true; - } - - /** - * Downloads a file from the SFTP server. - * - * Returns a string containing the contents of $remote_file if $local_file is left undefined or a boolean false if - * the operation was unsuccessful. If $local_file is defined, returns true or false depending on the success of the - * operation. - * - * $offset and $length can be used to download files in chunks. - * - * @param string $remote_file - * @param string $local_file - * @param int $offset - * @param int $length - * @return mixed - * @access public - */ - function get($remote_file, $local_file = false, $offset = 0, $length = -1) - { - if (!($this->bitmap & SSH2::MASK_LOGIN)) { - return false; - } - - $remote_file = $this->_realpath($remote_file); - if ($remote_file === false) { - return false; - } - - $packet = pack('Na*N2', strlen($remote_file), $remote_file, NET_SFTP_OPEN_READ, 0); - if (!$this->_send_sftp_packet(NET_SFTP_OPEN, $packet)) { - return false; - } - - $response = $this->_get_sftp_packet(); - switch ($this->packet_type) { - case NET_SFTP_HANDLE: - $handle = substr($response, 4); - break; - case NET_SFTP_STATUS: // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED - $this->_logError($response); - return false; - default: - user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS'); - return false; - } - - if (is_resource($local_file)) { - $fp = $local_file; - $stat = fstat($fp); - $res_offset = $stat['size']; - } else { - $res_offset = 0; - if ($local_file !== false) { - $fp = fopen($local_file, 'wb'); - if (!$fp) { - return false; - } - } else { - $content = ''; - } - } - - $fclose_check = $local_file !== false && !is_resource($local_file); - - $start = $offset; - $size = $this->max_sftp_packet < $length || $length < 0 ? $this->max_sftp_packet : $length; - while (true) { - $packet = pack('Na*N3', strlen($handle), $handle, $offset / 4294967296, $offset, $size); - if (!$this->_send_sftp_packet(NET_SFTP_READ, $packet)) { - if ($fclose_check) { - fclose($fp); - } - return false; - } - - $response = $this->_get_sftp_packet(); - switch ($this->packet_type) { - case NET_SFTP_DATA: - $temp = substr($response, 4); - $offset+= strlen($temp); - if ($local_file === false) { - $content.= $temp; - } else { - fputs($fp, $temp); - } - break; - case NET_SFTP_STATUS: - // could, in theory, return false if !strlen($content) but we'll hold off for the time being - $this->_logError($response); - break 2; - default: - user_error('Expected SSH_FXP_DATA or SSH_FXP_STATUS'); - if ($fclose_check) { - fclose($fp); - } - return false; - } - - if ($length > 0 && $length <= $offset - $start) { - break; - } - } - - if ($length > 0 && $length <= $offset - $start) { - if ($local_file === false) { - $content = substr($content, 0, $length); - } else { - ftruncate($fp, $length + $res_offset); - } - } - - if ($fclose_check) { - fclose($fp); - } - - if (!$this->_close_handle($handle)) { - return false; - } - - // if $content isn't set that means a file was written to - return isset($content) ? $content : true; - } - - /** - * Deletes a file on the SFTP server. - * - * @param string $path - * @param bool $recursive - * @return bool - * @access public - */ - function delete($path, $recursive = true) - { - if (!($this->bitmap & SSH2::MASK_LOGIN)) { - return false; - } - - $path = $this->_realpath($path); - if ($path === false) { - return false; - } - - // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.3 - if (!$this->_send_sftp_packet(NET_SFTP_REMOVE, pack('Na*', strlen($path), $path))) { - return false; - } - - $response = $this->_get_sftp_packet(); - if ($this->packet_type != NET_SFTP_STATUS) { - user_error('Expected SSH_FXP_STATUS'); - return false; - } - - // if $status isn't SSH_FX_OK it's probably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED - extract(unpack('Nstatus', $this->_string_shift($response, 4))); - if ($status != NET_SFTP_STATUS_OK) { - $this->_logError($response, $status); - if (!$recursive) { - return false; - } - $i = 0; - $result = $this->_delete_recursive($path, $i); - $this->_read_put_responses($i); - return $result; - } - - $this->_remove_from_stat_cache($path); - - return true; - } - - /** - * Recursively deletes directories on the SFTP server - * - * Minimizes directory lookups and SSH_FXP_STATUS requests for speed. - * - * @param string $path - * @param int $i - * @return bool - * @access private - */ - function _delete_recursive($path, &$i) - { - if (!$this->_read_put_responses($i)) { - return false; - } - $i = 0; - $entries = $this->_list($path, true); - - // normally $entries would have at least . and .. but it might not if the directories - // permissions didn't allow reading - if (empty($entries)) { - return false; - } - - unset($entries['.'], $entries['..']); - foreach ($entries as $filename => $props) { - if (!isset($props['type'])) { - return false; - } - - $temp = $path . '/' . $filename; - if ($props['type'] == NET_SFTP_TYPE_DIRECTORY) { - if (!$this->_delete_recursive($temp, $i)) { - return false; - } - } else { - if (!$this->_send_sftp_packet(NET_SFTP_REMOVE, pack('Na*', strlen($temp), $temp))) { - return false; - } - $this->_remove_from_stat_cache($temp); - - $i++; - - if ($i >= NET_SFTP_QUEUE_SIZE) { - if (!$this->_read_put_responses($i)) { - return false; - } - $i = 0; - } - } - } - - if (!$this->_send_sftp_packet(NET_SFTP_RMDIR, pack('Na*', strlen($path), $path))) { - return false; - } - $this->_remove_from_stat_cache($path); - - $i++; - - if ($i >= NET_SFTP_QUEUE_SIZE) { - if (!$this->_read_put_responses($i)) { - return false; - } - $i = 0; - } - - return true; - } - - /** - * Checks whether a file or directory exists - * - * @param string $path - * @return bool - * @access public - */ - function file_exists($path) - { - if ($this->use_stat_cache) { - $path = $this->_realpath($path); - - $result = $this->_query_stat_cache($path); - - if (isset($result)) { - // return true if $result is an array or if it's an stdClass object - return $result !== false; - } - } - - return $this->stat($path) !== false; - } - - /** - * Tells whether the filename is a directory - * - * @param string $path - * @return bool - * @access public - */ - function is_dir($path) - { - $result = $this->_get_stat_cache_prop($path, 'type'); - if ($result === false) { - return false; - } - return $result === NET_SFTP_TYPE_DIRECTORY; - } - - /** - * Tells whether the filename is a regular file - * - * @param string $path - * @return bool - * @access public - */ - function is_file($path) - { - $result = $this->_get_stat_cache_prop($path, 'type'); - if ($result === false) { - return false; - } - return $result === NET_SFTP_TYPE_REGULAR; - } - - /** - * Tells whether the filename is a symbolic link - * - * @param string $path - * @return bool - * @access public - */ - function is_link($path) - { - $result = $this->_get_lstat_cache_prop($path, 'type'); - if ($result === false) { - return false; - } - return $result === NET_SFTP_TYPE_SYMLINK; - } - - /** - * Gets last access time of file - * - * @param string $path - * @return mixed - * @access public - */ - function fileatime($path) - { - return $this->_get_stat_cache_prop($path, 'atime'); - } - - /** - * Gets file modification time - * - * @param string $path - * @return mixed - * @access public - */ - function filemtime($path) - { - return $this->_get_stat_cache_prop($path, 'mtime'); - } - - /** - * Gets file permissions - * - * @param string $path - * @return mixed - * @access public - */ - function fileperms($path) - { - return $this->_get_stat_cache_prop($path, 'permissions'); - } - - /** - * Gets file owner - * - * @param string $path - * @return mixed - * @access public - */ - function fileowner($path) - { - return $this->_get_stat_cache_prop($path, 'uid'); - } - - /** - * Gets file group - * - * @param string $path - * @return mixed - * @access public - */ - function filegroup($path) - { - return $this->_get_stat_cache_prop($path, 'gid'); - } - - /** - * Gets file size - * - * @param string $path - * @return mixed - * @access public - */ - function filesize($path) - { - return $this->_get_stat_cache_prop($path, 'size'); - } - - /** - * Gets file type - * - * @param string $path - * @return mixed - * @access public - */ - function filetype($path) - { - $type = $this->_get_stat_cache_prop($path, 'type'); - if ($type === false) { - return false; - } - - switch ($type) { - case NET_SFTP_TYPE_BLOCK_DEVICE: - return 'block'; - case NET_SFTP_TYPE_CHAR_DEVICE: - return 'char'; - case NET_SFTP_TYPE_DIRECTORY: - return 'dir'; - case NET_SFTP_TYPE_FIFO: - return 'fifo'; - case NET_SFTP_TYPE_REGULAR: - return 'file'; - case NET_SFTP_TYPE_SYMLINK: - return 'link'; - default: - return false; - } - } - - /** - * Return a stat properity - * - * Uses cache if appropriate. - * - * @param string $path - * @param string $prop - * @return mixed - * @access private - */ - function _get_stat_cache_prop($path, $prop) - { - return $this->_get_xstat_cache_prop($path, $prop, 'stat'); - } - - /** - * Return an lstat properity - * - * Uses cache if appropriate. - * - * @param string $path - * @param string $prop - * @return mixed - * @access private - */ - function _get_lstat_cache_prop($path, $prop) - { - return $this->_get_xstat_cache_prop($path, $prop, 'lstat'); - } - - /** - * Return a stat or lstat properity - * - * Uses cache if appropriate. - * - * @param string $path - * @param string $prop - * @return mixed - * @access private - */ - function _get_xstat_cache_prop($path, $prop, $type) - { - if ($this->use_stat_cache) { - $path = $this->_realpath($path); - - $result = $this->_query_stat_cache($path); - - if (is_object($result) && isset($result->$type)) { - return $result->{$type}[$prop]; - } - } - - $result = $this->$type($path); - - if ($result === false || !isset($result[$prop])) { - return false; - } - - return $result[$prop]; - } - - /** - * Renames a file or a directory on the SFTP server - * - * @param string $oldname - * @param string $newname - * @return bool - * @access public - */ - function rename($oldname, $newname) - { - if (!($this->bitmap & SSH2::MASK_LOGIN)) { - return false; - } - - $oldname = $this->_realpath($oldname); - $newname = $this->_realpath($newname); - if ($oldname === false || $newname === false) { - return false; - } - - // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.3 - $packet = pack('Na*Na*', strlen($oldname), $oldname, strlen($newname), $newname); - if (!$this->_send_sftp_packet(NET_SFTP_RENAME, $packet)) { - return false; - } - - $response = $this->_get_sftp_packet(); - if ($this->packet_type != NET_SFTP_STATUS) { - user_error('Expected SSH_FXP_STATUS'); - return false; - } - - // if $status isn't SSH_FX_OK it's probably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED - extract(unpack('Nstatus', $this->_string_shift($response, 4))); - if ($status != NET_SFTP_STATUS_OK) { - $this->_logError($response, $status); - return false; - } - - // don't move the stat cache entry over since this operation could very well change the - // atime and mtime attributes - //$this->_update_stat_cache($newname, $this->_query_stat_cache($oldname)); - $this->_remove_from_stat_cache($oldname); - $this->_remove_from_stat_cache($newname); - - return true; - } - - /** - * Parse Attributes - * - * See '7. File Attributes' of draft-ietf-secsh-filexfer-13 for more info. - * - * @param string $response - * @return array - * @access private - */ - function _parseAttributes(&$response) - { - $attr = array(); - extract(unpack('Nflags', $this->_string_shift($response, 4))); - // SFTPv4+ have a type field (a byte) that follows the above flag field - foreach ($this->attributes as $key => $value) { - switch ($flags & $key) { - case NET_SFTP_ATTR_SIZE: // 0x00000001 - // The size attribute is defined as an unsigned 64-bit integer. - // The following will use floats on 32-bit platforms, if necessary. - // As can be seen in the BigInteger class, floats are generally - // IEEE 754 binary64 "double precision" on such platforms and - // as such can represent integers of at least 2^50 without loss - // of precision. Interpreted in filesize, 2^50 bytes = 1024 TiB. - $attr['size'] = hexdec(bin2hex($this->_string_shift($response, 8))); - break; - case NET_SFTP_ATTR_UIDGID: // 0x00000002 (SFTPv3 only) - $attr+= unpack('Nuid/Ngid', $this->_string_shift($response, 8)); - break; - case NET_SFTP_ATTR_PERMISSIONS: // 0x00000004 - $attr+= unpack('Npermissions', $this->_string_shift($response, 4)); - // mode == permissions; permissions was the original array key and is retained for bc purposes. - // mode was added because that's the more industry standard terminology - $attr+= array('mode' => $attr['permissions']); - $fileType = $this->_parseMode($attr['permissions']); - if ($fileType !== false) { - $attr+= array('type' => $fileType); - } - break; - case NET_SFTP_ATTR_ACCESSTIME: // 0x00000008 - $attr+= unpack('Natime/Nmtime', $this->_string_shift($response, 8)); - break; - case NET_SFTP_ATTR_EXTENDED: // 0x80000000 - extract(unpack('Ncount', $this->_string_shift($response, 4))); - for ($i = 0; $i < $count; $i++) { - extract(unpack('Nlength', $this->_string_shift($response, 4))); - $key = $this->_string_shift($response, $length); - extract(unpack('Nlength', $this->_string_shift($response, 4))); - $attr[$key] = $this->_string_shift($response, $length); - } - } - } - return $attr; - } - - /** - * Attempt to identify the file type - * - * Quoting the SFTP RFC, "Implementations MUST NOT send bits that are not defined" but they seem to anyway - * - * @param int $mode - * @return int - * @access private - */ - function _parseMode($mode) - { - // values come from http://lxr.free-electrons.com/source/include/uapi/linux/stat.h#L12 - // see, also, http://linux.die.net/man/2/stat - switch ($mode & 0170000) {// ie. 1111 0000 0000 0000 - case 0000000: // no file type specified - figure out the file type using alternative means - return false; - case 0040000: - return NET_SFTP_TYPE_DIRECTORY; - case 0100000: - return NET_SFTP_TYPE_REGULAR; - case 0120000: - return NET_SFTP_TYPE_SYMLINK; - // new types introduced in SFTPv5+ - // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-05#section-5.2 - case 0010000: // named pipe (fifo) - return NET_SFTP_TYPE_FIFO; - case 0020000: // character special - return NET_SFTP_TYPE_CHAR_DEVICE; - case 0060000: // block special - return NET_SFTP_TYPE_BLOCK_DEVICE; - case 0140000: // socket - return NET_SFTP_TYPE_SOCKET; - case 0160000: // whiteout - // "SPECIAL should be used for files that are of - // a known type which cannot be expressed in the protocol" - return NET_SFTP_TYPE_SPECIAL; - default: - return NET_SFTP_TYPE_UNKNOWN; - } - } - - /** - * Parse Longname - * - * SFTPv3 doesn't provide any easy way of identifying a file type. You could try to open - * a file as a directory and see if an error is returned or you could try to parse the - * SFTPv3-specific longname field of the SSH_FXP_NAME packet. That's what this function does. - * The result is returned using the - * {@link http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-5.2 SFTPv4 type constants}. - * - * If the longname is in an unrecognized format bool(false) is returned. - * - * @param string $longname - * @return mixed - * @access private - */ - function _parseLongname($longname) - { - // http://en.wikipedia.org/wiki/Unix_file_types - // http://en.wikipedia.org/wiki/Filesystem_permissions#Notation_of_traditional_Unix_permissions - if (preg_match('#^[^/]([r-][w-][xstST-]){3}#', $longname)) { - switch ($longname[0]) { - case '-': - return NET_SFTP_TYPE_REGULAR; - case 'd': - return NET_SFTP_TYPE_DIRECTORY; - case 'l': - return NET_SFTP_TYPE_SYMLINK; - default: - return NET_SFTP_TYPE_SPECIAL; - } - } - - return false; - } - - /** - * Sends SFTP Packets - * - * See '6. General Packet Format' of draft-ietf-secsh-filexfer-13 for more info. - * - * @param int $type - * @param string $data - * @see self::_get_sftp_packet() - * @see self::_send_channel_packet() - * @return bool - * @access private - */ - function _send_sftp_packet($type, $data) - { - $packet = $this->request_id !== false ? - pack('NCNa*', strlen($data) + 5, $type, $this->request_id, $data) : - pack('NCa*', strlen($data) + 1, $type, $data); - - $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 - $result = $this->_send_channel_packet(self::CHANNEL, $packet); - $stop = strtok(microtime(), ' ') + strtok(''); - - if (defined('NET_SFTP_LOGGING')) { - $packet_type = '-> ' . $this->packet_types[$type] . - ' (' . round($stop - $start, 4) . 's)'; - if (NET_SFTP_LOGGING == NET_SFTP_LOG_REALTIME) { - echo "<pre>\r\n" . $this->_format_log(array($data), array($packet_type)) . "\r\n</pre>\r\n"; - flush(); - ob_flush(); - } else { - $this->packet_type_log[] = $packet_type; - if (NET_SFTP_LOGGING == NET_SFTP_LOG_COMPLEX) { - $this->packet_log[] = $data; - } - } - } - - return $result; - } - - /** - * Receives SFTP Packets - * - * See '6. General Packet Format' of draft-ietf-secsh-filexfer-13 for more info. - * - * Incidentally, the number of SSH_MSG_CHANNEL_DATA messages has no bearing on the number of SFTP packets present. - * There can be one SSH_MSG_CHANNEL_DATA messages containing two SFTP packets or there can be two SSH_MSG_CHANNEL_DATA - * messages containing one SFTP packet. - * - * @see self::_send_sftp_packet() - * @return string - * @access private - */ - function _get_sftp_packet() - { - $this->curTimeout = false; - - $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 - - // SFTP packet length - while (strlen($this->packet_buffer) < 4) { - $temp = $this->_get_channel_packet(self::CHANNEL); - if (is_bool($temp)) { - $this->packet_type = false; - $this->packet_buffer = ''; - return false; - } - $this->packet_buffer.= $temp; - } - extract(unpack('Nlength', $this->_string_shift($this->packet_buffer, 4))); - $tempLength = $length; - $tempLength-= strlen($this->packet_buffer); - - // SFTP packet type and data payload - while ($tempLength > 0) { - $temp = $this->_get_channel_packet(self::CHANNEL); - if (is_bool($temp)) { - $this->packet_type = false; - $this->packet_buffer = ''; - return false; - } - $this->packet_buffer.= $temp; - $tempLength-= strlen($temp); - } - - $stop = strtok(microtime(), ' ') + strtok(''); - - $this->packet_type = ord($this->_string_shift($this->packet_buffer)); - - if ($this->request_id !== false) { - $this->_string_shift($this->packet_buffer, 4); // remove the request id - $length-= 5; // account for the request id and the packet type - } else { - $length-= 1; // account for the packet type - } - - $packet = $this->_string_shift($this->packet_buffer, $length); - - if (defined('NET_SFTP_LOGGING')) { - $packet_type = '<- ' . $this->packet_types[$this->packet_type] . - ' (' . round($stop - $start, 4) . 's)'; - if (NET_SFTP_LOGGING == NET_SFTP_LOG_REALTIME) { - echo "<pre>\r\n" . $this->_format_log(array($packet), array($packet_type)) . "\r\n</pre>\r\n"; - flush(); - ob_flush(); - } else { - $this->packet_type_log[] = $packet_type; - if (NET_SFTP_LOGGING == NET_SFTP_LOG_COMPLEX) { - $this->packet_log[] = $packet; - } - } - } - - return $packet; - } - - /** - * Returns a log of the packets that have been sent and received. - * - * Returns a string if NET_SFTP_LOGGING == NET_SFTP_LOG_COMPLEX, an array if NET_SFTP_LOGGING == NET_SFTP_LOG_SIMPLE and false if !defined('NET_SFTP_LOGGING') - * - * @access public - * @return string or Array - */ - function getSFTPLog() - { - if (!defined('NET_SFTP_LOGGING')) { - return false; - } - - switch (NET_SFTP_LOGGING) { - case NET_SFTP_LOG_COMPLEX: - return $this->_format_log($this->packet_log, $this->packet_type_log); - break; - //case NET_SFTP_LOG_SIMPLE: - default: - return $this->packet_type_log; - } - } - - /** - * Returns all errors - * - * @return string - * @access public - */ - function getSFTPErrors() - { - return $this->sftp_errors; - } - - /** - * Returns the last error - * - * @return string - * @access public - */ - function getLastSFTPError() - { - return count($this->sftp_errors) ? $this->sftp_errors[count($this->sftp_errors) - 1] : ''; - } - - /** - * Get supported SFTP versions - * - * @return array - * @access public - */ - function getSupportedVersions() - { - $temp = array('version' => $this->version); - if (isset($this->extensions['versions'])) { - $temp['extensions'] = $this->extensions['versions']; - } - return $temp; - } - - /** - * Disconnect - * - * @param int $reason - * @return bool - * @access private - */ - function _disconnect($reason) - { - $this->pwd = false; - parent::_disconnect($reason); - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP/Stream.php b/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP/Stream.php deleted file mode 100755 index 08d726ca84266f91bd939bbbb917d69710421c2a..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP/Stream.php +++ /dev/null @@ -1,795 +0,0 @@ -<?php - -/** - * SFTP Stream Wrapper - * - * Creates an sftp:// protocol handler that can be used with, for example, fopen(), dir(), etc. - * - * PHP version 5 - * - * @category Net - * @package SFTP - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2013 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Net\SFTP; - -use phpseclib\Crypt\RSA; -use phpseclib\Net\SFTP; - -/** - * SFTP Stream Wrapper - * - * @package SFTP - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class Stream -{ - /** - * SFTP instances - * - * Rather than re-create the connection we re-use instances if possible - * - * @var array - */ - static $instances; - - /** - * SFTP instance - * - * @var object - * @access private - */ - var $sftp; - - /** - * Path - * - * @var string - * @access private - */ - var $path; - - /** - * Mode - * - * @var string - * @access private - */ - var $mode; - - /** - * Position - * - * @var int - * @access private - */ - var $pos; - - /** - * Size - * - * @var int - * @access private - */ - var $size; - - /** - * Directory entries - * - * @var array - * @access private - */ - var $entries; - - /** - * EOF flag - * - * @var bool - * @access private - */ - var $eof; - - /** - * Context resource - * - * Technically this needs to be publically accessible so PHP can set it directly - * - * @var resource - * @access public - */ - var $context; - - /** - * Notification callback function - * - * @var callable - * @access public - */ - var $notification; - - /** - * Registers this class as a URL wrapper. - * - * @param string $protocol The wrapper name to be registered. - * @return bool True on success, false otherwise. - * @access public - */ - static function register($protocol = 'sftp') - { - if (in_array($protocol, stream_get_wrappers(), true)) { - return false; - } - return stream_wrapper_register($protocol, get_called_class()); - } - - /** - * The Constructor - * - * @access public - */ - function __construct() - { - if (defined('NET_SFTP_STREAM_LOGGING')) { - echo "__construct()\r\n"; - } - } - - /** - * Path Parser - * - * Extract a path from a URI and actually connect to an SSH server if appropriate - * - * If "notification" is set as a context parameter the message code for successful login is - * NET_SSH2_MSG_USERAUTH_SUCCESS. For a failed login it's NET_SSH2_MSG_USERAUTH_FAILURE. - * - * @param string $path - * @return string - * @access private - */ - function _parse_path($path) - { - $orig = $path; - extract(parse_url($path) + array('port' => 22)); - if (isset($query)) { - $path.= '?' . $query; - } elseif (preg_match('/(\?|\?#)$/', $orig)) { - $path.= '?'; - } - if (isset($fragment)) { - $path.= '#' . $fragment; - } elseif ($orig[strlen($orig) - 1] == '#') { - $path.= '#'; - } - - if (!isset($host)) { - return false; - } - - if (isset($this->context)) { - $context = stream_context_get_params($this->context); - if (isset($context['notification'])) { - $this->notification = $context['notification']; - } - } - - if ($host[0] == '$') { - $host = substr($host, 1); - global $$host; - if (($$host instanceof SFTP) === false) { - return false; - } - $this->sftp = $$host; - } else { - if (isset($this->context)) { - $context = stream_context_get_options($this->context); - } - if (isset($context[$scheme]['session'])) { - $sftp = $context[$scheme]['session']; - } - if (isset($context[$scheme]['sftp'])) { - $sftp = $context[$scheme]['sftp']; - } - if (isset($sftp) && $sftp instanceof SFTP) { - $this->sftp = $sftp; - return $path; - } - if (isset($context[$scheme]['username'])) { - $user = $context[$scheme]['username']; - } - if (isset($context[$scheme]['password'])) { - $pass = $context[$scheme]['password']; - } - if (isset($context[$scheme]['privkey']) && $context[$scheme]['privkey'] instanceof RSA) { - $pass = $context[$scheme]['privkey']; - } - - if (!isset($user) || !isset($pass)) { - return false; - } - - // casting $pass to a string is necessary in the event that it's a \phpseclib\Crypt\RSA object - if (isset(self::$instances[$host][$port][$user][(string) $pass])) { - $this->sftp = self::$instances[$host][$port][$user][(string) $pass]; - } else { - $this->sftp = new SFTP($host, $port); - $this->sftp->disableStatCache(); - if (isset($this->notification) && is_callable($this->notification)) { - /* if !is_callable($this->notification) we could do this: - - user_error('fopen(): failed to call user notifier', E_USER_WARNING); - - the ftp wrapper gives errors like that when the notifier isn't callable. - i've opted not to do that, however, since the ftp wrapper gives the line - on which the fopen occurred as the line number - not the line that the - user_error is on. - */ - call_user_func($this->notification, STREAM_NOTIFY_CONNECT, STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, 0); - call_user_func($this->notification, STREAM_NOTIFY_AUTH_REQUIRED, STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, 0); - if (!$this->sftp->login($user, $pass)) { - call_user_func($this->notification, STREAM_NOTIFY_AUTH_RESULT, STREAM_NOTIFY_SEVERITY_ERR, 'Login Failure', NET_SSH2_MSG_USERAUTH_FAILURE, 0, 0); - return false; - } - call_user_func($this->notification, STREAM_NOTIFY_AUTH_RESULT, STREAM_NOTIFY_SEVERITY_INFO, 'Login Success', NET_SSH2_MSG_USERAUTH_SUCCESS, 0, 0); - } else { - if (!$this->sftp->login($user, $pass)) { - return false; - } - } - self::$instances[$host][$port][$user][(string) $pass] = $this->sftp; - } - } - - return $path; - } - - /** - * Opens file or URL - * - * @param string $path - * @param string $mode - * @param int $options - * @param string $opened_path - * @return bool - * @access public - */ - function _stream_open($path, $mode, $options, &$opened_path) - { - $path = $this->_parse_path($path); - - if ($path === false) { - return false; - } - $this->path = $path; - - $this->size = $this->sftp->size($path); - $this->mode = preg_replace('#[bt]$#', '', $mode); - $this->eof = false; - - if ($this->size === false) { - if ($this->mode[0] == 'r') { - return false; - } else { - $this->sftp->touch($path); - $this->size = 0; - } - } else { - switch ($this->mode[0]) { - case 'x': - return false; - case 'w': - $this->sftp->truncate($path, 0); - $this->size = 0; - } - } - - $this->pos = $this->mode[0] != 'a' ? 0 : $this->size; - - return true; - } - - /** - * Read from stream - * - * @param int $count - * @return mixed - * @access public - */ - function _stream_read($count) - { - switch ($this->mode) { - case 'w': - case 'a': - case 'x': - case 'c': - return false; - } - - // commented out because some files - eg. /dev/urandom - will say their size is 0 when in fact it's kinda infinite - //if ($this->pos >= $this->size) { - // $this->eof = true; - // return false; - //} - - $result = $this->sftp->get($this->path, false, $this->pos, $count); - if (isset($this->notification) && is_callable($this->notification)) { - if ($result === false) { - call_user_func($this->notification, STREAM_NOTIFY_FAILURE, STREAM_NOTIFY_SEVERITY_ERR, $this->sftp->getLastSFTPError(), NET_SFTP_OPEN, 0, 0); - return 0; - } - // seems that PHP calls stream_read in 8k chunks - call_user_func($this->notification, STREAM_NOTIFY_PROGRESS, STREAM_NOTIFY_SEVERITY_INFO, '', 0, strlen($result), $this->size); - } - - if (empty($result)) { // ie. false or empty string - $this->eof = true; - return false; - } - $this->pos+= strlen($result); - - return $result; - } - - /** - * Write to stream - * - * @param string $data - * @return mixed - * @access public - */ - function _stream_write($data) - { - switch ($this->mode) { - case 'r': - return false; - } - - $result = $this->sftp->put($this->path, $data, SFTP::SOURCE_STRING, $this->pos); - if (isset($this->notification) && is_callable($this->notification)) { - if (!$result) { - call_user_func($this->notification, STREAM_NOTIFY_FAILURE, STREAM_NOTIFY_SEVERITY_ERR, $this->sftp->getLastSFTPError(), NET_SFTP_OPEN, 0, 0); - return 0; - } - // seems that PHP splits up strings into 8k blocks before calling stream_write - call_user_func($this->notification, STREAM_NOTIFY_PROGRESS, STREAM_NOTIFY_SEVERITY_INFO, '', 0, strlen($data), strlen($data)); - } - - if ($result === false) { - return false; - } - $this->pos+= strlen($data); - if ($this->pos > $this->size) { - $this->size = $this->pos; - } - $this->eof = false; - return strlen($data); - } - - /** - * Retrieve the current position of a stream - * - * @return int - * @access public - */ - function _stream_tell() - { - return $this->pos; - } - - /** - * Tests for end-of-file on a file pointer - * - * In my testing there are four classes functions that normally effect the pointer: - * fseek, fputs / fwrite, fgets / fread and ftruncate. - * - * Only fgets / fread, however, results in feof() returning true. do fputs($fp, 'aaa') on a blank file and feof() - * will return false. do fread($fp, 1) and feof() will then return true. do fseek($fp, 10) on ablank file and feof() - * will return false. do fread($fp, 1) and feof() will then return true. - * - * @return bool - * @access public - */ - function _stream_eof() - { - return $this->eof; - } - - /** - * Seeks to specific location in a stream - * - * @param int $offset - * @param int $whence - * @return bool - * @access public - */ - function _stream_seek($offset, $whence) - { - switch ($whence) { - case SEEK_SET: - if ($offset >= $this->size || $offset < 0) { - return false; - } - break; - case SEEK_CUR: - $offset+= $this->pos; - break; - case SEEK_END: - $offset+= $this->size; - } - - $this->pos = $offset; - $this->eof = false; - return true; - } - - /** - * Change stream options - * - * @param string $path - * @param int $option - * @param mixed $var - * @return bool - * @access public - */ - function _stream_metadata($path, $option, $var) - { - $path = $this->_parse_path($path); - if ($path === false) { - return false; - } - - // stream_metadata was introduced in PHP 5.4.0 but as of 5.4.11 the constants haven't been defined - // see http://www.php.net/streamwrapper.stream-metadata and https://bugs.php.net/64246 - // and https://github.com/php/php-src/blob/master/main/php_streams.h#L592 - switch ($option) { - case 1: // PHP_STREAM_META_TOUCH - return $this->sftp->touch($path, $var[0], $var[1]); - case 2: // PHP_STREAM_OWNER_NAME - case 3: // PHP_STREAM_GROUP_NAME - return false; - case 4: // PHP_STREAM_META_OWNER - return $this->sftp->chown($path, $var); - case 5: // PHP_STREAM_META_GROUP - return $this->sftp->chgrp($path, $var); - case 6: // PHP_STREAM_META_ACCESS - return $this->sftp->chmod($path, $var) !== false; - } - } - - /** - * Retrieve the underlaying resource - * - * @param int $cast_as - * @return resource - * @access public - */ - function _stream_cast($cast_as) - { - return $this->sftp->fsock; - } - - /** - * Advisory file locking - * - * @param int $operation - * @return bool - * @access public - */ - function _stream_lock($operation) - { - return false; - } - - /** - * Renames a file or directory - * - * Attempts to rename oldname to newname, moving it between directories if necessary. - * If newname exists, it will be overwritten. This is a departure from what \phpseclib\Net\SFTP - * does. - * - * @param string $path_from - * @param string $path_to - * @return bool - * @access public - */ - function _rename($path_from, $path_to) - { - $path1 = parse_url($path_from); - $path2 = parse_url($path_to); - unset($path1['path'], $path2['path']); - if ($path1 != $path2) { - return false; - } - - $path_from = $this->_parse_path($path_from); - $path_to = parse_url($path_to); - if ($path_from === false) { - return false; - } - - $path_to = $path_to['path']; // the $component part of parse_url() was added in PHP 5.1.2 - // "It is an error if there already exists a file with the name specified by newpath." - // -- http://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-6.5 - if (!$this->sftp->rename($path_from, $path_to)) { - if ($this->sftp->stat($path_to)) { - return $this->sftp->delete($path_to, true) && $this->sftp->rename($path_from, $path_to); - } - return false; - } - - return true; - } - - /** - * Open directory handle - * - * The only $options is "whether or not to enforce safe_mode (0x04)". Since safe mode was deprecated in 5.3 and - * removed in 5.4 I'm just going to ignore it. - * - * Also, nlist() is the best that this function is realistically going to be able to do. When an SFTP client - * sends a SSH_FXP_READDIR packet you don't generally get info on just one file but on multiple files. Quoting - * the SFTP specs: - * - * The SSH_FXP_NAME response has the following format: - * - * uint32 id - * uint32 count - * repeats count times: - * string filename - * string longname - * ATTRS attrs - * - * @param string $path - * @param int $options - * @return bool - * @access public - */ - function _dir_opendir($path, $options) - { - $path = $this->_parse_path($path); - if ($path === false) { - return false; - } - $this->pos = 0; - $this->entries = $this->sftp->nlist($path); - return $this->entries !== false; - } - - /** - * Read entry from directory handle - * - * @return mixed - * @access public - */ - function _dir_readdir() - { - if (isset($this->entries[$this->pos])) { - return $this->entries[$this->pos++]; - } - return false; - } - - /** - * Rewind directory handle - * - * @return bool - * @access public - */ - function _dir_rewinddir() - { - $this->pos = 0; - return true; - } - - /** - * Close directory handle - * - * @return bool - * @access public - */ - function _dir_closedir() - { - return true; - } - - /** - * Create a directory - * - * Only valid $options is STREAM_MKDIR_RECURSIVE - * - * @param string $path - * @param int $mode - * @param int $options - * @return bool - * @access public - */ - function _mkdir($path, $mode, $options) - { - $path = $this->_parse_path($path); - if ($path === false) { - return false; - } - - return $this->sftp->mkdir($path, $mode, $options & STREAM_MKDIR_RECURSIVE); - } - - /** - * Removes a directory - * - * Only valid $options is STREAM_MKDIR_RECURSIVE per <http://php.net/streamwrapper.rmdir>, however, - * <http://php.net/rmdir> does not have a $recursive parameter as mkdir() does so I don't know how - * STREAM_MKDIR_RECURSIVE is supposed to be set. Also, when I try it out with rmdir() I get 8 as - * $options. What does 8 correspond to? - * - * @param string $path - * @param int $mode - * @param int $options - * @return bool - * @access public - */ - function _rmdir($path, $options) - { - $path = $this->_parse_path($path); - if ($path === false) { - return false; - } - - return $this->sftp->rmdir($path); - } - - /** - * Flushes the output - * - * See <http://php.net/fflush>. Always returns true because \phpseclib\Net\SFTP doesn't cache stuff before writing - * - * @return bool - * @access public - */ - function _stream_flush() - { - return true; - } - - /** - * Retrieve information about a file resource - * - * @return mixed - * @access public - */ - function _stream_stat() - { - $results = $this->sftp->stat($this->path); - if ($results === false) { - return false; - } - return $results; - } - - /** - * Delete a file - * - * @param string $path - * @return bool - * @access public - */ - function _unlink($path) - { - $path = $this->_parse_path($path); - if ($path === false) { - return false; - } - - return $this->sftp->delete($path, false); - } - - /** - * Retrieve information about a file - * - * Ignores the STREAM_URL_STAT_QUIET flag because the entirety of \phpseclib\Net\SFTP\Stream is quiet by default - * might be worthwhile to reconstruct bits 12-16 (ie. the file type) if mode doesn't have them but we'll - * cross that bridge when and if it's reached - * - * @param string $path - * @param int $flags - * @return mixed - * @access public - */ - function _url_stat($path, $flags) - { - $path = $this->_parse_path($path); - if ($path === false) { - return false; - } - - $results = $flags & STREAM_URL_STAT_LINK ? $this->sftp->lstat($path) : $this->sftp->stat($path); - if ($results === false) { - return false; - } - - return $results; - } - - /** - * Truncate stream - * - * @param int $new_size - * @return bool - * @access public - */ - function _stream_truncate($new_size) - { - if (!$this->sftp->truncate($this->path, $new_size)) { - return false; - } - - $this->eof = false; - $this->size = $new_size; - - return true; - } - - /** - * Change stream options - * - * STREAM_OPTION_WRITE_BUFFER isn't supported for the same reason stream_flush isn't. - * The other two aren't supported because of limitations in \phpseclib\Net\SFTP. - * - * @param int $option - * @param int $arg1 - * @param int $arg2 - * @return bool - * @access public - */ - function _stream_set_option($option, $arg1, $arg2) - { - return false; - } - - /** - * Close an resource - * - * @access public - */ - function _stream_close() - { - } - - /** - * __call Magic Method - * - * When you're utilizing an SFTP stream you're not calling the methods in this class directly - PHP is calling them for you. - * Which kinda begs the question... what methods is PHP calling and what parameters is it passing to them? This function - * lets you figure that out. - * - * If NET_SFTP_STREAM_LOGGING is defined all calls will be output on the screen and then (regardless of whether or not - * NET_SFTP_STREAM_LOGGING is enabled) the parameters will be passed through to the appropriate method. - * - * @param string - * @param array - * @return mixed - * @access public - */ - function __call($name, $arguments) - { - if (defined('NET_SFTP_STREAM_LOGGING')) { - echo $name . '('; - $last = count($arguments) - 1; - foreach ($arguments as $i => $argument) { - var_export($argument); - if ($i != $last) { - echo ','; - } - } - echo ")\r\n"; - } - $name = '_' . $name; - if (!method_exists($this, $name)) { - return false; - } - return call_user_func_array(array($this, $name), $arguments); - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Net/SSH1.php b/vendor/phpseclib/phpseclib/phpseclib/Net/SSH1.php deleted file mode 100755 index cc108a94f9866f409402bd1f0ee1e13160bbcd5e..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Net/SSH1.php +++ /dev/null @@ -1,1614 +0,0 @@ -<?php - -/** - * Pure-PHP implementation of SSHv1. - * - * PHP version 5 - * - * Here's a short example of how to use this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $ssh = new \phpseclib\Net\SSH1('www.domain.tld'); - * if (!$ssh->login('username', 'password')) { - * exit('Login Failed'); - * } - * - * echo $ssh->exec('ls -la'); - * ?> - * </code> - * - * Here's another short example: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $ssh = new \phpseclib\Net\SSH1('www.domain.tld'); - * if (!$ssh->login('username', 'password')) { - * exit('Login Failed'); - * } - * - * echo $ssh->read('username@username:~$'); - * $ssh->write("ls -la\n"); - * echo $ssh->read('username@username:~$'); - * ?> - * </code> - * - * More information on the SSHv1 specification can be found by reading - * {@link http://www.snailbook.com/docs/protocol-1.5.txt protocol-1.5.txt}. - * - * @category Net - * @package SSH1 - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2007 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Net; - -use phpseclib\Crypt\DES; -use phpseclib\Crypt\Random; -use phpseclib\Crypt\TripleDES; -use phpseclib\Math\BigInteger; - -/** - * Pure-PHP implementation of SSHv1. - * - * @package SSH1 - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class SSH1 -{ - /**#@+ - * Encryption Methods - * - * @see \phpseclib\Net\SSH1::getSupportedCiphers() - * @access public - */ - /** - * No encryption - * - * Not supported. - */ - const CIPHER_NONE = 0; - /** - * IDEA in CFB mode - * - * Not supported. - */ - const CIPHER_IDEA = 1; - /** - * DES in CBC mode - */ - const CIPHER_DES = 2; - /** - * Triple-DES in CBC mode - * - * All implementations are required to support this - */ - const CIPHER_3DES = 3; - /** - * TRI's Simple Stream encryption CBC - * - * Not supported nor is it defined in the official SSH1 specs. OpenSSH, however, does define it (see cipher.h), - * although it doesn't use it (see cipher.c) - */ - const CIPHER_BROKEN_TSS = 4; - /** - * RC4 - * - * Not supported. - * - * @internal According to the SSH1 specs: - * - * "The first 16 bytes of the session key are used as the key for - * the server to client direction. The remaining 16 bytes are used - * as the key for the client to server direction. This gives - * independent 128-bit keys for each direction." - * - * This library currently only supports encryption when the same key is being used for both directions. This is - * because there's only one $crypto object. Two could be added ($encrypt and $decrypt, perhaps). - */ - const CIPHER_RC4 = 5; - /** - * Blowfish - * - * Not supported nor is it defined in the official SSH1 specs. OpenSSH, however, defines it (see cipher.h) and - * uses it (see cipher.c) - */ - const CIPHER_BLOWFISH = 6; - /**#@-*/ - - /**#@+ - * Authentication Methods - * - * @see \phpseclib\Net\SSH1::getSupportedAuthentications() - * @access public - */ - /** - * .rhosts or /etc/hosts.equiv - */ - const AUTH_RHOSTS = 1; - /** - * pure RSA authentication - */ - const AUTH_RSA = 2; - /** - * password authentication - * - * This is the only method that is supported by this library. - */ - const AUTH_PASSWORD = 3; - /** - * .rhosts with RSA host authentication - */ - const AUTH_RHOSTS_RSA = 4; - /**#@-*/ - - /**#@+ - * Terminal Modes - * - * @link http://3sp.com/content/developer/maverick-net/docs/Maverick.SSH.PseudoTerminalModesMembers.html - * @access private - */ - const TTY_OP_END = 0; - /**#@-*/ - - /** - * The Response Type - * - * @see \phpseclib\Net\SSH1::_get_binary_packet() - * @access private - */ - const RESPONSE_TYPE = 1; - - /** - * The Response Data - * - * @see \phpseclib\Net\SSH1::_get_binary_packet() - * @access private - */ - const RESPONSE_DATA = 2; - - /**#@+ - * Execution Bitmap Masks - * - * @see \phpseclib\Net\SSH1::bitmap - * @access private - */ - const MASK_CONSTRUCTOR = 0x00000001; - const MASK_CONNECTED = 0x00000002; - const MASK_LOGIN = 0x00000004; - const MASK_SHELL = 0x00000008; - /**#@-*/ - - /**#@+ - * @access public - * @see \phpseclib\Net\SSH1::getLog() - */ - /** - * Returns the message numbers - */ - const LOG_SIMPLE = 1; - /** - * Returns the message content - */ - const LOG_COMPLEX = 2; - /** - * Outputs the content real-time - */ - const LOG_REALTIME = 3; - /** - * Dumps the content real-time to a file - */ - const LOG_REALTIME_FILE = 4; - /**#@-*/ - - /**#@+ - * @access public - * @see \phpseclib\Net\SSH1::read() - */ - /** - * Returns when a string matching $expect exactly is found - */ - const READ_SIMPLE = 1; - /** - * Returns when a string matching the regular expression $expect is found - */ - const READ_REGEX = 2; - /**#@-*/ - - /** - * The SSH identifier - * - * @var string - * @access private - */ - var $identifier = 'SSH-1.5-phpseclib'; - - /** - * The Socket Object - * - * @var object - * @access private - */ - var $fsock; - - /** - * The cryptography object - * - * @var object - * @access private - */ - var $crypto = false; - - /** - * Execution Bitmap - * - * The bits that are set represent functions that have been called already. This is used to determine - * if a requisite function has been successfully executed. If not, an error should be thrown. - * - * @var int - * @access private - */ - var $bitmap = 0; - - /** - * The Server Key Public Exponent - * - * Logged for debug purposes - * - * @see self::getServerKeyPublicExponent() - * @var string - * @access private - */ - var $server_key_public_exponent; - - /** - * The Server Key Public Modulus - * - * Logged for debug purposes - * - * @see self::getServerKeyPublicModulus() - * @var string - * @access private - */ - var $server_key_public_modulus; - - /** - * The Host Key Public Exponent - * - * Logged for debug purposes - * - * @see self::getHostKeyPublicExponent() - * @var string - * @access private - */ - var $host_key_public_exponent; - - /** - * The Host Key Public Modulus - * - * Logged for debug purposes - * - * @see self::getHostKeyPublicModulus() - * @var string - * @access private - */ - var $host_key_public_modulus; - - /** - * Supported Ciphers - * - * Logged for debug purposes - * - * @see self::getSupportedCiphers() - * @var array - * @access private - */ - var $supported_ciphers = array( - self::CIPHER_NONE => 'No encryption', - self::CIPHER_IDEA => 'IDEA in CFB mode', - self::CIPHER_DES => 'DES in CBC mode', - self::CIPHER_3DES => 'Triple-DES in CBC mode', - self::CIPHER_BROKEN_TSS => 'TRI\'s Simple Stream encryption CBC', - self::CIPHER_RC4 => 'RC4', - self::CIPHER_BLOWFISH => 'Blowfish' - ); - - /** - * Supported Authentications - * - * Logged for debug purposes - * - * @see self::getSupportedAuthentications() - * @var array - * @access private - */ - var $supported_authentications = array( - self::AUTH_RHOSTS => '.rhosts or /etc/hosts.equiv', - self::AUTH_RSA => 'pure RSA authentication', - self::AUTH_PASSWORD => 'password authentication', - self::AUTH_RHOSTS_RSA => '.rhosts with RSA host authentication' - ); - - /** - * Server Identification - * - * @see self::getServerIdentification() - * @var string - * @access private - */ - var $server_identification = ''; - - /** - * Protocol Flags - * - * @see self::__construct() - * @var array - * @access private - */ - var $protocol_flags = array(); - - /** - * Protocol Flag Log - * - * @see self::getLog() - * @var array - * @access private - */ - var $protocol_flag_log = array(); - - /** - * Message Log - * - * @see self::getLog() - * @var array - * @access private - */ - var $message_log = array(); - - /** - * Real-time log file pointer - * - * @see self::_append_log() - * @var resource - * @access private - */ - var $realtime_log_file; - - /** - * Real-time log file size - * - * @see self::_append_log() - * @var int - * @access private - */ - var $realtime_log_size; - - /** - * Real-time log file wrap boolean - * - * @see self::_append_log() - * @var bool - * @access private - */ - var $realtime_log_wrap; - - /** - * Interactive Buffer - * - * @see self::read() - * @var array - * @access private - */ - var $interactiveBuffer = ''; - - /** - * Timeout - * - * @see self::setTimeout() - * @access private - */ - var $timeout; - - /** - * Current Timeout - * - * @see self::_get_channel_packet() - * @access private - */ - var $curTimeout; - - /** - * Log Boundary - * - * @see self::_format_log() - * @access private - */ - var $log_boundary = ':'; - - /** - * Log Long Width - * - * @see self::_format_log() - * @access private - */ - var $log_long_width = 65; - - /** - * Log Short Width - * - * @see self::_format_log() - * @access private - */ - var $log_short_width = 16; - - /** - * Hostname - * - * @see self::__construct() - * @see self::_connect() - * @var string - * @access private - */ - var $host; - - /** - * Port Number - * - * @see self::__construct() - * @see self::_connect() - * @var int - * @access private - */ - var $port; - - /** - * Timeout for initial connection - * - * Set by the constructor call. Calling setTimeout() is optional. If it's not called functions like - * exec() won't timeout unless some PHP setting forces it too. The timeout specified in the constructor, - * however, is non-optional. There will be a timeout, whether or not you set it. If you don't it'll be - * 10 seconds. It is used by fsockopen() in that function. - * - * @see self::__construct() - * @see self::_connect() - * @var int - * @access private - */ - var $connectionTimeout; - - /** - * Default cipher - * - * @see self::__construct() - * @see self::_connect() - * @var int - * @access private - */ - var $cipher; - - /** - * Default Constructor. - * - * Connects to an SSHv1 server - * - * @param string $host - * @param int $port - * @param int $timeout - * @param int $cipher - * @return \phpseclib\Net\SSH1 - * @access public - */ - function __construct($host, $port = 22, $timeout = 10, $cipher = self::CIPHER_3DES) - { - $this->protocol_flags = array( - 1 => 'NET_SSH1_MSG_DISCONNECT', - 2 => 'NET_SSH1_SMSG_PUBLIC_KEY', - 3 => 'NET_SSH1_CMSG_SESSION_KEY', - 4 => 'NET_SSH1_CMSG_USER', - 9 => 'NET_SSH1_CMSG_AUTH_PASSWORD', - 10 => 'NET_SSH1_CMSG_REQUEST_PTY', - 12 => 'NET_SSH1_CMSG_EXEC_SHELL', - 13 => 'NET_SSH1_CMSG_EXEC_CMD', - 14 => 'NET_SSH1_SMSG_SUCCESS', - 15 => 'NET_SSH1_SMSG_FAILURE', - 16 => 'NET_SSH1_CMSG_STDIN_DATA', - 17 => 'NET_SSH1_SMSG_STDOUT_DATA', - 18 => 'NET_SSH1_SMSG_STDERR_DATA', - 19 => 'NET_SSH1_CMSG_EOF', - 20 => 'NET_SSH1_SMSG_EXITSTATUS', - 33 => 'NET_SSH1_CMSG_EXIT_CONFIRMATION' - ); - - $this->_define_array($this->protocol_flags); - - $this->host = $host; - $this->port = $port; - $this->connectionTimeout = $timeout; - $this->cipher = $cipher; - } - - /** - * Connect to an SSHv1 server - * - * @return bool - * @access private - */ - function _connect() - { - $this->fsock = @fsockopen($this->host, $this->port, $errno, $errstr, $this->connectionTimeout); - if (!$this->fsock) { - user_error(rtrim("Cannot connect to {$this->host}:{$this->port}. Error $errno. $errstr")); - return false; - } - - $this->server_identification = $init_line = fgets($this->fsock, 255); - - if (defined('NET_SSH1_LOGGING')) { - $this->_append_log('<-', $this->server_identification); - $this->_append_log('->', $this->identifier . "\r\n"); - } - - if (!preg_match('#SSH-([0-9\.]+)-(.+)#', $init_line, $parts)) { - user_error('Can only connect to SSH servers'); - return false; - } - if ($parts[1][0] != 1) { - user_error("Cannot connect to SSH $parts[1] servers"); - return false; - } - - fputs($this->fsock, $this->identifier."\r\n"); - - $response = $this->_get_binary_packet(); - if ($response[self::RESPONSE_TYPE] != NET_SSH1_SMSG_PUBLIC_KEY) { - user_error('Expected SSH_SMSG_PUBLIC_KEY'); - return false; - } - - $anti_spoofing_cookie = $this->_string_shift($response[self::RESPONSE_DATA], 8); - - $this->_string_shift($response[self::RESPONSE_DATA], 4); - - $temp = unpack('nlen', $this->_string_shift($response[self::RESPONSE_DATA], 2)); - $server_key_public_exponent = new BigInteger($this->_string_shift($response[self::RESPONSE_DATA], ceil($temp['len'] / 8)), 256); - $this->server_key_public_exponent = $server_key_public_exponent; - - $temp = unpack('nlen', $this->_string_shift($response[self::RESPONSE_DATA], 2)); - $server_key_public_modulus = new BigInteger($this->_string_shift($response[self::RESPONSE_DATA], ceil($temp['len'] / 8)), 256); - $this->server_key_public_modulus = $server_key_public_modulus; - - $this->_string_shift($response[self::RESPONSE_DATA], 4); - - $temp = unpack('nlen', $this->_string_shift($response[self::RESPONSE_DATA], 2)); - $host_key_public_exponent = new BigInteger($this->_string_shift($response[self::RESPONSE_DATA], ceil($temp['len'] / 8)), 256); - $this->host_key_public_exponent = $host_key_public_exponent; - - $temp = unpack('nlen', $this->_string_shift($response[self::RESPONSE_DATA], 2)); - $host_key_public_modulus = new BigInteger($this->_string_shift($response[self::RESPONSE_DATA], ceil($temp['len'] / 8)), 256); - $this->host_key_public_modulus = $host_key_public_modulus; - - $this->_string_shift($response[self::RESPONSE_DATA], 4); - - // get a list of the supported ciphers - extract(unpack('Nsupported_ciphers_mask', $this->_string_shift($response[self::RESPONSE_DATA], 4))); - foreach ($this->supported_ciphers as $mask => $name) { - if (($supported_ciphers_mask & (1 << $mask)) == 0) { - unset($this->supported_ciphers[$mask]); - } - } - - // get a list of the supported authentications - extract(unpack('Nsupported_authentications_mask', $this->_string_shift($response[self::RESPONSE_DATA], 4))); - foreach ($this->supported_authentications as $mask => $name) { - if (($supported_authentications_mask & (1 << $mask)) == 0) { - unset($this->supported_authentications[$mask]); - } - } - - $session_id = pack('H*', md5($host_key_public_modulus->toBytes() . $server_key_public_modulus->toBytes() . $anti_spoofing_cookie)); - - $session_key = Random::string(32); - $double_encrypted_session_key = $session_key ^ str_pad($session_id, 32, chr(0)); - - if ($server_key_public_modulus->compare($host_key_public_modulus) < 0) { - $double_encrypted_session_key = $this->_rsa_crypt( - $double_encrypted_session_key, - array( - $server_key_public_exponent, - $server_key_public_modulus - ) - ); - $double_encrypted_session_key = $this->_rsa_crypt( - $double_encrypted_session_key, - array( - $host_key_public_exponent, - $host_key_public_modulus - ) - ); - } else { - $double_encrypted_session_key = $this->_rsa_crypt( - $double_encrypted_session_key, - array( - $host_key_public_exponent, - $host_key_public_modulus - ) - ); - $double_encrypted_session_key = $this->_rsa_crypt( - $double_encrypted_session_key, - array( - $server_key_public_exponent, - $server_key_public_modulus - ) - ); - } - - $cipher = isset($this->supported_ciphers[$this->cipher]) ? $this->cipher : self::CIPHER_3DES; - $data = pack('C2a*na*N', NET_SSH1_CMSG_SESSION_KEY, $cipher, $anti_spoofing_cookie, 8 * strlen($double_encrypted_session_key), $double_encrypted_session_key, 0); - - if (!$this->_send_binary_packet($data)) { - user_error('Error sending SSH_CMSG_SESSION_KEY'); - return false; - } - - switch ($cipher) { - //case self::CIPHER_NONE: - // $this->crypto = new \phpseclib\Crypt\Null(); - // break; - case self::CIPHER_DES: - $this->crypto = new DES(); - $this->crypto->disablePadding(); - $this->crypto->enableContinuousBuffer(); - $this->crypto->setKey(substr($session_key, 0, 8)); - break; - case self::CIPHER_3DES: - $this->crypto = new TripleDES(TripleDES::MODE_3CBC); - $this->crypto->disablePadding(); - $this->crypto->enableContinuousBuffer(); - $this->crypto->setKey(substr($session_key, 0, 24)); - break; - //case self::CIPHER_RC4: - // $this->crypto = new RC4(); - // $this->crypto->enableContinuousBuffer(); - // $this->crypto->setKey(substr($session_key, 0, 16)); - // break; - } - - $response = $this->_get_binary_packet(); - - if ($response[self::RESPONSE_TYPE] != NET_SSH1_SMSG_SUCCESS) { - user_error('Expected SSH_SMSG_SUCCESS'); - return false; - } - - $this->bitmap = self::MASK_CONNECTED; - - return true; - } - - /** - * Login - * - * @param string $username - * @param string $password - * @return bool - * @access public - */ - function login($username, $password = '') - { - if (!($this->bitmap & self::MASK_CONSTRUCTOR)) { - $this->bitmap |= self::MASK_CONSTRUCTOR; - if (!$this->_connect()) { - return false; - } - } - - if (!($this->bitmap & self::MASK_CONNECTED)) { - return false; - } - - $data = pack('CNa*', NET_SSH1_CMSG_USER, strlen($username), $username); - - if (!$this->_send_binary_packet($data)) { - user_error('Error sending SSH_CMSG_USER'); - return false; - } - - $response = $this->_get_binary_packet(); - - if ($response === true) { - return false; - } - if ($response[self::RESPONSE_TYPE] == NET_SSH1_SMSG_SUCCESS) { - $this->bitmap |= self::MASK_LOGIN; - return true; - } elseif ($response[self::RESPONSE_TYPE] != NET_SSH1_SMSG_FAILURE) { - user_error('Expected SSH_SMSG_SUCCESS or SSH_SMSG_FAILURE'); - return false; - } - - $data = pack('CNa*', NET_SSH1_CMSG_AUTH_PASSWORD, strlen($password), $password); - - if (!$this->_send_binary_packet($data)) { - user_error('Error sending SSH_CMSG_AUTH_PASSWORD'); - return false; - } - - // remove the username and password from the last logged packet - if (defined('NET_SSH1_LOGGING') && NET_SSH1_LOGGING == self::LOG_COMPLEX) { - $data = pack('CNa*', NET_SSH1_CMSG_AUTH_PASSWORD, strlen('password'), 'password'); - $this->message_log[count($this->message_log) - 1] = $data; - } - - $response = $this->_get_binary_packet(); - - if ($response === true) { - return false; - } - if ($response[self::RESPONSE_TYPE] == NET_SSH1_SMSG_SUCCESS) { - $this->bitmap |= self::MASK_LOGIN; - return true; - } elseif ($response[self::RESPONSE_TYPE] == NET_SSH1_SMSG_FAILURE) { - return false; - } else { - user_error('Expected SSH_SMSG_SUCCESS or SSH_SMSG_FAILURE'); - return false; - } - } - - /** - * Set Timeout - * - * $ssh->exec('ping 127.0.0.1'); on a Linux host will never return and will run indefinitely. setTimeout() makes it so it'll timeout. - * Setting $timeout to false or 0 will mean there is no timeout. - * - * @param mixed $timeout - */ - function setTimeout($timeout) - { - $this->timeout = $this->curTimeout = $timeout; - } - - /** - * Executes a command on a non-interactive shell, returns the output, and quits. - * - * An SSH1 server will close the connection after a command has been executed on a non-interactive shell. SSH2 - * servers don't, however, this isn't an SSH2 client. The way this works, on the server, is by initiating a - * shell with the -s option, as discussed in the following links: - * - * {@link http://www.faqs.org/docs/bashman/bashref_65.html http://www.faqs.org/docs/bashman/bashref_65.html} - * {@link http://www.faqs.org/docs/bashman/bashref_62.html http://www.faqs.org/docs/bashman/bashref_62.html} - * - * To execute further commands, a new \phpseclib\Net\SSH1 object will need to be created. - * - * Returns false on failure and the output, otherwise. - * - * @see self::interactiveRead() - * @see self::interactiveWrite() - * @param string $cmd - * @return mixed - * @access public - */ - function exec($cmd, $block = true) - { - if (!($this->bitmap & self::MASK_LOGIN)) { - user_error('Operation disallowed prior to login()'); - return false; - } - - $data = pack('CNa*', NET_SSH1_CMSG_EXEC_CMD, strlen($cmd), $cmd); - - if (!$this->_send_binary_packet($data)) { - user_error('Error sending SSH_CMSG_EXEC_CMD'); - return false; - } - - if (!$block) { - return true; - } - - $output = ''; - $response = $this->_get_binary_packet(); - - if ($response !== false) { - do { - $output.= substr($response[self::RESPONSE_DATA], 4); - $response = $this->_get_binary_packet(); - } while (is_array($response) && $response[self::RESPONSE_TYPE] != NET_SSH1_SMSG_EXITSTATUS); - } - - $data = pack('C', NET_SSH1_CMSG_EXIT_CONFIRMATION); - - // i don't think it's really all that important if this packet gets sent or not. - $this->_send_binary_packet($data); - - fclose($this->fsock); - - // reset the execution bitmap - a new \phpseclib\Net\SSH1 object needs to be created. - $this->bitmap = 0; - - return $output; - } - - /** - * Creates an interactive shell - * - * @see self::interactiveRead() - * @see self::interactiveWrite() - * @return bool - * @access private - */ - function _initShell() - { - // connect using the sample parameters in protocol-1.5.txt. - // according to wikipedia.org's entry on text terminals, "the fundamental type of application running on a text - // terminal is a command line interpreter or shell". thus, opening a terminal session to run the shell. - $data = pack('CNa*N4C', NET_SSH1_CMSG_REQUEST_PTY, strlen('vt100'), 'vt100', 24, 80, 0, 0, self::TTY_OP_END); - - if (!$this->_send_binary_packet($data)) { - user_error('Error sending SSH_CMSG_REQUEST_PTY'); - return false; - } - - $response = $this->_get_binary_packet(); - - if ($response === true) { - return false; - } - if ($response[self::RESPONSE_TYPE] != NET_SSH1_SMSG_SUCCESS) { - user_error('Expected SSH_SMSG_SUCCESS'); - return false; - } - - $data = pack('C', NET_SSH1_CMSG_EXEC_SHELL); - - if (!$this->_send_binary_packet($data)) { - user_error('Error sending SSH_CMSG_EXEC_SHELL'); - return false; - } - - $this->bitmap |= self::MASK_SHELL; - - //stream_set_blocking($this->fsock, 0); - - return true; - } - - /** - * Inputs a command into an interactive shell. - * - * @see self::interactiveWrite() - * @param string $cmd - * @return bool - * @access public - */ - function write($cmd) - { - return $this->interactiveWrite($cmd); - } - - /** - * Returns the output of an interactive shell when there's a match for $expect - * - * $expect can take the form of a string literal or, if $mode == self::READ__REGEX, - * a regular expression. - * - * @see self::write() - * @param string $expect - * @param int $mode - * @return bool - * @access public - */ - function read($expect, $mode = self::READ__SIMPLE) - { - if (!($this->bitmap & self::MASK_LOGIN)) { - user_error('Operation disallowed prior to login()'); - return false; - } - - if (!($this->bitmap & self::MASK_SHELL) && !$this->_initShell()) { - user_error('Unable to initiate an interactive shell session'); - return false; - } - - $match = $expect; - while (true) { - if ($mode == self::READ__REGEX) { - preg_match($expect, $this->interactiveBuffer, $matches); - $match = isset($matches[0]) ? $matches[0] : ''; - } - $pos = strlen($match) ? strpos($this->interactiveBuffer, $match) : false; - if ($pos !== false) { - return $this->_string_shift($this->interactiveBuffer, $pos + strlen($match)); - } - $response = $this->_get_binary_packet(); - - if ($response === true) { - return $this->_string_shift($this->interactiveBuffer, strlen($this->interactiveBuffer)); - } - $this->interactiveBuffer.= substr($response[self::RESPONSE_DATA], 4); - } - } - - /** - * Inputs a command into an interactive shell. - * - * @see self::interactiveRead() - * @param string $cmd - * @return bool - * @access public - */ - function interactiveWrite($cmd) - { - if (!($this->bitmap & self::MASK_LOGIN)) { - user_error('Operation disallowed prior to login()'); - return false; - } - - if (!($this->bitmap & self::MASK_SHELL) && !$this->_initShell()) { - user_error('Unable to initiate an interactive shell session'); - return false; - } - - $data = pack('CNa*', NET_SSH1_CMSG_STDIN_DATA, strlen($cmd), $cmd); - - if (!$this->_send_binary_packet($data)) { - user_error('Error sending SSH_CMSG_STDIN'); - return false; - } - - return true; - } - - /** - * Returns the output of an interactive shell when no more output is available. - * - * Requires PHP 4.3.0 or later due to the use of the stream_select() function. If you see stuff like - * "^[[00m", you're seeing ANSI escape codes. According to - * {@link http://support.microsoft.com/kb/101875 How to Enable ANSI.SYS in a Command Window}, "Windows NT - * does not support ANSI escape sequences in Win32 Console applications", so if you're a Windows user, - * there's not going to be much recourse. - * - * @see self::interactiveRead() - * @return string - * @access public - */ - function interactiveRead() - { - if (!($this->bitmap & self::MASK_LOGIN)) { - user_error('Operation disallowed prior to login()'); - return false; - } - - if (!($this->bitmap & self::MASK_SHELL) && !$this->_initShell()) { - user_error('Unable to initiate an interactive shell session'); - return false; - } - - $read = array($this->fsock); - $write = $except = null; - if (stream_select($read, $write, $except, 0)) { - $response = $this->_get_binary_packet(); - return substr($response[self::RESPONSE_DATA], 4); - } else { - return ''; - } - } - - /** - * Disconnect - * - * @access public - */ - function disconnect() - { - $this->_disconnect(); - } - - /** - * Destructor. - * - * Will be called, automatically, if you're supporting just PHP5. If you're supporting PHP4, you'll need to call - * disconnect(). - * - * @access public - */ - function __destruct() - { - $this->_disconnect(); - } - - /** - * Disconnect - * - * @param string $msg - * @access private - */ - function _disconnect($msg = 'Client Quit') - { - if ($this->bitmap) { - $data = pack('C', NET_SSH1_CMSG_EOF); - $this->_send_binary_packet($data); - /* - $response = $this->_get_binary_packet(); - if ($response === true) { - $response = array(self::RESPONSE_TYPE => -1); - } - switch ($response[self::RESPONSE_TYPE]) { - case NET_SSH1_SMSG_EXITSTATUS: - $data = pack('C', NET_SSH1_CMSG_EXIT_CONFIRMATION); - break; - default: - $data = pack('CNa*', NET_SSH1_MSG_DISCONNECT, strlen($msg), $msg); - } - */ - $data = pack('CNa*', NET_SSH1_MSG_DISCONNECT, strlen($msg), $msg); - - $this->_send_binary_packet($data); - fclose($this->fsock); - $this->bitmap = 0; - } - } - - /** - * Gets Binary Packets - * - * See 'The Binary Packet Protocol' of protocol-1.5.txt for more info. - * - * Also, this function could be improved upon by adding detection for the following exploit: - * http://www.securiteam.com/securitynews/5LP042K3FY.html - * - * @see self::_send_binary_packet() - * @return array - * @access private - */ - function _get_binary_packet() - { - if (feof($this->fsock)) { - //user_error('connection closed prematurely'); - return false; - } - - if ($this->curTimeout) { - $read = array($this->fsock); - $write = $except = null; - - $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 - $sec = floor($this->curTimeout); - $usec = 1000000 * ($this->curTimeout - $sec); - // on windows this returns a "Warning: Invalid CRT parameters detected" error - if (!@stream_select($read, $write, $except, $sec, $usec) && !count($read)) { - //$this->_disconnect('Timeout'); - return true; - } - $elapsed = strtok(microtime(), ' ') + strtok('') - $start; - $this->curTimeout-= $elapsed; - } - - $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 - $temp = unpack('Nlength', fread($this->fsock, 4)); - - $padding_length = 8 - ($temp['length'] & 7); - $length = $temp['length'] + $padding_length; - $raw = ''; - - while ($length > 0) { - $temp = fread($this->fsock, $length); - $raw.= $temp; - $length-= strlen($temp); - } - $stop = strtok(microtime(), ' ') + strtok(''); - - if (strlen($raw) && $this->crypto !== false) { - $raw = $this->crypto->decrypt($raw); - } - - $padding = substr($raw, 0, $padding_length); - $type = $raw[$padding_length]; - $data = substr($raw, $padding_length + 1, -4); - - $temp = unpack('Ncrc', substr($raw, -4)); - - //if ( $temp['crc'] != $this->_crc($padding . $type . $data) ) { - // user_error('Bad CRC in packet from server'); - // return false; - //} - - $type = ord($type); - - if (defined('NET_SSH1_LOGGING')) { - $temp = isset($this->protocol_flags[$type]) ? $this->protocol_flags[$type] : 'UNKNOWN'; - $temp = '<- ' . $temp . - ' (' . round($stop - $start, 4) . 's)'; - $this->_append_log($temp, $data); - } - - return array( - self::RESPONSE_TYPE => $type, - self::RESPONSE_DATA => $data - ); - } - - /** - * Sends Binary Packets - * - * Returns true on success, false on failure. - * - * @see self::_get_binary_packet() - * @param string $data - * @return bool - * @access private - */ - function _send_binary_packet($data) - { - if (feof($this->fsock)) { - //user_error('connection closed prematurely'); - return false; - } - - $length = strlen($data) + 4; - - $padding = Random::string(8 - ($length & 7)); - - $orig = $data; - $data = $padding . $data; - $data.= pack('N', $this->_crc($data)); - - if ($this->crypto !== false) { - $data = $this->crypto->encrypt($data); - } - - $packet = pack('Na*', $length, $data); - - $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 - $result = strlen($packet) == fputs($this->fsock, $packet); - $stop = strtok(microtime(), ' ') + strtok(''); - - if (defined('NET_SSH1_LOGGING')) { - $temp = isset($this->protocol_flags[ord($orig[0])]) ? $this->protocol_flags[ord($orig[0])] : 'UNKNOWN'; - $temp = '-> ' . $temp . - ' (' . round($stop - $start, 4) . 's)'; - $this->_append_log($temp, $orig); - } - - return $result; - } - - /** - * Cyclic Redundancy Check (CRC) - * - * PHP's crc32 function is implemented slightly differently than the one that SSH v1 uses, so - * we've reimplemented it. A more detailed discussion of the differences can be found after - * $crc_lookup_table's initialization. - * - * @see self::_get_binary_packet() - * @see self::_send_binary_packet() - * @param string $data - * @return int - * @access private - */ - function _crc($data) - { - static $crc_lookup_table = array( - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, - 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, - 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, - 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, - 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, - 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, - 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, - 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, - 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, - 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, - 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, - 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, - 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, - 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, - 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, - 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, - 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, - 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, - 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, - 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, - 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, - 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, - 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, - 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, - 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, - 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, - 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, - 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, - 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, - 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, - 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, - 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, - 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, - 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, - 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, - 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, - 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, - 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, - 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, - 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, - 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, - 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, - 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, - 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, - 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, - 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, - 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D - ); - - // For this function to yield the same output as PHP's crc32 function, $crc would have to be - // set to 0xFFFFFFFF, initially - not 0x00000000 as it currently is. - $crc = 0x00000000; - $length = strlen($data); - - for ($i=0; $i<$length; $i++) { - // We AND $crc >> 8 with 0x00FFFFFF because we want the eight newly added bits to all - // be zero. PHP, unfortunately, doesn't always do this. 0x80000000 >> 8, as an example, - // yields 0xFF800000 - not 0x00800000. The following link elaborates: - // http://www.php.net/manual/en/language.operators.bitwise.php#57281 - $crc = (($crc >> 8) & 0x00FFFFFF) ^ $crc_lookup_table[($crc & 0xFF) ^ ord($data[$i])]; - } - - // In addition to having to set $crc to 0xFFFFFFFF, initially, the return value must be XOR'd with - // 0xFFFFFFFF for this function to return the same thing that PHP's crc32 function would. - return $crc; - } - - /** - * String Shift - * - * Inspired by array_shift - * - * @param string $string - * @param int $index - * @return string - * @access private - */ - function _string_shift(&$string, $index = 1) - { - $substr = substr($string, 0, $index); - $string = substr($string, $index); - return $substr; - } - - /** - * RSA Encrypt - * - * Returns mod(pow($m, $e), $n), where $n should be the product of two (large) primes $p and $q and where $e - * should be a number with the property that gcd($e, ($p - 1) * ($q - 1)) == 1. Could just make anything that - * calls this call modexp, instead, but I think this makes things clearer, maybe... - * - * @see self::__construct() - * @param BigInteger $m - * @param array $key - * @return BigInteger - * @access private - */ - function _rsa_crypt($m, $key) - { - /* - $rsa = new RSA(); - $rsa->loadKey($key, RSA::PUBLIC_FORMAT_RAW); - $rsa->setEncryptionMode(RSA::ENCRYPTION_PKCS1); - return $rsa->encrypt($m); - */ - - // To quote from protocol-1.5.txt: - // The most significant byte (which is only partial as the value must be - // less than the public modulus, which is never a power of two) is zero. - // - // The next byte contains the value 2 (which stands for public-key - // encrypted data in the PKCS standard [PKCS#1]). Then, there are non- - // zero random bytes to fill any unused space, a zero byte, and the data - // to be encrypted in the least significant bytes, the last byte of the - // data in the least significant byte. - - // Presumably the part of PKCS#1 they're refering to is "Section 7.2.1 Encryption Operation", - // under "7.2 RSAES-PKCS1-v1.5" and "7 Encryption schemes" of the following URL: - // ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1.pdf - $modulus = $key[1]->toBytes(); - $length = strlen($modulus) - strlen($m) - 3; - $random = ''; - while (strlen($random) != $length) { - $block = Random::string($length - strlen($random)); - $block = str_replace("\x00", '', $block); - $random.= $block; - } - $temp = chr(0) . chr(2) . $random . chr(0) . $m; - - $m = new BigInteger($temp, 256); - $m = $m->modPow($key[0], $key[1]); - - return $m->toBytes(); - } - - /** - * Define Array - * - * Takes any number of arrays whose indices are integers and whose values are strings and defines a bunch of - * named constants from it, using the value as the name of the constant and the index as the value of the constant. - * If any of the constants that would be defined already exists, none of the constants will be defined. - * - * @param array $array - * @access private - */ - function _define_array() - { - $args = func_get_args(); - foreach ($args as $arg) { - foreach ($arg as $key => $value) { - if (!defined($value)) { - define($value, $key); - } else { - break 2; - } - } - } - } - - /** - * Returns a log of the packets that have been sent and received. - * - * Returns a string if NET_SSH1_LOGGING == self::LOG_COMPLEX, an array if NET_SSH1_LOGGING == self::LOG_SIMPLE and false if !defined('NET_SSH1_LOGGING') - * - * @access public - * @return array|false|string - */ - function getLog() - { - if (!defined('NET_SSH1_LOGGING')) { - return false; - } - - switch (NET_SSH1_LOGGING) { - case self::LOG_SIMPLE: - return $this->message_number_log; - break; - case self::LOG_COMPLEX: - return $this->_format_log($this->message_log, $this->protocol_flags_log); - break; - default: - return false; - } - } - - /** - * Formats a log for printing - * - * @param array $message_log - * @param array $message_number_log - * @access private - * @return string - */ - function _format_log($message_log, $message_number_log) - { - $output = ''; - for ($i = 0; $i < count($message_log); $i++) { - $output.= $message_number_log[$i] . "\r\n"; - $current_log = $message_log[$i]; - $j = 0; - do { - if (strlen($current_log)) { - $output.= str_pad(dechex($j), 7, '0', STR_PAD_LEFT) . '0 '; - } - $fragment = $this->_string_shift($current_log, $this->log_short_width); - $hex = substr(preg_replace_callback('#.#s', array($this, '_format_log_helper'), $fragment), strlen($this->log_boundary)); - // replace non ASCII printable characters with dots - // http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters - // also replace < with a . since < messes up the output on web browsers - $raw = preg_replace('#[^\x20-\x7E]|<#', '.', $fragment); - $output.= str_pad($hex, $this->log_long_width - $this->log_short_width, ' ') . $raw . "\r\n"; - $j++; - } while (strlen($current_log)); - $output.= "\r\n"; - } - - return $output; - } - - /** - * Helper function for _format_log - * - * For use with preg_replace_callback() - * - * @param array $matches - * @access private - * @return string - */ - function _format_log_helper($matches) - { - return $this->log_boundary . str_pad(dechex(ord($matches[0])), 2, '0', STR_PAD_LEFT); - } - - /** - * Return the server key public exponent - * - * Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead, - * the raw bytes. This behavior is similar to PHP's md5() function. - * - * @param bool $raw_output - * @return string - * @access public - */ - function getServerKeyPublicExponent($raw_output = false) - { - return $raw_output ? $this->server_key_public_exponent->toBytes() : $this->server_key_public_exponent->toString(); - } - - /** - * Return the server key public modulus - * - * Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead, - * the raw bytes. This behavior is similar to PHP's md5() function. - * - * @param bool $raw_output - * @return string - * @access public - */ - function getServerKeyPublicModulus($raw_output = false) - { - return $raw_output ? $this->server_key_public_modulus->toBytes() : $this->server_key_public_modulus->toString(); - } - - /** - * Return the host key public exponent - * - * Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead, - * the raw bytes. This behavior is similar to PHP's md5() function. - * - * @param bool $raw_output - * @return string - * @access public - */ - function getHostKeyPublicExponent($raw_output = false) - { - return $raw_output ? $this->host_key_public_exponent->toBytes() : $this->host_key_public_exponent->toString(); - } - - /** - * Return the host key public modulus - * - * Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead, - * the raw bytes. This behavior is similar to PHP's md5() function. - * - * @param bool $raw_output - * @return string - * @access public - */ - function getHostKeyPublicModulus($raw_output = false) - { - return $raw_output ? $this->host_key_public_modulus->toBytes() : $this->host_key_public_modulus->toString(); - } - - /** - * Return a list of ciphers supported by SSH1 server. - * - * Just because a cipher is supported by an SSH1 server doesn't mean it's supported by this library. If $raw_output - * is set to true, returns, instead, an array of constants. ie. instead of array('Triple-DES in CBC mode'), you'll - * get array(self::CIPHER_3DES). - * - * @param bool $raw_output - * @return array - * @access public - */ - function getSupportedCiphers($raw_output = false) - { - return $raw_output ? array_keys($this->supported_ciphers) : array_values($this->supported_ciphers); - } - - /** - * Return a list of authentications supported by SSH1 server. - * - * Just because a cipher is supported by an SSH1 server doesn't mean it's supported by this library. If $raw_output - * is set to true, returns, instead, an array of constants. ie. instead of array('password authentication'), you'll - * get array(self::AUTH_PASSWORD). - * - * @param bool $raw_output - * @return array - * @access public - */ - function getSupportedAuthentications($raw_output = false) - { - return $raw_output ? array_keys($this->supported_authentications) : array_values($this->supported_authentications); - } - - /** - * Return the server identification. - * - * @return string - * @access public - */ - function getServerIdentification() - { - return rtrim($this->server_identification); - } - - /** - * Logs data packets - * - * Makes sure that only the last 1MB worth of packets will be logged - * - * @param string $data - * @access private - */ - function _append_log($protocol_flags, $message) - { - switch (NET_SSH1_LOGGING) { - // useful for benchmarks - case self::LOG_SIMPLE: - $this->protocol_flags_log[] = $protocol_flags; - break; - // the most useful log for SSH1 - case self::LOG_COMPLEX: - $this->protocol_flags_log[] = $protocol_flags; - $this->_string_shift($message); - $this->log_size+= strlen($message); - $this->message_log[] = $message; - while ($this->log_size > self::LOG_MAX_SIZE) { - $this->log_size-= strlen(array_shift($this->message_log)); - array_shift($this->protocol_flags_log); - } - break; - // dump the output out realtime; packets may be interspersed with non packets, - // passwords won't be filtered out and select other packets may not be correctly - // identified - case self::LOG_REALTIME: - echo "<pre>\r\n" . $this->_format_log(array($message), array($protocol_flags)) . "\r\n</pre>\r\n"; - @flush(); - @ob_flush(); - break; - // basically the same thing as self::LOG_REALTIME with the caveat that self::LOG_REALTIME_FILE - // needs to be defined and that the resultant log file will be capped out at self::LOG_MAX_SIZE. - // the earliest part of the log file is denoted by the first <<< START >>> and is not going to necessarily - // at the beginning of the file - case self::LOG_REALTIME_FILE: - if (!isset($this->realtime_log_file)) { - // PHP doesn't seem to like using constants in fopen() - $filename = self::LOG_REALTIME_FILE; - $fp = fopen($filename, 'w'); - $this->realtime_log_file = $fp; - } - if (!is_resource($this->realtime_log_file)) { - break; - } - $entry = $this->_format_log(array($message), array($protocol_flags)); - if ($this->realtime_log_wrap) { - $temp = "<<< START >>>\r\n"; - $entry.= $temp; - fseek($this->realtime_log_file, ftell($this->realtime_log_file) - strlen($temp)); - } - $this->realtime_log_size+= strlen($entry); - if ($this->realtime_log_size > self::LOG_MAX_SIZE) { - fseek($this->realtime_log_file, 0); - $this->realtime_log_size = strlen($entry); - $this->realtime_log_wrap = true; - } - fputs($this->realtime_log_file, $entry); - } - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php b/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php deleted file mode 100755 index 0f7c83188cb5ab8e27b6ae76bde57594007194d8..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php +++ /dev/null @@ -1,4168 +0,0 @@ -<?php - -/** - * Pure-PHP implementation of SSHv2. - * - * PHP version 5 - * - * Here are some examples of how to use this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $ssh = new \phpseclib\Net\SSH2('www.domain.tld'); - * if (!$ssh->login('username', 'password')) { - * exit('Login Failed'); - * } - * - * echo $ssh->exec('pwd'); - * echo $ssh->exec('ls -la'); - * ?> - * </code> - * - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $key = new \phpseclib\Crypt\RSA(); - * //$key->setPassword('whatever'); - * $key->loadKey(file_get_contents('privatekey')); - * - * $ssh = new \phpseclib\Net\SSH2('www.domain.tld'); - * if (!$ssh->login('username', $key)) { - * exit('Login Failed'); - * } - * - * echo $ssh->read('username@username:~$'); - * $ssh->write("ls -la\n"); - * echo $ssh->read('username@username:~$'); - * ?> - * </code> - * - * @category Net - * @package SSH2 - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2007 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - */ - -namespace phpseclib\Net; - -use phpseclib\Crypt\Base; -use phpseclib\Crypt\Blowfish; -use phpseclib\Crypt\Hash; -use phpseclib\Crypt\Random; -use phpseclib\Crypt\RC4; -use phpseclib\Crypt\Rijndael; -use phpseclib\Crypt\RSA; -use phpseclib\Crypt\TripleDES; -use phpseclib\Crypt\Twofish; -use phpseclib\Math\BigInteger; // Used to do Diffie-Hellman key exchange and DSA/RSA signature verification. -use phpseclib\System\SSH\Agent; - -/** - * Pure-PHP implementation of SSHv2. - * - * @package SSH2 - * @author Jim Wigginton <terrafrost@php.net> - * @access public - */ -class SSH2 -{ - /**#@+ - * Execution Bitmap Masks - * - * @see \phpseclib\Net\SSH2::bitmap - * @access private - */ - const MASK_CONSTRUCTOR = 0x00000001; - const MASK_CONNECTED = 0x00000002; - const MASK_LOGIN_REQ = 0x00000004; - const MASK_LOGIN = 0x00000008; - const MASK_SHELL = 0x00000010; - const MASK_WINDOW_ADJUST = 0x00000020; - /**#@-*/ - - /**#@+ - * Channel constants - * - * RFC4254 refers not to client and server channels but rather to sender and recipient channels. we don't refer - * to them in that way because RFC4254 toggles the meaning. the client sends a SSH_MSG_CHANNEL_OPEN message with - * a sender channel and the server sends a SSH_MSG_CHANNEL_OPEN_CONFIRMATION in response, with a sender and a - * recepient channel. at first glance, you might conclude that SSH_MSG_CHANNEL_OPEN_CONFIRMATION's sender channel - * would be the same thing as SSH_MSG_CHANNEL_OPEN's sender channel, but it's not, per this snipet: - * The 'recipient channel' is the channel number given in the original - * open request, and 'sender channel' is the channel number allocated by - * the other side. - * - * @see \phpseclib\Net\SSH2::_send_channel_packet() - * @see \phpseclib\Net\SSH2::_get_channel_packet() - * @access private - */ - const CHANNEL_EXEC = 0; // PuTTy uses 0x100 - const CHANNEL_SHELL = 1; - const CHANNEL_SUBSYSTEM = 2; - const CHANNEL_AGENT_FORWARD = 3; - /**#@-*/ - - /**#@+ - * @access public - * @see \phpseclib\Net\SSH2::getLog() - */ - /** - * Returns the message numbers - */ - const LOG_SIMPLE = 1; - /** - * Returns the message content - */ - const LOG_COMPLEX = 2; - /** - * Outputs the content real-time - */ - const LOG_REALTIME = 3; - /** - * Dumps the content real-time to a file - */ - const LOG_REALTIME_FILE = 4; - /**#@-*/ - - /**#@+ - * @access public - * @see \phpseclib\Net\SSH2::read() - */ - /** - * Returns when a string matching $expect exactly is found - */ - const READ_SIMPLE = 1; - /** - * Returns when a string matching the regular expression $expect is found - */ - const READ_REGEX = 2; - /** - * Make sure that the log never gets larger than this - */ - const LOG_MAX_SIZE = 1048576; // 1024 * 1024 - /**#@-*/ - - /** - * The SSH identifier - * - * @var string - * @access private - */ - var $identifier; - - /** - * The Socket Object - * - * @var object - * @access private - */ - var $fsock; - - /** - * Execution Bitmap - * - * The bits that are set represent functions that have been called already. This is used to determine - * if a requisite function has been successfully executed. If not, an error should be thrown. - * - * @var int - * @access private - */ - var $bitmap = 0; - - /** - * Error information - * - * @see self::getErrors() - * @see self::getLastError() - * @var string - * @access private - */ - var $errors = array(); - - /** - * Server Identifier - * - * @see self::getServerIdentification() - * @var array|false - * @access private - */ - var $server_identifier = false; - - /** - * Key Exchange Algorithms - * - * @see self::getKexAlgorithims() - * @var array|false - * @access private - */ - var $kex_algorithms = false; - - /** - * Minimum Diffie-Hellman Group Bit Size in RFC 4419 Key Exchange Methods - * - * @see self::_key_exchange() - * @var int - * @access private - */ - var $kex_dh_group_size_min = 1536; - - /** - * Preferred Diffie-Hellman Group Bit Size in RFC 4419 Key Exchange Methods - * - * @see self::_key_exchange() - * @var int - * @access private - */ - var $kex_dh_group_size_preferred = 2048; - - /** - * Maximum Diffie-Hellman Group Bit Size in RFC 4419 Key Exchange Methods - * - * @see self::_key_exchange() - * @var int - * @access private - */ - var $kex_dh_group_size_max = 4096; - - /** - * Server Host Key Algorithms - * - * @see self::getServerHostKeyAlgorithms() - * @var array|false - * @access private - */ - var $server_host_key_algorithms = false; - - /** - * Encryption Algorithms: Client to Server - * - * @see self::getEncryptionAlgorithmsClient2Server() - * @var array|false - * @access private - */ - var $encryption_algorithms_client_to_server = false; - - /** - * Encryption Algorithms: Server to Client - * - * @see self::getEncryptionAlgorithmsServer2Client() - * @var array|false - * @access private - */ - var $encryption_algorithms_server_to_client = false; - - /** - * MAC Algorithms: Client to Server - * - * @see self::getMACAlgorithmsClient2Server() - * @var array|false - * @access private - */ - var $mac_algorithms_client_to_server = false; - - /** - * MAC Algorithms: Server to Client - * - * @see self::getMACAlgorithmsServer2Client() - * @var array|false - * @access private - */ - var $mac_algorithms_server_to_client = false; - - /** - * Compression Algorithms: Client to Server - * - * @see self::getCompressionAlgorithmsClient2Server() - * @var array|false - * @access private - */ - var $compression_algorithms_client_to_server = false; - - /** - * Compression Algorithms: Server to Client - * - * @see self::getCompressionAlgorithmsServer2Client() - * @var array|false - * @access private - */ - var $compression_algorithms_server_to_client = false; - - /** - * Languages: Server to Client - * - * @see self::getLanguagesServer2Client() - * @var array|false - * @access private - */ - var $languages_server_to_client = false; - - /** - * Languages: Client to Server - * - * @see self::getLanguagesClient2Server() - * @var array|false - * @access private - */ - var $languages_client_to_server = false; - - /** - * Block Size for Server to Client Encryption - * - * "Note that the length of the concatenation of 'packet_length', - * 'padding_length', 'payload', and 'random padding' MUST be a multiple - * of the cipher block size or 8, whichever is larger. This constraint - * MUST be enforced, even when using stream ciphers." - * - * -- http://tools.ietf.org/html/rfc4253#section-6 - * - * @see self::__construct() - * @see self::_send_binary_packet() - * @var int - * @access private - */ - var $encrypt_block_size = 8; - - /** - * Block Size for Client to Server Encryption - * - * @see self::__construct() - * @see self::_get_binary_packet() - * @var int - * @access private - */ - var $decrypt_block_size = 8; - - /** - * Server to Client Encryption Object - * - * @see self::_get_binary_packet() - * @var object - * @access private - */ - var $decrypt = false; - - /** - * Client to Server Encryption Object - * - * @see self::_send_binary_packet() - * @var object - * @access private - */ - var $encrypt = false; - - /** - * Client to Server HMAC Object - * - * @see self::_send_binary_packet() - * @var object - * @access private - */ - var $hmac_create = false; - - /** - * Server to Client HMAC Object - * - * @see self::_get_binary_packet() - * @var object - * @access private - */ - var $hmac_check = false; - - /** - * Size of server to client HMAC - * - * We need to know how big the HMAC will be for the server to client direction so that we know how many bytes to read. - * For the client to server side, the HMAC object will make the HMAC as long as it needs to be. All we need to do is - * append it. - * - * @see self::_get_binary_packet() - * @var int - * @access private - */ - var $hmac_size = false; - - /** - * Server Public Host Key - * - * @see self::getServerPublicHostKey() - * @var string - * @access private - */ - var $server_public_host_key; - - /** - * Session identifer - * - * "The exchange hash H from the first key exchange is additionally - * used as the session identifier, which is a unique identifier for - * this connection." - * - * -- http://tools.ietf.org/html/rfc4253#section-7.2 - * - * @see self::_key_exchange() - * @var string - * @access private - */ - var $session_id = false; - - /** - * Exchange hash - * - * The current exchange hash - * - * @see self::_key_exchange() - * @var string - * @access private - */ - var $exchange_hash = false; - - /** - * Message Numbers - * - * @see self::__construct() - * @var array - * @access private - */ - var $message_numbers = array(); - - /** - * Disconnection Message 'reason codes' defined in RFC4253 - * - * @see self::__construct() - * @var array - * @access private - */ - var $disconnect_reasons = array(); - - /** - * SSH_MSG_CHANNEL_OPEN_FAILURE 'reason codes', defined in RFC4254 - * - * @see self::__construct() - * @var array - * @access private - */ - var $channel_open_failure_reasons = array(); - - /** - * Terminal Modes - * - * @link http://tools.ietf.org/html/rfc4254#section-8 - * @see self::__construct() - * @var array - * @access private - */ - var $terminal_modes = array(); - - /** - * SSH_MSG_CHANNEL_EXTENDED_DATA's data_type_codes - * - * @link http://tools.ietf.org/html/rfc4254#section-5.2 - * @see self::__construct() - * @var array - * @access private - */ - var $channel_extended_data_type_codes = array(); - - /** - * Send Sequence Number - * - * See 'Section 6.4. Data Integrity' of rfc4253 for more info. - * - * @see self::_send_binary_packet() - * @var int - * @access private - */ - var $send_seq_no = 0; - - /** - * Get Sequence Number - * - * See 'Section 6.4. Data Integrity' of rfc4253 for more info. - * - * @see self::_get_binary_packet() - * @var int - * @access private - */ - var $get_seq_no = 0; - - /** - * Server Channels - * - * Maps client channels to server channels - * - * @see self::_get_channel_packet() - * @see self::exec() - * @var array - * @access private - */ - var $server_channels = array(); - - /** - * Channel Buffers - * - * If a client requests a packet from one channel but receives two packets from another those packets should - * be placed in a buffer - * - * @see self::_get_channel_packet() - * @see self::exec() - * @var array - * @access private - */ - var $channel_buffers = array(); - - /** - * Channel Status - * - * Contains the type of the last sent message - * - * @see self::_get_channel_packet() - * @var array - * @access private - */ - var $channel_status = array(); - - /** - * Packet Size - * - * Maximum packet size indexed by channel - * - * @see self::_send_channel_packet() - * @var array - * @access private - */ - var $packet_size_client_to_server = array(); - - /** - * Message Number Log - * - * @see self::getLog() - * @var array - * @access private - */ - var $message_number_log = array(); - - /** - * Message Log - * - * @see self::getLog() - * @var array - * @access private - */ - var $message_log = array(); - - /** - * The Window Size - * - * Bytes the other party can send before it must wait for the window to be adjusted (0x7FFFFFFF = 2GB) - * - * @var int - * @see self::_send_channel_packet() - * @see self::exec() - * @access private - */ - var $window_size = 0x7FFFFFFF; - - /** - * Window size, server to client - * - * Window size indexed by channel - * - * @see self::_send_channel_packet() - * @var array - * @access private - */ - var $window_size_server_to_client = array(); - - /** - * Window size, client to server - * - * Window size indexed by channel - * - * @see self::_get_channel_packet() - * @var array - * @access private - */ - var $window_size_client_to_server = array(); - - /** - * Server signature - * - * Verified against $this->session_id - * - * @see self::getServerPublicHostKey() - * @var string - * @access private - */ - var $signature = ''; - - /** - * Server signature format - * - * ssh-rsa or ssh-dss. - * - * @see self::getServerPublicHostKey() - * @var string - * @access private - */ - var $signature_format = ''; - - /** - * Interactive Buffer - * - * @see self::read() - * @var array - * @access private - */ - var $interactiveBuffer = ''; - - /** - * Current log size - * - * Should never exceed self::LOG_MAX_SIZE - * - * @see self::_send_binary_packet() - * @see self::_get_binary_packet() - * @var int - * @access private - */ - var $log_size; - - /** - * Timeout - * - * @see self::setTimeout() - * @access private - */ - var $timeout; - - /** - * Current Timeout - * - * @see self::_get_channel_packet() - * @access private - */ - var $curTimeout; - - /** - * Real-time log file pointer - * - * @see self::_append_log() - * @var resource - * @access private - */ - var $realtime_log_file; - - /** - * Real-time log file size - * - * @see self::_append_log() - * @var int - * @access private - */ - var $realtime_log_size; - - /** - * Has the signature been validated? - * - * @see self::getServerPublicHostKey() - * @var bool - * @access private - */ - var $signature_validated = false; - - /** - * Real-time log file wrap boolean - * - * @see self::_append_log() - * @access private - */ - var $realtime_log_wrap; - - /** - * Flag to suppress stderr from output - * - * @see self::enableQuietMode() - * @access private - */ - var $quiet_mode = false; - - /** - * Time of first network activity - * - * @var int - * @access private - */ - var $last_packet; - - /** - * Exit status returned from ssh if any - * - * @var int - * @access private - */ - var $exit_status; - - /** - * Flag to request a PTY when using exec() - * - * @var bool - * @see self::enablePTY() - * @access private - */ - var $request_pty = false; - - /** - * Flag set while exec() is running when using enablePTY() - * - * @var bool - * @access private - */ - var $in_request_pty_exec = false; - - /** - * Flag set after startSubsystem() is called - * - * @var bool - * @access private - */ - var $in_subsystem; - - /** - * Contents of stdError - * - * @var string - * @access private - */ - var $stdErrorLog; - - /** - * The Last Interactive Response - * - * @see self::_keyboard_interactive_process() - * @var string - * @access private - */ - var $last_interactive_response = ''; - - /** - * Keyboard Interactive Request / Responses - * - * @see self::_keyboard_interactive_process() - * @var array - * @access private - */ - var $keyboard_requests_responses = array(); - - /** - * Banner Message - * - * Quoting from the RFC, "in some jurisdictions, sending a warning message before - * authentication may be relevant for getting legal protection." - * - * @see self::_filter() - * @see self::getBannerMessage() - * @var string - * @access private - */ - var $banner_message = ''; - - /** - * Did read() timeout or return normally? - * - * @see self::isTimeout() - * @var bool - * @access private - */ - var $is_timeout = false; - - /** - * Log Boundary - * - * @see self::_format_log() - * @var string - * @access private - */ - var $log_boundary = ':'; - - /** - * Log Long Width - * - * @see self::_format_log() - * @var int - * @access private - */ - var $log_long_width = 65; - - /** - * Log Short Width - * - * @see self::_format_log() - * @var int - * @access private - */ - var $log_short_width = 16; - - /** - * Hostname - * - * @see self::__construct() - * @see self::_connect() - * @var string - * @access private - */ - var $host; - - /** - * Port Number - * - * @see self::__construct() - * @see self::_connect() - * @var int - * @access private - */ - var $port; - - /** - * Number of columns for terminal window size - * - * @see self::getWindowColumns() - * @see self::setWindowColumns() - * @see self::setWindowSize() - * @var int - * @access private - */ - var $windowColumns = 80; - - /** - * Number of columns for terminal window size - * - * @see self::getWindowRows() - * @see self::setWindowRows() - * @see self::setWindowSize() - * @var int - * @access private - */ - var $windowRows = 24; - - /** - * Crypto Engine - * - * @see self::setCryptoEngine() - * @see self::_key_exchange() - * @var int - * @access private - */ - var $crypto_engine = false; - - /** - * A System_SSH_Agent for use in the SSH2 Agent Forwarding scenario - * - * @var System_SSH_Agent - * @access private - */ - var $agent; - - /** - * Default Constructor. - * - * $host can either be a string, representing the host, or a stream resource. - * - * @param mixed $host - * @param int $port - * @param int $timeout - * @see self::login() - * @return \phpseclib\Net\SSH2 - * @access public - */ - function __construct($host, $port = 22, $timeout = 10) - { - $this->message_numbers = array( - 1 => 'NET_SSH2_MSG_DISCONNECT', - 2 => 'NET_SSH2_MSG_IGNORE', - 3 => 'NET_SSH2_MSG_UNIMPLEMENTED', - 4 => 'NET_SSH2_MSG_DEBUG', - 5 => 'NET_SSH2_MSG_SERVICE_REQUEST', - 6 => 'NET_SSH2_MSG_SERVICE_ACCEPT', - 20 => 'NET_SSH2_MSG_KEXINIT', - 21 => 'NET_SSH2_MSG_NEWKEYS', - 30 => 'NET_SSH2_MSG_KEXDH_INIT', - 31 => 'NET_SSH2_MSG_KEXDH_REPLY', - 50 => 'NET_SSH2_MSG_USERAUTH_REQUEST', - 51 => 'NET_SSH2_MSG_USERAUTH_FAILURE', - 52 => 'NET_SSH2_MSG_USERAUTH_SUCCESS', - 53 => 'NET_SSH2_MSG_USERAUTH_BANNER', - - 80 => 'NET_SSH2_MSG_GLOBAL_REQUEST', - 81 => 'NET_SSH2_MSG_REQUEST_SUCCESS', - 82 => 'NET_SSH2_MSG_REQUEST_FAILURE', - 90 => 'NET_SSH2_MSG_CHANNEL_OPEN', - 91 => 'NET_SSH2_MSG_CHANNEL_OPEN_CONFIRMATION', - 92 => 'NET_SSH2_MSG_CHANNEL_OPEN_FAILURE', - 93 => 'NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST', - 94 => 'NET_SSH2_MSG_CHANNEL_DATA', - 95 => 'NET_SSH2_MSG_CHANNEL_EXTENDED_DATA', - 96 => 'NET_SSH2_MSG_CHANNEL_EOF', - 97 => 'NET_SSH2_MSG_CHANNEL_CLOSE', - 98 => 'NET_SSH2_MSG_CHANNEL_REQUEST', - 99 => 'NET_SSH2_MSG_CHANNEL_SUCCESS', - 100 => 'NET_SSH2_MSG_CHANNEL_FAILURE' - ); - $this->disconnect_reasons = array( - 1 => 'NET_SSH2_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT', - 2 => 'NET_SSH2_DISCONNECT_PROTOCOL_ERROR', - 3 => 'NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED', - 4 => 'NET_SSH2_DISCONNECT_RESERVED', - 5 => 'NET_SSH2_DISCONNECT_MAC_ERROR', - 6 => 'NET_SSH2_DISCONNECT_COMPRESSION_ERROR', - 7 => 'NET_SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE', - 8 => 'NET_SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED', - 9 => 'NET_SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE', - 10 => 'NET_SSH2_DISCONNECT_CONNECTION_LOST', - 11 => 'NET_SSH2_DISCONNECT_BY_APPLICATION', - 12 => 'NET_SSH2_DISCONNECT_TOO_MANY_CONNECTIONS', - 13 => 'NET_SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER', - 14 => 'NET_SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE', - 15 => 'NET_SSH2_DISCONNECT_ILLEGAL_USER_NAME' - ); - $this->channel_open_failure_reasons = array( - 1 => 'NET_SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED' - ); - $this->terminal_modes = array( - 0 => 'NET_SSH2_TTY_OP_END' - ); - $this->channel_extended_data_type_codes = array( - 1 => 'NET_SSH2_EXTENDED_DATA_STDERR' - ); - - $this->_define_array( - $this->message_numbers, - $this->disconnect_reasons, - $this->channel_open_failure_reasons, - $this->terminal_modes, - $this->channel_extended_data_type_codes, - array(60 => 'NET_SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ'), - array(60 => 'NET_SSH2_MSG_USERAUTH_PK_OK'), - array(60 => 'NET_SSH2_MSG_USERAUTH_INFO_REQUEST', - 61 => 'NET_SSH2_MSG_USERAUTH_INFO_RESPONSE'), - // RFC 4419 - diffie-hellman-group-exchange-sha{1,256} - array(30 => 'NET_SSH2_MSG_KEXDH_GEX_REQUEST_OLD', - 31 => 'NET_SSH2_MSG_KEXDH_GEX_GROUP', - 32 => 'NET_SSH2_MSG_KEXDH_GEX_INIT', - 33 => 'NET_SSH2_MSG_KEXDH_GEX_REPLY', - 34 => 'NET_SSH2_MSG_KEXDH_GEX_REQUEST'), - // RFC 5656 - Elliptic Curves (for curve25519-sha256@libssh.org) - array(30 => 'NET_SSH2_MSG_KEX_ECDH_INIT', - 31 => 'NET_SSH2_MSG_KEX_ECDH_REPLY') - ); - - if (is_resource($host)) { - $this->fsock = $host; - return; - } - - if (is_string($host)) { - $this->host = $host; - $this->port = $port; - $this->timeout = $timeout; - } - } - - /** - * Set Crypto Engine Mode - * - * Possible $engine values: - * CRYPT_MODE_INTERNAL, CRYPT_MODE_MCRYPT - * - * @param int $engine - * @access private - */ - function setCryptoEngine($engine) - { - $this->crypto_engine = $engine; - } - - /** - * Connect to an SSHv2 server - * - * @return bool - * @access private - */ - function _connect() - { - if ($this->bitmap & self::MASK_CONSTRUCTOR) { - return false; - } - - $this->bitmap |= self::MASK_CONSTRUCTOR; - - $this->curTimeout = $this->timeout; - - $this->last_packet = microtime(true); - - if (!is_resource($this->fsock)) { - $start = microtime(true); - $this->fsock = @fsockopen($this->host, $this->port, $errno, $errstr, $this->curTimeout); - if (!$this->fsock) { - $host = $this->host . ':' . $this->port; - user_error(rtrim("Cannot connect to $host. Error $errno. $errstr")); - return false; - } - $elapsed = microtime(true) - $start; - - $this->curTimeout-= $elapsed; - - if ($this->curTimeout <= 0) { - $this->is_timeout = true; - return false; - } - } - - /* According to the SSH2 specs, - - "The server MAY send other lines of data before sending the version - string. Each line SHOULD be terminated by a Carriage Return and Line - Feed. Such lines MUST NOT begin with "SSH-", and SHOULD be encoded - in ISO-10646 UTF-8 [RFC3629] (language is not specified). Clients - MUST be able to process such lines." */ - $temp = ''; - $extra = ''; - while (!feof($this->fsock) && !preg_match('#^SSH-(\d\.\d+)#', $temp, $matches)) { - if (substr($temp, -2) == "\r\n") { - $extra.= $temp; - $temp = ''; - } - - if ($this->curTimeout) { - if ($this->curTimeout < 0) { - $this->is_timeout = true; - return false; - } - $read = array($this->fsock); - $write = $except = null; - $start = microtime(true); - $sec = floor($this->curTimeout); - $usec = 1000000 * ($this->curTimeout - $sec); - // on windows this returns a "Warning: Invalid CRT parameters detected" error - // the !count() is done as a workaround for <https://bugs.php.net/42682> - if (!@stream_select($read, $write, $except, $sec, $usec) && !count($read)) { - $this->is_timeout = true; - return false; - } - $elapsed = microtime(true) - $start; - $this->curTimeout-= $elapsed; - } - - $temp.= fgets($this->fsock, 255); - } - - if (feof($this->fsock)) { - user_error('Connection closed by server'); - return false; - } - - $this->identifier = $this->_generate_identifier(); - - if (defined('NET_SSH2_LOGGING')) { - $this->_append_log('<-', $extra . $temp); - $this->_append_log('->', $this->identifier . "\r\n"); - } - - $this->server_identifier = trim($temp, "\r\n"); - if (strlen($extra)) { - $this->errors[] = utf8_decode($extra); - } - - if ($matches[1] != '1.99' && $matches[1] != '2.0') { - user_error("Cannot connect to SSH $matches[1] servers"); - return false; - } - - fputs($this->fsock, $this->identifier . "\r\n"); - - $response = $this->_get_binary_packet(); - if ($response === false) { - user_error('Connection closed by server'); - return false; - } - - if (ord($response[0]) != NET_SSH2_MSG_KEXINIT) { - user_error('Expected SSH_MSG_KEXINIT'); - return false; - } - - if (!$this->_key_exchange($response)) { - return false; - } - - $this->bitmap|= self::MASK_CONNECTED; - - return true; - } - - /** - * Generates the SSH identifier - * - * You should overwrite this method in your own class if you want to use another identifier - * - * @access protected - * @return string - */ - function _generate_identifier() - { - $identifier = 'SSH-2.0-phpseclib_2.0'; - - $ext = array(); - if (extension_loaded('libsodium')) { - $ext[] = 'libsodium'; - } - - if (extension_loaded('openssl')) { - $ext[] = 'openssl'; - } elseif (extension_loaded('mcrypt')) { - $ext[] = 'mcrypt'; - } - - if (extension_loaded('gmp')) { - $ext[] = 'gmp'; - } elseif (extension_loaded('bcmath')) { - $ext[] = 'bcmath'; - } - - if (!empty($ext)) { - $identifier .= ' (' . implode(', ', $ext) . ')'; - } - - return $identifier; - } - - /** - * Key Exchange - * - * @param string $kexinit_payload_server - * @access private - */ - function _key_exchange($kexinit_payload_server) - { - $kex_algorithms = array( - // Elliptic Curve Diffie-Hellman Key Agreement (ECDH) using - // Curve25519. See doc/curve25519-sha256@libssh.org.txt in the - // libssh repository for more information. - 'curve25519-sha256@libssh.org', - - // Diffie-Hellman Key Agreement (DH) using integer modulo prime - // groups. - 'diffie-hellman-group1-sha1', // REQUIRED - 'diffie-hellman-group14-sha1', // REQUIRED - 'diffie-hellman-group-exchange-sha1', // RFC 4419 - 'diffie-hellman-group-exchange-sha256', // RFC 4419 - ); - if (!class_exists('\Sodium')) { - $kex_algorithms = array_diff( - $kex_algorithms, - array('curve25519-sha256@libssh.org') - ); - } - - $server_host_key_algorithms = array( - 'ssh-rsa', // RECOMMENDED sign Raw RSA Key - 'ssh-dss' // REQUIRED sign Raw DSS Key - ); - - $encryption_algorithms = array( - // from <http://tools.ietf.org/html/rfc4345#section-4>: - 'arcfour256', - 'arcfour128', - - //'arcfour', // OPTIONAL the ARCFOUR stream cipher with a 128-bit key - - // CTR modes from <http://tools.ietf.org/html/rfc4344#section-4>: - 'aes128-ctr', // RECOMMENDED AES (Rijndael) in SDCTR mode, with 128-bit key - 'aes192-ctr', // RECOMMENDED AES with 192-bit key - 'aes256-ctr', // RECOMMENDED AES with 256-bit key - - 'twofish128-ctr', // OPTIONAL Twofish in SDCTR mode, with 128-bit key - 'twofish192-ctr', // OPTIONAL Twofish with 192-bit key - 'twofish256-ctr', // OPTIONAL Twofish with 256-bit key - - 'aes128-cbc', // RECOMMENDED AES with a 128-bit key - 'aes192-cbc', // OPTIONAL AES with a 192-bit key - 'aes256-cbc', // OPTIONAL AES in CBC mode, with a 256-bit key - - 'twofish128-cbc', // OPTIONAL Twofish with a 128-bit key - 'twofish192-cbc', // OPTIONAL Twofish with a 192-bit key - 'twofish256-cbc', - 'twofish-cbc', // OPTIONAL alias for "twofish256-cbc" - // (this is being retained for historical reasons) - - 'blowfish-ctr', // OPTIONAL Blowfish in SDCTR mode - - 'blowfish-cbc', // OPTIONAL Blowfish in CBC mode - - '3des-ctr', // RECOMMENDED Three-key 3DES in SDCTR mode - - '3des-cbc', // REQUIRED three-key 3DES in CBC mode - //'none' // OPTIONAL no encryption; NOT RECOMMENDED - ); - - if (extension_loaded('openssl') && !extension_loaded('mcrypt')) { - // OpenSSL does not support arcfour256 in any capacity and arcfour128 / arcfour support is limited to - // instances that do not use continuous buffers - $encryption_algorithms = array_diff( - $encryption_algorithms, - array('arcfour256', 'arcfour128', 'arcfour') - ); - } - - if (class_exists('\phpseclib\Crypt\RC4') === false) { - $encryption_algorithms = array_diff( - $encryption_algorithms, - array('arcfour256', 'arcfour128', 'arcfour') - ); - } - if (class_exists('\phpseclib\Crypt\Rijndael') === false) { - $encryption_algorithms = array_diff( - $encryption_algorithms, - array('aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'aes128-cbc', 'aes192-cbc', 'aes256-cbc') - ); - } - if (class_exists('\phpseclib\Crypt\Twofish') === false) { - $encryption_algorithms = array_diff( - $encryption_algorithms, - array('twofish128-ctr', 'twofish192-ctr', 'twofish256-ctr', 'twofish128-cbc', 'twofish192-cbc', 'twofish256-cbc', 'twofish-cbc') - ); - } - if (class_exists('\phpseclib\Crypt\Blowfish') === false) { - $encryption_algorithms = array_diff( - $encryption_algorithms, - array('blowfish-ctr', 'blowfish-cbc') - ); - } - if (class_exists('\phpseclib\Crypt\TripleDES') === false) { - $encryption_algorithms = array_diff( - $encryption_algorithms, - array('3des-ctr', '3des-cbc') - ); - } - $encryption_algorithms = array_values($encryption_algorithms); - - $mac_algorithms = array( - // from <http://www.ietf.org/rfc/rfc6668.txt>: - 'hmac-sha2-256',// RECOMMENDED HMAC-SHA256 (digest length = key length = 32) - - 'hmac-sha1-96', // RECOMMENDED first 96 bits of HMAC-SHA1 (digest length = 12, key length = 20) - 'hmac-sha1', // REQUIRED HMAC-SHA1 (digest length = key length = 20) - 'hmac-md5-96', // OPTIONAL first 96 bits of HMAC-MD5 (digest length = 12, key length = 16) - 'hmac-md5', // OPTIONAL HMAC-MD5 (digest length = key length = 16) - //'none' // OPTIONAL no MAC; NOT RECOMMENDED - ); - - $compression_algorithms = array( - 'none' // REQUIRED no compression - //'zlib' // OPTIONAL ZLIB (LZ77) compression - ); - - // some SSH servers have buggy implementations of some of the above algorithms - switch ($this->server_identifier) { - case 'SSH-2.0-SSHD': - $mac_algorithms = array_values(array_diff( - $mac_algorithms, - array('hmac-sha1-96', 'hmac-md5-96') - )); - } - - $str_kex_algorithms = implode(',', $kex_algorithms); - $str_server_host_key_algorithms = implode(',', $server_host_key_algorithms); - $encryption_algorithms_server_to_client = $encryption_algorithms_client_to_server = implode(',', $encryption_algorithms); - $mac_algorithms_server_to_client = $mac_algorithms_client_to_server = implode(',', $mac_algorithms); - $compression_algorithms_server_to_client = $compression_algorithms_client_to_server = implode(',', $compression_algorithms); - - $client_cookie = Random::string(16); - - $response = $kexinit_payload_server; - $this->_string_shift($response, 1); // skip past the message number (it should be SSH_MSG_KEXINIT) - $server_cookie = $this->_string_shift($response, 16); - - $temp = unpack('Nlength', $this->_string_shift($response, 4)); - $this->kex_algorithms = explode(',', $this->_string_shift($response, $temp['length'])); - - $temp = unpack('Nlength', $this->_string_shift($response, 4)); - $this->server_host_key_algorithms = explode(',', $this->_string_shift($response, $temp['length'])); - - $temp = unpack('Nlength', $this->_string_shift($response, 4)); - $this->encryption_algorithms_client_to_server = explode(',', $this->_string_shift($response, $temp['length'])); - - $temp = unpack('Nlength', $this->_string_shift($response, 4)); - $this->encryption_algorithms_server_to_client = explode(',', $this->_string_shift($response, $temp['length'])); - - $temp = unpack('Nlength', $this->_string_shift($response, 4)); - $this->mac_algorithms_client_to_server = explode(',', $this->_string_shift($response, $temp['length'])); - - $temp = unpack('Nlength', $this->_string_shift($response, 4)); - $this->mac_algorithms_server_to_client = explode(',', $this->_string_shift($response, $temp['length'])); - - $temp = unpack('Nlength', $this->_string_shift($response, 4)); - $this->compression_algorithms_client_to_server = explode(',', $this->_string_shift($response, $temp['length'])); - - $temp = unpack('Nlength', $this->_string_shift($response, 4)); - $this->compression_algorithms_server_to_client = explode(',', $this->_string_shift($response, $temp['length'])); - - $temp = unpack('Nlength', $this->_string_shift($response, 4)); - $this->languages_client_to_server = explode(',', $this->_string_shift($response, $temp['length'])); - - $temp = unpack('Nlength', $this->_string_shift($response, 4)); - $this->languages_server_to_client = explode(',', $this->_string_shift($response, $temp['length'])); - - extract(unpack('Cfirst_kex_packet_follows', $this->_string_shift($response, 1))); - $first_kex_packet_follows = $first_kex_packet_follows != 0; - - // the sending of SSH2_MSG_KEXINIT could go in one of two places. this is the second place. - $kexinit_payload_client = pack( - 'Ca*Na*Na*Na*Na*Na*Na*Na*Na*Na*Na*CN', - NET_SSH2_MSG_KEXINIT, - $client_cookie, - strlen($str_kex_algorithms), - $str_kex_algorithms, - strlen($str_server_host_key_algorithms), - $str_server_host_key_algorithms, - strlen($encryption_algorithms_client_to_server), - $encryption_algorithms_client_to_server, - strlen($encryption_algorithms_server_to_client), - $encryption_algorithms_server_to_client, - strlen($mac_algorithms_client_to_server), - $mac_algorithms_client_to_server, - strlen($mac_algorithms_server_to_client), - $mac_algorithms_server_to_client, - strlen($compression_algorithms_client_to_server), - $compression_algorithms_client_to_server, - strlen($compression_algorithms_server_to_client), - $compression_algorithms_server_to_client, - 0, - '', - 0, - '', - 0, - 0 - ); - - if (!$this->_send_binary_packet($kexinit_payload_client)) { - return false; - } - // here ends the second place. - - // we need to decide upon the symmetric encryption algorithms before we do the diffie-hellman key exchange - // we don't initialize any crypto-objects, yet - we do that, later. for now, we need the lengths to make the - // diffie-hellman key exchange as fast as possible - $decrypt = $this->_array_intersect_first($encryption_algorithms, $this->encryption_algorithms_server_to_client); - $decryptKeyLength = $this->_encryption_algorithm_to_key_size($decrypt); - if ($decryptKeyLength === null) { - user_error('No compatible server to client encryption algorithms found'); - return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); - } - - $encrypt = $this->_array_intersect_first($encryption_algorithms, $this->encryption_algorithms_client_to_server); - $encryptKeyLength = $this->_encryption_algorithm_to_key_size($encrypt); - if ($encryptKeyLength === null) { - user_error('No compatible client to server encryption algorithms found'); - return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); - } - - // through diffie-hellman key exchange a symmetric key is obtained - $kex_algorithm = $this->_array_intersect_first($kex_algorithms, $this->kex_algorithms); - if ($kex_algorithm === false) { - user_error('No compatible key exchange algorithms found'); - return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); - } - - // Only relevant in diffie-hellman-group-exchange-sha{1,256}, otherwise empty. - $exchange_hash_rfc4419 = ''; - - if ($kex_algorithm === 'curve25519-sha256@libssh.org') { - $x = Random::string(32); - $eBytes = \Sodium::crypto_box_publickey_from_secretkey($x); - $clientKexInitMessage = NET_SSH2_MSG_KEX_ECDH_INIT; - $serverKexReplyMessage = NET_SSH2_MSG_KEX_ECDH_REPLY; - $kexHash = new Hash('sha256'); - } else { - if (strpos($kex_algorithm, 'diffie-hellman-group-exchange') === 0) { - $dh_group_sizes_packed = pack( - 'NNN', - $this->kex_dh_group_size_min, - $this->kex_dh_group_size_preferred, - $this->kex_dh_group_size_max - ); - $packet = pack( - 'Ca*', - NET_SSH2_MSG_KEXDH_GEX_REQUEST, - $dh_group_sizes_packed - ); - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $response = $this->_get_binary_packet(); - if ($response === false) { - user_error('Connection closed by server'); - return false; - } - extract(unpack('Ctype', $this->_string_shift($response, 1))); - if ($type != NET_SSH2_MSG_KEXDH_GEX_GROUP) { - user_error('Expected SSH_MSG_KEX_DH_GEX_GROUP'); - return false; - } - - extract(unpack('NprimeLength', $this->_string_shift($response, 4))); - $primeBytes = $this->_string_shift($response, $primeLength); - $prime = new BigInteger($primeBytes, -256); - - extract(unpack('NgLength', $this->_string_shift($response, 4))); - $gBytes = $this->_string_shift($response, $gLength); - $g = new BigInteger($gBytes, -256); - - $exchange_hash_rfc4419 = pack( - 'a*Na*Na*', - $dh_group_sizes_packed, - $primeLength, - $primeBytes, - $gLength, - $gBytes - ); - - $clientKexInitMessage = NET_SSH2_MSG_KEXDH_GEX_INIT; - $serverKexReplyMessage = NET_SSH2_MSG_KEXDH_GEX_REPLY; - } else { - switch ($kex_algorithm) { - // see http://tools.ietf.org/html/rfc2409#section-6.2 and - // http://tools.ietf.org/html/rfc2412, appendex E - case 'diffie-hellman-group1-sha1': - $prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' . - '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' . - '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' . - 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF'; - break; - // see http://tools.ietf.org/html/rfc3526#section-3 - case 'diffie-hellman-group14-sha1': - $prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' . - '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' . - '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' . - 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF05' . - '98DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB' . - '9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B' . - 'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718' . - '3995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF'; - break; - } - // For both diffie-hellman-group1-sha1 and diffie-hellman-group14-sha1 - // the generator field element is 2 (decimal) and the hash function is sha1. - $g = new BigInteger(2); - $prime = new BigInteger($prime, 16); - $clientKexInitMessage = NET_SSH2_MSG_KEXDH_INIT; - $serverKexReplyMessage = NET_SSH2_MSG_KEXDH_REPLY; - } - - switch ($kex_algorithm) { - case 'diffie-hellman-group-exchange-sha256': - $kexHash = new Hash('sha256'); - break; - default: - $kexHash = new Hash('sha1'); - } - - /* To increase the speed of the key exchange, both client and server may - reduce the size of their private exponents. It should be at least - twice as long as the key material that is generated from the shared - secret. For more details, see the paper by van Oorschot and Wiener - [VAN-OORSCHOT]. - - -- http://tools.ietf.org/html/rfc4419#section-6.2 */ - $one = new BigInteger(1); - $keyLength = min($kexHash->getLength(), max($encryptKeyLength, $decryptKeyLength)); - $max = $one->bitwise_leftShift(16 * $keyLength); // 2 * 8 * $keyLength - $max = $max->subtract($one); - - $x = $one->random($one, $max); - $e = $g->modPow($x, $prime); - - $eBytes = $e->toBytes(true); - } - $data = pack('CNa*', $clientKexInitMessage, strlen($eBytes), $eBytes); - - if (!$this->_send_binary_packet($data)) { - user_error('Connection closed by server'); - return false; - } - - $response = $this->_get_binary_packet(); - if ($response === false) { - user_error('Connection closed by server'); - return false; - } - extract(unpack('Ctype', $this->_string_shift($response, 1))); - - if ($type != $serverKexReplyMessage) { - user_error('Expected SSH_MSG_KEXDH_REPLY'); - return false; - } - - $temp = unpack('Nlength', $this->_string_shift($response, 4)); - $this->server_public_host_key = $server_public_host_key = $this->_string_shift($response, $temp['length']); - - $temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4)); - $public_key_format = $this->_string_shift($server_public_host_key, $temp['length']); - - $temp = unpack('Nlength', $this->_string_shift($response, 4)); - $fBytes = $this->_string_shift($response, $temp['length']); - - $temp = unpack('Nlength', $this->_string_shift($response, 4)); - $this->signature = $this->_string_shift($response, $temp['length']); - - $temp = unpack('Nlength', $this->_string_shift($this->signature, 4)); - $this->signature_format = $this->_string_shift($this->signature, $temp['length']); - - if ($kex_algorithm === 'curve25519-sha256@libssh.org') { - if (strlen($fBytes) !== 32) { - user_error('Received curve25519 public key of invalid length.'); - return false; - } - $key = new BigInteger(\Sodium::crypto_scalarmult($x, $fBytes), 256); - \Sodium::sodium_memzero($x); - } else { - $f = new BigInteger($fBytes, -256); - $key = $f->modPow($x, $prime); - } - $keyBytes = $key->toBytes(true); - - $this->exchange_hash = pack( - 'Na*Na*Na*Na*Na*a*Na*Na*Na*', - strlen($this->identifier), - $this->identifier, - strlen($this->server_identifier), - $this->server_identifier, - strlen($kexinit_payload_client), - $kexinit_payload_client, - strlen($kexinit_payload_server), - $kexinit_payload_server, - strlen($this->server_public_host_key), - $this->server_public_host_key, - $exchange_hash_rfc4419, - strlen($eBytes), - $eBytes, - strlen($fBytes), - $fBytes, - strlen($keyBytes), - $keyBytes - ); - - $this->exchange_hash = $kexHash->hash($this->exchange_hash); - - if ($this->session_id === false) { - $this->session_id = $this->exchange_hash; - } - - $server_host_key_algorithm = $this->_array_intersect_first($server_host_key_algorithms, $this->server_host_key_algorithms); - if ($server_host_key_algorithm === false) { - user_error('No compatible server host key algorithms found'); - return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); - } - - if ($public_key_format != $server_host_key_algorithm || $this->signature_format != $server_host_key_algorithm) { - user_error('Server Host Key Algorithm Mismatch'); - return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); - } - - $packet = pack( - 'C', - NET_SSH2_MSG_NEWKEYS - ); - - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $response = $this->_get_binary_packet(); - - if ($response === false) { - user_error('Connection closed by server'); - return false; - } - - extract(unpack('Ctype', $this->_string_shift($response, 1))); - - if ($type != NET_SSH2_MSG_NEWKEYS) { - user_error('Expected SSH_MSG_NEWKEYS'); - return false; - } - - $keyBytes = pack('Na*', strlen($keyBytes), $keyBytes); - - $this->encrypt = $this->_encryption_algorithm_to_crypt_instance($encrypt); - if ($this->encrypt) { - if ($this->crypto_engine) { - $this->encrypt->setEngine($this->crypto_engine); - } - if ($this->encrypt->block_size) { - $this->encrypt_block_size = $this->encrypt->block_size; - } - $this->encrypt->enableContinuousBuffer(); - $this->encrypt->disablePadding(); - - $iv = $kexHash->hash($keyBytes . $this->exchange_hash . 'A' . $this->session_id); - while ($this->encrypt_block_size > strlen($iv)) { - $iv.= $kexHash->hash($keyBytes . $this->exchange_hash . $iv); - } - $this->encrypt->setIV(substr($iv, 0, $this->encrypt_block_size)); - - $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'C' . $this->session_id); - while ($encryptKeyLength > strlen($key)) { - $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); - } - $this->encrypt->setKey(substr($key, 0, $encryptKeyLength)); - } - - $this->decrypt = $this->_encryption_algorithm_to_crypt_instance($decrypt); - if ($this->decrypt) { - if ($this->crypto_engine) { - $this->decrypt->setEngine($this->crypto_engine); - } - if ($this->decrypt->block_size) { - $this->decrypt_block_size = $this->decrypt->block_size; - } - $this->decrypt->enableContinuousBuffer(); - $this->decrypt->disablePadding(); - - $iv = $kexHash->hash($keyBytes . $this->exchange_hash . 'B' . $this->session_id); - while ($this->decrypt_block_size > strlen($iv)) { - $iv.= $kexHash->hash($keyBytes . $this->exchange_hash . $iv); - } - $this->decrypt->setIV(substr($iv, 0, $this->decrypt_block_size)); - - $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'D' . $this->session_id); - while ($decryptKeyLength > strlen($key)) { - $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); - } - $this->decrypt->setKey(substr($key, 0, $decryptKeyLength)); - } - - /* The "arcfour128" algorithm is the RC4 cipher, as described in - [SCHNEIER], using a 128-bit key. The first 1536 bytes of keystream - generated by the cipher MUST be discarded, and the first byte of the - first encrypted packet MUST be encrypted using the 1537th byte of - keystream. - - -- http://tools.ietf.org/html/rfc4345#section-4 */ - if ($encrypt == 'arcfour128' || $encrypt == 'arcfour256') { - $this->encrypt->encrypt(str_repeat("\0", 1536)); - } - if ($decrypt == 'arcfour128' || $decrypt == 'arcfour256') { - $this->decrypt->decrypt(str_repeat("\0", 1536)); - } - - $mac_algorithm = $this->_array_intersect_first($mac_algorithms, $this->mac_algorithms_client_to_server); - if ($mac_algorithm === false) { - user_error('No compatible client to server message authentication algorithms found'); - return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); - } - - $createKeyLength = 0; // ie. $mac_algorithm == 'none' - switch ($mac_algorithm) { - case 'hmac-sha2-256': - $this->hmac_create = new Hash('sha256'); - $createKeyLength = 32; - break; - case 'hmac-sha1': - $this->hmac_create = new Hash('sha1'); - $createKeyLength = 20; - break; - case 'hmac-sha1-96': - $this->hmac_create = new Hash('sha1-96'); - $createKeyLength = 20; - break; - case 'hmac-md5': - $this->hmac_create = new Hash('md5'); - $createKeyLength = 16; - break; - case 'hmac-md5-96': - $this->hmac_create = new Hash('md5-96'); - $createKeyLength = 16; - } - - $mac_algorithm = $this->_array_intersect_first($mac_algorithms, $this->mac_algorithms_server_to_client); - if ($mac_algorithm === false) { - user_error('No compatible server to client message authentication algorithms found'); - return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); - } - - $checkKeyLength = 0; - $this->hmac_size = 0; - switch ($mac_algorithm) { - case 'hmac-sha2-256': - $this->hmac_check = new Hash('sha256'); - $checkKeyLength = 32; - $this->hmac_size = 32; - break; - case 'hmac-sha1': - $this->hmac_check = new Hash('sha1'); - $checkKeyLength = 20; - $this->hmac_size = 20; - break; - case 'hmac-sha1-96': - $this->hmac_check = new Hash('sha1-96'); - $checkKeyLength = 20; - $this->hmac_size = 12; - break; - case 'hmac-md5': - $this->hmac_check = new Hash('md5'); - $checkKeyLength = 16; - $this->hmac_size = 16; - break; - case 'hmac-md5-96': - $this->hmac_check = new Hash('md5-96'); - $checkKeyLength = 16; - $this->hmac_size = 12; - } - - $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'E' . $this->session_id); - while ($createKeyLength > strlen($key)) { - $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); - } - $this->hmac_create->setKey(substr($key, 0, $createKeyLength)); - - $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'F' . $this->session_id); - while ($checkKeyLength > strlen($key)) { - $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); - } - $this->hmac_check->setKey(substr($key, 0, $checkKeyLength)); - - $compression_algorithm = $this->_array_intersect_first($compression_algorithms, $this->compression_algorithms_server_to_client); - if ($compression_algorithm === false) { - user_error('No compatible server to client compression algorithms found'); - return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); - } - $this->decompress = $compression_algorithm == 'zlib'; - - $compression_algorithm = $this->_array_intersect_first($compression_algorithms, $this->compression_algorithms_client_to_server); - if ($compression_algorithm === false) { - user_error('No compatible client to server compression algorithms found'); - return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); - } - $this->compress = $compression_algorithm == 'zlib'; - - return true; - } - - /** - * Maps an encryption algorithm name to the number of key bytes. - * - * @param string $algorithm Name of the encryption algorithm - * @return int|null Number of bytes as an integer or null for unknown - * @access private - */ - function _encryption_algorithm_to_key_size($algorithm) - { - switch ($algorithm) { - case 'none': - return 0; - case 'aes128-cbc': - case 'aes128-ctr': - case 'arcfour': - case 'arcfour128': - case 'blowfish-cbc': - case 'blowfish-ctr': - case 'twofish128-cbc': - case 'twofish128-ctr': - return 16; - case '3des-cbc': - case '3des-ctr': - case 'aes192-cbc': - case 'aes192-ctr': - case 'twofish192-cbc': - case 'twofish192-ctr': - return 24; - case 'aes256-cbc': - case 'aes256-ctr': - case 'arcfour256': - case 'twofish-cbc': - case 'twofish256-cbc': - case 'twofish256-ctr': - return 32; - } - return null; - } - - /** - * Maps an encryption algorithm name to an instance of a subclass of - * \phpseclib\Crypt\Base. - * - * @param string $algorithm Name of the encryption algorithm - * @return mixed Instance of \phpseclib\Crypt\Base or null for unknown - * @access private - */ - function _encryption_algorithm_to_crypt_instance($algorithm) - { - switch ($algorithm) { - case '3des-cbc': - return new TripleDES(); - case '3des-ctr': - return new TripleDES(Base::MODE_CTR); - case 'aes256-cbc': - case 'aes192-cbc': - case 'aes128-cbc': - return new Rijndael(); - case 'aes256-ctr': - case 'aes192-ctr': - case 'aes128-ctr': - return new Rijndael(Base::MODE_CTR); - case 'blowfish-cbc': - return new Blowfish(); - case 'blowfish-ctr': - return new Blowfish(Base::MODE_CTR); - case 'twofish128-cbc': - case 'twofish192-cbc': - case 'twofish256-cbc': - case 'twofish-cbc': - return new Twofish(); - case 'twofish128-ctr': - case 'twofish192-ctr': - case 'twofish256-ctr': - return new Twofish(Base::MODE_CTR); - case 'arcfour': - case 'arcfour128': - case 'arcfour256': - return new RC4(); - } - return null; - } - - /** - * Login - * - * The $password parameter can be a plaintext password, a \phpseclib\Crypt\RSA object or an array - * - * @param string $username - * @param mixed $password - * @param mixed $... - * @return bool - * @see self::_login() - * @access public - */ - function login($username) - { - $args = func_get_args(); - return call_user_func_array(array(&$this, '_login'), $args); - } - - /** - * Login Helper - * - * @param string $username - * @param mixed $password - * @param mixed $... - * @return bool - * @see self::_login_helper() - * @access private - */ - function _login($username) - { - if (!($this->bitmap & self::MASK_CONSTRUCTOR)) { - if (!$this->_connect()) { - return false; - } - } - - $args = array_slice(func_get_args(), 1); - if (empty($args)) { - return $this->_login_helper($username); - } - - foreach ($args as $arg) { - if ($this->_login_helper($username, $arg)) { - return true; - } - } - return false; - } - - /** - * Login Helper - * - * @param string $username - * @param string $password - * @return bool - * @access private - * @internal It might be worthwhile, at some point, to protect against {@link http://tools.ietf.org/html/rfc4251#section-9.3.9 traffic analysis} - * by sending dummy SSH_MSG_IGNORE messages. - */ - function _login_helper($username, $password = null) - { - if (!($this->bitmap & self::MASK_CONNECTED)) { - return false; - } - - if (!($this->bitmap & self::MASK_LOGIN_REQ)) { - $packet = pack( - 'CNa*', - NET_SSH2_MSG_SERVICE_REQUEST, - strlen('ssh-userauth'), - 'ssh-userauth' - ); - - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $response = $this->_get_binary_packet(); - if ($response === false) { - user_error('Connection closed by server'); - return false; - } - - extract(unpack('Ctype', $this->_string_shift($response, 1))); - - if ($type != NET_SSH2_MSG_SERVICE_ACCEPT) { - user_error('Expected SSH_MSG_SERVICE_ACCEPT'); - return false; - } - $this->bitmap |= self::MASK_LOGIN_REQ; - } - - if (strlen($this->last_interactive_response)) { - return !is_string($password) && !is_array($password) ? false : $this->_keyboard_interactive_process($password); - } - - if ($password instanceof RSA) { - return $this->_privatekey_login($username, $password); - } elseif ($password instanceof Agent) { - return $this->_ssh_agent_login($username, $password); - } - - if (is_array($password)) { - if ($this->_keyboard_interactive_login($username, $password)) { - $this->bitmap |= self::MASK_LOGIN; - return true; - } - return false; - } - - if (!isset($password)) { - $packet = pack( - 'CNa*Na*Na*', - NET_SSH2_MSG_USERAUTH_REQUEST, - strlen($username), - $username, - strlen('ssh-connection'), - 'ssh-connection', - strlen('none'), - 'none' - ); - - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $response = $this->_get_binary_packet(); - if ($response === false) { - user_error('Connection closed by server'); - return false; - } - - extract(unpack('Ctype', $this->_string_shift($response, 1))); - - switch ($type) { - case NET_SSH2_MSG_USERAUTH_SUCCESS: - $this->bitmap |= self::MASK_LOGIN; - return true; - //case NET_SSH2_MSG_USERAUTH_FAILURE: - default: - return false; - } - } - - $packet = pack( - 'CNa*Na*Na*CNa*', - NET_SSH2_MSG_USERAUTH_REQUEST, - strlen($username), - $username, - strlen('ssh-connection'), - 'ssh-connection', - strlen('password'), - 'password', - 0, - strlen($password), - $password - ); - - // remove the username and password from the logged packet - if (!defined('NET_SSH2_LOGGING')) { - $logged = null; - } else { - $logged = pack( - 'CNa*Na*Na*CNa*', - NET_SSH2_MSG_USERAUTH_REQUEST, - strlen('username'), - 'username', - strlen('ssh-connection'), - 'ssh-connection', - strlen('password'), - 'password', - 0, - strlen('password'), - 'password' - ); - } - - if (!$this->_send_binary_packet($packet, $logged)) { - return false; - } - - $response = $this->_get_binary_packet(); - if ($response === false) { - user_error('Connection closed by server'); - return false; - } - - extract(unpack('Ctype', $this->_string_shift($response, 1))); - - switch ($type) { - case NET_SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ: // in theory, the password can be changed - if (defined('NET_SSH2_LOGGING')) { - $this->message_number_log[count($this->message_number_log) - 1] = 'NET_SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ'; - } - extract(unpack('Nlength', $this->_string_shift($response, 4))); - $this->errors[] = 'SSH_MSG_USERAUTH_PASSWD_CHANGEREQ: ' . utf8_decode($this->_string_shift($response, $length)); - return $this->_disconnect(NET_SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER); - case NET_SSH2_MSG_USERAUTH_FAILURE: - // can we use keyboard-interactive authentication? if not then either the login is bad or the server employees - // multi-factor authentication - extract(unpack('Nlength', $this->_string_shift($response, 4))); - $auth_methods = explode(',', $this->_string_shift($response, $length)); - extract(unpack('Cpartial_success', $this->_string_shift($response, 1))); - $partial_success = $partial_success != 0; - - if (!$partial_success && in_array('keyboard-interactive', $auth_methods)) { - if ($this->_keyboard_interactive_login($username, $password)) { - $this->bitmap |= self::MASK_LOGIN; - return true; - } - return false; - } - return false; - case NET_SSH2_MSG_USERAUTH_SUCCESS: - $this->bitmap |= self::MASK_LOGIN; - return true; - } - - return false; - } - - /** - * Login via keyboard-interactive authentication - * - * See {@link http://tools.ietf.org/html/rfc4256 RFC4256} for details. This is not a full-featured keyboard-interactive authenticator. - * - * @param string $username - * @param string $password - * @return bool - * @access private - */ - function _keyboard_interactive_login($username, $password) - { - $packet = pack( - 'CNa*Na*Na*Na*Na*', - NET_SSH2_MSG_USERAUTH_REQUEST, - strlen($username), - $username, - strlen('ssh-connection'), - 'ssh-connection', - strlen('keyboard-interactive'), - 'keyboard-interactive', - 0, - '', - 0, - '' - ); - - if (!$this->_send_binary_packet($packet)) { - return false; - } - - return $this->_keyboard_interactive_process($password); - } - - /** - * Handle the keyboard-interactive requests / responses. - * - * @param string $responses... - * @return bool - * @access private - */ - function _keyboard_interactive_process() - { - $responses = func_get_args(); - - if (strlen($this->last_interactive_response)) { - $response = $this->last_interactive_response; - } else { - $orig = $response = $this->_get_binary_packet(); - if ($response === false) { - user_error('Connection closed by server'); - return false; - } - } - - extract(unpack('Ctype', $this->_string_shift($response, 1))); - - switch ($type) { - case NET_SSH2_MSG_USERAUTH_INFO_REQUEST: - extract(unpack('Nlength', $this->_string_shift($response, 4))); - $this->_string_shift($response, $length); // name; may be empty - extract(unpack('Nlength', $this->_string_shift($response, 4))); - $this->_string_shift($response, $length); // instruction; may be empty - extract(unpack('Nlength', $this->_string_shift($response, 4))); - $this->_string_shift($response, $length); // language tag; may be empty - extract(unpack('Nnum_prompts', $this->_string_shift($response, 4))); - - for ($i = 0; $i < count($responses); $i++) { - if (is_array($responses[$i])) { - foreach ($responses[$i] as $key => $value) { - $this->keyboard_requests_responses[$key] = $value; - } - unset($responses[$i]); - } - } - $responses = array_values($responses); - - if (isset($this->keyboard_requests_responses)) { - for ($i = 0; $i < $num_prompts; $i++) { - extract(unpack('Nlength', $this->_string_shift($response, 4))); - // prompt - ie. "Password: "; must not be empty - $prompt = $this->_string_shift($response, $length); - //$echo = $this->_string_shift($response) != chr(0); - foreach ($this->keyboard_requests_responses as $key => $value) { - if (substr($prompt, 0, strlen($key)) == $key) { - $responses[] = $value; - break; - } - } - } - } - - // see http://tools.ietf.org/html/rfc4256#section-3.2 - if (strlen($this->last_interactive_response)) { - $this->last_interactive_response = ''; - } elseif (defined('NET_SSH2_LOGGING')) { - $this->message_number_log[count($this->message_number_log) - 1] = str_replace( - 'UNKNOWN', - 'NET_SSH2_MSG_USERAUTH_INFO_REQUEST', - $this->message_number_log[count($this->message_number_log) - 1] - ); - } - - if (!count($responses) && $num_prompts) { - $this->last_interactive_response = $orig; - return false; - } - - /* - After obtaining the requested information from the user, the client - MUST respond with an SSH_MSG_USERAUTH_INFO_RESPONSE message. - */ - // see http://tools.ietf.org/html/rfc4256#section-3.4 - $packet = $logged = pack('CN', NET_SSH2_MSG_USERAUTH_INFO_RESPONSE, count($responses)); - for ($i = 0; $i < count($responses); $i++) { - $packet.= pack('Na*', strlen($responses[$i]), $responses[$i]); - $logged.= pack('Na*', strlen('dummy-answer'), 'dummy-answer'); - } - - if (!$this->_send_binary_packet($packet, $logged)) { - return false; - } - - if (defined('NET_SSH2_LOGGING') && NET_SSH2_LOGGING == self::LOG_COMPLEX) { - $this->message_number_log[count($this->message_number_log) - 1] = str_replace( - 'UNKNOWN', - 'NET_SSH2_MSG_USERAUTH_INFO_RESPONSE', - $this->message_number_log[count($this->message_number_log) - 1] - ); - } - - /* - After receiving the response, the server MUST send either an - SSH_MSG_USERAUTH_SUCCESS, SSH_MSG_USERAUTH_FAILURE, or another - SSH_MSG_USERAUTH_INFO_REQUEST message. - */ - // maybe phpseclib should force close the connection after x request / responses? unless something like that is done - // there could be an infinite loop of request / responses. - return $this->_keyboard_interactive_process(); - case NET_SSH2_MSG_USERAUTH_SUCCESS: - return true; - case NET_SSH2_MSG_USERAUTH_FAILURE: - return false; - } - - return false; - } - - /** - * Login with an ssh-agent provided key - * - * @param string $username - * @param \phpseclib\System\SSH\Agent $agent - * @return bool - * @access private - */ - function _ssh_agent_login($username, $agent) - { - $this->agent = $agent; - $keys = $agent->requestIdentities(); - foreach ($keys as $key) { - if ($this->_privatekey_login($username, $key)) { - return true; - } - } - - return false; - } - - /** - * Login with an RSA private key - * - * @param string $username - * @param \phpseclib\Crypt\RSA $password - * @return bool - * @access private - * @internal It might be worthwhile, at some point, to protect against {@link http://tools.ietf.org/html/rfc4251#section-9.3.9 traffic analysis} - * by sending dummy SSH_MSG_IGNORE messages. - */ - function _privatekey_login($username, $privatekey) - { - // see http://tools.ietf.org/html/rfc4253#page-15 - $publickey = $privatekey->getPublicKey(RSA::PUBLIC_FORMAT_RAW); - if ($publickey === false) { - return false; - } - - $publickey = array( - 'e' => $publickey['e']->toBytes(true), - 'n' => $publickey['n']->toBytes(true) - ); - $publickey = pack( - 'Na*Na*Na*', - strlen('ssh-rsa'), - 'ssh-rsa', - strlen($publickey['e']), - $publickey['e'], - strlen($publickey['n']), - $publickey['n'] - ); - - $part1 = pack( - 'CNa*Na*Na*', - NET_SSH2_MSG_USERAUTH_REQUEST, - strlen($username), - $username, - strlen('ssh-connection'), - 'ssh-connection', - strlen('publickey'), - 'publickey' - ); - $part2 = pack('Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($publickey), $publickey); - - $packet = $part1 . chr(0) . $part2; - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $response = $this->_get_binary_packet(); - if ($response === false) { - user_error('Connection closed by server'); - return false; - } - - extract(unpack('Ctype', $this->_string_shift($response, 1))); - - switch ($type) { - case NET_SSH2_MSG_USERAUTH_FAILURE: - extract(unpack('Nlength', $this->_string_shift($response, 4))); - $this->errors[] = 'SSH_MSG_USERAUTH_FAILURE: ' . $this->_string_shift($response, $length); - return false; - case NET_SSH2_MSG_USERAUTH_PK_OK: - // we'll just take it on faith that the public key blob and the public key algorithm name are as - // they should be - if (defined('NET_SSH2_LOGGING') && NET_SSH2_LOGGING == self::LOG_COMPLEX) { - $this->message_number_log[count($this->message_number_log) - 1] = str_replace( - 'UNKNOWN', - 'NET_SSH2_MSG_USERAUTH_PK_OK', - $this->message_number_log[count($this->message_number_log) - 1] - ); - } - } - - $packet = $part1 . chr(1) . $part2; - $privatekey->setSignatureMode(RSA::SIGNATURE_PKCS1); - $signature = $privatekey->sign(pack('Na*a*', strlen($this->session_id), $this->session_id, $packet)); - $signature = pack('Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($signature), $signature); - $packet.= pack('Na*', strlen($signature), $signature); - - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $response = $this->_get_binary_packet(); - if ($response === false) { - user_error('Connection closed by server'); - return false; - } - - extract(unpack('Ctype', $this->_string_shift($response, 1))); - - switch ($type) { - case NET_SSH2_MSG_USERAUTH_FAILURE: - // either the login is bad or the server employs multi-factor authentication - return false; - case NET_SSH2_MSG_USERAUTH_SUCCESS: - $this->bitmap |= self::MASK_LOGIN; - return true; - } - - return false; - } - - /** - * Set Timeout - * - * $ssh->exec('ping 127.0.0.1'); on a Linux host will never return and will run indefinitely. setTimeout() makes it so it'll timeout. - * Setting $timeout to false or 0 will mean there is no timeout. - * - * @param mixed $timeout - * @access public - */ - function setTimeout($timeout) - { - $this->timeout = $this->curTimeout = $timeout; - } - - /** - * Get the output from stdError - * - * @access public - */ - function getStdError() - { - return $this->stdErrorLog; - } - - /** - * Execute Command - * - * If $callback is set to false then \phpseclib\Net\SSH2::_get_channel_packet(self::CHANNEL_EXEC) will need to be called manually. - * In all likelihood, this is not a feature you want to be taking advantage of. - * - * @param string $command - * @param Callback $callback - * @return string - * @access public - */ - function exec($command, $callback = null) - { - $this->curTimeout = $this->timeout; - $this->is_timeout = false; - $this->stdErrorLog = ''; - - if (!($this->bitmap & self::MASK_LOGIN)) { - return false; - } - - // RFC4254 defines the (client) window size as "bytes the other party can send before it must wait for the window to - // be adjusted". 0x7FFFFFFF is, at 2GB, the max size. technically, it should probably be decremented, but, - // honestly, if you're transfering more than 2GB, you probably shouldn't be using phpseclib, anyway. - // see http://tools.ietf.org/html/rfc4254#section-5.2 for more info - $this->window_size_server_to_client[self::CHANNEL_EXEC] = $this->window_size; - // 0x8000 is the maximum max packet size, per http://tools.ietf.org/html/rfc4253#section-6.1, although since PuTTy - // uses 0x4000, that's what will be used here, as well. - $packet_size = 0x4000; - - $packet = pack( - 'CNa*N3', - NET_SSH2_MSG_CHANNEL_OPEN, - strlen('session'), - 'session', - self::CHANNEL_EXEC, - $this->window_size_server_to_client[self::CHANNEL_EXEC], - $packet_size - ); - - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $this->channel_status[self::CHANNEL_EXEC] = NET_SSH2_MSG_CHANNEL_OPEN; - - $response = $this->_get_channel_packet(self::CHANNEL_EXEC); - if ($response === false) { - return false; - } - - if ($this->request_pty === true) { - $terminal_modes = pack('C', NET_SSH2_TTY_OP_END); - $packet = pack( - 'CNNa*CNa*N5a*', - NET_SSH2_MSG_CHANNEL_REQUEST, - $this->server_channels[self::CHANNEL_EXEC], - strlen('pty-req'), - 'pty-req', - 1, - strlen('vt100'), - 'vt100', - $this->windowColumns, - $this->windowRows, - 0, - 0, - strlen($terminal_modes), - $terminal_modes - ); - - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $response = $this->_get_binary_packet(); - if ($response === false) { - user_error('Connection closed by server'); - return false; - } - - list(, $type) = unpack('C', $this->_string_shift($response, 1)); - - switch ($type) { - case NET_SSH2_MSG_CHANNEL_SUCCESS: - break; - case NET_SSH2_MSG_CHANNEL_FAILURE: - default: - user_error('Unable to request pseudo-terminal'); - return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); - } - $this->in_request_pty_exec = true; - } - - // sending a pty-req SSH_MSG_CHANNEL_REQUEST message is unnecessary and, in fact, in most cases, slows things - // down. the one place where it might be desirable is if you're doing something like \phpseclib\Net\SSH2::exec('ping localhost &'). - // with a pty-req SSH_MSG_CHANNEL_REQUEST, exec() will return immediately and the ping process will then - // then immediately terminate. without such a request exec() will loop indefinitely. the ping process won't end but - // neither will your script. - - // although, in theory, the size of SSH_MSG_CHANNEL_REQUEST could exceed the maximum packet size established by - // SSH_MSG_CHANNEL_OPEN_CONFIRMATION, RFC4254#section-5.1 states that the "maximum packet size" refers to the - // "maximum size of an individual data packet". ie. SSH_MSG_CHANNEL_DATA. RFC4254#section-5.2 corroborates. - $packet = pack( - 'CNNa*CNa*', - NET_SSH2_MSG_CHANNEL_REQUEST, - $this->server_channels[self::CHANNEL_EXEC], - strlen('exec'), - 'exec', - 1, - strlen($command), - $command - ); - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $this->channel_status[self::CHANNEL_EXEC] = NET_SSH2_MSG_CHANNEL_REQUEST; - - $response = $this->_get_channel_packet(self::CHANNEL_EXEC); - if ($response === false) { - return false; - } - - $this->channel_status[self::CHANNEL_EXEC] = NET_SSH2_MSG_CHANNEL_DATA; - - if ($callback === false || $this->in_request_pty_exec) { - return true; - } - - $output = ''; - while (true) { - $temp = $this->_get_channel_packet(self::CHANNEL_EXEC); - switch (true) { - case $temp === true: - return is_callable($callback) ? true : $output; - case $temp === false: - return false; - default: - if (is_callable($callback)) { - if (call_user_func($callback, $temp) === true) { - $this->_close_channel(self::CHANNEL_EXEC); - return true; - } - } else { - $output.= $temp; - } - } - } - } - - /** - * Creates an interactive shell - * - * @see self::read() - * @see self::write() - * @return bool - * @access private - */ - function _initShell() - { - if ($this->in_request_pty_exec === true) { - return true; - } - - $this->window_size_server_to_client[self::CHANNEL_SHELL] = $this->window_size; - $packet_size = 0x4000; - - $packet = pack( - 'CNa*N3', - NET_SSH2_MSG_CHANNEL_OPEN, - strlen('session'), - 'session', - self::CHANNEL_SHELL, - $this->window_size_server_to_client[self::CHANNEL_SHELL], - $packet_size - ); - - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $this->channel_status[self::CHANNEL_SHELL] = NET_SSH2_MSG_CHANNEL_OPEN; - - $response = $this->_get_channel_packet(self::CHANNEL_SHELL); - if ($response === false) { - return false; - } - - $terminal_modes = pack('C', NET_SSH2_TTY_OP_END); - $packet = pack( - 'CNNa*CNa*N5a*', - NET_SSH2_MSG_CHANNEL_REQUEST, - $this->server_channels[self::CHANNEL_SHELL], - strlen('pty-req'), - 'pty-req', - 1, - strlen('vt100'), - 'vt100', - $this->windowColumns, - $this->windowRows, - 0, - 0, - strlen($terminal_modes), - $terminal_modes - ); - - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $response = $this->_get_binary_packet(); - if ($response === false) { - user_error('Connection closed by server'); - return false; - } - - list(, $type) = unpack('C', $this->_string_shift($response, 1)); - - switch ($type) { - case NET_SSH2_MSG_CHANNEL_SUCCESS: - // if a pty can't be opened maybe commands can still be executed - case NET_SSH2_MSG_CHANNEL_FAILURE: - break; - default: - user_error('Unable to request pseudo-terminal'); - return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); - } - - $packet = pack( - 'CNNa*C', - NET_SSH2_MSG_CHANNEL_REQUEST, - $this->server_channels[self::CHANNEL_SHELL], - strlen('shell'), - 'shell', - 1 - ); - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $this->channel_status[self::CHANNEL_SHELL] = NET_SSH2_MSG_CHANNEL_REQUEST; - - $response = $this->_get_channel_packet(self::CHANNEL_SHELL); - if ($response === false) { - return false; - } - - $this->channel_status[self::CHANNEL_SHELL] = NET_SSH2_MSG_CHANNEL_DATA; - - $this->bitmap |= self::MASK_SHELL; - - return true; - } - - /** - * Return the channel to be used with read() / write() - * - * @see self::read() - * @see self::write() - * @return int - * @access public - */ - function _get_interactive_channel() - { - switch (true) { - case $this->in_subsystem: - return self::CHANNEL_SUBSYSTEM; - case $this->in_request_pty_exec: - return self::CHANNEL_EXEC; - default: - return self::CHANNEL_SHELL; - } - } - - /** - * Return an available open channel - * - * @return int - * @access public - */ - function _get_open_channel() - { - $channel = self::CHANNEL_EXEC; - do { - if (isset($this->channel_status[$channel]) && $this->channel_status[$channel] == NET_SSH2_MSG_CHANNEL_OPEN) { - return $channel; - } - } while ($channel++ < self::CHANNEL_SUBSYSTEM); - - return false; - } - - /** - * Returns the output of an interactive shell - * - * Returns when there's a match for $expect, which can take the form of a string literal or, - * if $mode == self::READ_REGEX, a regular expression. - * - * @see self::write() - * @param string $expect - * @param int $mode - * @return string - * @access public - */ - function read($expect = '', $mode = self::READ_SIMPLE) - { - $this->curTimeout = $this->timeout; - $this->is_timeout = false; - - if (!($this->bitmap & self::MASK_LOGIN)) { - user_error('Operation disallowed prior to login()'); - return false; - } - - if (!($this->bitmap & self::MASK_SHELL) && !$this->_initShell()) { - user_error('Unable to initiate an interactive shell session'); - return false; - } - - $channel = $this->_get_interactive_channel(); - - $match = $expect; - while (true) { - if ($mode == self::READ_REGEX) { - preg_match($expect, substr($this->interactiveBuffer, -1024), $matches); - $match = isset($matches[0]) ? $matches[0] : ''; - } - $pos = strlen($match) ? strpos($this->interactiveBuffer, $match) : false; - if ($pos !== false) { - return $this->_string_shift($this->interactiveBuffer, $pos + strlen($match)); - } - $response = $this->_get_channel_packet($channel); - if (is_bool($response)) { - $this->in_request_pty_exec = false; - return $response ? $this->_string_shift($this->interactiveBuffer, strlen($this->interactiveBuffer)) : false; - } - - $this->interactiveBuffer.= $response; - } - } - - /** - * Inputs a command into an interactive shell. - * - * @see self::read() - * @param string $cmd - * @return bool - * @access public - */ - function write($cmd) - { - if (!($this->bitmap & self::MASK_LOGIN)) { - user_error('Operation disallowed prior to login()'); - return false; - } - - if (!($this->bitmap & self::MASK_SHELL) && !$this->_initShell()) { - user_error('Unable to initiate an interactive shell session'); - return false; - } - - return $this->_send_channel_packet($this->_get_interactive_channel(), $cmd); - } - - /** - * Start a subsystem. - * - * Right now only one subsystem at a time is supported. To support multiple subsystem's stopSubsystem() could accept - * a string that contained the name of the subsystem, but at that point, only one subsystem of each type could be opened. - * To support multiple subsystem's of the same name maybe it'd be best if startSubsystem() generated a new channel id and - * returns that and then that that was passed into stopSubsystem() but that'll be saved for a future date and implemented - * if there's sufficient demand for such a feature. - * - * @see self::stopSubsystem() - * @param string $subsystem - * @return bool - * @access public - */ - function startSubsystem($subsystem) - { - $this->window_size_server_to_client[self::CHANNEL_SUBSYSTEM] = $this->window_size; - - $packet = pack( - 'CNa*N3', - NET_SSH2_MSG_CHANNEL_OPEN, - strlen('session'), - 'session', - self::CHANNEL_SUBSYSTEM, - $this->window_size, - 0x4000 - ); - - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $this->channel_status[self::CHANNEL_SUBSYSTEM] = NET_SSH2_MSG_CHANNEL_OPEN; - - $response = $this->_get_channel_packet(self::CHANNEL_SUBSYSTEM); - if ($response === false) { - return false; - } - - $packet = pack( - 'CNNa*CNa*', - NET_SSH2_MSG_CHANNEL_REQUEST, - $this->server_channels[self::CHANNEL_SUBSYSTEM], - strlen('subsystem'), - 'subsystem', - 1, - strlen($subsystem), - $subsystem - ); - if (!$this->_send_binary_packet($packet)) { - return false; - } - - $this->channel_status[self::CHANNEL_SUBSYSTEM] = NET_SSH2_MSG_CHANNEL_REQUEST; - - $response = $this->_get_channel_packet(self::CHANNEL_SUBSYSTEM); - - if ($response === false) { - return false; - } - - $this->channel_status[self::CHANNEL_SUBSYSTEM] = NET_SSH2_MSG_CHANNEL_DATA; - - $this->bitmap |= self::MASK_SHELL; - $this->in_subsystem = true; - - return true; - } - - /** - * Stops a subsystem. - * - * @see self::startSubsystem() - * @return bool - * @access public - */ - function stopSubsystem() - { - $this->in_subsystem = false; - $this->_close_channel(self::CHANNEL_SUBSYSTEM); - return true; - } - - /** - * Closes a channel - * - * If read() timed out you might want to just close the channel and have it auto-restart on the next read() call - * - * @access public - */ - function reset() - { - $this->_close_channel($this->_get_interactive_channel()); - } - - /** - * Is timeout? - * - * Did exec() or read() return because they timed out or because they encountered the end? - * - * @access public - */ - function isTimeout() - { - return $this->is_timeout; - } - - /** - * Disconnect - * - * @access public - */ - function disconnect() - { - $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); - if (isset($this->realtime_log_file) && is_resource($this->realtime_log_file)) { - fclose($this->realtime_log_file); - } - } - - /** - * Destructor. - * - * Will be called, automatically, if you're supporting just PHP5. If you're supporting PHP4, you'll need to call - * disconnect(). - * - * @access public - */ - function __destruct() - { - $this->disconnect(); - } - - /** - * Is the connection still active? - * - * @return bool - * @access public - */ - function isConnected() - { - return (bool) ($this->bitmap & self::MASK_CONNECTED); - } - - /** - * Have you successfully been logged in? - * - * @return bool - * @access public - */ - function isAuthenticated() - { - return (bool) ($this->bitmap & self::MASK_LOGIN); - } - - /** - * Gets Binary Packets - * - * See '6. Binary Packet Protocol' of rfc4253 for more info. - * - * @see self::_send_binary_packet() - * @return string - * @access private - */ - function _get_binary_packet() - { - if (!is_resource($this->fsock) || feof($this->fsock)) { - user_error('Connection closed prematurely'); - $this->bitmap = 0; - return false; - } - - $start = microtime(true); - $raw = fread($this->fsock, $this->decrypt_block_size); - - if (!strlen($raw)) { - return ''; - } - - if ($this->decrypt !== false) { - $raw = $this->decrypt->decrypt($raw); - } - if ($raw === false) { - user_error('Unable to decrypt content'); - return false; - } - - extract(unpack('Npacket_length/Cpadding_length', $this->_string_shift($raw, 5))); - - $remaining_length = $packet_length + 4 - $this->decrypt_block_size; - - // quoting <http://tools.ietf.org/html/rfc4253#section-6.1>, - // "implementations SHOULD check that the packet length is reasonable" - // PuTTY uses 0x9000 as the actual max packet size and so to shall we - if ($remaining_length < -$this->decrypt_block_size || $remaining_length > 0x9000 || $remaining_length % $this->decrypt_block_size != 0) { - user_error('Invalid size'); - return false; - } - - $buffer = ''; - while ($remaining_length > 0) { - $temp = fread($this->fsock, $remaining_length); - if ($temp === false || feof($this->fsock)) { - user_error('Error reading from socket'); - $this->bitmap = 0; - return false; - } - $buffer.= $temp; - $remaining_length-= strlen($temp); - } - $stop = microtime(true); - if (strlen($buffer)) { - $raw.= $this->decrypt !== false ? $this->decrypt->decrypt($buffer) : $buffer; - } - - $payload = $this->_string_shift($raw, $packet_length - $padding_length - 1); - $padding = $this->_string_shift($raw, $padding_length); // should leave $raw empty - - if ($this->hmac_check !== false) { - $hmac = fread($this->fsock, $this->hmac_size); - if ($hmac === false || strlen($hmac) != $this->hmac_size) { - user_error('Error reading socket'); - $this->bitmap = 0; - return false; - } elseif ($hmac != $this->hmac_check->hash(pack('NNCa*', $this->get_seq_no, $packet_length, $padding_length, $payload . $padding))) { - user_error('Invalid HMAC'); - return false; - } - } - - //if ($this->decompress) { - // $payload = gzinflate(substr($payload, 2)); - //} - - $this->get_seq_no++; - - if (defined('NET_SSH2_LOGGING')) { - $current = microtime(true); - $message_number = isset($this->message_numbers[ord($payload[0])]) ? $this->message_numbers[ord($payload[0])] : 'UNKNOWN (' . ord($payload[0]) . ')'; - $message_number = '<- ' . $message_number . - ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; - $this->_append_log($message_number, $payload); - $this->last_packet = $current; - } - - return $this->_filter($payload); - } - - /** - * Filter Binary Packets - * - * Because some binary packets need to be ignored... - * - * @see self::_get_binary_packet() - * @return string - * @access private - */ - function _filter($payload) - { - switch (ord($payload[0])) { - case NET_SSH2_MSG_DISCONNECT: - $this->_string_shift($payload, 1); - extract(unpack('Nreason_code/Nlength', $this->_string_shift($payload, 8))); - $this->errors[] = 'SSH_MSG_DISCONNECT: ' . $this->disconnect_reasons[$reason_code] . "\r\n" . utf8_decode($this->_string_shift($payload, $length)); - $this->bitmap = 0; - return false; - case NET_SSH2_MSG_IGNORE: - $payload = $this->_get_binary_packet(); - break; - case NET_SSH2_MSG_DEBUG: - $this->_string_shift($payload, 2); - extract(unpack('Nlength', $this->_string_shift($payload, 4))); - $this->errors[] = 'SSH_MSG_DEBUG: ' . utf8_decode($this->_string_shift($payload, $length)); - $payload = $this->_get_binary_packet(); - break; - case NET_SSH2_MSG_UNIMPLEMENTED: - return false; - case NET_SSH2_MSG_KEXINIT: - if ($this->session_id !== false) { - if (!$this->_key_exchange($payload)) { - $this->bitmap = 0; - return false; - } - $payload = $this->_get_binary_packet(); - } - } - - // see http://tools.ietf.org/html/rfc4252#section-5.4; only called when the encryption has been activated and when we haven't already logged in - if (($this->bitmap & self::MASK_CONNECTED) && !($this->bitmap & self::MASK_LOGIN) && ord($payload[0]) == NET_SSH2_MSG_USERAUTH_BANNER) { - $this->_string_shift($payload, 1); - extract(unpack('Nlength', $this->_string_shift($payload, 4))); - $this->banner_message = utf8_decode($this->_string_shift($payload, $length)); - $payload = $this->_get_binary_packet(); - } - - // only called when we've already logged in - if (($this->bitmap & self::MASK_CONNECTED) && ($this->bitmap & self::MASK_LOGIN)) { - switch (ord($payload[0])) { - case NET_SSH2_MSG_GLOBAL_REQUEST: // see http://tools.ietf.org/html/rfc4254#section-4 - extract(unpack('Nlength', $this->_string_shift($payload, 4))); - $this->errors[] = 'SSH_MSG_GLOBAL_REQUEST: ' . $this->_string_shift($payload, $length); - - if (!$this->_send_binary_packet(pack('C', NET_SSH2_MSG_REQUEST_FAILURE))) { - return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); - } - - $payload = $this->_get_binary_packet(); - break; - case NET_SSH2_MSG_CHANNEL_OPEN: // see http://tools.ietf.org/html/rfc4254#section-5.1 - $this->_string_shift($payload, 1); - extract(unpack('Nlength', $this->_string_shift($payload, 4))); - $data = $this->_string_shift($payload, $length); - extract(unpack('Nserver_channel', $this->_string_shift($payload, 4))); - switch ($data) { - case 'auth-agent': - case 'auth-agent@openssh.com': - if (isset($this->agent)) { - $new_channel = self::CHANNEL_AGENT_FORWARD; - - extract(unpack('Nremote_window_size', $this->_string_shift($payload, 4))); - extract(unpack('Nremote_maximum_packet_size', $this->_string_shift($payload, 4))); - - $this->packet_size_client_to_server[$new_channel] = $remote_window_size; - $this->window_size_server_to_client[$new_channel] = $remote_maximum_packet_size; - $this->window_size_client_to_server[$new_channel] = $this->window_size; - - $packet_size = 0x4000; - - $packet = pack( - 'CN4', - NET_SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, - $server_channel, - $new_channel, - $packet_size, - $packet_size - ); - - $this->server_channels[$new_channel] = $server_channel; - $this->channel_status[$new_channel] = NET_SSH2_MSG_CHANNEL_OPEN_CONFIRMATION; - if (!$this->_send_binary_packet($packet)) { - return false; - } - } - break; - default: - $packet = pack( - 'CN3a*Na*', - NET_SSH2_MSG_REQUEST_FAILURE, - $server_channel, - NET_SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED, - 0, - '', - 0, - '' - ); - - if (!$this->_send_binary_packet($packet)) { - return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); - } - } - $payload = $this->_get_binary_packet(); - break; - case NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST: - $this->_string_shift($payload, 1); - extract(unpack('Nchannel', $this->_string_shift($payload, 4))); - extract(unpack('Nwindow_size', $this->_string_shift($payload, 4))); - $this->window_size_client_to_server[$channel]+= $window_size; - - $payload = ($this->bitmap & self::MASK_WINDOW_ADJUST) ? true : $this->_get_binary_packet(); - } - } - - return $payload; - } - - /** - * Enable Quiet Mode - * - * Suppress stderr from output - * - * @access public - */ - function enableQuietMode() - { - $this->quiet_mode = true; - } - - /** - * Disable Quiet Mode - * - * Show stderr in output - * - * @access public - */ - function disableQuietMode() - { - $this->quiet_mode = false; - } - - /** - * Returns whether Quiet Mode is enabled or not - * - * @see self::enableQuietMode() - * @see self::disableQuietMode() - * @access public - * @return bool - */ - function isQuietModeEnabled() - { - return $this->quiet_mode; - } - - /** - * Enable request-pty when using exec() - * - * @access public - */ - function enablePTY() - { - $this->request_pty = true; - } - - /** - * Disable request-pty when using exec() - * - * @access public - */ - function disablePTY() - { - $this->request_pty = false; - } - - /** - * Returns whether request-pty is enabled or not - * - * @see self::enablePTY() - * @see self::disablePTY() - * @access public - * @return bool - */ - function isPTYEnabled() - { - return $this->request_pty; - } - - /** - * Gets channel data - * - * Returns the data as a string if it's available and false if not. - * - * @param $client_channel - * @return mixed - * @access private - */ - function _get_channel_packet($client_channel, $skip_extended = false) - { - if (!empty($this->channel_buffers[$client_channel])) { - return array_shift($this->channel_buffers[$client_channel]); - } - - while (true) { - if ($this->curTimeout) { - if ($this->curTimeout < 0) { - $this->is_timeout = true; - return true; - } - - $read = array($this->fsock); - $write = $except = null; - - $start = microtime(true); - $sec = floor($this->curTimeout); - $usec = 1000000 * ($this->curTimeout - $sec); - // on windows this returns a "Warning: Invalid CRT parameters detected" error - if (!@stream_select($read, $write, $except, $sec, $usec) && !count($read)) { - $this->is_timeout = true; - return true; - } - $elapsed = microtime(true) - $start; - $this->curTimeout-= $elapsed; - } - - $response = $this->_get_binary_packet(); - if ($response === false) { - user_error('Connection closed by server'); - return false; - } - if ($client_channel == -1 && $response === true) { - return true; - } - if (!strlen($response)) { - return ''; - } - - extract(unpack('Ctype', $this->_string_shift($response, 1))); - - if ($type == NET_SSH2_MSG_CHANNEL_OPEN) { - extract(unpack('Nlength', $this->_string_shift($response, 4))); - } else { - extract(unpack('Nchannel', $this->_string_shift($response, 4))); - } - - // will not be setup yet on incoming channel open request - if (isset($channel) && isset($this->channel_status[$channel]) && isset($this->window_size_server_to_client[$channel])) { - $this->window_size_server_to_client[$channel]-= strlen($response); - - // resize the window, if appropriate - if ($this->window_size_server_to_client[$channel] < 0) { - $packet = pack('CNN', NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST, $this->server_channels[$channel], $this->window_size); - if (!$this->_send_binary_packet($packet)) { - return false; - } - $this->window_size_server_to_client[$channel]+= $this->window_size; - } - - switch ($this->channel_status[$channel]) { - case NET_SSH2_MSG_CHANNEL_OPEN: - switch ($type) { - case NET_SSH2_MSG_CHANNEL_OPEN_CONFIRMATION: - extract(unpack('Nserver_channel', $this->_string_shift($response, 4))); - $this->server_channels[$channel] = $server_channel; - extract(unpack('Nwindow_size', $this->_string_shift($response, 4))); - if ($window_size < 0) { - $window_size&= 0x7FFFFFFF; - $window_size+= 0x80000000; - } - $this->window_size_client_to_server[$channel] = $window_size; - $temp = unpack('Npacket_size_client_to_server', $this->_string_shift($response, 4)); - $this->packet_size_client_to_server[$channel] = $temp['packet_size_client_to_server']; - $result = $client_channel == $channel ? true : $this->_get_channel_packet($client_channel, $skip_extended); - $this->_on_channel_open(); - return $result; - //case NET_SSH2_MSG_CHANNEL_OPEN_FAILURE: - default: - user_error('Unable to open channel'); - return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); - } - break; - case NET_SSH2_MSG_CHANNEL_REQUEST: - switch ($type) { - case NET_SSH2_MSG_CHANNEL_SUCCESS: - return true; - case NET_SSH2_MSG_CHANNEL_FAILURE: - return false; - default: - user_error('Unable to fulfill channel request'); - return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); - } - case NET_SSH2_MSG_CHANNEL_CLOSE: - return $type == NET_SSH2_MSG_CHANNEL_CLOSE ? true : $this->_get_channel_packet($client_channel, $skip_extended); - } - } - - // ie. $this->channel_status[$channel] == NET_SSH2_MSG_CHANNEL_DATA - - switch ($type) { - case NET_SSH2_MSG_CHANNEL_DATA: - /* - if ($channel == self::CHANNEL_EXEC) { - // SCP requires null packets, such as this, be sent. further, in the case of the ssh.com SSH server - // this actually seems to make things twice as fast. more to the point, the message right after - // SSH_MSG_CHANNEL_DATA (usually SSH_MSG_IGNORE) won't block for as long as it would have otherwise. - // in OpenSSH it slows things down but only by a couple thousandths of a second. - $this->_send_channel_packet($channel, chr(0)); - } - */ - extract(unpack('Nlength', $this->_string_shift($response, 4))); - $data = $this->_string_shift($response, $length); - - if ($channel == self::CHANNEL_AGENT_FORWARD) { - $agent_response = $this->agent->_forward_data($data); - if (!is_bool($agent_response)) { - $this->_send_channel_packet($channel, $agent_response); - } - break; - } - - if ($client_channel == $channel) { - return $data; - } - if (!isset($this->channel_buffers[$channel])) { - $this->channel_buffers[$channel] = array(); - } - $this->channel_buffers[$channel][] = $data; - break; - case NET_SSH2_MSG_CHANNEL_EXTENDED_DATA: - /* - if ($client_channel == self::CHANNEL_EXEC) { - $this->_send_channel_packet($client_channel, chr(0)); - } - */ - // currently, there's only one possible value for $data_type_code: NET_SSH2_EXTENDED_DATA_STDERR - extract(unpack('Ndata_type_code/Nlength', $this->_string_shift($response, 8))); - $data = $this->_string_shift($response, $length); - $this->stdErrorLog.= $data; - if ($skip_extended || $this->quiet_mode) { - break; - } - if ($client_channel == $channel) { - return $data; - } - if (!isset($this->channel_buffers[$channel])) { - $this->channel_buffers[$channel] = array(); - } - $this->channel_buffers[$channel][] = $data; - break; - case NET_SSH2_MSG_CHANNEL_REQUEST: - extract(unpack('Nlength', $this->_string_shift($response, 4))); - $value = $this->_string_shift($response, $length); - switch ($value) { - case 'exit-signal': - $this->_string_shift($response, 1); - extract(unpack('Nlength', $this->_string_shift($response, 4))); - $this->errors[] = 'SSH_MSG_CHANNEL_REQUEST (exit-signal): ' . $this->_string_shift($response, $length); - $this->_string_shift($response, 1); - extract(unpack('Nlength', $this->_string_shift($response, 4))); - if ($length) { - $this->errors[count($this->errors)].= "\r\n" . $this->_string_shift($response, $length); - } - - $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_EOF, $this->server_channels[$client_channel])); - $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$channel])); - - $this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_EOF; - - break; - case 'exit-status': - extract(unpack('Cfalse/Nexit_status', $this->_string_shift($response, 5))); - $this->exit_status = $exit_status; - - // "The client MAY ignore these messages." - // -- http://tools.ietf.org/html/rfc4254#section-6.10 - - break; - default: - // "Some systems may not implement signals, in which case they SHOULD ignore this message." - // -- http://tools.ietf.org/html/rfc4254#section-6.9 - break; - } - break; - case NET_SSH2_MSG_CHANNEL_CLOSE: - $this->curTimeout = 0; - - if ($this->bitmap & self::MASK_SHELL) { - $this->bitmap&= ~self::MASK_SHELL; - } - if ($this->channel_status[$channel] != NET_SSH2_MSG_CHANNEL_EOF) { - $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$channel])); - } - - $this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_CLOSE; - return true; - case NET_SSH2_MSG_CHANNEL_EOF: - break; - default: - user_error('Error reading channel data'); - return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); - } - } - } - - /** - * Sends Binary Packets - * - * See '6. Binary Packet Protocol' of rfc4253 for more info. - * - * @param string $data - * @param string $logged - * @see self::_get_binary_packet() - * @return bool - * @access private - */ - function _send_binary_packet($data, $logged = null) - { - if (!is_resource($this->fsock) || feof($this->fsock)) { - user_error('Connection closed prematurely'); - $this->bitmap = 0; - return false; - } - - //if ($this->compress) { - // // the -4 removes the checksum: - // // http://php.net/function.gzcompress#57710 - // $data = substr(gzcompress($data), 0, -4); - //} - - // 4 (packet length) + 1 (padding length) + 4 (minimal padding amount) == 9 - $packet_length = strlen($data) + 9; - // round up to the nearest $this->encrypt_block_size - $packet_length+= (($this->encrypt_block_size - 1) * $packet_length) % $this->encrypt_block_size; - // subtracting strlen($data) is obvious - subtracting 5 is necessary because of packet_length and padding_length - $padding_length = $packet_length - strlen($data) - 5; - $padding = Random::string($padding_length); - - // we subtract 4 from packet_length because the packet_length field isn't supposed to include itself - $packet = pack('NCa*', $packet_length - 4, $padding_length, $data . $padding); - - $hmac = $this->hmac_create !== false ? $this->hmac_create->hash(pack('Na*', $this->send_seq_no, $packet)) : ''; - $this->send_seq_no++; - - if ($this->encrypt !== false) { - $packet = $this->encrypt->encrypt($packet); - } - - $packet.= $hmac; - - $start = microtime(true); - $result = strlen($packet) == fputs($this->fsock, $packet); - $stop = microtime(true); - - if (defined('NET_SSH2_LOGGING')) { - $current = microtime(true); - $message_number = isset($this->message_numbers[ord($data[0])]) ? $this->message_numbers[ord($data[0])] : 'UNKNOWN (' . ord($data[0]) . ')'; - $message_number = '-> ' . $message_number . - ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; - $this->_append_log($message_number, isset($logged) ? $logged : $data); - $this->last_packet = $current; - } - - return $result; - } - - /** - * Logs data packets - * - * Makes sure that only the last 1MB worth of packets will be logged - * - * @param string $data - * @access private - */ - function _append_log($message_number, $message) - { - // remove the byte identifying the message type from all but the first two messages (ie. the identification strings) - if (strlen($message_number) > 2) { - $this->_string_shift($message); - } - - switch (NET_SSH2_LOGGING) { - // useful for benchmarks - case self::LOG_SIMPLE: - $this->message_number_log[] = $message_number; - break; - // the most useful log for SSH2 - case self::LOG_COMPLEX: - $this->message_number_log[] = $message_number; - $this->log_size+= strlen($message); - $this->message_log[] = $message; - while ($this->log_size > self::LOG_MAX_SIZE) { - $this->log_size-= strlen(array_shift($this->message_log)); - array_shift($this->message_number_log); - } - break; - // dump the output out realtime; packets may be interspersed with non packets, - // passwords won't be filtered out and select other packets may not be correctly - // identified - case self::LOG_REALTIME: - switch (PHP_SAPI) { - case 'cli': - $start = $stop = "\r\n"; - break; - default: - $start = '<pre>'; - $stop = '</pre>'; - } - echo $start . $this->_format_log(array($message), array($message_number)) . $stop; - @flush(); - @ob_flush(); - break; - // basically the same thing as self::LOG_REALTIME with the caveat that self::LOG_REALTIME_FILE - // needs to be defined and that the resultant log file will be capped out at self::LOG_MAX_SIZE. - // the earliest part of the log file is denoted by the first <<< START >>> and is not going to necessarily - // at the beginning of the file - case self::LOG_REALTIME_FILE: - if (!isset($this->realtime_log_file)) { - // PHP doesn't seem to like using constants in fopen() - $filename = self::LOG_REALTIME_FILENAME; - $fp = fopen($filename, 'w'); - $this->realtime_log_file = $fp; - } - if (!is_resource($this->realtime_log_file)) { - break; - } - $entry = $this->_format_log(array($message), array($message_number)); - if ($this->realtime_log_wrap) { - $temp = "<<< START >>>\r\n"; - $entry.= $temp; - fseek($this->realtime_log_file, ftell($this->realtime_log_file) - strlen($temp)); - } - $this->realtime_log_size+= strlen($entry); - if ($this->realtime_log_size > self::LOG_MAX_SIZE) { - fseek($this->realtime_log_file, 0); - $this->realtime_log_size = strlen($entry); - $this->realtime_log_wrap = true; - } - fputs($this->realtime_log_file, $entry); - } - } - - /** - * Sends channel data - * - * Spans multiple SSH_MSG_CHANNEL_DATAs if appropriate - * - * @param int $client_channel - * @param string $data - * @return bool - * @access private - */ - function _send_channel_packet($client_channel, $data) - { - while (strlen($data)) { - if (!$this->window_size_client_to_server[$client_channel]) { - $this->bitmap^= self::MASK_WINDOW_ADJUST; - // using an invalid channel will let the buffers be built up for the valid channels - $this->_get_channel_packet(-1); - $this->bitmap^= self::MASK_WINDOW_ADJUST; - } - - /* The maximum amount of data allowed is determined by the maximum - packet size for the channel, and the current window size, whichever - is smaller. - -- http://tools.ietf.org/html/rfc4254#section-5.2 */ - $max_size = min( - $this->packet_size_client_to_server[$client_channel], - $this->window_size_client_to_server[$client_channel] - ); - - $temp = $this->_string_shift($data, $max_size); - $packet = pack( - 'CN2a*', - NET_SSH2_MSG_CHANNEL_DATA, - $this->server_channels[$client_channel], - strlen($temp), - $temp - ); - $this->window_size_client_to_server[$client_channel]-= strlen($temp); - if (!$this->_send_binary_packet($packet)) { - return false; - } - } - - return true; - } - - /** - * Closes and flushes a channel - * - * \phpseclib\Net\SSH2 doesn't properly close most channels. For exec() channels are normally closed by the server - * and for SFTP channels are presumably closed when the client disconnects. This functions is intended - * for SCP more than anything. - * - * @param int $client_channel - * @param bool $want_reply - * @return bool - * @access private - */ - function _close_channel($client_channel, $want_reply = false) - { - // see http://tools.ietf.org/html/rfc4254#section-5.3 - - $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_EOF, $this->server_channels[$client_channel])); - - if (!$want_reply) { - $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$client_channel])); - } - - $this->channel_status[$client_channel] = NET_SSH2_MSG_CHANNEL_CLOSE; - - $this->curTimeout = 0; - - while (!is_bool($this->_get_channel_packet($client_channel))) { - } - - if ($want_reply) { - $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$client_channel])); - } - - if ($this->bitmap & self::MASK_SHELL) { - $this->bitmap&= ~self::MASK_SHELL; - } - } - - /** - * Disconnect - * - * @param int $reason - * @return bool - * @access private - */ - function _disconnect($reason) - { - if ($this->bitmap & self::MASK_CONNECTED) { - $data = pack('CNNa*Na*', NET_SSH2_MSG_DISCONNECT, $reason, 0, '', 0, ''); - $this->_send_binary_packet($data); - $this->bitmap = 0; - fclose($this->fsock); - return false; - } - } - - /** - * String Shift - * - * Inspired by array_shift - * - * @param string $string - * @param int $index - * @return string - * @access private - */ - function _string_shift(&$string, $index = 1) - { - $substr = substr($string, 0, $index); - $string = substr($string, $index); - return $substr; - } - - /** - * Define Array - * - * Takes any number of arrays whose indices are integers and whose values are strings and defines a bunch of - * named constants from it, using the value as the name of the constant and the index as the value of the constant. - * If any of the constants that would be defined already exists, none of the constants will be defined. - * - * @param array $array - * @access private - */ - function _define_array() - { - $args = func_get_args(); - foreach ($args as $arg) { - foreach ($arg as $key => $value) { - if (!defined($value)) { - define($value, $key); - } else { - break 2; - } - } - } - } - - /** - * Returns a log of the packets that have been sent and received. - * - * Returns a string if NET_SSH2_LOGGING == self::LOG_COMPLEX, an array if NET_SSH2_LOGGING == self::LOG_SIMPLE and false if !defined('NET_SSH2_LOGGING') - * - * @access public - * @return array|false|string - */ - function getLog() - { - if (!defined('NET_SSH2_LOGGING')) { - return false; - } - - switch (NET_SSH2_LOGGING) { - case self::LOG_SIMPLE: - return $this->message_number_log; - break; - case self::LOG_COMPLEX: - return $this->_format_log($this->message_log, $this->message_number_log); - break; - default: - return false; - } - } - - /** - * Formats a log for printing - * - * @param array $message_log - * @param array $message_number_log - * @access private - * @return string - */ - function _format_log($message_log, $message_number_log) - { - $output = ''; - for ($i = 0; $i < count($message_log); $i++) { - $output.= $message_number_log[$i] . "\r\n"; - $current_log = $message_log[$i]; - $j = 0; - do { - if (strlen($current_log)) { - $output.= str_pad(dechex($j), 7, '0', STR_PAD_LEFT) . '0 '; - } - $fragment = $this->_string_shift($current_log, $this->log_short_width); - $hex = substr(preg_replace_callback('#.#s', array($this, '_format_log_helper'), $fragment), strlen($this->log_boundary)); - // replace non ASCII printable characters with dots - // http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters - // also replace < with a . since < messes up the output on web browsers - $raw = preg_replace('#[^\x20-\x7E]|<#', '.', $fragment); - $output.= str_pad($hex, $this->log_long_width - $this->log_short_width, ' ') . $raw . "\r\n"; - $j++; - } while (strlen($current_log)); - $output.= "\r\n"; - } - - return $output; - } - - /** - * Helper function for _format_log - * - * For use with preg_replace_callback() - * - * @param array $matches - * @access private - * @return string - */ - function _format_log_helper($matches) - { - return $this->log_boundary . str_pad(dechex(ord($matches[0])), 2, '0', STR_PAD_LEFT); - } - - /** - * Helper function for agent->_on_channel_open() - * - * Used when channels are created to inform agent - * of said channel opening. Must be called after - * channel open confirmation received - * - * @access private - */ - function _on_channel_open() - { - if (isset($this->agent)) { - $this->agent->_on_channel_open($this); - } - } - - /** - * Returns the first value of the intersection of two arrays or false if - * the intersection is empty. The order is defined by the first parameter. - * - * @param array $array1 - * @param array $array2 - * @return mixed False if intersection is empty, else intersected value. - * @access private - */ - function _array_intersect_first($array1, $array2) - { - foreach ($array1 as $value) { - if (in_array($value, $array2)) { - return $value; - } - } - return false; - } - - /** - * Returns all errors - * - * @return string - * @access public - */ - function getErrors() - { - return $this->errors; - } - - /** - * Returns the last error - * - * @return string - * @access public - */ - function getLastError() - { - $count = count($this->errors); - - if ($count > 0) { - return $this->errors[$count - 1]; - } - } - - /** - * Return the server identification. - * - * @return string - * @access public - */ - function getServerIdentification() - { - $this->_connect(); - - return $this->server_identifier; - } - - /** - * Return a list of the key exchange algorithms the server supports. - * - * @return array - * @access public - */ - function getKexAlgorithms() - { - $this->_connect(); - - return $this->kex_algorithms; - } - - /** - * Return a list of the host key (public key) algorithms the server supports. - * - * @return array - * @access public - */ - function getServerHostKeyAlgorithms() - { - $this->_connect(); - - return $this->server_host_key_algorithms; - } - - /** - * Return a list of the (symmetric key) encryption algorithms the server supports, when receiving stuff from the client. - * - * @return array - * @access public - */ - function getEncryptionAlgorithmsClient2Server() - { - $this->_connect(); - - return $this->encryption_algorithms_client_to_server; - } - - /** - * Return a list of the (symmetric key) encryption algorithms the server supports, when sending stuff to the client. - * - * @return array - * @access public - */ - function getEncryptionAlgorithmsServer2Client() - { - $this->_connect(); - - return $this->encryption_algorithms_server_to_client; - } - - /** - * Return a list of the MAC algorithms the server supports, when receiving stuff from the client. - * - * @return array - * @access public - */ - function getMACAlgorithmsClient2Server() - { - $this->_connect(); - - return $this->mac_algorithms_client_to_server; - } - - /** - * Return a list of the MAC algorithms the server supports, when sending stuff to the client. - * - * @return array - * @access public - */ - function getMACAlgorithmsServer2Client() - { - $this->_connect(); - - return $this->mac_algorithms_server_to_client; - } - - /** - * Return a list of the compression algorithms the server supports, when receiving stuff from the client. - * - * @return array - * @access public - */ - function getCompressionAlgorithmsClient2Server() - { - $this->_connect(); - - return $this->compression_algorithms_client_to_server; - } - - /** - * Return a list of the compression algorithms the server supports, when sending stuff to the client. - * - * @return array - * @access public - */ - function getCompressionAlgorithmsServer2Client() - { - $this->_connect(); - - return $this->compression_algorithms_server_to_client; - } - - /** - * Return a list of the languages the server supports, when sending stuff to the client. - * - * @return array - * @access public - */ - function getLanguagesServer2Client() - { - $this->_connect(); - - return $this->languages_server_to_client; - } - - /** - * Return a list of the languages the server supports, when receiving stuff from the client. - * - * @return array - * @access public - */ - function getLanguagesClient2Server() - { - $this->_connect(); - - return $this->languages_client_to_server; - } - - /** - * Returns the banner message. - * - * Quoting from the RFC, "in some jurisdictions, sending a warning message before - * authentication may be relevant for getting legal protection." - * - * @return string - * @access public - */ - function getBannerMessage() - { - return $this->banner_message; - } - - /** - * Returns the server public host key. - * - * Caching this the first time you connect to a server and checking the result on subsequent connections - * is recommended. Returns false if the server signature is not signed correctly with the public host key. - * - * @return mixed - * @access public - */ - function getServerPublicHostKey() - { - if (!($this->bitmap & self::MASK_CONSTRUCTOR)) { - if (!$this->_connect()) { - return false; - } - } - - $signature = $this->signature; - $server_public_host_key = $this->server_public_host_key; - - extract(unpack('Nlength', $this->_string_shift($server_public_host_key, 4))); - $this->_string_shift($server_public_host_key, $length); - - if ($this->signature_validated) { - return $this->bitmap ? - $this->signature_format . ' ' . base64_encode($this->server_public_host_key) : - false; - } - - $this->signature_validated = true; - - switch ($this->signature_format) { - case 'ssh-dss': - $zero = new BigInteger(); - - $temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4)); - $p = new BigInteger($this->_string_shift($server_public_host_key, $temp['length']), -256); - - $temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4)); - $q = new BigInteger($this->_string_shift($server_public_host_key, $temp['length']), -256); - - $temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4)); - $g = new BigInteger($this->_string_shift($server_public_host_key, $temp['length']), -256); - - $temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4)); - $y = new BigInteger($this->_string_shift($server_public_host_key, $temp['length']), -256); - - /* The value for 'dss_signature_blob' is encoded as a string containing - r, followed by s (which are 160-bit integers, without lengths or - padding, unsigned, and in network byte order). */ - $temp = unpack('Nlength', $this->_string_shift($signature, 4)); - if ($temp['length'] != 40) { - user_error('Invalid signature'); - return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); - } - - $r = new BigInteger($this->_string_shift($signature, 20), 256); - $s = new BigInteger($this->_string_shift($signature, 20), 256); - - switch (true) { - case $r->equals($zero): - case $r->compare($q) >= 0: - case $s->equals($zero): - case $s->compare($q) >= 0: - user_error('Invalid signature'); - return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); - } - - $w = $s->modInverse($q); - - $u1 = $w->multiply(new BigInteger(sha1($this->exchange_hash), 16)); - list(, $u1) = $u1->divide($q); - - $u2 = $w->multiply($r); - list(, $u2) = $u2->divide($q); - - $g = $g->modPow($u1, $p); - $y = $y->modPow($u2, $p); - - $v = $g->multiply($y); - list(, $v) = $v->divide($p); - list(, $v) = $v->divide($q); - - if (!$v->equals($r)) { - user_error('Bad server signature'); - return $this->_disconnect(NET_SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE); - } - - break; - case 'ssh-rsa': - $temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4)); - $e = new BigInteger($this->_string_shift($server_public_host_key, $temp['length']), -256); - - $temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4)); - $rawN = $this->_string_shift($server_public_host_key, $temp['length']); - $n = new BigInteger($rawN, -256); - $nLength = strlen(ltrim($rawN, "\0")); - - /* - $temp = unpack('Nlength', $this->_string_shift($signature, 4)); - $signature = $this->_string_shift($signature, $temp['length']); - - $rsa = new RSA(); - $rsa->setSignatureMode(RSA::SIGNATURE_PKCS1); - $rsa->loadKey(array('e' => $e, 'n' => $n), RSA::PUBLIC_FORMAT_RAW); - if (!$rsa->verify($this->exchange_hash, $signature)) { - user_error('Bad server signature'); - return $this->_disconnect(NET_SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE); - } - */ - - $temp = unpack('Nlength', $this->_string_shift($signature, 4)); - $s = new BigInteger($this->_string_shift($signature, $temp['length']), 256); - - // validate an RSA signature per "8.2 RSASSA-PKCS1-v1_5", "5.2.2 RSAVP1", and "9.1 EMSA-PSS" in the - // following URL: - // ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1.pdf - - // also, see SSHRSA.c (rsa2_verifysig) in PuTTy's source. - - if ($s->compare(new BigInteger()) < 0 || $s->compare($n->subtract(new BigInteger(1))) > 0) { - user_error('Invalid signature'); - return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); - } - - $s = $s->modPow($e, $n); - $s = $s->toBytes(); - - $h = pack('N4H*', 0x00302130, 0x0906052B, 0x0E03021A, 0x05000414, sha1($this->exchange_hash)); - $h = chr(0x01) . str_repeat(chr(0xFF), $nLength - 2 - strlen($h)) . $h; - - if ($s != $h) { - user_error('Bad server signature'); - return $this->_disconnect(NET_SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE); - } - break; - default: - user_error('Unsupported signature format'); - return $this->_disconnect(NET_SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE); - } - - return $this->signature_format . ' ' . base64_encode($this->server_public_host_key); - } - - /** - * Returns the exit status of an SSH command or false. - * - * @return false|int - * @access public - */ - function getExitStatus() - { - if (is_null($this->exit_status)) { - return false; - } - return $this->exit_status; - } - - /** - * Returns the number of columns for the terminal window size. - * - * @return int - * @access public - */ - function getWindowColumns() - { - return $this->windowColumns; - } - - /** - * Returns the number of rows for the terminal window size. - * - * @return int - * @access public - */ - function getWindowRows() - { - return $this->windowRows; - } - - /** - * Sets the number of columns for the terminal window size. - * - * @param int $value - * @access public - */ - function setWindowColumns($value) - { - $this->windowColumns = $value; - } - - /** - * Sets the number of rows for the terminal window size. - * - * @param int $value - * @access public - */ - function setWindowRows($value) - { - $this->windowRows = $value; - } - - /** - * Sets the number of columns and rows for the terminal window size. - * - * @param int $columns - * @param int $rows - * @access public - */ - function setWindowSize($columns = 80, $rows = 24) - { - $this->windowColumns = $columns; - $this->windowRows = $rows; - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/System/SSH/Agent.php b/vendor/phpseclib/phpseclib/phpseclib/System/SSH/Agent.php deleted file mode 100755 index ae465377fdc76e3d0130271af64bcce13173c941..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/System/SSH/Agent.php +++ /dev/null @@ -1,307 +0,0 @@ -<?php - -/** - * Pure-PHP ssh-agent client. - * - * PHP version 5 - * - * Here are some examples of how to use this library: - * <code> - * <?php - * include 'vendor/autoload.php'; - * - * $agent = new \phpseclib\System\SSH\Agent(); - * - * $ssh = new \phpseclib\Net\SSH2('www.domain.tld'); - * if (!$ssh->login('username', $agent)) { - * exit('Login Failed'); - * } - * - * echo $ssh->exec('pwd'); - * echo $ssh->exec('ls -la'); - * ?> - * </code> - * - * @category System - * @package SSH\Agent - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2014 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - * @internal See http://api.libssh.org/rfc/PROTOCOL.agent - */ - -namespace phpseclib\System\SSH; - -use phpseclib\Crypt\RSA; -use phpseclib\System\SSH\Agent\Identity; - -/** - * Pure-PHP ssh-agent client identity factory - * - * requestIdentities() method pumps out \phpseclib\System\SSH\Agent\Identity objects - * - * @package SSH\Agent - * @author Jim Wigginton <terrafrost@php.net> - * @access internal - */ -class Agent -{ - /**#@+ - * Message numbers - * - * @access private - */ - // to request SSH1 keys you have to use SSH_AGENTC_REQUEST_RSA_IDENTITIES (1) - const SSH_AGENTC_REQUEST_IDENTITIES = 11; - // this is the SSH2 response; the SSH1 response is SSH_AGENT_RSA_IDENTITIES_ANSWER (2). - const SSH_AGENT_IDENTITIES_ANSWER = 12; - // the SSH1 request is SSH_AGENTC_RSA_CHALLENGE (3) - const SSH_AGENTC_SIGN_REQUEST = 13; - // the SSH1 response is SSH_AGENT_RSA_RESPONSE (4) - const SSH_AGENT_SIGN_RESPONSE = 14; - /**#@-*/ - - /**@+ - * Agent forwarding status - * - * @access private - */ - // no forwarding requested and not active - const FORWARD_NONE = 0; - // request agent forwarding when opportune - const FORWARD_REQUEST = 1; - // forwarding has been request and is active - const FORWARD_ACTIVE = 2; - /**#@-*/ - - /** - * Unused - */ - const SSH_AGENT_FAILURE = 5; - - /** - * Socket Resource - * - * @var resource - * @access private - */ - var $fsock; - - /** - * Agent forwarding status - * - * @access private - */ - var $forward_status = self::FORWARD_NONE; - - /** - * Buffer for accumulating forwarded authentication - * agent data arriving on SSH data channel destined - * for agent unix socket - * - * @access private - */ - var $socket_buffer = ''; - - /** - * Tracking the number of bytes we are expecting - * to arrive for the agent socket on the SSH data - * channel - */ - var $expected_bytes = 0; - - /** - * Default Constructor - * - * @return \phpseclib\System\SSH\Agent - * @access public - */ - function __construct() - { - switch (true) { - case isset($_SERVER['SSH_AUTH_SOCK']): - $address = $_SERVER['SSH_AUTH_SOCK']; - break; - case isset($_ENV['SSH_AUTH_SOCK']): - $address = $_ENV['SSH_AUTH_SOCK']; - break; - default: - user_error('SSH_AUTH_SOCK not found'); - return false; - } - - $this->fsock = fsockopen('unix://' . $address, 0, $errno, $errstr); - if (!$this->fsock) { - user_error("Unable to connect to ssh-agent (Error $errno: $errstr)"); - } - } - - /** - * Request Identities - * - * See "2.5.2 Requesting a list of protocol 2 keys" - * Returns an array containing zero or more \phpseclib\System\SSH\Agent\Identity objects - * - * @return array - * @access public - */ - function requestIdentities() - { - if (!$this->fsock) { - return array(); - } - - $packet = pack('NC', 1, self::SSH_AGENTC_REQUEST_IDENTITIES); - if (strlen($packet) != fputs($this->fsock, $packet)) { - user_error('Connection closed while requesting identities'); - } - - $length = current(unpack('N', fread($this->fsock, 4))); - $type = ord(fread($this->fsock, 1)); - if ($type != self::SSH_AGENT_IDENTITIES_ANSWER) { - user_error('Unable to request identities'); - } - - $identities = array(); - $keyCount = current(unpack('N', fread($this->fsock, 4))); - for ($i = 0; $i < $keyCount; $i++) { - $length = current(unpack('N', fread($this->fsock, 4))); - $key_blob = fread($this->fsock, $length); - $length = current(unpack('N', fread($this->fsock, 4))); - if ($length) { - $key_comment = fread($this->fsock, $length); - } - $length = current(unpack('N', substr($key_blob, 0, 4))); - $key_type = substr($key_blob, 4, $length); - switch ($key_type) { - case 'ssh-rsa': - $key = new RSA(); - $key->loadKey('ssh-rsa ' . base64_encode($key_blob) . ' ' . $key_comment); - break; - case 'ssh-dss': - // not currently supported - break; - } - // resources are passed by reference by default - if (isset($key)) { - $identity = new Identity($this->fsock); - $identity->setPublicKey($key); - $identity->setPublicKeyBlob($key_blob); - $identities[] = $identity; - unset($key); - } - } - - return $identities; - } - - /** - * Signal that agent forwarding should - * be requested when a channel is opened - * - * @param Net_SSH2 $ssh - * @return bool - * @access public - */ - function startSSHForwarding($ssh) - { - if ($this->forward_status == self::FORWARD_NONE) { - $this->forward_status = self::FORWARD_REQUEST; - } - } - - /** - * Request agent forwarding of remote server - * - * @param Net_SSH2 $ssh - * @return bool - * @access private - */ - function _request_forwarding($ssh) - { - $request_channel = $ssh->_get_open_channel(); - if ($request_channel === false) { - return false; - } - - $packet = pack( - 'CNNa*C', - NET_SSH2_MSG_CHANNEL_REQUEST, - $ssh->server_channels[$request_channel], - strlen('auth-agent-req@openssh.com'), - 'auth-agent-req@openssh.com', - 1 - ); - - $ssh->channel_status[$request_channel] = NET_SSH2_MSG_CHANNEL_REQUEST; - - if (!$ssh->_send_binary_packet($packet)) { - return false; - } - - $response = $ssh->_get_channel_packet($request_channel); - if ($response === false) { - return false; - } - - $ssh->channel_status[$request_channel] = NET_SSH2_MSG_CHANNEL_OPEN; - $this->forward_status = self::FORWARD_ACTIVE; - - return true; - } - - /** - * On successful channel open - * - * This method is called upon successful channel - * open to give the SSH Agent an opportunity - * to take further action. i.e. request agent forwarding - * - * @param Net_SSH2 $ssh - * @access private - */ - function _on_channel_open($ssh) - { - if ($this->forward_status == self::FORWARD_REQUEST) { - $this->_request_forwarding($ssh); - } - } - - /** - * Forward data to SSH Agent and return data reply - * - * @param string $data - * @return data from SSH Agent - * @access private - */ - function _forward_data($data) - { - if ($this->expected_bytes > 0) { - $this->socket_buffer.= $data; - $this->expected_bytes -= strlen($data); - } else { - $agent_data_bytes = current(unpack('N', $data)); - $current_data_bytes = strlen($data); - $this->socket_buffer = $data; - if ($current_data_bytes != $agent_data_bytes + 4) { - $this->expected_bytes = ($agent_data_bytes + 4) - $current_data_bytes; - return false; - } - } - - if (strlen($this->socket_buffer) != fwrite($this->fsock, $this->socket_buffer)) { - user_error('Connection closed attempting to forward data to SSH agent'); - } - - $this->socket_buffer = ''; - $this->expected_bytes = 0; - - $agent_reply_bytes = current(unpack('N', fread($this->fsock, 4))); - - $agent_reply_data = fread($this->fsock, $agent_reply_bytes); - $agent_reply_data = current(unpack('a*', $agent_reply_data)); - - return pack('Na*', $agent_reply_bytes, $agent_reply_data); - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/System/SSH/Agent/Identity.php b/vendor/phpseclib/phpseclib/phpseclib/System/SSH/Agent/Identity.php deleted file mode 100755 index 790b267c156574b4765fffb530bc73626085838b..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/System/SSH/Agent/Identity.php +++ /dev/null @@ -1,159 +0,0 @@ -<?php -/** - * Pure-PHP ssh-agent client. - * - * PHP version 5 - * - * @category System - * @package SSH\Agent - * @author Jim Wigginton <terrafrost@php.net> - * @copyright 2009 Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net - * @internal See http://api.libssh.org/rfc/PROTOCOL.agent - */ - -namespace phpseclib\System\SSH\Agent; - -use phpseclib\System\SSH\Agent; - -/** - * Pure-PHP ssh-agent client identity object - * - * Instantiation should only be performed by \phpseclib\System\SSH\Agent class. - * This could be thought of as implementing an interface that phpseclib\Crypt\RSA - * implements. ie. maybe a Net_SSH_Auth_PublicKey interface or something. - * The methods in this interface would be getPublicKey, setSignatureMode - * and sign since those are the methods phpseclib looks for to perform - * public key authentication. - * - * @package SSH\Agent - * @author Jim Wigginton <terrafrost@php.net> - * @access internal - */ -class Identity -{ - /** - * Key Object - * - * @var \phpseclib\Crypt\RSA - * @access private - * @see self::getPublicKey() - */ - var $key; - - /** - * Key Blob - * - * @var string - * @access private - * @see self::sign() - */ - var $key_blob; - - /** - * Socket Resource - * - * @var resource - * @access private - * @see self::sign() - */ - var $fsock; - - /** - * Default Constructor. - * - * @param resource $fsock - * @return \phpseclib\System\SSH\Agent\Identity - * @access private - */ - function __construct($fsock) - { - $this->fsock = $fsock; - } - - /** - * Set Public Key - * - * Called by \phpseclib\System\SSH\Agent::requestIdentities() - * - * @param \phpseclib\Crypt\RSA $key - * @access private - */ - function setPublicKey($key) - { - $this->key = $key; - $this->key->setPublicKey(); - } - - /** - * Set Public Key - * - * Called by \phpseclib\System\SSH\Agent::requestIdentities(). The key blob could be extracted from $this->key - * but this saves a small amount of computation. - * - * @param string $key_blob - * @access private - */ - function setPublicKeyBlob($key_blob) - { - $this->key_blob = $key_blob; - } - - /** - * Get Public Key - * - * Wrapper for $this->key->getPublicKey() - * - * @param int $format optional - * @return mixed - * @access public - */ - function getPublicKey($format = null) - { - return !isset($format) ? $this->key->getPublicKey() : $this->key->getPublicKey($format); - } - - /** - * Set Signature Mode - * - * Doesn't do anything as ssh-agent doesn't let you pick and choose the signature mode. ie. - * ssh-agent's only supported mode is \phpseclib\Crypt\RSA::SIGNATURE_PKCS1 - * - * @param int $mode - * @access public - */ - function setSignatureMode($mode) - { - } - - /** - * Create a signature - * - * See "2.6.2 Protocol 2 private key signature request" - * - * @param string $message - * @return string - * @access public - */ - function sign($message) - { - // the last parameter (currently 0) is for flags and ssh-agent only defines one flag (for ssh-dss): SSH_AGENT_OLD_SIGNATURE - $packet = pack('CNa*Na*N', Agent::SSH_AGENTC_SIGN_REQUEST, strlen($this->key_blob), $this->key_blob, strlen($message), $message, 0); - $packet = pack('Na*', strlen($packet), $packet); - if (strlen($packet) != fputs($this->fsock, $packet)) { - user_error('Connection closed during signing'); - } - - $length = current(unpack('N', fread($this->fsock, 4))); - $type = ord(fread($this->fsock, 1)); - if ($type != Agent::SSH_AGENT_SIGN_RESPONSE) { - user_error('Unable to retreive signature'); - } - - $signature_blob = fread($this->fsock, $length - 1); - // the only other signature format defined - ssh-dss - is the same length as ssh-rsa - // the + 12 is for the other various SSH added length fields - return substr($signature_blob, strlen('ssh-rsa') + 12); - } -} diff --git a/vendor/phpseclib/phpseclib/phpseclib/openssl.cnf b/vendor/phpseclib/phpseclib/phpseclib/openssl.cnf deleted file mode 100755 index 2b8b52f9f7fc75fa8a7e0f6244712fb523adedc1..0000000000000000000000000000000000000000 --- a/vendor/phpseclib/phpseclib/phpseclib/openssl.cnf +++ /dev/null @@ -1,6 +0,0 @@ -# minimalist openssl.cnf file for use with phpseclib - -HOME = . -RANDFILE = $ENV::HOME/.rnd - -[ v3_ca ] diff --git a/vendor/pimple/pimple/.gitignore b/vendor/pimple/pimple/.gitignore old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/.travis.yml b/vendor/pimple/pimple/.travis.yml old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/CHANGELOG b/vendor/pimple/pimple/CHANGELOG old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/LICENSE b/vendor/pimple/pimple/LICENSE old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/README.rst b/vendor/pimple/pimple/README.rst old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/composer.json b/vendor/pimple/pimple/composer.json old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/.gitignore b/vendor/pimple/pimple/ext/pimple/.gitignore old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/README.md b/vendor/pimple/pimple/ext/pimple/README.md old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/config.m4 b/vendor/pimple/pimple/ext/pimple/config.m4 old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/config.w32 b/vendor/pimple/pimple/ext/pimple/config.w32 old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/php_pimple.h b/vendor/pimple/pimple/ext/pimple/php_pimple.h old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/pimple.c b/vendor/pimple/pimple/ext/pimple/pimple.c old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/pimple_compat.h b/vendor/pimple/pimple/ext/pimple/pimple_compat.h old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/001.phpt b/vendor/pimple/pimple/ext/pimple/tests/001.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/002.phpt b/vendor/pimple/pimple/ext/pimple/tests/002.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/003.phpt b/vendor/pimple/pimple/ext/pimple/tests/003.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/004.phpt b/vendor/pimple/pimple/ext/pimple/tests/004.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/005.phpt b/vendor/pimple/pimple/ext/pimple/tests/005.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/006.phpt b/vendor/pimple/pimple/ext/pimple/tests/006.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/007.phpt b/vendor/pimple/pimple/ext/pimple/tests/007.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/008.phpt b/vendor/pimple/pimple/ext/pimple/tests/008.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/009.phpt b/vendor/pimple/pimple/ext/pimple/tests/009.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/010.phpt b/vendor/pimple/pimple/ext/pimple/tests/010.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/011.phpt b/vendor/pimple/pimple/ext/pimple/tests/011.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/012.phpt b/vendor/pimple/pimple/ext/pimple/tests/012.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/013.phpt b/vendor/pimple/pimple/ext/pimple/tests/013.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/014.phpt b/vendor/pimple/pimple/ext/pimple/tests/014.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/015.phpt b/vendor/pimple/pimple/ext/pimple/tests/015.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/016.phpt b/vendor/pimple/pimple/ext/pimple/tests/016.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/017.phpt b/vendor/pimple/pimple/ext/pimple/tests/017.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/017_1.phpt b/vendor/pimple/pimple/ext/pimple/tests/017_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/018.phpt b/vendor/pimple/pimple/ext/pimple/tests/018.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/019.phpt b/vendor/pimple/pimple/ext/pimple/tests/019.phpt old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/bench.phpb b/vendor/pimple/pimple/ext/pimple/tests/bench.phpb old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/ext/pimple/tests/bench_shared.phpb b/vendor/pimple/pimple/ext/pimple/tests/bench_shared.phpb old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/phpunit.xml.dist b/vendor/pimple/pimple/phpunit.xml.dist old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/Container.php b/vendor/pimple/pimple/src/Pimple/Container.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/Exception/ExpectedInvokableException.php b/vendor/pimple/pimple/src/Pimple/Exception/ExpectedInvokableException.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/Exception/FrozenServiceException.php b/vendor/pimple/pimple/src/Pimple/Exception/FrozenServiceException.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/Exception/InvalidServiceIdentifierException.php b/vendor/pimple/pimple/src/Pimple/Exception/InvalidServiceIdentifierException.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/Exception/UnknownIdentifierException.php b/vendor/pimple/pimple/src/Pimple/Exception/UnknownIdentifierException.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/Psr11/Container.php b/vendor/pimple/pimple/src/Pimple/Psr11/Container.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/Psr11/ServiceLocator.php b/vendor/pimple/pimple/src/Pimple/Psr11/ServiceLocator.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/ServiceIterator.php b/vendor/pimple/pimple/src/Pimple/ServiceIterator.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/ServiceProviderInterface.php b/vendor/pimple/pimple/src/Pimple/ServiceProviderInterface.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/Invokable.php b/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/Invokable.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/NonInvokable.php b/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/NonInvokable.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/PimpleServiceProvider.php b/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/PimpleServiceProvider.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/Service.php b/vendor/pimple/pimple/src/Pimple/Tests/Fixtures/Service.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/Tests/PimpleServiceProviderInterfaceTest.php b/vendor/pimple/pimple/src/Pimple/Tests/PimpleServiceProviderInterfaceTest.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/Tests/PimpleTest.php b/vendor/pimple/pimple/src/Pimple/Tests/PimpleTest.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/Tests/Psr11/ContainerTest.php b/vendor/pimple/pimple/src/Pimple/Tests/Psr11/ContainerTest.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/Tests/Psr11/ServiceLocatorTest.php b/vendor/pimple/pimple/src/Pimple/Tests/Psr11/ServiceLocatorTest.php old mode 100755 new mode 100644 diff --git a/vendor/pimple/pimple/src/Pimple/Tests/ServiceIteratorTest.php b/vendor/pimple/pimple/src/Pimple/Tests/ServiceIteratorTest.php old mode 100755 new mode 100644 diff --git a/vendor/psr/container/.gitignore b/vendor/psr/container/.gitignore old mode 100755 new mode 100644 diff --git a/vendor/psr/container/LICENSE b/vendor/psr/container/LICENSE old mode 100755 new mode 100644 diff --git a/vendor/psr/container/README.md b/vendor/psr/container/README.md old mode 100755 new mode 100644 diff --git a/vendor/psr/container/composer.json b/vendor/psr/container/composer.json old mode 100755 new mode 100644 diff --git a/vendor/psr/container/src/ContainerExceptionInterface.php b/vendor/psr/container/src/ContainerExceptionInterface.php old mode 100755 new mode 100644 diff --git a/vendor/psr/container/src/ContainerInterface.php b/vendor/psr/container/src/ContainerInterface.php old mode 100755 new mode 100644 diff --git a/vendor/psr/container/src/NotFoundExceptionInterface.php b/vendor/psr/container/src/NotFoundExceptionInterface.php old mode 100755 new mode 100644 diff --git a/vendor/psr/http-message/CHANGELOG.md b/vendor/psr/http-message/CHANGELOG.md old mode 100755 new mode 100644 diff --git a/vendor/psr/http-message/LICENSE b/vendor/psr/http-message/LICENSE old mode 100755 new mode 100644 diff --git a/vendor/psr/http-message/README.md b/vendor/psr/http-message/README.md old mode 100755 new mode 100644 diff --git a/vendor/psr/http-message/composer.json b/vendor/psr/http-message/composer.json old mode 100755 new mode 100644 diff --git a/vendor/psr/http-message/src/MessageInterface.php b/vendor/psr/http-message/src/MessageInterface.php old mode 100755 new mode 100644 diff --git a/vendor/psr/http-message/src/RequestInterface.php b/vendor/psr/http-message/src/RequestInterface.php old mode 100755 new mode 100644 diff --git a/vendor/psr/http-message/src/ResponseInterface.php b/vendor/psr/http-message/src/ResponseInterface.php old mode 100755 new mode 100644 diff --git a/vendor/psr/http-message/src/ServerRequestInterface.php b/vendor/psr/http-message/src/ServerRequestInterface.php old mode 100755 new mode 100644 diff --git a/vendor/psr/http-message/src/StreamInterface.php b/vendor/psr/http-message/src/StreamInterface.php old mode 100755 new mode 100644 diff --git a/vendor/psr/http-message/src/UploadedFileInterface.php b/vendor/psr/http-message/src/UploadedFileInterface.php old mode 100755 new mode 100644 diff --git a/vendor/psr/http-message/src/UriInterface.php b/vendor/psr/http-message/src/UriInterface.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/.gitignore b/vendor/respect/validation/.gitignore old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/.php_cs b/vendor/respect/validation/.php_cs old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/.scrutinizer.yml b/vendor/respect/validation/.scrutinizer.yml old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/.travis.yml b/vendor/respect/validation/.travis.yml old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/CHANGELOG.md b/vendor/respect/validation/CHANGELOG.md old mode 100755 new mode 100644 index 941c175275c29be86ef6e6bd5559517e356dee85..6354b8158eac4e33b02d8d349d077abbdd5f9f4e --- a/vendor/respect/validation/CHANGELOG.md +++ b/vendor/respect/validation/CHANGELOG.md @@ -101,8 +101,6 @@ All notable changes of the Respect\Validation releases are documented in this fi *** See also: +- [README](README.md) - [Contributing](CONTRIBUTING.md) -- [Feature Guide](docs/README.md) -- [Installation](docs/INSTALL.md) - [License](LICENSE.md) -- [Validators](docs/VALIDATORS.md) diff --git a/vendor/respect/validation/CONTRIBUTING.md b/vendor/respect/validation/CONTRIBUTING.md old mode 100755 new mode 100644 index ca3b13191dd70e6315f37aa1d38741daf1129921..e36bf0f8adb2678f79e7b511a661af2a7918ddce --- a/vendor/respect/validation/CONTRIBUTING.md +++ b/vendor/respect/validation/CONTRIBUTING.md @@ -179,8 +179,8 @@ As we already said, none of them are required but you will help us a lot. ## Documentation Our docs at http://respect.github.io/Validation are generated from our Markdown -files using [Couscous][]. Add your brand new rule there and everything will be -updated as soon as possible. +files using [Read the Docs][]. Add your brand new rule there and everything will +be updated automatically. ## Running Tests @@ -234,15 +234,13 @@ $ vendor/bin/php-cs-fixer fix *** See also: -- [Feature Guide](docs/README.md) -- [Installation](docs/INSTALL.md) +- [README](README.md) - [License](LICENSE.md) -- [Validators](docs/VALIDATORS.md) - [Changelog](CHANGELOG.md) [ArrayType]: https://github.com/Respect/Validation/commit/f08a1fa -[Couscous]: http://couscous.io/ "Couscous" +[Read the Docs]: https://readthedocs.org/ "Read the Docs" [data provider]: https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers "PHPUnit Data Providers" [open an issue]: http://github.com/Respect/Validation/issues [php-cs-fixer]: https://github.com/FriendsOfPHP/PHP-CS-Fixer "PHP Coding Standard Fixer" diff --git a/vendor/respect/validation/LICENSE.md b/vendor/respect/validation/LICENSE.md old mode 100755 new mode 100644 index fc1d6e8bd414a62d5705663169534cf9638d0d30..615cfd2e8da8797393e71c88b153b4372c533a1a --- a/vendor/respect/validation/LICENSE.md +++ b/vendor/respect/validation/LICENSE.md @@ -32,8 +32,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *** See also: +- [README](README.md) - [Contributing](CONTRIBUTING.md) -- [Feature Guide](docs/README.md) -- [Installation](docs/INSTALL.md) -- [Validators](docs/VALIDATORS.md) - [Changelog](CHANGELOG.md) diff --git a/vendor/respect/validation/README.md b/vendor/respect/validation/README.md old mode 100755 new mode 100644 index dbf83e7f0cfe5775106b5b9d144c718cec82d5b6..6e026234f7e57b6e036a141fa768fa991f74b6d7 --- a/vendor/respect/validation/README.md +++ b/vendor/respect/validation/README.md @@ -10,16 +10,18 @@ [The most awesome validation engine ever created for PHP.](http://bit.ly/1a1oeQv) - Complex rules made simple: `v::numeric()->positive()->between(1, 255)->validate($input)`. -- [Granularity control](docs/README.md#validation-methods) for advanced reporting. +- Granularity control for advanced reporting. - More than 100 (fully tested) validators. -- [A concrete API](docs/CONCRETE_API.md) for non fluent usage. +- A concrete API for non fluent usage. - Works on PHP 5.4+ or HHVM 3.3+ +## Documentation + +Documentation can be found in https://respect-validation.readthedocs.io +and also in the [docs/](docs/index.md) folder. + ## Table of contents - [Contributing](CONTRIBUTING.md) -- [Feature Guide](docs/README.md) -- [Installation](docs/INSTALL.md) - [License](LICENSE.md) -- [Validators](docs/VALIDATORS.md) - [Changelog](CHANGELOG.md) diff --git a/vendor/respect/validation/composer.json b/vendor/respect/validation/composer.json old mode 100755 new mode 100644 index 85e2b2dd4a3be109ae539c2e6e80fc0df0dffe84..398dafe4d94711662e32d6c1779c0972c9733cc8 --- a/vendor/respect/validation/composer.json +++ b/vendor/respect/validation/composer.json @@ -4,7 +4,7 @@ "keywords": ["respect", "validation", "validator"], "type": "library", "homepage": "http://respect.github.io/Validation/", - "license": "BSD Style", + "license": "BSD-3-Clause", "authors": [ { "name": "Respect/Validation Contributors", @@ -16,7 +16,7 @@ "symfony/polyfill-mbstring": "^1.2" }, "require-dev": { - "egulias/email-validator": "~1.2", + "egulias/email-validator": "~1.2 || ~2.1", "mikey179/vfsStream": "^1.5", "phpunit/phpunit": "~4.0", "symfony/validator": "~2.6.9", diff --git a/vendor/respect/validation/couscous.yml b/vendor/respect/validation/couscous.yml old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/docs/Age.md b/vendor/respect/validation/docs/Age.md deleted file mode 100755 index 740d7279b676e08c6062a1fdae87bc675fc6bbbc..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Age.md +++ /dev/null @@ -1,46 +0,0 @@ -# Age - -- `v::age(int $minAge)` -- `v::age(int $minAge, int $maxAge)` -- `v::age(null, int $maxAge)` - -Validates ranges of years. - -The validated values can be any date value; internally they will be transformed -into [DateTime](http://php.net/manual/en/class.datetime.php) objects according -to the defined locale settings. - -The examples below validate if the given dates are lower or equal to 18 years ago: -```php -v::age(18)->validate('17 years ago'); // false -v::age(18)->validate('18 years ago'); // true -v::age(18)->validate('19 years ago'); // true -v::age(18)->validate('1970-01-01'); // true -v::age(18)->validate('today'); // false -``` - -The examples below validate if the given dates are between 10 and 50 years ago: -```php -v::age(10, 50)->validate('9 years ago'); // false -v::age(10, 50)->validate('10 years ago'); // true -v::age(10, 50)->validate('30 years ago'); // true -v::age(10, 50)->validate('50 years ago'); // true -v::age(10, 50)->validate('51 years ago'); // false -``` - -The examples below validate if the given dates are greater than or equal to 70 years ago: -```php -v::age(null, 70)->validate('today'); // true -v::age(null, 70)->validate('70 years ago'); // true -v::age(null, 70)->validate('71 years ago'); // false -``` - -Message template for this validator includes `{{minAge}}` and `{{maxAge}}`. - -*** -See also: - - * [Between](Between.md) - * [Date](Date.md) - * [Max](Max.md) - * [Min](Min.md) diff --git a/vendor/respect/validation/docs/AllOf.md b/vendor/respect/validation/docs/AllOf.md deleted file mode 100755 index 7bd2ecf0203be63de28fd5a27c59f0eb7dbe8ddc..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/AllOf.md +++ /dev/null @@ -1,30 +0,0 @@ -# AllOf - -- `v::allOf(v $v1, v $v2, v $v3...)` - -Will validate if all inner validators validates. - -```php -v::allOf( - v::intVal(), - v::positive() -)->validate(15); // true -``` - -This is similar to the chain (which is an allOf already), but -its syntax allows you to set custom names for every node: - -```php -v::allOf( - v::intVal()->setName('Account Number'), - v::positive()->setName('Higher Than Zero') -)->setName('Positive integer') - ->validate(15); // true -``` - -*** -See also: - - * [OneOf](OneOf.md) - * [NoneOf](NoneOf.md) - * [When](When.md) diff --git a/vendor/respect/validation/docs/Alnum.md b/vendor/respect/validation/docs/Alnum.md deleted file mode 100755 index 184c1e2cfb64c88fc4ee5340077c6a22e8a3710c..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Alnum.md +++ /dev/null @@ -1,44 +0,0 @@ -# Alnum - -- `v::alnum()` -- `v::alnum(string $additionalChars)` - -Validates alphanumeric characters from a-Z and 0-9. - -```php -v::alnum()->validate('foo 123'); // true -v::alnum()->validate('number 100%'); // false -v::alnum('%')->validate('number 100%'); // true -``` - -Because this rule allows whitespaces by default, you can separate additional -characters with a whitespace: - -```php -v::alnum('- ! :')->validate('foo :- 123 !'); // true -``` - -This validator allows whitespace, if you want to -remove them add `->noWhitespace()` to the chain: - -```php -v::alnum()->noWhitespace()->validate('foo 123'); // false -``` - -You can restrict case using the `->lowercase()` and -`->uppercase()` validators: - -```php -v::alnum()->uppercase()->validate('aaa'); // false -``` - -Message template for this validator includes `{{additionalChars}}` as -the string of extra chars passed as the parameter. - -*** -See also: - - * [Alpha](Alpha.md) - * [Digit](Digit.md) - * [Consonant](Consonant.md) - * [Vowel](Vowel.md) diff --git a/vendor/respect/validation/docs/Alpha.md b/vendor/respect/validation/docs/Alpha.md deleted file mode 100755 index 44f4dc3714c3ebfd64c46a9da17bfa8a91c091f4..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Alpha.md +++ /dev/null @@ -1,14 +0,0 @@ -# Alpha - -- `v::alpha()` -- `v::alpha(string $additionalChars)` - -This is similar to `v::alnum()`, but it doesn't allow numbers. - -*** -See also: - - * [Alnum](Alnum.md) - * [Digit](Digit.md) - * [Consonant](Consonant.md) - * [Vowel](Vowel.md) diff --git a/vendor/respect/validation/docs/AlwaysInvalid.md b/vendor/respect/validation/docs/AlwaysInvalid.md deleted file mode 100755 index 34b364deb352ea110706b05ade042e04f0ee079f..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/AlwaysInvalid.md +++ /dev/null @@ -1,14 +0,0 @@ -# AlwaysInvalid - -- `v::alwaysInvalid()` - -Always return false. - -```php -v::alwaysInvalid()->validate($whatever); // false -``` - -*** -See also: - - * [AlwaysValid](AlwaysValid.md) diff --git a/vendor/respect/validation/docs/AlwaysValid.md b/vendor/respect/validation/docs/AlwaysValid.md deleted file mode 100755 index 6a020bb420dfde6d6fe61722c7a15bbccd39a0bd..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/AlwaysValid.md +++ /dev/null @@ -1,14 +0,0 @@ -# AlwaysValid - -- `v::alwaysValid()` - -Always returns true. - -```php -v::alwaysValid()->validate($whatever); // true -``` - -*** -See also: - - * [AlwaysInvalid](AlwaysInvalid.md) diff --git a/vendor/respect/validation/docs/ArrayType.md b/vendor/respect/validation/docs/ArrayType.md deleted file mode 100755 index ed72eb393ccccd6ccfdb443b8c9c94891a5d7fa9..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/ArrayType.md +++ /dev/null @@ -1,27 +0,0 @@ -# ArrayType - -- `v::arrayType()` - -Validates whether the type of an input is array. - -```php -v::arrayType()->validate([]); // true -v::arrayType()->validate([1, 2, 3]); // true -v::arrayType()->validate(new ArrayObject()); // false -``` - -*** -See also: - - * [ArrayVal](ArrayVal.md) - * [BoolType](BoolType.md) - * [CallableType](CallableType.md) - * [Countable](Countable.md) - * [FloatType](FloatType.md) - * [IntType](IntType.md) - * [IterableType](IterableType.md) - * [NullType](NullType.md) - * [ObjectType](ObjectType.md) - * [ResourceType](ResourceType.md) - * [StringType](StringType.md) - * [Type](Type.md) diff --git a/vendor/respect/validation/docs/ArrayVal.md b/vendor/respect/validation/docs/ArrayVal.md deleted file mode 100755 index ec9eaf066a3b42a0ea67dd7351b818bf828f0cd6..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/ArrayVal.md +++ /dev/null @@ -1,22 +0,0 @@ -# ArrayVal - -- `v::arrayVal()` - -Validates if the input is an array or if the input can be used as an array -(instance of `ArrayAccess`). - -```php -v::arrayVal()->validate([]); // true -v::arrayVal()->validate(new ArrayObject); // true -``` - -*** -See also: - - * [ArrayType](ArrayType.md) - * [Countable](Countable.md) - * [Each](Each.md) - * [IterableType](IterableType.md) - * [Key](Key.md) - * [KeySet](KeySet.md) - * [KeyValue](KeyValue.md) diff --git a/vendor/respect/validation/docs/Attribute.md b/vendor/respect/validation/docs/Attribute.md deleted file mode 100755 index e48b6b664bb2c58027149a4870bacf6468659b4a..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Attribute.md +++ /dev/null @@ -1,33 +0,0 @@ -# Attribute - -- `v::attribute(string $name)` -- `v::attribute(string $name, v $validator)` -- `v::attribute(string $name, v $validator, boolean $mandatory = true)` - -Validates an object attribute. - -```php -$obj = new stdClass; -$obj->foo = 'bar'; - -v::attribute('foo')->validate($obj); // true -``` - -You can also validate the attribute itself: - -```php -v::attribute('foo', v::equals('bar'))->validate($obj); // true -``` - -Third parameter makes the attribute presence optional: - -```php -v::attribute('lorem', v::stringType(), false)->validate($obj); // true -``` - -The name of this validator is automatically set to the attribute name. - -*** -See also: - - * [Key](Key.md) diff --git a/vendor/respect/validation/docs/Bank.md b/vendor/respect/validation/docs/Bank.md deleted file mode 100755 index 028d71985d50b871bffeb9a9889c0cd8d81b27f2..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Bank.md +++ /dev/null @@ -1,20 +0,0 @@ -# Bank - -- `v::bank(string $countryCode)` - -Validates a bank. - -```php -v::bank("de")->validate("70169464"); // true -v::bank("de")->validate("12345"); // false -``` - -These country codes are supported: - - * "de" (Germany) - You must add `"malkusch/bav": "~1.0"` to your `require` property on composer.json file. - -*** -See also: - - * [BankAccount](BankAccount.md) - * [Bic](Bic.md) diff --git a/vendor/respect/validation/docs/BankAccount.md b/vendor/respect/validation/docs/BankAccount.md deleted file mode 100755 index f9d319d7f82c2ba7d6d681ab7f33ed43df3abfa4..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/BankAccount.md +++ /dev/null @@ -1,20 +0,0 @@ -# BankAccount - -- `v::bankAccount(string $countryCode, string $bank)` - -Validates a bank account for a given bank. - -```php -v::bankAccount("de", "70169464")->validate("1112"); // true -v::bankAccount("de", "70169464")->validate("1234"); // false -``` - -These country codes are supported: - - * "de" (Germany) - You must add `"malkusch/bav": "~1.0"` to your `require` property on composer.json file. - -*** -See also: - - * [Bank](Bank.md) - * [Bic](Bic.md) diff --git a/vendor/respect/validation/docs/Between.md b/vendor/respect/validation/docs/Between.md deleted file mode 100755 index 5c0204afc9aed1fb1834d82d0050cb274b060152..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Between.md +++ /dev/null @@ -1,44 +0,0 @@ -# Between - -- `v::between(mixed $start, mixed $end)` -- `v::between(mixed $start, mixed $end, boolean $inclusive = true)` - -Validates ranges. Most simple example: - -```php -v::intVal()->between(10, 20)->validate(15); // true -``` - -The type as the first validator in a chain is a good practice, -since between accepts many types: - -```php -v::stringType()->between('a', 'f')->validate('c'); // true -``` - -Also very powerful with dates: - -```php -v::date()->between('2009-01-01', '2013-01-01')->validate('2010-01-01'); // true -``` - -Date ranges accept strtotime values: - -```php -v::date()->between('yesterday', 'tomorrow')->validate('now'); // true -``` - -A third parameter may be passed to validate the passed values inclusive: - -```php -v::date()->between(10, 20, true)->validate(20); // true -``` - -Message template for this validator includes `{{minValue}}` and `{{maxValue}}`. - -*** -See also: - - * [Length](Length.md) - * [Min](Min.md) - * [Max](Max.md) diff --git a/vendor/respect/validation/docs/Bic.md b/vendor/respect/validation/docs/Bic.md deleted file mode 100755 index 82c67e8810a5caaadcd36cf798b35969935b1567..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Bic.md +++ /dev/null @@ -1,20 +0,0 @@ -# Bic - -- `v::bic(string $countryCode)` - -Validates a BIC (Bank Identifier Code) for a given country. - -```php -v::bic("de")->validate("VZVDDED1XXX"); // true -v::bic("de")->validate("VZVDDED1"); // true -``` - -Theses country codes are supported: - - * "de" (Germany) - You must add `"malkusch/bav": "~1.0"` to your `require` property on composer.json file. - -*** -See also: - - * [Bank](Bank.md) - * [BankAccount](BankAccount.md) diff --git a/vendor/respect/validation/docs/BoolType.md b/vendor/respect/validation/docs/BoolType.md deleted file mode 100755 index 979562189815b5d858b03e316120796971063de5..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/BoolType.md +++ /dev/null @@ -1,27 +0,0 @@ -# BoolType - -- `v::boolType()` - -Validates if the input is a boolean value: - -```php -v::boolType()->validate(true); // true -v::boolType()->validate(false); // true -``` - -*** -See also: - - * [ArrayType](ArrayType.md) - * [CallableType](CallableType.md) - * [FloatType](FloatType.md) - * [FloatVal](FloatVal.md) - * [IntType](IntType.md) - * [No](No.md) - * [NullType](NullType.md) - * [ObjectType](ObjectType.md) - * [ResourceType](ResourceType.md) - * [StringType](StringType.md) - * [TrueVal](TrueVal.md) - * [Type](Type.md) - * [Yes](Yes.md) diff --git a/vendor/respect/validation/docs/BoolVal.md b/vendor/respect/validation/docs/BoolVal.md deleted file mode 100755 index 26bf9a6d0d137efdb9707647190daf17041886ba..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/BoolVal.md +++ /dev/null @@ -1,31 +0,0 @@ -# BoolVal - -- `v::boolVal()` - -Validates if the input results in a boolean value: - -```php -v::boolVal()->validate('on'); // true -v::boolVal()->validate('off'); // true -v::boolVal()->validate('yes'); // true -v::boolVal()->validate('no'); // true -v::boolVal()->validate(1); // true -v::boolVal()->validate(0); // true -``` - -*** -See also: - - * [BoolType](BoolType.md) - * [CallableType](CallableType.md) - * [FloatType](FloatType.md) - * [FloatVal](FloatVal.md) - * [IntType](IntType.md) - * [No](No.md) - * [NullType](NullType.md) - * [ObjectType](ObjectType.md) - * [ResourceType](ResourceType.md) - * [StringType](StringType.md) - * [TrueVal](TrueVal.md) - * [Type](Type.md) - * [Yes](Yes.md) diff --git a/vendor/respect/validation/docs/Bsn.md b/vendor/respect/validation/docs/Bsn.md deleted file mode 100755 index e67f55e70d22aeddfe110578ff0cd57ff05fb2e3..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Bsn.md +++ /dev/null @@ -1,16 +0,0 @@ -# Bsn - -- `v::bsn()` - -Validates a Dutch citizen service number ([BSN](https://nl.wikipedia.org/wiki/Burgerservicenummer)). - -```php -v::bsn()->validate('612890053'); // true -``` - -*** -See also: - - * [Cnh](Cnh.md) - * [Cnpj](Cnpj.md) - * [Cpf](Cpf.md) diff --git a/vendor/respect/validation/docs/CONCRETE_API.md b/vendor/respect/validation/docs/CONCRETE_API.md deleted file mode 100755 index 735b6283d558ed32516a61b8ef6e5c87a2ee75da..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/CONCRETE_API.md +++ /dev/null @@ -1,77 +0,0 @@ -# Concrete API - -There are many micro-frameworks that rely on magic methods. We don't. In this -document we're gonna explore the Respect\Validation API without fluent interfaces -or magic methods. We'll use a traditional dependency injection approach. - -```php -use Respect\Validation\Validator as v; - -$usernameValidator = v::alnum()->noWhitespace()->length(1,15); -$usernameValidator->validate('alganet'); // true -``` - -If you `var_dump($usernameValidator)`, you'll see a composite of objects with -`Respect\Validation\Rules\Alnum`, `Respect\Validation\Rules\NoWhitespace` and -`Respect\Validation\Rules\Length`. There is a specific object for each rule, and -the chain only builds the structure. You can build it by yourself: - -```php -use Respect\Validation\Rules; - -$usernameValidator = new Rules\AllOf( - new Rules\Alnum(), - new Rules\NoWhitespace(), - new Rules\Length(1, 15) -); -$usernameValidator->validate('alganet'); // true -``` - -This is still a very lean API. You can use it in any dependency injection -container or test it in the way you want. Nesting is still possible: - -```php -use Respect\Validation\Rules; - -$usernameValidator = new Rules\AllOf( - new Rules\Alnum(), - new Rules\NoWhitespace(), - new Rules\Length(1, 15) -); -$userValidator = new Rules\Key('name', $usernameValidator); -$userValidator->validate(['name' => 'alganet']); // true -``` - -## How It Works? - -The Respect\Validation chain is an -[internal DSL](http://martinfowler.com/bliki/InternalDslStyle.html). -It acts in the creational realm of objects (where Abstract Factories and Builders -live), and it's only job is to make rule construction terse and fluent. - -## FAQ - -> Is `v` in `v::something` a class name? - -No! The class is `Respect\Validation\Validator`, we suggest `v` as a very short alias. - -> Is `v::something()` a static call? - -Yes. Just like the default `DateTime::createFromFormat()` or -`Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration()`. It builds -something complex and returns for you. - -> I really don't like static calls, can I avoid it? - -Yes. Just use `$validator = new Validator();` each time you want a new validator, -and continue from there. - -> Do you have a static method for each rule? - -No. We use `__callStatic()`. - -> Magic methods are slow! Why do you use them? - -They're optional. If you use the `new` interface, they won't be called. - -(still, do some benchmarks, you'd be surprised with our implementation). diff --git a/vendor/respect/validation/docs/Call.md b/vendor/respect/validation/docs/Call.md deleted file mode 100755 index f56b0a8e5e73b80188026d98206c916ae0fe8969..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Call.md +++ /dev/null @@ -1,51 +0,0 @@ -# Call - -- `v::call(callable $callback)` - -This is a very low level validator. It calls a function, method or closure -for the input and then validates it. Consider the following variable: - -```php -$url = 'http://www.google.com/search?q=respect.github.com' -``` - -To validate every part of this URL we could use the native `parse_url` -function to break its parts: - -```php -$parts = parse_url($url); -``` - -This function returns an array containing `scheme`, `host`, `path` and `query`. -We can validate them this way: - -```php -v::arrayVal()->key('scheme', v::startsWith('http')) - ->key('host', v::domain()) - ->key('path', v::stringType()) - ->key('query', v::notEmpty()); -``` - -Using `v::call()` you can do this in a single chain: - -```php -v::call( - 'parse_url', - v::arrayVal()->key('scheme', v::startsWith('http')) - ->key('host', v::domain()) - ->key('path', v::stringType()) - ->key('query', v::notEmpty()) -)->validate($url); -``` - -It is possible to call methods and closures as the first parameter: - -```php -v::call([$myObj, 'methodName'], v::intVal())->validate($myInput); -v::call(function($input) {}, v::intVal())->validate($myInput); -``` - -*** -See also: - - * [Callback](Callback.md) diff --git a/vendor/respect/validation/docs/CallableType.md b/vendor/respect/validation/docs/CallableType.md deleted file mode 100755 index 7f24dca7b0dfcbb4ae4591061d75f75793d35709..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/CallableType.md +++ /dev/null @@ -1,25 +0,0 @@ -# CallableType - -- `v::callableType()` - -Validates if the input is a callable value. - -```php -v::callableType()->validate(function () {}); // true -v::callableType()->validate('trim'); // true -v::callableType()->validate([new ObjectType, 'methodName']); // true -``` - -*** -See also: - - * [ArrayType](ArrayType.md) - * [BoolType](BoolType.md) - * [Callback](Callback.md) - * [FloatType](FloatType.md) - * [IntType](IntType.md) - * [NullType](NullType.md) - * [ObjectType](ObjectType.md) - * [ResourceType](ResourceType.md) - * [StringType](StringType.md) - * [Type](Type.md) diff --git a/vendor/respect/validation/docs/Callback.md b/vendor/respect/validation/docs/Callback.md deleted file mode 100755 index d5ec6b86c62bea13d0b8b1e999129775b67e20e2..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Callback.md +++ /dev/null @@ -1,21 +0,0 @@ -# Callback - -- `v::callback(callable $callback)` - -This is a wildcard validator, it uses a function name, method or closure -to validate something: - -```php -v::callback('is_int')->validate(10); // true -``` - -(Please note that this is a sample, the `v::intVal()` validator is much better). - -As in `v::call()`, you can pass a method or closure to it. - -*** -See also: - - * [Call](Call.md) - * [CallableType](CallableType.md) - * [FilterVar](FilterVar.md) diff --git a/vendor/respect/validation/docs/Charset.md b/vendor/respect/validation/docs/Charset.md deleted file mode 100755 index 43d889bdc687c4221eb82510f6fada2b39db8048..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Charset.md +++ /dev/null @@ -1,19 +0,0 @@ -# Charset - -- `v::charset(mixed $charset)` - -Validates if a string is in a specific charset. - -```php -v::charset('ASCII')->validate('açúcar'); // false -v::charset('ASCII')->validate('sugar'); //true -v::charset(['ISO-8859-1', 'EUC-JP'])->validate('日本国'); // true -``` - -The array format is a logic OR, not AND. - -*** -See also: - - * [Alnum](Alnum.md) - * [Alpha](Alpha.md) diff --git a/vendor/respect/validation/docs/Cnh.md b/vendor/respect/validation/docs/Cnh.md deleted file mode 100755 index 6815929a3910d537c8e5131828dd68fd176d9d29..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Cnh.md +++ /dev/null @@ -1,15 +0,0 @@ -# Cnh - -- `v::cnh()` - -Validates a Brazillian driver's license. - -```php -v::cnh()->validate('02650306461'); // true -``` - -*** -See also: - - * [Cnpj](Cnpj.md) - * [Cpf](Cpf.md) diff --git a/vendor/respect/validation/docs/Cnpj.md b/vendor/respect/validation/docs/Cnpj.md deleted file mode 100755 index 846d391762c2523cc527c61829c227ea3909f502..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Cnpj.md +++ /dev/null @@ -1,12 +0,0 @@ -# Cnpj - -- `v::cnpj()` - -Validates the Brazillian CNPJ number. Ignores non-digit chars, so -use `->digit()` if needed. - -*** -See also: - - * [Cpf](Cpf.md) - * [Cnh](Cnh.md) diff --git a/vendor/respect/validation/docs/Cntrl.md b/vendor/respect/validation/docs/Cntrl.md deleted file mode 100755 index 7a6552aa8e0529dcbc08cd4017f9bd65434a1dc2..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Cntrl.md +++ /dev/null @@ -1,17 +0,0 @@ -# Cntrl - -- `v::cntrl()` -- `v::cntrl(string $additionalChars)` - -This is similar to `v::alnum()`, but only accepts control characters: - -```php -v::cntrl()->validate("\n\r\t"); // true -``` - -*** -See also: - - * [Alnum](Alnum.md) - * [Prnt](Prnt.md) - * [Space](Space.md) diff --git a/vendor/respect/validation/docs/Consonant.md b/vendor/respect/validation/docs/Consonant.md deleted file mode 100755 index fac1fe53319d7ba5afe0f39aef44f4116a1b6c71..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Consonant.md +++ /dev/null @@ -1,18 +0,0 @@ -# Consonant - -- `v::consonant()` -- `v::consonant(string $additionalChars)` - -Similar to `v::alnum()`. Validates strings that contain only consonants: - -```php -v::consonant()->validate('xkcd'); // true -``` - -*** -See also: - - * [Alnum](Alnum.md) - * [Digit](Digit.md) - * [Alpha](Alpha.md) - * [Vowel](Vowel.md) diff --git a/vendor/respect/validation/docs/Contains.md b/vendor/respect/validation/docs/Contains.md deleted file mode 100755 index 6036494fe43cbbb06015a2e7edcc9fd4871d6d00..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Contains.md +++ /dev/null @@ -1,28 +0,0 @@ -# Contains - -- `v::contains(mixed $value)` -- `v::contains(mixed $value, boolean $identical = false)` - -For strings: - -```php -v::contains('ipsum')->validate('lorem ipsum'); // true -``` - -For arrays: - -```php -v::contains('ipsum')->validate(['ipsum', 'lorem']); // true -``` - -A second parameter may be passed for identical comparison instead -of equal comparison. - -Message template for this validator includes `{{containsValue}}`. - -*** -See also: - - * [StartsWith](StartsWith.md) - * [EndsWith](EndsWith.md) - * [In](In.md) diff --git a/vendor/respect/validation/docs/Countable.md b/vendor/respect/validation/docs/Countable.md deleted file mode 100755 index 0353de4d7a748ed9f490149b8f07d1343f084036..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Countable.md +++ /dev/null @@ -1,19 +0,0 @@ -# Countable - -- `v::countable()` - -Validates if the input is countable, in other words, if you're allowed to use -[count()](http://php.net/count) function on it. - -```php -v::countable()->validate([]); // true -v::countable()->validate(new ArrayObject()); // true -v::countable()->validate('string'); // false -``` - -*** -See also: - - * [ArrayVal](ArrayVal.md) - * [Instance](Instance.md) - * [IterableType](IterableType.md) diff --git a/vendor/respect/validation/docs/CountryCode.md b/vendor/respect/validation/docs/CountryCode.md deleted file mode 100755 index 469313db2dcb66a7306d53510b54c136afa758a8..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/CountryCode.md +++ /dev/null @@ -1,14 +0,0 @@ -# CountryCode - -- `v::countryCode()` - -Validates an ISO country code like US or BR. - -```php -v::countryCode()->validate('BR'); // true -``` - -*** -See also: - - * [Tld](Tld.md) diff --git a/vendor/respect/validation/docs/Cpf.md b/vendor/respect/validation/docs/Cpf.md deleted file mode 100755 index 0fc3a717af13febc2d111218e534d9f61271e037..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Cpf.md +++ /dev/null @@ -1,28 +0,0 @@ -# Cpf - -- `v::cpf()` - -Validates a Brazillian CPF number. - -```php -v::cpf()->validate('44455566820'); // true -``` - -It ignores any non-digit char: - -```php -v::cpf()->validate('444.555.668-20'); // true -``` - -If you need to validate digits only, add `->digit()` to -the chain: - -```php -v::digit()->cpf()->validate('44455566820'); // true -``` - -*** -See also: - - * [Cnpj](Cnpj.md) - * [Cnh](Cnh.md) diff --git a/vendor/respect/validation/docs/CreditCard.md b/vendor/respect/validation/docs/CreditCard.md deleted file mode 100755 index aa9783a23304444b5871f7965eec499ec9de7408..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/CreditCard.md +++ /dev/null @@ -1,39 +0,0 @@ -# CreditCard - -- `v::creditCard()` -- `v::creditCard(string $brand)` - -Validates a credit card number. - -```php -v::creditCard()->validate('5376 7473 9720 8720'); // true - -v::creditCard('American Express')->validate('340316193809364'); // true -v::creditCard('Diners Club')->validate('30351042633884'); // true -v::creditCard('Discover')->validate('6011000990139424'); // true -v::creditCard('JCB')->validate('3566002020360505'); // true -v::creditCard('Master')->validate('5376747397208720'); // true -v::creditCard('Visa')->validate('4024007153361885'); // true -``` - -The current supported brands are: - -- American Express -- Diners Club -- Discover -- JCB -- MasterCard -- Visa - -It ignores any non-digit chars, so use `->digit()` when appropriate. - -```php -v::digit()->creditCard()->validate('5376747397208720'); // true -``` - -*** -See also: - - * [Bank](Bank.md) - * [BankAccount](BankAccount.md) - * [Bic](Bic.md) diff --git a/vendor/respect/validation/docs/CurrencyCode.md b/vendor/respect/validation/docs/CurrencyCode.md deleted file mode 100755 index 95c13fae47325b977071590ec7304b7afdd5b3b6..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/CurrencyCode.md +++ /dev/null @@ -1,15 +0,0 @@ -# CurrencyCode - -- `v::currencyCode()` - -Validates an [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code like GBP or EUR. - -```php -v::currencyCode()->validate('GBP'); // true -``` - -*** -See also: - - * [CountryCode](CountryCode.md) - * [SubdivisionCode](SubdivisionCode.md) diff --git a/vendor/respect/validation/docs/Date.md b/vendor/respect/validation/docs/Date.md deleted file mode 100755 index 4afb9ecbd56a4b49614375508f38bc18cb1b5170..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Date.md +++ /dev/null @@ -1,40 +0,0 @@ -# Date - -- `v::date()` -- `v::date(string $format)` - -Validates if input is a date: - -```php -v::date()->validate('2009-01-01'); // true -``` - -Also accepts strtotime values: - -```php -v::date()->validate('now'); // true -``` - -And DateTime instances: - -```php -v::date()->validate(new DateTime); // true -``` - -You can pass a format when validating strings: - -```php -v::date('Y-m-d')->validate('01-01-2009'); // false -``` - -Format has no effect when validating DateTime instances. - -Message template for this validator includes `{{format}}`. - -*** -See also: - - * [Between](Between.md) - * [MinimumAge](MinimumAge.md) - * [LeapDate](LeapDate.md) - * [LeapYear](LeapYear.md) diff --git a/vendor/respect/validation/docs/Digit.md b/vendor/respect/validation/docs/Digit.md deleted file mode 100755 index c4638483f4d6734817263c9891263a1ea2d41deb..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Digit.md +++ /dev/null @@ -1,13 +0,0 @@ -# Digit - -- `v::digit()` - -This is similar to `v::alnum()`, but it doesn't allow a-Z. - -*** -See also: - - * [Alnum](Alnum.md) - * [Alpha](Alpha.md) - * [Vowel](Vowel.md) - * [Consonant](Consonant.md) diff --git a/vendor/respect/validation/docs/Directory.md b/vendor/respect/validation/docs/Directory.md deleted file mode 100755 index 7d49c63b726e0bec8c8d615092d3ed7ce275755c..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Directory.md +++ /dev/null @@ -1,30 +0,0 @@ -# Directory - -- `v::directory()` - -Validates directories. - -```php -v::directory()->validate(__DIR__); // true -v::directory()->validate(__FILE__); // false -``` - -This validator will consider SplFileInfo instances, so you can do something like: - -```php -v::directory()->validate(new \SplFileInfo($directory)); -``` - -*** -See also: - - * [Executable](Executable.md) - * [Exists](Exists.md) - * [Extension](Extension.md) - * [File](File.md) - * [Mimetype](Mimetype.md) - * [Readable](Readable.md) - * [Size](Size.md) - * [SymbolicLink](SymbolicLink.md) - * [Uploaded](Uploaded.md) - * [Writable](Writable.md) diff --git a/vendor/respect/validation/docs/Domain.md b/vendor/respect/validation/docs/Domain.md deleted file mode 100755 index ac5d76a7b77d89952de912a75c614fa3479f99aa..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Domain.md +++ /dev/null @@ -1,40 +0,0 @@ -# Domain - -- `v::domain()` -- `v::domain(boolean $tldCheck = true)` - -Validates domain names. - -```php -v::domain()->validate('google.com'); -``` - -You can skip *top level domain* (TLD) checks to validate internal -domain names: - -```php -v::domain(false)->validate('dev.machine.local'); -``` - -This is a composite validator, it validates several rules -internally: - - * If input is an IP address, it fails. - * If input contains whitespace, it fails. - * If input does not contain any dots, it fails. - * If input has less than two parts, it fails. - * Input must end with a top-level-domain to pass (if not skipped). - * Each part must be alphanumeric and not start with an hyphen. - * [PunnyCode][] is accepted for [Internationalizing Domain Names in Applications][IDNA]. - -Messages for this validator will reflect rules above. - -*** -See also: - - * [Ip](Ip.md) - * [MacAddress](MacAddress.md) - * [Tld](Tld.md) - -[PunnyCode]: http://en.wikipedia.org/wiki/Punycode "Wikipedia: Punnycode" -[IDNA]: http://en.wikipedia.org/wiki/Internationalized_domain_name#Internationalizing_Domain_Names_in_Applications "Wikipedia: Internationalized domain name" diff --git a/vendor/respect/validation/docs/Each.md b/vendor/respect/validation/docs/Each.md deleted file mode 100755 index ecc1c666359e921a9a33cdebe1a2c3ee5a6c4a92..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Each.md +++ /dev/null @@ -1,27 +0,0 @@ -# Each - -- `v::each(v $validatorForValue)` -- `v::each(null, v $validatorForKey)` -- `v::each(v $validatorForValue, v $validatorForKey)` - -Iterates over an array or Iterator and validates the value or key -of each entry: - -```php -$releaseDates = [ - 'validation' => '2010-01-01', - 'template' => '2011-01-01', - 'relational' => '2011-02-05', -]; - -v::arrayVal()->each(v::date())->validate($releaseDates); // true -v::arrayVal()->each(v::date(), v::stringType()->lowercase())->validate($releaseDates); // true -``` - -Using `arrayVal()` before `each()` is a best practice. - -*** -See also: - - * [Key](Key.md) - * [ArrayVal](ArrayVal.md) diff --git a/vendor/respect/validation/docs/Email.md b/vendor/respect/validation/docs/Email.md deleted file mode 100755 index 64a4d7cf3c4896dd1786e20c99b74bd89adbf184..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Email.md +++ /dev/null @@ -1,16 +0,0 @@ -# Email - -- `v::email()` - -Validates an email address. - -```php -v::email()->validate('alexandre@gaigalas.net'); // true -``` - -*** -See also: - - * [Phone](Phone.md) - * [Url](Url.md) - * [VideoUrl](VideoUrl.md) diff --git a/vendor/respect/validation/docs/EndsWith.md b/vendor/respect/validation/docs/EndsWith.md deleted file mode 100755 index 99ec5b215a194760e80132ea1083bd791b903b0e..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/EndsWith.md +++ /dev/null @@ -1,31 +0,0 @@ -# EndsWith - -- `v::endsWith(mixed $value)` -- `v::endsWith(mixed $value, boolean $identical = false)` - -This validator is similar to `v::contains()`, but validates -only if the value is at the end of the input. - -For strings: - -```php -v::endsWith('ipsum')->validate('lorem ipsum'); // true -``` - -For arrays: - -```php -v::endsWith('ipsum')->validate(['lorem', 'ipsum']); // true -``` - -A second parameter may be passed for identical comparison instead -of equal comparison. - -Message template for this validator includes `{{endValue}}`. - -*** -See also: - - * [StartsWith](StartsWith.md) - * [Contains](Contains.md) - * [In](In.md) diff --git a/vendor/respect/validation/docs/Equals.md b/vendor/respect/validation/docs/Equals.md deleted file mode 100755 index e28f783dfcfd4128c7eecba94307e4ae53aeff1c..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Equals.md +++ /dev/null @@ -1,17 +0,0 @@ -# Equals - -- `v::equals(mixed $value)` - -Validates if the input is equal to some value. - -```php -v::equals('alganet')->validate('alganet'); // true -``` - -Message template for this validator includes `{{compareTo}}`. - -*** -See also: - - * [Contains](Contains.md) - * [Identical](Identical.md) diff --git a/vendor/respect/validation/docs/Even.md b/vendor/respect/validation/docs/Even.md deleted file mode 100755 index da52597b85c0793e85862dd42611df0f4da6a7cd..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Even.md +++ /dev/null @@ -1,17 +0,0 @@ -# Even - -- `v::even()` - -Validates an even number. - -```php -v::intVal()->even()->validate(2); // true -``` - -Using `int()` before `even()` is a best practice. - -*** -See also: - - * [Odd](Odd.md) - * [Multiple](Multiple.md) diff --git a/vendor/respect/validation/docs/Executable.md b/vendor/respect/validation/docs/Executable.md deleted file mode 100755 index 7c1e1303dc350d4034dc1f8c6454e835943187e2..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Executable.md +++ /dev/null @@ -1,23 +0,0 @@ -# Executable - -- `v::executable()` - -Validates if a file is an executable. - -```php -v::email()->executable('script.sh'); // true -``` - -*** -See also: - - * [Directory](Directory.md) - * [Exists](Exists.md) - * [Extension](Extension.md) - * [File](File.md) - * [Mimetype](Mimetype.md) - * [Readable](Readable.md) - * [Size](Size.md) - * [SymbolicLink](SymbolicLink.md) - * [Uploaded](Uploaded.md) - * [Writable](Writable.md) diff --git a/vendor/respect/validation/docs/Exists.md b/vendor/respect/validation/docs/Exists.md deleted file mode 100755 index 681c50743b70cd7b36548571ca47ae2d51cc4075..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Exists.md +++ /dev/null @@ -1,30 +0,0 @@ -# Exists - -- `v::exists()` - -Validates files or directories. - -```php -v::exists()->validate(__FILE__); // true -v::exists()->validate(__DIR__); // true -``` - -This validator will consider SplFileInfo instances, so you can do something like: - -```php -v::exists()->validate(new \SplFileInfo($file)); -``` - -*** -See also: - - * [Directory](Directory.md) - * [Executable](Executable.md) - * [Extension](Extension.md) - * [File](File.md) - * [Mimetype](Mimetype.md) - * [Readable](Readable.md) - * [Size](Size.md) - * [SymbolicLink](SymbolicLink.md) - * [Uploaded](Uploaded.md) - * [Writable](Writable.md) diff --git a/vendor/respect/validation/docs/Extension.md b/vendor/respect/validation/docs/Extension.md deleted file mode 100755 index 4abc0d5ba51f701827dd166daac098ec79c65e3f..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Extension.md +++ /dev/null @@ -1,25 +0,0 @@ -# Extension - -- `v::extension(string $extension)` - -Validates if the file extension matches the expected one: - -```php -v::extension('png')->validate('image.png'); // true -``` - -This rule is case-sensitive. - -*** -See also: - - * [Directory](Directory.md) - * [Executable](Executable.md) - * [Exists](Exists.md) - * [File](File.md) - * [Mimetype](Mimetype.md) - * [Readable](Readable.md) - * [Size](Size.md) - * [SymbolicLink](SymbolicLink.md) - * [Uploaded](Uploaded.md) - * [Writable](Writable.md) diff --git a/vendor/respect/validation/docs/Factor.md b/vendor/respect/validation/docs/Factor.md deleted file mode 100755 index 1e04276432d1bc8583fa89da6c004d43abdb2568..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Factor.md +++ /dev/null @@ -1,19 +0,0 @@ -# Factor - -- `v::factor(int $dividend)` - -Validates if the input is a factor of the defined dividend. - -```php -v::factor(0)->validate(5); // true -v::factor(4)->validate(2); // true -v::factor(4)->validate(3); // false -``` - -*** -See also: - - * [Digit](Digit.md) - * [Finite](Finite.md) - * [Infinite](Infinite.md) - * [Numeric](Numeric.md) diff --git a/vendor/respect/validation/docs/FalseVal.md b/vendor/respect/validation/docs/FalseVal.md deleted file mode 100755 index 6ca060d33ca40dd587efb0e4583b7606b1000f03..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/FalseVal.md +++ /dev/null @@ -1,21 +0,0 @@ -# FalseVal - -- `v::falseVal()` - -Validates if a value is considered as `false`. - -```php -v::falseVal()->validate(false); // true -v::falseVal()->validate(0); // true -v::falseVal()->validate('0'); // true -v::falseVal()->validate('false'); // true -v::falseVal()->validate('off'); // true -v::falseVal()->validate('no'); // true -v::falseVal()->validate('0.5'); // false -v::falseVal()->validate('2'); // false -``` - -*** -See also: - - * [TrueVal](TrueVal.md) diff --git a/vendor/respect/validation/docs/Fibonacci.md b/vendor/respect/validation/docs/Fibonacci.md deleted file mode 100755 index fe8c5235b775e98fda3c81e43f1736e7e18dc30f..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Fibonacci.md +++ /dev/null @@ -1,17 +0,0 @@ -# Fibonacci - - - `v::fibonacci()` - -Validates whether the input follows the Fibonacci integer sequence. - -```php -v::fibonacci()->validate(1); // true -v::fibonacci()->validate('34'); // true -v::fibonacci()->validate(6); // false -``` - -*** -See also: - - * [PrimeNumber](PrimeNumber.md) - * [PerfectSquare](PerfectSquare.md) \ No newline at end of file diff --git a/vendor/respect/validation/docs/File.md b/vendor/respect/validation/docs/File.md deleted file mode 100755 index 8454d0258d2d1922fc5105c71f1e6ea3a3ab28fb..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/File.md +++ /dev/null @@ -1,30 +0,0 @@ -# File - -- `v::file()` - -Validates files. - -```php -v::file()->validate(__FILE__); // true -v::file()->validate(__DIR__); // false -``` - -This validator will consider SplFileInfo instances, so you can do something like: - -```php -v::file()->validate(new \SplFileInfo($file)); -``` - -*** -See also: - - * [Directory](Directory.md) - * [Executable](Executable.md) - * [Exists](Exists.md) - * [Extension](Extension.md) - * [Mimetype](Mimetype.md) - * [Readable](Readable.md) - * [Size](Size.md) - * [SymbolicLink](SymbolicLink.md) - * [Uploaded](Uploaded.md) - * [Writable](Writable.md) diff --git a/vendor/respect/validation/docs/FilterVar.md b/vendor/respect/validation/docs/FilterVar.md deleted file mode 100755 index a13d4fa091ffab6afb9a9df90b13d9adba374d64..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/FilterVar.md +++ /dev/null @@ -1,18 +0,0 @@ -# FilterVar - -- `v::filterVar(int $filter)` -- `v::filterVar(int $filter, mixed $options)` - -A wrapper for PHP's [filter_var()](http://php.net/filter_var) function. - -```php -v::filterVar(FILTER_VALIDATE_EMAIL)->validate('bob@example.com'); // true -v::filterVar(FILTER_VALIDATE_URL)->validate('http://example.com'); // true -v::filterVar(FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)->validate('http://example.com'); // false -v::filterVar(FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)->validate('http://example.com/path'); // true -``` - -*** -See also: - - * [Callback](Callback.md) diff --git a/vendor/respect/validation/docs/Finite.md b/vendor/respect/validation/docs/Finite.md deleted file mode 100755 index 42ef9f30d6d833305e0140c368d87694dd9b887c..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Finite.md +++ /dev/null @@ -1,18 +0,0 @@ -# Finite - -- `v::finite()` - -Validates if the input is a finite number. - -```php -v::finite()->validate('10'); // true -v::finite()->validate(10); // true -``` - -*** -See also: - - * [Digit](Digit.md) - * [Infinite](Infinite.md) - * [IntVal](IntVal.md) - * [Numeric](Numeric.md) diff --git a/vendor/respect/validation/docs/FloatType.md b/vendor/respect/validation/docs/FloatType.md deleted file mode 100755 index 87efee83511a971477a7ec4ca2f84fc4ab81dbcc..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/FloatType.md +++ /dev/null @@ -1,25 +0,0 @@ -# FloatType - -- `v::floatType()` - -Validates whether the type of a value is float. - -```php -v::floatType()->validate(1.5); // true -v::floatType()->validate('1.5'); // false -v::floatType()->validate(0e5); // true -``` - -*** -See also: - - * [BoolType](BoolType.md) - * [CallableType](CallableType.md) - * [FloatVal](FloatVal.md) - * [IntType](IntType.md) - * [IntVal](IntVal.md) - * [NullType](NullType.md) - * [ObjectType](ObjectType.md) - * [ResourceType](ResourceType.md) - * [StringType](StringType.md) - * [Type](Type.md) diff --git a/vendor/respect/validation/docs/FloatVal.md b/vendor/respect/validation/docs/FloatVal.md deleted file mode 100755 index f73c2fc073094600820a00cba34c34ec6c378bd3..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/FloatVal.md +++ /dev/null @@ -1,17 +0,0 @@ -# FloatVal - -- `v::floatVal()` - -Validates a floating point number. - -```php -v::floatVal()->validate(1.5); // true -v::floatVal()->validate('1e5'); // true -``` - -*** -See also: - - * [FloatType](FloatType.md) - * [IntType](IntType.md) - * [IntVal](IntVal.md) diff --git a/vendor/respect/validation/docs/Graph.md b/vendor/respect/validation/docs/Graph.md deleted file mode 100755 index 2c7503ad785414e4459968261f12b844a93db206..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Graph.md +++ /dev/null @@ -1,15 +0,0 @@ -# Graph - -- `v::graph()` -- `v::graph(string $additionalChars)` - -Validates all characters that are graphically represented. - -```php -v::graph()->validate('LKM@#$%4;'); // true -``` - -*** -See also: - - * [Prnt](Prnt.md) diff --git a/vendor/respect/validation/docs/HexRgbColor.md b/vendor/respect/validation/docs/HexRgbColor.md deleted file mode 100755 index 3e4a1e98d9e538d3f90f4aa2f25ab88e85bfaf8e..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/HexRgbColor.md +++ /dev/null @@ -1,16 +0,0 @@ -# HexRgbColor - -- `v::hexRgbColor()` - -Validates a hex RGB color - -```php -v::hexRgbColor()->validate('#FFFAAA'); // true -v::hexRgbColor()->validate('123123'); // true -v::hexRgbColor()->validate('FCD'); // true -``` - -*** -See also: - - * [Vxdigit](Vxdigit.md) diff --git a/vendor/respect/validation/docs/INSTALL.md b/vendor/respect/validation/docs/INSTALL.md deleted file mode 100755 index 9cf5efb04d0ebe5d4200890e6af78c7aa90f829d..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/INSTALL.md +++ /dev/null @@ -1,18 +0,0 @@ -# Installation - -Package is available on [Packagist](http://packagist.org/packages/respect/validation), -you can install it using [Composer](http://getcomposer.org). - -```shell -composer require respect/validation -``` - -[PHP](https://php.net) 5.4+ or [HHVM](http://hhvm.com) 3.3+ are required. - -*** -See also: - -- [Contributing](../CONTRIBUTING.md) -- [Feature Guide](README.md) -- [License](../LICENSE.md) -- [Validators](VALIDATORS.md) diff --git a/vendor/respect/validation/docs/Identical.md b/vendor/respect/validation/docs/Identical.md deleted file mode 100755 index 0a280678abbaa25cb0749d159cf47b5b117d7793..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Identical.md +++ /dev/null @@ -1,18 +0,0 @@ -# Identical - -- `v::identical(mixed $value)` - -Validates if the input is identical to some value. - -```php -v::identical(42)->validate(42); // true -v::identical(42)->validate('42'); // false -``` - -Message template for this validator includes `{{compareTo}}`. - -*** -See also: - - * [Contains](Contains.md) - * [Equals](Equals.md) diff --git a/vendor/respect/validation/docs/IdentityCard.md b/vendor/respect/validation/docs/IdentityCard.md deleted file mode 100755 index 052eca1a28fd616d8538eae8d56d50cc2042a729..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/IdentityCard.md +++ /dev/null @@ -1,21 +0,0 @@ -# IdentityCard - -- `v::identityCard(string $countryCode)` - -Validates Identity Card numbers according to the defined country. - -```php -v::identityCard('PL')->validate('AYW036733'); // true -v::identityCard('PL')->validate('APH505567'); // true -v::identityCard('PL')->validate('APH 505567'); // false -v::identityCard('PL')->validate('AYW036731'); // false -``` - -For now this rule only accepts Polish Identity Card numbers (Dowód Osobisty). - -*** -See also: - - * [Bank](Bank.md) - * [Pesel](Pesel.md) - * [SubdivisionCode](SubdivisionCode.md) diff --git a/vendor/respect/validation/docs/Image.md b/vendor/respect/validation/docs/Image.md deleted file mode 100755 index 5a84facf66d6e3f41314691b25d1fee0db21c383..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Image.md +++ /dev/null @@ -1,32 +0,0 @@ -# Image - -- `v::image()` -- `v::image(finfo $fileInfo)` - -Validates if the file is a valid image by checking its MIME type. - -```php -v::image()->validate('image.gif'); // true -v::image()->validate('image.jpg'); // true -v::image()->validate('image.png'); // true -``` - -All the validations above must return `false` if the input is not a valid file -or of the MIME doesn't match with the file extension. - -This rule relies on [fileinfo](http://php.net/fileinfo) PHP extension. - -*** -See also: - - * [Directory](Directory.md) - * [Executable](Executable.md) - * [Exists](Exists.md) - * [Extension](Extension.md) - * [File](File.md) - * [Mimetype](Mimetype.md) - * [Readable](Readable.md) - * [Size](Size.md) - * [SymbolicLink](SymbolicLink.md) - * [Uploaded](Uploaded.md) - * [Writable](Writable.md) diff --git a/vendor/respect/validation/docs/Imei.md b/vendor/respect/validation/docs/Imei.md deleted file mode 100755 index 96ed8e0a2a9fd0175165d0c7dd96bdee6ae8d76b..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Imei.md +++ /dev/null @@ -1,20 +0,0 @@ -# Imei - -- `v::imei()` - -Validates is the input is a valid [IMEI][]. - -```php -v::imei()->validate('35-209900-176148-1'); // true -v::imei()->validate('490154203237518'); // true -``` - -*** -See also: - - * [Bsn](Bsn.md) - * [Cnh](Cnh.md) - * [Cnpj](Cnpj.md) - * [Cpf](Cpf.md) - -[IMEI]: https://en.wikipedia.org/wiki/International_Mobile_Station_Equipment_Identity "International Mobile Station Equipment Identity" diff --git a/vendor/respect/validation/docs/In.md b/vendor/respect/validation/docs/In.md deleted file mode 100755 index a8aa698141b844e55c90845c8acdefca31f05ba1..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/In.md +++ /dev/null @@ -1,30 +0,0 @@ -# In - -- `v::in(mixed $haystack)` -- `v::in(mixed $haystack, boolean $identical = false)` - -Validates if the input is contained in a specific haystack. - -For strings: - -```php -v::in('lorem ipsum')->validate('ipsum'); // true -``` - -For arrays: - -```php -v::in(['lorem', 'ipsum'])->validate('lorem'); // true -``` - -A second parameter may be passed for identical comparison instead -of equal comparison. - -Message template for this validator includes `{{haystack}}`. - -*** -See also: - - * [StartsWith](StartsWith.md) - * [EndsWith](EndsWith.md) - * [Contains](Contains.md) diff --git a/vendor/respect/validation/docs/Infinite.md b/vendor/respect/validation/docs/Infinite.md deleted file mode 100755 index d29c666a4f11afd0ae697fca58c4c837705a72b1..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Infinite.md +++ /dev/null @@ -1,17 +0,0 @@ -# Infinite - -- `v::infinite()` - -Validates if the input is an infinite number. - -```php -v::infinite()->validate(INF); // true -``` - -*** -See also: - - * [Digit](Digit.md) - * [Finite](Finite.md) - * [IntVal](IntVal.md) - * [Numeric](Numeric.md) diff --git a/vendor/respect/validation/docs/Instance.md b/vendor/respect/validation/docs/Instance.md deleted file mode 100755 index bbb45dd0c888a24183525f1d9e539c59bbd3c8cf..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Instance.md +++ /dev/null @@ -1,17 +0,0 @@ -# Instance - -- `v::instance(string $instanceName)` - -Validates if the input is an instance of the given class or interface. - -```php -v::instance('DateTime')->validate(new DateTime); // true -v::instance('Traversable')->validate(new ArrayObject); // true -``` - -Message template for this validator includes `{{instanceName}}`. - -*** -See also: - - * [ObjectType](ObjectType.md) diff --git a/vendor/respect/validation/docs/IntType.md b/vendor/respect/validation/docs/IntType.md deleted file mode 100755 index d4313657fccba3df7b4c9c9a4fd95744a6d10950..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/IntType.md +++ /dev/null @@ -1,27 +0,0 @@ -# IntType - -- `v::intType()` - -Validates whether the type of a value is integer. - -```php -v::intType()->validate(42); // true -v::intType()->validate('10'); // false -``` - -*** -See also: - - * [BoolType](BoolType.md) - * [CallableType](CallableType.md) - * [Digit](Digit.md) - * [Finite](Finite.md) - * [FloatType](FloatType.md) - * [Infinite](Infinite.md) - * [IntVal](IntVal.md) - * [NullType](NullType.md) - * [Numeric](Numeric.md) - * [ObjectType](ObjectType.md) - * [ResourceType](ResourceType.md) - * [StringType](StringType.md) - * [Type](Type.md) diff --git a/vendor/respect/validation/docs/IntVal.md b/vendor/respect/validation/docs/IntVal.md deleted file mode 100755 index 18a04046192e8e3e6642d635d394946f16ec078f..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/IntVal.md +++ /dev/null @@ -1,18 +0,0 @@ -# IntVal - -- `v::intVal()` - -Validates if the input is an integer. - -```php -v::intVal()->validate('10'); // true -v::intVal()->validate(10); // true -``` - -*** -See also: - - * [Digit](Digit.md) - * [Finite](Finite.md) - * [Infinite](Infinite.md) - * [Numeric](Numeric.md) diff --git a/vendor/respect/validation/docs/Ip.md b/vendor/respect/validation/docs/Ip.md deleted file mode 100755 index 927dbc7ef618932495bd9e39f38e735675d27d43..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Ip.md +++ /dev/null @@ -1,24 +0,0 @@ -# Ip - -- `v::ip()` -- `v::ip(mixed $options)` - -Validates IP Addresses. This validator uses the native filter_var() -PHP function. - -```php -v::ip()->validate('192.168.0.1'); -``` - -You can pass a parameter with filter_var flags for IP. - -```php -v::ip(FILTER_FLAG_NO_PRIV_RANGE)->validate('127.0.0.1'); // false -``` - -*** -See also: - - * [Domain](Domain.md) - * [MacAddress](MacAddress.md) - * [Tld](Tld.md) diff --git a/vendor/respect/validation/docs/Iterable.md b/vendor/respect/validation/docs/Iterable.md deleted file mode 100755 index b64abe28899857ddec73717780d5e5acc4a4560c..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Iterable.md +++ /dev/null @@ -1,5 +0,0 @@ -# Iterable - -- `v::iterable()` - -**Deprecated**: Use [IterableType](IterableType.md) instead. diff --git a/vendor/respect/validation/docs/IterableType.md b/vendor/respect/validation/docs/IterableType.md deleted file mode 100755 index a246af271f9cba26a1b0dd538f1eb637e6056e14..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/IterableType.md +++ /dev/null @@ -1,20 +0,0 @@ -# IterableType - -- `v::iterableType()` - -Validates if the input is iterable, in other words, if you're able to iterate -over it with [foreach](http://php.net/foreach) language construct. - -```php -v::iterableType()->validate([]); // true -v::iterableType()->validate(new ArrayObject()); // true -v::iterableType()->validate(new stdClass()); // true -v::iterableType()->validate('string'); // false -``` - -*** -See also: - - * [ArrayVal](ArrayVal.md) - * [Countable](Countable.md) - * [Instance](Instance.md) diff --git a/vendor/respect/validation/docs/Json.md b/vendor/respect/validation/docs/Json.md deleted file mode 100755 index eb41367ceaf4ffe1b8060977dada30cad6981013..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Json.md +++ /dev/null @@ -1,18 +0,0 @@ -# Json - -- `v::json()` - -Validates if the given input is a valid JSON. - -```php -v::json()->validate('{"foo":"bar"}'); // true -``` - -*** -See also: - - * [Domain](Domain.md) - * [Email](Email.md) - * [FilterVar](FilterVar.md) - * [Phone](Phone.md) - * [VideoUrl](VideoUrl.md) diff --git a/vendor/respect/validation/docs/Key.md b/vendor/respect/validation/docs/Key.md deleted file mode 100755 index 70a74c07a5a2836c4879799cddfbae89d377a23a..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Key.md +++ /dev/null @@ -1,34 +0,0 @@ -# Key - -- `v::key(string $name)` -- `v::key(string $name, v $validator)` -- `v::key(string $name, v $validator, boolean $mandatory = true)` - -Validates an array key. - -```php -$dict = [ - 'foo' => 'bar' -]; - -v::key('foo')->validate($dict); // true -``` - -You can also validate the key value itself: - -```php -v::key('foo', v::equals('bar'))->validate($dict); // true -``` - -Third parameter makes the key presence optional: - -```php -v::key('lorem', v::stringType(), false)->validate($dict); // true -``` - -The name of this validator is automatically set to the key name. - -*** -See also: - - * [Attribute](Attribute.md) diff --git a/vendor/respect/validation/docs/KeyNested.md b/vendor/respect/validation/docs/KeyNested.md deleted file mode 100755 index 3129dde31c723082fab3332c9c0fa6a3ef81bd2e..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/KeyNested.md +++ /dev/null @@ -1,40 +0,0 @@ -# KeyNested - -- `v::keyNested(string $name)` -- `v::keyNested(string $name, v $validator)` -- `v::keyNested(string $name, v $validator, boolean $mandatory = true)` - -Validates an array key or an object property using `.` to represent nested data. - -Validating keys from arrays or `ArrayAccess` instances: - -```php -$array = [ - 'foo' => [ - 'bar' => 123, - ], -]; - -v::keyNested('foo.bar')->validate($array); // true -``` - -Validating object properties: - -```php -$object = new stdClass(); -$object->foo = new stdClass(); -$object->foo->bar = 42; - -v::keyNested('foo.bar')->validate($object); // true -``` - -This rule was inspired by [Yii2 ArrayHelper][]. - -*** -See also: - - * [Attribute](Attribute.md) - * [Key](Key.md) - - -[Yii2 ArrayHelper]: https://github.com/yiisoft/yii2/blob/68c30c1/framework/helpers/BaseArrayHelper.php "Yii2 ArrayHelper" diff --git a/vendor/respect/validation/docs/KeySet.md b/vendor/respect/validation/docs/KeySet.md deleted file mode 100755 index faf40818aafbd384335127681e039e5c744ce1dc..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/KeySet.md +++ /dev/null @@ -1,51 +0,0 @@ -# KeySet - -- `v::keySet(Key $rule...)` - -Validates a keys in a defined structure. - -```php -$dict = ['foo' => 42]; - -v::keySet( - v::key('foo', v::intVal()) -)->validate($dict); // true -``` - -Extra keys are not allowed: -```php -$dict = ['foo' => 42, 'bar' => 'String']; - -v::keySet( - v::key('foo', v::intVal()) -)->validate($dict); // false -``` - -Missing required keys are not allowed: -```php -$dict = ['foo' => 42, 'bar' => 'String']; - -v::keySet( - v::key('foo', v::intVal()), - v::key('bar', v::stringType()), - v::key('baz', v::boolType()) -)->validate($dict); // false -``` - -Missing non-required keys are allowed: -```php -$dict = ['foo' => 42, 'bar' => 'String']; - -v::keySet( - v::key('foo', v::intVal()), - v::key('bar', v::stringType()), - v::key('baz', v::boolType(), false) -)->validate($dict); // true -``` - -The keys' order is not considered in the validation. - -*** -See also: - - * [Key](Key.md) diff --git a/vendor/respect/validation/docs/KeyValue.md b/vendor/respect/validation/docs/KeyValue.md deleted file mode 100755 index 98ee9db8731581b6fbda57e80f05742a5e4b4b0c..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/KeyValue.md +++ /dev/null @@ -1,62 +0,0 @@ -# KeyValue - -- `keyValue(string $comparedKey, string $ruleName, string $baseKey)` - -Performs validation of `$comparedKey` using the rule named on `$ruleName` with -`$baseKey` as base. - -Sometimes, when validating arrays, the validation of a key value depends on -another key value and that may cause some ugly code since you need the input -before the validation, making some checking manually: - -```php -v::key('password')->check($_POST); -v::key('password_confirmation', v::equals($_POST['password']))->check($_POST); -``` - -The problem with the above code is because you do not know if `password` is a -valid key, so you must check it manually before performing the validation on -`password_confirmation`. - -The `keyValue()` rule makes this job easier by creating a rule named on -`$ruleName` passing `$baseKey` as the first argument of this rule, see an example: - -```php -v::keyValue('password_confirmation', 'equals', 'password')->validate($_POST); -``` - -The above code will result on `true` if _`$_POST['password_confirmation']` is -[equals](Equals.md) to `$_POST['password']`_, it's the same of: - -See another example: - -```php -v::keyValue('state', 'subdivisionCode', 'country')->validate($_POST); -``` - -The above code will result on `true` if _`$_POST['state']` is a -[subdivision code](SubdivisionCode.md) of `$_POST['country']`_: - -This rule will invalidate the input if `$comparedKey` or `$baseKey` don't exist, -or if the rule named on `$ruleName` could not be created (or don't exist). - -When using `assert()` or `check()` methods and the rule do not pass, it overwrites -all values in the validation exceptions with `$baseKey` and `$comparedKey`. - -```php -v::keyValue('password_confirmation', 'equals', 'password')->check($input); -``` - -The above code may generate the message: - -``` -password_confirmation must be equals "password" -``` - -*** -See also: - - * [Key](Key.md) - * [KeyNested](KeyNested.md) - * [KeySet](KeySet.md) - diff --git a/vendor/respect/validation/docs/LanguageCode.md b/vendor/respect/validation/docs/LanguageCode.md deleted file mode 100755 index a990f315a9a6f8d8b5261bfeab954fa5890a1bed..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/LanguageCode.md +++ /dev/null @@ -1,20 +0,0 @@ -# LanguageCode - -- `v::languageCode()` - -Validates a language code based on ISO 639: - -```php -v::languageCode()->validate('pt'); // true -v::languageCode()->validate('en'); // true -v::languageCode()->validate('it'); // true -v::languageCode('alpha-3')->validate('ita'); // true -v::languageCode('alpha-3')->validate('eng'); // true -``` - -You can choose between alpha-2 and alpha-3, alpha-2 is set by default. - -*** -See also: - - * [CountryCode](CountryCode.md) \ No newline at end of file diff --git a/vendor/respect/validation/docs/LeapDate.md b/vendor/respect/validation/docs/LeapDate.md deleted file mode 100755 index aa0e7581f7ab4207e3f863dcd14a6c800cd5bd14..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/LeapDate.md +++ /dev/null @@ -1,18 +0,0 @@ -# LeapDate - -- `v::leapDate(string $format)` - -Validates if a date is leap. - -```php -v::leapDate('Y-m-d')->validate('1988-02-29'); // true -``` - -This validator accepts DateTime instances as well. The $format -parameter is mandatory. - -*** -See also: - - * [Date](Date.md) - * [LeapYear](LeapYear.md) diff --git a/vendor/respect/validation/docs/LeapYear.md b/vendor/respect/validation/docs/LeapYear.md deleted file mode 100755 index db208993164f717ab648968850f78013a8794f74..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/LeapYear.md +++ /dev/null @@ -1,17 +0,0 @@ -# LeapYear - -- `v::leapYear()` - -Validates if a year is leap. - -```php -v::leapYear()->validate('1988'); // true -``` - -This validator accepts DateTime instances as well. - -*** -See also: - - * [Date](Date.md) - * [LeapDate](LeapDate.md) diff --git a/vendor/respect/validation/docs/Length.md b/vendor/respect/validation/docs/Length.md deleted file mode 100755 index 2fbf519536b85d41e705750ef6d05b57d0d59645..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Length.md +++ /dev/null @@ -1,44 +0,0 @@ -# Length - -- `v::length(int $min, int $max)` -- `v::length(int $min, null)` -- `v::length(null, int $max)` -- `v::length(int $min, int $max, boolean $inclusive = true)` - -Validates lengths. Most simple example: - -```php -v::stringType()->length(1, 5)->validate('abc'); // true -``` - -You can also validate only minimum length: - -```php -v::stringType()->length(5, null)->validate('abcdef'); // true -``` - -Only maximum length: - -```php -v::stringType()->length(null, 5)->validate('abc'); // true -``` - -The type as the first validator in a chain is a good practice, -since length accepts many types: - -```php -v::arrayVal()->length(1, 5)->validate(['foo', 'bar']); // true -``` - -A third parameter may be passed to validate the passed values inclusive: - -```php -v::stringType()->length(1, 5, true)->validate('a'); // true -``` - -Message template for this validator includes `{{minValue}}` and `{{maxValue}}`. - -*** -See also: - - * [Between](Between.md) diff --git a/vendor/respect/validation/docs/Lowercase.md b/vendor/respect/validation/docs/Lowercase.md deleted file mode 100755 index a79f82b76fdb91a36d71b1ceffa09daa00ea1b07..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Lowercase.md +++ /dev/null @@ -1,14 +0,0 @@ -# Lowercase - -- `v::lowercase()` - -Validates if string characters are lowercase in the input: - -```php -v::stringType()->lowercase()->validate('xkcd'); // true -``` - -*** -See also: - - * [Uppercase](Uppercase.md) diff --git a/vendor/respect/validation/docs/MacAddress.md b/vendor/respect/validation/docs/MacAddress.md deleted file mode 100755 index 92f427af302b90114e4c6705be4687b1c87a3c29..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/MacAddress.md +++ /dev/null @@ -1,17 +0,0 @@ -# MacAddress - -- `v::macAddress()` - -Validates a Mac Address. - -```php -v::macAddress()->validate('00:11:22:33:44:55'); // true -v::macAddress()->validate('af-AA-22-33-44-55'); // true -``` - -*** -See also: - - * [Domain](Domain.md) - * [Ip](Ip.md) - * [Tld](Tld.md) diff --git a/vendor/respect/validation/docs/Max.md b/vendor/respect/validation/docs/Max.md deleted file mode 100755 index 1c199b9497ad9067e2241117fbc8893543443996..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Max.md +++ /dev/null @@ -1,36 +0,0 @@ -# Max - -- `v::max(mixed $maxValue)` -- `v::max(mixed $maxValue, boolean $inclusive = true)` - -Validates if the input doesn't exceed the maximum value. - -```php -v::intVal()->max(15)->validate(20); // false -v::intVal()->max(20)->validate(20); // false -v::intVal()->max(20, true)->validate(20); // true -``` - -Also accepts dates: - -```php -v::date()->max('2012-01-01')->validate('2010-01-01'); // true -``` - -Also date intervals: - -```php -// Same of minimum age validation -v::date()->max('-18 years')->validate('1988-09-09'); // true -``` - -`true` may be passed as a parameter to indicate that inclusive -values must be used. - -Message template for this validator includes `{{maxValue}}`. - -*** -See also: - - * [Min](Min.md) - * [Between](Between.md) diff --git a/vendor/respect/validation/docs/Mimetype.md b/vendor/respect/validation/docs/Mimetype.md deleted file mode 100755 index a2af05e8c74aec337944d3a1566a5a050ba822b4..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Mimetype.md +++ /dev/null @@ -1,25 +0,0 @@ -# Mimetype - -- `v::mimetype(string $mimetype)` - -Validates if the file mimetype matches the expected one: - -```php -v::mimetype('image/png')->validate('image.png'); // true -``` - -This rule is case-sensitive and requires [fileinfo](http://php.net/fileinfo) PHP extension. - -*** -See also: - - * [Directory](Directory.md) - * [Executable](Executable.md) - * [Exists](Exists.md) - * [Extension](Extension.md) - * [File](File.md) - * [Readable](Readable.md) - * [Size](Size.md) - * [SymbolicLink](SymbolicLink.md) - * [Uploaded](Uploaded.md) - * [Writable](Writable.md) diff --git a/vendor/respect/validation/docs/Min.md b/vendor/respect/validation/docs/Min.md deleted file mode 100755 index 460154f25f8435fe489caff1681dd0c1ee49ce37..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Min.md +++ /dev/null @@ -1,29 +0,0 @@ -# Min - -- `v::min(mixed $minValue)` -- `v::min(mixed $minValue, boolean $inclusive = true)` - -Validates if the input is greater than the minimum value. - -```php -v::intVal()->min(15)->validate(5); // false -v::intVal()->min(5)->validate(5); // false -v::intVal()->min(5, true)->validate(5); // true -``` - -Also accepts dates: - -```php -v::date()->min('2012-01-01')->validate('2015-01-01'); // true -``` - -`true` may be passed as a parameter to indicate that inclusive -values must be used. - -Message template for this validator includes `{{minValue}}`. - -*** -See also: - - * [Max](Max.md) - * [Between](Between.md) diff --git a/vendor/respect/validation/docs/MinimumAge.md b/vendor/respect/validation/docs/MinimumAge.md deleted file mode 100755 index 33b457ae0b0ad2d3b34288a56569dee05e6e6188..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/MinimumAge.md +++ /dev/null @@ -1,23 +0,0 @@ -# MinimumAge - -This is going to be deprecated, please use [Age](Age.md) instead. - -- `v::minimumAge(int $age)` -- `v::minimumAge(int $age, string $format)` - -Validates a minimum age for a given date. - -```php -v::minimumAge(18)->validate('1987-01-01'); // true -v::minimumAge(18, 'd/m/Y')->validate('01/01/1987'); // true -``` - -Using `date()` before is a best-practice. - -Message template for this validator includes `{{age}}`. - -*** -See also: - - * [Age](Age.md) - * [Date](Date.md) diff --git a/vendor/respect/validation/docs/Multiple.md b/vendor/respect/validation/docs/Multiple.md deleted file mode 100755 index b6d8c7ff02ce91038d3b57c4abff84308cacc737..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Multiple.md +++ /dev/null @@ -1,14 +0,0 @@ -# Multiple - -- `v::multiple(int $multipleOf)` - -Validates if the input is a multiple of the given parameter - -```php -v::intVal()->multiple(3)->validate(9); // true -``` - -*** -See also: - - * [PrimeNumber](PrimeNumber.md) diff --git a/vendor/respect/validation/docs/Negative.md b/vendor/respect/validation/docs/Negative.md deleted file mode 100755 index efecb52018b0763c49d61deec12b3f45b1bbec7c..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Negative.md +++ /dev/null @@ -1,14 +0,0 @@ -# Negative - -- `v::negative()` - -Validates if a number is lower than zero - -```php -v::numeric()->negative()->validate(-15); // true -``` - -*** -See also: - - * [Positive](Positive.md) diff --git a/vendor/respect/validation/docs/NfeAccessKey.md b/vendor/respect/validation/docs/NfeAccessKey.md deleted file mode 100755 index 2f9188f1b0ce52d960b4ef30f58dd17b203c6d61..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/NfeAccessKey.md +++ /dev/null @@ -1,16 +0,0 @@ -# NfeAccessKey - -- `v::nfeAccessKey(string $accessKey)` - -Validates the access key of the Brazilian electronic invoice (NFe). - -```php -v::nfeAccessKey()->validate('31841136830118868211870485416765268625116906'); // true -``` - -*** -See also: - - * [Cnh](Cnh.md) - * [Cnpj](Cnpj.md) - * [Cpf](Cpf.md) diff --git a/vendor/respect/validation/docs/No.md b/vendor/respect/validation/docs/No.md deleted file mode 100755 index e50b4c72becd343ad8682869488b9522d8fd456f..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/No.md +++ /dev/null @@ -1,24 +0,0 @@ -# No - -- `v::no()` -- `v::no(boolean $locale)` - -Validates if value is considered as "No". - -```php -v::no()->validate('N'); // true -v::no()->validate('Nay'); // true -v::no()->validate('Nix'); // true -v::no()->validate('No'); // true -v::no()->validate('Nope'); // true -v::no()->validate('Not'); // true -``` - -This rule is case insensitive. - -If `$locale` is TRUE, uses the value of [nl_langinfo()](http://php.net/nl_langinfo) with `NOEXPR` constant. - -*** -See also: - - * [Yes](Yes.md) diff --git a/vendor/respect/validation/docs/NoWhitespace.md b/vendor/respect/validation/docs/NoWhitespace.md deleted file mode 100755 index 052cfcdee028d66c24fe55bb1b6bce6ee64e7a27..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/NoWhitespace.md +++ /dev/null @@ -1,21 +0,0 @@ -# NoWhitespace - -- `v::noWhitespace()` - -Validates if a string contains no whitespace (spaces, tabs and line breaks); - -```php -v::noWhitespace()->validate('foo bar'); //false -v::noWhitespace()->validate("foo\nbar"); // false -``` - -This is most useful when chaining with other validators such as `v::alnum()` - -*** -See also: - - * [Alnum](Alnum.md) - * [Alpha](Alpha.md) - * [NotBlank](NotBlank.md) - * [NotEmpty](NotEmpty.md) - * [NotOptional](NotOptional.md) diff --git a/vendor/respect/validation/docs/NoneOf.md b/vendor/respect/validation/docs/NoneOf.md deleted file mode 100755 index 44e91537e8754135bf7f3a0400e0d5259d036188..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/NoneOf.md +++ /dev/null @@ -1,21 +0,0 @@ -# NoneOf - -- `v::noneOf(v $v1, v $v2, v $v3...)` - -Validates if NONE of the given validators validate: - -```php -v::noneOf( - v::intVal(), - v::floatVal() -)->validate('foo'); // true -``` - -In the sample above, 'foo' isn't a integer nor a float, so noneOf returns true. - -*** -See also: - - * [Not](Not.md) - * [AllOf](AllOf.md) - * [OneOf](OneOf.md) diff --git a/vendor/respect/validation/docs/Not.md b/vendor/respect/validation/docs/Not.md deleted file mode 100755 index 31f575bca1748ce768a9dbc54e4b9ed4d7d7e4c3..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Not.md +++ /dev/null @@ -1,24 +0,0 @@ -# Not - -- `v::not(v $negatedValidator)` - -Negates any rule. - -```php -v::not(v::ip())->validate('foo'); // true -``` - -In the sample above, validator returns true because 'foo' isn't an IP Address. - -You can negate complex, grouped or chained validators as well: - -```php -v::not(v::intVal()->positive())->validate(-1.5); // true -``` - -Each other validation has custom messages for negated rules. - -*** -See also: - - * [NoneOf](NoneOf.md) diff --git a/vendor/respect/validation/docs/NotBlank.md b/vendor/respect/validation/docs/NotBlank.md deleted file mode 100755 index 35a5ef2de273e29918c98c4a743603b026ffd3ca..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/NotBlank.md +++ /dev/null @@ -1,34 +0,0 @@ -# NotBlank - -- `v::notBlank()` - -Validates if the given input is not a blank value (`null`, zeros, empty strings -or empty arrays, recursively). - -```php -v::notBlank()->validate(null); // false -v::notBlank()->validate(''); // false -v::notBlank()->validate([]); // false -v::notBlank()->validate(' '); // false -v::notBlank()->validate(0); // false -v::notBlank()->validate('0'); // false -v::notBlank()->validate(0); // false -v::notBlank()->validate('0.0'); // false -v::notBlank()->validate(false); // false -v::notBlank()->validate(['']); // false -v::notBlank()->validate([' ']); // false -v::notBlank()->validate([0]); // false -v::notBlank()->validate(['0']); // false -v::notBlank()->validate([false]); // false -v::notBlank()->validate([[''], [0]]); // false -v::notBlank()->validate(new stdClass()); // false -``` - -It's similar to [NotEmpty](NotEmpty.md) but it's way more strict. - -*** -See also: - - * [NoWhitespace](NoWhitespace.md) - * [NotEmpty](NotEmpty.md) - * [NullType](NullType.md) diff --git a/vendor/respect/validation/docs/NotEmpty.md b/vendor/respect/validation/docs/NotEmpty.md deleted file mode 100755 index ab888f6a641664ad296b7de9cb616c4421500f08..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/NotEmpty.md +++ /dev/null @@ -1,42 +0,0 @@ -# NotEmpty - -- `v::notEmpty()` - -Validates if the given input is not empty or in other words is input mandatory and -required. This function also takes whitespace into account, use `noWhitespace()` -if no spaces or linebreaks and other whitespace anywhere in the input is desired. - -```php -v::stringType()->notEmpty()->validate(''); // false -``` - -Null values are empty: - -```php -v::notEmpty()->validate(null); // false -``` - -Numbers: - -```php -v::intVal()->notEmpty()->validate(0); // false -``` - -Empty arrays: - -```php -v::arrayVal()->notEmpty()->validate([]); // false -``` - -Whitespace: - -```php -v::stringType()->notEmpty()->validate(' '); //false -v::stringType()->notEmpty()->validate("\t \n \r"); //false -``` - -*** -See also: - - * [NoWhitespace](NoWhitespace.md) - * [NullType](NullType.md) diff --git a/vendor/respect/validation/docs/NotOptional.md b/vendor/respect/validation/docs/NotOptional.md deleted file mode 100755 index 487e7f1ef253ff82ead7b3f150f7c07a3163209b..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/NotOptional.md +++ /dev/null @@ -1,39 +0,0 @@ -# NotOptional - -- `v::notOptional()` - -Validates if the given input is not optional. By _optional_ we consider `null` -or an empty string (`''`). - -```php -v::notOptional()->validate(''); // false -v::notOptional()->validate(null); // false -``` - -Other values: - -```php -v::notOptional()->validate([]); // true -v::notOptional()->validate(' '); // true -v::notOptional()->validate(0); // true -v::notOptional()->validate('0'); // true -v::notOptional()->validate(0); // true -v::notOptional()->validate('0.0'); // true -v::notOptional()->validate(false); // true -v::notOptional()->validate(['']); // true -v::notOptional()->validate([' ']); // true -v::notOptional()->validate([0]); // true -v::notOptional()->validate(['0']); // true -v::notOptional()->validate([false]); // true -v::notOptional()->validate([[''), [0]]); // true -v::notOptional()->validate(new stdClass()); // true -``` - -*** -See also: - - * [NoWhitespace](NoWhitespace.md) - * [NotBlank](NotBlank.md) - * [NotEmpty](NotEmpty.md) - * [NullType](NullType.md) - * [Optional](Optional.md) diff --git a/vendor/respect/validation/docs/NullType.md b/vendor/respect/validation/docs/NullType.md deleted file mode 100755 index 5b39feb6c2d0eb36a964fc982d2fcd58aa73cea8..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/NullType.md +++ /dev/null @@ -1,25 +0,0 @@ -# NullType - -- `v::nullType()` - -Validates if the input is null. - -```php -v::nullType()->validate(null); // true -``` - -*** -See also: - - * [BoolType](BoolType.md) - * [CallableType](CallableType.md) - * [FloatType](FloatType.md) - * [IntType](IntType.md) - * [NotBlank](NotBlank.md) - * [NotEmpty](NotEmpty.md) - * [NotOptional](NotOptional.md) - * [NullType](NullType.md) - * [ObjectType](ObjectType.md) - * [ResourceType](ResourceType.md) - * [StringType](StringType.md) - * [Type](Type.md) diff --git a/vendor/respect/validation/docs/Numeric.md b/vendor/respect/validation/docs/Numeric.md deleted file mode 100755 index d8121fb61c9ae621e4ebe74b45b80853e5c95721..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Numeric.md +++ /dev/null @@ -1,18 +0,0 @@ -# Numeric - -- `v::numeric()` - -Validates on any numeric value. - -```php -v::numeric()->validate(-12); // true -v::numeric()->validate('135.0'); // true -``` - -*** -See also: - - * [Digit](Digit.md) - * [Finite](Finite.md) - * [Infinite](Infinite.md) - * [IntVal](IntVal.md) diff --git a/vendor/respect/validation/docs/ObjectType.md b/vendor/respect/validation/docs/ObjectType.md deleted file mode 100755 index 39212603155048570ca891161b495f1f8f41792c..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/ObjectType.md +++ /dev/null @@ -1,24 +0,0 @@ -# ObjectType - -- `v::objectType()` - -Validates if the input is an object. - -```php -v::objectType()->validate(new stdClass); // true -``` - -*** -See also: - - * [Attribute](Attribute.md) - * [BoolType](BoolType.md) - * [CallableType](CallableType.md) - * [FloatType](FloatType.md) - * [Instance](Instance.md) - * [IntType](IntType.md) - * [NullType](NullType.md) - * [ObjectType](ObjectType.md) - * [ResourceType](ResourceType.md) - * [StringType](StringType.md) - * [Type](Type.md) diff --git a/vendor/respect/validation/docs/Odd.md b/vendor/respect/validation/docs/Odd.md deleted file mode 100755 index b1a8d05fc978f94cd5e074288b5988969c161868..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Odd.md +++ /dev/null @@ -1,17 +0,0 @@ -# Odd - -- `v::odd()` - -Validates an odd number. - -```php -v::intVal()->odd()->validate(3); // true -``` - -Using `int()` before `odd()` is a best practice. - -*** -See also: - - * [Even](Even.md) - * [Multiple](Multiple.md) diff --git a/vendor/respect/validation/docs/OneOf.md b/vendor/respect/validation/docs/OneOf.md deleted file mode 100755 index e16be50df043ad94aa622584da26a71746077ee0..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/OneOf.md +++ /dev/null @@ -1,25 +0,0 @@ -# OneOf - -- `v::oneOf(v $v1, v $v2, v $v3...)` - -This is a group validator that acts as an OR operator. - -```php -v::oneOf( - v::intVal(), - v::floatVal() -)->validate(15.5); // true -``` - -In the sample above, `v::intVal()` doesn't validates, but -`v::floatVal()` validates, so oneOf returns true. - -`v::oneOf` returns true if at least one inner validator -passes. - -*** -See also: - - * [AllOf](AllOf.md) - * [NoneOf](NoneOf.md) - * [When](When.md) diff --git a/vendor/respect/validation/docs/Optional.md b/vendor/respect/validation/docs/Optional.md deleted file mode 100755 index 1a4aa5ec091f9731c70ae017489abc01c6424de1..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Optional.md +++ /dev/null @@ -1,21 +0,0 @@ -# Optional - -- `v::optional(v $rule)` - -Validates if the given input is optional or not. By _optional_ we consider `null` -or an empty string (`''`). - -```php -v::optional(v::alpha())->validate(''); // true -v::optional(v::digit())->validate(null); // true -``` - - -*** -See also: - - * [NoWhitespace](NoWhitespace.md) - * [NotBlank](NotBlank.md) - * [NotEmpty](NotEmpty.md) - * [NotOptional](NotOptional.md) - * [NullType](NullType.md) diff --git a/vendor/respect/validation/docs/PerfectSquare.md b/vendor/respect/validation/docs/PerfectSquare.md deleted file mode 100755 index 3a344b27c9125bd28f0ac6afc1fa8b3d485d372b..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/PerfectSquare.md +++ /dev/null @@ -1,16 +0,0 @@ -# PerfectSquare - -- `v::perfectSquare()` - -Validates a perfect square. - -```php -v::perfectSquare()->validate(25); // true (5*5) -v::perfectSquare()->validate(9); // true (3*3) -``` - -*** -See also: - - * [Factor](Factor.md) - * [PrimeNumber](PrimeNumber.md) diff --git a/vendor/respect/validation/docs/Pesel.md b/vendor/respect/validation/docs/Pesel.md deleted file mode 100755 index 275ff7f8d3117304f091e08f9b3424aff30cbf65..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Pesel.md +++ /dev/null @@ -1,12 +0,0 @@ -# Pesel - -- `v::pesel()` - -Validates PESEL (Polish human identification number). - -```php -v::pesel()->validate('21120209256'); // true -v::pesel()->validate('97072704800'); // true -v::pesel()->validate('97072704801'); // false -v::pesel()->validate('PESEL123456'); // false -``` diff --git a/vendor/respect/validation/docs/Phone.md b/vendor/respect/validation/docs/Phone.md deleted file mode 100755 index ac3cba9b9582c7192467e65376d4c0e7dd8b0899..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Phone.md +++ /dev/null @@ -1,22 +0,0 @@ -# Phone - -- `v::phone()` - -Validates a valid 7, 10, 11 digit phone number (North America, Europe and most -Asian and Middle East countries), supporting country and area codes (in dot, -space or dashed notations) such as: - - (555)555-5555 - 555 555 5555 - +5(555)555.5555 - 33(1)22 22 22 22 - +33(1)22 22 22 22 - +33(020)7777 7777 - 03-6106666 - -*** -See also: - - * [Email](Email.md) - * [Url](Url.md) - * [VideoUrl](VideoUrl.md) diff --git a/vendor/respect/validation/docs/PhpLabel.md b/vendor/respect/validation/docs/PhpLabel.md deleted file mode 100755 index 4295267d72fb63767b02985ce2fd2f4479226e43..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/PhpLabel.md +++ /dev/null @@ -1,24 +0,0 @@ -# PhpLabel - -- `v::phpLabel()` - -Validates if a value is considered a valid PHP Label, -so that it can be used as a *variable*, *function* or *class* name, for example. - -Reference: -http://php.net/manual/en/language.variables.basics.php - -```php -v::phpLabel()->validate('person'); //true -v::phpLabel()->validate('foo'); //true -v::phpLabel()->validate('4ccess'); //false -``` - -*** -See also: - - * [Regex](Regex.md) - * [ResourceType](ResourceType.md) - * [Slug](Slug.md) - * [Charset](Charset.md) - \ No newline at end of file diff --git a/vendor/respect/validation/docs/Positive.md b/vendor/respect/validation/docs/Positive.md deleted file mode 100755 index ecf75d9f00fd536907b1e56462fda4f184920501..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Positive.md +++ /dev/null @@ -1,14 +0,0 @@ -# Positive - -- `v::positive()` - -Validates if a number is higher than zero - -```php -v::numeric()->positive()->validate(-15); // false -``` - -*** -See also: - - * [Negative](Negative.md) diff --git a/vendor/respect/validation/docs/PostalCode.md b/vendor/respect/validation/docs/PostalCode.md deleted file mode 100755 index c18ec96ede6a146bddb14f0c964cb95b278a4670..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/PostalCode.md +++ /dev/null @@ -1,22 +0,0 @@ -# PostalCode - -- `v::postalCode(string $countryCode)` - -Validates a postal code according to the given country code. - -```php -v::postalCode('BR')->validate('02179000'); // true -v::postalCode('BR')->validate('02179-000'); // true -v::postalCode('US')->validate('02179-000'); // false -v::postalCode('US')->validate('55372'); // true -v::postalCode('PL')->validate('99-300'); // true -``` - -Message template for this validator includes `{{countryCode}}`. - -Extracted from [GeoNames](http://www.geonames.org/). - -*** -See also: - - * [CountryCode](CountryCode.md) diff --git a/vendor/respect/validation/docs/PrimeNumber.md b/vendor/respect/validation/docs/PrimeNumber.md deleted file mode 100755 index dee58eabd4c93b89b4e351fd856d9608beeddfa6..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/PrimeNumber.md +++ /dev/null @@ -1,16 +0,0 @@ -# PrimeNumber - -- `v::primeNumber()` - -Validates a prime number - -```php -v::primeNumber()->validate(7); // true -``` - -*** -See also: - - * [Factor](Factor.md) - * [PerfectSquare](PerfectSquare.md) - * [PrimeNumber](PrimeNumber.md) diff --git a/vendor/respect/validation/docs/Prnt.md b/vendor/respect/validation/docs/Prnt.md deleted file mode 100755 index 29dc6d76397b0d52e1cb0b8a269d4f4395952913..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Prnt.md +++ /dev/null @@ -1,15 +0,0 @@ -# Prnt - -- `v::prnt()` -- `v::prnt(string $additionalChars)` - -Similar to `v::graph` but accepts whitespace. - -```php -v::prnt()->validate('LMKA0$% _123'); // true -``` - -*** -See also: - - * [Graph](Graph.md) diff --git a/vendor/respect/validation/docs/Punct.md b/vendor/respect/validation/docs/Punct.md deleted file mode 100755 index d49411aa90978c85ffe136eb0afdf574dc985fd5..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Punct.md +++ /dev/null @@ -1,17 +0,0 @@ -# Punct - -- `v::punct()` -- `v::punct(string $additionalChars)` - -Accepts only punctuation characters: - -```php -v::punct()->validate('&,.;[]'); // true -``` - -*** -See also: - - * [Cntrl](Cntrl.md) - * [Graph](Graph.md) - * [Prnt](Prnt.md) diff --git a/vendor/respect/validation/docs/README.md b/vendor/respect/validation/docs/README.md deleted file mode 100755 index abd573aaff56a3aae4a2660f92ac9c3f62c8ac88..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/README.md +++ /dev/null @@ -1,310 +0,0 @@ -# Feature Guide - -## Namespace import - -Respect\Validation is namespaced, but you can make your life easier by importing -a single class into your context: - -```php -use Respect\Validation\Validator as v; -``` - -## Simple validation - -The Hello World validator is something like this: - -```php -$number = 123; -v::numeric()->validate($number); // true -``` - -## Chained validation - -It is possible to use validators in a chain. Sample below validates a string -containing numbers and letters, no whitespace and length between 1 and 15. - -```php -$usernameValidator = v::alnum()->noWhitespace()->length(1, 15); -$usernameValidator->validate('alganet'); // true -``` - -## Validating object attributes - -Given this simple object: - -```php -$user = new stdClass; -$user->name = 'Alexandre'; -$user->birthdate = '1987-07-01'; -``` - -Is possible to validate its attributes in a single chain: - -```php -$userValidator = v::attribute('name', v::stringType()->length(1,32)) - ->attribute('birthdate', v::date()->age(18)); - -$userValidator->validate($user); // true -``` - -Validating array keys is also possible using `v::key()` - -Note that we used `v::stringType()` and `v::date()` in the beginning of the validator. -Although is not mandatory, it is a good practice to use the type of the -validated object as the first node in the chain. - -## Input optional - -On oldest versions of Respect\Validation all validators treat input as optional -and accept an empty string input as valid. Even though a useful feature that -caused a lot of troubles for our team and neither was an obvious behavior. Also -there was some people who likes to accept `null` as optional value, not only an -empty string. - -For that reason all rules are mandatory now but if you want to treat a value as -optional you can use `v::optional()` rule: - -```php -v::alpha()->validate(''); // false input required -v::alpha()->validate(null); // false input required - -v::optional(v::alpha())->validate(''); // true -v::optional(v::alpha())->validate(null); // true -``` - -By _optional_ we consider `null` or an empty string (`''`). - -See more on [Optional](Optional.md). - -## Negating rules - -You can use the `v::not()` to negate any rule: - -```php -v::not(v::intVal())->validate(10); // false, input must not be integer -``` - -## Validator reuse - -Once created, you can reuse your validator anywhere. Remember `$usernameValidator`? - -```php -$usernameValidator->validate('respect'); //true -$usernameValidator->validate('alexandre gaigalas'); // false -$usernameValidator->validate('#$%'); //false -``` - -## Exception types - -* `Respect\Validation\Exceptions\ExceptionInterface`: - * All exceptions implement this interface; -* `Respect\Validation\Exceptions\ValidationException`: - * Implements the `Respect\Validation\Exceptions\ExceptionInterface` interface - * Thrown when the `check()` fails - * All validation exceptions extend this class - * Available methods: - * `getMainMessage()`; - * `setMode($mode)`; - * `setName($name)`; - * `setParam($name, $value)`; - * `setTemplate($template)`; - * more... -* `Respect\Validation\Exceptions\NestedValidationException`: - * Extends the `Respect\Validation\Exceptions\ValidationException` class - * Usually thrown when the `assert()` fails - * Available methods: - * `findMessages()`; - * `getFullMessage()`; - * `getMessages()`; - * more... - -## Informative exceptions - -When something goes wrong, Validation can tell you exactly what's going on. For this, -we use the `assert()` method instead of `validate()`: - -```php -use Respect\Validation\Exceptions\NestedValidationException; - -try { - $usernameValidator->assert('really messed up screen#name'); -} catch(NestedValidationException $exception) { - echo $exception->getFullMessage(); -} -``` - -The printed message is exactly this, as a nested Markdown list: - -```no-highlight -- All of the required rules must pass for "really messed up screen#name" - - "really messed up screen#name" must contain only letters (a-z) and digits (0-9) - - "really messed up screen#name" must not contain whitespace - - "really messed up screen#name" must have a length between 1 and 15 -``` - -## Getting all messages as an array - -The Markdown list is fine, but unusable on a HTML form or something more custom. -For that you can use `getMessages()`. - -It will return all messages from the rules that did not pass the validation. - -```php -try { - $usernameValidator->assert('really messed up screen#name'); -} catch(NestedValidationException $exception) { - print_r($exception->getMessages()); -} -``` - -The code above may display something like: - -```no-highlight -Array -( - [0] => "really messed up screen#name" must contain only letters (a-z) and digits (0-9) - [1] => "really messed up screen#name" must not contain whitespace - [2] => "really messed up screen#name" must have a length between 1 and 15 -) -``` - -## Getting messages as an array by name - -If you want to get specific message by name you can use `findMessages()` passing -the names of the rules you want: - -```php -try { - $usernameValidator->assert('really messed up screen#name'); -} catch(NestedValidationException $exception) { - print_r($exception->findMessages(['alnum', 'noWhitespace'])); -} -``` - -The `findMessages()` returns an array with messages from the requested validators, -like this: - -```no-highlight -Array -( - [alnum] => "really messed up screen#name" must contain only letters (a-z) and digits (0-9) - [noWhitespace] => "really messed up screen#name" must not contain whitespace -) -``` - -## Custom messages - -Getting messages as an array is fine, but sometimes you need to customize them in order -to present them to the user. This is possible using the `findMessages()` method as well: - -```php -$errors = $exception->findMessages([ - 'alnum' => '{{name}} must contain only letters and digits', - 'length' => '{{name}} must not have more than 15 chars', - 'noWhitespace' => '{{name}} cannot contain spaces' -]); -``` - -For all messages, the `{{name}}` variable is available for templates. If you -do not define a name it uses the input to replace this placeholder. - -## Message localization - -You're also able to translate your message to another language with Validation. -The only thing one must do is to define the param `translator` as a callable that -will handle the translation: - -```php -$exception->setParam('translator', 'gettext'); -``` - -The example above uses `gettext()` but you can use any other callable value, like -`[$translator, 'trans']` or `you_custom_function()`. - -After that, if you call `getMainMessage()` or `getFullMessage()` (for nested), -the message will be translated. - -Note that `getMessage()` will keep the original message. - -## Custom rules - -You also can use your own rules: - -```php -namespace My\Validation\Rules; - -use Respect\Validation\Rules\AbstractRule; - -class MyRule extends AbstractRule -{ - public function validate($input) - { - // Do something here with the $input and return a boolean value - } -} -``` - -If you do want Validation to execute you rule (or rules) in the chain, you must -use `v::with()` passing your rule's namespace as an argument: - -```php -v::with('My\\Validation\\Rules\\'); -v::myRule(); // Try to load "My\Validation\Rules\MyRule" if any -``` - -By default `with()` appends the given prefix, but you can change this behavior -in order to overwrite default rules: - -```php -v::with('My\\Validation\\Rules', true); -v::alnum(); // Try to use "My\Validation\Rules\Alnum" if any -``` - -## Validator name - -On `v::attribute()` and `v::key()`, `{{name}}` is the attribute/key name. For others, -is the same as the input. You can customize a validator name using: - -```php -v::date('Y-m-d')->between('1980-02-02', 'now')->setName('Member Since'); -``` - -## Zend/Symfony validators - -It is also possible to reuse validators from other frameworks if they are installed: - -```php -$hostnameValidator = v::zend('Hostname')->assert('google.com'); -$timeValidator = v::sf('Time')->assert('22:00:01'); -``` - -## Validation methods - -We've seen `validate()` that returns true or false and `assert()` that throws a complete -validation report. There is also a `check()` method that returns an Exception -only with the first error found: - -```php -use Respect\Validation\Exceptions\ValidationException; - -try { - $usernameValidator->check('really messed up screen#name'); -} catch(ValidationException $exception) { - echo $exception->getMainMessage(); -} -``` - -Message: - -```no-highlight -"really messed up screen#name" must contain only letters (a-z) and digits (0-9) -``` - -*** -See also: - -- [Contributing](../CONTRIBUTING.md) -- [Installation](INSTALL.md) -- [License](../LICENSE.md) -- [Validators](VALIDATORS.md) -- [Changelog](../CHANGELOG.md) diff --git a/vendor/respect/validation/docs/Readable.md b/vendor/respect/validation/docs/Readable.md deleted file mode 100755 index 00a074eb9142aa4700965e2bf593d6b3cbd67e3d..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Readable.md +++ /dev/null @@ -1,23 +0,0 @@ -# Readable - -- `v::readable()` - -Validates if the given data is a file exists and is readable. - -```php -v::readable()->validate('/path/of/a/readable/file'); // true -``` - -*** -See also: - - * [Directory](Directory.md) - * [Executable](Executable.md) - * [Exists](Exists.md) - * [Extension](Extension.md) - * [File](File.md) - * [Mimetype](Mimetype.md) - * [Size](Size.md) - * [SymbolicLink](SymbolicLink.md) - * [Uploaded](Uploaded.md) - * [Writable](Writable.md) diff --git a/vendor/respect/validation/docs/Regex.md b/vendor/respect/validation/docs/Regex.md deleted file mode 100755 index ed0d2517345e6fcb37c9ad8e68a3d83d98b815ab..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Regex.md +++ /dev/null @@ -1,21 +0,0 @@ -# Regex - -- `v::regex(string $regex)` - -Evaluates a regex on the input and validates if matches - -```php -v::regex('/[a-z]/')->validate('a'); // true -``` - -Message template for this validator includes `{{regex}}` - -*** -See also: - - * [Alnum](Alnum.md) - * [Alpha](Alpha.md) - * [Contains](Contains.md) - * [Digit](Digit.md) - * [EndsWith](EndsWith.md) - * [StartsWith](StartsWith.md) diff --git a/vendor/respect/validation/docs/ResourceType.md b/vendor/respect/validation/docs/ResourceType.md deleted file mode 100755 index c21a2f1d89b7a85c966d8eefdd07e3abe4d4e565..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/ResourceType.md +++ /dev/null @@ -1,21 +0,0 @@ -# ResourceType - -- `v::resourceType()` - -Validates if the input is a resource. - -```php -v::resourceType()->validate(fopen('/path/to/file.txt', 'w')); // true -``` - -*** -See also: - - * [BoolType](BoolType.md) - * [CallableType](CallableType.md) - * [FloatType](FloatType.md) - * [IntType](IntType.md) - * [NullType](NullType.md) - * [ObjectType](ObjectType.md) - * [StringType](StringType.md) - * [Type](Type.md) diff --git a/vendor/respect/validation/docs/Roman.md b/vendor/respect/validation/docs/Roman.md deleted file mode 100755 index b619930e1bf61ec67b70c246aa1aaa23bbfafb00..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Roman.md +++ /dev/null @@ -1,16 +0,0 @@ -# Roman - -- `v::roman()` - -Validates roman numbers - -```php -v::roman()->validate('IV'); // true -``` - -*** -See also: - - * [In](In.md) - * [Regex](Regex.md) - * [Uppercase](Uppercase.md) diff --git a/vendor/respect/validation/docs/ScalarVal.md b/vendor/respect/validation/docs/ScalarVal.md deleted file mode 100755 index 366657854d77bda4e2df7eac79e9787b4c392fc1..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/ScalarVal.md +++ /dev/null @@ -1,15 +0,0 @@ -# ScalarVal - -- `v::scalarVal()` - -Validates if the input is a scalar value. - -```php -v::scalarVal()->validate([]); // false -v::scalarVal()->validate(135.0); // true -``` - -*** -See also: - - * [Type](Type.md) diff --git a/vendor/respect/validation/docs/Sf.md b/vendor/respect/validation/docs/Sf.md deleted file mode 100755 index a7988a8b98d4027c45045556046a7d7169bc4a0b..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Sf.md +++ /dev/null @@ -1,19 +0,0 @@ -# Sf - -- `v::sf(string $validator)` - -Use Symfony2 validators inside Respect\Validation flow. Messages -are preserved. - -```php -v::sf('Time')->validate('15:00:00'); -``` - - -You must add `"symfony/validator": "~2.6"` to your `require` property on composer.json file. - - -*** -See also: - - * [Zend](Zend.md) diff --git a/vendor/respect/validation/docs/Size.md b/vendor/respect/validation/docs/Size.md deleted file mode 100755 index 13f5aee4e96aec1c383ef7bed1c78a471aa33f6f..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Size.md +++ /dev/null @@ -1,48 +0,0 @@ -# Size - -- `v::size(string $minSize)` -- `v::size(string $minSize, string $maxSize)` -- `v::size(null, string $maxSize)` - -Validates file sizes: - -```php -v::size('1KB')->validate($filename); // Must have at least 1KB size -v::size('1MB', '2MB')->validate($filename); // Must have the size between 1MB and 2MB -v::size(null, '1GB')->validate($filename); // Must not be greater than 1GB -``` - -Sizes are not case-sensitive and the accepted values are: - -- B -- KB -- MB -- GB -- TB -- PB -- EB -- ZB -- YB - -This validator will consider `SplFileInfo` instances, like: - -```php -$fileInfo = new SplFileInfo($filename); -v::size('1.5mb')->validate($fileInfo); // Will return true or false -``` - -Message template for this validator includes `{{minSize}}` and `{{maxSize}}`. - -*** -See also: - - * [Directory](Directory.md) - * [Executable](Executable.md) - * [Exists](Exists.md) - * [Extension](Extension.md) - * [File](File.md) - * [Mimetype](Mimetype.md) - * [Readable](Readable.md) - * [SymbolicLink](SymbolicLink.md) - * [Uploaded](Uploaded.md) - * [Writable](Writable.md) diff --git a/vendor/respect/validation/docs/Slug.md b/vendor/respect/validation/docs/Slug.md deleted file mode 100755 index 599bbbaac904fdef72ddcf7fc753511aa67fc8a7..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Slug.md +++ /dev/null @@ -1,17 +0,0 @@ -# Slug - -- `v::slug()` - -Validates slug-like strings: - -```php -v::slug()->validate('my-wordpress-title'); // true -v::slug()->validate('my-wordpress--title'); // false -v::slug()->validate('my-wordpress-title-'); // false -``` - -*** -See also: - - * [Url](Url.md) - * [VideoUrl](VideoUrl.md) diff --git a/vendor/respect/validation/docs/Space.md b/vendor/respect/validation/docs/Space.md deleted file mode 100755 index a0faec57133569ef6457237c0eacd2f9e6782db0..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Space.md +++ /dev/null @@ -1,15 +0,0 @@ -# Space - -- `v::space()` -- `v::space(string $additionalChars)` - -Accepts only whitespace: - -```php -v::space()->validate(' '); // true -``` - -*** -See also: - - * [Cntrl](Cntrl.md) diff --git a/vendor/respect/validation/docs/StartsWith.md b/vendor/respect/validation/docs/StartsWith.md deleted file mode 100755 index 842655d94b25b1460254e12d1d4618032cf77d5c..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/StartsWith.md +++ /dev/null @@ -1,31 +0,0 @@ -# StartsWith - -- `v::startsWith(mixed $value)` -- `v::startsWith(mixed $value, boolean $identical = false)` - -This validator is similar to `v::contains()`, but validates -only if the value is at the beginning of the input. - -For strings: - -```php -v::startsWith('lorem')->validate('lorem ipsum'); // true -``` - -For arrays: - -```php -v::startsWith('lorem')->validate(['lorem', 'ipsum']); // true -``` - -`true` may be passed as a parameter to indicate identical comparison -instead of equal. - -Message template for this validator includes `{{startValue}}`. - -*** -See also: - - * [EndsWith](EndsWith.md) - * [Contains](Contains.md) - * [In](In.md) diff --git a/vendor/respect/validation/docs/StringType.md b/vendor/respect/validation/docs/StringType.md deleted file mode 100755 index 624c3df8cfbe16b0774d69203d9d5d32a5c12f03..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/StringType.md +++ /dev/null @@ -1,22 +0,0 @@ -# StringType - -- `v::stringType()` - -Validates a string. - -```php -v::stringType()->validate('hi'); // true -``` - -*** -See also: - - * [Alnum](Alnum.md) - * [BoolType](BoolType.md) - * [CallableType](CallableType.md) - * [FloatType](FloatType.md) - * [IntType](IntType.md) - * [NullType](NullType.md) - * [ObjectType](ObjectType.md) - * [ResourceType](ResourceType.md) - * [Type](Type.md) diff --git a/vendor/respect/validation/docs/SubdivisionCode.md b/vendor/respect/validation/docs/SubdivisionCode.md deleted file mode 100755 index 3cb031922eff171dcac07b05827f9420049fa83c..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/SubdivisionCode.md +++ /dev/null @@ -1,284 +0,0 @@ -# SubdivisionCode - -- `v::subdivisionCode(string $countryCode)` - -Validates subdivision country codes according to [ISO 3166-2][]. - -The `$countryCode` must be a country in [ISO 3166-1 alpha-2][] format. - -```php -v::subdivisionCode('BR')->validate('SP'); // true -v::subdivisionCode('US')->validate('CA'); // true -``` - -This rule is case sensitive. - -## Available country codes - -- `AD`: Andorra -- `AE`: United Arab Emirates -- `AF`: Afghanistan -- `AG`: Antigua and Barbuda -- `AI`: Anguilla -- `AL`: Albania -- `AM`: Armenia -- `AN`: AN.html -- `AO`: Angola -- `AQ`: Antarctica -- `AR`: Argentina -- `AS`: American Samoa -- `AT`: Austria -- `AU`: Australia -- `AW`: Aruba -- `AX`: Åland -- `AZ`: Azerbaijan -- `BA`: Bosnia and Herzegovina -- `BB`: Barbados -- `BD`: Bangladesh -- `BE`: Belgium -- `BF`: Burkina Faso -- `BG`: Bulgaria -- `BH`: Bahrain -- `BI`: Burundi -- `BJ`: Benin -- `BL`: Saint Barthélemy -- `BM`: Bermuda -- `BN`: Brunei -- `BO`: Bolivia -- `BQ`: Bonaire -- `BR`: Brazil -- `BS`: Bahamas -- `BT`: Bhutan -- `BV`: Bouvet Island -- `BW`: Botswana -- `BY`: Belarus -- `BZ`: Belize -- `CA`: Canada -- `CC`: Cocos [Keeling] Islands -- `CD`: Democratic Republic of the Congo -- `CF`: Central African Republic -- `CG`: Republic of the Congo -- `CH`: Switzerland -- `CI`: Ivory Coast -- `CK`: Cook Islands -- `CL`: Chile -- `CM`: Cameroon -- `CN`: China -- `CO`: Colombia -- `CR`: Costa Rica -- `CS`: CS.html -- `CU`: Cuba -- `CV`: Cape Verde -- `CW`: Curacao -- `CX`: Christmas Island -- `CY`: Cyprus -- `CZ`: Czech Republic -- `DE`: Germany -- `DJ`: Djibouti -- `DK`: Denmark -- `DM`: Dominica -- `DO`: Dominican Republic -- `DZ`: Algeria -- `EC`: Ecuador -- `EE`: Estonia -- `EG`: Egypt -- `EH`: Western Sahara -- `ER`: Eritrea -- `ES`: Spain -- `ET`: Ethiopia -- `FI`: Finland -- `FJ`: Fiji -- `FK`: Falkland Islands -- `FM`: Micronesia -- `FO`: Faroe Islands -- `FR`: France -- `GA`: Gabon -- `GB`: United Kingdom -- `GD`: Grenada -- `GE`: Georgia -- `GF`: French Guiana -- `GG`: Guernsey -- `GH`: Ghana -- `GI`: Gibraltar -- `GL`: Greenland -- `GM`: Gambia -- `GN`: Guinea -- `GP`: Guadeloupe -- `GQ`: Equatorial Guinea -- `GR`: Greece -- `GS`: South Georgia and the South Sandwich Islands -- `GT`: Guatemala -- `GU`: Guam -- `GW`: Guinea-Bissau -- `GY`: Guyana -- `HK`: Hong Kong -- `HM`: Heard Island and McDonald Islands -- `HN`: Honduras -- `HR`: Croatia -- `HT`: Haiti -- `HU`: Hungary -- `ID`: Indonesia -- `IE`: Ireland -- `IL`: Israel -- `IM`: Isle of Man -- `IN`: India -- `IO`: British Indian Ocean Territory -- `IQ`: Iraq -- `IR`: Iran -- `IS`: Iceland -- `IT`: Italy -- `JE`: Jersey -- `JM`: Jamaica -- `JO`: Jordan -- `JP`: Japan -- `KE`: Kenya -- `KG`: Kyrgyzstan -- `KH`: Cambodia -- `KI`: Kiribati -- `KM`: Comoros -- `KN`: Saint Kitts and Nevis -- `KP`: North Korea -- `KR`: South Korea -- `KW`: Kuwait -- `KY`: Cayman Islands -- `KZ`: Kazakhstan -- `LA`: Laos -- `LB`: Lebanon -- `LC`: Saint Lucia -- `LI`: Liechtenstein -- `LK`: Sri Lanka -- `LR`: Liberia -- `LS`: Lesotho -- `LT`: Lithuania -- `LU`: Luxembourg -- `LV`: Latvia -- `LY`: Libya -- `MA`: Morocco -- `MC`: Monaco -- `MD`: Moldova -- `ME`: Montenegro -- `MF`: Saint Martin -- `MG`: Madagascar -- `MH`: Marshall Islands -- `MK`: Macedonia -- `ML`: Mali -- `MM`: Myanmar [Burma] -- `MN`: Mongolia -- `MO`: Macao -- `MP`: Northern Mariana Islands -- `MQ`: Martinique -- `MR`: Mauritania -- `MS`: Montserrat -- `MT`: Malta -- `MU`: Mauritius -- `MV`: Maldives -- `MW`: Malawi -- `MX`: Mexico -- `MY`: Malaysia -- `MZ`: Mozambique -- `NA`: Namibia -- `NC`: New Caledonia -- `NE`: Niger -- `NF`: Norfolk Island -- `NG`: Nigeria -- `NI`: Nicaragua -- `NL`: Netherlands -- `NO`: Norway -- `NP`: Nepal -- `NR`: Nauru -- `NU`: Niue -- `NZ`: New Zealand -- `OM`: Oman -- `PA`: Panama -- `PE`: Peru -- `PF`: French Polynesia -- `PG`: Papua New Guinea -- `PH`: Philippines -- `PK`: Pakistan -- `PL`: Poland -- `PM`: Saint Pierre and Miquelon -- `PN`: Pitcairn Islands -- `PR`: Puerto Rico -- `PS`: Palestine -- `PT`: Portugal -- `PW`: Palau -- `PY`: Paraguay -- `QA`: Qatar -- `RE`: Réunion -- `RO`: Romania -- `RS`: Serbia -- `RU`: Russia -- `RW`: Rwanda -- `SA`: Saudi Arabia -- `SB`: Solomon Islands -- `SC`: Seychelles -- `SD`: Sudan -- `SE`: Sweden -- `SG`: Singapore -- `SH`: Saint Helena -- `SI`: Slovenia -- `SJ`: Svalbard and Jan Mayen -- `SK`: Slovakia -- `SL`: Sierra Leone -- `SM`: San Marino -- `SN`: Senegal -- `SO`: Somalia -- `SR`: Suriname -- `SS`: South Sudan -- `ST`: São Tomé and Príncipe -- `SV`: El Salvador -- `SX`: Sint Maarten -- `SY`: Syria -- `SZ`: Swaziland -- `TC`: Turks and Caicos Islands -- `TD`: Chad -- `TF`: French Southern Territories -- `TG`: Togo -- `TH`: Thailand -- `TJ`: Tajikistan -- `TK`: Tokelau -- `TL`: East Timor -- `TM`: Turkmenistan -- `TN`: Tunisia -- `TO`: Tonga -- `TR`: Turkey -- `TT`: Trinidad and Tobago -- `TV`: Tuvalu -- `TW`: Taiwan -- `TZ`: Tanzania -- `UA`: Ukraine -- `UG`: Uganda -- `UM`: U.S. Minor Outlying Islands -- `US`: United States -- `UY`: Uruguay -- `UZ`: Uzbekistan -- `VA`: Vatican City -- `VC`: Saint Vincent and the Grenadines -- `VE`: Venezuela -- `VG`: British Virgin Islands -- `VI`: U.S. Virgin Islands -- `VN`: Vietnam -- `VU`: Vanuatu -- `WF`: Wallis and Futuna -- `WS`: Samoa -- `XK`: Kosovo -- `YE`: Yemen -- `YT`: Mayotte -- `ZA`: South Africa -- `ZM`: Zambia -- `ZW`: Zimbabwe - -All data was extrated from [GeoNames][] which is licensed under a -[Creative Commons Attribution 3.0 License][]. - -*** -See also: - - * [CountryCode](CountryCode.md) - * [Tld](Tld.md) - - -[Creative Commons Attribution 3.0 License]: http://creativecommons.org/licenses/by/3.0 "Creative Commons Attribution 3.0 License" -[GeoNames]: http://www.geonames.org "GetNames" -[ISO 3166-1 alpha-2]: http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 "ISO 3166-1 alpha-2" -[ISO 3166-2]: http://en.wikipedia.org/wiki/ISO_3166-2 "ISO 3166-2" diff --git a/vendor/respect/validation/docs/SymbolicLink.md b/vendor/respect/validation/docs/SymbolicLink.md deleted file mode 100755 index bc9019657bc68072e439020da43c0169169eab43..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/SymbolicLink.md +++ /dev/null @@ -1,23 +0,0 @@ -# SymbolicLink - -- `v::symbolicLink()` - -Validates if the given data is a path of a valid symbolic link. - -```php -v::symbolicLink()->validate('/path/of/valid/symbolic/link'); // true -``` - -*** -See also: - - * [Directory](Directory.md) - * [Executable](Executable.md) - * [Exists](Exists.md) - * [Extension](Extension.md) - * [File](File.md) - * [Mimetype](Mimetype.md) - * [Readable](Readable.md) - * [Size](Size.md) - * [Uploaded](Uploaded.md) - * [Writable](Writable.md) diff --git a/vendor/respect/validation/docs/Tld.md b/vendor/respect/validation/docs/Tld.md deleted file mode 100755 index db05452a196958e19b794707740c69487c99d5a2..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Tld.md +++ /dev/null @@ -1,17 +0,0 @@ -# Tld - -- `v::tld()` - -Validates a top-level domain - -```php -v::tld()->validate('com'); // true -v::tld()->validate('ly'); // true -v::tld()->validate('org'); // true -``` - -*** -See also: - - * [Domain](Domain.md) - * [CountryCode](CountryCode.md) diff --git a/vendor/respect/validation/docs/TrueVal.md b/vendor/respect/validation/docs/TrueVal.md deleted file mode 100755 index 59869d200419e5db273de2f4fa7c6bb30847dbd7..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/TrueVal.md +++ /dev/null @@ -1,21 +0,0 @@ -# TrueVal - -- `v::trueVal()` - -Validates if a value is considered as `true`. - -```php -v::trueVal()->validate(true); // true -v::trueVal()->validate(1); // true -v::trueVal()->validate('1'); // true -v::trueVal()->validate('true'); // true -v::trueVal()->validate('on'); // true -v::trueVal()->validate('yes'); // true -v::trueVal()->validate('0.5'); // false -v::trueVal()->validate('2'); // false -``` - -*** -See also: - - * [FalseVal](FalseVal.md) diff --git a/vendor/respect/validation/docs/Type.md b/vendor/respect/validation/docs/Type.md deleted file mode 100755 index 50f2abb9f9a75a2e1fa087a69b38274ad45d8631..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Type.md +++ /dev/null @@ -1,31 +0,0 @@ -# Type - -- `v::type(string $type)` - -Validates the type of input. - -```php -v::type('bool')->validate(true); // true -v::type('callable')->validate(function (){}); // true -v::type('object')->validate(new stdClass()); // true -``` - -*** -See also: - - * [ArrayVal](ArrayVal.md) - * [BoolType](BoolType.md) - * [CallableType](CallableType.md) - * [Finite](Finite.md) - * [FloatType](FloatType.md) - * [FloatVal](FloatVal.md) - * [Infinite](Infinite.md) - * [Instance](Instance.md) - * [IntType](IntType.md) - * [IntVal](IntVal.md) - * [NullType](NullType.md) - * [ObjectType](ObjectType.md) - * [ResourceType](ResourceType.md) - * [ScalarVal](ScalarVal.md) - * [StringType](StringType.md) - * [Type](Type.md) diff --git a/vendor/respect/validation/docs/Uploaded.md b/vendor/respect/validation/docs/Uploaded.md deleted file mode 100755 index 774f9bb8216835034c4fa9c02263dfe2c9f898f5..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Uploaded.md +++ /dev/null @@ -1,23 +0,0 @@ -# Uploaded - -- `v::uploaded()` - -Validates if the given data is a file that was uploaded via HTTP POST. - -```php -v::uploaded()->validate('/path/of/an/uploaded/file'); // true -``` - -*** -See also: - - * [Directory](Directory.md) - * [Executable](Executable.md) - * [Exists](Exists.md) - * [Extension](Extension.md) - * [File](File.md) - * [Mimetype](Mimetype.md) - * [Readable](Readable.md) - * [Size](Size.md) - * [SymbolicLink](SymbolicLink.md) - * [Writable](Writable.md) diff --git a/vendor/respect/validation/docs/Uppercase.md b/vendor/respect/validation/docs/Uppercase.md deleted file mode 100755 index 1dff7acf584a5ee43724526f6ff729879521ef2e..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Uppercase.md +++ /dev/null @@ -1,14 +0,0 @@ -# Uppercase - -- `v::uppercase()` - -Validates if string characters are uppercase in the input: - -```php -v::stringType()->uppercase()->validate('W3C'); // true -``` - -*** -See also: - - * [Lowercase](Lowercase.md) diff --git a/vendor/respect/validation/docs/Url.md b/vendor/respect/validation/docs/Url.md deleted file mode 100755 index 5638cf55f4b364edceea324d80904c3f87ce3178..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Url.md +++ /dev/null @@ -1,24 +0,0 @@ -# Url - -- `v::url()` - -Validates if input is an URL: - -```php -v::url()->validate('http://example.com'); // true -v::url()->validate('https://www.youtube.com/watch?v=6FOUqQt3Kg0'); // true -v::url()->validate('ldap://[::1]'); // true -v::url()->validate('mailto:john.doe@example.com'); // true -v::url()->validate('news:new.example.com'); // true -``` - -This rule uses [FilterVar](FilterVar.md) - -*** -See also: - - * [Domain](Domain.md) - * [Email](Email.md) - * [FilterVar](FilterVar.md) - * [Phone](Phone.md) - * [VideoUrl](VideoUrl.md) diff --git a/vendor/respect/validation/docs/VALIDATORS.md b/vendor/respect/validation/docs/VALIDATORS.md deleted file mode 100755 index 4804cbee39d14c11fbdd5325884fbd9399c06964..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/VALIDATORS.md +++ /dev/null @@ -1,338 +0,0 @@ -# Validators - -## Types - - * [ArrayVal](ArrayVal.md) - * [ArrayType](ArrayType.md) - * [BoolVal](BoolVal.md) - * [BoolType](BoolType.md) - * [CallableType](CallableType.md) - * [Countable](Countable.md) - * [Date](Date.md) - * [FalseVal](FalseVal.md) - * [FloatVal](FloatVal.md) - * [FloatType](FloatType.md) - * [Instance](Instance.md) - * [IntVal](IntVal.md) - * [IntType](IntType.md) - * [IterableType](IterableType.md) - * [NullType](NullType.md) - * [Numeric](Numeric.md) - * [ObjectType](ObjectType.md) - * [ResourceType](ResourceType.md) - * [ScalarVal](ScalarVal.md) - * [StringType](StringType.md) - * [TrueVal](TrueVal.md) - * [Type](Type.md) - * [Xdigit](Xdigit.md) - -## Generics - - * [AlwaysInvalid](AlwaysInvalid.md) - * [AlwaysValid](AlwaysValid.md) - * [Call](Call.md) - * [Callback](Callback.md) - * [FilterVar](FilterVar.md) - * [Not](Not.md) - * [Optional](Optional.md) - * [Type](Type.md) - * [When](When.md) - -## Comparing Values - - * [Age](Age.md) - * [Between](Between.md) - * [Equals](Equals.md) - * [Identical](Identical.md) - * [Max](Max.md) - * [Min](Min.md) - -## Numeric - - * [Between](Between.md) - * [BoolType](BoolType.md) - * [Even](Even.md) - * [Factor](Factor.md) - * [Fibonacci](Fibonacci.md) - * [Finite](Finite.md) - * [FloatVal](FloatVal.md) - * [FloatType](FloatType.md) - * [Infinite](Infinite.md) - * [IntVal](IntVal.md) - * [IntType](IntType.md) - * [Multiple](Multiple.md) - * [Negative](Negative.md) - * [NotEmpty](NotEmpty.md) - * [Numeric](Numeric.md) - * [Odd](Odd.md) - * [PerfectSquare](PerfectSquare.md) - * [Positive](Positive.md) - * [PrimeNumber](PrimeNumber.md) - * [Roman](Roman.md) - * [Xdigit](Xdigit.md) - -## String - - * [Alnum](Alnum.md) - * [Alpha](Alpha.md) - * [Between](Between.md) - * [Charset](Charset.md) - * [Cntrl](Cntrl.md) - * [Consonant](Consonant.md) - * [Contains](Contains.md) - * [Digit](Digit.md) - * [EndsWith](EndsWith.md) - * [Graph](Graph.md) - * [In](In.md) - * [Length](Length.md) - * [Lowercase](Lowercase.md) - * [NotEmpty](NotEmpty.md) - * [NoWhitespace](NoWhitespace.md) - * [PhpLabel](PhpLabel.md) - * [Prnt](Prnt.md) - * [Punct](Punct.md) - * [Regex](Regex.md) - * [ResourceType](ResourceType.md) - * [Slug](Slug.md) - * [Space](Space.md) - * [StartsWith](StartsWith.md) - * [Uppercase](Uppercase.md) - * [Version](Version.md) - * [Vowel](Vowel.md) - * [Xdigit](Xdigit.md) - -## Arrays - - * [ArrayVal](ArrayVal.md) - * [ArrayType](ArrayType.md) - * [Contains](Contains.md) - * [Each](Each.md) - * [EndsWith](EndsWith.md) - * [In](In.md) - * [Key](Key.md) - * [KeyNested](KeyNested.md) - * [KeySet](KeySet.md) - * [KeyValue](KeyValue.md) - * [Length](Length.md) - * [NotEmpty](NotEmpty.md) - * [StartsWith](StartsWith.md) - -## Objects - - * [Attribute](Attribute.md) - * [Instance](Instance.md) - * [Length](Length.md) - -## Date and Time - - * [Age](Age.md) - * [Between](Between.md) - * [Date](Date.md) - * [LeapDate](LeapDate.md) - * [LeapYear](LeapYear.md) - * [MinimumAge](MinimumAge.md) - -## Group Validators - - * [AllOf](AllOf.md) - * [NoneOf](NoneOf.md) - * [OneOf](OneOf.md) - -## Regional - - * [CountryCode](CountryCode.md) - * [CurrencyCode](CurrencyCode.md) - * [IdentityCard](IdentityCard.md) - * [LanguageCode](LanguageCode.md) - * [PostalCode](PostalCode.md) - * [SubdivisionCode](SubdivisionCode.md) - * [Tld](Tld.md) - -## Files - - * [Directory](Directory.md) - * [Executable](Executable.md) - * [Exists](Exists.md) - * [Extension](Extension.md) - * [File](File.md) - * [Image](Image.md) - * [Mimetype](Mimetype.md) - * [Readable](Readable.md) - * [Size](Size.md) - * [SymbolicLink](SymbolicLink.md) - * [Uploaded](Uploaded.md) - * [Writable](Writable.md) - -## Banking - - * [Bank](Bank.md) - * [BankAccount](BankAccount.md) - * [Bic](Bic.md) - -## Other - - * [Bsn](Bsn.md) - * [Cnh](Cnh.md) - * [Cnpj](Cnpj.md) - * [Cpf](Cpf.md) - * [Domain](Domain.md) - * [Email](Email.md) - * [HexRgbColor](HexRgbColor.md) - * [Imei](Imei.md) - * [Ip](Ip.md) - * [Json](Json.md) - * [MacAddress](MacAddress.md) - * [NfeAccessKey](NfeAccessKey.md) - * [NotBlank](NotBlank.md) - * [NotOptional](NotOptional.md) - * [Pesel](Pesel.md) - * [Phone](Phone.md) - * [Sf](Sf.md) - * [Url](Url.md) - * [VideoUrl](VideoUrl.md) - * [Zend](Zend.md) - -## Yes/No - - * [No](No.md) - * [Yes](Yes.md) - -## Alphabetically - - * [Age](Age.md) - * [AllOf](AllOf.md) - * [Alnum](Alnum.md) - * [Alpha](Alpha.md) - * [AlwaysInvalid](AlwaysInvalid.md) - * [AlwaysValid](AlwaysValid.md) - * [ArrayVal](ArrayVal.md) - * [ArrayType](ArrayType.md) - * [Attribute](Attribute.md) - * [Bank](Bank.md) - * [BankAccount](BankAccount.md) - * [Between](Between.md) - * [Bic](Bic.md) - * [BoolType](BoolType.md) - * [Bsn](Bsn.md) - * [Call](Call.md) - * [CallableType](CallableType.md) - * [Callback](Callback.md) - * [Charset](Charset.md) - * [Cnh](Cnh.md) - * [Cnpj](Cnpj.md) - * [Cntrl](Cntrl.md) - * [Consonant](Consonant.md) - * [Contains](Contains.md) - * [Countable](Countable.md) - * [CountryCode](CountryCode.md) - * [Cpf](Cpf.md) - * [CreditCard](CreditCard.md) - * [Date](Date.md) - * [Digit](Digit.md) - * [Directory](Directory.md) - * [Domain](Domain.md) - * [Each](Each.md) - * [Email](Email.md) - * [EndsWith](EndsWith.md) - * [Equals](Equals.md) - * [Even](Even.md) - * [Executable](Executable.md) - * [Exists](Exists.md) - * [Extension](Extension.md) - * [Factor](Factor.md) - * [FalseVal](FalseVal.md) - * [Fibonacci](Fibonacci.md) - * [File](File.md) - * [FilterVar](FilterVar.md) - * [Finite](Finite.md) - * [FloatVal](FloatVal.md) - * [FloatType](FloatType.md) - * [Graph](Graph.md) - * [HexRgbColor](HexRgbColor.md) - * [Identical](Identical.md) - * [IdentityCard](IdentityCard.md) - * [Image](Image.md) - * [Imei](Imei.md) - * [In](In.md) - * [Infinite](Infinite.md) - * [Instance](Instance.md) - * [IntVal](IntVal.md) - * [IntType](IntType.md) - * [Ip](Ip.md) - * [IterableType](IterableType.md) - * [Json](Json.md) - * [Key](Key.md) - * [KeyNested](KeyNested.md) - * [KeySet](KeySet.md) - * [KeyValue](KeyValue.md) - * [LanguageCode](LanguageCode.md) - * [LeapDate](LeapDate.md) - * [LeapYear](LeapYear.md) - * [Length](Length.md) - * [Lowercase](Lowercase.md) - * [MacAddress](MacAddress.md) - * [Max](Max.md) - * [Mimetype](Mimetype.md) - * [Min](Min.md) - * [MinimumAge](MinimumAge.md) - * [Multiple](Multiple.md) - * [Negative](Negative.md) - * [NfeAccessKey](NfeAccessKey.md) - * [No](No.md) - * [NoWhitespace](NoWhitespace.md) - * [NoneOf](NoneOf.md) - * [Not](Not.md) - * [NotBlank](NotBlank.md) - * [NotEmpty](NotEmpty.md) - * [NotOptional](NotOptional.md) - * [NullType](NullType.md) - * [Numeric](Numeric.md) - * [ObjectType](ObjectType.md) - * [Odd](Odd.md) - * [OneOf](OneOf.md) - * [Optional](Optional.md) - * [PerfectSquare](PerfectSquare.md) - * [Pesel](Pesel.md) - * [Phone](Phone.md) - * [PhpLabel](PhpLabel.md) - * [Positive](Positive.md) - * [PostalCode](PostalCode.md) - * [PrimeNumber](PrimeNumber.md) - * [Prnt](Prnt.md) - * [Punct](Punct.md) - * [Readable](Readable.md) - * [Regex](Regex.md) - * [ResourceType](ResourceType.md) - * [Roman](Roman.md) - * [ScalarVal](ScalarVal.md) - * [Sf](Sf.md) - * [Size](Size.md) - * [Slug](Slug.md) - * [Space](Space.md) - * [StartsWith](StartsWith.md) - * [StringType](StringType.md) - * [SubdivisionCode](SubdivisionCode.md) - * [SymbolicLink](SymbolicLink.md) - * [Tld](Tld.md) - * [TrueVal](TrueVal.md) - * [Type](Type.md) - * [Uploaded](Uploaded.md) - * [Uppercase](Uppercase.md) - * [Url](Url.md) - * [Version](Version.md) - * [VideoUrl](VideoUrl.md) - * [Vowel](Vowel.md) - * [When](When.md) - * [Writable](Writable.md) - * [Xdigit](Xdigit.md) - * [Yes](Yes.md) - * [Zend](Zend.md) - -*** -See also: - -- [Contributing](../CONTRIBUTING.md) -- [Feature Guide](README.md) -- [Installation](INSTALL.md) -- [License](../LICENSE.md) -- [Changelog](../CHANGELOG.md) diff --git a/vendor/respect/validation/docs/Version.md b/vendor/respect/validation/docs/Version.md deleted file mode 100755 index aad3ce8a3d02bc333d3bff0c11a9b359a67c66c7..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Version.md +++ /dev/null @@ -1,16 +0,0 @@ -# Version - -- `v::version()` - -Validates version numbers using Semantic Versioning. - -```php -v::version()->validate('1.0.0'); -``` - -*** -See also: - - * [Equals](Equals.md) - * [Regex](Regex.md) - * [Roman](Roman.md) diff --git a/vendor/respect/validation/docs/VideoUrl.md b/vendor/respect/validation/docs/VideoUrl.md deleted file mode 100755 index 1ef962793bdc6082f57ad70d42f059a06095ca5a..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/VideoUrl.md +++ /dev/null @@ -1,35 +0,0 @@ -# VideoUrl - -- `v::videoUrl()` -- `v::videoUrl(string $service)` - -Validates if the input is a video URL value: - -```php -v::videoUrl()->validate('https://player.vimeo.com/video/71787467'); // true -v::videoUrl()->validate('https://vimeo.com/71787467'); // true -v::videoUrl()->validate('https://www.youtube.com/embed/netHLn9TScY'); // true -v::videoUrl()->validate('https://www.youtube.com/watch?v=netHLn9TScY'); // true -v::videoUrl()->validate('https://youtu.be/netHLn9TScY'); // true - -v::videoUrl('youtube')->validate('https://www.youtube.com/watch?v=netHLn9TScY'); // true -v::videoUrl('vimeo')->validate('https://vimeo.com/71787467'); // true - -v::videoUrl()->validate('https://youtube.com'); // false -v::videoUrl('youtube')->validate('https://vimeo.com/71787467'); // false -``` - -The services accepted are: - -- YouTube -- Vimeo - -The `$service` value is not case-sensitive. - -Message template for this validator includes `{{service}}`. - - -*** -See also: - - * [Url](Url.md) diff --git a/vendor/respect/validation/docs/Vowel.md b/vendor/respect/validation/docs/Vowel.md deleted file mode 100755 index 98d806f5d90b39658d61d9e69dec3d86b5330e2f..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Vowel.md +++ /dev/null @@ -1,17 +0,0 @@ -# Vowel - -- `v::vowel()` - -Similar to `v::alnum()`. Validates strings that contains only vowels: - -```php -v::vowel()->validate('aei'); // true -``` - -*** -See also: - - * [Alnum](Alnum.md) - * [Digit](Digit.md) - * [Alpha](Alpha.md) - * [Consonant](Consonant.md) diff --git a/vendor/respect/validation/docs/When.md b/vendor/respect/validation/docs/When.md deleted file mode 100755 index 6254cb34d991733bd29c9b2281bad838f362a24e..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/When.md +++ /dev/null @@ -1,24 +0,0 @@ -# When - -- `v::when(v $if, v $then, v $else)` -- `v::when(v $if, v $then)` - -A ternary validator that accepts three parameters. - -When the `$if` validates, returns validation for `$then`. -When the `$if` doesn't validate, returns validation for `$else`, if defined. - -```php -v::when(v::intVal(), v::positive(), v::notEmpty())->validate($input); -``` - -In the sample above, if `$input` is an integer, then it must be positive. -If `$input` is not an integer, then it must not me empty. -When `$else` is not defined use [AlwaysInvalid](AlwaysInvalid.md) - -*** -See also: - - * [AllOf](AllOf.md) - * [OneOf](OneOf.md) - * [NoneOf](NoneOf.md) diff --git a/vendor/respect/validation/docs/Writable.md b/vendor/respect/validation/docs/Writable.md deleted file mode 100755 index b7aa5e436534c6fee4bdf42b5fdafefc7494b08f..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Writable.md +++ /dev/null @@ -1,23 +0,0 @@ -# Writable - -- `v::writable()` - -Validates if the given input is writable file. - -```php -v::writable()->validate('/path/of/a/writable/file'); // true -``` - -*** -See also: - - * [Directory](Directory.md) - * [Executable](Executable.md) - * [Exists](Exists.md) - * [Extension](Extension.md) - * [File](File.md) - * [Mimetype](Mimetype.md) - * [Readable](Readable.md) - * [Size](Size.md) - * [SymbolicLink](SymbolicLink.md) - * [Uploaded](Uploaded.md) diff --git a/vendor/respect/validation/docs/Xdigit.md b/vendor/respect/validation/docs/Xdigit.md deleted file mode 100755 index 9e79d0fdfc6b52ac263f8748ce5dc03c778c9c81..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Xdigit.md +++ /dev/null @@ -1,22 +0,0 @@ -# Xdigit - -- `v::xdigit()` - -Accepts an hexadecimal number: - -```php -v::xdigit()->validate('abc123'); // true -``` - -Notice, however, that it doesn't accept strings starting with 0x: - -```php -v::xdigit()->validate('0x1f'); // false -``` - -*** -See also: - - * [Digit](Digit.md) - * [Alnum](Alnum.md) - * [HexRgbColor](HexRgbColor.md) diff --git a/vendor/respect/validation/docs/Yes.md b/vendor/respect/validation/docs/Yes.md deleted file mode 100755 index 9fef6d8f4d6b0e02e6b9dab619c39451b9f83db6..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Yes.md +++ /dev/null @@ -1,23 +0,0 @@ -# Yes - -- `v::yes()` -- `v::yes(boolean $locale)` - -Validates if value is considered as "Yes". - -```php -v::yes()->validate('Y'); // true -v::yes()->validate('Yea'); // true -v::yes()->validate('Yeah'); // true -v::yes()->validate('Yep'); // true -v::yes()->validate('Yes'); // true -``` - -This rule is case insensitive. - -If `$locale` is TRUE, uses the value of [nl_langinfo()](http://php.net/nl_langinfo) with `YESEXPR` constant. - -*** -See also: - - * [No](No.md) diff --git a/vendor/respect/validation/docs/Zend.md b/vendor/respect/validation/docs/Zend.md deleted file mode 100755 index 8ec0ae8ed7ff8daf197e3ef1b5e42ed594ca2b94..0000000000000000000000000000000000000000 --- a/vendor/respect/validation/docs/Zend.md +++ /dev/null @@ -1,17 +0,0 @@ -# Zend - -- `v::zend(mixed $validator)` - -Use Zend validators inside Respect\Validation flow. Messages -are preserved. - -```php -v::zend('Hostname')->validate('google.com'); -``` - -You must add `"zendframework/zend-validator": "~2.3"` to your `require` property on composer.json file. - -*** -See also: - - * [Sf](Sf.md) diff --git a/vendor/respect/validation/library/Exceptions/AgeException.php b/vendor/respect/validation/library/Exceptions/AgeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/AllOfException.php b/vendor/respect/validation/library/Exceptions/AllOfException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/AlnumException.php b/vendor/respect/validation/library/Exceptions/AlnumException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/AlphaException.php b/vendor/respect/validation/library/Exceptions/AlphaException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/AlwaysInvalidException.php b/vendor/respect/validation/library/Exceptions/AlwaysInvalidException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/AlwaysValidException.php b/vendor/respect/validation/library/Exceptions/AlwaysValidException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ArrayTypeException.php b/vendor/respect/validation/library/Exceptions/ArrayTypeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ArrayValException.php b/vendor/respect/validation/library/Exceptions/ArrayValException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/AtLeastException.php b/vendor/respect/validation/library/Exceptions/AtLeastException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/AttributeException.php b/vendor/respect/validation/library/Exceptions/AttributeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/BankAccountException.php b/vendor/respect/validation/library/Exceptions/BankAccountException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/BankException.php b/vendor/respect/validation/library/Exceptions/BankException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/BaseException.php b/vendor/respect/validation/library/Exceptions/BaseException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/BetweenException.php b/vendor/respect/validation/library/Exceptions/BetweenException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/BicException.php b/vendor/respect/validation/library/Exceptions/BicException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/BoolTypeException.php b/vendor/respect/validation/library/Exceptions/BoolTypeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/BoolValException.php b/vendor/respect/validation/library/Exceptions/BoolValException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/BsnException.php b/vendor/respect/validation/library/Exceptions/BsnException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/CallException.php b/vendor/respect/validation/library/Exceptions/CallException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/CallableTypeException.php b/vendor/respect/validation/library/Exceptions/CallableTypeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/CallbackException.php b/vendor/respect/validation/library/Exceptions/CallbackException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/CharsetException.php b/vendor/respect/validation/library/Exceptions/CharsetException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/CnhException.php b/vendor/respect/validation/library/Exceptions/CnhException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/CnpjException.php b/vendor/respect/validation/library/Exceptions/CnpjException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/CntrlException.php b/vendor/respect/validation/library/Exceptions/CntrlException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ComponentException.php b/vendor/respect/validation/library/Exceptions/ComponentException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ConsonantException.php b/vendor/respect/validation/library/Exceptions/ConsonantException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ContainsException.php b/vendor/respect/validation/library/Exceptions/ContainsException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/CountableException.php b/vendor/respect/validation/library/Exceptions/CountableException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/CountryCodeException.php b/vendor/respect/validation/library/Exceptions/CountryCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/CpfException.php b/vendor/respect/validation/library/Exceptions/CpfException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/CreditCardException.php b/vendor/respect/validation/library/Exceptions/CreditCardException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/CurrencyCodeException.php b/vendor/respect/validation/library/Exceptions/CurrencyCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/DateException.php b/vendor/respect/validation/library/Exceptions/DateException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/DigitException.php b/vendor/respect/validation/library/Exceptions/DigitException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/DirectoryException.php b/vendor/respect/validation/library/Exceptions/DirectoryException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/DomainException.php b/vendor/respect/validation/library/Exceptions/DomainException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/EachException.php b/vendor/respect/validation/library/Exceptions/EachException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/EmailException.php b/vendor/respect/validation/library/Exceptions/EmailException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/EndsWithException.php b/vendor/respect/validation/library/Exceptions/EndsWithException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/EqualsException.php b/vendor/respect/validation/library/Exceptions/EqualsException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/EvenException.php b/vendor/respect/validation/library/Exceptions/EvenException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ExceptionInterface.php b/vendor/respect/validation/library/Exceptions/ExceptionInterface.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ExecutableException.php b/vendor/respect/validation/library/Exceptions/ExecutableException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ExistsException.php b/vendor/respect/validation/library/Exceptions/ExistsException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ExtensionException.php b/vendor/respect/validation/library/Exceptions/ExtensionException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/FactorException.php b/vendor/respect/validation/library/Exceptions/FactorException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/FalseValException.php b/vendor/respect/validation/library/Exceptions/FalseValException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/FibonacciException.php b/vendor/respect/validation/library/Exceptions/FibonacciException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/FileException.php b/vendor/respect/validation/library/Exceptions/FileException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/FilterVarException.php b/vendor/respect/validation/library/Exceptions/FilterVarException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/FiniteException.php b/vendor/respect/validation/library/Exceptions/FiniteException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/FloatTypeException.php b/vendor/respect/validation/library/Exceptions/FloatTypeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/FloatValException.php b/vendor/respect/validation/library/Exceptions/FloatValException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/GraphException.php b/vendor/respect/validation/library/Exceptions/GraphException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/GroupedValidationException.php b/vendor/respect/validation/library/Exceptions/GroupedValidationException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/HexRgbColorException.php b/vendor/respect/validation/library/Exceptions/HexRgbColorException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/IdenticalException.php b/vendor/respect/validation/library/Exceptions/IdenticalException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/IdentityCardException.php b/vendor/respect/validation/library/Exceptions/IdentityCardException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ImageException.php b/vendor/respect/validation/library/Exceptions/ImageException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ImeiException.php b/vendor/respect/validation/library/Exceptions/ImeiException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/InException.php b/vendor/respect/validation/library/Exceptions/InException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/InfiniteException.php b/vendor/respect/validation/library/Exceptions/InfiniteException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/InstanceException.php b/vendor/respect/validation/library/Exceptions/InstanceException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/IntTypeException.php b/vendor/respect/validation/library/Exceptions/IntTypeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/IntValException.php b/vendor/respect/validation/library/Exceptions/IntValException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/IpException.php b/vendor/respect/validation/library/Exceptions/IpException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/IterableException.php b/vendor/respect/validation/library/Exceptions/IterableException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/IterableTypeException.php b/vendor/respect/validation/library/Exceptions/IterableTypeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/JsonException.php b/vendor/respect/validation/library/Exceptions/JsonException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/KeyException.php b/vendor/respect/validation/library/Exceptions/KeyException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/KeyNestedException.php b/vendor/respect/validation/library/Exceptions/KeyNestedException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/KeySetException.php b/vendor/respect/validation/library/Exceptions/KeySetException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/KeyValueException.php b/vendor/respect/validation/library/Exceptions/KeyValueException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/LanguageCodeException.php b/vendor/respect/validation/library/Exceptions/LanguageCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/LeapDateException.php b/vendor/respect/validation/library/Exceptions/LeapDateException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/LeapYearException.php b/vendor/respect/validation/library/Exceptions/LeapYearException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/LengthException.php b/vendor/respect/validation/library/Exceptions/LengthException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/Locale/GermanBankAccountException.php b/vendor/respect/validation/library/Exceptions/Locale/GermanBankAccountException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/Locale/GermanBankException.php b/vendor/respect/validation/library/Exceptions/Locale/GermanBankException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/Locale/GermanBicException.php b/vendor/respect/validation/library/Exceptions/Locale/GermanBicException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/Locale/PlIdentityCardException.php b/vendor/respect/validation/library/Exceptions/Locale/PlIdentityCardException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/LowercaseException.php b/vendor/respect/validation/library/Exceptions/LowercaseException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/MacAddressException.php b/vendor/respect/validation/library/Exceptions/MacAddressException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/MaxException.php b/vendor/respect/validation/library/Exceptions/MaxException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/MimetypeException.php b/vendor/respect/validation/library/Exceptions/MimetypeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/MinException.php b/vendor/respect/validation/library/Exceptions/MinException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/MinimumAgeException.php b/vendor/respect/validation/library/Exceptions/MinimumAgeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/MostOfException.php b/vendor/respect/validation/library/Exceptions/MostOfException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/MultipleException.php b/vendor/respect/validation/library/Exceptions/MultipleException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/NegativeException.php b/vendor/respect/validation/library/Exceptions/NegativeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/NestedValidationException.php b/vendor/respect/validation/library/Exceptions/NestedValidationException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/NfeAccessKeyException.php b/vendor/respect/validation/library/Exceptions/NfeAccessKeyException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/NoException.php b/vendor/respect/validation/library/Exceptions/NoException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/NoWhitespaceException.php b/vendor/respect/validation/library/Exceptions/NoWhitespaceException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/NoneOfException.php b/vendor/respect/validation/library/Exceptions/NoneOfException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/NotBlankException.php b/vendor/respect/validation/library/Exceptions/NotBlankException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/NotEmptyException.php b/vendor/respect/validation/library/Exceptions/NotEmptyException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/NotException.php b/vendor/respect/validation/library/Exceptions/NotException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/NotOptionalException.php b/vendor/respect/validation/library/Exceptions/NotOptionalException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/NullTypeException.php b/vendor/respect/validation/library/Exceptions/NullTypeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/NumericException.php b/vendor/respect/validation/library/Exceptions/NumericException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ObjectTypeException.php b/vendor/respect/validation/library/Exceptions/ObjectTypeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/OddException.php b/vendor/respect/validation/library/Exceptions/OddException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/OneOfException.php b/vendor/respect/validation/library/Exceptions/OneOfException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/OptionalException.php b/vendor/respect/validation/library/Exceptions/OptionalException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/PerfectSquareException.php b/vendor/respect/validation/library/Exceptions/PerfectSquareException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/PeselException.php b/vendor/respect/validation/library/Exceptions/PeselException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/PhoneException.php b/vendor/respect/validation/library/Exceptions/PhoneException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/PhpLabelException.php b/vendor/respect/validation/library/Exceptions/PhpLabelException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/PositiveException.php b/vendor/respect/validation/library/Exceptions/PositiveException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/PostalCodeException.php b/vendor/respect/validation/library/Exceptions/PostalCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/PrimeNumberException.php b/vendor/respect/validation/library/Exceptions/PrimeNumberException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/PrntException.php b/vendor/respect/validation/library/Exceptions/PrntException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/PunctException.php b/vendor/respect/validation/library/Exceptions/PunctException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ReadableException.php b/vendor/respect/validation/library/Exceptions/ReadableException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/RecursiveExceptionIterator.php b/vendor/respect/validation/library/Exceptions/RecursiveExceptionIterator.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/RegexException.php b/vendor/respect/validation/library/Exceptions/RegexException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ResourceTypeException.php b/vendor/respect/validation/library/Exceptions/ResourceTypeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/RomanException.php b/vendor/respect/validation/library/Exceptions/RomanException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ScalarValException.php b/vendor/respect/validation/library/Exceptions/ScalarValException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SfException.php b/vendor/respect/validation/library/Exceptions/SfException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SizeException.php b/vendor/respect/validation/library/Exceptions/SizeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SlugException.php b/vendor/respect/validation/library/Exceptions/SlugException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SpaceException.php b/vendor/respect/validation/library/Exceptions/SpaceException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/StartsWithException.php b/vendor/respect/validation/library/Exceptions/StartsWithException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/StringTypeException.php b/vendor/respect/validation/library/Exceptions/StringTypeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/AdSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/AdSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/AeSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/AeSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/AfSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/AfSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/AgSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/AgSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/AiSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/AiSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/AlSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/AlSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/AmSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/AmSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/AnSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/AnSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/AoSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/AoSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/AqSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/AqSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/ArSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/ArSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/AsSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/AsSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/AtSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/AtSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/AuSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/AuSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/AwSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/AwSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/AxSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/AxSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/AzSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/AzSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BaSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BaSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BbSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BbSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BdSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BdSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BeSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BeSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BfSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BfSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BgSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BgSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BhSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BhSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BiSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BiSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BjSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BjSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BlSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BlSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BmSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BmSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BnSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BnSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BoSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BoSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BqSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BqSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BrSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BrSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BsSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BsSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BtSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BtSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BvSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BvSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BwSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BwSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BySubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BySubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/BzSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/BzSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CaSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CaSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CcSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CcSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CdSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CdSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CfSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CfSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CgSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CgSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/ChSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/ChSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CiSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CiSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CkSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CkSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/ClSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/ClSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CmSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CmSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CnSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CnSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CoSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CoSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CrSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CrSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CsSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CsSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CuSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CuSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CvSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CvSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CwSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CwSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CxSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CxSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CySubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CySubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/CzSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/CzSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/DeSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/DeSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/DjSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/DjSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/DkSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/DkSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/DmSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/DmSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/DoSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/DoSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/DzSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/DzSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/EcSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/EcSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/EeSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/EeSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/EgSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/EgSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/EhSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/EhSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/ErSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/ErSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/EsSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/EsSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/EtSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/EtSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/FiSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/FiSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/FjSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/FjSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/FkSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/FkSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/FmSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/FmSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/FoSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/FoSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/FrSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/FrSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GaSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GaSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GbSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GbSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GdSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GdSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GeSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GeSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GfSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GfSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GgSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GgSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GhSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GhSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GiSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GiSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GlSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GlSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GmSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GmSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GnSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GnSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GpSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GpSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GqSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GqSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GrSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GrSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GsSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GsSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GtSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GtSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GuSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GuSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GwSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GwSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/GySubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/GySubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/HkSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/HkSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/HmSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/HmSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/HnSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/HnSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/HrSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/HrSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/HtSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/HtSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/HuSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/HuSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/IdSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/IdSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/IeSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/IeSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/IlSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/IlSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/ImSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/ImSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/InSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/InSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/IoSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/IoSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/IqSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/IqSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/IrSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/IrSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/IsSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/IsSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/ItSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/ItSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/JeSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/JeSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/JmSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/JmSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/JoSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/JoSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/JpSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/JpSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/KeSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/KeSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/KgSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/KgSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/KhSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/KhSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/KiSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/KiSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/KmSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/KmSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/KnSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/KnSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/KpSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/KpSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/KrSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/KrSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/KwSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/KwSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/KySubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/KySubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/KzSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/KzSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/LaSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/LaSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/LbSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/LbSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/LcSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/LcSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/LiSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/LiSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/LkSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/LkSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/LrSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/LrSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/LsSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/LsSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/LtSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/LtSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/LuSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/LuSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/LvSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/LvSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/LySubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/LySubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MaSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MaSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/McSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/McSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MdSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MdSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MeSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MeSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MfSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MfSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MgSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MgSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MhSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MhSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MkSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MkSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MlSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MlSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MmSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MmSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MnSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MnSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MoSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MoSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MpSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MpSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MqSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MqSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MrSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MrSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MsSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MsSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MtSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MtSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MuSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MuSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MvSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MvSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MwSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MwSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MxSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MxSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MySubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MySubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/MzSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/MzSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/NaSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/NaSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/NcSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/NcSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/NeSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/NeSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/NfSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/NfSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/NgSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/NgSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/NiSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/NiSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/NlSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/NlSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/NoSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/NoSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/NpSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/NpSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/NrSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/NrSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/NuSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/NuSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/NzSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/NzSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/OmSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/OmSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/PaSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/PaSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/PeSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/PeSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/PfSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/PfSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/PgSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/PgSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/PhSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/PhSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/PkSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/PkSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/PlSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/PlSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/PmSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/PmSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/PnSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/PnSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/PrSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/PrSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/PsSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/PsSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/PtSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/PtSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/PwSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/PwSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/PySubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/PySubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/QaSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/QaSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/ReSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/ReSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/RoSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/RoSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/RsSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/RsSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/RuSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/RuSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/RwSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/RwSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SaSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SaSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SbSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SbSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/ScSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/ScSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SdSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SdSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SeSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SeSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SgSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SgSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/ShSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/ShSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SiSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SiSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SjSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SjSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SkSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SkSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SlSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SlSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SmSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SmSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SnSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SnSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SoSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SoSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SrSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SrSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SsSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SsSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/StSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/StSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SvSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SvSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SxSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SxSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SySubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SySubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/SzSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/SzSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/TcSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/TcSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/TdSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/TdSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/TfSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/TfSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/TgSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/TgSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/ThSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/ThSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/TjSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/TjSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/TkSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/TkSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/TlSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/TlSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/TmSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/TmSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/TnSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/TnSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/ToSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/ToSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/TrSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/TrSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/TtSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/TtSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/TvSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/TvSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/TwSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/TwSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/TzSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/TzSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/UaSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/UaSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/UgSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/UgSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/UmSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/UmSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/UsSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/UsSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/UySubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/UySubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/UzSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/UzSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/VaSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/VaSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/VcSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/VcSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/VeSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/VeSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/VgSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/VgSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/ViSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/ViSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/VnSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/VnSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/VuSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/VuSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/WfSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/WfSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/WsSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/WsSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/XkSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/XkSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/YeSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/YeSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/YtSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/YtSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/ZaSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/ZaSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/ZmSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/ZmSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCode/ZwSubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCode/ZwSubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SubdivisionCodeException.php b/vendor/respect/validation/library/Exceptions/SubdivisionCodeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/SymbolicLinkException.php b/vendor/respect/validation/library/Exceptions/SymbolicLinkException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/TldException.php b/vendor/respect/validation/library/Exceptions/TldException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/TrueValException.php b/vendor/respect/validation/library/Exceptions/TrueValException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/TypeException.php b/vendor/respect/validation/library/Exceptions/TypeException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/UploadedException.php b/vendor/respect/validation/library/Exceptions/UploadedException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/UppercaseException.php b/vendor/respect/validation/library/Exceptions/UppercaseException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/UrlException.php b/vendor/respect/validation/library/Exceptions/UrlException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ValidationException.php b/vendor/respect/validation/library/Exceptions/ValidationException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/VersionException.php b/vendor/respect/validation/library/Exceptions/VersionException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/VideoUrlException.php b/vendor/respect/validation/library/Exceptions/VideoUrlException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/VowelException.php b/vendor/respect/validation/library/Exceptions/VowelException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/WhenException.php b/vendor/respect/validation/library/Exceptions/WhenException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/WritableException.php b/vendor/respect/validation/library/Exceptions/WritableException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/XdigitException.php b/vendor/respect/validation/library/Exceptions/XdigitException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/YesException.php b/vendor/respect/validation/library/Exceptions/YesException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Exceptions/ZendException.php b/vendor/respect/validation/library/Exceptions/ZendException.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Factory.php b/vendor/respect/validation/library/Factory.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/AbstractComposite.php b/vendor/respect/validation/library/Rules/AbstractComposite.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/AbstractCtypeRule.php b/vendor/respect/validation/library/Rules/AbstractCtypeRule.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/AbstractFilterRule.php b/vendor/respect/validation/library/Rules/AbstractFilterRule.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/AbstractInterval.php b/vendor/respect/validation/library/Rules/AbstractInterval.php old mode 100755 new mode 100644 index 5879d992ef0ef1544e73301ed8b1a88c28160bf6..09758633ae1f15a433a6fbd2d1bf08e3a4026bcd --- a/vendor/respect/validation/library/Rules/AbstractInterval.php +++ b/vendor/respect/validation/library/Rules/AbstractInterval.php @@ -25,6 +25,11 @@ abstract class AbstractInterval extends AbstractRule $this->inclusive = $inclusive; } + protected function isAbleToCompareValues($left, $right) + { + return is_scalar($left) === is_scalar($right); + } + protected function filterInterval($value) { if (!is_string($value) || is_numeric($value) || empty($value)) { diff --git a/vendor/respect/validation/library/Rules/AbstractRegexRule.php b/vendor/respect/validation/library/Rules/AbstractRegexRule.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/AbstractRelated.php b/vendor/respect/validation/library/Rules/AbstractRelated.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/AbstractRule.php b/vendor/respect/validation/library/Rules/AbstractRule.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/AbstractSearcher.php b/vendor/respect/validation/library/Rules/AbstractSearcher.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/AbstractWrapper.php b/vendor/respect/validation/library/Rules/AbstractWrapper.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Age.php b/vendor/respect/validation/library/Rules/Age.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/AllOf.php b/vendor/respect/validation/library/Rules/AllOf.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Alnum.php b/vendor/respect/validation/library/Rules/Alnum.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Alpha.php b/vendor/respect/validation/library/Rules/Alpha.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/AlwaysInvalid.php b/vendor/respect/validation/library/Rules/AlwaysInvalid.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/AlwaysValid.php b/vendor/respect/validation/library/Rules/AlwaysValid.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/ArrayType.php b/vendor/respect/validation/library/Rules/ArrayType.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/ArrayVal.php b/vendor/respect/validation/library/Rules/ArrayVal.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Attribute.php b/vendor/respect/validation/library/Rules/Attribute.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Bank.php b/vendor/respect/validation/library/Rules/Bank.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/BankAccount.php b/vendor/respect/validation/library/Rules/BankAccount.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Base.php b/vendor/respect/validation/library/Rules/Base.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Between.php b/vendor/respect/validation/library/Rules/Between.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Bic.php b/vendor/respect/validation/library/Rules/Bic.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/BoolType.php b/vendor/respect/validation/library/Rules/BoolType.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/BoolVal.php b/vendor/respect/validation/library/Rules/BoolVal.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Bsn.php b/vendor/respect/validation/library/Rules/Bsn.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Call.php b/vendor/respect/validation/library/Rules/Call.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/CallableType.php b/vendor/respect/validation/library/Rules/CallableType.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Callback.php b/vendor/respect/validation/library/Rules/Callback.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Charset.php b/vendor/respect/validation/library/Rules/Charset.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Cnh.php b/vendor/respect/validation/library/Rules/Cnh.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Cnpj.php b/vendor/respect/validation/library/Rules/Cnpj.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Cntrl.php b/vendor/respect/validation/library/Rules/Cntrl.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Consonant.php b/vendor/respect/validation/library/Rules/Consonant.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Contains.php b/vendor/respect/validation/library/Rules/Contains.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Countable.php b/vendor/respect/validation/library/Rules/Countable.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/CountryCode.php b/vendor/respect/validation/library/Rules/CountryCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Cpf.php b/vendor/respect/validation/library/Rules/Cpf.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/CreditCard.php b/vendor/respect/validation/library/Rules/CreditCard.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/CurrencyCode.php b/vendor/respect/validation/library/Rules/CurrencyCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Date.php b/vendor/respect/validation/library/Rules/Date.php old mode 100755 new mode 100644 index eb47d16db423b9683e04b44cc68e579ac73f0d66..342e1d434fcc73104412f03cf69908e5a7944d90 --- a/vendor/respect/validation/library/Rules/Date.php +++ b/vendor/respect/validation/library/Rules/Date.php @@ -49,8 +49,39 @@ class Date extends AbstractRule $this->format = $exceptionalFormats[$this->format]; } - $info = date_parse_from_format($this->format, $inputString); + return $this->isValidForFormatProvided($input); + } + + private function isValidForFormatProvided($input) + { + $info = date_parse_from_format($this->format, $input); + if (!$this->isParsable($info)) { + return false; + } + + if ($this->hasDateFormat()) { + return $this->hasValidDate($info); + } + + return true; + } + private function isParsable(array $info) + { return ($info['error_count'] === 0 && $info['warning_count'] === 0); } + + private function hasDateFormat() + { + return preg_match('/[djSFmMnYy]/', $this->format) > 0; + } + + private function hasValidDate(array $info) + { + if ($info['day']) { + return checkdate((int) $info['month'], $info['day'], (int) $info['year']); + } + + return checkdate($info['month'] ?: 1, $info['day'] ?: 1, $info['year'] ?: 1); + } } diff --git a/vendor/respect/validation/library/Rules/Digit.php b/vendor/respect/validation/library/Rules/Digit.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Directory.php b/vendor/respect/validation/library/Rules/Directory.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Domain.php b/vendor/respect/validation/library/Rules/Domain.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Each.php b/vendor/respect/validation/library/Rules/Each.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Email.php b/vendor/respect/validation/library/Rules/Email.php old mode 100755 new mode 100644 index d6ef31d5cfebfd8616663428276bf297621ea4a6..9de8547ce1bb75dabf71d0086469f19d80b99c08 --- a/vendor/respect/validation/library/Rules/Email.php +++ b/vendor/respect/validation/library/Rules/Email.php @@ -33,9 +33,13 @@ class Email extends AbstractRule public function validate($input) { + if (!is_string($input)) { + return false; + } + $emailValidator = $this->getEmailValidator(); if (!$emailValidator instanceof EmailValidator) { - return is_string($input) && filter_var($input, FILTER_VALIDATE_EMAIL); + return (bool) filter_var($input, FILTER_VALIDATE_EMAIL); } if (!class_exists('Egulias\\EmailValidator\\Validation\\RFCValidation')) { diff --git a/vendor/respect/validation/library/Rules/EndsWith.php b/vendor/respect/validation/library/Rules/EndsWith.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Equals.php b/vendor/respect/validation/library/Rules/Equals.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Even.php b/vendor/respect/validation/library/Rules/Even.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Executable.php b/vendor/respect/validation/library/Rules/Executable.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Exists.php b/vendor/respect/validation/library/Rules/Exists.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Extension.php b/vendor/respect/validation/library/Rules/Extension.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Factor.php b/vendor/respect/validation/library/Rules/Factor.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/FalseVal.php b/vendor/respect/validation/library/Rules/FalseVal.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Fibonacci.php b/vendor/respect/validation/library/Rules/Fibonacci.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/File.php b/vendor/respect/validation/library/Rules/File.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/FilterVar.php b/vendor/respect/validation/library/Rules/FilterVar.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Finite.php b/vendor/respect/validation/library/Rules/Finite.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/FloatType.php b/vendor/respect/validation/library/Rules/FloatType.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/FloatVal.php b/vendor/respect/validation/library/Rules/FloatVal.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Graph.php b/vendor/respect/validation/library/Rules/Graph.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/HexRgbColor.php b/vendor/respect/validation/library/Rules/HexRgbColor.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Identical.php b/vendor/respect/validation/library/Rules/Identical.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/IdentityCard.php b/vendor/respect/validation/library/Rules/IdentityCard.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Image.php b/vendor/respect/validation/library/Rules/Image.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Imei.php b/vendor/respect/validation/library/Rules/Imei.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/In.php b/vendor/respect/validation/library/Rules/In.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Infinite.php b/vendor/respect/validation/library/Rules/Infinite.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Instance.php b/vendor/respect/validation/library/Rules/Instance.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/IntType.php b/vendor/respect/validation/library/Rules/IntType.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/IntVal.php b/vendor/respect/validation/library/Rules/IntVal.php old mode 100755 new mode 100644 index 8f8ff81eb48b19fce79eabaa7754b7ec492800bb..e5c89f1f871cc333a0f633f7229c24b649ebed42 --- a/vendor/respect/validation/library/Rules/IntVal.php +++ b/vendor/respect/validation/library/Rules/IntVal.php @@ -19,6 +19,6 @@ class IntVal extends AbstractRule return false; } - return false !== filter_var($input, FILTER_VALIDATE_INT); + return false !== filter_var($input, FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_OCTAL); } } diff --git a/vendor/respect/validation/library/Rules/Ip.php b/vendor/respect/validation/library/Rules/Ip.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Iterable.php b/vendor/respect/validation/library/Rules/Iterable.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/IterableType.php b/vendor/respect/validation/library/Rules/IterableType.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Json.php b/vendor/respect/validation/library/Rules/Json.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Key.php b/vendor/respect/validation/library/Rules/Key.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/KeyNested.php b/vendor/respect/validation/library/Rules/KeyNested.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/KeySet.php b/vendor/respect/validation/library/Rules/KeySet.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/KeyValue.php b/vendor/respect/validation/library/Rules/KeyValue.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/LanguageCode.php b/vendor/respect/validation/library/Rules/LanguageCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/LeapDate.php b/vendor/respect/validation/library/Rules/LeapDate.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/LeapYear.php b/vendor/respect/validation/library/Rules/LeapYear.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Length.php b/vendor/respect/validation/library/Rules/Length.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Locale/Factory.php b/vendor/respect/validation/library/Rules/Locale/Factory.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Locale/GermanBank.php b/vendor/respect/validation/library/Rules/Locale/GermanBank.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Locale/GermanBankAccount.php b/vendor/respect/validation/library/Rules/Locale/GermanBankAccount.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Locale/GermanBic.php b/vendor/respect/validation/library/Rules/Locale/GermanBic.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Locale/PlIdentityCard.php b/vendor/respect/validation/library/Rules/Locale/PlIdentityCard.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Lowercase.php b/vendor/respect/validation/library/Rules/Lowercase.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/MacAddress.php b/vendor/respect/validation/library/Rules/MacAddress.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Max.php b/vendor/respect/validation/library/Rules/Max.php old mode 100755 new mode 100644 index 2bad580062662d4f118fdcfc5b0b1e5dad99db1f..79d97fbf63ed49328b5285d22c8a1bedf78bf26e --- a/vendor/respect/validation/library/Rules/Max.php +++ b/vendor/respect/validation/library/Rules/Max.php @@ -15,10 +15,17 @@ class Max extends AbstractInterval { public function validate($input) { + $filteredInput = $this->filterInterval($input); + $filteredInterval = $this->filterInterval($this->interval); + + if (!$this->isAbleToCompareValues($filteredInput, $filteredInterval)) { + return false; + } + if ($this->inclusive) { - return $this->filterInterval($input) <= $this->filterInterval($this->interval); + return $filteredInput <= $filteredInterval; } - return $this->filterInterval($input) < $this->filterInterval($this->interval); + return $filteredInput < $filteredInterval; } } diff --git a/vendor/respect/validation/library/Rules/Mimetype.php b/vendor/respect/validation/library/Rules/Mimetype.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Min.php b/vendor/respect/validation/library/Rules/Min.php old mode 100755 new mode 100644 index 994e813ba6c6e94e52a15b0aac7984f257ab7a50..26b5085bda2b98743ebf8bce1d7c129747801bd4 --- a/vendor/respect/validation/library/Rules/Min.php +++ b/vendor/respect/validation/library/Rules/Min.php @@ -15,10 +15,17 @@ class Min extends AbstractInterval { public function validate($input) { + $filteredInput = $this->filterInterval($input); + $filteredInterval = $this->filterInterval($this->interval); + + if (!$this->isAbleToCompareValues($filteredInput, $filteredInterval)) { + return false; + } + if ($this->inclusive) { - return $this->filterInterval($input) >= $this->filterInterval($this->interval); + return $filteredInput >= $filteredInterval; } - return $this->filterInterval($input) > $this->filterInterval($this->interval); + return $filteredInput > $filteredInterval; } } diff --git a/vendor/respect/validation/library/Rules/MinimumAge.php b/vendor/respect/validation/library/Rules/MinimumAge.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Multiple.php b/vendor/respect/validation/library/Rules/Multiple.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Negative.php b/vendor/respect/validation/library/Rules/Negative.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/NfeAccessKey.php b/vendor/respect/validation/library/Rules/NfeAccessKey.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/No.php b/vendor/respect/validation/library/Rules/No.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/NoWhitespace.php b/vendor/respect/validation/library/Rules/NoWhitespace.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/NoneOf.php b/vendor/respect/validation/library/Rules/NoneOf.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Not.php b/vendor/respect/validation/library/Rules/Not.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/NotBlank.php b/vendor/respect/validation/library/Rules/NotBlank.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/NotEmpty.php b/vendor/respect/validation/library/Rules/NotEmpty.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/NotOptional.php b/vendor/respect/validation/library/Rules/NotOptional.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/NullType.php b/vendor/respect/validation/library/Rules/NullType.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Numeric.php b/vendor/respect/validation/library/Rules/Numeric.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/ObjectType.php b/vendor/respect/validation/library/Rules/ObjectType.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Odd.php b/vendor/respect/validation/library/Rules/Odd.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/OneOf.php b/vendor/respect/validation/library/Rules/OneOf.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Optional.php b/vendor/respect/validation/library/Rules/Optional.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/PerfectSquare.php b/vendor/respect/validation/library/Rules/PerfectSquare.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Pesel.php b/vendor/respect/validation/library/Rules/Pesel.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Phone.php b/vendor/respect/validation/library/Rules/Phone.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/PhpLabel.php b/vendor/respect/validation/library/Rules/PhpLabel.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Positive.php b/vendor/respect/validation/library/Rules/Positive.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/PostalCode.php b/vendor/respect/validation/library/Rules/PostalCode.php old mode 100755 new mode 100644 index a2847a730456a5a553379fe7c261c1524d8fab11..ebdba1670df89a07ff571adaa06fb5277a3b6fc0 --- a/vendor/respect/validation/library/Rules/PostalCode.php +++ b/vendor/respect/validation/library/Rules/PostalCode.php @@ -21,157 +21,166 @@ class PostalCode extends Regex * @link http://download.geonames.org/export/dump/countryInfo.txt */ public $postalCodes = [ - 'AD' => "/^(?:AD)*(\d{3})$/", - 'AM' => "/^(\d{6})$/", - 'AR' => "/^([A-Z]\d{4}[A-Z]{3})$/", - 'AT' => "/^(\d{4})$/", - 'AU' => "/^(\d{4})$/", - 'AX' => "/^(?:FI)*(\d{5})$/", - 'AZ' => "/^(?:AZ)*(\d{4})$/", - 'BA' => "/^(\d{5})$/", - 'BB' => "/^(?:BB)*(\d{5})$/", - 'BD' => "/^(\d{4})$/", - 'BE' => "/^(\d{4})$/", - 'BG' => "/^(\d{4})$/", - 'BH' => "/^(\d{3}\d?)$/", - 'BM' => "/^([A-Z]{2}\d{2})$/", - 'BN' => "/^([A-Z]{2}\d{4})$/", - 'BR' => "/^(\d{8}|\d{5}-\d{3})$/", - 'BY' => "/^(\d{6})$/", - 'CA' => "/^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ]) ?(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$/", - 'CH' => "/^(\d{4})$/", - 'CL' => "/^(\d{7})$/", - 'CN' => "/^(\d{6})$/", - 'CR' => "/^(\d{4})$/", - 'CS' => "/^((\d{5})|(\d{3}\040\d{2}))$/", - 'CU' => "/^(?:CP)*(\d{5})$/", - 'CV' => "/^(\d{4})$/", - 'CX' => "/^(\d{4})$/", - 'CY' => "/^(\d{4})$/", - 'CZ' => "/^(\d{5})$/", - 'DE' => "/^(\d{5})$/", - 'DK' => "/^(\d{4})$/", - 'DO' => "/^(\d{5})$/", - 'DZ' => "/^(\d{5})$/", - 'EC' => "/^([a-zA-Z]\d{4}[a-zA-Z])$/", - 'EE' => "/^(\d{5})$/", - 'EG' => "/^(\d{5})$/", - 'ES' => "/^(\d{5})$/", - 'ET' => "/^(\d{4})$/", - 'FI' => "/^(?:FI)*(\d{5})$/", - 'FM' => "/^(\d{5})$/", - 'FO' => "/^(?:FO)*(\d{3})$/", - 'FR' => "/^(\d{5})$/", + 'AD' => '/^(?:AD)*(\d{3})$/', + 'AL' => '/^(\d{4})$/', + 'AM' => '/^(\d{6})$/', + 'AR' => '/^[A-Z]?\d{4}[A-Z]{0,3}$/', + 'AS' => '/96799/', + 'AT' => '/^(\d{4})$/', + 'AU' => '/^(\d{4})$/', + 'AX' => '/^(?:FI)*(\d{5})$/', + 'AZ' => '/^(?:AZ)*(\d{4})$/', + 'BA' => '/^(\d{5})$/', + 'BB' => '/^(?:BB)*(\d{5})$/', + 'BD' => '/^(\d{4})$/', + 'BE' => '/^(\d{4})$/', + 'BG' => '/^(\d{4})$/', + 'BH' => '/^(\d{3}\d?)$/', + 'BL' => '/^(\d{5})$/', + 'BM' => '/^([A-Z]{2}\d{2})$/', + 'BN' => '/^([A-Z]{2}\d{4})$/', + 'BR' => '/^\d{5}-?\d{3}$/', + 'BY' => '/^(\d{6})$/', + 'CA' => '/^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ]) ?(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$/', + 'CH' => '/^(\d{4})$/', + 'CL' => '/^(\d{7})$/', + 'CN' => '/^(\d{6})$/', + 'CO' => '/^(\d{6})$/', + 'CR' => '/^(\d{5})$/', + 'CS' => '/^(\d{5})$/', + 'CU' => '/^(?:CP)*(\d{5})$/', + 'CV' => '/^(\d{4})$/', + 'CX' => '/^(\d{4})$/', + 'CY' => '/^(\d{4})$/', + 'CZ' => '/^\d{3}\s?\d{2}$/', + 'DE' => '/^(\d{5})$/', + 'DK' => '/^(\d{4})$/', + 'DO' => '/^(\d{5})$/', + 'DZ' => '/^(\d{5})$/', + 'EC' => '/^([a-zA-Z]\d{4}[a-zA-Z])$/', + 'EE' => '/^(\d{5})$/', + 'EG' => '/^(\d{5})$/', + 'ES' => '/^(\d{5})$/', + 'ET' => '/^(\d{4})$/', + 'FI' => '/^(?:FI)*(\d{5})$/', + 'FM' => '/^(\d{5})$/', + 'FO' => '/^(?:FO)*(\d{3})$/', + 'FR' => '/^(\d{5})$/', 'GB' => '/^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) [0-9][A-Za-z]{2})$/', - 'GE' => "/^(\d{4})$/", - 'GF' => "/^((97|98)3\d{2})$/", - 'GG' => "/^(([A-Z]\d{2}[A-Z]{2})|([A-Z]\d{3}[A-Z]{2})|([A-Z]{2}\d{2}[A-Z]{2})|([A-Z]{2}\d{3}[A-Z]{2})|([A-Z]\d[A-Z]\d[A-Z]{2})|([A-Z]{2}\d[A-Z]\d[A-Z]{2})|(GIR0AA))$/", - 'GL' => "/^(\d{4})$/", - 'GP' => "/^((97|98)\d{3})$/", - 'GR' => "/^(\d{5})$/", - 'GT' => "/^(\d{5})$/", - 'GU' => "/^(969\d{2})$/", - 'GW' => "/^(\d{4})$/", - 'HN' => "/^([A-Z]{2}\d{4})$/", - 'HR' => "/^(?:HR)*(\d{5})$/", - 'HT' => "/^(?:HT)*(\d{4})$/", - 'HU' => "/^(\d{4})$/", - 'ID' => "/^(\d{5})$/", - 'IL' => "/^(\d{5})$/", - 'IM' => "/^(([A-Z]\d{2}[A-Z]{2})|([A-Z]\d{3}[A-Z]{2})|([A-Z]{2}\d{2}[A-Z]{2})|([A-Z]{2}\d{3}[A-Z]{2})|([A-Z]\d[A-Z]\d[A-Z]{2})|([A-Z]{2}\d[A-Z]\d[A-Z]{2})|(GIR0AA))$/", - 'IN' => "/^(\d{6})$/", - 'IQ' => "/^(\d{5})$/", - 'IR' => "/^(\d{10})$/", - 'IS' => "/^(\d{3})$/", - 'IT' => "/^(\d{5})$/", - 'JE' => "/^(([A-Z]\d{2}[A-Z]{2})|([A-Z]\d{3}[A-Z]{2})|([A-Z]{2}\d{2}[A-Z]{2})|([A-Z]{2}\d{3}[A-Z]{2})|([A-Z]\d[A-Z]\d[A-Z]{2})|([A-Z]{2}\d[A-Z]\d[A-Z]{2})|(GIR0AA))$/", - 'JO' => "/^(\d{5})$/", - 'JP' => "/^(\d{7})$/", - 'KE' => "/^(\d{5})$/", - 'KG' => "/^(\d{6})$/", - 'KH' => "/^(\d{5})$/", - 'KP' => "/^(\d{6})$/", - 'KR' => "/^(?:SEOUL)*(\d{6})$/", - 'KW' => "/^(\d{5})$/", - 'KZ' => "/^(\d{6})$/", - 'LA' => "/^(\d{5})$/", - 'LB' => "/^(\d{4}(\d{4})?)$/", - 'LI' => "/^(\d{4})$/", - 'LK' => "/^(\d{5})$/", - 'LR' => "/^(\d{4})$/", - 'LS' => "/^(\d{3})$/", - 'LT' => "/^(?:LT)*(\d{5})$/", - 'LU' => "/^(\d{4})$/", - 'LV' => "/^(?:LV)*(\d{4})$/", - 'MA' => "/^(\d{5})$/", - 'MC' => "/^(\d{5})$/", - 'MD' => "/^(?:MD)*(\d{4})$/", - 'ME' => "/^(\d{5})$/", - 'MG' => "/^(\d{3})$/", - 'MK' => "/^(\d{4})$/", - 'MM' => "/^(\d{5})$/", - 'MN' => "/^(\d{6})$/", - 'MQ' => "/^(\d{5})$/", - 'MT' => "/^([A-Z]{3}\d{2}\d?)$/", - 'MV' => "/^(\d{5})$/", - 'MX' => "/^(\d{5})$/", - 'MY' => "/^(\d{5})$/", - 'MZ' => "/^(\d{4})$/", - 'NC' => "/^(\d{5})$/", - 'NE' => "/^(\d{4})$/", - 'NF' => "/^(\d{4})$/", - 'NG' => "/^(\d{6})$/", - 'NI' => "/^(\d{7})$/", - 'NL' => "/^(\d{4} ?[A-Z]{2})$/", - 'NO' => "/^(\d{4})$/", - 'NP' => "/^(\d{5})$/", - 'NZ' => "/^(\d{4})$/", - 'OM' => "/^(\d{3})$/", - 'PF' => "/^((97|98)7\d{2})$/", - 'PG' => "/^(\d{3})$/", - 'PH' => "/^(\d{4})$/", - 'PK' => "/^(\d{5})$/", - 'PL' => "/^(\d{2}-\d{3})$/", + 'GE' => '/^(\d{4})$/', + 'GF' => '/^((97|98)3\d{2})$/', + 'GG' => '/^((?:(?:[A-PR-UWYZ][A-HK-Y]\d[ABEHMNPRV-Y0-9]|[A-PR-UWYZ]\d[A-HJKPS-UW0-9])\s\d[ABD-HJLNP-UW-Z]{2})|GIR\s?0AA)$/', + 'GL' => '/^(\d{4})$/', + 'GP' => '/^((97|98)\d{3})$/', + 'GR' => '/^(\d{5})$/', + 'GT' => '/^(\d{5})$/', + 'GU' => '/^(969\d{2})$/', + 'GW' => '/^(\d{4})$/', + 'HN' => '/^([A-Z]{2}\d{4})$/', + 'HR' => '/^(?:HR)*(\d{5})$/', + 'HT' => '/^(?:HT)*(\d{4})$/', + 'HU' => '/^(\d{4})$/', + 'ID' => '/^(\d{5})$/', + 'IE' => '/^[A-Z]\d{2}$|^[A-Z]{3}[A-Z]{4}$/', + 'IL' => '/^(\d{5})$/', + 'IM' => '/^((?:(?:[A-PR-UWYZ][A-HK-Y]\d[ABEHMNPRV-Y0-9]|[A-PR-UWYZ]\d[A-HJKPS-UW0-9])\s\d[ABD-HJLNP-UW-Z]{2})|GIR\s?0AA)$/', + 'IN' => '/^(\d{6})$/', + 'IQ' => '/^(\d{5})$/', + 'IR' => '/^(\d{10})$/', + 'IS' => '/^(\d{3})$/', + 'IT' => '/^(\d{5})$/', + 'JE' => '/^((?:(?:[A-PR-UWYZ][A-HK-Y]\d[ABEHMNPRV-Y0-9]|[A-PR-UWYZ]\d[A-HJKPS-UW0-9])\s\d[ABD-HJLNP-UW-Z]{2})|GIR\s?0AA)$/', + 'JO' => '/^(\d{5})$/', + 'JP' => '/^\d{3}-\d{4}$/', + 'KE' => '/^(\d{5})$/', + 'KG' => '/^(\d{6})$/', + 'KH' => '/^(\d{5})$/', + 'KP' => '/^(\d{6})$/', + 'KR' => '/^(\d{5})$/', + 'KW' => '/^(\d{5})$/', + 'KZ' => '/^(\d{6})$/', + 'LA' => '/^(\d{5})$/', + 'LB' => '/^(\d{4}(\d{4})?)$/', + 'LI' => '/^(\d{4})$/', + 'LK' => '/^(\d{5})$/', + 'LR' => '/^(\d{4})$/', + 'LS' => '/^(\d{3})$/', + 'LT' => '/^(?:LT)*(\d{5})$/', + 'LU' => '/^(?:L-)?\d{4}$/', + 'LV' => '/^(?:LV)*(\d{4})$/', + 'MA' => '/^(\d{5})$/', + 'MC' => '/^(\d{5})$/', + 'MD' => '/^MD-\d{4}$/', + 'ME' => '/^(\d{5})$/', + 'MF' => '/^(\d{5})$/', + 'MG' => '/^(\d{3})$/', + 'MH' => '/^969\d{2}(-\d{4})$/', + 'MK' => '/^(\d{4})$/', + 'MM' => '/^(\d{5})$/', + 'MN' => '/^(\d{6})$/', + 'MP' => '/^9695\d{1}$/', + 'MQ' => '/^(\d{5})$/', + 'MT' => '/^[A-Z]{3}\s?\d{4}$/', + 'MV' => '/^(\d{5})$/', + 'MX' => '/^(\d{5})$/', + 'MY' => '/^(\d{5})$/', + 'MZ' => '/^(\d{4})$/', + 'NC' => '/^(\d{5})$/', + 'NE' => '/^(\d{4})$/', + 'NF' => '/^(\d{4})$/', + 'NG' => '/^(\d{6})$/', + 'NI' => '/^(\d{7})$/', + 'NL' => '/^(\d{4} ?[A-Z]{2})$/', + 'NO' => '/^(\d{4})$/', + 'NP' => '/^(\d{5})$/', + 'NZ' => '/^(\d{4})$/', + 'OM' => '/^(\d{3})$/', + 'PF' => '/^((97|98)7\d{2})$/', + 'PG' => '/^(\d{3})$/', + 'PH' => '/^(\d{4})$/', + 'PK' => '/^(\d{5})$/', + 'PL' => '/^\d{2}-\d{3}$/', 'PM' => '/^(97500)$/', - 'PR' => "/^(\d{9})$/", - 'PT' => "/^(\d{7})$/", + 'PR' => '/^00[679]\d{2}(?:-\d{4})?$/', + 'PT' => '/^\d{4}-?\d{3}$/', 'PW' => '/^(96940)$/', - 'PY' => "/^(\d{4})$/", - 'RE' => "/^((97|98)(4|7|8)\d{2})$/", - 'RO' => "/^(\d{6})$/", - 'RS' => "/^(\d{6})$/", - 'RU' => "/^(\d{6})$/", - 'SA' => "/^(\d{5})$/", - 'SD' => "/^(\d{5})$/", - 'SE' => "/^(?:SE)*(\d{5})$/", - 'SG' => "/^(\d{6})$/", + 'PY' => '/^(\d{4})$/', + 'RE' => '/^((97|98)(4|7|8)\d{2})$/', + 'RO' => '/^(\d{6})$/', + 'RS' => '/^(\d{6})$/', + 'RU' => '/^(\d{6})$/', + 'SA' => '/^(\d{5})$/', + 'SD' => '/^(\d{5})$/', + 'SE' => '/^(?:SE)?\d{3}\s\d{2}$/', + 'SG' => '/^(\d{6})$/', 'SH' => '/^(STHL1ZZ)$/', - 'SI' => "/^(?:SI)*(\d{4})$/", - 'SK' => "/^((\d{5})|(\d{3}\040\d{2}))$/", - 'SM' => "/^(4789\d)$/", - 'SN' => "/^(\d{5})$/", - 'SO' => "/^([A-Z]{2}\d{5})$/", - 'SV' => "/^(?:CP)*(\d{4})$/", - 'SZ' => "/^([A-Z]\d{3})$/", + 'SI' => '/^(?:SI)*(\d{4})$/', + 'SJ' => '/^(\d{4})$/', + 'SK' => '/^\d{3}\s?\d{2}$/', + 'SM' => '/^(4789\d)$/', + 'SN' => '/^(\d{5})$/', + 'SO' => '/^([A-Z]{2}\d{5})$/', + 'SV' => '/^(?:CP)*(\d{4})$/', + 'SZ' => '/^([A-Z]\d{3})$/', 'TC' => '/^(TKCA 1ZZ)$/', - 'TH' => "/^(\d{5})$/", - 'TJ' => "/^(\d{6})$/", - 'TM' => "/^(\d{6})$/", - 'TN' => "/^(\d{4})$/", - 'TR' => "/^(\d{5})$/", - 'TW' => "/^(\d{5})$/", - 'UA' => "/^(\d{5})$/", - 'US' => "/^\d{5}(-\d{4})?$/", - 'UY' => "/^(\d{5})$/", - 'UZ' => "/^(\d{6})$/", - 'VA' => "/^(\d{5})$/", - 'VE' => "/^(\d{4})$/", - 'VI' => "/^\d{5}(-\d{4})?$/", - 'VN' => "/^(\d{6})$/", - 'WF' => "/^(986\d{2})$/", - 'YT' => "/^(\d{5})$/", - 'ZA' => "/^(\d{4})$/", - 'ZM' => "/^(\d{5})$/", + 'TH' => '/^(\d{5})$/', + 'TJ' => '/^(\d{6})$/', + 'TM' => '/^(\d{6})$/', + 'TN' => '/^(\d{4})$/', + 'TR' => '/^(\d{5})$/', + 'TW' => '/^(\d{5})$/', + 'UA' => '/^(\d{5})$/', + 'US' => '/^\d{5}(-\d{4})?$/', + 'UY' => '/^(\d{5})$/', + 'UZ' => '/^(\d{6})$/', + 'VA' => '/^(\d{5})$/', + 'VE' => '/^(\d{4})$/', + 'VI' => '/^008\d{2}(?:-\d{4})?$/', + 'VN' => '/^(\d{6})$/', + 'WF' => '/^(986\d{2})$/', + 'YT' => '/^(\d{5})$/', + 'ZA' => '/^(\d{4})$/', + 'ZM' => '/^(\d{5})$/', ]; public $countryCode; diff --git a/vendor/respect/validation/library/Rules/PrimeNumber.php b/vendor/respect/validation/library/Rules/PrimeNumber.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Prnt.php b/vendor/respect/validation/library/Rules/Prnt.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Punct.php b/vendor/respect/validation/library/Rules/Punct.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Readable.php b/vendor/respect/validation/library/Rules/Readable.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Regex.php b/vendor/respect/validation/library/Rules/Regex.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/ResourceType.php b/vendor/respect/validation/library/Rules/ResourceType.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Roman.php b/vendor/respect/validation/library/Rules/Roman.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/ScalarVal.php b/vendor/respect/validation/library/Rules/ScalarVal.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Sf.php b/vendor/respect/validation/library/Rules/Sf.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Size.php b/vendor/respect/validation/library/Rules/Size.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Slug.php b/vendor/respect/validation/library/Rules/Slug.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Space.php b/vendor/respect/validation/library/Rules/Space.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/StartsWith.php b/vendor/respect/validation/library/Rules/StartsWith.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/StringType.php b/vendor/respect/validation/library/Rules/StringType.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/AdSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/AdSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/AeSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/AeSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/AfSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/AfSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/AgSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/AgSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/AiSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/AiSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/AlSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/AlSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/AmSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/AmSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/AnSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/AnSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/AoSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/AoSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/AqSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/AqSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/ArSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/ArSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/AsSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/AsSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/AtSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/AtSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/AuSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/AuSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/AwSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/AwSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/AxSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/AxSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/AzSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/AzSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BaSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BaSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BbSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BbSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BdSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BdSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BeSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BeSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BfSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BfSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BgSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BgSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BhSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BhSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BiSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BiSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BjSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BjSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BlSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BlSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BmSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BmSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BnSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BnSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BoSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BoSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BqSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BqSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BrSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BrSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BsSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BsSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BtSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BtSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BvSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BvSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BwSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BwSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BySubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BySubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/BzSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/BzSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CaSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CaSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CcSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CcSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CdSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CdSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CfSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CfSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CgSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CgSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/ChSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/ChSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CiSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CiSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CkSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CkSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/ClSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/ClSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CmSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CmSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CnSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CnSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CoSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CoSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CrSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CrSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CsSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CsSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CuSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CuSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CvSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CvSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CwSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CwSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CxSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CxSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CySubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CySubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/CzSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/CzSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/DeSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/DeSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/DjSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/DjSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/DkSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/DkSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/DmSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/DmSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/DoSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/DoSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/DzSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/DzSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/EcSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/EcSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/EeSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/EeSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/EgSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/EgSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/EhSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/EhSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/ErSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/ErSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/EsSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/EsSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/EtSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/EtSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/FiSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/FiSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/FjSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/FjSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/FkSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/FkSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/FmSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/FmSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/FoSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/FoSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/FrSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/FrSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GaSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GaSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GbSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GbSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GdSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GdSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GeSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GeSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GfSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GfSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GgSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GgSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GhSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GhSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GiSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GiSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GlSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GlSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GmSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GmSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GnSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GnSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GpSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GpSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GqSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GqSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GrSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GrSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GsSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GsSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GtSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GtSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GuSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GuSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GwSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GwSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/GySubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/GySubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/HkSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/HkSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/HmSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/HmSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/HnSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/HnSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/HrSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/HrSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/HtSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/HtSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/HuSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/HuSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/IdSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/IdSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/IeSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/IeSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/IlSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/IlSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/ImSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/ImSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/InSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/InSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/IoSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/IoSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/IqSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/IqSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/IrSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/IrSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/IsSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/IsSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/ItSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/ItSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/JeSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/JeSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/JmSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/JmSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/JoSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/JoSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/JpSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/JpSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/KeSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/KeSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/KgSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/KgSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/KhSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/KhSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/KiSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/KiSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/KmSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/KmSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/KnSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/KnSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/KpSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/KpSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/KrSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/KrSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/KwSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/KwSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/KySubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/KySubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/KzSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/KzSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/LaSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/LaSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/LbSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/LbSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/LcSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/LcSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/LiSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/LiSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/LkSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/LkSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/LrSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/LrSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/LsSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/LsSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/LtSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/LtSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/LuSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/LuSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/LvSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/LvSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/LySubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/LySubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MaSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MaSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/McSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/McSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MdSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MdSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MeSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MeSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MfSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MfSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MgSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MgSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MhSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MhSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MkSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MkSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MlSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MlSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MmSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MmSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MnSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MnSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MoSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MoSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MpSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MpSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MqSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MqSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MrSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MrSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MsSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MsSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MtSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MtSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MuSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MuSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MvSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MvSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MwSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MwSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MxSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MxSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MySubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MySubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/MzSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/MzSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/NaSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/NaSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/NcSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/NcSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/NeSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/NeSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/NfSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/NfSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/NgSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/NgSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/NiSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/NiSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/NlSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/NlSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/NoSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/NoSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/NpSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/NpSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/NrSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/NrSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/NuSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/NuSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/NzSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/NzSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/OmSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/OmSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/PaSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/PaSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/PeSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/PeSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/PfSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/PfSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/PgSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/PgSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/PhSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/PhSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/PkSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/PkSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/PlSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/PlSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/PmSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/PmSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/PnSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/PnSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/PrSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/PrSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/PsSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/PsSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/PtSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/PtSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/PwSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/PwSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/PySubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/PySubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/QaSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/QaSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/ReSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/ReSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/RoSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/RoSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/RsSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/RsSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/RuSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/RuSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/RwSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/RwSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SaSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SaSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SbSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SbSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/ScSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/ScSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SdSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SdSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SeSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SeSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SgSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SgSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/ShSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/ShSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SiSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SiSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SjSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SjSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SkSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SkSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SlSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SlSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SmSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SmSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SnSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SnSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SoSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SoSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SrSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SrSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SsSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SsSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/StSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/StSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SvSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SvSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SxSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SxSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SySubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SySubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/SzSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/SzSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/TcSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/TcSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/TdSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/TdSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/TfSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/TfSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/TgSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/TgSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/ThSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/ThSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/TjSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/TjSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/TkSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/TkSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/TlSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/TlSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/TmSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/TmSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/TnSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/TnSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/ToSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/ToSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/TrSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/TrSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/TtSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/TtSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/TvSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/TvSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/TwSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/TwSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/TzSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/TzSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/UaSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/UaSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/UgSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/UgSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/UmSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/UmSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/UsSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/UsSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/UySubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/UySubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/UzSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/UzSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/VaSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/VaSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/VcSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/VcSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/VeSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/VeSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/VgSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/VgSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/ViSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/ViSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/VnSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/VnSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/VuSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/VuSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/WfSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/WfSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/WsSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/WsSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/XkSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/XkSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/YeSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/YeSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/YtSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/YtSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/ZaSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/ZaSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/ZmSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/ZmSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SubdivisionCode/ZwSubdivisionCode.php b/vendor/respect/validation/library/Rules/SubdivisionCode/ZwSubdivisionCode.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/SymbolicLink.php b/vendor/respect/validation/library/Rules/SymbolicLink.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Tld.php b/vendor/respect/validation/library/Rules/Tld.php old mode 100755 new mode 100644 index 3c10223323c8363aece34832034f26ca995f19d6..fe53ad898ef3dd6413a367011b549a539cd1e397 --- a/vendor/respect/validation/library/Rules/Tld.php +++ b/vendor/respect/validation/library/Rules/Tld.php @@ -14,109 +14,230 @@ namespace Respect\Validation\Rules; class Tld extends AbstractRule { protected $tldList = [ - //generic - http://en.wikipedia.org/wiki/Generic_top-level_domain - 'aero', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', - 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'post', 'pro', - 'tel', 'travel', 'xxx', 'ninja', 'abb', 'abbott', 'abogado', 'academy', - 'accenture', 'accountant', 'accountants', 'active', 'actor', 'ads', 'adult', - 'aeg', 'afl', 'agency', 'aig', 'airforce', 'allfinanz', 'alsace', 'amsterdam', - 'an', 'android', 'apartments', 'app', 'aquarelle', 'archi', 'army', 'arpa', - 'associates', 'attorney', 'auction', 'audio', 'auto', 'autos', 'axa', 'azure', - 'band', 'bank', 'bar', 'barclaycard', 'barclays', 'bargains', 'bauhaus', - 'bayern', 'bbc', 'bbva', 'beer', 'berlin', 'best', 'bharti', 'bible', 'bid', - 'bike', 'bing', 'bingo', 'bio', 'black', 'blackfriday', 'bloomberg', 'blue', - 'bmw', 'bnl', 'bnpparibas', 'boats', 'bond', 'boo', 'boutique', 'bradesco', - 'bridgestone', 'broker', 'brother', 'brussels', 'budapest', 'build', 'builders', - 'business', 'buzz', 'bv', 'bzh', 'cab', 'cafe', 'cal', 'camera', 'camp', - 'cancerresearch', 'canon', 'capetown', 'capital', 'caravan', 'cards', - 'care', 'career', 'careers', 'cars', 'cartier', 'casa', 'cash', 'casino', - 'catering', 'cba', 'cbn', 'center', 'ceo', 'cern', 'cfa', 'cfd', 'channel', - 'chat', 'cheap', 'chloe', 'christmas', 'chrome', 'church', 'cisco', 'citic', - 'city', 'claims', 'cleaning', 'click', 'clinic', 'clothing', 'cloud', 'club', - 'coach', 'codes', 'coffee', 'college', 'cologne', 'commbank', 'community', - 'company', 'computer', 'condos', 'construction', 'consulting', 'contractors', - 'cooking', 'cool', 'corsica', 'country', 'coupons', 'courses', 'credit', - 'creditcard', 'cricket', 'crown', 'crs', 'cruises', 'cuisinella', 'cw', - 'cymru', 'cyou', 'dabur', 'dad', 'dance', 'date', 'dating', 'datsun', - 'day', 'dclk', 'deals', 'degree', 'delivery', 'democrat', 'dental', 'dentist' - , 'desi', 'design', 'dev', 'diamonds', 'diet', 'digital', 'direct', 'directory', - 'discount', 'dnp', 'docs', 'dog', 'doha', 'domains', 'doosan', 'download', - 'drive', 'durban', 'dvag', 'earth', 'eat', 'education', 'email', 'emerck', - 'energy', 'engineer', 'engineering', 'enterprises', 'epson', 'equipment', - 'erni', 'esq', 'estate', 'eurovision', 'eus', 'events', 'everbank', - 'exchange', 'expert', 'exposed', 'express', 'fail', 'faith', 'fan', 'fans', - 'farm', 'fashion', 'feedback', 'film', 'finance', 'financial', 'firmdale', - 'fish', 'fishing', 'fit', 'fitness', 'flights', 'florist', 'flowers', 'flsmidth', - 'fly', 'foo', 'football', 'forex', 'forsale', 'forum', 'foundation', 'frl', - 'frogans', 'fund', 'furniture', 'futbol', 'fyi', 'gal', 'gallery', 'garden', - 'gbiz', 'gdn', 'gent', 'genting', 'ggee', 'gift', 'gifts', 'gives', 'glass', - 'gle', 'global', 'globo', 'gmail', 'gmo', 'gmx', 'gold', 'goldpoint', 'golf', - 'goo', 'goog', 'google', 'gop', 'graphics', 'gratis', 'green', 'gripe', 'guge', - 'guide', 'guitars', 'guru', 'hamburg', 'hangout', 'haus', 'healthcare', 'help', - 'here', 'hermes', 'hiphop', 'hitachi', 'hiv', 'hockey', 'holdings', 'holiday', - 'homedepot', 'homes', 'honda', 'horse', 'host', 'hosting', 'hoteles', 'hotmail', - 'house', 'how', 'ibm', 'icbc', 'icu', 'ifm', 'immo', 'immobilien', 'industries', - 'infiniti', 'ing', 'ink', 'institute', 'insure', 'international', 'investments', - 'irish', 'iwc', 'java', 'jcb', 'jetzt', 'jewelry', 'jlc', 'jll', 'joburg', 'juegos', - 'kaufen', 'kddi', 'kim', 'kitchen', 'kiwi', 'koeln', 'komatsu', 'krd', 'kred', - 'kyoto', 'lacaixa', 'land', 'lasalle', 'lat', 'latrobe', 'law', 'lawyer', 'lds', - 'lease', 'leclerc', 'legal', 'lgbt', 'liaison', 'lidl', 'life', 'lighting', - 'limited', 'limo', 'link', 'loan', 'loans', 'lol', 'london', 'lotte', 'lotto', - 'love', 'ltda', 'lupin', 'luxe', 'luxury', 'madrid', 'maif', 'maison', 'management', - 'mango', 'market', 'marketing', 'markets', 'marriott', 'mba', 'media', 'meet', - 'melbourne', 'meme', 'memorial', 'men', 'menu', 'miami', 'microsoft', 'mini', 'mma', - 'moda', 'moe', 'monash', 'money', 'montblanc', 'mormon', 'mortgage', 'moscow', - 'motorcycles', 'mov', 'movie', 'movistar', 'mtn', 'mtpc', 'nadex', 'nagoya', 'navy', - 'nec', 'netbank', 'network', 'neustar', 'new', 'news', 'nexus', 'ngo', 'nhk', 'nico', - 'ninja', 'nissan', 'nra', 'nrw', 'ntt', 'nyc', 'office', 'okinawa', 'omega', 'one', - 'ong', 'onl', 'online', 'ooo', 'oracle', 'organic', 'osaka', 'otsuka', 'ovh', 'page', - 'panerai', 'paris', 'partners', 'parts', 'party', 'pharmacy', 'philips', 'photo', - 'photography', 'photos', 'physio', 'piaget', 'pics', 'pictet', 'pictures', 'pink', - 'pizza', 'place', 'play', 'plumbing', 'plus', 'pohl', 'poker', 'porn', 'praxi', - 'press', 'prod', 'productions', 'prof', 'properties', 'property', 'pub', 'qpon', - 'quebec', 'racing', 'realtor', 'realty', 'recipes', 'red', 'redstone', 'rehab', - 'reise', 'reisen', 'reit', 'ren', 'rent', 'rentals', 'repair', 'report', 'republican', - 'rest', 'restaurant', 'review', 'reviews', 'rich', 'ricoh', 'rio', 'rip', 'rocks', - 'rodeo', 'rsvp', 'ruhr', 'run', 'ryukyu', 'saarland', 'sakura', 'sale', 'samsung', - 'sandvik', 'sandvikcoromant', 'sap', 'sarl', 'saxo', 'sca', 'scb', 'schmidt', - 'scholarships', 'school', 'schule', 'schwarz', 'science', 'scor', 'scot', 'seat', - 'sener', 'services', 'sew', 'sex', 'sexy', 'shiksha', 'shoes', 'show', 'shriram', - 'singles', 'site', 'sj', 'ski', 'sky', 'skype', 'sncf', 'soccer', 'social', - 'software', 'sohu', 'solar', 'solutions', 'sony', 'soy', 'space', 'spiegel', - 'spreadbetting', 'starhub', 'statoil', 'studio', 'study', 'style', 'sucks', 'supplies', - 'supply', 'support', 'surf', 'surgery', 'suzuki', 'swatch', 'swiss', 'sx', 'sydney', - 'systems', 'taipei', 'tatar', 'tattoo', 'tax', 'taxi', 'team', 'tech', 'technology', - 'telefonica', 'temasek', 'tennis', 'thd', 'theater', 'tickets', 'tienda', 'tips', - 'tires', 'tirol', 'today', 'tokyo', 'tools', 'top', 'toray', 'toshiba', 'tours', - 'town', 'toys', 'trade', 'trading', 'training', 'trust', 'tui', 'university', 'uno', - 'uol', 'vacations', 'vegas', 'ventures', 'versicherung', 'vet', 'viajes', 'video', - 'villas', 'vision', 'vista', 'vistaprint', 'vlaanderen', 'vodka', 'vote', 'voting', - 'voto', 'voyage', 'wales', 'walter', 'wang', 'watch', 'webcam', 'website', 'wed', - 'wedding', 'weir', 'whoswho', 'wien', 'wiki', 'williamhill', 'win', 'windows', - 'wme', 'work', 'works', 'world', 'wtc', 'wtf', 'xbox', 'xerox', 'xin', 'xyz', - 'yachts', 'yandex', 'yodobashi', 'yoga', 'yokohama', 'youtube', 'zip', 'zone', 'zuerich', - //country - 'ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'ao', 'aq', 'ar', 'as', - 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', - 'bi', 'bj', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bw', 'by', 'bz', - 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', - 'cr', 'cs', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', - 'dz', 'ec', 'ee', 'eg', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', - 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', - 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', - 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is', - 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', - 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', - 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mk', 'ml', 'mm', - 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', - 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', - 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', - 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', - 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sk', 'sl', 'sm', 'sn', 'so', - 'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', - 'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', - 'ug', 'uk', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', - 'wf', 'ws', 'ye', 'yt', 'za', 'zm', 'zw', + // https://data.iana.org/TLD/tlds-alpha-by-domain.txt + // Version 2018100800, Last Updated Mon Oct 8 07:07:01 2018 UTC + 'aaa', 'aarp', 'abarth', 'abb', 'abbott', 'abbvie', 'abc', 'able', + 'abogado', 'abudhabi', 'ac', 'academy', 'accenture', 'accountant', + 'accountants', 'aco', 'active', 'actor', 'ad', 'adac', 'ads', 'adult', + 'ae', 'aeg', 'aero', 'aetna', 'af', 'afamilycompany', 'afl', 'africa', + 'ag', 'agakhan', 'agency', 'ai', 'aig', 'aigo', 'airbus', 'airforce', + 'airtel', 'akdn', 'al', 'alfaromeo', 'alibaba', 'alipay', 'allfinanz', + 'allstate', 'ally', 'alsace', 'alstom', 'am', 'americanexpress', + 'americanfamily', 'amex', 'amfam', 'amica', 'amsterdam', 'analytics', + 'android', 'anquan', 'anz', 'ao', 'aol', 'apartments', 'app', 'apple', + 'aq', 'aquarelle', 'ar', 'arab', 'aramco', 'archi', 'army', 'arpa', + 'art', 'arte', 'as', 'asda', 'asia', 'associates', 'at', 'athleta', + 'attorney', 'au', 'auction', 'audi', 'audible', 'audio', 'auspost', + 'author', 'auto', 'autos', 'avianca', 'aw', 'aws', 'ax', 'axa', 'az', + 'azure', 'ba', 'baby', 'baidu', 'banamex', 'bananarepublic', 'band', + 'bank', 'bar', 'barcelona', 'barclaycard', 'barclays', 'barefoot', + 'bargains', 'baseball', 'basketball', 'bauhaus', 'bayern', 'bb', 'bbc', + 'bbt', 'bbva', 'bcg', 'bcn', 'bd', 'be', 'beats', 'beauty', 'beer', + 'bentley', 'berlin', 'best', 'bestbuy', 'bet', 'bf', 'bg', 'bh', + 'bharti', 'bi', 'bible', 'bid', 'bike', 'bing', 'bingo', 'bio', 'biz', + 'bj', 'black', 'blackfriday', 'blanco', 'blockbuster', 'blog', + 'bloomberg', 'blue', 'bm', 'bms', 'bmw', 'bn', 'bnl', 'bnpparibas', + 'bo', 'boats', 'boehringer', 'bofa', 'bom', 'bond', 'boo', 'book', + 'booking', 'bosch', 'bostik', 'boston', 'bot', 'boutique', 'box', 'br', + 'bradesco', 'bridgestone', 'broadway', 'broker', 'brother', 'brussels', + 'bs', 'bt', 'budapest', 'bugatti', 'build', 'builders', 'business', + 'buy', 'buzz', 'bv', 'bw', 'by', 'bz', 'bzh', 'ca', 'cab', 'cafe', + 'cal', 'call', 'calvinklein', 'cam', 'camera', 'camp', + 'cancerresearch', 'canon', 'capetown', 'capital', 'capitalone', 'car', + 'caravan', 'cards', 'care', 'career', 'careers', 'cars', 'cartier', + 'casa', 'case', 'caseih', 'cash', 'casino', 'cat', 'catering', + 'catholic', 'cba', 'cbn', 'cbre', 'cbs', 'cc', 'cd', 'ceb', 'center', + 'ceo', 'cern', 'cf', 'cfa', 'cfd', 'cg', 'ch', 'chanel', 'channel', + 'charity', 'chase', 'chat', 'cheap', 'chintai', 'christmas', 'chrome', + 'chrysler', 'church', 'ci', 'cipriani', 'circle', 'cisco', 'citadel', + 'citi', 'citic', 'city', 'cityeats', 'ck', 'cl', 'claims', 'cleaning', + 'click', 'clinic', 'clinique', 'clothing', 'cloud', 'club', 'clubmed', + 'cm', 'cn', 'co', 'coach', 'codes', 'coffee', 'college', 'cologne', + 'com', 'comcast', 'commbank', 'community', 'company', 'compare', + 'computer', 'comsec', 'condos', 'construction', 'consulting', + 'contact', 'contractors', 'cooking', 'cookingchannel', 'cool', 'coop', + 'corsica', 'country', 'coupon', 'coupons', 'courses', 'cr', 'credit', + 'creditcard', 'creditunion', 'cricket', 'crown', 'crs', 'cruise', + 'cruises', 'csc', 'cu', 'cuisinella', 'cv', 'cw', 'cx', 'cy', 'cymru', + 'cyou', 'cz', 'dabur', 'dad', 'dance', 'data', 'date', 'dating', + 'datsun', 'day', 'dclk', 'dds', 'de', 'deal', 'dealer', 'deals', + 'degree', 'delivery', 'dell', 'deloitte', 'delta', 'democrat', + 'dental', 'dentist', 'desi', 'design', 'dev', 'dhl', 'diamonds', + 'diet', 'digital', 'direct', 'directory', 'discount', 'discover', + 'dish', 'diy', 'dj', 'dk', 'dm', 'dnp', 'do', 'docs', 'doctor', + 'dodge', 'dog', 'doha', 'domains', 'dot', 'download', 'drive', 'dtv', + 'dubai', 'duck', 'dunlop', 'duns', 'dupont', 'durban', 'dvag', 'dvr', + 'dz', 'earth', 'eat', 'ec', 'eco', 'edeka', 'edu', 'education', 'ee', + 'eg', 'email', 'emerck', 'energy', 'engineer', 'engineering', + 'enterprises', 'epost', 'epson', 'equipment', 'er', 'ericsson', 'erni', + 'es', 'esq', 'estate', 'esurance', 'et', 'etisalat', 'eu', + 'eurovision', 'eus', 'events', 'everbank', 'exchange', 'expert', + 'exposed', 'express', 'extraspace', 'fage', 'fail', 'fairwinds', + 'faith', 'family', 'fan', 'fans', 'farm', 'farmers', 'fashion', 'fast', + 'fedex', 'feedback', 'ferrari', 'ferrero', 'fi', 'fiat', 'fidelity', + 'fido', 'film', 'final', 'finance', 'financial', 'fire', 'firestone', + 'firmdale', 'fish', 'fishing', 'fit', 'fitness', 'fj', 'fk', 'flickr', + 'flights', 'flir', 'florist', 'flowers', 'fly', 'fm', 'fo', 'foo', + 'food', 'foodnetwork', 'football', 'ford', 'forex', 'forsale', 'forum', + 'foundation', 'fox', 'fr', 'free', 'fresenius', 'frl', 'frogans', + 'frontdoor', 'frontier', 'ftr', 'fujitsu', 'fujixerox', 'fun', 'fund', + 'furniture', 'futbol', 'fyi', 'ga', 'gal', 'gallery', 'gallo', + 'gallup', 'game', 'games', 'gap', 'garden', 'gb', 'gbiz', 'gd', 'gdn', + 'ge', 'gea', 'gent', 'genting', 'george', 'gf', 'gg', 'ggee', 'gh', + 'gi', 'gift', 'gifts', 'gives', 'giving', 'gl', 'glade', 'glass', + 'gle', 'global', 'globo', 'gm', 'gmail', 'gmbh', 'gmo', 'gmx', 'gn', + 'godaddy', 'gold', 'goldpoint', 'golf', 'goo', 'goodyear', 'goog', + 'google', 'gop', 'got', 'gov', 'gp', 'gq', 'gr', 'grainger', + 'graphics', 'gratis', 'green', 'gripe', 'grocery', 'group', 'gs', 'gt', + 'gu', 'guardian', 'gucci', 'guge', 'guide', 'guitars', 'guru', 'gw', + 'gy', 'hair', 'hamburg', 'hangout', 'haus', 'hbo', 'hdfc', 'hdfcbank', + 'health', 'healthcare', 'help', 'helsinki', 'here', 'hermes', 'hgtv', + 'hiphop', 'hisamitsu', 'hitachi', 'hiv', 'hk', 'hkt', 'hm', 'hn', + 'hockey', 'holdings', 'holiday', 'homedepot', 'homegoods', 'homes', + 'homesense', 'honda', 'honeywell', 'horse', 'hospital', 'host', + 'hosting', 'hot', 'hoteles', 'hotels', 'hotmail', 'house', 'how', 'hr', + 'hsbc', 'ht', 'hu', 'hughes', 'hyatt', 'hyundai', 'ibm', 'icbc', 'ice', + 'icu', 'id', 'ie', 'ieee', 'ifm', 'ikano', 'il', 'im', 'imamat', + 'imdb', 'immo', 'immobilien', 'in', 'inc', 'industries', 'infiniti', + 'info', 'ing', 'ink', 'institute', 'insurance', 'insure', 'int', + 'intel', 'international', 'intuit', 'investments', 'io', 'ipiranga', + 'iq', 'ir', 'irish', 'is', 'iselect', 'ismaili', 'ist', 'istanbul', + 'it', 'itau', 'itv', 'iveco', 'jaguar', 'java', 'jcb', 'jcp', 'je', + 'jeep', 'jetzt', 'jewelry', 'jio', 'jll', 'jm', 'jmp', 'jnj', 'jo', + 'jobs', 'joburg', 'jot', 'joy', 'jp', 'jpmorgan', 'jprs', 'juegos', + 'juniper', 'kaufen', 'kddi', 'ke', 'kerryhotels', 'kerrylogistics', + 'kerryproperties', 'kfh', 'kg', 'kh', 'ki', 'kia', 'kim', 'kinder', + 'kindle', 'kitchen', 'kiwi', 'km', 'kn', 'koeln', 'komatsu', 'kosher', + 'kp', 'kpmg', 'kpn', 'kr', 'krd', 'kred', 'kuokgroup', 'kw', 'ky', + 'kyoto', 'kz', 'la', 'lacaixa', 'ladbrokes', 'lamborghini', 'lamer', + 'lancaster', 'lancia', 'lancome', 'land', 'landrover', 'lanxess', + 'lasalle', 'lat', 'latino', 'latrobe', 'law', 'lawyer', 'lb', 'lc', + 'lds', 'lease', 'leclerc', 'lefrak', 'legal', 'lego', 'lexus', 'lgbt', + 'li', 'liaison', 'lidl', 'life', 'lifeinsurance', 'lifestyle', + 'lighting', 'like', 'lilly', 'limited', 'limo', 'lincoln', 'linde', + 'link', 'lipsy', 'live', 'living', 'lixil', 'lk', 'llc', 'loan', + 'loans', 'locker', 'locus', 'loft', 'lol', 'london', 'lotte', 'lotto', + 'love', 'lpl', 'lplfinancial', 'lr', 'ls', 'lt', 'ltd', 'ltda', 'lu', + 'lundbeck', 'lupin', 'luxe', 'luxury', 'lv', 'ly', 'ma', 'macys', + 'madrid', 'maif', 'maison', 'makeup', 'man', 'management', 'mango', + 'map', 'market', 'marketing', 'markets', 'marriott', 'marshalls', + 'maserati', 'mattel', 'mba', 'mc', 'mckinsey', 'md', 'me', 'med', + 'media', 'meet', 'melbourne', 'meme', 'memorial', 'men', 'menu', + 'merckmsd', 'metlife', 'mg', 'mh', 'miami', 'microsoft', 'mil', 'mini', + 'mint', 'mit', 'mitsubishi', 'mk', 'ml', 'mlb', 'mls', 'mm', 'mma', + 'mn', 'mo', 'mobi', 'mobile', 'mobily', 'moda', 'moe', 'moi', 'mom', + 'monash', 'money', 'monster', 'mopar', 'mormon', 'mortgage', 'moscow', + 'moto', 'motorcycles', 'mov', 'movie', 'movistar', 'mp', 'mq', 'mr', + 'ms', 'msd', 'mt', 'mtn', 'mtr', 'mu', 'museum', 'mutual', 'mv', 'mw', + 'mx', 'my', 'mz', 'na', 'nab', 'nadex', 'nagoya', 'name', 'nationwide', + 'natura', 'navy', 'nba', 'nc', 'ne', 'nec', 'net', 'netbank', + 'netflix', 'network', 'neustar', 'new', 'newholland', 'news', 'next', + 'nextdirect', 'nexus', 'nf', 'nfl', 'ng', 'ngo', 'nhk', 'ni', 'nico', + 'nike', 'nikon', 'ninja', 'nissan', 'nissay', 'nl', 'no', 'nokia', + 'northwesternmutual', 'norton', 'now', 'nowruz', 'nowtv', 'np', 'nr', + 'nra', 'nrw', 'ntt', 'nu', 'nyc', 'nz', 'obi', 'observer', 'off', + 'office', 'okinawa', 'olayan', 'olayangroup', 'oldnavy', 'ollo', 'om', + 'omega', 'one', 'ong', 'onl', 'online', 'onyourside', 'ooo', 'open', + 'oracle', 'orange', 'org', 'organic', 'origins', 'osaka', 'otsuka', + 'ott', 'ovh', 'pa', 'page', 'panasonic', 'paris', 'pars', 'partners', + 'parts', 'party', 'passagens', 'pay', 'pccw', 'pe', 'pet', 'pf', + 'pfizer', 'pg', 'ph', 'pharmacy', 'phd', 'philips', 'phone', 'photo', + 'photography', 'photos', 'physio', 'piaget', 'pics', 'pictet', + 'pictures', 'pid', 'pin', 'ping', 'pink', 'pioneer', 'pizza', 'pk', + 'pl', 'place', 'play', 'playstation', 'plumbing', 'plus', 'pm', 'pn', + 'pnc', 'pohl', 'poker', 'politie', 'porn', 'post', 'pr', 'pramerica', + 'praxi', 'press', 'prime', 'pro', 'prod', 'productions', 'prof', + 'progressive', 'promo', 'properties', 'property', 'protection', 'pru', + 'prudential', 'ps', 'pt', 'pub', 'pw', 'pwc', 'py', 'qa', 'qpon', + 'quebec', 'quest', 'qvc', 'racing', 'radio', 'raid', 're', 'read', + 'realestate', 'realtor', 'realty', 'recipes', 'red', 'redstone', + 'redumbrella', 'rehab', 'reise', 'reisen', 'reit', 'reliance', 'ren', + 'rent', 'rentals', 'repair', 'report', 'republican', 'rest', + 'restaurant', 'review', 'reviews', 'rexroth', 'rich', 'richardli', + 'ricoh', 'rightathome', 'ril', 'rio', 'rip', 'rmit', 'ro', 'rocher', + 'rocks', 'rodeo', 'rogers', 'room', 'rs', 'rsvp', 'ru', 'rugby', + 'ruhr', 'run', 'rw', 'rwe', 'ryukyu', 'sa', 'saarland', 'safe', + 'safety', 'sakura', 'sale', 'salon', 'samsclub', 'samsung', 'sandvik', + 'sandvikcoromant', 'sanofi', 'sap', 'sarl', 'sas', 'save', 'saxo', + 'sb', 'sbi', 'sbs', 'sc', 'sca', 'scb', 'schaeffler', 'schmidt', + 'scholarships', 'school', 'schule', 'schwarz', 'science', 'scjohnson', + 'scor', 'scot', 'sd', 'se', 'search', 'seat', 'secure', 'security', + 'seek', 'select', 'sener', 'services', 'ses', 'seven', 'sew', 'sex', + 'sexy', 'sfr', 'sg', 'sh', 'shangrila', 'sharp', 'shaw', 'shell', + 'shia', 'shiksha', 'shoes', 'shop', 'shopping', 'shouji', 'show', + 'showtime', 'shriram', 'si', 'silk', 'sina', 'singles', 'site', 'sj', + 'sk', 'ski', 'skin', 'sky', 'skype', 'sl', 'sling', 'sm', 'smart', + 'smile', 'sn', 'sncf', 'so', 'soccer', 'social', 'softbank', + 'software', 'sohu', 'solar', 'solutions', 'song', 'sony', 'soy', + 'space', 'spiegel', 'sport', 'spot', 'spreadbetting', 'sr', 'srl', + 'srt', 'st', 'stada', 'staples', 'star', 'starhub', 'statebank', + 'statefarm', 'stc', 'stcgroup', 'stockholm', 'storage', 'store', + 'stream', 'studio', 'study', 'style', 'su', 'sucks', 'supplies', + 'supply', 'support', 'surf', 'surgery', 'suzuki', 'sv', 'swatch', + 'swiftcover', 'swiss', 'sx', 'sy', 'sydney', 'symantec', 'systems', + 'sz', 'tab', 'taipei', 'talk', 'taobao', 'target', 'tatamotors', + 'tatar', 'tattoo', 'tax', 'taxi', 'tc', 'tci', 'td', 'tdk', 'team', + 'tech', 'technology', 'tel', 'telefonica', 'temasek', 'tennis', 'teva', + 'tf', 'tg', 'th', 'thd', 'theater', 'theatre', 'tiaa', 'tickets', + 'tienda', 'tiffany', 'tips', 'tires', 'tirol', 'tj', 'tjmaxx', 'tjx', + 'tk', 'tkmaxx', 'tl', 'tm', 'tmall', 'tn', 'to', 'today', 'tokyo', + 'tools', 'top', 'toray', 'toshiba', 'total', 'tours', 'town', 'toyota', + 'toys', 'tr', 'trade', 'trading', 'training', 'travel', + 'travelchannel', 'travelers', 'travelersinsurance', 'trust', 'trv', + 'tt', 'tube', 'tui', 'tunes', 'tushu', 'tv', 'tvs', 'tw', 'tz', 'ua', + 'ubank', 'ubs', 'uconnect', 'ug', 'uk', 'unicom', 'university', 'uno', + 'uol', 'ups', 'us', 'uy', 'uz', 'va', 'vacations', 'vana', 'vanguard', + 'vc', 've', 'vegas', 'ventures', 'verisign', 'versicherung', 'vet', + 'vg', 'vi', 'viajes', 'video', 'vig', 'viking', 'villas', 'vin', 'vip', + 'virgin', 'visa', 'vision', 'vistaprint', 'viva', 'vivo', 'vlaanderen', + 'vn', 'vodka', 'volkswagen', 'volvo', 'vote', 'voting', 'voto', + 'voyage', 'vu', 'vuelos', 'wales', 'walmart', 'walter', 'wang', + 'wanggou', 'warman', 'watch', 'watches', 'weather', 'weatherchannel', + 'webcam', 'weber', 'website', 'wed', 'wedding', 'weibo', 'weir', 'wf', + 'whoswho', 'wien', 'wiki', 'williamhill', 'win', 'windows', 'wine', + 'winners', 'wme', 'wolterskluwer', 'woodside', 'work', 'works', + 'world', 'wow', 'ws', 'wtc', 'wtf', 'xbox', 'xerox', 'xfinity', + 'xihuan', 'xin', 'xn--11b4c3d', 'xn--1ck2e1b', 'xn--1qqw23a', + 'xn--2scrj9c', 'xn--30rr7y', 'xn--3bst00m', 'xn--3ds443g', + 'xn--3e0b707e', 'xn--3hcrj9c', 'xn--3oq18vl8pn36a', 'xn--3pxu8k', + 'xn--42c2d9a', 'xn--45br5cyl', 'xn--45brj9c', 'xn--45q11c', + 'xn--4gbrim', 'xn--54b7fta0cc', 'xn--55qw42g', 'xn--55qx5d', + 'xn--5su34j936bgsg', 'xn--5tzm5g', 'xn--6frz82g', 'xn--6qq986b3xl', + 'xn--80adxhks', 'xn--80ao21a', 'xn--80aqecdr1a', 'xn--80asehdb', + 'xn--80aswg', 'xn--8y0a063a', 'xn--90a3ac', 'xn--90ae', 'xn--90ais', + 'xn--9dbq2a', 'xn--9et52u', 'xn--9krt00a', 'xn--b4w605ferd', + 'xn--bck1b9a5dre4c', 'xn--c1avg', 'xn--c2br7g', 'xn--cck2b3b', + 'xn--cg4bki', 'xn--clchc0ea0b2g2a9gcd', 'xn--czr694b', 'xn--czrs0t', + 'xn--czru2d', 'xn--d1acj3b', 'xn--d1alf', 'xn--e1a4c', 'xn--eckvdtc9d', + 'xn--efvy88h', 'xn--estv75g', 'xn--fct429k', 'xn--fhbei', + 'xn--fiq228c5hs', 'xn--fiq64b', 'xn--fiqs8s', 'xn--fiqz9s', + 'xn--fjq720a', 'xn--flw351e', 'xn--fpcrj9c3d', 'xn--fzc2c9e2c', + 'xn--fzys8d69uvgm', 'xn--g2xx48c', 'xn--gckr3f0f', 'xn--gecrj9c', + 'xn--gk3at1e', 'xn--h2breg3eve', 'xn--h2brj9c', 'xn--h2brj9c8c', + 'xn--hxt814e', 'xn--i1b6b1a6a2e', 'xn--imr513n', 'xn--io0a7i', + 'xn--j1aef', 'xn--j1amh', 'xn--j6w193g', 'xn--jlq61u9w7b', + 'xn--jvr189m', 'xn--kcrx77d1x4a', 'xn--kprw13d', 'xn--kpry57d', + 'xn--kpu716f', 'xn--kput3i', 'xn--l1acc', 'xn--lgbbat1ad8j', + 'xn--mgb9awbf', 'xn--mgba3a3ejt', 'xn--mgba3a4f16a', + 'xn--mgba7c0bbn0a', 'xn--mgbaakc7dvf', 'xn--mgbaam7a8h', + 'xn--mgbab2bd', 'xn--mgbai9azgqp6j', 'xn--mgbayh7gpa', + 'xn--mgbb9fbpob', 'xn--mgbbh1a', 'xn--mgbbh1a71e', 'xn--mgbc0a9azcg', + 'xn--mgbca7dzdo', 'xn--mgberp4a5d4ar', 'xn--mgbgu82a', + 'xn--mgbi4ecexp', 'xn--mgbpl2fh', 'xn--mgbt3dhd', 'xn--mgbtx2b', + 'xn--mgbx4cd0ab', 'xn--mix891f', 'xn--mk1bu44c', 'xn--mxtq1m', + 'xn--ngbc5azd', 'xn--ngbe9e0a', 'xn--ngbrx', 'xn--node', 'xn--nqv7f', + 'xn--nqv7fs00ema', 'xn--nyqy26a', 'xn--o3cw4h', 'xn--ogbpf8fl', + 'xn--otu796d', 'xn--p1acf', 'xn--p1ai', 'xn--pbt977c', 'xn--pgbs0dh', + 'xn--pssy2u', 'xn--q9jyb4c', 'xn--qcka1pmc', 'xn--qxam', 'xn--rhqv96g', + 'xn--rovu88b', 'xn--rvc1e0am3e', 'xn--s9brj9c', 'xn--ses554g', + 'xn--t60b56a', 'xn--tckwe', 'xn--tiq49xqyj', 'xn--unup4y', + 'xn--vermgensberater-ctb', 'xn--vermgensberatung-pwb', 'xn--vhquv', + 'xn--vuq861b', 'xn--w4r85el8fhu5dnra', 'xn--w4rs40l', 'xn--wgbh1c', + 'xn--wgbl6a', 'xn--xhq521b', 'xn--xkc2al3hye2a', 'xn--xkc2dl3a5ee0h', + 'xn--y9a3aq', 'xn--yfro4i67o', 'xn--ygbi2ammx', 'xn--zfr164b', 'xxx', + 'xyz', 'yachts', 'yahoo', 'yamaxun', 'yandex', 'ye', 'yodobashi', + 'yoga', 'yokohama', 'you', 'youtube', 'yt', 'yun', 'za', 'zappos', + 'zara', 'zero', 'zip', 'zippo', 'zm', 'zone', 'zuerich', 'zw', ]; public function validate($input) diff --git a/vendor/respect/validation/library/Rules/TrueVal.php b/vendor/respect/validation/library/Rules/TrueVal.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Type.php b/vendor/respect/validation/library/Rules/Type.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Uploaded.php b/vendor/respect/validation/library/Rules/Uploaded.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Uppercase.php b/vendor/respect/validation/library/Rules/Uppercase.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Url.php b/vendor/respect/validation/library/Rules/Url.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Version.php b/vendor/respect/validation/library/Rules/Version.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/VideoUrl.php b/vendor/respect/validation/library/Rules/VideoUrl.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Vowel.php b/vendor/respect/validation/library/Rules/Vowel.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/When.php b/vendor/respect/validation/library/Rules/When.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Writable.php b/vendor/respect/validation/library/Rules/Writable.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Xdigit.php b/vendor/respect/validation/library/Rules/Xdigit.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Yes.php b/vendor/respect/validation/library/Rules/Yes.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Rules/Zend.php b/vendor/respect/validation/library/Rules/Zend.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Validatable.php b/vendor/respect/validation/library/Validatable.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/library/Validator.php b/vendor/respect/validation/library/Validator.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/phpunit.xml.dist b/vendor/respect/validation/phpunit.xml.dist old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/fixtures/invalid-image.png b/vendor/respect/validation/tests/fixtures/invalid-image.png old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/fixtures/valid-image.gif b/vendor/respect/validation/tests/fixtures/valid-image.gif old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/fixtures/valid-image.jpg b/vendor/respect/validation/tests/fixtures/valid-image.jpg old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/fixtures/valid-image.png b/vendor/respect/validation/tests/fixtures/valid-image.png old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/assert-with-keys.phpt b/vendor/respect/validation/tests/integration/assert-with-keys.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/bsn_1.phpt b/vendor/respect/validation/tests/integration/bsn_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/bsn_2.phpt b/vendor/respect/validation/tests/integration/bsn_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/bsn_3.phpt b/vendor/respect/validation/tests/integration/bsn_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/do_not_rely_on_nested_validation_exception_interface_for_check.phpt b/vendor/respect/validation/tests/integration/do_not_rely_on_nested_validation_exception_interface_for_check.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/exception_update.phpt b/vendor/respect/validation/tests/integration/exception_update.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/find_messages_should_apply_templates_to_flattened_messages.phpt b/vendor/respect/validation/tests/integration/find_messages_should_apply_templates_to_flattened_messages.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/find_messages_should_return_composite_validation_messages_flattened.phpt b/vendor/respect/validation/tests/integration/find_messages_should_return_composite_validation_messages_flattened.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/get_full_message_should_include_all_validation_messages_in_a_chain.phpt b/vendor/respect/validation/tests/integration/get_full_message_should_include_all_validation_messages_in_a_chain.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/get_messages_should_include_all_validation_messages_in_a_chain.phpt b/vendor/respect/validation/tests/integration/get_messages_should_include_all_validation_messages_in_a_chain.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/issue-1033.phpt b/vendor/respect/validation/tests/integration/issue-1033.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/issue-179.phpt b/vendor/respect/validation/tests/integration/issue-179.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/issue-425.phpt b/vendor/respect/validation/tests/integration/issue-425.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/issue-446.phpt b/vendor/respect/validation/tests/integration/issue-446.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/issue-619.phpt b/vendor/respect/validation/tests/integration/issue-619.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/issue-620.phpt b/vendor/respect/validation/tests/integration/issue-620.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/issue-689.phpt b/vendor/respect/validation/tests/integration/issue-689.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/issue-690.phpt b/vendor/respect/validation/tests/integration/issue-690.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/issue-719.phpt b/vendor/respect/validation/tests/integration/issue-719.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/issue-727.phpt b/vendor/respect/validation/tests/integration/issue-727.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/issue-739.phpt b/vendor/respect/validation/tests/integration/issue-739.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/issue-799.phpt b/vendor/respect/validation/tests/integration/issue-799.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/issue-805.phpt b/vendor/respect/validation/tests/integration/issue-805.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/issue_85_find_messages_should_not_trigger_catchable_fatal_error.phpt b/vendor/respect/validation/tests/integration/issue_85_find_messages_should_not_trigger_catchable_fatal_error.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/keys_as_validator_names.phpt b/vendor/respect/validation/tests/integration/keys_as_validator_names.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/not_should_work_by_builder.phpt b/vendor/respect/validation/tests/integration/not_should_work_by_builder.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/not_with_recursion.phpt b/vendor/respect/validation/tests/integration/not_with_recursion.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/not_without_recursion.phpt b/vendor/respect/validation/tests/integration/not_without_recursion.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/readme/example_1.phpt b/vendor/respect/validation/tests/integration/readme/example_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/readme/example_2.phpt b/vendor/respect/validation/tests/integration/readme/example_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/readme/example_3.phpt b/vendor/respect/validation/tests/integration/readme/example_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/readme/example_4.phpt b/vendor/respect/validation/tests/integration/readme/example_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/age_1.phpt b/vendor/respect/validation/tests/integration/rules/age_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/age_2.phpt b/vendor/respect/validation/tests/integration/rules/age_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/age_3.phpt b/vendor/respect/validation/tests/integration/rules/age_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/age_4.phpt b/vendor/respect/validation/tests/integration/rules/age_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/allOf_1.phpt b/vendor/respect/validation/tests/integration/rules/allOf_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/allOf_2.phpt b/vendor/respect/validation/tests/integration/rules/allOf_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/allOf_3.phpt b/vendor/respect/validation/tests/integration/rules/allOf_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/allOf_4.phpt b/vendor/respect/validation/tests/integration/rules/allOf_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/allOf_5.phpt b/vendor/respect/validation/tests/integration/rules/allOf_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/alnum_1.phpt b/vendor/respect/validation/tests/integration/rules/alnum_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/alnum_2.phpt b/vendor/respect/validation/tests/integration/rules/alnum_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/alnum_3.phpt b/vendor/respect/validation/tests/integration/rules/alnum_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/alnum_4.phpt b/vendor/respect/validation/tests/integration/rules/alnum_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/alnum_5.phpt b/vendor/respect/validation/tests/integration/rules/alnum_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/alnum_6_expected_char.phpt b/vendor/respect/validation/tests/integration/rules/alnum_6_expected_char.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/alnum_7_not_empty.phpt b/vendor/respect/validation/tests/integration/rules/alnum_7_not_empty.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/alnum_8_uppercase.phpt b/vendor/respect/validation/tests/integration/rules/alnum_8_uppercase.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/alpha_1.phpt b/vendor/respect/validation/tests/integration/rules/alpha_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/alpha_2.phpt b/vendor/respect/validation/tests/integration/rules/alpha_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/alpha_3.phpt b/vendor/respect/validation/tests/integration/rules/alpha_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/alpha_4.phpt b/vendor/respect/validation/tests/integration/rules/alpha_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/alwaysInvalid_1.phpt b/vendor/respect/validation/tests/integration/rules/alwaysInvalid_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/alwaysInvalid_2.phpt b/vendor/respect/validation/tests/integration/rules/alwaysInvalid_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/alwaysValid_1.phpt b/vendor/respect/validation/tests/integration/rules/alwaysValid_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/arrayType_1.phpt b/vendor/respect/validation/tests/integration/rules/arrayType_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/arrayType_2.phpt b/vendor/respect/validation/tests/integration/rules/arrayType_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/arrayType_3.phpt b/vendor/respect/validation/tests/integration/rules/arrayType_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/arrayType_4.phpt b/vendor/respect/validation/tests/integration/rules/arrayType_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/arrayType_5.phpt b/vendor/respect/validation/tests/integration/rules/arrayType_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/arrayVal_1.phpt b/vendor/respect/validation/tests/integration/rules/arrayVal_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/arrayVal_2.phpt b/vendor/respect/validation/tests/integration/rules/arrayVal_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/arrayVal_3.phpt b/vendor/respect/validation/tests/integration/rules/arrayVal_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/arrayVal_4.phpt b/vendor/respect/validation/tests/integration/rules/arrayVal_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/arrayVal_5.phpt b/vendor/respect/validation/tests/integration/rules/arrayVal_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/beetwen_1.phpt b/vendor/respect/validation/tests/integration/rules/beetwen_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/beetwen_2.phpt b/vendor/respect/validation/tests/integration/rules/beetwen_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/beetwen_3.phpt b/vendor/respect/validation/tests/integration/rules/beetwen_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/beetwen_4.phpt b/vendor/respect/validation/tests/integration/rules/beetwen_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/beetwen_5.phpt b/vendor/respect/validation/tests/integration/rules/beetwen_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/beetwen_6.phpt b/vendor/respect/validation/tests/integration/rules/beetwen_6.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/boolType_1.phpt b/vendor/respect/validation/tests/integration/rules/boolType_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/boolType_2.phpt b/vendor/respect/validation/tests/integration/rules/boolType_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/boolType_3.phpt b/vendor/respect/validation/tests/integration/rules/boolType_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/boolType_4.phpt b/vendor/respect/validation/tests/integration/rules/boolType_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/boolType_5.phpt b/vendor/respect/validation/tests/integration/rules/boolType_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/boolval_1.phpt b/vendor/respect/validation/tests/integration/rules/boolval_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/boolval_2.phpt b/vendor/respect/validation/tests/integration/rules/boolval_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/bsn_1.phpt b/vendor/respect/validation/tests/integration/rules/bsn_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/bsn_2.phpt b/vendor/respect/validation/tests/integration/rules/bsn_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/bsn_3.phpt b/vendor/respect/validation/tests/integration/rules/bsn_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/callableType_1.phpt b/vendor/respect/validation/tests/integration/rules/callableType_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/callableType_2.phpt b/vendor/respect/validation/tests/integration/rules/callableType_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/callableType_3.phpt b/vendor/respect/validation/tests/integration/rules/callableType_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/callableType_4.phpt b/vendor/respect/validation/tests/integration/rules/callableType_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/cnpj_1.phpt b/vendor/respect/validation/tests/integration/rules/cnpj_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/cnpj_2.phpt b/vendor/respect/validation/tests/integration/rules/cnpj_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/cnpj_3.phpt b/vendor/respect/validation/tests/integration/rules/cnpj_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/cnpj_4.phpt b/vendor/respect/validation/tests/integration/rules/cnpj_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/cnpj_5.phpt b/vendor/respect/validation/tests/integration/rules/cnpj_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/cnpj_6.phpt b/vendor/respect/validation/tests/integration/rules/cnpj_6.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/consonant_1.phpt b/vendor/respect/validation/tests/integration/rules/consonant_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/consonant_2.phpt b/vendor/respect/validation/tests/integration/rules/consonant_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/consonant_3.phpt b/vendor/respect/validation/tests/integration/rules/consonant_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/consonant_4.phpt b/vendor/respect/validation/tests/integration/rules/consonant_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/consonant_5.phpt b/vendor/respect/validation/tests/integration/rules/consonant_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countable_1.phpt b/vendor/respect/validation/tests/integration/rules/countable_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countable_3.phpt b/vendor/respect/validation/tests/integration/rules/countable_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countable_4.phpt b/vendor/respect/validation/tests/integration/rules/countable_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countable_5.phpt b/vendor/respect/validation/tests/integration/rules/countable_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_alpha-2_1.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_alpha-2_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_alpha-2_2.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_alpha-2_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_alpha-2_3.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_alpha-2_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_alpha-2_4.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_alpha-2_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_alpha-2_5.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_alpha-2_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_alpha-2_6.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_alpha-2_6.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_alpha-3_1.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_alpha-3_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_alpha-3_2.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_alpha-3_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_alpha-3_3.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_alpha-3_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_alpha-3_4.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_alpha-3_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_alpha-3_5.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_alpha-3_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_alpha-3_6.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_alpha-3_6.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_number_1.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_number_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_number_2.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_number_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_number_3.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_number_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_number_4.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_number_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_number_5.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_number_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/countryCode_number_6.phpt b/vendor/respect/validation/tests/integration/rules/countryCode_number_6.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/cpf_1.phpt b/vendor/respect/validation/tests/integration/rules/cpf_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/cpf_2.phpt b/vendor/respect/validation/tests/integration/rules/cpf_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/cpf_3.phpt b/vendor/respect/validation/tests/integration/rules/cpf_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/cpf_4.phpt b/vendor/respect/validation/tests/integration/rules/cpf_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/cpf_5.phpt b/vendor/respect/validation/tests/integration/rules/cpf_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/creditCard_1.phpt b/vendor/respect/validation/tests/integration/rules/creditCard_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/creditCard_2.phpt b/vendor/respect/validation/tests/integration/rules/creditCard_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/creditCard_3.phpt b/vendor/respect/validation/tests/integration/rules/creditCard_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/creditCard_4.phpt b/vendor/respect/validation/tests/integration/rules/creditCard_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/currencyCode_1.phpt b/vendor/respect/validation/tests/integration/rules/currencyCode_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/currencyCode_2.phpt b/vendor/respect/validation/tests/integration/rules/currencyCode_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/currencyCode_3.phpt b/vendor/respect/validation/tests/integration/rules/currencyCode_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/currencyCode_4.phpt b/vendor/respect/validation/tests/integration/rules/currencyCode_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/currencyCode_5.phpt b/vendor/respect/validation/tests/integration/rules/currencyCode_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/digit_1.phpt b/vendor/respect/validation/tests/integration/rules/digit_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/digit_2.phpt b/vendor/respect/validation/tests/integration/rules/digit_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/digit_3.phpt b/vendor/respect/validation/tests/integration/rules/digit_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/digit_4.phpt b/vendor/respect/validation/tests/integration/rules/digit_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/digit_5.phpt b/vendor/respect/validation/tests/integration/rules/digit_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/email_1.phpt b/vendor/respect/validation/tests/integration/rules/email_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/email_2.phpt b/vendor/respect/validation/tests/integration/rules/email_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/email_3.phpt b/vendor/respect/validation/tests/integration/rules/email_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/email_4.phpt b/vendor/respect/validation/tests/integration/rules/email_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/email_5.phpt b/vendor/respect/validation/tests/integration/rules/email_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/email_6.phpt b/vendor/respect/validation/tests/integration/rules/email_6.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/equals_1.phpt b/vendor/respect/validation/tests/integration/rules/equals_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/equals_2.phpt b/vendor/respect/validation/tests/integration/rules/equals_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/equals_3.phpt b/vendor/respect/validation/tests/integration/rules/equals_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/equals_4.phpt b/vendor/respect/validation/tests/integration/rules/equals_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/equals_5.phpt b/vendor/respect/validation/tests/integration/rules/equals_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/exists_1.phpt b/vendor/respect/validation/tests/integration/rules/exists_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/exists_2.phpt b/vendor/respect/validation/tests/integration/rules/exists_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/floatType_1.phpt b/vendor/respect/validation/tests/integration/rules/floatType_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/floatType_2.phpt b/vendor/respect/validation/tests/integration/rules/floatType_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/floatType_3.phpt b/vendor/respect/validation/tests/integration/rules/floatType_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/floatType_4.phpt b/vendor/respect/validation/tests/integration/rules/floatType_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/floatType_5.phpt b/vendor/respect/validation/tests/integration/rules/floatType_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/identityCard_1.phpt b/vendor/respect/validation/tests/integration/rules/identityCard_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/identityCard_2.phpt b/vendor/respect/validation/tests/integration/rules/identityCard_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/identityCard_3.phpt b/vendor/respect/validation/tests/integration/rules/identityCard_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/identityCard_4.phpt b/vendor/respect/validation/tests/integration/rules/identityCard_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/identityCard_5.phpt b/vendor/respect/validation/tests/integration/rules/identityCard_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/image_1.phpt b/vendor/respect/validation/tests/integration/rules/image_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/image_2.phpt b/vendor/respect/validation/tests/integration/rules/image_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/image_3.phpt b/vendor/respect/validation/tests/integration/rules/image_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/image_4.phpt b/vendor/respect/validation/tests/integration/rules/image_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/image_5.phpt b/vendor/respect/validation/tests/integration/rules/image_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/imei_1.phpt b/vendor/respect/validation/tests/integration/rules/imei_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/imei_2.phpt b/vendor/respect/validation/tests/integration/rules/imei_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/imei_3.phpt b/vendor/respect/validation/tests/integration/rules/imei_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/intType_1.phpt b/vendor/respect/validation/tests/integration/rules/intType_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/intType_2.phpt b/vendor/respect/validation/tests/integration/rules/intType_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/intType_3.phpt b/vendor/respect/validation/tests/integration/rules/intType_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/intType_4.phpt b/vendor/respect/validation/tests/integration/rules/intType_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/intType_5.phpt b/vendor/respect/validation/tests/integration/rules/intType_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/ip_1.phpt b/vendor/respect/validation/tests/integration/rules/ip_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/ip_2.phpt b/vendor/respect/validation/tests/integration/rules/ip_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/ip_3.phpt b/vendor/respect/validation/tests/integration/rules/ip_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/ip_4.phpt b/vendor/respect/validation/tests/integration/rules/ip_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/ip_5.phpt b/vendor/respect/validation/tests/integration/rules/ip_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/ip_6.phpt b/vendor/respect/validation/tests/integration/rules/ip_6.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/iterableType_1.phpt b/vendor/respect/validation/tests/integration/rules/iterableType_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/iterableType_2.phpt b/vendor/respect/validation/tests/integration/rules/iterableType_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/iterableType_3.phpt b/vendor/respect/validation/tests/integration/rules/iterableType_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/iterableType_4.phpt b/vendor/respect/validation/tests/integration/rules/iterableType_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/iterableType_5.phpt b/vendor/respect/validation/tests/integration/rules/iterableType_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/keyNested_1.phpt b/vendor/respect/validation/tests/integration/rules/keyNested_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/keyValue_1.phpt b/vendor/respect/validation/tests/integration/rules/keyValue_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/keyValue_2.phpt b/vendor/respect/validation/tests/integration/rules/keyValue_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/keyValue_3.phpt b/vendor/respect/validation/tests/integration/rules/keyValue_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/keyValue_4.phpt b/vendor/respect/validation/tests/integration/rules/keyValue_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/keyValue_5.phpt b/vendor/respect/validation/tests/integration/rules/keyValue_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/languagecode_1.phpt b/vendor/respect/validation/tests/integration/rules/languagecode_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/languagecode_2.phpt b/vendor/respect/validation/tests/integration/rules/languagecode_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/length_1.phpt b/vendor/respect/validation/tests/integration/rules/length_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/length_2.phpt b/vendor/respect/validation/tests/integration/rules/length_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/length_3.phpt b/vendor/respect/validation/tests/integration/rules/length_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/minimumAge_1.phpt b/vendor/respect/validation/tests/integration/rules/minimumAge_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/minimumAge_2.phpt b/vendor/respect/validation/tests/integration/rules/minimumAge_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/minimumAge_3.phpt b/vendor/respect/validation/tests/integration/rules/minimumAge_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/minimumAge_4.phpt b/vendor/respect/validation/tests/integration/rules/minimumAge_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/notBlank_1.phpt b/vendor/respect/validation/tests/integration/rules/notBlank_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/notBlank_2.phpt b/vendor/respect/validation/tests/integration/rules/notBlank_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/notBlank_3.phpt b/vendor/respect/validation/tests/integration/rules/notBlank_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/notBlank_4.phpt b/vendor/respect/validation/tests/integration/rules/notBlank_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/notEmpty_1.phpt b/vendor/respect/validation/tests/integration/rules/notEmpty_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/notEmpty_2.phpt b/vendor/respect/validation/tests/integration/rules/notEmpty_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/notEmpty_3.phpt b/vendor/respect/validation/tests/integration/rules/notEmpty_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/notEmpty_4.phpt b/vendor/respect/validation/tests/integration/rules/notEmpty_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/notOptional_1.phpt b/vendor/respect/validation/tests/integration/rules/notOptional_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/notOptional_2.phpt b/vendor/respect/validation/tests/integration/rules/notOptional_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/notOptional_3.phpt b/vendor/respect/validation/tests/integration/rules/notOptional_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/notOptional_4.phpt b/vendor/respect/validation/tests/integration/rules/notOptional_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/nullType_1.phpt b/vendor/respect/validation/tests/integration/rules/nullType_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/nullType_2.phpt b/vendor/respect/validation/tests/integration/rules/nullType_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/nullType_3.phpt b/vendor/respect/validation/tests/integration/rules/nullType_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/nullType_4.phpt b/vendor/respect/validation/tests/integration/rules/nullType_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/numeric_1.phpt b/vendor/respect/validation/tests/integration/rules/numeric_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/numeric_2.phpt b/vendor/respect/validation/tests/integration/rules/numeric_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/numeric_3.phpt b/vendor/respect/validation/tests/integration/rules/numeric_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/numeric_4.phpt b/vendor/respect/validation/tests/integration/rules/numeric_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/objectType_1.phpt b/vendor/respect/validation/tests/integration/rules/objectType_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/objectType_2.phpt b/vendor/respect/validation/tests/integration/rules/objectType_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/objectType_3.phpt b/vendor/respect/validation/tests/integration/rules/objectType_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/objectType_4.phpt b/vendor/respect/validation/tests/integration/rules/objectType_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/optional-assert.phpt b/vendor/respect/validation/tests/integration/rules/optional-assert.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/optional-check.phpt b/vendor/respect/validation/tests/integration/rules/optional-check.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/optional-validate.phpt b/vendor/respect/validation/tests/integration/rules/optional-validate.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/optional_1.phpt b/vendor/respect/validation/tests/integration/rules/optional_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/optional_2.phpt b/vendor/respect/validation/tests/integration/rules/optional_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/optional_3.phpt b/vendor/respect/validation/tests/integration/rules/optional_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/optional_4.phpt b/vendor/respect/validation/tests/integration/rules/optional_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/pesel_1.phpt b/vendor/respect/validation/tests/integration/rules/pesel_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/pesel_2.phpt b/vendor/respect/validation/tests/integration/rules/pesel_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/pesel_3.phpt b/vendor/respect/validation/tests/integration/rules/pesel_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/pesel_4.phpt b/vendor/respect/validation/tests/integration/rules/pesel_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/pesel_5.phpt b/vendor/respect/validation/tests/integration/rules/pesel_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/phplabel.phpt b/vendor/respect/validation/tests/integration/rules/phplabel.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/phplabel_2.phpt b/vendor/respect/validation/tests/integration/rules/phplabel_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/phplabel_3.phpt b/vendor/respect/validation/tests/integration/rules/phplabel_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/slug_1.phpt b/vendor/respect/validation/tests/integration/rules/slug_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/slug_2.phpt b/vendor/respect/validation/tests/integration/rules/slug_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/slug_3.phpt b/vendor/respect/validation/tests/integration/rules/slug_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/slug_4.phpt b/vendor/respect/validation/tests/integration/rules/slug_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/slug_5.phpt b/vendor/respect/validation/tests/integration/rules/slug_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/stringType_1.phpt b/vendor/respect/validation/tests/integration/rules/stringType_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/stringType_2.phpt b/vendor/respect/validation/tests/integration/rules/stringType_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/stringType_3.phpt b/vendor/respect/validation/tests/integration/rules/stringType_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/stringType_4.phpt b/vendor/respect/validation/tests/integration/rules/stringType_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/stringType_5.phpt b/vendor/respect/validation/tests/integration/rules/stringType_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/tld_1.phpt b/vendor/respect/validation/tests/integration/rules/tld_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/tld_2.phpt b/vendor/respect/validation/tests/integration/rules/tld_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/tld_3.phpt b/vendor/respect/validation/tests/integration/rules/tld_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/tld_4.phpt b/vendor/respect/validation/tests/integration/rules/tld_4.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/tld_5.phpt b/vendor/respect/validation/tests/integration/rules/tld_5.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/when_1.phpt b/vendor/respect/validation/tests/integration/rules/when_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/when_2.phpt b/vendor/respect/validation/tests/integration/rules/when_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/yes_1.phpt b/vendor/respect/validation/tests/integration/rules/yes_1.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/yes_2.phpt b/vendor/respect/validation/tests/integration/rules/yes_2.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/rules/yes_3.phpt b/vendor/respect/validation/tests/integration/rules/yes_3.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/set_template_with_multiple_validators_should_use_template_as_full_message.phpt b/vendor/respect/validation/tests/integration/set_template_with_multiple_validators_should_use_template_as_full_message.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/set_template_with_multiple_validators_should_use_template_as_main_message.phpt b/vendor/respect/validation/tests/integration/set_template_with_multiple_validators_should_use_template_as_main_message.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/set_template_with_single_validator_should_use_template_as_main_message.phpt b/vendor/respect/validation/tests/integration/set_template_with_single_validator_should_use_template_as_main_message.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/should_not_overwrite_defined_names.phpt b/vendor/respect/validation/tests/integration/should_not_overwrite_defined_names.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/translator-assert.phpt b/vendor/respect/validation/tests/integration/translator-assert.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/integration/translator-check.phpt b/vendor/respect/validation/tests/integration/translator-check.phpt old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/library/Rules/RuleTestCase.php b/vendor/respect/validation/tests/library/Rules/RuleTestCase.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Exceptions/CheckExceptionsTest.php b/vendor/respect/validation/tests/unit/Exceptions/CheckExceptionsTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Exceptions/NestedValidationExceptionTest.php b/vendor/respect/validation/tests/unit/Exceptions/NestedValidationExceptionTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Exceptions/ValidationExceptionTest.php b/vendor/respect/validation/tests/unit/Exceptions/ValidationExceptionTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/FactoryTest.php b/vendor/respect/validation/tests/unit/FactoryTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/AbstractCompositeTest.php b/vendor/respect/validation/tests/unit/Rules/AbstractCompositeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/AbstractCtypeRuleTest.php b/vendor/respect/validation/tests/unit/Rules/AbstractCtypeRuleTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/AbstractFilterRuleTest.php b/vendor/respect/validation/tests/unit/Rules/AbstractFilterRuleTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/AbstractRegexRuleTest.php b/vendor/respect/validation/tests/unit/Rules/AbstractRegexRuleTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/AbstractRelatedTest.php b/vendor/respect/validation/tests/unit/Rules/AbstractRelatedTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/AbstractRuleTest.php b/vendor/respect/validation/tests/unit/Rules/AbstractRuleTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/AbstractSearcherTest.php b/vendor/respect/validation/tests/unit/Rules/AbstractSearcherTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/AbstractWrapperTest.php b/vendor/respect/validation/tests/unit/Rules/AbstractWrapperTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/AgeTest.php b/vendor/respect/validation/tests/unit/Rules/AgeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/AllOfTest.php b/vendor/respect/validation/tests/unit/Rules/AllOfTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/AlnumTest.php b/vendor/respect/validation/tests/unit/Rules/AlnumTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/AlphaTest.php b/vendor/respect/validation/tests/unit/Rules/AlphaTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/AlwaysInvalidTest.php b/vendor/respect/validation/tests/unit/Rules/AlwaysInvalidTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/AlwaysValidTest.php b/vendor/respect/validation/tests/unit/Rules/AlwaysValidTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/ArrayTypeTest.php b/vendor/respect/validation/tests/unit/Rules/ArrayTypeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/ArrayValTest.php b/vendor/respect/validation/tests/unit/Rules/ArrayValTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/AttributeTest.php b/vendor/respect/validation/tests/unit/Rules/AttributeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/BaseTest.php b/vendor/respect/validation/tests/unit/Rules/BaseTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/BetweenTest.php b/vendor/respect/validation/tests/unit/Rules/BetweenTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/BoolTypeTest.php b/vendor/respect/validation/tests/unit/Rules/BoolTypeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/BoolValTest.php b/vendor/respect/validation/tests/unit/Rules/BoolValTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/BsnTest.php b/vendor/respect/validation/tests/unit/Rules/BsnTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/CallTest.php b/vendor/respect/validation/tests/unit/Rules/CallTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/CallableTypeTest.php b/vendor/respect/validation/tests/unit/Rules/CallableTypeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/CallbackTest.php b/vendor/respect/validation/tests/unit/Rules/CallbackTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/CharsetTest.php b/vendor/respect/validation/tests/unit/Rules/CharsetTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/CnhTest.php b/vendor/respect/validation/tests/unit/Rules/CnhTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/CnpjTest.php b/vendor/respect/validation/tests/unit/Rules/CnpjTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/CntrlTest.php b/vendor/respect/validation/tests/unit/Rules/CntrlTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/ConsonantTest.php b/vendor/respect/validation/tests/unit/Rules/ConsonantTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/ContainsTest.php b/vendor/respect/validation/tests/unit/Rules/ContainsTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/CountableTest.php b/vendor/respect/validation/tests/unit/Rules/CountableTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/CountryCodeTest.php b/vendor/respect/validation/tests/unit/Rules/CountryCodeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/CpfTest.php b/vendor/respect/validation/tests/unit/Rules/CpfTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/CreditCardTest.php b/vendor/respect/validation/tests/unit/Rules/CreditCardTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/CurrencyCodeTest.php b/vendor/respect/validation/tests/unit/Rules/CurrencyCodeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/DateTest.php b/vendor/respect/validation/tests/unit/Rules/DateTest.php old mode 100755 new mode 100644 index 0b895592387946fc02e22e4881811e2c8714591d..b0262a6e663f75866f85d09432e36429e3778e97 --- a/vendor/respect/validation/tests/unit/Rules/DateTest.php +++ b/vendor/respect/validation/tests/unit/Rules/DateTest.php @@ -19,7 +19,7 @@ use DateTimeImmutable; * @covers Respect\Validation\Rules\Date * @covers Respect\Validation\Exceptions\DateException */ -class DateTest extends \PHPUnit_Framework_TestCase +class DateTest extends RuleTestCase { protected $dateValidator; @@ -150,4 +150,57 @@ class DateTest extends \PHPUnit_Framework_TestCase ['UTC', 'z', 320], ]; } + + /** + * {@inheritdoc} + */ + public function providerForValidInput() + { + return [ + [new Date(), 'now'], + [new Date(), 'today'], + [new Date(), 'tomorrow'], + [new Date(), 'yesterday'], + [new Date(), '+1 day'], + [new Date(), 'next Thursday'], + [new Date(), '+1 week 2 days 4 hours 2 seconds'], + [new Date(), 2018], + [new Date(), new DateTime()], + [new Date('Y-m-d'), '2009-09-09'], + [new Date('d/m/Y'), '23/05/1987'], + [new Date('c'), '2004-02-12T15:19:21+00:00'], + [new Date('r'), 'Thu, 29 Dec 2005 01:02:03 +0000'], + [new Date('U'), 1464658596], + [new Date('h'), 6], + [new Date('z'), 320], + [new Date('Ym'), 202302], + [new Date('m'), 12], + [new Date('Y'), 2000], + ]; + } + + /** + * {@inheritdoc} + */ + public function providerForInvalidInput() + { + return [ + [new Date(), 'not-a-date'], + [new Date(), []], + [new Date(), true], + [new Date(), false], + [new Date(), null], + [new Date(), ''], + [new Date('Y-m-d'), '2009-12-00'], + [new Date('Y-m-d'), '2018-02-29'], + [new Date('h'), 24], + [new Date(), '2014-99'], + [new Date('d'), 1], + [new Date('Y-m'), '2014-99'], + [new Date('m'), '99'], + [new Date('H'), '24'], + [new Date('i'), '60'], + [new Date('s'), '60'], + ]; + } } diff --git a/vendor/respect/validation/tests/unit/Rules/DigitTest.php b/vendor/respect/validation/tests/unit/Rules/DigitTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/DirectoryTest.php b/vendor/respect/validation/tests/unit/Rules/DirectoryTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/DomainTest.php b/vendor/respect/validation/tests/unit/Rules/DomainTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/EachTest.php b/vendor/respect/validation/tests/unit/Rules/EachTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/EmailTest.php b/vendor/respect/validation/tests/unit/Rules/EmailTest.php old mode 100755 new mode 100644 index 1d74eebacda6dea1da6baee23d64d372a5985519..3c32e47392d91f18da14ec8d6c7b0b12c7986e12 --- a/vendor/respect/validation/tests/unit/Rules/EmailTest.php +++ b/vendor/respect/validation/tests/unit/Rules/EmailTest.php @@ -11,6 +11,8 @@ namespace Respect\Validation\Rules; +use stdClass; + function class_exists($className) { if (isset($GLOBALS['class_exists'][$className])) { @@ -142,6 +144,10 @@ class EmailTest extends \PHPUnit_Framework_TestCase ['test@test..com'], ['test@test.com.'], ['.test@test.com'], + [[]], + [new stdClass()], + [null], + [tmpfile()], ]; } } diff --git a/vendor/respect/validation/tests/unit/Rules/EndsWithTest.php b/vendor/respect/validation/tests/unit/Rules/EndsWithTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/EqualsTest.php b/vendor/respect/validation/tests/unit/Rules/EqualsTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/EvenTest.php b/vendor/respect/validation/tests/unit/Rules/EvenTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/ExecutableTest.php b/vendor/respect/validation/tests/unit/Rules/ExecutableTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/ExistsTest.php b/vendor/respect/validation/tests/unit/Rules/ExistsTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/ExtensionTest.php b/vendor/respect/validation/tests/unit/Rules/ExtensionTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/FactorTest.php b/vendor/respect/validation/tests/unit/Rules/FactorTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/FalseValTest.php b/vendor/respect/validation/tests/unit/Rules/FalseValTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/FibonacciTest.php b/vendor/respect/validation/tests/unit/Rules/FibonacciTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/FileTest.php b/vendor/respect/validation/tests/unit/Rules/FileTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/FilterVarTest.php b/vendor/respect/validation/tests/unit/Rules/FilterVarTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/FiniteTest.php b/vendor/respect/validation/tests/unit/Rules/FiniteTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/FloatTypeTest.php b/vendor/respect/validation/tests/unit/Rules/FloatTypeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/FloatValTest.php b/vendor/respect/validation/tests/unit/Rules/FloatValTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/GraphTest.php b/vendor/respect/validation/tests/unit/Rules/GraphTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/HexRgbColorTest.php b/vendor/respect/validation/tests/unit/Rules/HexRgbColorTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/IdenticalTest.php b/vendor/respect/validation/tests/unit/Rules/IdenticalTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/ImageTest.php b/vendor/respect/validation/tests/unit/Rules/ImageTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/ImeiTest.php b/vendor/respect/validation/tests/unit/Rules/ImeiTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/InTest.php b/vendor/respect/validation/tests/unit/Rules/InTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/InfiniteTest.php b/vendor/respect/validation/tests/unit/Rules/InfiniteTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/InstanceTest.php b/vendor/respect/validation/tests/unit/Rules/InstanceTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/IntTypeTest.php b/vendor/respect/validation/tests/unit/Rules/IntTypeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/IntValTest.php b/vendor/respect/validation/tests/unit/Rules/IntValTest.php old mode 100755 new mode 100644 index 5d3bd04ed213e9fddab3474d638e7dbe15d3fac3..302c19da32b373a63103e2803152e4f397b6d1a8 --- a/vendor/respect/validation/tests/unit/Rules/IntValTest.php +++ b/vendor/respect/validation/tests/unit/Rules/IntValTest.php @@ -52,6 +52,8 @@ class IntValTest extends \PHPUnit_Framework_TestCase ['165'], [123456], [PHP_INT_MAX], + ['06'], + ['0'] ]; } diff --git a/vendor/respect/validation/tests/unit/Rules/IpTest.php b/vendor/respect/validation/tests/unit/Rules/IpTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/IterableTypeTest.php b/vendor/respect/validation/tests/unit/Rules/IterableTypeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/JsonTest.php b/vendor/respect/validation/tests/unit/Rules/JsonTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/KeyNestedTest.php b/vendor/respect/validation/tests/unit/Rules/KeyNestedTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/KeySetTest.php b/vendor/respect/validation/tests/unit/Rules/KeySetTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/KeyTest.php b/vendor/respect/validation/tests/unit/Rules/KeyTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/KeyValueTest.php b/vendor/respect/validation/tests/unit/Rules/KeyValueTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/LanguageCodeTest.php b/vendor/respect/validation/tests/unit/Rules/LanguageCodeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/LeapDateTest.php b/vendor/respect/validation/tests/unit/Rules/LeapDateTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/LeapYearTest.php b/vendor/respect/validation/tests/unit/Rules/LeapYearTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/LengthTest.php b/vendor/respect/validation/tests/unit/Rules/LengthTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/Locale/PlIdentityCardTest.php b/vendor/respect/validation/tests/unit/Rules/Locale/PlIdentityCardTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/LowercaseTest.php b/vendor/respect/validation/tests/unit/Rules/LowercaseTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/MacAddressTest.php b/vendor/respect/validation/tests/unit/Rules/MacAddressTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/MaxTest.php b/vendor/respect/validation/tests/unit/Rules/MaxTest.php old mode 100755 new mode 100644 index 34a05ec1dd596d29fb64258e7ab4e98a9ca017ee..72771e52cc442dcd8793e9157f5487cb3f70224a --- a/vendor/respect/validation/tests/unit/Rules/MaxTest.php +++ b/vendor/respect/validation/tests/unit/Rules/MaxTest.php @@ -62,6 +62,8 @@ class MaxTest extends \PHPUnit_Framework_TestCase [200, false, 250], [200, false, 1500], [200, false, 200], + [1900, false, '2018-01-25'], + [10.5, false, '2018-01-25'], ]; } } diff --git a/vendor/respect/validation/tests/unit/Rules/MimetypeTest.php b/vendor/respect/validation/tests/unit/Rules/MimetypeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/MinTest.php b/vendor/respect/validation/tests/unit/Rules/MinTest.php old mode 100755 new mode 100644 index f8bce87b673c2646a67bc755b01778fa3fd18606..fa01e132792e6d2345117ef923dbe713397880f6 --- a/vendor/respect/validation/tests/unit/Rules/MinTest.php +++ b/vendor/respect/validation/tests/unit/Rules/MinTest.php @@ -70,6 +70,8 @@ class MinTest extends \PHPUnit_Framework_TestCase [0, false, -250], [0, false, -50], [50, false, 50], + [2040, false, '2018-01-25'], + [10.5, false, '2018-01-25'], ]; } } diff --git a/vendor/respect/validation/tests/unit/Rules/MininumAgeTest.php b/vendor/respect/validation/tests/unit/Rules/MininumAgeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/MultipleTest.php b/vendor/respect/validation/tests/unit/Rules/MultipleTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/NegativeTest.php b/vendor/respect/validation/tests/unit/Rules/NegativeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/NfeAccessKeyTest.php b/vendor/respect/validation/tests/unit/Rules/NfeAccessKeyTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/NoTest.php b/vendor/respect/validation/tests/unit/Rules/NoTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/NoWhitespaceTest.php b/vendor/respect/validation/tests/unit/Rules/NoWhitespaceTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/NoneOfTest.php b/vendor/respect/validation/tests/unit/Rules/NoneOfTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/NotBlankTest.php b/vendor/respect/validation/tests/unit/Rules/NotBlankTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/NotEmptyTest.php b/vendor/respect/validation/tests/unit/Rules/NotEmptyTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/NotOptionalTest.php b/vendor/respect/validation/tests/unit/Rules/NotOptionalTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/NotTest.php b/vendor/respect/validation/tests/unit/Rules/NotTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/NullTypeTest.php b/vendor/respect/validation/tests/unit/Rules/NullTypeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/NumericTest.php b/vendor/respect/validation/tests/unit/Rules/NumericTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/ObjectTypeTest.php b/vendor/respect/validation/tests/unit/Rules/ObjectTypeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/OddTest.php b/vendor/respect/validation/tests/unit/Rules/OddTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/OneOfTest.php b/vendor/respect/validation/tests/unit/Rules/OneOfTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/OptionalTest.php b/vendor/respect/validation/tests/unit/Rules/OptionalTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/PerfectSquareTest.php b/vendor/respect/validation/tests/unit/Rules/PerfectSquareTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/PeselTest.php b/vendor/respect/validation/tests/unit/Rules/PeselTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/PhoneTest.php b/vendor/respect/validation/tests/unit/Rules/PhoneTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/PhpLabelTest.php b/vendor/respect/validation/tests/unit/Rules/PhpLabelTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/PositiveTest.php b/vendor/respect/validation/tests/unit/Rules/PositiveTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/PostalCodeTest.php b/vendor/respect/validation/tests/unit/Rules/PostalCodeTest.php old mode 100755 new mode 100644 index e87d6549662a241c00d3cfc8a708f0fef0adcabc..32dc7a1412ac0f36c5f1b278a9c69b5eefb5ad33 --- a/vendor/respect/validation/tests/unit/Rules/PostalCodeTest.php +++ b/vendor/respect/validation/tests/unit/Rules/PostalCodeTest.php @@ -86,6 +86,7 @@ class PostalCodeTest extends \PHPUnit_Framework_TestCase return [ ['BR', '02179-000'], ['BR', '02179000'], + ['CA', 'A1A 2B2'], ['GB', 'GIR 0AA'], ['GB', 'PR1 9LY'], ['US', '02179'], @@ -93,6 +94,10 @@ class PostalCodeTest extends \PHPUnit_Framework_TestCase ['PL', '99-300'], ['NL', '1012 GX'], ['NL', '1012GX'], + ['PT', '3660-606'], + ['PT', '3660606'], + ['CO', '110231'], + ['KR', '03187'], ]; } @@ -121,12 +126,15 @@ class PostalCodeTest extends \PHPUnit_Framework_TestCase return [ ['BR', '02179'], ['BR', '02179.000'], + ['CA', '1A1B2B'], ['GB', 'GIR 00A'], ['GB', 'GIR0AA'], ['GB', 'PR19LY'], ['US', '021 79'], ['YE', '02179'], ['PL', '99300'], + ['KR', '548940'], + ['KR', '548-940'], ]; } } diff --git a/vendor/respect/validation/tests/unit/Rules/PrimeNumberTest.php b/vendor/respect/validation/tests/unit/Rules/PrimeNumberTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/PrntTest.php b/vendor/respect/validation/tests/unit/Rules/PrntTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/PunctTest.php b/vendor/respect/validation/tests/unit/Rules/PunctTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/ReadableTest.php b/vendor/respect/validation/tests/unit/Rules/ReadableTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/RegexTest.php b/vendor/respect/validation/tests/unit/Rules/RegexTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/ResourceTypeTest.php b/vendor/respect/validation/tests/unit/Rules/ResourceTypeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/RomanTest.php b/vendor/respect/validation/tests/unit/Rules/RomanTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/ScalarValTest.php b/vendor/respect/validation/tests/unit/Rules/ScalarValTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/SfTest.php b/vendor/respect/validation/tests/unit/Rules/SfTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/SizeTest.php b/vendor/respect/validation/tests/unit/Rules/SizeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/SlugTest.php b/vendor/respect/validation/tests/unit/Rules/SlugTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/SpaceTest.php b/vendor/respect/validation/tests/unit/Rules/SpaceTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/StartsWithTest.php b/vendor/respect/validation/tests/unit/Rules/StartsWithTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/StringTypeTest.php b/vendor/respect/validation/tests/unit/Rules/StringTypeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/SubdivisionCodeTest.php b/vendor/respect/validation/tests/unit/Rules/SubdivisionCodeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/SymbolicLinkTest.php b/vendor/respect/validation/tests/unit/Rules/SymbolicLinkTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/TldTest.php b/vendor/respect/validation/tests/unit/Rules/TldTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/TrueValTest.php b/vendor/respect/validation/tests/unit/Rules/TrueValTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/TypeTest.php b/vendor/respect/validation/tests/unit/Rules/TypeTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/UploadedTest.php b/vendor/respect/validation/tests/unit/Rules/UploadedTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/UppercaseTest.php b/vendor/respect/validation/tests/unit/Rules/UppercaseTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/UrlTest.php b/vendor/respect/validation/tests/unit/Rules/UrlTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/VersionTest.php b/vendor/respect/validation/tests/unit/Rules/VersionTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/VideoUrlTest.php b/vendor/respect/validation/tests/unit/Rules/VideoUrlTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/VowelTest.php b/vendor/respect/validation/tests/unit/Rules/VowelTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/WhenTest.php b/vendor/respect/validation/tests/unit/Rules/WhenTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/WritableTest.php b/vendor/respect/validation/tests/unit/Rules/WritableTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/XdigitTest.php b/vendor/respect/validation/tests/unit/Rules/XdigitTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/YesTest.php b/vendor/respect/validation/tests/unit/Rules/YesTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/Rules/ZendTest.php b/vendor/respect/validation/tests/unit/Rules/ZendTest.php old mode 100755 new mode 100644 diff --git a/vendor/respect/validation/tests/unit/ValidatorTest.php b/vendor/respect/validation/tests/unit/ValidatorTest.php old mode 100755 new mode 100644 diff --git a/vendor/setasign/fpdi-tcpdf/LICENSE.txt b/vendor/setasign/fpdi-tcpdf/LICENSE.txt old mode 100755 new mode 100644 diff --git a/vendor/setasign/fpdi-tcpdf/README.md b/vendor/setasign/fpdi-tcpdf/README.md old mode 100755 new mode 100644 index c9f4be0d2f5107367ab46ef037d8928fb99b6d29..b64c3ca67d2ef7c2263ee5fb320a26287b2647ee --- a/vendor/setasign/fpdi-tcpdf/README.md +++ b/vendor/setasign/fpdi-tcpdf/README.md @@ -4,7 +4,7 @@ A kind of metadata package for Composer with fixed dependencies for the latest v ## Installation with [Composer](https://packagist.org/packages/setasign/fpdi-tcpdf) ```bash -$ composer require setasign/fpdi-tcpdf:2.0 +$ composer require setasign/fpdi-tcpdf:2.1 ``` or you can include the following in your composer.json file: @@ -12,7 +12,7 @@ or you can include the following in your composer.json file: ```json { "require": { - "setasign/fpdi-tcpdf": "^2.0" + "setasign/fpdi-tcpdf": "^2.1" } } ``` diff --git a/vendor/setasign/fpdi-tcpdf/composer.json b/vendor/setasign/fpdi-tcpdf/composer.json old mode 100755 new mode 100644 index d1fa9d80b196f9cbe30ec100361a209fe378a410..52b32517614ab7f38ddd0e24e00018b1d9480c7d --- a/vendor/setasign/fpdi-tcpdf/composer.json +++ b/vendor/setasign/fpdi-tcpdf/composer.json @@ -14,6 +14,6 @@ ], "require": { "tecnickcom/tcpdf": "^6.2", - "setasign/fpdi": "^2.0" + "setasign/fpdi": "^2.1" } } diff --git a/vendor/setasign/fpdi/LICENSE.txt b/vendor/setasign/fpdi/LICENSE.txt old mode 100755 new mode 100644 diff --git a/vendor/setasign/fpdi/README.md b/vendor/setasign/fpdi/README.md old mode 100755 new mode 100644 index 5a68ad2bde3681dc594cc52412288ad324493058..42856df3e52d6ae9b9428d69adf83bae69a2f0ac --- a/vendor/setasign/fpdi/README.md +++ b/vendor/setasign/fpdi/README.md @@ -13,14 +13,16 @@ FPDI is a collection of PHP classes facilitating developers to read pages from e documents and use them as templates in [FPDF](http://www.fpdf.org), which was developed by Olivier Plathey. Apart from a copy of [FPDF](http://www.fpdf.org), FPDI does not require any special PHP extensions. -FPDI can also be used as an extension for [TCPDF](https://github.com/tecnickcom/TCPDF), too. +FPDI can also be used as an extension for [TCPDF](https://github.com/tecnickcom/TCPDF) or +[tFPDF](http://fpdf.org/en/script/script92.php), too. ## Installation with [Composer](https://packagist.org/packages/setasign/fpdi) -Because FPDI can be used with FPDF or TCPDF we didn't added a fixed dependency in the main -composer.json file but we added metadata packages for both -[FPDF](https://github.com/Setasign/FPDI-FPDF) and -[TCPDF](https://github.com/Setasign/FPDI-TCPDF). +Because FPDI can be used with FPDF, TCPDF or tFPDF we didn't added a fixed dependency in the main +composer.json file but we added metadata packages for +[FPDF](https://github.com/Setasign/FPDI-FPDF), +[TCPDF](https://github.com/Setasign/FPDI-TCPDF) and +[tFPDF](https://github.com/Setasign/FPDI-tFPDF). ### Evaluate Dependencies Automatically @@ -42,6 +44,15 @@ For TCPDF add following [package](https://github.com/Setasign/FPDI-TCPDF) to you } ``` +For tFPDF add following [package](https://github.com/Setasign/FPDI-tFPDF) to your composer.json: +```json +{ + "require": { + "setasign/fpdi-tfpdf": "^2.1" + } +} +``` + ### Manual Dependencies If you don't want to use the metadata packages, it is up to you to add the dependencies to your @@ -69,6 +80,17 @@ If you want to use TCPDF, your have to update your composer.json respectively to } ``` +If you want to use tFPDF, your have to update your composer.json respectively to: + +```json +{ + "require": { + "tecnickcom/tfpdf": "1.25", + "setasign/fpdi": "^2.1" + } +} +``` + ## Manual Installation If you do not use composer, just require the autoload.php in the /src folder: @@ -110,8 +132,8 @@ version 2: result in an `InvalidArgumentException` now. - The return value of `getTemplateSize()` had changed to an array with more speaking keys and reusability: Use `width` instead of `w` and `height` instead of `h`. -- If you want to use **FPDI with TCPDF** you need to refactor your code to use the class `TcpdfFpdi` -instead of `FPDI`. +- If you want to use **FPDI with TCPDF** you need to refactor your code to use the class `Tcpdf\Fpdi` +(since 2.1; before it was `TcpdfFpdi`) instead of `FPDI`. ## Example and Documentation @@ -119,13 +141,18 @@ A simple example, that imports a single page and places this onto a new created ```php <?php -use setasign\Fpdi; +use setasign\Fpdi\Fpdi; +// or for usage with TCPDF: +// use setasign\Fpdi\Tcpdf\Fpdi; + +// or for usage with tFPDF: +// use setasign\Fpdi\Tfpdf\Fpdi; // setup the autoload function require_once('vendor/autoload.php'); // initiate FPDI -$pdf = new Fpdi\Fpdi(); +$pdf = new Fpdi(); // add a page $pdf->AddPage(); // set the source file diff --git a/vendor/setasign/fpdi/composer.json b/vendor/setasign/fpdi/composer.json old mode 100755 new mode 100644 index ba4eb380080bcbd409d5ab39574f83ba997ce3f0..58f79315dd98f3ae08ab88240a4450ca6355a230 --- a/vendor/setasign/fpdi/composer.json +++ b/vendor/setasign/fpdi/composer.json @@ -31,14 +31,16 @@ } ], "suggest": { - "setasign/fpdf": "FPDI will extend this class but as it is also possible to use \"tecnickcom/tcpdf\" as an alternative there's no fixed dependency configured.", + "setasign/fpdf": "FPDI will extend this class but as it is also possible to use TCPDF or tFPDF as an alternative. There's no fixed dependency configured.", "setasign/fpdi-fpdf": "Use this package to automatically evaluate dependencies to FPDF.", - "setasign/fpdi-tcpdf": "Use this package to automatically evaluate dependencies to TCPDF." + "setasign/fpdi-tcpdf": "Use this package to automatically evaluate dependencies to TCPDF.", + "setasign/fpdi-tfpdf": "Use this package to automatically evaluate dependencies to tFPDF." }, "require-dev": { "phpunit/phpunit": "~5.7", "setasign/fpdf": "~1.8", - "tecnickcom/tcpdf": "~6.2" + "tecnickcom/tcpdf": "~6.2", + "setasign/tfpdf": "1.25" }, "autoload-dev": { "psr-4": { diff --git a/vendor/setasign/fpdi/src/FpdfTpl.php b/vendor/setasign/fpdi/src/FpdfTpl.php old mode 100755 new mode 100644 index 0d11850fdda6c22648dbfaaa144d41e7dbc7b47d..86672e59370b228b5b52cf82f9c64001fd0705de --- a/vendor/setasign/fpdi/src/FpdfTpl.php +++ b/vendor/setasign/fpdi/src/FpdfTpl.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi; @@ -19,440 +18,5 @@ namespace setasign\Fpdi; */ class FpdfTpl extends \FPDF { - /** - * Data of all created templates. - * - * @var array - */ - protected $templates = []; - - /** - * The template id for the currently created template. - * - * @var null|int - */ - protected $currentTemplateId; - - /** - * A counter for template ids. - * - * @var int - */ - protected $templateId = 0; - - /** - * Set the page format of the current page. - * - * @param array $size An array with two values defining the size. - * @param string $orientation "L" for landscape, "P" for portrait. - * @throws \BadMethodCallException - */ - public function setPageFormat($size, $orientation) - { - if ($this->currentTemplateId !== null) { - throw new \BadMethodCallException('The page format cannot be changed when writing to a template.'); - } - - if (!\in_array($orientation, ['P', 'L'], true)) { - throw new \InvalidArgumentException(\sprintf( - 'Invalid page orientation "%s"! Only "P" and "L" are allowed!', - $orientation - )); - } - - $size = $this->_getpagesize($size); - - if ($orientation != $this->CurOrientation - || $size[0] != $this->CurPageSize[0] - || $size[1] != $this->CurPageSize[1] - ) { - // New size or orientation - if ($orientation === 'P') { - $this->w = $size[0]; - $this->h = $size[1]; - } else { - $this->w = $size[1]; - $this->h = $size[0]; - } - $this->wPt = $this->w * $this->k; - $this->hPt = $this->h * $this->k; - $this->PageBreakTrigger = $this->h - $this->bMargin; - $this->CurOrientation = $orientation; - $this->CurPageSize = $size; - - $this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt); - } - } - - /** - * Draws a template onto the page or another template. - * - * Omit one of the size parameters (width, height) to calculate the other one automatically in view to the aspect - * ratio. - * - * @param mixed $tpl The template id - * @param array|float|int $x The abscissa of upper-left corner. Alternatively you could use an assoc array - * with the keys "x", "y", "width", "height", "adjustPageSize". - * @param float|int $y The ordinate of upper-left corner. - * @param float|int|null $width The width. - * @param float|int|null $height The height. - * @param bool $adjustPageSize - * @return array The size - * @see FpdfTpl::getTemplateSize() - */ - public function useTemplate($tpl, $x = 0, $y = 0, $width = null, $height = null, $adjustPageSize = false) - { - if (!isset($this->templates[$tpl])) { - throw new \InvalidArgumentException('Template does not exist!'); - } - - if (\is_array($x)) { - unset($x['tpl']); - \extract($x, EXTR_IF_EXISTS); - /** @noinspection NotOptimalIfConditionsInspection */ - /** @noinspection CallableParameterUseCaseInTypeContextInspection */ - if (\is_array($x)) { - $x = 0; - } - } - - $template = $this->templates[$tpl]; - - $originalSize = $this->getTemplateSize($tpl); - $newSize = $this->getTemplateSize($tpl, $width, $height); - if ($adjustPageSize) { - $this->setPageFormat($newSize, $newSize['orientation']); - } - - $this->_out( - // reset standard values, translate and scale - \sprintf( - 'q 0 J 1 w 0 j 0 G 0 g %.4F 0 0 %.4F %.4F %.4F cm /%s Do Q', - ($newSize['width'] / $originalSize['width']), - ($newSize['height'] / $originalSize['height']), - $x * $this->k, - ($this->h - $y - $newSize['height']) * $this->k, - $template['id'] - ) - ); - - return $newSize; - } - - /** - * Get the size of a template. - * - * Omit one of the size parameters (width, height) to calculate the other one automatically in view to the aspect - * ratio. - * - * @param mixed $tpl The template id - * @param float|int|null $width The width. - * @param float|int|null $height The height. - * @return array|bool An array with following keys: width, height, 0 (=width), 1 (=height), orientation (L or P) - */ - public function getTemplateSize($tpl, $width = null, $height = null) - { - if (!isset($this->templates[$tpl])) { - return false; - } - - if ($width === null && $height === null) { - $width = $this->templates[$tpl]['width']; - $height = $this->templates[$tpl]['height']; - } elseif ($width === null) { - $width = $height * $this->templates[$tpl]['width'] / $this->templates[$tpl]['height']; - } - - if ($height === null) { - $height = $width * $this->templates[$tpl]['height'] / $this->templates[$tpl]['width']; - } - - if ($height <= 0. || $width <= 0.) { - throw new \InvalidArgumentException('Width or height parameter needs to be larger than zero.'); - } - - return [ - 'width' => $width, - 'height' => $height, - 0 => $width, - 1 => $height, - 'orientation' => $width > $height ? 'L' : 'P' - ]; - } - - /** - * Begins a new template. - * - * @param float|int|null $width The width of the template. If null, the current page width is used. - * @param float|int|null $height The height of the template. If null, the current page height is used. - * @param bool $groupXObject Define the form XObject as a group XObject to support transparency (if used). - * @return int A template identifier. - */ - public function beginTemplate($width = null, $height = null, $groupXObject = false) - { - if ($width === null) { - $width = $this->w; - } - - if ($height === null) { - $height = $this->h; - } - - $templateId = $this->getNextTemplateId(); - - // initiate buffer with current state of FPDF - $buffer = "2 J\n" - . \sprintf('%.2F w', $this->LineWidth * $this->k) . "\n"; - - if ($this->FontFamily) { - $buffer .= \sprintf("BT /F%d %.2F Tf ET\n", $this->CurrentFont['i'], $this->FontSizePt); - } - - if ($this->DrawColor !== '0 G') { - $buffer .= $this->DrawColor . "\n"; - } - if ($this->FillColor !== '0 g') { - $buffer .= $this->FillColor . "\n"; - } - - if ($groupXObject && \version_compare('1.4', $this->PDFVersion, '>')) { - $this->PDFVersion = '1.4'; - } - - $this->templates[$templateId] = [ - 'objectNumber' => null, - 'id' => 'TPL' . $templateId, - 'buffer' => $buffer, - 'width' => $width, - 'height' => $height, - 'groupXObject' => $groupXObject, - 'state' => [ - 'x' => $this->x, - 'y' => $this->y, - 'AutoPageBreak' => $this->AutoPageBreak, - 'bMargin' => $this->bMargin, - 'tMargin' => $this->tMargin, - 'lMargin' => $this->lMargin, - 'rMargin' => $this->rMargin, - 'h' => $this->h, - 'w' => $this->w, - 'FontFamily' => $this->FontFamily, - 'FontStyle' => $this->FontStyle, - 'FontSizePt' => $this->FontSizePt, - 'FontSize' => $this->FontSize, - 'underline' => $this->underline - ] - ]; - - $this->SetAutoPageBreak(false); - $this->currentTemplateId = $templateId; - - $this->h = $height; - $this->w = $width; - - $this->SetXY($this->lMargin, $this->tMargin); - $this->SetRightMargin($this->w - $width + $this->rMargin); - - return $templateId; - } - - /** - * Ends a template. - * - * @return bool|int|null A template identifier. - */ - public function endTemplate() - { - if (null === $this->currentTemplateId) { - return false; - } - - $templateId = $this->currentTemplateId; - $template = $this->templates[$templateId]; - - $state = $template['state']; - $this->SetXY($state['x'], $state['y']); - $this->tMargin = $state['tMargin']; - $this->lMargin = $state['lMargin']; - $this->rMargin = $state['rMargin']; - $this->h = $state['h']; - $this->w = $state['w']; - $this->SetAutoPageBreak($state['AutoPageBreak'], $state['bMargin']); - - $this->FontFamily = $state['FontFamily']; - $this->FontStyle = $state['FontStyle']; - $this->FontSizePt = $state['FontSizePt']; - $this->FontSize = $state['FontSize']; - - $this->underline = $state['underline']; - - $fontKey = $this->FontFamily . $this->FontStyle; - if ($fontKey) { - $this->CurrentFont =& $this->fonts[$fontKey]; - } else { - unset($this->CurrentFont); - } - - $this->currentTemplateId = null; - - return $templateId; - } - - /** - * Get the next template id. - * - * @return int - */ - protected function getNextTemplateId() - { - return $this->templateId++; - } - - /* overwritten FPDF methods: */ - - /** - * @inheritdoc - */ - public function AddPage($orientation = '', $size = '', $rotation = 0) - { - if ($this->currentTemplateId !== null) { - throw new \BadMethodCallException('Pages cannot be added when writing to a template.'); - } - parent::AddPage($orientation, $size, $rotation); - } - - /** - * @inheritdoc - */ - public function Link($x, $y, $w, $h, $link) - { - if ($this->currentTemplateId !== null) { - throw new \BadMethodCallException('Links cannot be set when writing to a template.'); - } - parent::Link($x, $y, $w, $h, $link); - } - - /** - * @inheritdoc - */ - public function SetLink($link, $y = 0, $page = -1) - { - if ($this->currentTemplateId !== null) { - throw new \BadMethodCallException('Links cannot be set when writing to a template.'); - } - return parent::SetLink($link, $y, $page); - } - - /** - * @inheritdoc - */ - public function SetDrawColor($r, $g = null, $b = null) - { - parent::SetDrawColor($r, $g, $b); - if ($this->page === 0 && $this->currentTemplateId !== null) { - $this->_out($this->DrawColor); - } - } - - /** - * @inheritdoc - */ - public function SetFillColor($r, $g = null, $b = null) - { - parent::SetFillColor($r, $g, $b); - if ($this->page === 0 && $this->currentTemplateId !== null) { - $this->_out($this->FillColor); - } - } - - /** - * @inheritdoc - */ - public function SetLineWidth($width) - { - parent::SetLineWidth($width); - if ($this->page === 0 && $this->currentTemplateId !== null) { - $this->_out(\sprintf('%.2F w', $width * $this->k)); - } - } - - /** - * @inheritdoc - */ - public function SetFont($family, $style = '', $size = 0) - { - parent::SetFont($family, $style, $size); - if ($this->page === 0 && $this->currentTemplateId !== null) { - $this->_out(\sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); - } - } - - /** - * @inheritdoc - */ - public function SetFontSize($size) - { - parent::SetFontSize($size); - if ($this->page === 0 && $this->currentTemplateId !== null) { - $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); - } - } - - /** - * @inheritdoc - */ - protected function _putimages() - { - parent::_putimages(); - - foreach ($this->templates as $key => $template) { - $this->_newobj(); - $this->templates[$key]['objectNumber'] = $this->n; - - $this->_put('<</Type /XObject /Subtype /Form /FormType 1'); - $this->_put(\sprintf('/BBox[0 0 %.2F %.2F]', $template['width'] * $this->k, $template['height'] * $this->k)); - $this->_put('/Resources 2 0 R'); // default resources dictionary of FPDF - - if ($this->compress) { - $buffer = \gzcompress($template['buffer']); - $this->_put('/Filter/FlateDecode'); - } else { - $buffer = $template['buffer']; - } - - $this->_put('/Length ' . \strlen($buffer)); - - if ($template['groupXObject']) { - $this->_put('/Group <</Type/Group/S/Transparency>>'); - } - - $this->_put('>>'); - $this->_putstream($buffer); - $this->_put('endobj'); - } - } - - /** - * @inheritdoc - */ - protected function _putxobjectdict() - { - foreach ($this->templates as $key => $template) { - $this->_put('/' . $template['id'] . ' ' . $template['objectNumber'] . ' 0 R'); - } - - parent::_putxobjectdict(); - } - - /** - * @inheritdoc - */ - public function _out($s) - { - if ($this->currentTemplateId !== null) { - $this->templates[$this->currentTemplateId]['buffer'] .= $s . "\n"; - } else { - parent::_out($s); - } - } + use FpdfTplTrait; } diff --git a/vendor/setasign/fpdi/src/Fpdi.php b/vendor/setasign/fpdi/src/Fpdi.php old mode 100755 new mode 100644 index 769a8530afe120b8215007329addaf9afa066981..1a39c95afaee67d8781056175b0a7671fdb85c46 --- a/vendor/setasign/fpdi/src/Fpdi.php +++ b/vendor/setasign/fpdi/src/Fpdi.php @@ -3,14 +3,14 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi; use setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException; +use setasign\Fpdi\PdfParser\PdfParserException; use setasign\Fpdi\PdfParser\Type\PdfIndirectObject; use setasign\Fpdi\PdfParser\Type\PdfNull; @@ -30,7 +30,7 @@ class Fpdi extends FpdfTpl * * @string */ - const VERSION = '2.0.3'; + const VERSION = '2.1.1'; /** * Draws an imported page or a template onto the page or another template. @@ -75,7 +75,7 @@ class Fpdi extends FpdfTpl public function getTemplateSize($tpl, $width = null, $height = null) { $size = parent::getTemplateSize($tpl, $width, $height); - if (false === $size) { + if ($size === false) { return $this->getImportedPageSize($tpl, $width, $height); } @@ -84,6 +84,8 @@ class Fpdi extends FpdfTpl /** * @inheritdoc + * @throws CrossReferenceException + * @throws PdfParserException */ protected function _putimages() { diff --git a/vendor/setasign/fpdi/src/FpdiException.php b/vendor/setasign/fpdi/src/FpdiException.php old mode 100755 new mode 100644 index 7a23c71023f9a485a0be55414197abafc38b5588..e9522f53bfd10200a222b70847dc2cd4a0586f53 --- a/vendor/setasign/fpdi/src/FpdiException.php +++ b/vendor/setasign/fpdi/src/FpdiException.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi; diff --git a/vendor/setasign/fpdi/src/FpdiTrait.php b/vendor/setasign/fpdi/src/FpdiTrait.php old mode 100755 new mode 100644 index 03e42483366b27bb1dbccc901db924b7cd76d285..f5702e550d1ff78d3d9953f38f637b9761b24f3c --- a/vendor/setasign/fpdi/src/FpdiTrait.php +++ b/vendor/setasign/fpdi/src/FpdiTrait.php @@ -3,14 +3,16 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi; +use setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException; +use setasign\Fpdi\PdfParser\Filter\FilterException; use setasign\Fpdi\PdfParser\PdfParser; +use setasign\Fpdi\PdfParser\PdfParserException; use setasign\Fpdi\PdfParser\StreamReader; use setasign\Fpdi\PdfParser\Type\PdfArray; use setasign\Fpdi\PdfParser\Type\PdfBoolean; @@ -25,6 +27,7 @@ use setasign\Fpdi\PdfParser\Type\PdfStream; use setasign\Fpdi\PdfParser\Type\PdfString; use setasign\Fpdi\PdfParser\Type\PdfToken; use setasign\Fpdi\PdfParser\Type\PdfType; +use setasign\Fpdi\PdfParser\Type\PdfTypeException; use setasign\Fpdi\PdfReader\PageBoundaries; use setasign\Fpdi\PdfReader\PdfReader; use setasign\Fpdi\PdfReader\PdfReaderException; @@ -121,7 +124,7 @@ trait FpdiTrait $id = (string) $file; } elseif (\is_string($file)) { $id = \realpath($file); - if (false === $id) { + if ($id === false) { $id = $file; } } elseif (\is_object($file)) { @@ -132,6 +135,7 @@ trait FpdiTrait ); } + /** @noinspection OffsetOperationsInspection */ if (isset($this->readers[$id])) { return $id; } @@ -145,6 +149,7 @@ trait FpdiTrait } $reader = new PdfReader($this->getPdfParserInstance($streamReader)); + /** @noinspection OffsetOperationsInspection */ $this->readers[$id] = $reader; return $id; @@ -172,6 +177,7 @@ trait FpdiTrait * * @param string|resource|StreamReader $file Path to the file or a stream resource or a StreamReader instance. * @return int The page count of the PDF document. + * @throws PdfParserException */ public function setSourceFile($file) { @@ -191,8 +197,12 @@ trait FpdiTrait * @param string $box The page boundary to import. Default set to PageBoundaries::CROP_BOX. * @param bool $groupXObject Define the form XObject as a group XObject to support transparency (if used). * @return string A unique string identifying the imported page. - * @see PageBoundaries + * @throws CrossReferenceException + * @throws FilterException + * @throws PdfParserException + * @throws PdfTypeException * @throws PdfReaderException + * @see PageBoundaries */ public function importPage($pageNumber, $box = PageBoundaries::CROP_BOX, $groupXObject = true) { @@ -364,6 +374,7 @@ trait FpdiTrait public function useImportedPage($pageId, $x = 0, $y = 0, $width = null, $height = null, $adjustPageSize = false) { if (\is_array($x)) { + /** @noinspection OffsetOperationsInspection */ unset($x['pageId']); \extract($x, EXTR_IF_EXISTS); /** @noinspection NotOptimalIfConditionsInspection */ @@ -446,6 +457,7 @@ trait FpdiTrait * Writes a PdfType object to the resulting buffer. * * @param PdfType $value + * @throws PdfTypeException */ protected function writePdfType(PdfType $value) { diff --git a/vendor/setasign/fpdi/src/PdfParser/CrossReference/AbstractReader.php b/vendor/setasign/fpdi/src/PdfParser/CrossReference/AbstractReader.php old mode 100755 new mode 100644 index 6db71199d312e136458fffe179931a408a40ddf3..4bd6a16fa82c56d5b8fb0d6a23ab8b3045a4f06b --- a/vendor/setasign/fpdi/src/PdfParser/CrossReference/AbstractReader.php +++ b/vendor/setasign/fpdi/src/PdfParser/CrossReference/AbstractReader.php @@ -3,16 +3,16 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\CrossReference; use setasign\Fpdi\PdfParser\PdfParser; use setasign\Fpdi\PdfParser\Type\PdfDictionary; use setasign\Fpdi\PdfParser\Type\PdfToken; +use setasign\Fpdi\PdfParser\Type\PdfTypeException; /** * Abstract class for cross-reference reader classes. @@ -35,6 +35,8 @@ abstract class AbstractReader * AbstractReader constructor. * * @param PdfParser $parser + * @throws CrossReferenceException + * @throws PdfTypeException */ public function __construct(PdfParser $parser) { @@ -56,28 +58,36 @@ abstract class AbstractReader * Read the trailer dictionary. * * @throws CrossReferenceException + * @throws PdfTypeException */ protected function readTrailer() { - $trailerKeyword = $this->parser->readValue(); - if ($trailerKeyword === false || - !($trailerKeyword instanceof PdfToken) || - $trailerKeyword->value !== 'trailer' - ) { + try { + $trailerKeyword = $this->parser->readValue(null, PdfToken::class); + if ($trailerKeyword->value !== 'trailer') { + throw new CrossReferenceException( + \sprintf( + 'Unexpected end of cross reference. "trailer"-keyword expected, got: %s.', + $trailerKeyword->value + ), + CrossReferenceException::UNEXPECTED_END + ); + } + } catch (PdfTypeException $e) { throw new CrossReferenceException( - \sprintf( - 'Unexpected end of cross reference. "trailer"-keyword expected, got: %s', - $trailerKeyword instanceof PdfToken ? $trailerKeyword->value : 'nothing' - ), - CrossReferenceException::UNEXPECTED_END + 'Unexpected end of cross reference. "trailer"-keyword expected, got an invalid object type.', + CrossReferenceException::UNEXPECTED_END, + $e ); } - $trailer = $this->parser->readValue(); - if ($trailer === false || !($trailer instanceof PdfDictionary)) { + try { + $trailer = $this->parser->readValue(null, PdfDictionary::class); + } catch (PdfTypeException $e) { throw new CrossReferenceException( 'Unexpected end of cross reference. Trailer not found.', - CrossReferenceException::UNEXPECTED_END + CrossReferenceException::UNEXPECTED_END, + $e ); } diff --git a/vendor/setasign/fpdi/src/PdfParser/CrossReference/CrossReference.php b/vendor/setasign/fpdi/src/PdfParser/CrossReference/CrossReference.php old mode 100755 new mode 100644 index a9d2d8f1ee6eeb12c91b6d016a1331f5e9b1b518..620411962cad2e269136aee233aea3381a42e17a --- a/vendor/setasign/fpdi/src/PdfParser/CrossReference/CrossReference.php +++ b/vendor/setasign/fpdi/src/PdfParser/CrossReference/CrossReference.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\CrossReference; @@ -16,6 +15,7 @@ use setasign\Fpdi\PdfParser\Type\PdfIndirectObject; use setasign\Fpdi\PdfParser\Type\PdfNumeric; use setasign\Fpdi\PdfParser\Type\PdfStream; use setasign\Fpdi\PdfParser\Type\PdfToken; +use setasign\Fpdi\PdfParser\Type\PdfTypeException; /** * Class CrossReference @@ -52,6 +52,8 @@ class CrossReference * CrossReference constructor. * * @param PdfParser $parser + * @throws CrossReferenceException + * @throws PdfTypeException */ public function __construct(PdfParser $parser, $fileHeaderOffset = 0) { @@ -60,7 +62,8 @@ class CrossReference $offset = $this->findStartXref(); $reader = null; - while ($offset !== false) { + /** @noinspection TypeUnsafeComparisonInspection */ + while ($offset != false) { // By doing an unsafe comparsion we ignore faulty references to byte offset 0 $reader = $this->readXref($offset + $this->fileHeaderOffset); $trailer = $reader->getTrailer(); $this->checkForEncryption($trailer); @@ -80,6 +83,10 @@ class CrossReference */ $reader->fixFaultySubSectionShift(); } + + if ($reader === null) { + throw new CrossReferenceException('No cross-reference found.', CrossReferenceException::NO_XREF_FOUND); + } } /** @@ -122,7 +129,7 @@ class CrossReference { foreach ($this->getReaders() as $reader) { $offset = $reader->getOffsetFor($objectNumber); - if (false !== $offset) { + if ($offset !== false) { return $offset; } } @@ -140,7 +147,7 @@ class CrossReference public function getIndirectObject($objectNumber) { $offset = $this->getOffsetFor($objectNumber); - if (false === $offset) { + if ($offset === false) { throw new CrossReferenceException( \sprintf('Object (id:%s) not found.', $objectNumber), CrossReferenceException::OBJECT_NOT_FOUND @@ -152,11 +159,14 @@ class CrossReference $parser->getTokenizer()->clearStack(); $parser->getStreamReader()->reset($offset + $this->fileHeaderOffset); - $object = $parser->readValue(); - if (false === $object || !($object instanceof PdfIndirectObject)) { + try { + /** @var PdfIndirectObject $object */ + $object = $parser->readValue(null, PdfIndirectObject::class); + } catch (PdfTypeException $e) { throw new CrossReferenceException( \sprintf('Object (id:%s) not found at location (%s).', $objectNumber, $offset), - CrossReferenceException::OBJECT_NOT_FOUND + CrossReferenceException::OBJECT_NOT_FOUND, + $e ); } @@ -178,6 +188,7 @@ class CrossReference * @param int $offset * @return ReaderInterface * @throws CrossReferenceException + * @throws PdfTypeException */ protected function readXref($offset) { @@ -194,6 +205,7 @@ class CrossReference * @param PdfToken|PdfIndirectObject $initValue * @return ReaderInterface|bool * @throws CrossReferenceException + * @throws PdfTypeException */ protected function initReaderInstance($initValue) { @@ -268,10 +280,10 @@ class CrossReference $buffer = $reader->getBuffer(false); $pos = \strrpos($buffer, 'startxref'); $addOffset = 9; - if (false === $pos) { + if ($pos === false) { // Some corrupted documents uses startref, instead of startxref $pos = \strrpos($buffer, 'startref'); - if (false === $pos) { + if ($pos === false) { throw new CrossReferenceException( 'Unable to find pointer to xref table', CrossReferenceException::NO_STARTXREF_FOUND @@ -282,11 +294,13 @@ class CrossReference $reader->setOffset($pos + $addOffset); - $value = $this->parser->readValue(); - if (!($value instanceof PdfNumeric)) { + try { + $value = $this->parser->readValue(null, PdfNumeric::class); + } catch (PdfTypeException $e) { throw new CrossReferenceException( 'Invalid data after startxref keyword.', - CrossReferenceException::INVALID_DATA + CrossReferenceException::INVALID_DATA, + $e ); } diff --git a/vendor/setasign/fpdi/src/PdfParser/CrossReference/CrossReferenceException.php b/vendor/setasign/fpdi/src/PdfParser/CrossReference/CrossReferenceException.php old mode 100755 new mode 100644 index 73bb09f82e1aa35fb018d096b8dee693a8183ce8..faffdcb990b5ca4f6c7df5f301500024bb09d9f4 --- a/vendor/setasign/fpdi/src/PdfParser/CrossReference/CrossReferenceException.php +++ b/vendor/setasign/fpdi/src/PdfParser/CrossReference/CrossReferenceException.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\CrossReference; diff --git a/vendor/setasign/fpdi/src/PdfParser/CrossReference/FixedReader.php b/vendor/setasign/fpdi/src/PdfParser/CrossReference/FixedReader.php old mode 100755 new mode 100644 index 0a9c0e8f2cbdbdc124b9f35a57803a7810ebde1b..b77bcbbcb6670e132e9120d928aa6eff9e273e16 --- a/vendor/setasign/fpdi/src/PdfParser/CrossReference/FixedReader.php +++ b/vendor/setasign/fpdi/src/PdfParser/CrossReference/FixedReader.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\CrossReference; @@ -39,6 +38,7 @@ class FixedReader extends AbstractReader implements ReaderInterface * FixedReader constructor. * * @param PdfParser $parser + * @throws CrossReferenceException */ public function __construct(PdfParser $parser) { @@ -99,7 +99,7 @@ class FixedReader extends AbstractReader implements ReaderInterface } // jump over if line content doesn't match the expected string - if (2 !== \sscanf($line, '%d %d', $startObject, $entryCount)) { + if (\sscanf($line, '%d %d', $startObject, $entryCount) !== 2) { continue; } @@ -138,6 +138,9 @@ class FixedReader extends AbstractReader implements ReaderInterface $this->reader->reset($lastLineStart); } + // reset after the last correct parsed line + $this->reader->reset($lastLineStart); + if (\count($subSections) === 0) { throw new CrossReferenceException( 'No entries found in cross-reference.', diff --git a/vendor/setasign/fpdi/src/PdfParser/CrossReference/LineReader.php b/vendor/setasign/fpdi/src/PdfParser/CrossReference/LineReader.php old mode 100755 new mode 100644 index 260ac22ada0800cf60ba5791c34238b805f2a59e..6e9939c96190aa81533c94d8b4ee94d70721d97a --- a/vendor/setasign/fpdi/src/PdfParser/CrossReference/LineReader.php +++ b/vendor/setasign/fpdi/src/PdfParser/CrossReference/LineReader.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\CrossReference; @@ -34,6 +33,7 @@ class LineReader extends AbstractReader implements ReaderInterface * LineReader constructor. * * @param PdfParser $parser + * @throws CrossReferenceException */ public function __construct(PdfParser $parser) { @@ -80,14 +80,14 @@ class LineReader extends AbstractReader implements ReaderInterface while ( ($trailerPos = \strpos($reader->getBuffer(false), 'trailer', \max($bytesPerCycle * $cycles++, 0))) === false ) { - if (false === $reader->increaseLength($bytesPerCycle)) { + if ($reader->increaseLength($bytesPerCycle) === false) { break; } } - if (false === $trailerPos) { + if ($trailerPos === false) { throw new CrossReferenceException( - 'Unexpected end of cross reference. trailer-keyword not found.', + 'Unexpected end of cross reference. "trailer"-keyword not found.', CrossReferenceException::NO_TRAILER_FOUND ); } diff --git a/vendor/setasign/fpdi/src/PdfParser/CrossReference/ReaderInterface.php b/vendor/setasign/fpdi/src/PdfParser/CrossReference/ReaderInterface.php old mode 100755 new mode 100644 index 6d8015b1ae9d15d3e197a368a17dab0d18371a6e..ca2ef8fde1807a18440c43348f34fc4443a60e47 --- a/vendor/setasign/fpdi/src/PdfParser/CrossReference/ReaderInterface.php +++ b/vendor/setasign/fpdi/src/PdfParser/CrossReference/ReaderInterface.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\CrossReference; diff --git a/vendor/setasign/fpdi/src/PdfParser/Filter/Ascii85.php b/vendor/setasign/fpdi/src/PdfParser/Filter/Ascii85.php old mode 100755 new mode 100644 index 76ad3735a35bd9507961fe34d97cd81669856593..74a11fcb66bfa567cdcd6607e3dfbca2e5a5fff5 --- a/vendor/setasign/fpdi/src/PdfParser/Filter/Ascii85.php +++ b/vendor/setasign/fpdi/src/PdfParser/Filter/Ascii85.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Filter; diff --git a/vendor/setasign/fpdi/src/PdfParser/Filter/Ascii85Exception.php b/vendor/setasign/fpdi/src/PdfParser/Filter/Ascii85Exception.php old mode 100755 new mode 100644 index a6f5887d078f24de0b3323135296f62d7f15a4d6..ac2a003133f3662cd11659107873d58f5b0351b4 --- a/vendor/setasign/fpdi/src/PdfParser/Filter/Ascii85Exception.php +++ b/vendor/setasign/fpdi/src/PdfParser/Filter/Ascii85Exception.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Filter; diff --git a/vendor/setasign/fpdi/src/PdfParser/Filter/AsciiHex.php b/vendor/setasign/fpdi/src/PdfParser/Filter/AsciiHex.php old mode 100755 new mode 100644 index 92ad8d8e921f55676e0907663fe2688ff4029188..9c9e401cb0436a5ed0d6c752508b02740d5e61b1 --- a/vendor/setasign/fpdi/src/PdfParser/Filter/AsciiHex.php +++ b/vendor/setasign/fpdi/src/PdfParser/Filter/AsciiHex.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Filter; diff --git a/vendor/setasign/fpdi/src/PdfParser/Filter/FilterException.php b/vendor/setasign/fpdi/src/PdfParser/Filter/FilterException.php old mode 100755 new mode 100644 index 878cb128ed219e0badab784021ce440e9eab6c02..e7e189cda4960cf2353744bf23966bc74392322c --- a/vendor/setasign/fpdi/src/PdfParser/Filter/FilterException.php +++ b/vendor/setasign/fpdi/src/PdfParser/Filter/FilterException.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Filter; diff --git a/vendor/setasign/fpdi/src/PdfParser/Filter/FilterInterface.php b/vendor/setasign/fpdi/src/PdfParser/Filter/FilterInterface.php old mode 100755 new mode 100644 index 86f54fe14914f52d1d3f22461c5bd1a0b79eab4c..3177a3497f0e36dc2cd9c8da970c87c80bc7fc18 --- a/vendor/setasign/fpdi/src/PdfParser/Filter/FilterInterface.php +++ b/vendor/setasign/fpdi/src/PdfParser/Filter/FilterInterface.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Filter; diff --git a/vendor/setasign/fpdi/src/PdfParser/Filter/Flate.php b/vendor/setasign/fpdi/src/PdfParser/Filter/Flate.php old mode 100755 new mode 100644 index 1fd032dd74df90058cd4936f5d46d236f403387a..13d61970ff40cafea177ba4b2a1b4ea8ef3e2f49 --- a/vendor/setasign/fpdi/src/PdfParser/Filter/Flate.php +++ b/vendor/setasign/fpdi/src/PdfParser/Filter/Flate.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Filter; @@ -42,7 +41,7 @@ class Flate implements FilterInterface if ($this->extensionLoaded()) { $oData = $data; $data = @((\strlen($data) > 0) ? \gzuncompress($data) : ''); - if (false === $data) { + if ($data === false) { // Try this fallback $tries = 1; while ($tries < 10 && ($data === false || \strlen($data) < (\strlen($oData) - $tries - 1))) { @@ -50,7 +49,7 @@ class Flate implements FilterInterface $tries++; } - if (false === $data) { + if ($data === false) { throw new FlateException( 'Error while decompressing stream.', FlateException::DECOMPRESS_ERROR diff --git a/vendor/setasign/fpdi/src/PdfParser/Filter/FlateException.php b/vendor/setasign/fpdi/src/PdfParser/Filter/FlateException.php old mode 100755 new mode 100644 index f3bc6e3eeba8e74e2401820c76e0d4fb7c75d64a..c87ac342fc24db57eba9d8ae9c550f33d732c792 --- a/vendor/setasign/fpdi/src/PdfParser/Filter/FlateException.php +++ b/vendor/setasign/fpdi/src/PdfParser/Filter/FlateException.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Filter; diff --git a/vendor/setasign/fpdi/src/PdfParser/Filter/Lzw.php b/vendor/setasign/fpdi/src/PdfParser/Filter/Lzw.php old mode 100755 new mode 100644 index c8f416bef8997eeadfb7bf18ba2bb7ab45ae7bb4..df10bad73875c529ae2540935baa23e53990c3e0 --- a/vendor/setasign/fpdi/src/PdfParser/Filter/Lzw.php +++ b/vendor/setasign/fpdi/src/PdfParser/Filter/Lzw.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Filter; @@ -71,7 +70,7 @@ class Lzw implements FilterInterface */ public function decode($data) { - if ($data[0] == 0x00 && $data[1] == 0x01) { + if ($data[0] === "\x00" && $data[1] === "\x01") { throw new LzwException( 'LZW flavour not supported.', LzwException::LZW_FLAVOUR_NOT_SUPPORTED @@ -93,12 +92,12 @@ class Lzw implements FilterInterface $uncompData = ''; - while (($code = $this->getNextCode()) != 257) { - if ($code == 256) { + while (($code = $this->getNextCode()) !== 257) { + if ($code === 256) { $this->initsTable(); $code = $this->getNextCode(); - if ($code == 257) { + if ($code === 257) { break; } @@ -154,11 +153,11 @@ class Lzw implements FilterInterface // Add this new String to the table $this->sTable[$this->tIdx++] = $string; - if ($this->tIdx == 511) { + if ($this->tIdx === 511) { $this->bitsToGet = 10; - } elseif ($this->tIdx == 1023) { + } elseif ($this->tIdx === 1023) { $this->bitsToGet = 11; - } elseif ($this->tIdx == 2047) { + } elseif ($this->tIdx === 2047) { $this->bitsToGet = 12; } } @@ -170,7 +169,7 @@ class Lzw implements FilterInterface */ protected function getNextCode() { - if ($this->bytePointer == $this->dataLength) { + if ($this->bytePointer === $this->dataLength) { return 257; } diff --git a/vendor/setasign/fpdi/src/PdfParser/Filter/LzwException.php b/vendor/setasign/fpdi/src/PdfParser/Filter/LzwException.php old mode 100755 new mode 100644 index dabc3df498191c2a291e38dab03938f1b8a36033..4d88616d20a6daf788be26044caae145a737c879 --- a/vendor/setasign/fpdi/src/PdfParser/Filter/LzwException.php +++ b/vendor/setasign/fpdi/src/PdfParser/Filter/LzwException.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Filter; diff --git a/vendor/setasign/fpdi/src/PdfParser/PdfParser.php b/vendor/setasign/fpdi/src/PdfParser/PdfParser.php old mode 100755 new mode 100644 index efb291f1fdd4a26361930f6cdf70461019995400..c6759c56e405960564b07024db06f2e9c8665221 --- a/vendor/setasign/fpdi/src/PdfParser/PdfParser.php +++ b/vendor/setasign/fpdi/src/PdfParser/PdfParser.php @@ -3,14 +3,14 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser; use setasign\Fpdi\PdfParser\CrossReference\CrossReference; +use setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException; use setasign\Fpdi\PdfParser\Type\PdfArray; use setasign\Fpdi\PdfParser\Type\PdfBoolean; use setasign\Fpdi\PdfParser\Type\PdfDictionary; @@ -125,7 +125,7 @@ class PdfParser while (true) { $buffer = $this->streamReader->getBuffer(false); $offset = \strpos($buffer, '%PDF-'); - if (false === $offset) { + if ($offset === false) { if (!$this->streamReader->increaseLength(100) || (--$maxIterations === 0)) { throw new PdfParserException( 'Unable to find PDF file header.', @@ -148,10 +148,12 @@ class PdfParser * Get the cross reference instance. * * @return CrossReference + * @throws CrossReferenceException + * @throws PdfParserException */ public function getCrossReference() { - if (null === $this->xref) { + if ($this->xref === null) { $this->xref = new CrossReference($this, $this->resolveFileHeader()); } @@ -191,6 +193,9 @@ class PdfParser * Get the catalog dictionary. * * @return PdfDictionary + * @throws Type\PdfTypeException + * @throws CrossReferenceException + * @throws PdfParserException */ public function getCatalog() { @@ -208,6 +213,8 @@ class PdfParser * @param int $objectNumber * @param bool $cache * @return PdfIndirectObject + * @throws CrossReferenceException + * @throws PdfParserException */ public function getIndirectObject($objectNumber, $cache = false) { @@ -230,34 +237,44 @@ class PdfParser * Read a PDF value. * * @param null|bool|string $token + * @param null|string $expectedType * @return bool|PdfArray|PdfBoolean|PdfHexString|PdfName|PdfNull|PdfNumeric|PdfString|PdfToken|PdfIndirectObjectReference + * @throws Type\PdfTypeException */ - public function readValue($token = null) + public function readValue($token = null, $expectedType = null) { - if (null === $token) { + if ($token === null) { $token = $this->tokenizer->getNextToken(); } - if (false === $token) { + if ($token === false) { + if ($expectedType !== null) { + throw new Type\PdfTypeException('Got unexpected token type.', Type\PdfTypeException::INVALID_DATA_TYPE); + } return false; } switch ($token) { case '(': + $this->ensureExpectedType($token, $expectedType); return PdfString::parse($this->streamReader); case '<': if ($this->streamReader->getByte() === '<') { + $this->ensureExpectedType('<<', $expectedType); $this->streamReader->addOffset(1); return PdfDictionary::parse($this->tokenizer, $this->streamReader, $this); } + $this->ensureExpectedType($token, $expectedType); return PdfHexString::parse($this->streamReader); case '/': + $this->ensureExpectedType($token, $expectedType); return PdfName::parse($this->tokenizer, $this->streamReader); case '[': + $this->ensureExpectedType($token, $expectedType); return PdfArray::parse($this->tokenizer, $this); default: @@ -267,6 +284,12 @@ class PdfParser if (($token3 = $this->tokenizer->getNextToken()) !== false) { switch ($token3) { case 'obj': + if ($expectedType !== null && $expectedType !== PdfIndirectObject::class) { + throw new Type\PdfTypeException( + 'Got unexpected token type.', Type\PdfTypeException::INVALID_DATA_TYPE + ); + } + return PdfIndirectObject::parse( $token, $token2, @@ -275,6 +298,14 @@ class PdfParser $this->streamReader ); case 'R': + if ($expectedType !== null && + $expectedType !== PdfIndirectObjectReference::class + ) { + throw new Type\PdfTypeException( + 'Got unexpected token type.', Type\PdfTypeException::INVALID_DATA_TYPE + ); + } + return PdfIndirectObjectReference::create($token, $token2); } @@ -285,21 +316,62 @@ class PdfParser $this->tokenizer->pushStack($token2); } + if ($expectedType !== null && $expectedType !== PdfNumeric::class) { + throw new Type\PdfTypeException( + 'Got unexpected token type.', Type\PdfTypeException::INVALID_DATA_TYPE + ); + } return PdfNumeric::create($token); } - if ('true' === $token || 'false' === $token) { - return PdfBoolean::create('true' === $token); + if ($token === 'true' || $token === 'false') { + $this->ensureExpectedType($token, $expectedType); + return PdfBoolean::create($token === 'true'); } - if ('null' === $token) { + if ($token === 'null') { + $this->ensureExpectedType($token, $expectedType); return new PdfNull(); } + if ($expectedType !== null && $expectedType !== PdfToken::class) { + throw new Type\PdfTypeException( + 'Got unexpected token type.', Type\PdfTypeException::INVALID_DATA_TYPE + ); + } + $v = new PdfToken(); $v->value = $token; return $v; } } + + /** + * Ensures that the token will evaluate to an expected object type (or not). + * + * @param string $token + * @param string|null $expectedType + * @return bool + * @throws Type\PdfTypeException + */ + private function ensureExpectedType($token, $expectedType) + { + static $mapping = [ + '(' => PdfString::class, + '<' => PdfHexString::class, + '<<' => PdfDictionary::class, + '/' => PdfName::class, + '[' => PdfArray::class, + 'true' => PdfBoolean::class, + 'false' => PdfBoolean::class, + 'null' => PdfNull::class + ]; + + if ($expectedType === null || $mapping[$token] === $expectedType) { + return true; + } + + throw new Type\PdfTypeException('Got unexpected token type.', Type\PdfTypeException::INVALID_DATA_TYPE); + } } diff --git a/vendor/setasign/fpdi/src/PdfParser/PdfParserException.php b/vendor/setasign/fpdi/src/PdfParser/PdfParserException.php old mode 100755 new mode 100644 index d81f46f076fb9b612b3f28d4e6e25689a8453c23..86f73c9b3bacefb11943fc686142ada6ccd4253b --- a/vendor/setasign/fpdi/src/PdfParser/PdfParserException.php +++ b/vendor/setasign/fpdi/src/PdfParser/PdfParserException.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser; diff --git a/vendor/setasign/fpdi/src/PdfParser/StreamReader.php b/vendor/setasign/fpdi/src/PdfParser/StreamReader.php old mode 100755 new mode 100644 index e3bd456059f2a214d41dcff90d0046df9ee87bb9..bda71a4c87692dd489d5e6c1c6849c8c18d31048 --- a/vendor/setasign/fpdi/src/PdfParser/StreamReader.php +++ b/vendor/setasign/fpdi/src/PdfParser/StreamReader.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser; @@ -163,7 +162,7 @@ class StreamReader */ public function getBuffer($atOffset = true) { - if (false === $atOffset) { + if ($atOffset === false) { return $this->buffer; } @@ -184,7 +183,7 @@ class StreamReader */ public function getByte($position = null) { - $position = (int) (null !== $position ? $position : $this->offset); + $position = (int) ($position !== null ? $position : $this->offset); if ($position >= $this->bufferLength && (!$this->increaseLength() || $position >= $this->bufferLength) ) { @@ -206,7 +205,7 @@ class StreamReader */ public function readByte($position = null) { - if (null !== $position) { + if ($position !== null) { $position = (int) $position; // check if needed bytes are available in the current buffer if (!($position >= $this->position && $position < $this->position + $this->bufferLength)) { @@ -243,7 +242,7 @@ class StreamReader public function readBytes($length, $position = null) { $length = (int) $length; - if (null !== $position) { + if ($position !== null) { // check if needed bytes are available in the current buffer if (!($position >= $this->position && $position < $this->position + $this->bufferLength)) { $this->reset($position, $length); @@ -275,7 +274,7 @@ class StreamReader */ public function readLine($length = 1024) { - if (false === $this->ensureContent()) { + if ($this->ensureContent() === false) { return false; } @@ -372,7 +371,7 @@ class StreamReader */ public function getTotalLength() { - if (null === $this->totalLength) { + if ($this->totalLength === null) { $stat = \fstat($this->stream); $this->totalLength = $stat['size']; } @@ -394,7 +393,7 @@ class StreamReader */ public function reset($pos = 0, $length = 200) { - if (null === $pos) { + if ($pos === null) { $pos = $this->position + $this->offset; } elseif ($pos < 0) { $pos = \max(0, $this->getTotalLength() + $pos); diff --git a/vendor/setasign/fpdi/src/PdfParser/Tokenizer.php b/vendor/setasign/fpdi/src/PdfParser/Tokenizer.php old mode 100755 new mode 100644 index 500b247785e125d29f287fe6fc7df3c7f08e054b..f49f62e357b245ec9cc65ca02a814a73aa09b433 --- a/vendor/setasign/fpdi/src/PdfParser/Tokenizer.php +++ b/vendor/setasign/fpdi/src/PdfParser/Tokenizer.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser; @@ -75,7 +74,7 @@ class Tokenizer public function getNextToken() { $token = \array_pop($this->stack); - if (null !== $token) { + if ($token !== null) { return $token; } @@ -90,7 +89,7 @@ class Tokenizer $byte === "\x09" || $byte === "\x00" ) { - if (false === $this->leapWhiteSpaces()) { + if ($this->leapWhiteSpaces() === false) { return false; } $byte = $this->streamReader->readByte(); diff --git a/vendor/setasign/fpdi/src/PdfParser/Type/PdfArray.php b/vendor/setasign/fpdi/src/PdfParser/Type/PdfArray.php old mode 100755 new mode 100644 index 6ad096d8806b47568cca5180f84e860f985bcce3..bb203de4c8401dbfea0af286499a7a02f9414654 --- a/vendor/setasign/fpdi/src/PdfParser/Type/PdfArray.php +++ b/vendor/setasign/fpdi/src/PdfParser/Type/PdfArray.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Type; @@ -27,6 +26,7 @@ class PdfArray extends PdfType * @param Tokenizer $tokenizer * @param PdfParser $parser * @return bool|self + * @throws PdfTypeException */ public static function parse(Tokenizer $tokenizer, PdfParser $parser) { diff --git a/vendor/setasign/fpdi/src/PdfParser/Type/PdfBoolean.php b/vendor/setasign/fpdi/src/PdfParser/Type/PdfBoolean.php old mode 100755 new mode 100644 index 0910d087ac31a58d07f9ebd51381a1c9ef23b07d..6fd42abf144114f23ed1cd03c95dfe8ae499e3ce --- a/vendor/setasign/fpdi/src/PdfParser/Type/PdfBoolean.php +++ b/vendor/setasign/fpdi/src/PdfParser/Type/PdfBoolean.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Type; @@ -35,6 +34,7 @@ class PdfBoolean extends PdfType * * @param mixed $value * @return self + * @throws PdfTypeException */ public static function ensure($value) { diff --git a/vendor/setasign/fpdi/src/PdfParser/Type/PdfDictionary.php b/vendor/setasign/fpdi/src/PdfParser/Type/PdfDictionary.php old mode 100755 new mode 100644 index b0a2ee0d190fd19c33a15d3203d3ebe1db05ac3b..49267ff9c6de426532f8072a4d0851baaaf69509 --- a/vendor/setasign/fpdi/src/PdfParser/Type/PdfDictionary.php +++ b/vendor/setasign/fpdi/src/PdfParser/Type/PdfDictionary.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Type; @@ -28,6 +27,7 @@ class PdfDictionary extends PdfType * @param StreamReader $streamReader * @param PdfParser $parser * @return bool|self + * @throws PdfTypeException */ public static function parse(Tokenizer $tokenizer, StreamReader $streamReader, PdfParser $parser) { @@ -41,7 +41,7 @@ class PdfDictionary extends PdfType } $key = $parser->readValue($token); - if (false === $key) { + if ($key === false) { return false; } @@ -62,7 +62,7 @@ class PdfDictionary extends PdfType $value = $parser->readValue(); - if (false === $value) { + if ($value === false) { return false; } @@ -106,6 +106,7 @@ class PdfDictionary extends PdfType * @param string $key * @param PdfType|mixed|null $default * @return PdfNull|PdfType + * @throws PdfTypeException */ public static function get($dictionary, $key, PdfType $default = null) { @@ -125,6 +126,7 @@ class PdfDictionary extends PdfType * * @param mixed $dictionary * @return self + * @throws PdfTypeException */ public static function ensure($dictionary) { diff --git a/vendor/setasign/fpdi/src/PdfParser/Type/PdfHexString.php b/vendor/setasign/fpdi/src/PdfParser/Type/PdfHexString.php old mode 100755 new mode 100644 index f6f44811eebaee6f6bada552d68c18a3917d781f..2eb9539c25a81bb325e4a230c9688f4050682904 --- a/vendor/setasign/fpdi/src/PdfParser/Type/PdfHexString.php +++ b/vendor/setasign/fpdi/src/PdfParser/Type/PdfHexString.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Type; @@ -36,7 +35,7 @@ class PdfHexString extends PdfType while (true) { $buffer = $streamReader->getBuffer(false); $pos = \strpos($buffer, '>', $bufferOffset); - if (false === $pos) { + if ($pos === false) { if (!$streamReader->increaseLength()) { return false; } @@ -74,6 +73,7 @@ class PdfHexString extends PdfType * * @param mixed $hexString * @return self + * @throws PdfTypeException */ public static function ensure($hexString) { diff --git a/vendor/setasign/fpdi/src/PdfParser/Type/PdfIndirectObject.php b/vendor/setasign/fpdi/src/PdfParser/Type/PdfIndirectObject.php old mode 100755 new mode 100644 index bbe42ffda851acb981197ba2df1c541b477939f1..046616a28d3ffde6644442f4d403b5ce3773e453 --- a/vendor/setasign/fpdi/src/PdfParser/Type/PdfIndirectObject.php +++ b/vendor/setasign/fpdi/src/PdfParser/Type/PdfIndirectObject.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Type; @@ -30,6 +29,7 @@ class PdfIndirectObject extends PdfType * @param Tokenizer $tokenizer * @param StreamReader $reader * @return bool|self + * @throws PdfTypeException */ public static function parse( $objectNumberToken, @@ -81,6 +81,7 @@ class PdfIndirectObject extends PdfType * * @param mixed $indirectObject * @return self + * @throws PdfTypeException */ public static function ensure($indirectObject) { diff --git a/vendor/setasign/fpdi/src/PdfParser/Type/PdfIndirectObjectReference.php b/vendor/setasign/fpdi/src/PdfParser/Type/PdfIndirectObjectReference.php old mode 100755 new mode 100644 index 02a2a62c60b5abe5997baca8d597fa8a2cb16abb..517199d558b3334c89ab85b2f6476930335d9856 --- a/vendor/setasign/fpdi/src/PdfParser/Type/PdfIndirectObjectReference.php +++ b/vendor/setasign/fpdi/src/PdfParser/Type/PdfIndirectObjectReference.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Type; @@ -38,6 +37,7 @@ class PdfIndirectObjectReference extends PdfType * * @param mixed $value * @return self + * @throws PdfTypeException */ public static function ensure($value) { diff --git a/vendor/setasign/fpdi/src/PdfParser/Type/PdfName.php b/vendor/setasign/fpdi/src/PdfParser/Type/PdfName.php old mode 100755 new mode 100644 index dab2e07eecba8073faa8dde6986d44ca128b0b18..cb3ad51e901ed94a9fcfe74eb09432fa70a5d913 --- a/vendor/setasign/fpdi/src/PdfParser/Type/PdfName.php +++ b/vendor/setasign/fpdi/src/PdfParser/Type/PdfName.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Type; @@ -47,7 +46,7 @@ class PdfName extends PdfType */ static public function unescape($value) { - if (false === strpos($value, '#')) + if (strpos($value, '#') === false) return $value; return preg_replace_callback('/#[a-fA-F\d]{2}/', function($matches) { @@ -74,6 +73,7 @@ class PdfName extends PdfType * * @param mixed $name * @return self + * @throws PdfTypeException */ public static function ensure($name) { diff --git a/vendor/setasign/fpdi/src/PdfParser/Type/PdfNull.php b/vendor/setasign/fpdi/src/PdfParser/Type/PdfNull.php old mode 100755 new mode 100644 index fc97ac036c01a0f72dba02e86c97789c331e06e5..6d040a6b7a7d900244097e9aebd966964941bff8 --- a/vendor/setasign/fpdi/src/PdfParser/Type/PdfNull.php +++ b/vendor/setasign/fpdi/src/PdfParser/Type/PdfNull.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Type; diff --git a/vendor/setasign/fpdi/src/PdfParser/Type/PdfNumeric.php b/vendor/setasign/fpdi/src/PdfParser/Type/PdfNumeric.php old mode 100755 new mode 100644 index ed6921f7ef2041bd13d32cd6697230e00e553c8b..fc3a4e112a63d6ce35bd53775bfd89e589014ea0 --- a/vendor/setasign/fpdi/src/PdfParser/Type/PdfNumeric.php +++ b/vendor/setasign/fpdi/src/PdfParser/Type/PdfNumeric.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Type; @@ -36,6 +35,7 @@ class PdfNumeric extends PdfType * * @param mixed $value * @return self + * @throws PdfTypeException */ public static function ensure($value) { diff --git a/vendor/setasign/fpdi/src/PdfParser/Type/PdfStream.php b/vendor/setasign/fpdi/src/PdfParser/Type/PdfStream.php old mode 100755 new mode 100644 index a3418ead6f1eafa160c5a66c605e528f01a134c7..eeec67f515d5cb170affc3ed5b736a612ee879fd --- a/vendor/setasign/fpdi/src/PdfParser/Type/PdfStream.php +++ b/vendor/setasign/fpdi/src/PdfParser/Type/PdfStream.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Type; @@ -95,6 +94,7 @@ class PdfStream extends PdfType * * @param mixed $stream * @return self + * @throws PdfTypeException */ public static function ensure($stream) { @@ -120,6 +120,7 @@ class PdfStream extends PdfType * * @param bool $cache Whether cache the stream data or not. * @return bool|string + * @throws PdfTypeException */ public function getStream($cache = false) { @@ -130,7 +131,7 @@ class PdfStream extends PdfType while (true) { $buffer = $this->reader->getBuffer(false); $length = \strpos($buffer, 'endstream'); - if (false === $length) { + if ($length === false) { if (!$this->reader->increaseLength(100000)) { return false; } diff --git a/vendor/setasign/fpdi/src/PdfParser/Type/PdfString.php b/vendor/setasign/fpdi/src/PdfParser/Type/PdfString.php old mode 100755 new mode 100644 index 55852cc1f8b982124a86a3ce442d72fda784719b..9a3bb47eec09aabfa42b904dd0c5fadb67406d7f --- a/vendor/setasign/fpdi/src/PdfParser/Type/PdfString.php +++ b/vendor/setasign/fpdi/src/PdfParser/Type/PdfString.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Type; @@ -73,6 +72,7 @@ class PdfString extends PdfType * * @param mixed $string * @return self + * @throws PdfTypeException */ public static function ensure($string) { diff --git a/vendor/setasign/fpdi/src/PdfParser/Type/PdfToken.php b/vendor/setasign/fpdi/src/PdfParser/Type/PdfToken.php old mode 100755 new mode 100644 index e9419027f4d33cd1540e1e7dbb3e69ce1c7c313f..89cf113fb18a005eadc31a5cc72dcf2a76de299d --- a/vendor/setasign/fpdi/src/PdfParser/Type/PdfToken.php +++ b/vendor/setasign/fpdi/src/PdfParser/Type/PdfToken.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Type; @@ -36,6 +35,7 @@ class PdfToken extends PdfType * * @param mixed $token * @return self + * @throws PdfTypeException */ public static function ensure($token) { diff --git a/vendor/setasign/fpdi/src/PdfParser/Type/PdfType.php b/vendor/setasign/fpdi/src/PdfParser/Type/PdfType.php old mode 100755 new mode 100644 index 927f0f7bc33914c16999c7244058d702e6edb6b5..61aeb6ee919fb86af8c6c59a91cec79f561eb8d9 --- a/vendor/setasign/fpdi/src/PdfParser/Type/PdfType.php +++ b/vendor/setasign/fpdi/src/PdfParser/Type/PdfType.php @@ -3,14 +3,15 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Type; +use setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException; use setasign\Fpdi\PdfParser\PdfParser; +use setasign\Fpdi\PdfParser\PdfParserException; /** * A class defining a PDF data type @@ -28,6 +29,8 @@ class PdfType * @param PdfParser $parser * @param bool $stopAtIndirectObject * @return PdfType + * @throws CrossReferenceException + * @throws PdfParserException */ public static function resolve(PdfType $value, PdfParser $parser, $stopAtIndirectObject = false) { diff --git a/vendor/setasign/fpdi/src/PdfParser/Type/PdfTypeException.php b/vendor/setasign/fpdi/src/PdfParser/Type/PdfTypeException.php old mode 100755 new mode 100644 index 9f59a589817552a79438bf2794e2ad483490a6a2..97de6463d5ef373c5fd7f939db4f295ae0735578 --- a/vendor/setasign/fpdi/src/PdfParser/Type/PdfTypeException.php +++ b/vendor/setasign/fpdi/src/PdfParser/Type/PdfTypeException.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfParser\Type; diff --git a/vendor/setasign/fpdi/src/PdfReader/DataStructure/Rectangle.php b/vendor/setasign/fpdi/src/PdfReader/DataStructure/Rectangle.php old mode 100755 new mode 100644 index e11cb2ae8e7ff7f7bf80921fa0c67b38757c9b53..8ffa956237bfc3fc47f96d5940b7e3ec39b4a0d4 --- a/vendor/setasign/fpdi/src/PdfReader/DataStructure/Rectangle.php +++ b/vendor/setasign/fpdi/src/PdfReader/DataStructure/Rectangle.php @@ -3,17 +3,19 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfReader\DataStructure; +use setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException; use setasign\Fpdi\PdfParser\PdfParser; +use setasign\Fpdi\PdfParser\PdfParserException; use setasign\Fpdi\PdfParser\Type\PdfArray; use setasign\Fpdi\PdfParser\Type\PdfNumeric; use setasign\Fpdi\PdfParser\Type\PdfType; +use setasign\Fpdi\PdfParser\Type\PdfTypeException; /** * Class representing a rectangle @@ -48,6 +50,9 @@ class Rectangle * @param PdfArray|mixed $array * @param PdfParser $parser * @return Rectangle + * @throws PdfTypeException + * @throws CrossReferenceException + * @throws PdfParserException */ public static function byPdfArray($array, PdfParser $parser) { diff --git a/vendor/setasign/fpdi/src/PdfReader/Page.php b/vendor/setasign/fpdi/src/PdfReader/Page.php old mode 100755 new mode 100644 index f9f84355b60f063a8933b220f033984a43f637bb..64668297bb02446b2b20ca9c38081bb4d7a1bfd9 --- a/vendor/setasign/fpdi/src/PdfReader/Page.php +++ b/vendor/setasign/fpdi/src/PdfReader/Page.php @@ -3,14 +3,15 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfReader; +use setasign\Fpdi\PdfParser\Filter\FilterException; use setasign\Fpdi\PdfParser\PdfParser; +use setasign\Fpdi\PdfParser\PdfParserException; use setasign\Fpdi\PdfParser\Type\PdfArray; use setasign\Fpdi\PdfParser\Type\PdfDictionary; use setasign\Fpdi\PdfParser\Type\PdfIndirectObject; @@ -18,7 +19,9 @@ use setasign\Fpdi\PdfParser\Type\PdfNull; use setasign\Fpdi\PdfParser\Type\PdfNumeric; use setasign\Fpdi\PdfParser\Type\PdfStream; use setasign\Fpdi\PdfParser\Type\PdfType; +use setasign\Fpdi\PdfParser\Type\PdfTypeException; use setasign\Fpdi\PdfReader\DataStructure\Rectangle; +use setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException; /** * Class representing a page of a PDF document @@ -75,6 +78,9 @@ class Page * Get the dictionary of this page. * * @return PdfDictionary + * @throws PdfParserException + * @throws PdfTypeException + * @throws CrossReferenceException */ public function getPageDictionary() { @@ -91,6 +97,9 @@ class Page * @param string $name * @param bool $inherited * @return PdfType|null + * @throws PdfParserException + * @throws PdfTypeException + * @throws CrossReferenceException */ public function getAttribute($name, $inherited = true) { @@ -102,7 +111,7 @@ class Page $inheritedKeys = ['Resources', 'MediaBox', 'CropBox', 'Rotate']; if ($inherited && \in_array($name, $inheritedKeys, true)) { - if (null === $this->inheritedAttributes) { + if ($this->inheritedAttributes === null) { $this->inheritedAttributes = []; $inheritedKeys = \array_filter($inheritedKeys, function ($key) use ($dict) { return !isset($dict->value[$key]); @@ -140,6 +149,9 @@ class Page * Get the rotation value. * * @return int + * @throws PdfParserException + * @throws PdfTypeException + * @throws CrossReferenceException */ public function getRotation() { @@ -163,17 +175,20 @@ class Page * @param string $box * @param bool $fallback * @return bool|Rectangle + * @throws PdfParserException + * @throws PdfTypeException + * @throws CrossReferenceException * @see PageBoundaries */ public function getBoundary($box = PageBoundaries::CROP_BOX, $fallback = true) { $value = $this->getAttribute($box); - if (null !== $value) { + if ($value !== null) { return Rectangle::byPdfArray($value, $this->parser); } - if (false === $fallback) { + if ($fallback === false) { return false; } @@ -195,11 +210,14 @@ class Page * @param string $box * @param bool $fallback * @return array|bool + * @throws PdfParserException + * @throws PdfTypeException + * @throws CrossReferenceException */ public function getWidthAndHeight($box = PageBoundaries::CROP_BOX, $fallback = true) { $boundary = $this->getBoundary($box, $fallback); - if (false === $boundary) { + if ($boundary === false) { return false; } @@ -217,6 +235,9 @@ class Page * * @return string * @throws PdfReaderException + * @throws PdfTypeException + * @throws FilterException + * @throws PdfParserException */ public function getContentStream() { diff --git a/vendor/setasign/fpdi/src/PdfReader/PageBoundaries.php b/vendor/setasign/fpdi/src/PdfReader/PageBoundaries.php old mode 100755 new mode 100644 index 2aeaada70dec95a822dea0a29988c1b9933eccb6..08e4224eaf1a11cc5167843c80ab9f86195c79e8 --- a/vendor/setasign/fpdi/src/PdfReader/PageBoundaries.php +++ b/vendor/setasign/fpdi/src/PdfReader/PageBoundaries.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfReader; diff --git a/vendor/setasign/fpdi/src/PdfReader/PdfReader.php b/vendor/setasign/fpdi/src/PdfReader/PdfReader.php old mode 100755 new mode 100644 index 31da99c4e562a40ed686867d6199b0451b037b7b..f8f3419205597ea50ffb40b95bb79ea04cb2bbd6 --- a/vendor/setasign/fpdi/src/PdfReader/PdfReader.php +++ b/vendor/setasign/fpdi/src/PdfReader/PdfReader.php @@ -3,19 +3,21 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfReader; +use setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException; use setasign\Fpdi\PdfParser\PdfParser; +use setasign\Fpdi\PdfParser\PdfParserException; use setasign\Fpdi\PdfParser\Type\PdfArray; use setasign\Fpdi\PdfParser\Type\PdfDictionary; use setasign\Fpdi\PdfParser\Type\PdfIndirectObjectReference; use setasign\Fpdi\PdfParser\Type\PdfNumeric; use setasign\Fpdi\PdfParser\Type\PdfType; +use setasign\Fpdi\PdfParser\Type\PdfTypeException; /** * A PDF reader class @@ -76,6 +78,7 @@ class PdfReader * Get the PDF version. * * @return string + * @throws PdfParserException */ public function getPdfVersion() { @@ -86,6 +89,9 @@ class PdfReader * Get the page count. * * @return int + * @throws PdfTypeException + * @throws CrossReferenceException + * @throws PdfParserException */ public function getPageCount() { @@ -106,6 +112,10 @@ class PdfReader * * @param int $pageNumber * @return Page + * @throws PdfTypeException + * @throws CrossReferenceException + * @throws PdfParserException + * @throws \InvalidArgumentException */ public function getPage($pageNumber) { @@ -168,6 +178,10 @@ class PdfReader /** * Walk the page tree and resolve all indirect objects of all pages. + * + * @throws PdfTypeException + * @throws CrossReferenceException + * @throws PdfParserException */ protected function readPages() { diff --git a/vendor/setasign/fpdi/src/PdfReader/PdfReaderException.php b/vendor/setasign/fpdi/src/PdfReader/PdfReaderException.php old mode 100755 new mode 100644 index 37ce77d18cf9fc02f571953b0ef728a3542035aa..20413acced6e08ce882fea7d2b65ceb8180e2db8 --- a/vendor/setasign/fpdi/src/PdfReader/PdfReaderException.php +++ b/vendor/setasign/fpdi/src/PdfReader/PdfReaderException.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi\PdfReader; diff --git a/vendor/setasign/fpdi/src/TcpdfFpdi.php b/vendor/setasign/fpdi/src/TcpdfFpdi.php old mode 100755 new mode 100644 index 519accf27797024add3d6499401f632b84760fe3..e71dc9d4ee9868823f96baf08d88d659cbb8b5de --- a/vendor/setasign/fpdi/src/TcpdfFpdi.php +++ b/vendor/setasign/fpdi/src/TcpdfFpdi.php @@ -3,260 +3,21 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ namespace setasign\Fpdi; -use setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException; -use setasign\Fpdi\PdfParser\Filter\AsciiHex; -use setasign\Fpdi\PdfParser\Type\PdfHexString; -use setasign\Fpdi\PdfParser\Type\PdfIndirectObject; -use setasign\Fpdi\PdfParser\Type\PdfNull; -use setasign\Fpdi\PdfParser\Type\PdfNumeric; -use setasign\Fpdi\PdfParser\Type\PdfStream; -use setasign\Fpdi\PdfParser\Type\PdfString; -use setasign\Fpdi\PdfParser\Type\PdfType; - /** * Class TcpdfFpdi * * This class let you import pages of existing PDF documents into a reusable structure for TCPDF. * * @package setasign\Fpdi + * @deprecated Class was moved to \setasign\Fpdi\Tcpdf\Fpdi */ -class TcpdfFpdi extends \TCPDF +class TcpdfFpdi extends \setasign\Fpdi\Tcpdf\Fpdi { - use FpdiTrait { - writePdfType as fpdiWritePdfType; - useImportedPage as fpdiUseImportedPage; - } - - /** - * FPDI version - * - * @string - */ - const VERSION = '2.0.3'; - - /** - * A counter for template ids. - * - * @var int - */ - protected $templateId = 0; - - /** - * The currently used object number. - * - * @var int - */ - protected $currentObjectNumber; - - /** - * Get the next template id. - * - * @return int - */ - protected function getNextTemplateId() - { - return $this->templateId++; - } - - /** - * Draws an imported page onto the page or another template. - * - * Omit one of the size parameters (width, height) to calculate the other one automatically in view to the aspect - * ratio. - * - * @param mixed $tpl The template id - * @param float|int|array $x The abscissa of upper-left corner. Alternatively you could use an assoc array - * with the keys "x", "y", "width", "height", "adjustPageSize". - * @param float|int $y The ordinate of upper-left corner. - * @param float|int|null $width The width. - * @param float|int|null $height The height. - * @param bool $adjustPageSize - * @return array The size - * @see FpdiTrait::getTemplateSize() - */ - public function useTemplate($tpl, $x = 0, $y = 0, $width = null, $height = null, $adjustPageSize = false) - { - return $this->useImportedPage($tpl, $x, $y, $width, $height, $adjustPageSize); - } - - /** - * Draws an imported page onto the page. - * - * Omit one of the size parameters (width, height) to calculate the other one automatically in view to the aspect - * ratio. - * - * @param mixed $pageId The page id - * @param float|int|array $x The abscissa of upper-left corner. Alternatively you could use an assoc array - * with the keys "x", "y", "width", "height", "adjustPageSize". - * @param float|int $y The ordinate of upper-left corner. - * @param float|int|null $width The width. - * @param float|int|null $height The height. - * @param bool $adjustPageSize - * @return array The size. - * @see Fpdi::getTemplateSize() - */ - public function useImportedPage($pageId, $x = 0, $y = 0, $width = null, $height = null, $adjustPageSize = false) - { - $size = $this->fpdiUseImportedPage($pageId, $x, $y, $width, $height, $adjustPageSize); - if ($this->inxobj) { - $importedPage = $this->importedPages[$pageId]; - $this->xobjects[$this->xobjid]['importedPages'][$importedPage['id']] = $pageId; - } - - return $size; - } - - /** - * Get the size of an imported page. - * - * Omit one of the size parameters (width, height) to calculate the other one automatically in view to the aspect - * ratio. - * - * @param mixed $tpl The template id - * @param float|int|null $width The width. - * @param float|int|null $height The height. - * @return array|bool An array with following keys: width, height, 0 (=width), 1 (=height), orientation (L or P) - */ - public function getTemplateSize($tpl, $width = null, $height = null) - { - return $this->getImportedPageSize($tpl, $width, $height); - } - - /** - * @inheritdoc - */ - protected function _getxobjectdict() - { - $out = parent::_getxobjectdict(); - - foreach ($this->importedPages as $key => $pageData) { - $out .= '/' . $pageData['id'] . ' ' . $pageData['objectNumber'] . ' 0 R '; - } - - return $out; - } - - /** - * @inheritdoc - */ - protected function _putxobjects() - { - foreach ($this->importedPages as $key => $pageData) { - $this->currentObjectNumber = $this->_newobj(); - $this->importedPages[$key]['objectNumber'] = $this->currentObjectNumber; - $this->currentReaderId = $pageData['readerId']; - $this->writePdfType($pageData['stream']); - $this->_put('endobj'); - } - - foreach (\array_keys($this->readers) as $readerId) { - $parser = $this->getPdfReader($readerId)->getParser(); - $this->currentReaderId = $readerId; - - while (($objectNumber = \array_pop($this->objectsToCopy[$readerId])) !== null) { - try { - $object = $parser->getIndirectObject($objectNumber); - - } catch (CrossReferenceException $e) { - if ($e->getCode() === CrossReferenceException::OBJECT_NOT_FOUND) { - $object = PdfIndirectObject::create($objectNumber, 0, new PdfNull()); - } else { - throw $e; - } - } - - $this->writePdfType($object); - } - } - - // let's prepare resources for imported pages in templates - foreach ($this->xobjects as $xObjectId => $data) { - if (!isset($data['importedPages'])) { - continue; - } - - foreach ($data['importedPages'] as $id => $pageKey) { - $page = $this->importedPages[$pageKey]; - $this->xobjects[$xObjectId]['xobjects'][$id] = ['n' => $page['objectNumber']]; - } - } - - - parent::_putxobjects(); - $this->currentObjectNumber = null; - } - - /** - * Append content to the buffer of TCPDF. - * - * @param string $s - * @param bool $newLine - */ - protected function _put($s, $newLine = true) - { - if ($newLine) { - $this->setBuffer($s . "\n"); - } else { - $this->setBuffer($s); - } - } - - /** - * Begin a new object and return the object number. - * - * @param int|string $objid Object ID (leave empty to get a new ID). - * @return int object number - */ - protected function _newobj($objid = '') - { - $this->_out($this->_getobj($objid)); - return $this->n; - } - - /** - * Writes a PdfType object to the resulting buffer. - * - * @param PdfType $value - */ - protected function writePdfType(PdfType $value) - { - if (!$this->encrypted) { - $this->fpdiWritePdfType($value); - return; - } - - if ($value instanceof PdfString) { - $string = PdfString::unescape($value->value); - $string = $this->_encrypt_data($this->currentObjectNumber, $string); - $value->value = \TCPDF_STATIC::_escape($string); - - } elseif ($value instanceof PdfHexString) { - $filter = new AsciiHex(); - $string = $filter->decode($value->value); - $string = $this->_encrypt_data($this->currentObjectNumber, $string); - $value->value = $filter->encode($string, true); - - } elseif ($value instanceof PdfStream) { - $stream = $value->getStream(); - $stream = $this->_encrypt_data($this->currentObjectNumber, $stream); - $dictionary = $value->value; - $dictionary->value['Length'] = PdfNumeric::create(\strlen($stream)); - $value = PdfStream::create($dictionary, $stream); - - } elseif ($value instanceof PdfIndirectObject) { - /** - * @var $value PdfIndirectObject - */ - $this->currentObjectNumber = $this->objectMap[$this->currentReaderId][$value->objectNumber]; - } - - $this->fpdiWritePdfType($value); - } + // this class is moved to \setasign\Fpdi\Tcpdf\Fpdi } diff --git a/vendor/setasign/fpdi/src/autoload.php b/vendor/setasign/fpdi/src/autoload.php old mode 100755 new mode 100644 index 64086bed84316e73cf49ec95fd1067212bb98f48..5fed74df1ca8340f386dcc3814417ffd1cfa04a0 --- a/vendor/setasign/fpdi/src/autoload.php +++ b/vendor/setasign/fpdi/src/autoload.php @@ -3,10 +3,9 @@ * This file is part of FPDI * * @package setasign\Fpdi - * @copyright Copyright (c) 2017 Setasign - Jan Slabon (https://www.setasign.com) + * @copyright Copyright (c) 2018 Setasign - Jan Slabon (https://www.setasign.com) * @license http://opensource.org/licenses/mit-license The MIT License - * @version 2.0.3 - */ + */ spl_autoload_register(function ($class) { if (strpos($class, 'setasign\Fpdi\\') === 0) { diff --git a/vendor/slim/slim/CODE_OF_CONDUCT.md b/vendor/slim/slim/CODE_OF_CONDUCT.md old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/LICENSE.md b/vendor/slim/slim/LICENSE.md old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/App.php b/vendor/slim/slim/Slim/App.php old mode 100755 new mode 100644 index ba2aef40695fde23b49021b307e1cbbfeceed8d2..6bf64a0f904b3da4a710eb258f06d5ac99fdc97c --- a/vendor/slim/slim/Slim/App.php +++ b/vendor/slim/slim/Slim/App.php @@ -52,7 +52,7 @@ class App * * @var string */ - const VERSION = '3.10.0'; + const VERSION = '3.11.0'; /** * Container @@ -424,8 +424,10 @@ class App if (!headers_sent()) { // Headers foreach ($response->getHeaders() as $name => $values) { + $first = stripos($name, 'Set-Cookie') === 0 ? false : true; foreach ($values as $value) { - header(sprintf('%s: %s', $name, $value), false); + header(sprintf('%s: %s', $name, $value), $first); + $first = false; } } @@ -438,7 +440,7 @@ class App $response->getProtocolVersion(), $response->getStatusCode(), $response->getReasonPhrase() - )); + ), true, $response->getStatusCode()); } // Body diff --git a/vendor/slim/slim/Slim/CallableResolver.php b/vendor/slim/slim/Slim/CallableResolver.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/CallableResolverAwareTrait.php b/vendor/slim/slim/Slim/CallableResolverAwareTrait.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Collection.php b/vendor/slim/slim/Slim/Collection.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Container.php b/vendor/slim/slim/Slim/Container.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/DefaultServicesProvider.php b/vendor/slim/slim/Slim/DefaultServicesProvider.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/DeferredCallable.php b/vendor/slim/slim/Slim/DeferredCallable.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Exception/ContainerException.php b/vendor/slim/slim/Slim/Exception/ContainerException.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Exception/ContainerValueNotFoundException.php b/vendor/slim/slim/Slim/Exception/ContainerValueNotFoundException.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Exception/InvalidMethodException.php b/vendor/slim/slim/Slim/Exception/InvalidMethodException.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Exception/MethodNotAllowedException.php b/vendor/slim/slim/Slim/Exception/MethodNotAllowedException.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Exception/NotFoundException.php b/vendor/slim/slim/Slim/Exception/NotFoundException.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Exception/SlimException.php b/vendor/slim/slim/Slim/Exception/SlimException.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Handlers/AbstractError.php b/vendor/slim/slim/Slim/Handlers/AbstractError.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Handlers/AbstractHandler.php b/vendor/slim/slim/Slim/Handlers/AbstractHandler.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Handlers/Error.php b/vendor/slim/slim/Slim/Handlers/Error.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Handlers/NotAllowed.php b/vendor/slim/slim/Slim/Handlers/NotAllowed.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Handlers/NotFound.php b/vendor/slim/slim/Slim/Handlers/NotFound.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Handlers/PhpError.php b/vendor/slim/slim/Slim/Handlers/PhpError.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php b/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponseArgs.php b/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponseArgs.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Http/Body.php b/vendor/slim/slim/Slim/Http/Body.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Http/Cookies.php b/vendor/slim/slim/Slim/Http/Cookies.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Http/Environment.php b/vendor/slim/slim/Slim/Http/Environment.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Http/Headers.php b/vendor/slim/slim/Slim/Http/Headers.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Http/Message.php b/vendor/slim/slim/Slim/Http/Message.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Http/Request.php b/vendor/slim/slim/Slim/Http/Request.php old mode 100755 new mode 100644 index 3bda649b3353be17eb101839f99a7d3d771f4a20..2762ffc555054a64eb586fcdd59ca0ca22e8d973 --- a/vendor/slim/slim/Slim/Http/Request.php +++ b/vendor/slim/slim/Slim/Http/Request.php @@ -1134,7 +1134,7 @@ class Request extends Message implements ServerRequestInterface * Note: This method is not part of the PSR-7 standard. * * @param string $key The parameter key. - * @param string $default The default value. + * @param mixed $default The default value. * * @return mixed The parameter value. */ @@ -1211,7 +1211,7 @@ class Request extends Message implements ServerRequestInterface $params = $this->getQueryParams(); $postParams = $this->getParsedBody(); if ($postParams) { - $params = array_merge($params, (array)$postParams); + $params = array_replace($params, (array)$postParams); } if ($only) { diff --git a/vendor/slim/slim/Slim/Http/RequestBody.php b/vendor/slim/slim/Slim/Http/RequestBody.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Http/Response.php b/vendor/slim/slim/Slim/Http/Response.php old mode 100755 new mode 100644 index d8fb8dcb02c7a2e96e94fd15cde0d3c6dde0c4de..9b5272e648c00c5e88155c9a7a794e1e7a735028 --- a/vendor/slim/slim/Slim/Http/Response.php +++ b/vendor/slim/slim/Slim/Http/Response.php @@ -31,7 +31,7 @@ class Response extends Message implements ResponseInterface * * @var int */ - protected $status = 200; + protected $status = StatusCode::HTTP_OK; /** * Reason phrase @@ -47,74 +47,74 @@ class Response extends Message implements ResponseInterface */ protected static $messages = [ //Informational 1xx - 100 => 'Continue', - 101 => 'Switching Protocols', - 102 => 'Processing', + StatusCode::HTTP_CONTINUE => 'Continue', + StatusCode::HTTP_SWITCHING_PROTOCOLS => 'Switching Protocols', + StatusCode::HTTP_PROCESSING => 'Processing', //Successful 2xx - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - 207 => 'Multi-Status', - 208 => 'Already Reported', - 226 => 'IM Used', + StatusCode::HTTP_OK => 'OK', + StatusCode::HTTP_CREATED => 'Created', + StatusCode::HTTP_ACCEPTED => 'Accepted', + StatusCode::HTTP_NONAUTHORITATIVE_INFORMATION => 'Non-Authoritative Information', + StatusCode::HTTP_NO_CONTENT => 'No Content', + StatusCode::HTTP_RESET_CONTENT => 'Reset Content', + StatusCode::HTTP_PARTIAL_CONTENT => 'Partial Content', + StatusCode::HTTP_MULTI_STATUS => 'Multi-Status', + StatusCode::HTTP_ALREADY_REPORTED => 'Already Reported', + StatusCode::HTTP_IM_USED => 'IM Used', //Redirection 3xx - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 306 => '(Unused)', - 307 => 'Temporary Redirect', - 308 => 'Permanent Redirect', + StatusCode::HTTP_MULTIPLE_CHOICES => 'Multiple Choices', + StatusCode::HTTP_MOVED_PERMANENTLY => 'Moved Permanently', + StatusCode::HTTP_FOUND => 'Found', + StatusCode::HTTP_SEE_OTHER => 'See Other', + StatusCode::HTTP_NOT_MODIFIED => 'Not Modified', + StatusCode::HTTP_USE_PROXY => 'Use Proxy', + StatusCode::HTTP_UNUSED => '(Unused)', + StatusCode::HTTP_TEMPORARY_REDIRECT => 'Temporary Redirect', + StatusCode::HTTP_PERMANENT_REDIRECT => 'Permanent Redirect', //Client Error 4xx - 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', - 418 => 'I\'m a teapot', - 421 => 'Misdirected Request', - 422 => 'Unprocessable Entity', - 423 => 'Locked', - 424 => 'Failed Dependency', - 426 => 'Upgrade Required', - 428 => 'Precondition Required', - 429 => 'Too Many Requests', - 431 => 'Request Header Fields Too Large', - 444 => 'Connection Closed Without Response', - 451 => 'Unavailable For Legal Reasons', - 499 => 'Client Closed Request', + StatusCode::HTTP_BAD_REQUEST => 'Bad Request', + StatusCode::HTTP_UNAUTHORIZED => 'Unauthorized', + StatusCode::HTTP_PAYMENT_REQUIRED => 'Payment Required', + StatusCode::HTTP_FORBIDDEN => 'Forbidden', + StatusCode::HTTP_NOT_FOUND => 'Not Found', + StatusCode::HTTP_METHOD_NOT_ALLOWED => 'Method Not Allowed', + StatusCode::HTTP_NOT_ACCEPTABLE => 'Not Acceptable', + StatusCode::HTTP_PROXY_AUTHENTICATION_REQUIRED => 'Proxy Authentication Required', + StatusCode::HTTP_REQUEST_TIMEOUT => 'Request Timeout', + StatusCode::HTTP_CONFLICT => 'Conflict', + StatusCode::HTTP_GONE => 'Gone', + StatusCode::HTTP_LENGTH_REQUIRED => 'Length Required', + StatusCode::HTTP_PRECONDITION_FAILED => 'Precondition Failed', + StatusCode::HTTP_REQUEST_ENTITY_TOO_LARGE => 'Request Entity Too Large', + StatusCode::HTTP_REQUEST_URI_TOO_LONG => 'Request-URI Too Long', + StatusCode::HTTP_UNSUPPORTED_MEDIA_TYPE => 'Unsupported Media Type', + StatusCode::HTTP_REQUESTED_RANGE_NOT_SATISFIABLE => 'Requested Range Not Satisfiable', + StatusCode::HTTP_EXPECTATION_FAILED => 'Expectation Failed', + StatusCode::HTTP_IM_A_TEAPOT => 'I\'m a teapot', + StatusCode::HTTP_MISDIRECTED_REQUEST => 'Misdirected Request', + StatusCode::HTTP_UNPROCESSABLE_ENTITY => 'Unprocessable Entity', + StatusCode::HTTP_LOCKED => 'Locked', + StatusCode::HTTP_FAILED_DEPENDENCY => 'Failed Dependency', + StatusCode::HTTP_UPGRADE_REQUIRED => 'Upgrade Required', + StatusCode::HTTP_PRECONDITION_REQUIRED => 'Precondition Required', + StatusCode::HTTP_TOO_MANY_REQUESTS => 'Too Many Requests', + StatusCode::HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE => 'Request Header Fields Too Large', + StatusCode::HTTP_CONNECTION_CLOSED_WITHOUT_RESPONSE => 'Connection Closed Without Response', + StatusCode::HTTP_UNAVAILABLE_FOR_LEGAL_REASONS => 'Unavailable For Legal Reasons', + StatusCode::HTTP_CLIENT_CLOSED_REQUEST => 'Client Closed Request', //Server Error 5xx - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 506 => 'Variant Also Negotiates', - 507 => 'Insufficient Storage', - 508 => 'Loop Detected', - 510 => 'Not Extended', - 511 => 'Network Authentication Required', - 599 => 'Network Connect Timeout Error', + StatusCode::HTTP_INTERNAL_SERVER_ERROR => 'Internal Server Error', + StatusCode::HTTP_NOT_IMPLEMENTED => 'Not Implemented', + StatusCode::HTTP_BAD_GATEWAY => 'Bad Gateway', + StatusCode::HTTP_SERVICE_UNAVAILABLE => 'Service Unavailable', + StatusCode::HTTP_GATEWAY_TIMEOUT => 'Gateway Timeout', + StatusCode::HTTP_VERSION_NOT_SUPPORTED => 'HTTP Version Not Supported', + StatusCode::HTTP_VARIANT_ALSO_NEGOTIATES => 'Variant Also Negotiates', + StatusCode::HTTP_INSUFFICIENT_STORAGE => 'Insufficient Storage', + StatusCode::HTTP_LOOP_DETECTED => 'Loop Detected', + StatusCode::HTTP_NOT_EXTENDED => 'Not Extended', + StatusCode::HTTP_NETWORK_AUTHENTICATION_REQUIRED => 'Network Authentication Required', + StatusCode::HTTP_NETWORK_CONNECTION_TIMEOUT_ERROR => 'Network Connect Timeout Error', ]; /** @@ -122,7 +122,7 @@ class Response extends Message implements ResponseInterface * * @var string */ - const EOL = "\r\n"; + const EOL = "\r\n"; /** * Create new HTTP response. @@ -131,8 +131,11 @@ class Response extends Message implements ResponseInterface * @param HeadersInterface|null $headers The response headers. * @param StreamInterface|null $body The response body. */ - public function __construct($status = 200, HeadersInterface $headers = null, StreamInterface $body = null) - { + public function __construct( + $status = StatusCode::HTTP_OK, + HeadersInterface $headers = null, + StreamInterface $body = null + ) { $this->status = $this->filterStatus($status); $this->headers = $headers ? $headers : new Headers(); $this->body = $body ? $body : new Body(fopen('php://temp', 'r+')); @@ -218,7 +221,10 @@ class Response extends Message implements ResponseInterface */ protected function filterStatus($status) { - if (!is_integer($status) || $status<100 || $status>599) { + if (!is_integer($status) || + $status<StatusCode::HTTP_CONTINUE || + $status>StatusCode::HTTP_NETWORK_CONNECTION_TIMEOUT_ERROR + ) { throw new InvalidArgumentException('Invalid HTTP status code'); } @@ -269,8 +275,8 @@ class Response extends Message implements ResponseInterface $clone = clone $this; $clone->headers->set($name, $value); - if ($clone->getStatusCode() === 200 && strtolower($name) === 'location') { - $clone = $clone->withStatus(302); + if ($clone->getStatusCode() === StatusCode::HTTP_OK && strtolower($name) === 'location') { + $clone = $clone->withStatus(StatusCode::HTTP_FOUND); } return $clone; @@ -318,8 +324,8 @@ class Response extends Message implements ResponseInterface { $responseWithRedirect = $this->withHeader('Location', (string)$url); - if (is_null($status) && $this->getStatusCode() === 200) { - $status = 302; + if (is_null($status) && $this->getStatusCode() === StatusCode::HTTP_OK) { + $status = StatusCode::HTTP_FOUND; } if (!is_null($status)) { @@ -369,7 +375,10 @@ class Response extends Message implements ResponseInterface */ public function isEmpty() { - return in_array($this->getStatusCode(), [204, 205, 304]); + return in_array( + $this->getStatusCode(), + [StatusCode::HTTP_NO_CONTENT, StatusCode::HTTP_RESET_CONTENT, StatusCode::HTTP_NOT_MODIFIED] + ); } /** @@ -381,7 +390,7 @@ class Response extends Message implements ResponseInterface */ public function isInformational() { - return $this->getStatusCode() >= 100 && $this->getStatusCode() < 200; + return $this->getStatusCode() >= StatusCode::HTTP_CONTINUE && $this->getStatusCode() < StatusCode::HTTP_OK; } /** @@ -393,7 +402,7 @@ class Response extends Message implements ResponseInterface */ public function isOk() { - return $this->getStatusCode() === 200; + return $this->getStatusCode() === StatusCode::HTTP_OK; } /** @@ -405,7 +414,8 @@ class Response extends Message implements ResponseInterface */ public function isSuccessful() { - return $this->getStatusCode() >= 200 && $this->getStatusCode() < 300; + return $this->getStatusCode() >= StatusCode::HTTP_OK && + $this->getStatusCode() < StatusCode::HTTP_MULTIPLE_CHOICES; } /** @@ -417,7 +427,16 @@ class Response extends Message implements ResponseInterface */ public function isRedirect() { - return in_array($this->getStatusCode(), [301, 302, 303, 307]); + return in_array( + $this->getStatusCode(), + [ + StatusCode::HTTP_MOVED_PERMANENTLY, + StatusCode::HTTP_FOUND, + StatusCode::HTTP_SEE_OTHER, + StatusCode::HTTP_TEMPORARY_REDIRECT, + StatusCode::HTTP_PERMANENT_REDIRECT + ] + ); } /** @@ -429,7 +448,8 @@ class Response extends Message implements ResponseInterface */ public function isRedirection() { - return $this->getStatusCode() >= 300 && $this->getStatusCode() < 400; + return $this->getStatusCode() >= StatusCode::HTTP_MULTIPLE_CHOICES && + $this->getStatusCode() < StatusCode::HTTP_BAD_REQUEST; } /** @@ -442,7 +462,7 @@ class Response extends Message implements ResponseInterface */ public function isForbidden() { - return $this->getStatusCode() === 403; + return $this->getStatusCode() === StatusCode::HTTP_FORBIDDEN; } /** @@ -454,7 +474,7 @@ class Response extends Message implements ResponseInterface */ public function isNotFound() { - return $this->getStatusCode() === 404; + return $this->getStatusCode() === StatusCode::HTTP_NOT_FOUND; } /** @@ -466,7 +486,8 @@ class Response extends Message implements ResponseInterface */ public function isClientError() { - return $this->getStatusCode() >= 400 && $this->getStatusCode() < 500; + return $this->getStatusCode() >= StatusCode::HTTP_BAD_REQUEST && + $this->getStatusCode() < StatusCode::HTTP_INTERNAL_SERVER_ERROR; } /** @@ -478,7 +499,7 @@ class Response extends Message implements ResponseInterface */ public function isServerError() { - return $this->getStatusCode() >= 500 && $this->getStatusCode() < 600; + return $this->getStatusCode() >= StatusCode::HTTP_INTERNAL_SERVER_ERROR && $this->getStatusCode() < 600; } /** diff --git a/vendor/slim/slim/Slim/Http/Stream.php b/vendor/slim/slim/Slim/Http/Stream.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Http/UploadedFile.php b/vendor/slim/slim/Slim/Http/UploadedFile.php old mode 100755 new mode 100644 index ae5dfb65e593c491afe3e8e495143b869bdda62d..431ef2d3faf24c5b198609c28db4df66b3560e96 --- a/vendor/slim/slim/Slim/Http/UploadedFile.php +++ b/vendor/slim/slim/Slim/Http/UploadedFile.php @@ -177,7 +177,7 @@ class UploadedFile implements UploadedFileInterface public function getStream() { if ($this->moved) { - throw new \RuntimeException(sprintf('Uploaded file %1s has already been moved', $this->name)); + throw new \RuntimeException(sprintf('Uploaded file %s has already been moved', $this->name)); } if ($this->stream === null) { $this->stream = new Stream(fopen($this->file, 'r')); @@ -233,22 +233,22 @@ class UploadedFile implements UploadedFileInterface if ($targetIsStream) { if (!copy($this->file, $targetPath)) { - throw new RuntimeException(sprintf('Error moving uploaded file %1s to %2s', $this->name, $targetPath)); + throw new RuntimeException(sprintf('Error moving uploaded file %s to %s', $this->name, $targetPath)); } if (!unlink($this->file)) { - throw new RuntimeException(sprintf('Error removing uploaded file %1s', $this->name)); + throw new RuntimeException(sprintf('Error removing uploaded file %s', $this->name)); } } elseif ($this->sapi) { if (!is_uploaded_file($this->file)) { - throw new RuntimeException(sprintf('%1s is not a valid uploaded file', $this->file)); + throw new RuntimeException(sprintf('%s is not a valid uploaded file', $this->file)); } if (!move_uploaded_file($this->file, $targetPath)) { - throw new RuntimeException(sprintf('Error moving uploaded file %1s to %2s', $this->name, $targetPath)); + throw new RuntimeException(sprintf('Error moving uploaded file %s to %s', $this->name, $targetPath)); } } else { if (!rename($this->file, $targetPath)) { - throw new RuntimeException(sprintf('Error moving uploaded file %1s to %2s', $this->name, $targetPath)); + throw new RuntimeException(sprintf('Error moving uploaded file %s to %s', $this->name, $targetPath)); } } diff --git a/vendor/slim/slim/Slim/Http/Uri.php b/vendor/slim/slim/Slim/Http/Uri.php old mode 100755 new mode 100644 index fb0f04b5c3e9de7440b0342343bc693bc1d23a20..7e168a66013327f78cc5e0ef81390a899125660f --- a/vendor/slim/slim/Slim/Http/Uri.php +++ b/vendor/slim/slim/Slim/Http/Uri.php @@ -173,15 +173,17 @@ class Uri implements UriInterface $username = $env->get('PHP_AUTH_USER', ''); $password = $env->get('PHP_AUTH_PW', ''); - // Authority: Host + // Authority: Host and Port if ($env->has('HTTP_HOST')) { $host = $env->get('HTTP_HOST'); + // set a port default + $port = null; } else { $host = $env->get('SERVER_NAME'); + // set a port default + $port = (int)$env->get('SERVER_PORT', 80); } - // Authority: Port - $port = (int)$env->get('SERVER_PORT', 80); if (preg_match('/^(\[[a-fA-F0-9:.]+\])(:\d+)?\z/', $host, $matches)) { $host = $matches[1]; @@ -338,7 +340,7 @@ class Uri implements UriInterface $host = $this->getHost(); $port = $this->getPort(); - return ($userInfo ? $userInfo . '@' : '') . $host . ($port !== null ? ':' . $port : ''); + return ($userInfo !== '' ? $userInfo . '@' : '') . $host . ($port !== null ? ':' . $port : ''); } /** @@ -358,7 +360,7 @@ class Uri implements UriInterface */ public function getUserInfo() { - return $this->user . ($this->password ? ':' . $this->password : ''); + return $this->user . ($this->password !== '' ? ':' . $this->password : ''); } /** @@ -379,8 +381,8 @@ class Uri implements UriInterface { $clone = clone $this; $clone->user = $this->filterUserInfo($user); - if ($clone->user) { - $clone->password = $password ? $this->filterUserInfo($password) : ''; + if ('' !== $clone->user) { + $clone->password = !in_array($password, [null, ''], true) ? $this->filterUserInfo($password) : ''; } else { $clone->password = ''; } @@ -812,11 +814,11 @@ class Uri implements UriInterface $path = $basePath . '/' . ltrim($path, '/'); - return ($scheme ? $scheme . ':' : '') - . ($authority ? '//' . $authority : '') + return ($scheme !== '' ? $scheme . ':' : '') + . ($authority !== '' ? '//' . $authority : '') . $path - . ($query ? '?' . $query : '') - . ($fragment ? '#' . $fragment : ''); + . ($query !== '' ? '?' . $query : '') + . ($fragment !== '' ? '#' . $fragment : ''); } /** @@ -834,11 +836,11 @@ class Uri implements UriInterface $authority = $this->getAuthority(); $basePath = $this->getBasePath(); - if ($authority && substr($basePath, 0, 1) !== '/') { + if ($authority !== '' && substr($basePath, 0, 1) !== '/') { $basePath = $basePath . '/' . $basePath; } - return ($scheme ? $scheme . ':' : '') + return ($scheme !== '' ? $scheme . ':' : '') . ($authority ? '//' . $authority : '') . rtrim($basePath, '/'); } diff --git a/vendor/slim/slim/Slim/Interfaces/CallableResolverInterface.php b/vendor/slim/slim/Slim/Interfaces/CallableResolverInterface.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Interfaces/CollectionInterface.php b/vendor/slim/slim/Slim/Interfaces/CollectionInterface.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Interfaces/Http/CookiesInterface.php b/vendor/slim/slim/Slim/Interfaces/Http/CookiesInterface.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Interfaces/Http/EnvironmentInterface.php b/vendor/slim/slim/Slim/Interfaces/Http/EnvironmentInterface.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Interfaces/Http/HeadersInterface.php b/vendor/slim/slim/Slim/Interfaces/Http/HeadersInterface.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Interfaces/InvocationStrategyInterface.php b/vendor/slim/slim/Slim/Interfaces/InvocationStrategyInterface.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Interfaces/RouteGroupInterface.php b/vendor/slim/slim/Slim/Interfaces/RouteGroupInterface.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Interfaces/RouteInterface.php b/vendor/slim/slim/Slim/Interfaces/RouteInterface.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Interfaces/RouterInterface.php b/vendor/slim/slim/Slim/Interfaces/RouterInterface.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/MiddlewareAwareTrait.php b/vendor/slim/slim/Slim/MiddlewareAwareTrait.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Routable.php b/vendor/slim/slim/Slim/Routable.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Route.php b/vendor/slim/slim/Slim/Route.php old mode 100755 new mode 100644 index fa8be4e44688acbc2e62682c6565f06c1925030d..117c0998397492c8a296d24e92457af40364e9fd --- a/vendor/slim/slim/Slim/Route.php +++ b/vendor/slim/slim/Slim/Route.php @@ -68,6 +68,13 @@ class Route extends Routable implements RouteInterface */ protected $arguments = []; + /** + * Route arguments parameters + * + * @var null|array + */ + protected $savedArguments = []; + /** * The callable payload * @@ -193,6 +200,8 @@ class Route extends Routable implements RouteInterface * * @param boolean|string $mode * + * @return self + * * @throws InvalidArgumentException If an unknown buffering mode is specified */ public function setOutputBuffering($mode) @@ -201,6 +210,7 @@ class Route extends Routable implements RouteInterface throw new InvalidArgumentException('Unknown output buffering mode'); } $this->outputBuffering = $mode; + return $this; } /** @@ -226,11 +236,15 @@ class Route extends Routable implements RouteInterface * * @param string $name * @param string $value + * @param bool $includeInSavedArguments * * @return self */ - public function setArgument($name, $value) + public function setArgument($name, $value, $includeInSavedArguments = true) { + if ($includeInSavedArguments) { + $this->savedArguments[$name] = $value; + } $this->arguments[$name] = $value; return $this; } @@ -239,11 +253,15 @@ class Route extends Routable implements RouteInterface * Replace route arguments * * @param array $arguments + * @param bool $includeInSavedArguments * * @return self */ - public function setArguments(array $arguments) + public function setArguments(array $arguments, $includeInSavedArguments = true) { + if ($includeInSavedArguments) { + $this->savedArguments = $arguments; + } $this->arguments = $arguments; return $this; } @@ -286,9 +304,12 @@ class Route extends Routable implements RouteInterface */ public function prepare(ServerRequestInterface $request, array $arguments) { - // Add the arguments + // Remove temp arguments + $this->setArguments($this->savedArguments); + + // Add the route arguments foreach ($arguments as $k => $v) { - $this->setArgument($k, $v); + $this->setArgument($k, $v, false); } } diff --git a/vendor/slim/slim/Slim/RouteGroup.php b/vendor/slim/slim/Slim/RouteGroup.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/Slim/Router.php b/vendor/slim/slim/Slim/Router.php old mode 100755 new mode 100644 diff --git a/vendor/slim/slim/composer.json b/vendor/slim/slim/composer.json old mode 100755 new mode 100644 index 554a838a95d5d15008f1196743205a01c3922ab3..db3a11a974045159eba743ff7d1856668f6f023e --- a/vendor/slim/slim/composer.json +++ b/vendor/slim/slim/composer.json @@ -47,12 +47,15 @@ "Slim\\": "Slim" } }, + "autoload-dev": { + "files": [ + "tests/Assets/HeaderFunctions.php" + ] + }, "scripts": { "test": [ - "@phpunit", - "@phpcs" - ], - "phpunit": "php vendor/bin/phpunit", - "phpcs": "php vendor/bin/phpcs" + "phpunit", + "phpcs" + ] } } diff --git a/vendor/symfony/options-resolver/.gitignore b/vendor/symfony/options-resolver/.gitignore deleted file mode 100755 index c49a5d8df5c6548379f00c77fe572a7217bce218..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/vendor/symfony/options-resolver/CHANGELOG.md b/vendor/symfony/options-resolver/CHANGELOG.md deleted file mode 100755 index 6e9d49fb61d75997a3bcfa9177f3062fcd397247..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/CHANGELOG.md +++ /dev/null @@ -1,52 +0,0 @@ -CHANGELOG -========= - -3.4.0 ------ - - * added `OptionsResolverIntrospector` to inspect options definitions inside an `OptionsResolver` instance - * added array of types support in allowed types (e.g int[]) - -2.6.0 ------ - - * deprecated OptionsResolverInterface - * [BC BREAK] removed "array" type hint from OptionsResolverInterface methods - setRequired(), setAllowedValues(), addAllowedValues(), setAllowedTypes() and - addAllowedTypes() - * added OptionsResolver::setDefault() - * added OptionsResolver::hasDefault() - * added OptionsResolver::setNormalizer() - * added OptionsResolver::isRequired() - * added OptionsResolver::getRequiredOptions() - * added OptionsResolver::isMissing() - * added OptionsResolver::getMissingOptions() - * added OptionsResolver::setDefined() - * added OptionsResolver::isDefined() - * added OptionsResolver::getDefinedOptions() - * added OptionsResolver::remove() - * added OptionsResolver::clear() - * deprecated OptionsResolver::replaceDefaults() - * deprecated OptionsResolver::setOptional() in favor of setDefined() - * deprecated OptionsResolver::isKnown() in favor of isDefined() - * [BC BREAK] OptionsResolver::isRequired() returns true now if a required - option has a default value set - * [BC BREAK] merged Options into OptionsResolver and turned Options into an - interface - * deprecated Options::overload() (now in OptionsResolver) - * deprecated Options::set() (now in OptionsResolver) - * deprecated Options::get() (now in OptionsResolver) - * deprecated Options::has() (now in OptionsResolver) - * deprecated Options::replace() (now in OptionsResolver) - * [BC BREAK] Options::get() (now in OptionsResolver) can only be used within - lazy option/normalizer closures now - * [BC BREAK] removed Traversable interface from Options since using within - lazy option/normalizer closures resulted in exceptions - * [BC BREAK] removed Options::all() since using within lazy option/normalizer - closures resulted in exceptions - * [BC BREAK] OptionDefinitionException now extends LogicException instead of - RuntimeException - * [BC BREAK] normalizers are not executed anymore for unset options - * normalizers are executed after validating the options now - * [BC BREAK] an UndefinedOptionsException is now thrown instead of an - InvalidOptionsException when non-existing options are passed diff --git a/vendor/symfony/options-resolver/Debug/OptionsResolverIntrospector.php b/vendor/symfony/options-resolver/Debug/OptionsResolverIntrospector.php deleted file mode 100755 index 60317243e9c4f937e6f181f079c0eda0cdb1ef93..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/Debug/OptionsResolverIntrospector.php +++ /dev/null @@ -1,102 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\OptionsResolver\Debug; - -use Symfony\Component\OptionsResolver\Exception\NoConfigurationException; -use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * @author Maxime Steinhausser <maxime.steinhausser@gmail.com> - * - * @final - */ -class OptionsResolverIntrospector -{ - private $get; - - public function __construct(OptionsResolver $optionsResolver) - { - $this->get = \Closure::bind(function ($property, $option, $message) { - /** @var OptionsResolver $this */ - if (!$this->isDefined($option)) { - throw new UndefinedOptionsException(sprintf('The option "%s" does not exist.', $option)); - } - - if (!array_key_exists($option, $this->{$property})) { - throw new NoConfigurationException($message); - } - - return $this->{$property}[$option]; - }, $optionsResolver, $optionsResolver); - } - - /** - * @param string $option - * - * @return mixed - * - * @throws NoConfigurationException on no configured value - */ - public function getDefault($option) - { - return call_user_func($this->get, 'defaults', $option, sprintf('No default value was set for the "%s" option.', $option)); - } - - /** - * @param string $option - * - * @return \Closure[] - * - * @throws NoConfigurationException on no configured closures - */ - public function getLazyClosures($option) - { - return call_user_func($this->get, 'lazy', $option, sprintf('No lazy closures were set for the "%s" option.', $option)); - } - - /** - * @param string $option - * - * @return string[] - * - * @throws NoConfigurationException on no configured types - */ - public function getAllowedTypes($option) - { - return call_user_func($this->get, 'allowedTypes', $option, sprintf('No allowed types were set for the "%s" option.', $option)); - } - - /** - * @param string $option - * - * @return mixed[] - * - * @throws NoConfigurationException on no configured values - */ - public function getAllowedValues($option) - { - return call_user_func($this->get, 'allowedValues', $option, sprintf('No allowed values were set for the "%s" option.', $option)); - } - - /** - * @param string $option - * - * @return \Closure - * - * @throws NoConfigurationException on no configured normalizer - */ - public function getNormalizer($option) - { - return call_user_func($this->get, 'normalizers', $option, sprintf('No normalizer was set for the "%s" option.', $option)); - } -} diff --git a/vendor/symfony/options-resolver/Exception/AccessException.php b/vendor/symfony/options-resolver/Exception/AccessException.php deleted file mode 100755 index c12b6806456f0ae3d51b19f99c73bb0bb0c50c48..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/Exception/AccessException.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\OptionsResolver\Exception; - -/** - * Thrown when trying to read an option outside of or write it inside of - * {@link \Symfony\Component\OptionsResolver\Options::resolve()}. - * - * @author Bernhard Schussek <bschussek@gmail.com> - */ -class AccessException extends \LogicException implements ExceptionInterface -{ -} diff --git a/vendor/symfony/options-resolver/Exception/ExceptionInterface.php b/vendor/symfony/options-resolver/Exception/ExceptionInterface.php deleted file mode 100755 index b62bb51d465ba38aa7a2645abe9f5f2c984058d8..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/Exception/ExceptionInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\OptionsResolver\Exception; - -/** - * Marker interface for all exceptions thrown by the OptionsResolver component. - * - * @author Bernhard Schussek <bschussek@gmail.com> - */ -interface ExceptionInterface -{ -} diff --git a/vendor/symfony/options-resolver/Exception/InvalidArgumentException.php b/vendor/symfony/options-resolver/Exception/InvalidArgumentException.php deleted file mode 100755 index 6d421d68b35cb0f3b40749ccde74ebb14c2a6422..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/Exception/InvalidArgumentException.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\OptionsResolver\Exception; - -/** - * Thrown when an argument is invalid. - * - * @author Bernhard Schussek <bschussek@gmail.com> - */ -class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface -{ -} diff --git a/vendor/symfony/options-resolver/Exception/InvalidOptionsException.php b/vendor/symfony/options-resolver/Exception/InvalidOptionsException.php deleted file mode 100755 index 6fd4f125f4478b555847e28ede4a8c9cdbff5668..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/Exception/InvalidOptionsException.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\OptionsResolver\Exception; - -/** - * Thrown when the value of an option does not match its validation rules. - * - * You should make sure a valid value is passed to the option. - * - * @author Bernhard Schussek <bschussek@gmail.com> - */ -class InvalidOptionsException extends InvalidArgumentException -{ -} diff --git a/vendor/symfony/options-resolver/Exception/MissingOptionsException.php b/vendor/symfony/options-resolver/Exception/MissingOptionsException.php deleted file mode 100755 index faa487f16f003354de8c0f681f806d31b44f28c9..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/Exception/MissingOptionsException.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\OptionsResolver\Exception; - -/** - * Exception thrown when a required option is missing. - * - * Add the option to the passed options array. - * - * @author Bernhard Schussek <bschussek@gmail.com> - */ -class MissingOptionsException extends InvalidArgumentException -{ -} diff --git a/vendor/symfony/options-resolver/Exception/NoConfigurationException.php b/vendor/symfony/options-resolver/Exception/NoConfigurationException.php deleted file mode 100755 index 6693ec14df892d213865b404c6a3eb63e99cfb2e..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/Exception/NoConfigurationException.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\OptionsResolver\Exception; - -use Symfony\Component\OptionsResolver\Debug\OptionsResolverIntrospector; - -/** - * Thrown when trying to introspect an option definition property - * for which no value was configured inside the OptionsResolver instance. - * - * @see OptionsResolverIntrospector - * - * @author Maxime Steinhausser <maxime.steinhausser@gmail.com> - */ -class NoConfigurationException extends \RuntimeException implements ExceptionInterface -{ -} diff --git a/vendor/symfony/options-resolver/Exception/NoSuchOptionException.php b/vendor/symfony/options-resolver/Exception/NoSuchOptionException.php deleted file mode 100755 index 4c3280f4c7cac9a8069730ce19257b270a3de6a5..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/Exception/NoSuchOptionException.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\OptionsResolver\Exception; - -/** - * Thrown when trying to read an option that has no value set. - * - * When accessing optional options from within a lazy option or normalizer you should first - * check whether the optional option is set. You can do this with `isset($options['optional'])`. - * In contrast to the {@link UndefinedOptionsException}, this is a runtime exception that can - * occur when evaluating lazy options. - * - * @author Tobias Schultze <http://tobion.de> - */ -class NoSuchOptionException extends \OutOfBoundsException implements ExceptionInterface -{ -} diff --git a/vendor/symfony/options-resolver/Exception/OptionDefinitionException.php b/vendor/symfony/options-resolver/Exception/OptionDefinitionException.php deleted file mode 100755 index e8e339d446efa29e2e119af80f08624d1f49d8db..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/Exception/OptionDefinitionException.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\OptionsResolver\Exception; - -/** - * Thrown when two lazy options have a cyclic dependency. - * - * @author Bernhard Schussek <bschussek@gmail.com> - */ -class OptionDefinitionException extends \LogicException implements ExceptionInterface -{ -} diff --git a/vendor/symfony/options-resolver/Exception/UndefinedOptionsException.php b/vendor/symfony/options-resolver/Exception/UndefinedOptionsException.php deleted file mode 100755 index 6ca3fce470a609d98ad5acef72298ea7645cf0f3..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/Exception/UndefinedOptionsException.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\OptionsResolver\Exception; - -/** - * Exception thrown when an undefined option is passed. - * - * You should remove the options in question from your code or define them - * beforehand. - * - * @author Bernhard Schussek <bschussek@gmail.com> - */ -class UndefinedOptionsException extends InvalidArgumentException -{ -} diff --git a/vendor/symfony/options-resolver/LICENSE b/vendor/symfony/options-resolver/LICENSE deleted file mode 100755 index 21d7fb9e2f29b50caca3a76f0647e94e2cc8ddc1..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2018 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/symfony/options-resolver/Options.php b/vendor/symfony/options-resolver/Options.php deleted file mode 100755 index d444ec4230d51f9e672e5845b34355cc39b4146c..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/Options.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\OptionsResolver; - -/** - * Contains resolved option values. - * - * @author Bernhard Schussek <bschussek@gmail.com> - * @author Tobias Schultze <http://tobion.de> - */ -interface Options extends \ArrayAccess, \Countable -{ -} diff --git a/vendor/symfony/options-resolver/OptionsResolver.php b/vendor/symfony/options-resolver/OptionsResolver.php deleted file mode 100755 index a58f45c0a65888ecd7692afddc862674f17fa034..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/OptionsResolver.php +++ /dev/null @@ -1,1121 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\OptionsResolver; - -use Symfony\Component\OptionsResolver\Exception\AccessException; -use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; -use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; -use Symfony\Component\OptionsResolver\Exception\NoSuchOptionException; -use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; -use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; - -/** - * Validates options and merges them with default values. - * - * @author Bernhard Schussek <bschussek@gmail.com> - * @author Tobias Schultze <http://tobion.de> - */ -class OptionsResolver implements Options -{ - /** - * The names of all defined options. - */ - private $defined = array(); - - /** - * The default option values. - */ - private $defaults = array(); - - /** - * The names of required options. - */ - private $required = array(); - - /** - * The resolved option values. - */ - private $resolved = array(); - - /** - * A list of normalizer closures. - * - * @var \Closure[] - */ - private $normalizers = array(); - - /** - * A list of accepted values for each option. - */ - private $allowedValues = array(); - - /** - * A list of accepted types for each option. - */ - private $allowedTypes = array(); - - /** - * A list of closures for evaluating lazy options. - */ - private $lazy = array(); - - /** - * A list of lazy options whose closure is currently being called. - * - * This list helps detecting circular dependencies between lazy options. - */ - private $calling = array(); - - /** - * Whether the instance is locked for reading. - * - * Once locked, the options cannot be changed anymore. This is - * necessary in order to avoid inconsistencies during the resolving - * process. If any option is changed after being read, all evaluated - * lazy options that depend on this option would become invalid. - */ - private $locked = false; - - private static $typeAliases = array( - 'boolean' => 'bool', - 'integer' => 'int', - 'double' => 'float', - ); - - /** - * Sets the default value of a given option. - * - * If the default value should be set based on other options, you can pass - * a closure with the following signature: - * - * function (Options $options) { - * // ... - * } - * - * The closure will be evaluated when {@link resolve()} is called. The - * closure has access to the resolved values of other options through the - * passed {@link Options} instance: - * - * function (Options $options) { - * if (isset($options['port'])) { - * // ... - * } - * } - * - * If you want to access the previously set default value, add a second - * argument to the closure's signature: - * - * $options->setDefault('name', 'Default Name'); - * - * $options->setDefault('name', function (Options $options, $previousValue) { - * // 'Default Name' === $previousValue - * }); - * - * This is mostly useful if the configuration of the {@link Options} object - * is spread across different locations of your code, such as base and - * sub-classes. - * - * @param string $option The name of the option - * @param mixed $value The default value of the option - * - * @return $this - * - * @throws AccessException If called from a lazy option or normalizer - */ - public function setDefault($option, $value) - { - // Setting is not possible once resolving starts, because then lazy - // options could manipulate the state of the object, leading to - // inconsistent results. - if ($this->locked) { - throw new AccessException('Default values cannot be set from a lazy option or normalizer.'); - } - - // If an option is a closure that should be evaluated lazily, store it - // in the "lazy" property. - if ($value instanceof \Closure) { - $reflClosure = new \ReflectionFunction($value); - $params = $reflClosure->getParameters(); - - if (isset($params[0]) && null !== ($class = $params[0]->getClass()) && Options::class === $class->name) { - // Initialize the option if no previous value exists - if (!isset($this->defaults[$option])) { - $this->defaults[$option] = null; - } - - // Ignore previous lazy options if the closure has no second parameter - if (!isset($this->lazy[$option]) || !isset($params[1])) { - $this->lazy[$option] = array(); - } - - // Store closure for later evaluation - $this->lazy[$option][] = $value; - $this->defined[$option] = true; - - // Make sure the option is processed - unset($this->resolved[$option]); - - return $this; - } - } - - // This option is not lazy anymore - unset($this->lazy[$option]); - - // Yet undefined options can be marked as resolved, because we only need - // to resolve options with lazy closures, normalizers or validation - // rules, none of which can exist for undefined options - // If the option was resolved before, update the resolved value - if (!isset($this->defined[$option]) || array_key_exists($option, $this->resolved)) { - $this->resolved[$option] = $value; - } - - $this->defaults[$option] = $value; - $this->defined[$option] = true; - - return $this; - } - - /** - * Sets a list of default values. - * - * @param array $defaults The default values to set - * - * @return $this - * - * @throws AccessException If called from a lazy option or normalizer - */ - public function setDefaults(array $defaults) - { - foreach ($defaults as $option => $value) { - $this->setDefault($option, $value); - } - - return $this; - } - - /** - * Returns whether a default value is set for an option. - * - * Returns true if {@link setDefault()} was called for this option. - * An option is also considered set if it was set to null. - * - * @param string $option The option name - * - * @return bool Whether a default value is set - */ - public function hasDefault($option) - { - return array_key_exists($option, $this->defaults); - } - - /** - * Marks one or more options as required. - * - * @param string|string[] $optionNames One or more option names - * - * @return $this - * - * @throws AccessException If called from a lazy option or normalizer - */ - public function setRequired($optionNames) - { - if ($this->locked) { - throw new AccessException('Options cannot be made required from a lazy option or normalizer.'); - } - - foreach ((array) $optionNames as $option) { - $this->defined[$option] = true; - $this->required[$option] = true; - } - - return $this; - } - - /** - * Returns whether an option is required. - * - * An option is required if it was passed to {@link setRequired()}. - * - * @param string $option The name of the option - * - * @return bool Whether the option is required - */ - public function isRequired($option) - { - return isset($this->required[$option]); - } - - /** - * Returns the names of all required options. - * - * @return string[] The names of the required options - * - * @see isRequired() - */ - public function getRequiredOptions() - { - return array_keys($this->required); - } - - /** - * Returns whether an option is missing a default value. - * - * An option is missing if it was passed to {@link setRequired()}, but not - * to {@link setDefault()}. This option must be passed explicitly to - * {@link resolve()}, otherwise an exception will be thrown. - * - * @param string $option The name of the option - * - * @return bool Whether the option is missing - */ - public function isMissing($option) - { - return isset($this->required[$option]) && !array_key_exists($option, $this->defaults); - } - - /** - * Returns the names of all options missing a default value. - * - * @return string[] The names of the missing options - * - * @see isMissing() - */ - public function getMissingOptions() - { - return array_keys(array_diff_key($this->required, $this->defaults)); - } - - /** - * Defines a valid option name. - * - * Defines an option name without setting a default value. The option will - * be accepted when passed to {@link resolve()}. When not passed, the - * option will not be included in the resolved options. - * - * @param string|string[] $optionNames One or more option names - * - * @return $this - * - * @throws AccessException If called from a lazy option or normalizer - */ - public function setDefined($optionNames) - { - if ($this->locked) { - throw new AccessException('Options cannot be defined from a lazy option or normalizer.'); - } - - foreach ((array) $optionNames as $option) { - $this->defined[$option] = true; - } - - return $this; - } - - /** - * Returns whether an option is defined. - * - * Returns true for any option passed to {@link setDefault()}, - * {@link setRequired()} or {@link setDefined()}. - * - * @param string $option The option name - * - * @return bool Whether the option is defined - */ - public function isDefined($option) - { - return isset($this->defined[$option]); - } - - /** - * Returns the names of all defined options. - * - * @return string[] The names of the defined options - * - * @see isDefined() - */ - public function getDefinedOptions() - { - return array_keys($this->defined); - } - - /** - * Sets the normalizer for an option. - * - * The normalizer should be a closure with the following signature: - * - * ```php - * function (Options $options, $value) { - * // ... - * } - * ``` - * - * The closure is invoked when {@link resolve()} is called. The closure - * has access to the resolved values of other options through the passed - * {@link Options} instance. - * - * The second parameter passed to the closure is the value of - * the option. - * - * The resolved option value is set to the return value of the closure. - * - * @param string $option The option name - * @param \Closure $normalizer The normalizer - * - * @return $this - * - * @throws UndefinedOptionsException If the option is undefined - * @throws AccessException If called from a lazy option or normalizer - */ - public function setNormalizer($option, \Closure $normalizer) - { - if ($this->locked) { - throw new AccessException('Normalizers cannot be set from a lazy option or normalizer.'); - } - - if (!isset($this->defined[$option])) { - throw new UndefinedOptionsException(sprintf( - 'The option "%s" does not exist. Defined options are: "%s".', - $option, - implode('", "', array_keys($this->defined)) - )); - } - - $this->normalizers[$option] = $normalizer; - - // Make sure the option is processed - unset($this->resolved[$option]); - - return $this; - } - - /** - * Sets allowed values for an option. - * - * Instead of passing values, you may also pass a closures with the - * following signature: - * - * function ($value) { - * // return true or false - * } - * - * The closure receives the value as argument and should return true to - * accept the value and false to reject the value. - * - * @param string $option The option name - * @param mixed $allowedValues One or more acceptable values/closures - * - * @return $this - * - * @throws UndefinedOptionsException If the option is undefined - * @throws AccessException If called from a lazy option or normalizer - */ - public function setAllowedValues($option, $allowedValues) - { - if ($this->locked) { - throw new AccessException('Allowed values cannot be set from a lazy option or normalizer.'); - } - - if (!isset($this->defined[$option])) { - throw new UndefinedOptionsException(sprintf( - 'The option "%s" does not exist. Defined options are: "%s".', - $option, - implode('", "', array_keys($this->defined)) - )); - } - - $this->allowedValues[$option] = \is_array($allowedValues) ? $allowedValues : array($allowedValues); - - // Make sure the option is processed - unset($this->resolved[$option]); - - return $this; - } - - /** - * Adds allowed values for an option. - * - * The values are merged with the allowed values defined previously. - * - * Instead of passing values, you may also pass a closures with the - * following signature: - * - * function ($value) { - * // return true or false - * } - * - * The closure receives the value as argument and should return true to - * accept the value and false to reject the value. - * - * @param string $option The option name - * @param mixed $allowedValues One or more acceptable values/closures - * - * @return $this - * - * @throws UndefinedOptionsException If the option is undefined - * @throws AccessException If called from a lazy option or normalizer - */ - public function addAllowedValues($option, $allowedValues) - { - if ($this->locked) { - throw new AccessException('Allowed values cannot be added from a lazy option or normalizer.'); - } - - if (!isset($this->defined[$option])) { - throw new UndefinedOptionsException(sprintf( - 'The option "%s" does not exist. Defined options are: "%s".', - $option, - implode('", "', array_keys($this->defined)) - )); - } - - if (!is_array($allowedValues)) { - $allowedValues = array($allowedValues); - } - - if (!isset($this->allowedValues[$option])) { - $this->allowedValues[$option] = $allowedValues; - } else { - $this->allowedValues[$option] = array_merge($this->allowedValues[$option], $allowedValues); - } - - // Make sure the option is processed - unset($this->resolved[$option]); - - return $this; - } - - /** - * Sets allowed types for an option. - * - * Any type for which a corresponding is_<type>() function exists is - * acceptable. Additionally, fully-qualified class or interface names may - * be passed. - * - * @param string $option The option name - * @param string|string[] $allowedTypes One or more accepted types - * - * @return $this - * - * @throws UndefinedOptionsException If the option is undefined - * @throws AccessException If called from a lazy option or normalizer - */ - public function setAllowedTypes($option, $allowedTypes) - { - if ($this->locked) { - throw new AccessException('Allowed types cannot be set from a lazy option or normalizer.'); - } - - if (!isset($this->defined[$option])) { - throw new UndefinedOptionsException(sprintf( - 'The option "%s" does not exist. Defined options are: "%s".', - $option, - implode('", "', array_keys($this->defined)) - )); - } - - $this->allowedTypes[$option] = (array) $allowedTypes; - - // Make sure the option is processed - unset($this->resolved[$option]); - - return $this; - } - - /** - * Adds allowed types for an option. - * - * The types are merged with the allowed types defined previously. - * - * Any type for which a corresponding is_<type>() function exists is - * acceptable. Additionally, fully-qualified class or interface names may - * be passed. - * - * @param string $option The option name - * @param string|string[] $allowedTypes One or more accepted types - * - * @return $this - * - * @throws UndefinedOptionsException If the option is undefined - * @throws AccessException If called from a lazy option or normalizer - */ - public function addAllowedTypes($option, $allowedTypes) - { - if ($this->locked) { - throw new AccessException('Allowed types cannot be added from a lazy option or normalizer.'); - } - - if (!isset($this->defined[$option])) { - throw new UndefinedOptionsException(sprintf( - 'The option "%s" does not exist. Defined options are: "%s".', - $option, - implode('", "', array_keys($this->defined)) - )); - } - - if (!isset($this->allowedTypes[$option])) { - $this->allowedTypes[$option] = (array) $allowedTypes; - } else { - $this->allowedTypes[$option] = array_merge($this->allowedTypes[$option], (array) $allowedTypes); - } - - // Make sure the option is processed - unset($this->resolved[$option]); - - return $this; - } - - /** - * Removes the option with the given name. - * - * Undefined options are ignored. - * - * @param string|string[] $optionNames One or more option names - * - * @return $this - * - * @throws AccessException If called from a lazy option or normalizer - */ - public function remove($optionNames) - { - if ($this->locked) { - throw new AccessException('Options cannot be removed from a lazy option or normalizer.'); - } - - foreach ((array) $optionNames as $option) { - unset($this->defined[$option], $this->defaults[$option], $this->required[$option], $this->resolved[$option]); - unset($this->lazy[$option], $this->normalizers[$option], $this->allowedTypes[$option], $this->allowedValues[$option]); - } - - return $this; - } - - /** - * Removes all options. - * - * @return $this - * - * @throws AccessException If called from a lazy option or normalizer - */ - public function clear() - { - if ($this->locked) { - throw new AccessException('Options cannot be cleared from a lazy option or normalizer.'); - } - - $this->defined = array(); - $this->defaults = array(); - $this->required = array(); - $this->resolved = array(); - $this->lazy = array(); - $this->normalizers = array(); - $this->allowedTypes = array(); - $this->allowedValues = array(); - - return $this; - } - - /** - * Merges options with the default values stored in the container and - * validates them. - * - * Exceptions are thrown if: - * - * - Undefined options are passed; - * - Required options are missing; - * - Options have invalid types; - * - Options have invalid values. - * - * @param array $options A map of option names to values - * - * @return array The merged and validated options - * - * @throws UndefinedOptionsException If an option name is undefined - * @throws InvalidOptionsException If an option doesn't fulfill the - * specified validation rules - * @throws MissingOptionsException If a required option is missing - * @throws OptionDefinitionException If there is a cyclic dependency between - * lazy options and/or normalizers - * @throws NoSuchOptionException If a lazy option reads an unavailable option - * @throws AccessException If called from a lazy option or normalizer - */ - public function resolve(array $options = array()) - { - if ($this->locked) { - throw new AccessException('Options cannot be resolved from a lazy option or normalizer.'); - } - - // Allow this method to be called multiple times - $clone = clone $this; - - // Make sure that no unknown options are passed - $diff = array_diff_key($options, $clone->defined); - - if (count($diff) > 0) { - ksort($clone->defined); - ksort($diff); - - throw new UndefinedOptionsException(sprintf( - (count($diff) > 1 ? 'The options "%s" do not exist.' : 'The option "%s" does not exist.').' Defined options are: "%s".', - implode('", "', array_keys($diff)), - implode('", "', array_keys($clone->defined)) - )); - } - - // Override options set by the user - foreach ($options as $option => $value) { - $clone->defaults[$option] = $value; - unset($clone->resolved[$option], $clone->lazy[$option]); - } - - // Check whether any required option is missing - $diff = array_diff_key($clone->required, $clone->defaults); - - if (count($diff) > 0) { - ksort($diff); - - throw new MissingOptionsException(sprintf( - count($diff) > 1 ? 'The required options "%s" are missing.' : 'The required option "%s" is missing.', - implode('", "', array_keys($diff)) - )); - } - - // Lock the container - $clone->locked = true; - - // Now process the individual options. Use offsetGet(), which resolves - // the option itself and any options that the option depends on - foreach ($clone->defaults as $option => $_) { - $clone->offsetGet($option); - } - - return $clone->resolved; - } - - /** - * Returns the resolved value of an option. - * - * @param string $option The option name - * - * @return mixed The option value - * - * @throws AccessException If accessing this method outside of - * {@link resolve()} - * @throws NoSuchOptionException If the option is not set - * @throws InvalidOptionsException If the option doesn't fulfill the - * specified validation rules - * @throws OptionDefinitionException If there is a cyclic dependency between - * lazy options and/or normalizers - */ - public function offsetGet($option) - { - if (!$this->locked) { - throw new AccessException('Array access is only supported within closures of lazy options and normalizers.'); - } - - // Shortcut for resolved options - if (array_key_exists($option, $this->resolved)) { - return $this->resolved[$option]; - } - - // Check whether the option is set at all - if (!array_key_exists($option, $this->defaults)) { - if (!isset($this->defined[$option])) { - throw new NoSuchOptionException(sprintf( - 'The option "%s" does not exist. Defined options are: "%s".', - $option, - implode('", "', array_keys($this->defined)) - )); - } - - throw new NoSuchOptionException(sprintf( - 'The optional option "%s" has no value set. You should make sure it is set with "isset" before reading it.', - $option - )); - } - - $value = $this->defaults[$option]; - - // Resolve the option if the default value is lazily evaluated - if (isset($this->lazy[$option])) { - // If the closure is already being called, we have a cyclic - // dependency - if (isset($this->calling[$option])) { - throw new OptionDefinitionException(sprintf( - 'The options "%s" have a cyclic dependency.', - implode('", "', array_keys($this->calling)) - )); - } - - // The following section must be protected from cyclic - // calls. Set $calling for the current $option to detect a cyclic - // dependency - // BEGIN - $this->calling[$option] = true; - try { - foreach ($this->lazy[$option] as $closure) { - $value = $closure($this, $value); - } - } finally { - unset($this->calling[$option]); - } - // END - } - - // Validate the type of the resolved option - if (isset($this->allowedTypes[$option])) { - $valid = false; - $invalidTypes = array(); - - foreach ($this->allowedTypes[$option] as $type) { - $type = isset(self::$typeAliases[$type]) ? self::$typeAliases[$type] : $type; - - if ($valid = $this->verifyTypes($type, $value, $invalidTypes)) { - break; - } - } - - if (!$valid) { - $keys = array_keys($invalidTypes); - - if (1 === \count($keys) && '[]' === substr($keys[0], -2)) { - throw new InvalidOptionsException(sprintf('The option "%s" with value %s is expected to be of type "%s", but one of the elements is of type "%s".', $option, $this->formatValue($value), implode('" or "', $this->allowedTypes[$option]), $keys[0])); - } - - throw new InvalidOptionsException(sprintf('The option "%s" with value %s is expected to be of type "%s", but is of type "%s".', $option, $this->formatValue($value), implode('" or "', $this->allowedTypes[$option]), implode('|', array_keys($invalidTypes)))); - } - } - - // Validate the value of the resolved option - if (isset($this->allowedValues[$option])) { - $success = false; - $printableAllowedValues = array(); - - foreach ($this->allowedValues[$option] as $allowedValue) { - if ($allowedValue instanceof \Closure) { - if ($allowedValue($value)) { - $success = true; - break; - } - - // Don't include closures in the exception message - continue; - } elseif ($value === $allowedValue) { - $success = true; - break; - } - - $printableAllowedValues[] = $allowedValue; - } - - if (!$success) { - $message = sprintf( - 'The option "%s" with value %s is invalid.', - $option, - $this->formatValue($value) - ); - - if (count($printableAllowedValues) > 0) { - $message .= sprintf( - ' Accepted values are: %s.', - $this->formatValues($printableAllowedValues) - ); - } - - throw new InvalidOptionsException($message); - } - } - - // Normalize the validated option - if (isset($this->normalizers[$option])) { - // If the closure is already being called, we have a cyclic - // dependency - if (isset($this->calling[$option])) { - throw new OptionDefinitionException(sprintf( - 'The options "%s" have a cyclic dependency.', - implode('", "', array_keys($this->calling)) - )); - } - - $normalizer = $this->normalizers[$option]; - - // The following section must be protected from cyclic - // calls. Set $calling for the current $option to detect a cyclic - // dependency - // BEGIN - $this->calling[$option] = true; - try { - $value = $normalizer($this, $value); - } finally { - unset($this->calling[$option]); - } - // END - } - - // Mark as resolved - $this->resolved[$option] = $value; - - return $value; - } - - /** - * @param string $type - * @param mixed $value - * @param array &$invalidTypes - * - * @return bool - */ - private function verifyTypes($type, $value, array &$invalidTypes) - { - if (\is_array($value) && '[]' === substr($type, -2)) { - return $this->verifyArrayType($type, $value, $invalidTypes); - } - - if (self::isValueValidType($type, $value)) { - return true; - } - - if (!$invalidTypes) { - $invalidTypes[$this->formatTypeOf($value, null)] = true; - } - - return false; - } - - /** - * @return bool - */ - private function verifyArrayType($type, array $value, array &$invalidTypes, $level = 0) - { - $type = substr($type, 0, -2); - - $suffix = '[]'; - while (\strlen($suffix) <= $level * 2) { - $suffix .= '[]'; - } - - if ('[]' === substr($type, -2)) { - $success = true; - foreach ($value as $item) { - if (!\is_array($item)) { - $invalidTypes[$this->formatTypeOf($item, null).$suffix] = true; - - return false; - } - - if (!$this->verifyArrayType($type, $item, $invalidTypes, $level + 1)) { - $success = false; - } - } - - return $success; - } - - foreach ($value as $item) { - if (!self::isValueValidType($type, $item)) { - $invalidTypes[$this->formatTypeOf($item, $type).$suffix] = $value; - - return false; - } - } - - return true; - } - - /** - * Returns whether a resolved option with the given name exists. - * - * @param string $option The option name - * - * @return bool Whether the option is set - * - * @throws AccessException If accessing this method outside of {@link resolve()} - * - * @see \ArrayAccess::offsetExists() - */ - public function offsetExists($option) - { - if (!$this->locked) { - throw new AccessException('Array access is only supported within closures of lazy options and normalizers.'); - } - - return array_key_exists($option, $this->defaults); - } - - /** - * Not supported. - * - * @throws AccessException - */ - public function offsetSet($option, $value) - { - throw new AccessException('Setting options via array access is not supported. Use setDefault() instead.'); - } - - /** - * Not supported. - * - * @throws AccessException - */ - public function offsetUnset($option) - { - throw new AccessException('Removing options via array access is not supported. Use remove() instead.'); - } - - /** - * Returns the number of set options. - * - * This may be only a subset of the defined options. - * - * @return int Number of options - * - * @throws AccessException If accessing this method outside of {@link resolve()} - * - * @see \Countable::count() - */ - public function count() - { - if (!$this->locked) { - throw new AccessException('Counting is only supported within closures of lazy options and normalizers.'); - } - - return count($this->defaults); - } - - /** - * Returns a string representation of the type of the value. - * - * This method should be used if you pass the type of a value as - * message parameter to a constraint violation. Note that such - * parameters should usually not be included in messages aimed at - * non-technical people. - * - * @param mixed $value The value to return the type of - * @param string $type - * - * @return string The type of the value - */ - private function formatTypeOf($value, $type) - { - $suffix = ''; - - if ('[]' === substr($type, -2)) { - $suffix = '[]'; - $type = substr($type, 0, -2); - while ('[]' === substr($type, -2)) { - $type = substr($type, 0, -2); - $value = array_shift($value); - if (!\is_array($value)) { - break; - } - $suffix .= '[]'; - } - - if (\is_array($value)) { - $subTypes = array(); - foreach ($value as $val) { - $subTypes[$this->formatTypeOf($val, null)] = true; - } - - return implode('|', array_keys($subTypes)).$suffix; - } - } - - return (\is_object($value) ? get_class($value) : gettype($value)).$suffix; - } - - /** - * Returns a string representation of the value. - * - * This method returns the equivalent PHP tokens for most scalar types - * (i.e. "false" for false, "1" for 1 etc.). Strings are always wrapped - * in double quotes ("). - * - * @param mixed $value The value to format as string - * - * @return string The string representation of the passed value - */ - private function formatValue($value) - { - if (\is_object($value)) { - return get_class($value); - } - - if (\is_array($value)) { - return 'array'; - } - - if (\is_string($value)) { - return '"'.$value.'"'; - } - - if (\is_resource($value)) { - return 'resource'; - } - - if (null === $value) { - return 'null'; - } - - if (false === $value) { - return 'false'; - } - - if (true === $value) { - return 'true'; - } - - return (string) $value; - } - - /** - * Returns a string representation of a list of values. - * - * Each of the values is converted to a string using - * {@link formatValue()}. The values are then concatenated with commas. - * - * @param array $values A list of values - * - * @return string The string representation of the value list - * - * @see formatValue() - */ - private function formatValues(array $values) - { - foreach ($values as $key => $value) { - $values[$key] = $this->formatValue($value); - } - - return implode(', ', $values); - } - - private static function isValueValidType($type, $value) - { - return (function_exists($isFunction = 'is_'.$type) && $isFunction($value)) || $value instanceof $type; - } - - /** - * @return array - */ - private function getInvalidValues(array $arrayValues, $type) - { - $invalidValues = array(); - - foreach ($arrayValues as $key => $value) { - if (!self::isValueValidType($type, $value)) { - $invalidValues[$key] = $value; - } - } - - return $invalidValues; - } -} diff --git a/vendor/symfony/options-resolver/README.md b/vendor/symfony/options-resolver/README.md deleted file mode 100755 index 245e69b548d6d62251f075d51eab8e657c1ab054..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/README.md +++ /dev/null @@ -1,15 +0,0 @@ -OptionsResolver Component -========================= - -The OptionsResolver component is `array_replace` on steroids. It allows you to -create an options system with required options, defaults, validation (type, -value), normalization and more. - -Resources ---------- - - * [Documentation](https://symfony.com/doc/current/components/options_resolver.html) - * [Contributing](https://symfony.com/doc/current/contributing/index.html) - * [Report issues](https://github.com/symfony/symfony/issues) and - [send Pull Requests](https://github.com/symfony/symfony/pulls) - in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/vendor/symfony/options-resolver/Tests/Debug/OptionsResolverIntrospectorTest.php b/vendor/symfony/options-resolver/Tests/Debug/OptionsResolverIntrospectorTest.php deleted file mode 100755 index 7c4753ab5f6b4f07168c35c26c1061e9a5ea8540..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/Tests/Debug/OptionsResolverIntrospectorTest.php +++ /dev/null @@ -1,203 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\OptionsResolver\Tests\Debug; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\OptionsResolver\Debug\OptionsResolverIntrospector; -use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolver; - -class OptionsResolverIntrospectorTest extends TestCase -{ - public function testGetDefault() - { - $resolver = new OptionsResolver(); - $resolver->setDefault($option = 'foo', 'bar'); - - $debug = new OptionsResolverIntrospector($resolver); - $this->assertSame('bar', $debug->getDefault($option)); - } - - public function testGetDefaultNull() - { - $resolver = new OptionsResolver(); - $resolver->setDefault($option = 'foo', null); - - $debug = new OptionsResolverIntrospector($resolver); - $this->assertNull($debug->getDefault($option)); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException - * @expectedExceptionMessage No default value was set for the "foo" option. - */ - public function testGetDefaultThrowsOnNoConfiguredValue() - { - $resolver = new OptionsResolver(); - $resolver->setDefined($option = 'foo'); - - $debug = new OptionsResolverIntrospector($resolver); - $this->assertSame('bar', $debug->getDefault($option)); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException - * @expectedExceptionMessage The option "foo" does not exist. - */ - public function testGetDefaultThrowsOnNotDefinedOption() - { - $resolver = new OptionsResolver(); - - $debug = new OptionsResolverIntrospector($resolver); - $this->assertSame('bar', $debug->getDefault('foo')); - } - - public function testGetLazyClosures() - { - $resolver = new OptionsResolver(); - $closures = array(); - $resolver->setDefault($option = 'foo', $closures[] = function (Options $options) {}); - - $debug = new OptionsResolverIntrospector($resolver); - $this->assertSame($closures, $debug->getLazyClosures($option)); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException - * @expectedExceptionMessage No lazy closures were set for the "foo" option. - */ - public function testGetLazyClosuresThrowsOnNoConfiguredValue() - { - $resolver = new OptionsResolver(); - $resolver->setDefined($option = 'foo'); - - $debug = new OptionsResolverIntrospector($resolver); - $this->assertSame('bar', $debug->getLazyClosures($option)); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException - * @expectedExceptionMessage The option "foo" does not exist. - */ - public function testGetLazyClosuresThrowsOnNotDefinedOption() - { - $resolver = new OptionsResolver(); - - $debug = new OptionsResolverIntrospector($resolver); - $this->assertSame('bar', $debug->getLazyClosures('foo')); - } - - public function testGetAllowedTypes() - { - $resolver = new OptionsResolver(); - $resolver->setDefined($option = 'foo'); - $resolver->setAllowedTypes($option = 'foo', $allowedTypes = array('string', 'bool')); - - $debug = new OptionsResolverIntrospector($resolver); - $this->assertSame($allowedTypes, $debug->getAllowedTypes($option)); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException - * @expectedExceptionMessage No allowed types were set for the "foo" option. - */ - public function testGetAllowedTypesThrowsOnNoConfiguredValue() - { - $resolver = new OptionsResolver(); - $resolver->setDefined($option = 'foo'); - - $debug = new OptionsResolverIntrospector($resolver); - $this->assertSame('bar', $debug->getAllowedTypes($option)); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException - * @expectedExceptionMessage The option "foo" does not exist. - */ - public function testGetAllowedTypesThrowsOnNotDefinedOption() - { - $resolver = new OptionsResolver(); - - $debug = new OptionsResolverIntrospector($resolver); - $this->assertSame('bar', $debug->getAllowedTypes('foo')); - } - - public function testGetAllowedValues() - { - $resolver = new OptionsResolver(); - $resolver->setDefined($option = 'foo'); - $resolver->setAllowedValues($option = 'foo', $allowedValues = array('bar', 'baz')); - - $debug = new OptionsResolverIntrospector($resolver); - $this->assertSame($allowedValues, $debug->getAllowedValues($option)); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException - * @expectedExceptionMessage No allowed values were set for the "foo" option. - */ - public function testGetAllowedValuesThrowsOnNoConfiguredValue() - { - $resolver = new OptionsResolver(); - $resolver->setDefined($option = 'foo'); - - $debug = new OptionsResolverIntrospector($resolver); - $this->assertSame('bar', $debug->getAllowedValues($option)); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException - * @expectedExceptionMessage The option "foo" does not exist. - */ - public function testGetAllowedValuesThrowsOnNotDefinedOption() - { - $resolver = new OptionsResolver(); - - $debug = new OptionsResolverIntrospector($resolver); - $this->assertSame('bar', $debug->getAllowedValues('foo')); - } - - public function testGetNormalizer() - { - $resolver = new OptionsResolver(); - $resolver->setDefined($option = 'foo'); - $resolver->setNormalizer($option = 'foo', $normalizer = function () {}); - - $debug = new OptionsResolverIntrospector($resolver); - $this->assertSame($normalizer, $debug->getNormalizer($option)); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException - * @expectedExceptionMessage No normalizer was set for the "foo" option. - */ - public function testGetNormalizerThrowsOnNoConfiguredValue() - { - $resolver = new OptionsResolver(); - $resolver->setDefined($option = 'foo'); - - $debug = new OptionsResolverIntrospector($resolver); - $this->assertSame('bar', $debug->getNormalizer($option)); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException - * @expectedExceptionMessage The option "foo" does not exist. - */ - public function testGetNormalizerThrowsOnNotDefinedOption() - { - $resolver = new OptionsResolver(); - - $debug = new OptionsResolverIntrospector($resolver); - $this->assertSame('bar', $debug->getNormalizer('foo')); - } -} diff --git a/vendor/symfony/options-resolver/Tests/OptionsResolverTest.php b/vendor/symfony/options-resolver/Tests/OptionsResolverTest.php deleted file mode 100755 index ac129844476042b609648f551b7b7019b47b1cec..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/Tests/OptionsResolverTest.php +++ /dev/null @@ -1,1736 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\OptionsResolver\Tests; - -use PHPUnit\Framework\Assert; -use PHPUnit\Framework\TestCase; -use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; -use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolver; - -class OptionsResolverTest extends TestCase -{ - /** - * @var OptionsResolver - */ - private $resolver; - - protected function setUp() - { - $this->resolver = new OptionsResolver(); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException - * @expectedExceptionMessage The option "foo" does not exist. Defined options are: "a", "z". - */ - public function testResolveFailsIfNonExistingOption() - { - $this->resolver->setDefault('z', '1'); - $this->resolver->setDefault('a', '2'); - - $this->resolver->resolve(array('foo' => 'bar')); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException - * @expectedExceptionMessage The options "baz", "foo", "ping" do not exist. Defined options are: "a", "z". - */ - public function testResolveFailsIfMultipleNonExistingOptions() - { - $this->resolver->setDefault('z', '1'); - $this->resolver->setDefault('a', '2'); - - $this->resolver->resolve(array('ping' => 'pong', 'foo' => 'bar', 'baz' => 'bam')); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testResolveFailsFromLazyOption() - { - $this->resolver->setDefault('foo', function (Options $options) { - $options->resolve(array()); - }); - - $this->resolver->resolve(); - } - - public function testSetDefaultReturnsThis() - { - $this->assertSame($this->resolver, $this->resolver->setDefault('foo', 'bar')); - } - - public function testSetDefault() - { - $this->resolver->setDefault('one', '1'); - $this->resolver->setDefault('two', '20'); - - $this->assertEquals(array( - 'one' => '1', - 'two' => '20', - ), $this->resolver->resolve()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testFailIfSetDefaultFromLazyOption() - { - $this->resolver->setDefault('lazy', function (Options $options) { - $options->setDefault('default', 42); - }); - - $this->resolver->resolve(); - } - - public function testHasDefault() - { - $this->assertFalse($this->resolver->hasDefault('foo')); - $this->resolver->setDefault('foo', 42); - $this->assertTrue($this->resolver->hasDefault('foo')); - } - - public function testHasDefaultWithNullValue() - { - $this->assertFalse($this->resolver->hasDefault('foo')); - $this->resolver->setDefault('foo', null); - $this->assertTrue($this->resolver->hasDefault('foo')); - } - - public function testSetLazyReturnsThis() - { - $this->assertSame($this->resolver, $this->resolver->setDefault('foo', function (Options $options) {})); - } - - public function testSetLazyClosure() - { - $this->resolver->setDefault('foo', function (Options $options) { - return 'lazy'; - }); - - $this->assertEquals(array('foo' => 'lazy'), $this->resolver->resolve()); - } - - public function testClosureWithoutTypeHintNotInvoked() - { - $closure = function ($options) { - Assert::fail('Should not be called'); - }; - - $this->resolver->setDefault('foo', $closure); - - $this->assertSame(array('foo' => $closure), $this->resolver->resolve()); - } - - public function testClosureWithoutParametersNotInvoked() - { - $closure = function () { - Assert::fail('Should not be called'); - }; - - $this->resolver->setDefault('foo', $closure); - - $this->assertSame(array('foo' => $closure), $this->resolver->resolve()); - } - - public function testAccessPreviousDefaultValue() - { - // defined by superclass - $this->resolver->setDefault('foo', 'bar'); - - // defined by subclass - $this->resolver->setDefault('foo', function (Options $options, $previousValue) { - Assert::assertEquals('bar', $previousValue); - - return 'lazy'; - }); - - $this->assertEquals(array('foo' => 'lazy'), $this->resolver->resolve()); - } - - public function testAccessPreviousLazyDefaultValue() - { - // defined by superclass - $this->resolver->setDefault('foo', function (Options $options) { - return 'bar'; - }); - - // defined by subclass - $this->resolver->setDefault('foo', function (Options $options, $previousValue) { - Assert::assertEquals('bar', $previousValue); - - return 'lazy'; - }); - - $this->assertEquals(array('foo' => 'lazy'), $this->resolver->resolve()); - } - - public function testPreviousValueIsNotEvaluatedIfNoSecondArgument() - { - // defined by superclass - $this->resolver->setDefault('foo', function () { - Assert::fail('Should not be called'); - }); - - // defined by subclass, no $previousValue argument defined! - $this->resolver->setDefault('foo', function (Options $options) { - return 'lazy'; - }); - - $this->assertEquals(array('foo' => 'lazy'), $this->resolver->resolve()); - } - - public function testOverwrittenLazyOptionNotEvaluated() - { - $this->resolver->setDefault('foo', function (Options $options) { - Assert::fail('Should not be called'); - }); - - $this->resolver->setDefault('foo', 'bar'); - - $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); - } - - public function testInvokeEachLazyOptionOnlyOnce() - { - $calls = 0; - - $this->resolver->setDefault('lazy1', function (Options $options) use (&$calls) { - Assert::assertSame(1, ++$calls); - - $options['lazy2']; - }); - - $this->resolver->setDefault('lazy2', function (Options $options) use (&$calls) { - Assert::assertSame(2, ++$calls); - }); - - $this->resolver->resolve(); - - $this->assertSame(2, $calls); - } - - public function testSetRequiredReturnsThis() - { - $this->assertSame($this->resolver, $this->resolver->setRequired('foo')); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testFailIfSetRequiredFromLazyOption() - { - $this->resolver->setDefault('foo', function (Options $options) { - $options->setRequired('bar'); - }); - - $this->resolver->resolve(); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\MissingOptionsException - */ - public function testResolveFailsIfRequiredOptionMissing() - { - $this->resolver->setRequired('foo'); - - $this->resolver->resolve(); - } - - public function testResolveSucceedsIfRequiredOptionSet() - { - $this->resolver->setRequired('foo'); - $this->resolver->setDefault('foo', 'bar'); - - $this->assertNotEmpty($this->resolver->resolve()); - } - - public function testResolveSucceedsIfRequiredOptionPassed() - { - $this->resolver->setRequired('foo'); - - $this->assertNotEmpty($this->resolver->resolve(array('foo' => 'bar'))); - } - - public function testIsRequired() - { - $this->assertFalse($this->resolver->isRequired('foo')); - $this->resolver->setRequired('foo'); - $this->assertTrue($this->resolver->isRequired('foo')); - } - - public function testRequiredIfSetBefore() - { - $this->assertFalse($this->resolver->isRequired('foo')); - - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setRequired('foo'); - - $this->assertTrue($this->resolver->isRequired('foo')); - } - - public function testStillRequiredAfterSet() - { - $this->assertFalse($this->resolver->isRequired('foo')); - - $this->resolver->setRequired('foo'); - $this->resolver->setDefault('foo', 'bar'); - - $this->assertTrue($this->resolver->isRequired('foo')); - } - - public function testIsNotRequiredAfterRemove() - { - $this->assertFalse($this->resolver->isRequired('foo')); - $this->resolver->setRequired('foo'); - $this->resolver->remove('foo'); - $this->assertFalse($this->resolver->isRequired('foo')); - } - - public function testIsNotRequiredAfterClear() - { - $this->assertFalse($this->resolver->isRequired('foo')); - $this->resolver->setRequired('foo'); - $this->resolver->clear(); - $this->assertFalse($this->resolver->isRequired('foo')); - } - - public function testGetRequiredOptions() - { - $this->resolver->setRequired(array('foo', 'bar')); - $this->resolver->setDefault('bam', 'baz'); - $this->resolver->setDefault('foo', 'boo'); - - $this->assertSame(array('foo', 'bar'), $this->resolver->getRequiredOptions()); - } - - public function testIsMissingIfNotSet() - { - $this->assertFalse($this->resolver->isMissing('foo')); - $this->resolver->setRequired('foo'); - $this->assertTrue($this->resolver->isMissing('foo')); - } - - public function testIsNotMissingIfSet() - { - $this->resolver->setDefault('foo', 'bar'); - - $this->assertFalse($this->resolver->isMissing('foo')); - $this->resolver->setRequired('foo'); - $this->assertFalse($this->resolver->isMissing('foo')); - } - - public function testIsNotMissingAfterRemove() - { - $this->resolver->setRequired('foo'); - $this->resolver->remove('foo'); - $this->assertFalse($this->resolver->isMissing('foo')); - } - - public function testIsNotMissingAfterClear() - { - $this->resolver->setRequired('foo'); - $this->resolver->clear(); - $this->assertFalse($this->resolver->isRequired('foo')); - } - - public function testGetMissingOptions() - { - $this->resolver->setRequired(array('foo', 'bar')); - $this->resolver->setDefault('bam', 'baz'); - $this->resolver->setDefault('foo', 'boo'); - - $this->assertSame(array('bar'), $this->resolver->getMissingOptions()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testFailIfSetDefinedFromLazyOption() - { - $this->resolver->setDefault('foo', function (Options $options) { - $options->setDefined('bar'); - }); - - $this->resolver->resolve(); - } - - public function testDefinedOptionsNotIncludedInResolvedOptions() - { - $this->resolver->setDefined('foo'); - - $this->assertSame(array(), $this->resolver->resolve()); - } - - public function testDefinedOptionsIncludedIfDefaultSetBefore() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setDefined('foo'); - - $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); - } - - public function testDefinedOptionsIncludedIfDefaultSetAfter() - { - $this->resolver->setDefined('foo'); - $this->resolver->setDefault('foo', 'bar'); - - $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); - } - - public function testDefinedOptionsIncludedIfPassedToResolve() - { - $this->resolver->setDefined('foo'); - - $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve(array('foo' => 'bar'))); - } - - public function testIsDefined() - { - $this->assertFalse($this->resolver->isDefined('foo')); - $this->resolver->setDefined('foo'); - $this->assertTrue($this->resolver->isDefined('foo')); - } - - public function testLazyOptionsAreDefined() - { - $this->assertFalse($this->resolver->isDefined('foo')); - $this->resolver->setDefault('foo', function (Options $options) {}); - $this->assertTrue($this->resolver->isDefined('foo')); - } - - public function testRequiredOptionsAreDefined() - { - $this->assertFalse($this->resolver->isDefined('foo')); - $this->resolver->setRequired('foo'); - $this->assertTrue($this->resolver->isDefined('foo')); - } - - public function testSetOptionsAreDefined() - { - $this->assertFalse($this->resolver->isDefined('foo')); - $this->resolver->setDefault('foo', 'bar'); - $this->assertTrue($this->resolver->isDefined('foo')); - } - - public function testGetDefinedOptions() - { - $this->resolver->setDefined(array('foo', 'bar')); - $this->resolver->setDefault('baz', 'bam'); - $this->resolver->setRequired('boo'); - - $this->assertSame(array('foo', 'bar', 'baz', 'boo'), $this->resolver->getDefinedOptions()); - } - - public function testRemovedOptionsAreNotDefined() - { - $this->assertFalse($this->resolver->isDefined('foo')); - $this->resolver->setDefined('foo'); - $this->assertTrue($this->resolver->isDefined('foo')); - $this->resolver->remove('foo'); - $this->assertFalse($this->resolver->isDefined('foo')); - } - - public function testClearedOptionsAreNotDefined() - { - $this->assertFalse($this->resolver->isDefined('foo')); - $this->resolver->setDefined('foo'); - $this->assertTrue($this->resolver->isDefined('foo')); - $this->resolver->clear(); - $this->assertFalse($this->resolver->isDefined('foo')); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException - */ - public function testSetAllowedTypesFailsIfUnknownOption() - { - $this->resolver->setAllowedTypes('foo', 'string'); - } - - public function testResolveTypedArray() - { - $this->resolver->setDefined('foo'); - $this->resolver->setAllowedTypes('foo', 'string[]'); - $options = $this->resolver->resolve(array('foo' => array('bar', 'baz'))); - - $this->assertSame(array('foo' => array('bar', 'baz')), $options); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testFailIfSetAllowedTypesFromLazyOption() - { - $this->resolver->setDefault('foo', function (Options $options) { - $options->setAllowedTypes('bar', 'string'); - }); - - $this->resolver->setDefault('bar', 'baz'); - - $this->resolver->resolve(); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[]", but one of the elements is of type "DateTime[]". - */ - public function testResolveFailsIfInvalidTypedArray() - { - $this->resolver->setDefined('foo'); - $this->resolver->setAllowedTypes('foo', 'int[]'); - - $this->resolver->resolve(array('foo' => array(new \DateTime()))); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * @expectedExceptionMessage The option "foo" with value "bar" is expected to be of type "int[]", but is of type "string". - */ - public function testResolveFailsWithNonArray() - { - $this->resolver->setDefined('foo'); - $this->resolver->setAllowedTypes('foo', 'int[]'); - - $this->resolver->resolve(array('foo' => 'bar')); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[]", but one of the elements is of type "stdClass[]". - */ - public function testResolveFailsIfTypedArrayContainsInvalidTypes() - { - $this->resolver->setDefined('foo'); - $this->resolver->setAllowedTypes('foo', 'int[]'); - $values = range(1, 5); - $values[] = new \stdClass(); - $values[] = array(); - $values[] = new \DateTime(); - $values[] = 123; - - $this->resolver->resolve(array('foo' => $values)); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "double[][]". - */ - public function testResolveFailsWithCorrectLevelsButWrongScalar() - { - $this->resolver->setDefined('foo'); - $this->resolver->setAllowedTypes('foo', 'int[][]'); - - $this->resolver->resolve( - array( - 'foo' => array( - array(1.2), - ), - ) - ); - } - - /** - * @dataProvider provideInvalidTypes - */ - public function testResolveFailsIfInvalidType($actualType, $allowedType, $exceptionMessage) - { - $this->resolver->setDefined('option'); - $this->resolver->setAllowedTypes('option', $allowedType); - - if (method_exists($this, 'expectException')) { - $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); - $this->expectExceptionMessage($exceptionMessage); - } else { - $this->setExpectedException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', $exceptionMessage); - } - - $this->resolver->resolve(array('option' => $actualType)); - } - - public function provideInvalidTypes() - { - return array( - array(true, 'string', 'The option "option" with value true is expected to be of type "string", but is of type "boolean".'), - array(false, 'string', 'The option "option" with value false is expected to be of type "string", but is of type "boolean".'), - array(fopen(__FILE__, 'r'), 'string', 'The option "option" with value resource is expected to be of type "string", but is of type "resource".'), - array(array(), 'string', 'The option "option" with value array is expected to be of type "string", but is of type "array".'), - array(new OptionsResolver(), 'string', 'The option "option" with value Symfony\Component\OptionsResolver\OptionsResolver is expected to be of type "string", but is of type "Symfony\Component\OptionsResolver\OptionsResolver".'), - array(42, 'string', 'The option "option" with value 42 is expected to be of type "string", but is of type "integer".'), - array(null, 'string', 'The option "option" with value null is expected to be of type "string", but is of type "NULL".'), - array('bar', '\stdClass', 'The option "option" with value "bar" is expected to be of type "\stdClass", but is of type "string".'), - ); - } - - public function testResolveSucceedsIfValidType() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setAllowedTypes('foo', 'string'); - - $this->assertNotEmpty($this->resolver->resolve()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * @expectedExceptionMessage The option "foo" with value 42 is expected to be of type "string" or "bool", but is of type "integer". - */ - public function testResolveFailsIfInvalidTypeMultiple() - { - $this->resolver->setDefault('foo', 42); - $this->resolver->setAllowedTypes('foo', array('string', 'bool')); - - $this->resolver->resolve(); - } - - public function testResolveSucceedsIfValidTypeMultiple() - { - $this->resolver->setDefault('foo', true); - $this->resolver->setAllowedTypes('foo', array('string', 'bool')); - - $this->assertNotEmpty($this->resolver->resolve()); - } - - public function testResolveSucceedsIfInstanceOfClass() - { - $this->resolver->setDefault('foo', new \stdClass()); - $this->resolver->setAllowedTypes('foo', '\stdClass'); - - $this->assertNotEmpty($this->resolver->resolve()); - } - - public function testResolveSucceedsIfTypedArray() - { - $this->resolver->setDefault('foo', null); - $this->resolver->setAllowedTypes('foo', array('null', 'DateTime[]')); - - $data = array( - 'foo' => array( - new \DateTime(), - new \DateTime(), - ), - ); - $result = $this->resolver->resolve($data); - $this->assertEquals($data, $result); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testResolveFailsIfNotInstanceOfClass() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setAllowedTypes('foo', '\stdClass'); - - $this->resolver->resolve(); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException - */ - public function testAddAllowedTypesFailsIfUnknownOption() - { - $this->resolver->addAllowedTypes('foo', 'string'); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testFailIfAddAllowedTypesFromLazyOption() - { - $this->resolver->setDefault('foo', function (Options $options) { - $options->addAllowedTypes('bar', 'string'); - }); - - $this->resolver->setDefault('bar', 'baz'); - - $this->resolver->resolve(); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testResolveFailsIfInvalidAddedType() - { - $this->resolver->setDefault('foo', 42); - $this->resolver->addAllowedTypes('foo', 'string'); - - $this->resolver->resolve(); - } - - public function testResolveSucceedsIfValidAddedType() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->addAllowedTypes('foo', 'string'); - - $this->assertNotEmpty($this->resolver->resolve()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testResolveFailsIfInvalidAddedTypeMultiple() - { - $this->resolver->setDefault('foo', 42); - $this->resolver->addAllowedTypes('foo', array('string', 'bool')); - - $this->resolver->resolve(); - } - - public function testResolveSucceedsIfValidAddedTypeMultiple() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->addAllowedTypes('foo', array('string', 'bool')); - - $this->assertNotEmpty($this->resolver->resolve()); - } - - public function testAddAllowedTypesDoesNotOverwrite() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setAllowedTypes('foo', 'string'); - $this->resolver->addAllowedTypes('foo', 'bool'); - - $this->resolver->setDefault('foo', 'bar'); - - $this->assertNotEmpty($this->resolver->resolve()); - } - - public function testAddAllowedTypesDoesNotOverwrite2() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setAllowedTypes('foo', 'string'); - $this->resolver->addAllowedTypes('foo', 'bool'); - - $this->resolver->setDefault('foo', false); - - $this->assertNotEmpty($this->resolver->resolve()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException - */ - public function testSetAllowedValuesFailsIfUnknownOption() - { - $this->resolver->setAllowedValues('foo', 'bar'); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testFailIfSetAllowedValuesFromLazyOption() - { - $this->resolver->setDefault('foo', function (Options $options) { - $options->setAllowedValues('bar', 'baz'); - }); - - $this->resolver->setDefault('bar', 'baz'); - - $this->resolver->resolve(); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * @expectedExceptionMessage The option "foo" with value 42 is invalid. Accepted values are: "bar". - */ - public function testResolveFailsIfInvalidValue() - { - $this->resolver->setDefined('foo'); - $this->resolver->setAllowedValues('foo', 'bar'); - - $this->resolver->resolve(array('foo' => 42)); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * @expectedExceptionMessage The option "foo" with value null is invalid. Accepted values are: "bar". - */ - public function testResolveFailsIfInvalidValueIsNull() - { - $this->resolver->setDefault('foo', null); - $this->resolver->setAllowedValues('foo', 'bar'); - - $this->resolver->resolve(); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testResolveFailsIfInvalidValueStrict() - { - $this->resolver->setDefault('foo', 42); - $this->resolver->setAllowedValues('foo', '42'); - - $this->resolver->resolve(); - } - - public function testResolveSucceedsIfValidValue() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setAllowedValues('foo', 'bar'); - - $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); - } - - public function testResolveSucceedsIfValidValueIsNull() - { - $this->resolver->setDefault('foo', null); - $this->resolver->setAllowedValues('foo', null); - - $this->assertEquals(array('foo' => null), $this->resolver->resolve()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * @expectedExceptionMessage The option "foo" with value 42 is invalid. Accepted values are: "bar", false, null. - */ - public function testResolveFailsIfInvalidValueMultiple() - { - $this->resolver->setDefault('foo', 42); - $this->resolver->setAllowedValues('foo', array('bar', false, null)); - - $this->resolver->resolve(); - } - - public function testResolveSucceedsIfValidValueMultiple() - { - $this->resolver->setDefault('foo', 'baz'); - $this->resolver->setAllowedValues('foo', array('bar', 'baz')); - - $this->assertEquals(array('foo' => 'baz'), $this->resolver->resolve()); - } - - public function testResolveFailsIfClosureReturnsFalse() - { - $this->resolver->setDefault('foo', 42); - $this->resolver->setAllowedValues('foo', function ($value) use (&$passedValue) { - $passedValue = $value; - - return false; - }); - - try { - $this->resolver->resolve(); - $this->fail('Should fail'); - } catch (InvalidOptionsException $e) { - } - - $this->assertSame(42, $passedValue); - } - - public function testResolveSucceedsIfClosureReturnsTrue() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setAllowedValues('foo', function ($value) use (&$passedValue) { - $passedValue = $value; - - return true; - }); - - $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); - $this->assertSame('bar', $passedValue); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testResolveFailsIfAllClosuresReturnFalse() - { - $this->resolver->setDefault('foo', 42); - $this->resolver->setAllowedValues('foo', array( - function () { return false; }, - function () { return false; }, - function () { return false; }, - )); - - $this->resolver->resolve(); - } - - public function testResolveSucceedsIfAnyClosureReturnsTrue() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setAllowedValues('foo', array( - function () { return false; }, - function () { return true; }, - function () { return false; }, - )); - - $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException - */ - public function testAddAllowedValuesFailsIfUnknownOption() - { - $this->resolver->addAllowedValues('foo', 'bar'); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testFailIfAddAllowedValuesFromLazyOption() - { - $this->resolver->setDefault('foo', function (Options $options) { - $options->addAllowedValues('bar', 'baz'); - }); - - $this->resolver->setDefault('bar', 'baz'); - - $this->resolver->resolve(); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testResolveFailsIfInvalidAddedValue() - { - $this->resolver->setDefault('foo', 42); - $this->resolver->addAllowedValues('foo', 'bar'); - - $this->resolver->resolve(); - } - - public function testResolveSucceedsIfValidAddedValue() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->addAllowedValues('foo', 'bar'); - - $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); - } - - public function testResolveSucceedsIfValidAddedValueIsNull() - { - $this->resolver->setDefault('foo', null); - $this->resolver->addAllowedValues('foo', null); - - $this->assertEquals(array('foo' => null), $this->resolver->resolve()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testResolveFailsIfInvalidAddedValueMultiple() - { - $this->resolver->setDefault('foo', 42); - $this->resolver->addAllowedValues('foo', array('bar', 'baz')); - - $this->resolver->resolve(); - } - - public function testResolveSucceedsIfValidAddedValueMultiple() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->addAllowedValues('foo', array('bar', 'baz')); - - $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); - } - - public function testAddAllowedValuesDoesNotOverwrite() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setAllowedValues('foo', 'bar'); - $this->resolver->addAllowedValues('foo', 'baz'); - - $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); - } - - public function testAddAllowedValuesDoesNotOverwrite2() - { - $this->resolver->setDefault('foo', 'baz'); - $this->resolver->setAllowedValues('foo', 'bar'); - $this->resolver->addAllowedValues('foo', 'baz'); - - $this->assertEquals(array('foo' => 'baz'), $this->resolver->resolve()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testResolveFailsIfAllAddedClosuresReturnFalse() - { - $this->resolver->setDefault('foo', 42); - $this->resolver->setAllowedValues('foo', function () { return false; }); - $this->resolver->addAllowedValues('foo', function () { return false; }); - - $this->resolver->resolve(); - } - - public function testResolveSucceedsIfAnyAddedClosureReturnsTrue() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setAllowedValues('foo', function () { return false; }); - $this->resolver->addAllowedValues('foo', function () { return true; }); - - $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); - } - - public function testResolveSucceedsIfAnyAddedClosureReturnsTrue2() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setAllowedValues('foo', function () { return true; }); - $this->resolver->addAllowedValues('foo', function () { return false; }); - - $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); - } - - public function testSetNormalizerReturnsThis() - { - $this->resolver->setDefault('foo', 'bar'); - $this->assertSame($this->resolver, $this->resolver->setNormalizer('foo', function () {})); - } - - public function testSetNormalizerClosure() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setNormalizer('foo', function () { - return 'normalized'; - }); - - $this->assertEquals(array('foo' => 'normalized'), $this->resolver->resolve()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException - */ - public function testSetNormalizerFailsIfUnknownOption() - { - $this->resolver->setNormalizer('foo', function () {}); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testFailIfSetNormalizerFromLazyOption() - { - $this->resolver->setDefault('foo', function (Options $options) { - $options->setNormalizer('foo', function () {}); - }); - - $this->resolver->setDefault('bar', 'baz'); - - $this->resolver->resolve(); - } - - public function testNormalizerReceivesSetOption() - { - $this->resolver->setDefault('foo', 'bar'); - - $this->resolver->setNormalizer('foo', function (Options $options, $value) { - return 'normalized['.$value.']'; - }); - - $this->assertEquals(array('foo' => 'normalized[bar]'), $this->resolver->resolve()); - } - - public function testNormalizerReceivesPassedOption() - { - $this->resolver->setDefault('foo', 'bar'); - - $this->resolver->setNormalizer('foo', function (Options $options, $value) { - return 'normalized['.$value.']'; - }); - - $resolved = $this->resolver->resolve(array('foo' => 'baz')); - - $this->assertEquals(array('foo' => 'normalized[baz]'), $resolved); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testValidateTypeBeforeNormalization() - { - $this->resolver->setDefault('foo', 'bar'); - - $this->resolver->setAllowedTypes('foo', 'int'); - - $this->resolver->setNormalizer('foo', function () { - Assert::fail('Should not be called.'); - }); - - $this->resolver->resolve(); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testValidateValueBeforeNormalization() - { - $this->resolver->setDefault('foo', 'bar'); - - $this->resolver->setAllowedValues('foo', 'baz'); - - $this->resolver->setNormalizer('foo', function () { - Assert::fail('Should not be called.'); - }); - - $this->resolver->resolve(); - } - - public function testNormalizerCanAccessOtherOptions() - { - $this->resolver->setDefault('default', 'bar'); - $this->resolver->setDefault('norm', 'baz'); - - $this->resolver->setNormalizer('norm', function (Options $options) { - /* @var TestCase $test */ - Assert::assertSame('bar', $options['default']); - - return 'normalized'; - }); - - $this->assertEquals(array( - 'default' => 'bar', - 'norm' => 'normalized', - ), $this->resolver->resolve()); - } - - public function testNormalizerCanAccessLazyOptions() - { - $this->resolver->setDefault('lazy', function (Options $options) { - return 'bar'; - }); - $this->resolver->setDefault('norm', 'baz'); - - $this->resolver->setNormalizer('norm', function (Options $options) { - /* @var TestCase $test */ - Assert::assertEquals('bar', $options['lazy']); - - return 'normalized'; - }); - - $this->assertEquals(array( - 'lazy' => 'bar', - 'norm' => 'normalized', - ), $this->resolver->resolve()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException - */ - public function testFailIfCyclicDependencyBetweenNormalizers() - { - $this->resolver->setDefault('norm1', 'bar'); - $this->resolver->setDefault('norm2', 'baz'); - - $this->resolver->setNormalizer('norm1', function (Options $options) { - $options['norm2']; - }); - - $this->resolver->setNormalizer('norm2', function (Options $options) { - $options['norm1']; - }); - - $this->resolver->resolve(); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException - */ - public function testFailIfCyclicDependencyBetweenNormalizerAndLazyOption() - { - $this->resolver->setDefault('lazy', function (Options $options) { - $options['norm']; - }); - - $this->resolver->setDefault('norm', 'baz'); - - $this->resolver->setNormalizer('norm', function (Options $options) { - $options['lazy']; - }); - - $this->resolver->resolve(); - } - - public function testCaughtExceptionFromNormalizerDoesNotCrashOptionResolver() - { - $throw = true; - - $this->resolver->setDefaults(array('catcher' => null, 'thrower' => null)); - - $this->resolver->setNormalizer('catcher', function (Options $options) { - try { - return $options['thrower']; - } catch (\Exception $e) { - return false; - } - }); - - $this->resolver->setNormalizer('thrower', function () use (&$throw) { - if ($throw) { - $throw = false; - throw new \UnexpectedValueException('throwing'); - } - - return true; - }); - - $this->assertSame(array('catcher' => false, 'thrower' => true), $this->resolver->resolve()); - } - - public function testCaughtExceptionFromLazyDoesNotCrashOptionResolver() - { - $throw = true; - - $this->resolver->setDefault('catcher', function (Options $options) { - try { - return $options['thrower']; - } catch (\Exception $e) { - return false; - } - }); - - $this->resolver->setDefault('thrower', function (Options $options) use (&$throw) { - if ($throw) { - $throw = false; - throw new \UnexpectedValueException('throwing'); - } - - return true; - }); - - $this->assertSame(array('catcher' => false, 'thrower' => true), $this->resolver->resolve()); - } - - public function testInvokeEachNormalizerOnlyOnce() - { - $calls = 0; - - $this->resolver->setDefault('norm1', 'bar'); - $this->resolver->setDefault('norm2', 'baz'); - - $this->resolver->setNormalizer('norm1', function ($options) use (&$calls) { - Assert::assertSame(1, ++$calls); - - $options['norm2']; - }); - $this->resolver->setNormalizer('norm2', function () use (&$calls) { - Assert::assertSame(2, ++$calls); - }); - - $this->resolver->resolve(); - - $this->assertSame(2, $calls); - } - - public function testNormalizerNotCalledForUnsetOptions() - { - $this->resolver->setDefined('norm'); - - $this->resolver->setNormalizer('norm', function () { - Assert::fail('Should not be called.'); - }); - - $this->assertEmpty($this->resolver->resolve()); - } - - public function testSetDefaultsReturnsThis() - { - $this->assertSame($this->resolver, $this->resolver->setDefaults(array('foo', 'bar'))); - } - - public function testSetDefaults() - { - $this->resolver->setDefault('one', '1'); - $this->resolver->setDefault('two', 'bar'); - - $this->resolver->setDefaults(array( - 'two' => '2', - 'three' => '3', - )); - - $this->assertEquals(array( - 'one' => '1', - 'two' => '2', - 'three' => '3', - ), $this->resolver->resolve()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testFailIfSetDefaultsFromLazyOption() - { - $this->resolver->setDefault('foo', function (Options $options) { - $options->setDefaults(array('two' => '2')); - }); - - $this->resolver->resolve(); - } - - public function testRemoveReturnsThis() - { - $this->resolver->setDefault('foo', 'bar'); - - $this->assertSame($this->resolver, $this->resolver->remove('foo')); - } - - public function testRemoveSingleOption() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setDefault('baz', 'boo'); - $this->resolver->remove('foo'); - - $this->assertSame(array('baz' => 'boo'), $this->resolver->resolve()); - } - - public function testRemoveMultipleOptions() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setDefault('baz', 'boo'); - $this->resolver->setDefault('doo', 'dam'); - - $this->resolver->remove(array('foo', 'doo')); - - $this->assertSame(array('baz' => 'boo'), $this->resolver->resolve()); - } - - public function testRemoveLazyOption() - { - $this->resolver->setDefault('foo', function (Options $options) { - return 'lazy'; - }); - $this->resolver->remove('foo'); - - $this->assertSame(array(), $this->resolver->resolve()); - } - - public function testRemoveNormalizer() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setNormalizer('foo', function (Options $options, $value) { - return 'normalized'; - }); - $this->resolver->remove('foo'); - $this->resolver->setDefault('foo', 'bar'); - - $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); - } - - public function testRemoveAllowedTypes() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setAllowedTypes('foo', 'int'); - $this->resolver->remove('foo'); - $this->resolver->setDefault('foo', 'bar'); - - $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); - } - - public function testRemoveAllowedValues() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setAllowedValues('foo', array('baz', 'boo')); - $this->resolver->remove('foo'); - $this->resolver->setDefault('foo', 'bar'); - - $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testFailIfRemoveFromLazyOption() - { - $this->resolver->setDefault('foo', function (Options $options) { - $options->remove('bar'); - }); - - $this->resolver->setDefault('bar', 'baz'); - - $this->resolver->resolve(); - } - - public function testRemoveUnknownOptionIgnored() - { - $this->assertNotNull($this->resolver->remove('foo')); - } - - public function testClearReturnsThis() - { - $this->assertSame($this->resolver, $this->resolver->clear()); - } - - public function testClearRemovesAllOptions() - { - $this->resolver->setDefault('one', 1); - $this->resolver->setDefault('two', 2); - - $this->resolver->clear(); - - $this->assertEmpty($this->resolver->resolve()); - } - - public function testClearLazyOption() - { - $this->resolver->setDefault('foo', function (Options $options) { - return 'lazy'; - }); - $this->resolver->clear(); - - $this->assertSame(array(), $this->resolver->resolve()); - } - - public function testClearNormalizer() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setNormalizer('foo', function (Options $options, $value) { - return 'normalized'; - }); - $this->resolver->clear(); - $this->resolver->setDefault('foo', 'bar'); - - $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); - } - - public function testClearAllowedTypes() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setAllowedTypes('foo', 'int'); - $this->resolver->clear(); - $this->resolver->setDefault('foo', 'bar'); - - $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); - } - - public function testClearAllowedValues() - { - $this->resolver->setDefault('foo', 'bar'); - $this->resolver->setAllowedValues('foo', 'baz'); - $this->resolver->clear(); - $this->resolver->setDefault('foo', 'bar'); - - $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testFailIfClearFromLazyption() - { - $this->resolver->setDefault('foo', function (Options $options) { - $options->clear(); - }); - - $this->resolver->setDefault('bar', 'baz'); - - $this->resolver->resolve(); - } - - public function testClearOptionAndNormalizer() - { - $this->resolver->setDefault('foo1', 'bar'); - $this->resolver->setNormalizer('foo1', function (Options $options) { - return ''; - }); - $this->resolver->setDefault('foo2', 'bar'); - $this->resolver->setNormalizer('foo2', function (Options $options) { - return ''; - }); - - $this->resolver->clear(); - $this->assertEmpty($this->resolver->resolve()); - } - - public function testArrayAccess() - { - $this->resolver->setDefault('default1', 0); - $this->resolver->setDefault('default2', 1); - $this->resolver->setRequired('required'); - $this->resolver->setDefined('defined'); - $this->resolver->setDefault('lazy1', function (Options $options) { - return 'lazy'; - }); - - $this->resolver->setDefault('lazy2', function (Options $options) { - Assert::assertArrayHasKey('default1', $options); - Assert::assertArrayHasKey('default2', $options); - Assert::assertArrayHasKey('required', $options); - Assert::assertArrayHasKey('lazy1', $options); - Assert::assertArrayHasKey('lazy2', $options); - Assert::assertArrayNotHasKey('defined', $options); - - Assert::assertSame(0, $options['default1']); - Assert::assertSame(42, $options['default2']); - Assert::assertSame('value', $options['required']); - Assert::assertSame('lazy', $options['lazy1']); - - // Obviously $options['lazy'] and $options['defined'] cannot be - // accessed - }); - - $this->resolver->resolve(array('default2' => 42, 'required' => 'value')); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testArrayAccessGetFailsOutsideResolve() - { - $this->resolver->setDefault('default', 0); - - $this->resolver['default']; - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testArrayAccessExistsFailsOutsideResolve() - { - $this->resolver->setDefault('default', 0); - - isset($this->resolver['default']); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testArrayAccessSetNotSupported() - { - $this->resolver['default'] = 0; - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testArrayAccessUnsetNotSupported() - { - $this->resolver->setDefault('default', 0); - - unset($this->resolver['default']); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\NoSuchOptionException - * @expectedExceptionMessage The option "undefined" does not exist. Defined options are: "foo", "lazy". - */ - public function testFailIfGetNonExisting() - { - $this->resolver->setDefault('foo', 'bar'); - - $this->resolver->setDefault('lazy', function (Options $options) { - $options['undefined']; - }); - - $this->resolver->resolve(); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\NoSuchOptionException - * @expectedExceptionMessage The optional option "defined" has no value set. You should make sure it is set with "isset" before reading it. - */ - public function testFailIfGetDefinedButUnset() - { - $this->resolver->setDefined('defined'); - - $this->resolver->setDefault('lazy', function (Options $options) { - $options['defined']; - }); - - $this->resolver->resolve(); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException - */ - public function testFailIfCyclicDependency() - { - $this->resolver->setDefault('lazy1', function (Options $options) { - $options['lazy2']; - }); - - $this->resolver->setDefault('lazy2', function (Options $options) { - $options['lazy1']; - }); - - $this->resolver->resolve(); - } - - public function testCount() - { - $this->resolver->setDefault('default', 0); - $this->resolver->setRequired('required'); - $this->resolver->setDefined('defined'); - $this->resolver->setDefault('lazy1', function () {}); - - $this->resolver->setDefault('lazy2', function (Options $options) { - Assert::assertCount(4, $options); - }); - - $this->assertCount(4, $this->resolver->resolve(array('required' => 'value'))); - } - - /** - * In resolve() we count the options that are actually set (which may be - * only a subset of the defined options). Outside of resolve(), it's not - * clear what is counted. - * - * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException - */ - public function testCountFailsOutsideResolve() - { - $this->resolver->setDefault('foo', 0); - $this->resolver->setRequired('bar'); - $this->resolver->setDefined('bar'); - $this->resolver->setDefault('lazy1', function () {}); - - count($this->resolver); - } - - public function testNestedArrays() - { - $this->resolver->setDefined('foo'); - $this->resolver->setAllowedTypes('foo', 'int[][]'); - - $this->assertEquals(array( - 'foo' => array( - array( - 1, 2, - ), - ), - ), $this->resolver->resolve( - array( - 'foo' => array( - array(1, 2), - ), - ) - )); - } - - public function testNested2Arrays() - { - $this->resolver->setDefined('foo'); - $this->resolver->setAllowedTypes('foo', 'int[][][][]'); - - $this->assertEquals(array( - 'foo' => array( - array( - array( - array( - 1, 2, - ), - ), - ), - ), - ), $this->resolver->resolve( - array( - 'foo' => array( - array( - array( - array(1, 2), - ), - ), - ), - ) - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * @expectedExceptionMessage The option "foo" with value array is expected to be of type "float[][][][]", but one of the elements is of type "integer[][][][]". - */ - public function testNestedArraysException() - { - $this->resolver->setDefined('foo'); - $this->resolver->setAllowedTypes('foo', 'float[][][][]'); - - $this->resolver->resolve( - array( - 'foo' => array( - array( - array( - array(1, 2), - ), - ), - ), - ) - ); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "boolean[][]". - */ - public function testNestedArrayException1() - { - $this->resolver->setDefined('foo'); - $this->resolver->setAllowedTypes('foo', 'int[][]'); - $this->resolver->resolve(array( - 'foo' => array( - array(1, true, 'str', array(2, 3)), - ), - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[][]", but one of the elements is of type "boolean[][]". - */ - public function testNestedArrayException2() - { - $this->resolver->setDefined('foo'); - $this->resolver->setAllowedTypes('foo', 'int[][]'); - $this->resolver->resolve(array( - 'foo' => array( - array(true, 'str', array(2, 3)), - ), - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * @expectedExceptionMessage The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "string[][]". - */ - public function testNestedArrayException3() - { - $this->resolver->setDefined('foo'); - $this->resolver->setAllowedTypes('foo', 'string[][][]'); - $this->resolver->resolve(array( - 'foo' => array( - array('str', array(1, 2)), - ), - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * @expectedExceptionMessage The option "foo" with value array is expected to be of type "string[][][]", but one of the elements is of type "integer[][][]". - */ - public function testNestedArrayException4() - { - $this->resolver->setDefined('foo'); - $this->resolver->setAllowedTypes('foo', 'string[][][]'); - $this->resolver->resolve(array( - 'foo' => array( - array( - array('str'), array(1, 2), ), - ), - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * @expectedExceptionMessage The option "foo" with value array is expected to be of type "string[]", but one of the elements is of type "array[]". - */ - public function testNestedArrayException5() - { - $this->resolver->setDefined('foo'); - $this->resolver->setAllowedTypes('foo', 'string[]'); - $this->resolver->resolve(array( - 'foo' => array( - array( - array('str'), array(1, 2), ), - ), - )); - } -} diff --git a/vendor/symfony/options-resolver/composer.json b/vendor/symfony/options-resolver/composer.json deleted file mode 100755 index 895847ea5add7aaa90fac5fe7ed6e7841b484066..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/composer.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "symfony/options-resolver", - "type": "library", - "description": "Symfony OptionsResolver Component", - "keywords": ["options", "config", "configuration"], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": "^5.5.9|>=7.0.8" - }, - "autoload": { - "psr-4": { "Symfony\\Component\\OptionsResolver\\": "" }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - } -} diff --git a/vendor/symfony/options-resolver/phpunit.xml.dist b/vendor/symfony/options-resolver/phpunit.xml.dist deleted file mode 100755 index 7e04e6049127d8f2771bba5b90edd64c51d27941..0000000000000000000000000000000000000000 --- a/vendor/symfony/options-resolver/phpunit.xml.dist +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" - backupGlobals="false" - colors="true" - bootstrap="vendor/autoload.php" - failOnRisky="true" - failOnWarning="true" -> - <php> - <ini name="error_reporting" value="-1" /> - </php> - - <testsuites> - <testsuite name="Symfony OptionsResolver Component Test Suite"> - <directory>./Tests/</directory> - </testsuite> - </testsuites> - - <filter> - <whitelist> - <directory>./</directory> - <exclude> - <directory>./Resources</directory> - <directory>./Tests</directory> - <directory>./vendor</directory> - </exclude> - </whitelist> - </filter> -</phpunit> diff --git a/vendor/symfony/polyfill-mbstring/LICENSE b/vendor/symfony/polyfill-mbstring/LICENSE old mode 100755 new mode 100644 diff --git a/vendor/symfony/polyfill-mbstring/Mbstring.php b/vendor/symfony/polyfill-mbstring/Mbstring.php old mode 100755 new mode 100644 index 4bd326e5f6e89c2ca7df31ab3247fd0a63d8bc7c..a5e4a8fde4bdee4cd0036a1bf85490c6fdb9d789 --- a/vendor/symfony/polyfill-mbstring/Mbstring.php +++ b/vendor/symfony/polyfill-mbstring/Mbstring.php @@ -44,7 +44,7 @@ namespace Symfony\Polyfill\Mbstring; * - mb_strrchr - Finds the last occurrence of a character in a string within another * - mb_strrichr - Finds the last occurrence of a character in a string within another, case insensitive * - mb_strripos - Finds position of last occurrence of a string within another, case insensitive - * - mb_strstr - Finds first occurrence of a string within anothers + * - mb_strstr - Finds first occurrence of a string within another * - mb_strwidth - Return width of string * - mb_substr_count - Count the number of substring occurrences * @@ -72,8 +72,8 @@ final class Mbstring private static $language = 'neutral'; private static $internalEncoding = 'UTF-8'; private static $caseFold = array( - array('µ','ſ',"\xCD\x85",'ς',"\xCF\x90","\xCF\x91","\xCF\x95","\xCF\x96","\xCF\xB0","\xCF\xB1","\xCF\xB5","\xE1\xBA\x9B","\xE1\xBE\xBE"), - array('μ','s','ι', 'σ','β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1",'ι'), + array('µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"), + array('μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1", 'ι'), ); public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null) @@ -141,7 +141,8 @@ final class Mbstring public static function mb_decode_numericentity($s, $convmap, $encoding = null) { if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) { - trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.gettype($s).' given', E_USER_WARNING); + trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING); + return null; } @@ -150,7 +151,8 @@ final class Mbstring } if (null !== $encoding && !\is_scalar($encoding)) { - trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.gettype($s).' given', E_USER_WARNING); + trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING); + return ''; // Instead of null (cf. mb_encode_numericentity). } @@ -185,6 +187,7 @@ final class Mbstring return Mbstring::mb_chr($c - $convmap[$i + 2]); } } + return $m[0]; }, $s); @@ -198,7 +201,8 @@ final class Mbstring public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false) { if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) { - trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.gettype($s).' given', E_USER_WARNING); + trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING); + return null; } @@ -207,12 +211,14 @@ final class Mbstring } if (null !== $encoding && !\is_scalar($encoding)) { - trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.gettype($s).' given', E_USER_WARNING); + trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING); + return null; // Instead of '' (cf. mb_decode_numericentity). } if (null !== $is_hex && !\is_scalar($is_hex)) { - trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.gettype($s).' given', E_USER_WARNING); + trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', E_USER_WARNING); + return null; } @@ -281,8 +287,11 @@ final class Mbstring } if (MB_CASE_TITLE == $mode) { - $s = preg_replace_callback('/\b\p{Ll}/u', array(__CLASS__, 'title_case_upper'), $s); - $s = preg_replace_callback('/\B[\p{Lu}\p{Lt}]+/u', array(__CLASS__, 'title_case_lower'), $s); + static $titleRegexp = null; + if (null === $titleRegexp) { + $titleRegexp = self::getData('titleCaseRegexp'); + } + $s = preg_replace_callback($titleRegexp, array(__CLASS__, 'title_case'), $s); } else { if (MB_CASE_UPPER == $mode) { static $upper = null; @@ -324,7 +333,7 @@ final class Mbstring } else { $s = substr_replace($s, $uchr, $i - $ulen, $ulen); $len += $nlen - $ulen; - $i += $nlen - $ulen; + $i += $nlen - $ulen; } } } @@ -452,6 +461,7 @@ final class Mbstring if (strncmp($enc, 'ISO-8859-', 9)) { return false; } + // no break case 'ASCII': case 'UTF8': case 'UTF-8': @@ -701,6 +711,10 @@ final class Mbstring $s = mb_convert_encoding($s, 'UTF-8', $encoding); } + if (1 === \strlen($s)) { + return \ord($s); + } + $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0; if (0xF0 <= $code) { return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80; @@ -752,14 +766,9 @@ final class Mbstring return $entities; } - private static function title_case_lower(array $s) - { - return self::mb_convert_case($s[0], MB_CASE_LOWER, 'UTF-8'); - } - - private static function title_case_upper(array $s) + private static function title_case(array $s) { - return self::mb_convert_case($s[0], MB_CASE_UPPER, 'UTF-8'); + return self::mb_convert_case($s[1], MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], MB_CASE_LOWER, 'UTF-8'); } private static function getData($file) diff --git a/vendor/symfony/polyfill-mbstring/README.md b/vendor/symfony/polyfill-mbstring/README.md old mode 100755 new mode 100644 diff --git a/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php b/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php old mode 100755 new mode 100644 index 3ca16416a82580b15bd446ba5cf75dc3d87fa922..e6fbfa64e6215a3e572d3d99f794cc6a85ea8af8 --- a/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php +++ b/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php @@ -1,6 +1,6 @@ <?php -static $data = array ( +return array( 'A' => 'a', 'B' => 'b', 'C' => 'c', @@ -1094,8 +1094,3 @@ static $data = array ( '𑢾' => '𑣞', '𑢿' => '𑣟', ); - -$result =& $data; -unset($data); - -return $result; diff --git a/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php b/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php old mode 100755 new mode 100644 index ec9422121cae73c8baa8d0cfc695897a5c091961..b8103b2e808dd0a670c04868f20edcc969ea7e70 --- a/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php +++ b/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php @@ -1,6 +1,6 @@ <?php -static $data = array ( +return array( 'a' => 'A', 'b' => 'B', 'c' => 'C', @@ -1102,8 +1102,3 @@ static $data = array ( '𑣞' => '𑢾', '𑣟' => '𑢿', ); - -$result =& $data; -unset($data); - -return $result; diff --git a/vendor/symfony/polyfill-mbstring/bootstrap.php b/vendor/symfony/polyfill-mbstring/bootstrap.php old mode 100755 new mode 100644 diff --git a/vendor/symfony/polyfill-mbstring/composer.json b/vendor/symfony/polyfill-mbstring/composer.json old mode 100755 new mode 100644 index 49b720dd81e2c2286cd0faf81182dfca43e7776d..50ea12f1bbb09226c9ee9abc9c3c33d8655af2b2 --- a/vendor/symfony/polyfill-mbstring/composer.json +++ b/vendor/symfony/polyfill-mbstring/composer.json @@ -28,7 +28,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.8-dev" + "dev-master": "1.9-dev" } } } diff --git a/vendor/tecnickcom/tcpdf/CHANGELOG.TXT b/vendor/tecnickcom/tcpdf/CHANGELOG.TXT old mode 100755 new mode 100644 index d6e4cf05e91a428a21c8fdf4719dd13b08339ac6..3bdae3e2450c604e1ad4bc8bd82af16ab0068f6a --- a/vendor/tecnickcom/tcpdf/CHANGELOG.TXT +++ b/vendor/tecnickcom/tcpdf/CHANGELOG.TXT @@ -1,5 +1,17 @@ -Unreleased - - fix Undesired mouseover effect on links in PDF on Chrome Pdf Viewer +6.2.25 + - Fix support for image URLs. + +6.2.24 + - Support remote urls when checking if file exists. + +6.2.23 + - Simplify file_exists function. + +6.2.22 + - Fix for security vulnerability: Using the phar:// wrapper it was possible to trigger the unserialization of user provided data. + +6.2.19 + - Merge various fixes for PHP 7.3 compatibility and security. 6.2.13 (2016-06-10) - IMPORTANT: A new version of this library is under development at https://github.com/tecnickcom/tc-lib-pdf and as a consequence this version will not receive any additional development or support. This version should be considered obsolete, new projects should use the new version as soon it will become stable. diff --git a/vendor/tecnickcom/tcpdf/LICENSE.TXT b/vendor/tecnickcom/tcpdf/LICENSE.TXT old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/README.md b/vendor/tecnickcom/tcpdf/README.md old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/composer.json b/vendor/tecnickcom/tcpdf/composer.json old mode 100755 new mode 100644 index 83ffd67b8b6cfb1898b82b1f4220ddfa5b619664..1f19dfd86412e341a3ed189c6c44462b6bfab3b8 --- a/vendor/tecnickcom/tcpdf/composer.json +++ b/vendor/tecnickcom/tcpdf/composer.json @@ -1,6 +1,6 @@ { "name": "tecnickcom/tcpdf", - "version": "6.2.17", + "version": "6.2.26", "homepage": "http://www.tcpdf.org/", "type": "library", "description": "TCPDF is a PHP class for generating PDF documents and barcodes.", diff --git a/vendor/tecnickcom/tcpdf/config/tcpdf_config.php b/vendor/tecnickcom/tcpdf/config/tcpdf_config.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/example_1d_html.php b/vendor/tecnickcom/tcpdf/examples/barcodes/example_1d_html.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/example_1d_png.php b/vendor/tecnickcom/tcpdf/examples/barcodes/example_1d_png.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/example_1d_svg.php b/vendor/tecnickcom/tcpdf/examples/barcodes/example_1d_svg.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/example_1d_svgi.php b/vendor/tecnickcom/tcpdf/examples/barcodes/example_1d_svgi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_datamatrix_html.php b/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_datamatrix_html.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_datamatrix_png.php b/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_datamatrix_png.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_datamatrix_svg.php b/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_datamatrix_svg.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_datamatrix_svgi.php b/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_datamatrix_svgi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_pdf417_html.php b/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_pdf417_html.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_pdf417_png.php b/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_pdf417_png.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_pdf417_svg.php b/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_pdf417_svg.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_pdf417_svgi.php b/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_pdf417_svgi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_qrcode_html.php b/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_qrcode_html.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_qrcode_png.php b/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_qrcode_png.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_qrcode_svg.php b/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_qrcode_svg.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_qrcode_svgi.php b/vendor/tecnickcom/tcpdf/examples/barcodes/example_2d_qrcode_svgi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/tcpdf_barcodes_1d_include.php b/vendor/tecnickcom/tcpdf/examples/barcodes/tcpdf_barcodes_1d_include.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/barcodes/tcpdf_barcodes_2d_include.php b/vendor/tecnickcom/tcpdf/examples/barcodes/tcpdf_barcodes_2d_include.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/config/tcpdf_config_alt.php b/vendor/tecnickcom/tcpdf/examples/config/tcpdf_config_alt.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/data/cert/tcpdf.crt b/vendor/tecnickcom/tcpdf/examples/data/cert/tcpdf.crt old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/data/cert/tcpdf.fdf b/vendor/tecnickcom/tcpdf/examples/data/cert/tcpdf.fdf old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/data/cert/tcpdf.p12 b/vendor/tecnickcom/tcpdf/examples/data/cert/tcpdf.p12 old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/data/chapter_demo_1.txt b/vendor/tecnickcom/tcpdf/examples/data/chapter_demo_1.txt old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/data/chapter_demo_2.txt b/vendor/tecnickcom/tcpdf/examples/data/chapter_demo_2.txt old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/data/table_data_demo.txt b/vendor/tecnickcom/tcpdf/examples/data/table_data_demo.txt old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/data/utf8test.txt b/vendor/tecnickcom/tcpdf/examples/data/utf8test.txt old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_001.php b/vendor/tecnickcom/tcpdf/examples/example_001.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_002.php b/vendor/tecnickcom/tcpdf/examples/example_002.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_003.php b/vendor/tecnickcom/tcpdf/examples/example_003.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_004.php b/vendor/tecnickcom/tcpdf/examples/example_004.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_005.php b/vendor/tecnickcom/tcpdf/examples/example_005.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_006.php b/vendor/tecnickcom/tcpdf/examples/example_006.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_007.php b/vendor/tecnickcom/tcpdf/examples/example_007.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_008.php b/vendor/tecnickcom/tcpdf/examples/example_008.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_009.php b/vendor/tecnickcom/tcpdf/examples/example_009.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_010.php b/vendor/tecnickcom/tcpdf/examples/example_010.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_011.php b/vendor/tecnickcom/tcpdf/examples/example_011.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_012.pdf b/vendor/tecnickcom/tcpdf/examples/example_012.pdf old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_012.php b/vendor/tecnickcom/tcpdf/examples/example_012.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_013.php b/vendor/tecnickcom/tcpdf/examples/example_013.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_014.php b/vendor/tecnickcom/tcpdf/examples/example_014.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_015.php b/vendor/tecnickcom/tcpdf/examples/example_015.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_016.php b/vendor/tecnickcom/tcpdf/examples/example_016.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_017.php b/vendor/tecnickcom/tcpdf/examples/example_017.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_018.php b/vendor/tecnickcom/tcpdf/examples/example_018.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_019.php b/vendor/tecnickcom/tcpdf/examples/example_019.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_020.php b/vendor/tecnickcom/tcpdf/examples/example_020.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_021.php b/vendor/tecnickcom/tcpdf/examples/example_021.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_022.php b/vendor/tecnickcom/tcpdf/examples/example_022.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_023.php b/vendor/tecnickcom/tcpdf/examples/example_023.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_024.php b/vendor/tecnickcom/tcpdf/examples/example_024.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_025.php b/vendor/tecnickcom/tcpdf/examples/example_025.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_026.php b/vendor/tecnickcom/tcpdf/examples/example_026.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_027.php b/vendor/tecnickcom/tcpdf/examples/example_027.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_028.php b/vendor/tecnickcom/tcpdf/examples/example_028.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_029.php b/vendor/tecnickcom/tcpdf/examples/example_029.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_030.php b/vendor/tecnickcom/tcpdf/examples/example_030.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_031.php b/vendor/tecnickcom/tcpdf/examples/example_031.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_032.php b/vendor/tecnickcom/tcpdf/examples/example_032.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_033.php b/vendor/tecnickcom/tcpdf/examples/example_033.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_034.php b/vendor/tecnickcom/tcpdf/examples/example_034.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_035.php b/vendor/tecnickcom/tcpdf/examples/example_035.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_036.php b/vendor/tecnickcom/tcpdf/examples/example_036.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_037.php b/vendor/tecnickcom/tcpdf/examples/example_037.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_038.php b/vendor/tecnickcom/tcpdf/examples/example_038.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_039.php b/vendor/tecnickcom/tcpdf/examples/example_039.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_040.php b/vendor/tecnickcom/tcpdf/examples/example_040.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_041.php b/vendor/tecnickcom/tcpdf/examples/example_041.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_042.php b/vendor/tecnickcom/tcpdf/examples/example_042.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_043.php b/vendor/tecnickcom/tcpdf/examples/example_043.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_044.php b/vendor/tecnickcom/tcpdf/examples/example_044.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_045.php b/vendor/tecnickcom/tcpdf/examples/example_045.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_046.php b/vendor/tecnickcom/tcpdf/examples/example_046.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_047.php b/vendor/tecnickcom/tcpdf/examples/example_047.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_048.php b/vendor/tecnickcom/tcpdf/examples/example_048.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_049.php b/vendor/tecnickcom/tcpdf/examples/example_049.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_050.php b/vendor/tecnickcom/tcpdf/examples/example_050.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_051.php b/vendor/tecnickcom/tcpdf/examples/example_051.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_052.php b/vendor/tecnickcom/tcpdf/examples/example_052.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_053.php b/vendor/tecnickcom/tcpdf/examples/example_053.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_054.php b/vendor/tecnickcom/tcpdf/examples/example_054.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_055.php b/vendor/tecnickcom/tcpdf/examples/example_055.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_056.php b/vendor/tecnickcom/tcpdf/examples/example_056.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_057.php b/vendor/tecnickcom/tcpdf/examples/example_057.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_058.php b/vendor/tecnickcom/tcpdf/examples/example_058.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_059.php b/vendor/tecnickcom/tcpdf/examples/example_059.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_060.php b/vendor/tecnickcom/tcpdf/examples/example_060.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_061.php b/vendor/tecnickcom/tcpdf/examples/example_061.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_062.php b/vendor/tecnickcom/tcpdf/examples/example_062.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_063.php b/vendor/tecnickcom/tcpdf/examples/example_063.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_064.php b/vendor/tecnickcom/tcpdf/examples/example_064.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/example_065.php b/vendor/tecnickcom/tcpdf/examples/example_065.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/images/_blank.png b/vendor/tecnickcom/tcpdf/examples/images/_blank.png old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/images/alpha.png b/vendor/tecnickcom/tcpdf/examples/images/alpha.png old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/images/image_demo.jpg b/vendor/tecnickcom/tcpdf/examples/images/image_demo.jpg old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/images/image_with_alpha.png b/vendor/tecnickcom/tcpdf/examples/images/image_with_alpha.png old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/images/img.png b/vendor/tecnickcom/tcpdf/examples/images/img.png old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/images/logo_example.gif b/vendor/tecnickcom/tcpdf/examples/images/logo_example.gif old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/images/logo_example.jpg b/vendor/tecnickcom/tcpdf/examples/images/logo_example.jpg old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/images/logo_example.png b/vendor/tecnickcom/tcpdf/examples/images/logo_example.png old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/images/tcpdf_box.ai b/vendor/tecnickcom/tcpdf/examples/images/tcpdf_box.ai old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/images/tcpdf_box.svg b/vendor/tecnickcom/tcpdf/examples/images/tcpdf_box.svg old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/images/tcpdf_cell.png b/vendor/tecnickcom/tcpdf/examples/images/tcpdf_cell.png old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/images/tcpdf_logo.jpg b/vendor/tecnickcom/tcpdf/examples/images/tcpdf_logo.jpg old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/images/tcpdf_signature.png b/vendor/tecnickcom/tcpdf/examples/images/tcpdf_signature.png old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/images/testsvg.svg b/vendor/tecnickcom/tcpdf/examples/images/testsvg.svg old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/images/tux.svg b/vendor/tecnickcom/tcpdf/examples/images/tux.svg old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/index.php b/vendor/tecnickcom/tcpdf/examples/index.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/afr.php b/vendor/tecnickcom/tcpdf/examples/lang/afr.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/ara.php b/vendor/tecnickcom/tcpdf/examples/lang/ara.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/aze.php b/vendor/tecnickcom/tcpdf/examples/lang/aze.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/bel.php b/vendor/tecnickcom/tcpdf/examples/lang/bel.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/bra.php b/vendor/tecnickcom/tcpdf/examples/lang/bra.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/bul.php b/vendor/tecnickcom/tcpdf/examples/lang/bul.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/cat.php b/vendor/tecnickcom/tcpdf/examples/lang/cat.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/ces.php b/vendor/tecnickcom/tcpdf/examples/lang/ces.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/chi.php b/vendor/tecnickcom/tcpdf/examples/lang/chi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/cym.php b/vendor/tecnickcom/tcpdf/examples/lang/cym.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/dan.php b/vendor/tecnickcom/tcpdf/examples/lang/dan.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/eng.php b/vendor/tecnickcom/tcpdf/examples/lang/eng.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/est.php b/vendor/tecnickcom/tcpdf/examples/lang/est.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/eus.php b/vendor/tecnickcom/tcpdf/examples/lang/eus.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/far.php b/vendor/tecnickcom/tcpdf/examples/lang/far.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/fra.php b/vendor/tecnickcom/tcpdf/examples/lang/fra.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/ger.php b/vendor/tecnickcom/tcpdf/examples/lang/ger.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/gle.php b/vendor/tecnickcom/tcpdf/examples/lang/gle.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/glg.php b/vendor/tecnickcom/tcpdf/examples/lang/glg.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/hat.php b/vendor/tecnickcom/tcpdf/examples/lang/hat.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/heb.php b/vendor/tecnickcom/tcpdf/examples/lang/heb.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/hrv.php b/vendor/tecnickcom/tcpdf/examples/lang/hrv.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/hun.php b/vendor/tecnickcom/tcpdf/examples/lang/hun.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/hye.php b/vendor/tecnickcom/tcpdf/examples/lang/hye.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/ind.php b/vendor/tecnickcom/tcpdf/examples/lang/ind.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/ita.php b/vendor/tecnickcom/tcpdf/examples/lang/ita.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/jpn.php b/vendor/tecnickcom/tcpdf/examples/lang/jpn.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/kat.php b/vendor/tecnickcom/tcpdf/examples/lang/kat.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/kor.php b/vendor/tecnickcom/tcpdf/examples/lang/kor.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/mkd.php b/vendor/tecnickcom/tcpdf/examples/lang/mkd.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/mlt.php b/vendor/tecnickcom/tcpdf/examples/lang/mlt.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/msa.php b/vendor/tecnickcom/tcpdf/examples/lang/msa.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/nld.php b/vendor/tecnickcom/tcpdf/examples/lang/nld.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/nob.php b/vendor/tecnickcom/tcpdf/examples/lang/nob.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/pol.php b/vendor/tecnickcom/tcpdf/examples/lang/pol.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/por.php b/vendor/tecnickcom/tcpdf/examples/lang/por.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/ron.php b/vendor/tecnickcom/tcpdf/examples/lang/ron.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/rus.php b/vendor/tecnickcom/tcpdf/examples/lang/rus.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/slv.php b/vendor/tecnickcom/tcpdf/examples/lang/slv.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/spa.php b/vendor/tecnickcom/tcpdf/examples/lang/spa.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/sqi.php b/vendor/tecnickcom/tcpdf/examples/lang/sqi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/srp.php b/vendor/tecnickcom/tcpdf/examples/lang/srp.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/swa.php b/vendor/tecnickcom/tcpdf/examples/lang/swa.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/swe.php b/vendor/tecnickcom/tcpdf/examples/lang/swe.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/ukr.php b/vendor/tecnickcom/tcpdf/examples/lang/ukr.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/urd.php b/vendor/tecnickcom/tcpdf/examples/lang/urd.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/yid.php b/vendor/tecnickcom/tcpdf/examples/lang/yid.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/lang/zho.php b/vendor/tecnickcom/tcpdf/examples/lang/zho.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/examples/tcpdf_include.php b/vendor/tecnickcom/tcpdf/examples/tcpdf_include.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/ae_fonts_2.0/COPYING b/vendor/tecnickcom/tcpdf/fonts/ae_fonts_2.0/COPYING old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/ae_fonts_2.0/ChangeLog b/vendor/tecnickcom/tcpdf/fonts/ae_fonts_2.0/ChangeLog old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/ae_fonts_2.0/ChangeLog.9745.BAK b/vendor/tecnickcom/tcpdf/fonts/ae_fonts_2.0/ChangeLog.9745.BAK old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/ae_fonts_2.0/README b/vendor/tecnickcom/tcpdf/fonts/ae_fonts_2.0/README old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/aealarabiya.ctg.z b/vendor/tecnickcom/tcpdf/fonts/aealarabiya.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/aealarabiya.php b/vendor/tecnickcom/tcpdf/fonts/aealarabiya.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/aealarabiya.z b/vendor/tecnickcom/tcpdf/fonts/aealarabiya.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/aefurat.ctg.z b/vendor/tecnickcom/tcpdf/fonts/aefurat.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/aefurat.php b/vendor/tecnickcom/tcpdf/fonts/aefurat.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/aefurat.z b/vendor/tecnickcom/tcpdf/fonts/aefurat.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/cid0cs.php b/vendor/tecnickcom/tcpdf/fonts/cid0cs.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/cid0ct.php b/vendor/tecnickcom/tcpdf/fonts/cid0ct.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/cid0jp.php b/vendor/tecnickcom/tcpdf/fonts/cid0jp.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/cid0kr.php b/vendor/tecnickcom/tcpdf/fonts/cid0kr.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/courier.php b/vendor/tecnickcom/tcpdf/fonts/courier.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/courierb.php b/vendor/tecnickcom/tcpdf/fonts/courierb.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/courierbi.php b/vendor/tecnickcom/tcpdf/fonts/courierbi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/courieri.php b/vendor/tecnickcom/tcpdf/fonts/courieri.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/AUTHORS b/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/AUTHORS old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/BUGS b/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/BUGS old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/LICENSE b/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/LICENSE old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/NEWS b/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/NEWS old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/README b/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/README old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/langcover.txt b/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/langcover.txt old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/status.txt b/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/status.txt old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/unicover.txt b/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.33/unicover.txt old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/AUTHORS b/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/AUTHORS old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/BUGS b/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/BUGS old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/LICENSE b/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/LICENSE old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/NEWS b/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/NEWS old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/README b/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/README old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/langcover.txt b/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/langcover.txt old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/status.txt b/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/status.txt old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/unicover.txt b/vendor/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/unicover.txt old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusans.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavusans.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusans.php b/vendor/tecnickcom/tcpdf/fonts/dejavusans.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusans.z b/vendor/tecnickcom/tcpdf/fonts/dejavusans.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansb.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavusansb.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansb.php b/vendor/tecnickcom/tcpdf/fonts/dejavusansb.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansb.z b/vendor/tecnickcom/tcpdf/fonts/dejavusansb.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansbi.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavusansbi.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansbi.php b/vendor/tecnickcom/tcpdf/fonts/dejavusansbi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansbi.z b/vendor/tecnickcom/tcpdf/fonts/dejavusansbi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensed.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensed.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensed.php b/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensed.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensed.z b/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensed.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedb.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedb.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedb.php b/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedb.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedb.z b/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedb.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedbi.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedbi.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedbi.php b/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedbi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedbi.z b/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedbi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedi.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedi.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedi.php b/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedi.z b/vendor/tecnickcom/tcpdf/fonts/dejavusanscondensedi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansextralight.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavusansextralight.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansextralight.php b/vendor/tecnickcom/tcpdf/fonts/dejavusansextralight.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansextralight.z b/vendor/tecnickcom/tcpdf/fonts/dejavusansextralight.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansi.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavusansi.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansi.php b/vendor/tecnickcom/tcpdf/fonts/dejavusansi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansi.z b/vendor/tecnickcom/tcpdf/fonts/dejavusansi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansmono.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavusansmono.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansmono.php b/vendor/tecnickcom/tcpdf/fonts/dejavusansmono.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansmono.z b/vendor/tecnickcom/tcpdf/fonts/dejavusansmono.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansmonob.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavusansmonob.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansmonob.php b/vendor/tecnickcom/tcpdf/fonts/dejavusansmonob.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansmonob.z b/vendor/tecnickcom/tcpdf/fonts/dejavusansmonob.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansmonobi.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavusansmonobi.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansmonobi.php b/vendor/tecnickcom/tcpdf/fonts/dejavusansmonobi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansmonobi.z b/vendor/tecnickcom/tcpdf/fonts/dejavusansmonobi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansmonoi.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavusansmonoi.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansmonoi.php b/vendor/tecnickcom/tcpdf/fonts/dejavusansmonoi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavusansmonoi.z b/vendor/tecnickcom/tcpdf/fonts/dejavusansmonoi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserif.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavuserif.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserif.php b/vendor/tecnickcom/tcpdf/fonts/dejavuserif.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserif.z b/vendor/tecnickcom/tcpdf/fonts/dejavuserif.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifb.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavuserifb.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifb.php b/vendor/tecnickcom/tcpdf/fonts/dejavuserifb.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifb.z b/vendor/tecnickcom/tcpdf/fonts/dejavuserifb.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifbi.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavuserifbi.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifbi.php b/vendor/tecnickcom/tcpdf/fonts/dejavuserifbi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifbi.z b/vendor/tecnickcom/tcpdf/fonts/dejavuserifbi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensed.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensed.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensed.php b/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensed.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensed.z b/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensed.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedb.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedb.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedb.php b/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedb.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedb.z b/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedb.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedbi.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedbi.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedbi.php b/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedbi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedbi.z b/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedbi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedi.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedi.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedi.php b/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedi.z b/vendor/tecnickcom/tcpdf/fonts/dejavuserifcondensedi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifi.ctg.z b/vendor/tecnickcom/tcpdf/fonts/dejavuserifi.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifi.php b/vendor/tecnickcom/tcpdf/fonts/dejavuserifi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/dejavuserifi.z b/vendor/tecnickcom/tcpdf/fonts/dejavuserifi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freefont-20100919/AUTHORS b/vendor/tecnickcom/tcpdf/fonts/freefont-20100919/AUTHORS old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freefont-20100919/COPYING b/vendor/tecnickcom/tcpdf/fonts/freefont-20100919/COPYING old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freefont-20100919/CREDITS b/vendor/tecnickcom/tcpdf/fonts/freefont-20100919/CREDITS old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freefont-20100919/ChangeLog b/vendor/tecnickcom/tcpdf/fonts/freefont-20100919/ChangeLog old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freefont-20100919/INSTALL b/vendor/tecnickcom/tcpdf/fonts/freefont-20100919/INSTALL old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freefont-20100919/README b/vendor/tecnickcom/tcpdf/fonts/freefont-20100919/README old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/AUTHORS b/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/AUTHORS old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/COPYING b/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/COPYING old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/CREDITS b/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/CREDITS old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/ChangeLog b/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/ChangeLog old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/ChangeLog.10070.BAK b/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/ChangeLog.10070.BAK old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/INSTALL b/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/INSTALL old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/README b/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/README old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/TROUBLESHOOTING b/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/TROUBLESHOOTING old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/USAGE b/vendor/tecnickcom/tcpdf/fonts/freefont-20120503/USAGE old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freemono.ctg.z b/vendor/tecnickcom/tcpdf/fonts/freemono.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freemono.php b/vendor/tecnickcom/tcpdf/fonts/freemono.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freemono.z b/vendor/tecnickcom/tcpdf/fonts/freemono.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freemonob.ctg.z b/vendor/tecnickcom/tcpdf/fonts/freemonob.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freemonob.php b/vendor/tecnickcom/tcpdf/fonts/freemonob.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freemonob.z b/vendor/tecnickcom/tcpdf/fonts/freemonob.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freemonobi.ctg.z b/vendor/tecnickcom/tcpdf/fonts/freemonobi.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freemonobi.php b/vendor/tecnickcom/tcpdf/fonts/freemonobi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freemonobi.z b/vendor/tecnickcom/tcpdf/fonts/freemonobi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freemonoi.ctg.z b/vendor/tecnickcom/tcpdf/fonts/freemonoi.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freemonoi.php b/vendor/tecnickcom/tcpdf/fonts/freemonoi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freemonoi.z b/vendor/tecnickcom/tcpdf/fonts/freemonoi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freesans.ctg.z b/vendor/tecnickcom/tcpdf/fonts/freesans.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freesans.php b/vendor/tecnickcom/tcpdf/fonts/freesans.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freesans.z b/vendor/tecnickcom/tcpdf/fonts/freesans.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freesansb.ctg.z b/vendor/tecnickcom/tcpdf/fonts/freesansb.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freesansb.php b/vendor/tecnickcom/tcpdf/fonts/freesansb.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freesansb.z b/vendor/tecnickcom/tcpdf/fonts/freesansb.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freesansbi.ctg.z b/vendor/tecnickcom/tcpdf/fonts/freesansbi.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freesansbi.php b/vendor/tecnickcom/tcpdf/fonts/freesansbi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freesansbi.z b/vendor/tecnickcom/tcpdf/fonts/freesansbi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freesansi.ctg.z b/vendor/tecnickcom/tcpdf/fonts/freesansi.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freesansi.php b/vendor/tecnickcom/tcpdf/fonts/freesansi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freesansi.z b/vendor/tecnickcom/tcpdf/fonts/freesansi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freeserif.ctg.z b/vendor/tecnickcom/tcpdf/fonts/freeserif.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freeserif.php b/vendor/tecnickcom/tcpdf/fonts/freeserif.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freeserif.z b/vendor/tecnickcom/tcpdf/fonts/freeserif.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freeserifb.ctg.z b/vendor/tecnickcom/tcpdf/fonts/freeserifb.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freeserifb.php b/vendor/tecnickcom/tcpdf/fonts/freeserifb.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freeserifb.z b/vendor/tecnickcom/tcpdf/fonts/freeserifb.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freeserifbi.ctg.z b/vendor/tecnickcom/tcpdf/fonts/freeserifbi.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freeserifbi.php b/vendor/tecnickcom/tcpdf/fonts/freeserifbi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freeserifbi.z b/vendor/tecnickcom/tcpdf/fonts/freeserifbi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freeserifi.ctg.z b/vendor/tecnickcom/tcpdf/fonts/freeserifi.ctg.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freeserifi.php b/vendor/tecnickcom/tcpdf/fonts/freeserifi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/freeserifi.z b/vendor/tecnickcom/tcpdf/fonts/freeserifi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/helvetica.php b/vendor/tecnickcom/tcpdf/fonts/helvetica.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/helveticab.php b/vendor/tecnickcom/tcpdf/fonts/helveticab.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/helveticabi.php b/vendor/tecnickcom/tcpdf/fonts/helveticabi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/helveticai.php b/vendor/tecnickcom/tcpdf/fonts/helveticai.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/hysmyeongjostdmedium.php b/vendor/tecnickcom/tcpdf/fonts/hysmyeongjostdmedium.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/kozgopromedium.php b/vendor/tecnickcom/tcpdf/fonts/kozgopromedium.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/kozminproregular.php b/vendor/tecnickcom/tcpdf/fonts/kozminproregular.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/msungstdlight.php b/vendor/tecnickcom/tcpdf/fonts/msungstdlight.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfacourier.php b/vendor/tecnickcom/tcpdf/fonts/pdfacourier.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfacourier.z b/vendor/tecnickcom/tcpdf/fonts/pdfacourier.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfacourierb.php b/vendor/tecnickcom/tcpdf/fonts/pdfacourierb.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfacourierb.z b/vendor/tecnickcom/tcpdf/fonts/pdfacourierb.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfacourierbi.php b/vendor/tecnickcom/tcpdf/fonts/pdfacourierbi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfacourierbi.z b/vendor/tecnickcom/tcpdf/fonts/pdfacourierbi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfacourieri.php b/vendor/tecnickcom/tcpdf/fonts/pdfacourieri.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfacourieri.z b/vendor/tecnickcom/tcpdf/fonts/pdfacourieri.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfahelvetica.php b/vendor/tecnickcom/tcpdf/fonts/pdfahelvetica.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfahelvetica.z b/vendor/tecnickcom/tcpdf/fonts/pdfahelvetica.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfahelveticab.php b/vendor/tecnickcom/tcpdf/fonts/pdfahelveticab.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfahelveticab.z b/vendor/tecnickcom/tcpdf/fonts/pdfahelveticab.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfahelveticabi.php b/vendor/tecnickcom/tcpdf/fonts/pdfahelveticabi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfahelveticabi.z b/vendor/tecnickcom/tcpdf/fonts/pdfahelveticabi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfahelveticai.php b/vendor/tecnickcom/tcpdf/fonts/pdfahelveticai.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfahelveticai.z b/vendor/tecnickcom/tcpdf/fonts/pdfahelveticai.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfasymbol.php b/vendor/tecnickcom/tcpdf/fonts/pdfasymbol.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfasymbol.z b/vendor/tecnickcom/tcpdf/fonts/pdfasymbol.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfatimes.php b/vendor/tecnickcom/tcpdf/fonts/pdfatimes.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfatimes.z b/vendor/tecnickcom/tcpdf/fonts/pdfatimes.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfatimesb.php b/vendor/tecnickcom/tcpdf/fonts/pdfatimesb.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfatimesb.z b/vendor/tecnickcom/tcpdf/fonts/pdfatimesb.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfatimesbi.php b/vendor/tecnickcom/tcpdf/fonts/pdfatimesbi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfatimesbi.z b/vendor/tecnickcom/tcpdf/fonts/pdfatimesbi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfatimesi.php b/vendor/tecnickcom/tcpdf/fonts/pdfatimesi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfatimesi.z b/vendor/tecnickcom/tcpdf/fonts/pdfatimesi.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfazapfdingbats.php b/vendor/tecnickcom/tcpdf/fonts/pdfazapfdingbats.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/pdfazapfdingbats.z b/vendor/tecnickcom/tcpdf/fonts/pdfazapfdingbats.z old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/stsongstdlight.php b/vendor/tecnickcom/tcpdf/fonts/stsongstdlight.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/symbol.php b/vendor/tecnickcom/tcpdf/fonts/symbol.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/times.php b/vendor/tecnickcom/tcpdf/fonts/times.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/timesb.php b/vendor/tecnickcom/tcpdf/fonts/timesb.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/timesbi.php b/vendor/tecnickcom/tcpdf/fonts/timesbi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/timesi.php b/vendor/tecnickcom/tcpdf/fonts/timesi.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/uni2cid_ac15.php b/vendor/tecnickcom/tcpdf/fonts/uni2cid_ac15.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/uni2cid_ag15.php b/vendor/tecnickcom/tcpdf/fonts/uni2cid_ag15.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/uni2cid_aj16.php b/vendor/tecnickcom/tcpdf/fonts/uni2cid_aj16.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/uni2cid_ak12.php b/vendor/tecnickcom/tcpdf/fonts/uni2cid_ak12.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/fonts/zapfdingbats.php b/vendor/tecnickcom/tcpdf/fonts/zapfdingbats.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/include/barcodes/datamatrix.php b/vendor/tecnickcom/tcpdf/include/barcodes/datamatrix.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/include/barcodes/pdf417.php b/vendor/tecnickcom/tcpdf/include/barcodes/pdf417.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/include/barcodes/qrcode.php b/vendor/tecnickcom/tcpdf/include/barcodes/qrcode.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/include/sRGB.icc b/vendor/tecnickcom/tcpdf/include/sRGB.icc old mode 100755 new mode 100644 index 71e33830223c4c05c61002462e13df02bb30ae02..1d8f7419c3bf2c6a3dd78f2c679fdefbda1776a3 Binary files a/vendor/tecnickcom/tcpdf/include/sRGB.icc and b/vendor/tecnickcom/tcpdf/include/sRGB.icc differ diff --git a/vendor/tecnickcom/tcpdf/include/tcpdf_colors.php b/vendor/tecnickcom/tcpdf/include/tcpdf_colors.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/include/tcpdf_filters.php b/vendor/tecnickcom/tcpdf/include/tcpdf_filters.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/include/tcpdf_font_data.php b/vendor/tecnickcom/tcpdf/include/tcpdf_font_data.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/include/tcpdf_fonts.php b/vendor/tecnickcom/tcpdf/include/tcpdf_fonts.php old mode 100755 new mode 100644 index ba89c7cfbededee98f6d55380e72c409cae61102..9242ca4bfdb5290c47f0a10f8694bbd4673e51df --- a/vendor/tecnickcom/tcpdf/include/tcpdf_fonts.php +++ b/vendor/tecnickcom/tcpdf/include/tcpdf_fonts.php @@ -70,7 +70,7 @@ class TCPDF_FONTS { * @public static */ public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $outpath='', $platid=3, $encid=1, $addcbbox=false, $link=false) { - if (!file_exists($fontfile)) { + if (!TCPDF_STATIC::file_exists($fontfile)) { // Could not find file return false; } @@ -95,7 +95,7 @@ class TCPDF_FONTS { $outpath = self::_getfontpath(); } // check if this font already exist - if (@file_exists($outpath.$font_name.'.php')) { + if (@TCPDF_STATIC::file_exists($outpath.$font_name.'.php')) { // this font already exist (delete it from fonts folder to rebuild it) return $font_name; } @@ -1543,11 +1543,11 @@ class TCPDF_FONTS { public static function getFontFullPath($file, $fontdir=false) { $fontfile = ''; // search files on various directories - if (($fontdir !== false) AND @file_exists($fontdir.$file)) { + if (($fontdir !== false) AND @TCPDF_STATIC::file_exists($fontdir.$file)) { $fontfile = $fontdir.$file; - } elseif (@file_exists(self::_getfontpath().$file)) { + } elseif (@TCPDF_STATIC::file_exists(self::_getfontpath().$file)) { $fontfile = self::_getfontpath().$file; - } elseif (@file_exists($file)) { + } elseif (@TCPDF_STATIC::file_exists($file)) { $fontfile = $file; } return $fontfile; @@ -2003,7 +2003,11 @@ class TCPDF_FONTS { $chars = str_split($str); $carr = array_map('ord', $chars); } - $currentfont['subsetchars'] += array_fill_keys($carr, true); + if (is_array($currentfont['subsetchars']) && is_array($carr)) { + $currentfont['subsetchars'] += array_fill_keys($carr, true); + } else { + $currentfont['subsetchars'] = array_merge($currentfont['subsetchars'], $carr); + } return $carr; } diff --git a/vendor/tecnickcom/tcpdf/include/tcpdf_images.php b/vendor/tecnickcom/tcpdf/include/tcpdf_images.php old mode 100755 new mode 100644 index c2e3c36f9305814184940f7adc689dcf32c74d77..86b3c20dbd8b55321c12fffb04f39b8923a248ca --- a/vendor/tecnickcom/tcpdf/include/tcpdf_images.php +++ b/vendor/tecnickcom/tcpdf/include/tcpdf_images.php @@ -161,12 +161,8 @@ class TCPDF_IMAGES { */ public static function _parsejpeg($file) { // check if is a local file - if (!@file_exists($file)) { - // try to encode spaces on filename - $tfile = str_replace(' ', '%20', $file); - if (@file_exists($tfile)) { - $file = $tfile; - } + if (!@TCPDF_STATIC::file_exists($file)) { + return false; } $a = getimagesize($file); if (empty($a)) { diff --git a/vendor/tecnickcom/tcpdf/include/tcpdf_static.php b/vendor/tecnickcom/tcpdf/include/tcpdf_static.php old mode 100755 new mode 100644 index aa42c850a27454f7bc1d5173b1afbbd5ae52d6bf..df1b28e1ef87467a9f3bee38b58556802d488fc6 --- a/vendor/tecnickcom/tcpdf/include/tcpdf_static.php +++ b/vendor/tecnickcom/tcpdf/include/tcpdf_static.php @@ -55,7 +55,7 @@ class TCPDF_STATIC { * Current TCPDF version. * @private static */ - private static $tcpdf_version = '6.2.17'; + private static $tcpdf_version = '6.2.26'; /** * String alias for total number of pages. @@ -1774,39 +1774,6 @@ class TCPDF_STATIC { return $angle; } - - - - - - - - - - - - - - - - -// ==================================================================================================================== -// REIMPLEMENTED -// ==================================================================================================================== - - - - - - - - - - - - - - /** * Split string by a regular expression. * This is a wrapper for the preg_split function to avoid the bug: https://bugs.php.net/bug.php?id=45850 @@ -1854,6 +1821,49 @@ class TCPDF_STATIC { return fopen($filename, $mode); } + /** + * Check if the URL exist. + * @param url (string) URL to check. + * @return Returns TRUE if the URL exists; FALSE otherwise. + * @public static + */ + public static function url_exists($url) { + $crs = curl_init(); + curl_setopt($crs, CURLOPT_URL, $url); + curl_setopt($crs, CURLOPT_NOBODY, true); + curl_setopt($crs, CURLOPT_FAILONERROR, true); + if ((ini_get('open_basedir') == '') && (!ini_get('safe_mode'))) { + curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true); + } + curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5); + curl_setopt($crs, CURLOPT_TIMEOUT, 30); + curl_setopt($crs, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($crs, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($crs, CURLOPT_USERAGENT, 'tc-lib-file'); + curl_exec($crs); + $code = curl_getinfo($crs, CURLINFO_HTTP_CODE); + curl_close($crs); + return ($code == 200); + } + + /** + * Wrapper for file_exists. + * Checks whether a file or directory exists. + * Only allows some protocols and local files. + * @param filename (string) Path to the file or directory. + * @return Returns TRUE if the file or directory specified by filename exists; FALSE otherwise. + * @public static + */ + public static function file_exists($filename) { + if (preg_match('|^https?://|', $filename) == 1) { + return self::url_exists($filename); + } + if (strpos($filename, '://')) { + return false; // only support http and https wrappers for security reasons + } + return @file_exists($filename); + } + /** * Reads entire file into a string. * The file can be also an URL. @@ -1914,8 +1924,10 @@ class TCPDF_STATIC { } // $alt = array_unique($alt); - //var_dump($alt);exit;//DEBUG foreach ($alt as $path) { + if (!self::file_exists($path)) { + return false; + } $ret = @file_get_contents($path); if ($ret !== false) { return $ret; @@ -1949,8 +1961,6 @@ class TCPDF_STATIC { return false; } - - /** * Get ULONG from string (Big Endian 32-bit unsigned integer). * @param $str (string) string from where to extract value diff --git a/vendor/tecnickcom/tcpdf/tcpdf.php b/vendor/tecnickcom/tcpdf/tcpdf.php old mode 100755 new mode 100644 index ef411a17dee3a16cdb369e76e45b8e449ed0e089..24ef434ab8a58523e06289e1a46b3647f69c2ac8 --- a/vendor/tecnickcom/tcpdf/tcpdf.php +++ b/vendor/tecnickcom/tcpdf/tcpdf.php @@ -1,13 +1,13 @@ <?php //============================================================+ // File name : tcpdf.php -// Version : 6.2.13 +// Version : 6.2.26 // Begin : 2002-08-03 -// Last Update : 2015-06-18 +// Last Update : 2018-09-14 // Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com // License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html) // ------------------------------------------------------------------- -// Copyright (C) 2002-2015 Nicola Asuni - Tecnick.com LTD +// Copyright (C) 2002-2018 Nicola Asuni - Tecnick.com LTD // // This file is part of TCPDF software library. // @@ -104,7 +104,7 @@ * Tools to encode your unicode fonts are on fonts/utils directory.</p> * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 6.2.8 + * @version 6.2.26 */ // TCPDF configuration @@ -128,8 +128,11 @@ require_once(dirname(__FILE__).'/include/tcpdf_static.php'); * TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br> * @package com.tecnick.tcpdf * @brief PHP class for generating PDF documents without requiring external extensions. - * @version 6.2.8 + * @version 6.2.26 * @author Nicola Asuni - info@tecnick.com + * @IgnoreAnnotation("protected") + * @IgnoreAnnotation("public") + * @IgnoreAnnotation("pre") */ class TCPDF { @@ -1994,10 +1997,6 @@ class TCPDF { * @since 1.53.0.TC016 */ public function __destruct() { - // restore internal encoding - if (isset($this->internal_encoding) AND !empty($this->internal_encoding)) { - mb_internal_encoding($this->internal_encoding); - } // cleanup $this->_destroy(true); } @@ -4257,7 +4256,7 @@ class TCPDF { // true when the font style variation is missing $missing_style = false; // search and include font file - if (TCPDF_STATIC::empty_string($fontfile) OR (!@file_exists($fontfile))) { + if (TCPDF_STATIC::empty_string($fontfile) OR (!@TCPDF_STATIC::file_exists($fontfile))) { // build a standard filenames for specified font $tmp_fontfile = str_replace(' ', '', $family).strtolower($style).'.php'; $fontfile = TCPDF_FONTS::getFontFullPath($tmp_fontfile, $fontdir); @@ -4269,7 +4268,7 @@ class TCPDF { } } // include font file - if (!TCPDF_STATIC::empty_string($fontfile) AND (@file_exists($fontfile))) { + if (!TCPDF_STATIC::empty_string($fontfile) AND (@TCPDF_STATIC::file_exists($fontfile))) { include($fontfile); } else { $this->Error('Could not include font definition file: '.$family.''); @@ -4453,6 +4452,7 @@ class TCPDF { * @see SetFont() */ public function SetFontSize($size, $out=true) { + $size = (float)$size; // font size in points $this->FontSizePt = $size; // font size in user units @@ -4809,19 +4809,19 @@ class TCPDF { $this->PageAnnots[$page][] = array('n' => ++$this->n, 'x' => $x, 'y' => $y, 'w' => $w, 'h' => $h, 'txt' => $text, 'opt' => $opt, 'numspaces' => $spaces); if (!$this->pdfa_mode) { if ((($opt['Subtype'] == 'FileAttachment') OR ($opt['Subtype'] == 'Sound')) AND (!TCPDF_STATIC::empty_string($opt['FS'])) - AND (@file_exists($opt['FS']) OR TCPDF_STATIC::isValidURL($opt['FS'])) + AND (@TCPDF_STATIC::file_exists($opt['FS']) OR TCPDF_STATIC::isValidURL($opt['FS'])) AND (!isset($this->embeddedfiles[basename($opt['FS'])]))) { $this->embeddedfiles[basename($opt['FS'])] = array('f' => ++$this->n, 'n' => ++$this->n, 'file' => $opt['FS']); } } // Add widgets annotation's icons - if (isset($opt['mk']['i']) AND @file_exists($opt['mk']['i'])) { + if (isset($opt['mk']['i']) AND @TCPDF_STATIC::file_exists($opt['mk']['i'])) { $this->Image($opt['mk']['i'], '', '', 10, 10, '', '', '', false, 300, '', false, false, 0, false, true); } - if (isset($opt['mk']['ri']) AND @file_exists($opt['mk']['ri'])) { + if (isset($opt['mk']['ri']) AND @TCPDF_STATIC::file_exists($opt['mk']['ri'])) { $this->Image($opt['mk']['ri'], '', '', 0, 0, '', '', '', false, 300, '', false, false, 0, false, true); } - if (isset($opt['mk']['ix']) AND @file_exists($opt['mk']['ix'])) { + if (isset($opt['mk']['ix']) AND @TCPDF_STATIC::file_exists($opt['mk']['ix'])) { $this->Image($opt['mk']['ix'], '', '', 0, 0, '', '', '', false, 300, '', false, false, 0, false, true); } } @@ -5769,10 +5769,9 @@ class TCPDF { $this->resetLastH(); } if (!TCPDF_STATIC::empty_string($y)) { - $this->SetY($y); - } else { - $y = $this->GetY(); + $this->SetY($y); // set y in order to convert negative y values to positive ones } + $y = $this->GetY(); $resth = 0; if (($h > 0) AND $this->inPageBody() AND (($y + $h + $mc_margin['T'] + $mc_margin['B']) > $this->PageBreakTrigger)) { // spit cell in more pages/columns @@ -6845,13 +6844,9 @@ class TCPDF { $file = substr($file, 1); $exurl = $file; } - // check if is a local file - if (!@file_exists($file)) { - // try to encode spaces on filename - $tfile = str_replace(' ', '%20', $file); - if (@file_exists($tfile)) { - $file = $tfile; - } + // check if file exist and it is valid + if (!@TCPDF_STATIC::file_exists($file)) { + return false; } if (($imsize = @getimagesize($file)) === FALSE) { if (in_array($file, $this->imagekeys)) { @@ -7750,6 +7745,10 @@ class TCPDF { * @since 4.5.016 (2009-02-24) */ public function _destroy($destroyall=false, $preserve_objcopy=false) { + // restore internal encoding + if (isset($this->internal_encoding) AND !empty($this->internal_encoding)) { + mb_internal_encoding($this->internal_encoding); + } if ($destroyall AND !$preserve_objcopy) { // remove all temporary files $tmpfiles = glob(K_PATH_CACHE.'__tcpdf_'.$this->file_id.'_*'); @@ -9648,7 +9647,7 @@ class TCPDF { protected function _putcatalog() { // put XMP $xmpobj = $this->_putXMP(); - // if required, add standard sRGB_IEC61966-2.1 blackscaled ICC colour profile + // if required, add standard sRGB ICC colour profile if ($this->pdfa_mode OR $this->force_srgb) { $iccobj = $this->_newobj(); $icc = file_get_contents(dirname(__FILE__).'/include/sRGB.icc'); @@ -17783,7 +17782,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: // justify block if (!TCPDF_STATIC::empty_string($this->lispacer)) { $this->lispacer = ''; - continue; + break; } preg_match('/([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]([0-9\.\+\-]*)[\s]('.$strpiece[1][0].')[\s](re)([\s]*)/x', $pmid, $xmatches); if (!isset($xmatches[1])) { @@ -18318,7 +18317,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: } // text $this->htmlvspace = 0; - if ((!$this->premode) AND $this->isRTLTextDir()) { + $isRTLString = preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_RTL, $dom[$key]['value']) || preg_match(TCPDF_FONT_DATA::$uni_RE_PATTERN_ARABIC, $dom[$key]['value']); + if ((!$this->premode) AND $this->isRTLTextDir() AND !$isRTLString) { // reverse spaces order $lsp = ''; // left spaces $rsp = ''; // right spaces @@ -18333,7 +18333,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: if ($newline) { if (!$this->premode) { $prelen = strlen($dom[$key]['value']); - if ($this->isRTLTextDir()) { + if ($this->isRTLTextDir() AND !$isRTLString) { // right trim except non-breaking space $dom[$key]['value'] = $this->stringRightTrim($dom[$key]['value']); } else { @@ -18817,100 +18817,122 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: break; } case 'img': { - if (!empty($tag['attribute']['src'])) { - if ($tag['attribute']['src'][0] === '@') { - // data stream - $tag['attribute']['src'] = '@'.base64_decode(substr($tag['attribute']['src'], 1)); - $type = ''; - } else { - // get image type - $type = TCPDF_IMAGES::getImageFileType($tag['attribute']['src']); - } - if (!isset($tag['width'])) { - $tag['width'] = 0; - } - if (!isset($tag['height'])) { - $tag['height'] = 0; - } - //if (!isset($tag['attribute']['align'])) { - // the only alignment supported is "bottom" - // further development is required for other modes. - $tag['attribute']['align'] = 'bottom'; - //} - switch($tag['attribute']['align']) { - case 'top': { - $align = 'T'; - break; - } - case 'middle': { - $align = 'M'; - break; - } - case 'bottom': { - $align = 'B'; - break; + if (empty($tag['attribute']['src'])) { + break; + } + $imgsrc = $tag['attribute']['src']; + if ($imgsrc[0] === '@') { + // data stream + $imgsrc = '@'.base64_decode(substr($imgsrc, 1)); + $type = ''; + } else { + if (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) { + // fix image path + $findroot = strpos($imgsrc, $_SERVER['DOCUMENT_ROOT']); + if (($findroot === false) OR ($findroot > 1)) { + if (substr($_SERVER['DOCUMENT_ROOT'], -1) == '/') { + $imgsrc = substr($_SERVER['DOCUMENT_ROOT'], 0, -1).$imgsrc; + } else { + $imgsrc = $_SERVER['DOCUMENT_ROOT'].$imgsrc; + } } - default: { - $align = 'B'; - break; + $imgsrc = urldecode($imgsrc); + $testscrtype = @parse_url($imgsrc); + if (empty($testscrtype['query'])) { + // convert URL to server path + $imgsrc = str_replace(K_PATH_URL, K_PATH_MAIN, $imgsrc); + } elseif (preg_match('|^https?://|', $imgsrc) !== 1) { + // convert URL to server path + $imgsrc = str_replace(K_PATH_MAIN, K_PATH_URL, $imgsrc); } } - $prevy = $this->y; - $xpos = $this->x; - $imglink = ''; - if (isset($this->HREF['url']) AND !TCPDF_STATIC::empty_string($this->HREF['url'])) { - $imglink = $this->HREF['url']; - if ($imglink[0] == '#') { - // convert url to internal link - $lnkdata = explode(',', $imglink); - if (isset($lnkdata[0])) { - $page = intval(substr($lnkdata[0], 1)); - if (empty($page) OR ($page <= 0)) { - $page = $this->page; - } - if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) { - $lnky = floatval($lnkdata[1]); - } else { - $lnky = 0; - } - $imglink = $this->AddLink(); - $this->SetLink($imglink, $lnky, $page); + // get image type + $type = TCPDF_IMAGES::getImageFileType($imgsrc); + } + if (!isset($tag['width'])) { + $tag['width'] = 0; + } + if (!isset($tag['height'])) { + $tag['height'] = 0; + } + //if (!isset($tag['attribute']['align'])) { + // the only alignment supported is "bottom" + // further development is required for other modes. + $tag['attribute']['align'] = 'bottom'; + //} + switch($tag['attribute']['align']) { + case 'top': { + $align = 'T'; + break; + } + case 'middle': { + $align = 'M'; + break; + } + case 'bottom': { + $align = 'B'; + break; + } + default: { + $align = 'B'; + break; + } + } + $prevy = $this->y; + $xpos = $this->x; + $imglink = ''; + if (isset($this->HREF['url']) AND !TCPDF_STATIC::empty_string($this->HREF['url'])) { + $imglink = $this->HREF['url']; + if ($imglink[0] == '#') { + // convert url to internal link + $lnkdata = explode(',', $imglink); + if (isset($lnkdata[0])) { + $page = intval(substr($lnkdata[0], 1)); + if (empty($page) OR ($page <= 0)) { + $page = $this->page; + } + if (isset($lnkdata[1]) AND (strlen($lnkdata[1]) > 0)) { + $lnky = floatval($lnkdata[1]); + } else { + $lnky = 0; } + $imglink = $this->AddLink(); + $this->SetLink($imglink, $lnky, $page); } } - $border = 0; - if (isset($tag['border']) AND !empty($tag['border'])) { - // currently only support 1 (frame) or a combination of 'LTRB' - $border = $tag['border']; - } - $iw = ''; - if (isset($tag['width'])) { - $iw = $this->getHTMLUnitToUnits($tag['width'], ($tag['fontsize'] / $this->k), 'px', false); - } - $ih = ''; - if (isset($tag['height'])) { - $ih = $this->getHTMLUnitToUnits($tag['height'], ($tag['fontsize'] / $this->k), 'px', false); - } - if (($type == 'eps') OR ($type == 'ai')) { - $this->ImageEps($tag['attribute']['src'], $xpos, $this->y, $iw, $ih, $imglink, true, $align, '', $border, true); - } elseif ($type == 'svg') { - $this->ImageSVG($tag['attribute']['src'], $xpos, $this->y, $iw, $ih, $imglink, $align, '', $border, true); - } else { - $this->Image($tag['attribute']['src'], $xpos, $this->y, $iw, $ih, '', $imglink, $align, false, 300, '', false, false, $border, false, false, true); + } + $border = 0; + if (isset($tag['border']) AND !empty($tag['border'])) { + // currently only support 1 (frame) or a combination of 'LTRB' + $border = $tag['border']; + } + $iw = ''; + if (isset($tag['width'])) { + $iw = $this->getHTMLUnitToUnits($tag['width'], ($tag['fontsize'] / $this->k), 'px', false); + } + $ih = ''; + if (isset($tag['height'])) { + $ih = $this->getHTMLUnitToUnits($tag['height'], ($tag['fontsize'] / $this->k), 'px', false); + } + if (($type == 'eps') OR ($type == 'ai')) { + $this->ImageEps($imgsrc, $xpos, $this->y, $iw, $ih, $imglink, true, $align, '', $border, true); + } elseif ($type == 'svg') { + $this->ImageSVG($imgsrc, $xpos, $this->y, $iw, $ih, $imglink, $align, '', $border, true); + } else { + $this->Image($imgsrc, $xpos, $this->y, $iw, $ih, '', $imglink, $align, false, 300, '', false, false, $border, false, false, true); + } + switch($align) { + case 'T': { + $this->y = $prevy; + break; } - switch($align) { - case 'T': { - $this->y = $prevy; - break; - } - case 'M': { - $this->y = (($this->img_rb_y + $prevy - ($this->getCellHeight($tag['fontsize'] / $this->k))) / 2); - break; - } - case 'B': { - $this->y = $this->img_rb_y - ($this->getCellHeight($tag['fontsize'] / $this->k) - ($this->getFontDescent($tag['fontname'], $tag['fontstyle'], $tag['fontsize']) * $this->cell_height_ratio)); - break; - } + case 'M': { + $this->y = (($this->img_rb_y + $prevy - ($this->getCellHeight($tag['fontsize'] / $this->k))) / 2); + break; + } + case 'B': { + $this->y = $this->img_rb_y - ($this->getCellHeight($tag['fontsize'] / $this->k) - ($this->getFontDescent($tag['fontname'], $tag['fontstyle'], $tag['fontsize']) * $this->cell_height_ratio)); + break; } } break; @@ -24206,9 +24228,12 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: } $img = urldecode($img); $testscrtype = @parse_url($img); - if (!isset($testscrtype['query']) OR empty($testscrtype['query'])) { + if (empty($testscrtype['query'])) { // convert URL to server path $img = str_replace(K_PATH_URL, K_PATH_MAIN, $img); + } elseif (preg_match('|^https?://|', $img) !== 1) { + // convert server path to URL + $img = str_replace(K_PATH_MAIN, K_PATH_URL, $img); } } // get image type diff --git a/vendor/tecnickcom/tcpdf/tcpdf_autoconfig.php b/vendor/tecnickcom/tcpdf/tcpdf_autoconfig.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/tcpdf_barcodes_1d.php b/vendor/tecnickcom/tcpdf/tcpdf_barcodes_1d.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/tcpdf_barcodes_2d.php b/vendor/tecnickcom/tcpdf/tcpdf_barcodes_2d.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/tcpdf_import.php b/vendor/tecnickcom/tcpdf/tcpdf_import.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/tcpdf_parser.php b/vendor/tecnickcom/tcpdf/tcpdf_parser.php old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/tools/.htaccess b/vendor/tecnickcom/tcpdf/tools/.htaccess old mode 100755 new mode 100644 diff --git a/vendor/tecnickcom/tcpdf/tools/convert_fonts_examples.txt b/vendor/tecnickcom/tcpdf/tools/convert_fonts_examples.txt old mode 100755 new mode 100644 diff --git a/vendor/zf1/zend-exception/LICENSE.txt b/vendor/zf1/zend-exception/LICENSE.txt deleted file mode 100755 index 6eab5aa14fd421059dfecada369abb8dd79c8a48..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-exception/LICENSE.txt +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2005-2015, Zend Technologies USA, Inc. -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. - - * Neither the name of Zend Technologies USA, Inc. nor the names of its - 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 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/zf1/zend-exception/README.md b/vendor/zf1/zend-exception/README.md deleted file mode 100755 index 6ae9e0346a71ba5c5a0d946435375cbbe43f9514..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-exception/README.md +++ /dev/null @@ -1,22 +0,0 @@ -Zend Framework 1 for Composer -============================= - -This package is a part of the Zend Framework 1. Each component was separated and put into its own composer package. Some modifications were made for improved [Composer](http://getcomposer.org/) integration. This package can also be found at [Packagist](http://packagist.org/packages/zf1). - -## Why? - -**Size!** Zend Framework is very large and contains a huge amount of files (over 72000 files in the main repository!). If you're only using a part of the framework, using the separated packages will greatly reduce the amount of files. This will make setup faster and easier on your disks. - -**Autoloading!** Explicit `require_once` calls in the source code has been commented out to rely on composer autoloading, this reduces the number of included files to a minimum. - -**Migration!** Zend Framework 2 has been around for a while now, and migrating all your projects takes a lot of time. Using these packages makes it easier to migrate each component separately. Also, some packages doesn't exist in zf2 (such as the zend-search-lucene), now you can continue using that package without requiring the entire framework. - -If you're using major parts of the framework, I would recommend checking out the [zendframework1 package](https://github.com/bombayworks/zendframework1), which contains the entire framework optimized for composer usage. - -## How to use - -Add `"zf1/zend-exception": "~1.12"` to the require section of your composer.json, include the composer autoloader and you're good to go. - -## Broken dependencies? - -Dependencies have been set automatically based on the [requirements from the zend framework manual](http://framework.zend.com/manual/1.12/en/requirements.introduction.html), if you find any broken dependencies please submit an issue. \ No newline at end of file diff --git a/vendor/zf1/zend-exception/composer.json b/vendor/zf1/zend-exception/composer.json deleted file mode 100755 index 831089ac95457ae282266de3be7faac896640b06..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-exception/composer.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "zf1/zend-exception", - "description": "Zend Framework 1 Exception package", - "keywords": [ - "framework", - "zf1", - "zend", - "exception" - ], - "homepage": "http://framework.zend.com/", - "license": "BSD-3-Clause", - "require": { - "php": ">=5.2.11" - }, - "autoload": { - "psr-0": { - "Zend_Exception": "library/" - } - } -} \ No newline at end of file diff --git a/vendor/zf1/zend-exception/library/Zend/Exception.php b/vendor/zf1/zend-exception/library/Zend/Exception.php deleted file mode 100755 index d97acb0f92cd5b4899791bdf7f53cbce9f52e60d..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-exception/library/Zend/Exception.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** -* @category Zend -* @package Zend -* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) -* @license http://framework.zend.com/license/new-bsd New BSD License -*/ -class Zend_Exception extends Exception -{ - /** - * @var null|Exception - */ - private $_previous = null; - - /** - * Construct the exception - * - * @param string $msg - * @param int $code - * @param Exception $previous - * @return void - */ - public function __construct($msg = '', $code = 0, Exception $previous = null) - { - if (version_compare(PHP_VERSION, '5.3.0', '<')) { - parent::__construct($msg, (int) $code); - $this->_previous = $previous; - } else { - parent::__construct($msg, (int) $code, $previous); - } - } - - /** - * Overloading - * - * For PHP < 5.3.0, provides access to the getPrevious() method. - * - * @param string $method - * @param array $args - * @return mixed - */ - public function __call($method, array $args) - { - if ('getprevious' == strtolower($method)) { - return $this->_getPrevious(); - } - return null; - } - - /** - * String representation of the exception - * - * @return string - */ - public function __toString() - { - if (version_compare(PHP_VERSION, '5.3.0', '<')) { - if (null !== ($e = $this->getPrevious())) { - return $e->__toString() - . "\n\nNext " - . parent::__toString(); - } - } - return parent::__toString(); - } - - /** - * Returns previous Exception - * - * @return Exception|null - */ - protected function _getPrevious() - { - return $this->_previous; - } -} diff --git a/vendor/zf1/zend-search-lucene/LICENSE.txt b/vendor/zf1/zend-search-lucene/LICENSE.txt deleted file mode 100755 index 6eab5aa14fd421059dfecada369abb8dd79c8a48..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/LICENSE.txt +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2005-2015, Zend Technologies USA, Inc. -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. - - * Neither the name of Zend Technologies USA, Inc. nor the names of its - 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 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/zf1/zend-search-lucene/README.md b/vendor/zf1/zend-search-lucene/README.md deleted file mode 100755 index a438cb7ccda87bb386f62b7cdddef5058a301767..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/README.md +++ /dev/null @@ -1,22 +0,0 @@ -Zend Framework 1 for Composer -============================= - -This package is a part of the Zend Framework 1. Each component was separated and put into its own composer package. Some modifications were made for improved [Composer](http://getcomposer.org/) integration. This package can also be found at [Packagist](http://packagist.org/packages/zf1). - -## Why? - -**Size!** Zend Framework is very large and contains a huge amount of files (over 72000 files in the main repository!). If you're only using a part of the framework, using the separated packages will greatly reduce the amount of files. This will make setup faster and easier on your disks. - -**Autoloading!** Explicit `require_once` calls in the source code has been commented out to rely on composer autoloading, this reduces the number of included files to a minimum. - -**Migration!** Zend Framework 2 has been around for a while now, and migrating all your projects takes a lot of time. Using these packages makes it easier to migrate each component separately. Also, some packages doesn't exist in zf2 (such as the zend-search-lucene), now you can continue using that package without requiring the entire framework. - -If you're using major parts of the framework, I would recommend checking out the [zendframework1 package](https://github.com/bombayworks/zendframework1), which contains the entire framework optimized for composer usage. - -## How to use - -Add `"zf1/zend-search-lucene": "~1.12"` to the require section of your composer.json, include the composer autoloader and you're good to go. - -## Broken dependencies? - -Dependencies have been set automatically based on the [requirements from the zend framework manual](http://framework.zend.com/manual/1.12/en/requirements.introduction.html), if you find any broken dependencies please submit an issue. \ No newline at end of file diff --git a/vendor/zf1/zend-search-lucene/composer.json b/vendor/zf1/zend-search-lucene/composer.json deleted file mode 100755 index 62e13dd6dc8b528066a73e140f3550dd19fbf0dc..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/composer.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "zf1/zend-search-lucene", - "description": "Zend Framework 1 Search Lucene package", - "keywords": [ - "framework", - "zf1", - "zend", - "search", - "lucene" - ], - "homepage": "http://framework.zend.com/", - "license": "BSD-3-Clause", - "require": { - "php": ">=5.2.11", - "zf1/zend-exception": "self.version", - "zf1/zend-search": "self.version", - "zf1/zend-xml": "self.version" - }, - "autoload": { - "psr-0": { - "Zend_Search_Lucene": "library/" - } - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene.php deleted file mode 100755 index 60ca962e2d2c3d9658dc47649a0590546ebd1894..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene.php +++ /dev/null @@ -1,1579 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** User land classes and interfaces turned on by Zend/Search/Lucene.php file inclusion. */ -/** @todo Section should be removed with ZF 2.0 release as obsolete */ - -/** Zend_Search_Lucene_Document_Html */ -// require_once 'Zend/Search/Lucene/Document/Html.php'; - -/** Zend_Search_Lucene_Document_Docx */ -// require_once 'Zend/Search/Lucene/Document/Docx.php'; - -/** Zend_Search_Lucene_Document_Pptx */ -// require_once 'Zend/Search/Lucene/Document/Pptx.php'; - -/** Zend_Search_Lucene_Document_Xlsx */ -// require_once 'Zend/Search/Lucene/Document/Xlsx.php'; - -/** Zend_Search_Lucene_Search_QueryParser */ -// require_once 'Zend/Search/Lucene/Search/QueryParser.php'; - -/** Zend_Search_Lucene_Search_QueryHit */ -// require_once 'Zend/Search/Lucene/Search/QueryHit.php'; - -/** Zend_Search_Lucene_Analysis_Analyzer */ -// require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - -/** Zend_Search_Lucene_Search_Query_Term */ -// require_once 'Zend/Search/Lucene/Search/Query/Term.php'; - -/** Zend_Search_Lucene_Search_Query_Phrase */ -// require_once 'Zend/Search/Lucene/Search/Query/Phrase.php'; - -/** Zend_Search_Lucene_Search_Query_MultiTerm */ -// require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php'; - -/** Zend_Search_Lucene_Search_Query_Wildcard */ -// require_once 'Zend/Search/Lucene/Search/Query/Wildcard.php'; - -/** Zend_Search_Lucene_Search_Query_Range */ -// require_once 'Zend/Search/Lucene/Search/Query/Range.php'; - -/** Zend_Search_Lucene_Search_Query_Fuzzy */ -// require_once 'Zend/Search/Lucene/Search/Query/Fuzzy.php'; - -/** Zend_Search_Lucene_Search_Query_Boolean */ -// require_once 'Zend/Search/Lucene/Search/Query/Boolean.php'; - -/** Zend_Search_Lucene_Search_Query_Empty */ -// require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - -/** Zend_Search_Lucene_Search_Query_Insignificant */ -// require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php'; - - - - -/** Internally used classes */ - -/** Zend_Search_Lucene_Interface */ -// require_once 'Zend/Search/Lucene/Interface.php'; - -/** Zend_Search_Lucene_Index_SegmentInfo */ -// require_once 'Zend/Search/Lucene/Index/SegmentInfo.php'; - -/** Zend_Search_Lucene_LockManager */ -// require_once 'Zend/Search/Lucene/LockManager.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene implements Zend_Search_Lucene_Interface -{ - /** - * Default field name for search - * - * Null means search through all fields - * - * @var string - */ - private static $_defaultSearchField = null; - - /** - * Result set limit - * - * 0 means no limit - * - * @var integer - */ - private static $_resultSetLimit = 0; - - /** - * Terms per query limit - * - * 0 means no limit - * - * @var integer - */ - private static $_termsPerQueryLimit = 1024; - - /** - * File system adapter. - * - * @var Zend_Search_Lucene_Storage_Directory - */ - private $_directory = null; - - /** - * File system adapter closing option - * - * @var boolean - */ - private $_closeDirOnExit = true; - - /** - * Writer for this index, not instantiated unless required. - * - * @var Zend_Search_Lucene_Index_Writer - */ - private $_writer = null; - - /** - * Array of Zend_Search_Lucene_Index_SegmentInfo objects for current version of index. - * - * @var array Zend_Search_Lucene_Index_SegmentInfo - */ - private $_segmentInfos = array(); - - /** - * Number of documents in this index. - * - * @var integer - */ - private $_docCount = 0; - - /** - * Flag for index changes - * - * @var boolean - */ - private $_hasChanges = false; - - - /** - * Signal, that index is already closed, changes are fixed and resources are cleaned up - * - * @var boolean - */ - private $_closed = false; - - /** - * Number of references to the index object - * - * @var integer - */ - private $_refCount = 0; - - /** - * Current segment generation - * - * @var integer - */ - private $_generation; - - const FORMAT_PRE_2_1 = 0; - const FORMAT_2_1 = 1; - const FORMAT_2_3 = 2; - - - /** - * Index format version - * - * @var integer - */ - private $_formatVersion; - - /** - * Create index - * - * @param mixed $directory - * @return Zend_Search_Lucene_Interface - */ - public static function create($directory) - { - /** Zend_Search_Lucene_Proxy */ - // require_once 'Zend/Search/Lucene/Proxy.php'; - - return new Zend_Search_Lucene_Proxy(new Zend_Search_Lucene($directory, true)); - } - - /** - * Open index - * - * @param mixed $directory - * @return Zend_Search_Lucene_Interface - */ - public static function open($directory) - { - /** Zend_Search_Lucene_Proxy */ - // require_once 'Zend/Search/Lucene/Proxy.php'; - - return new Zend_Search_Lucene_Proxy(new Zend_Search_Lucene($directory, false)); - } - - /** Generation retrieving counter */ - const GENERATION_RETRIEVE_COUNT = 10; - - /** Pause between generation retrieving attempts in milliseconds */ - const GENERATION_RETRIEVE_PAUSE = 50; - - /** - * Get current generation number - * - * Returns generation number - * 0 means pre-2.1 index format - * -1 means there are no segments files. - * - * @param Zend_Search_Lucene_Storage_Directory $directory - * @return integer - * @throws Zend_Search_Lucene_Exception - */ - public static function getActualGeneration(Zend_Search_Lucene_Storage_Directory $directory) - { - /** - * Zend_Search_Lucene uses segments.gen file to retrieve current generation number - * - * Apache Lucene index format documentation mentions this method only as a fallback method - * - * Nevertheless we use it according to the performance considerations - * - * @todo check if we can use some modification of Apache Lucene generation determination algorithm - * without performance problems - */ - - // require_once 'Zend/Search/Lucene/Exception.php'; - try { - for ($count = 0; $count < self::GENERATION_RETRIEVE_COUNT; $count++) { - // Try to get generation file - $genFile = $directory->getFileObject('segments.gen', false); - - $format = $genFile->readInt(); - if ($format != (int)0xFFFFFFFE) { - throw new Zend_Search_Lucene_Exception('Wrong segments.gen file format'); - } - - $gen1 = $genFile->readLong(); - $gen2 = $genFile->readLong(); - - if ($gen1 == $gen2) { - return $gen1; - } - - usleep(self::GENERATION_RETRIEVE_PAUSE * 1000); - } - - // All passes are failed - throw new Zend_Search_Lucene_Exception('Index is under processing now'); - } catch (Zend_Search_Lucene_Exception $e) { - if (strpos($e->getMessage(), 'is not readable') !== false) { - try { - // Try to open old style segments file - $segmentsFile = $directory->getFileObject('segments', false); - - // It's pre-2.1 index - return 0; - } catch (Zend_Search_Lucene_Exception $e) { - if (strpos($e->getMessage(), 'is not readable') !== false) { - return -1; - } else { - throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e); - } - } - } else { - throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e); - } - } - - return -1; - } - - /** - * Get generation number associated with this index instance - * - * The same generation number in pair with document number or query string - * guarantees to give the same result while index retrieving. - * So it may be used for search result caching. - * - * @return integer - */ - public function getGeneration() - { - return $this->_generation; - } - - - /** - * Get segments file name - * - * @param integer $generation - * @return string - */ - public static function getSegmentFileName($generation) - { - if ($generation == 0) { - return 'segments'; - } - - return 'segments_' . base_convert($generation, 10, 36); - } - - /** - * Get index format version - * - * @return integer - */ - public function getFormatVersion() - { - return $this->_formatVersion; - } - - /** - * Set index format version. - * Index is converted to this format at the nearest upfdate time - * - * @param int $formatVersion - * @throws Zend_Search_Lucene_Exception - */ - public function setFormatVersion($formatVersion) - { - if ($formatVersion != self::FORMAT_PRE_2_1 && - $formatVersion != self::FORMAT_2_1 && - $formatVersion != self::FORMAT_2_3) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Unsupported index format'); - } - - $this->_formatVersion = $formatVersion; - } - - /** - * Read segments file for pre-2.1 Lucene index format - * - * @throws Zend_Search_Lucene_Exception - */ - private function _readPre21SegmentsFile() - { - $segmentsFile = $this->_directory->getFileObject('segments'); - - $format = $segmentsFile->readInt(); - - if ($format != (int)0xFFFFFFFF) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Wrong segments file format'); - } - - // read version - $segmentsFile->readLong(); - - // read segment name counter - $segmentsFile->readInt(); - - $segments = $segmentsFile->readInt(); - - $this->_docCount = 0; - - // read segmentInfos - for ($count = 0; $count < $segments; $count++) { - $segName = $segmentsFile->readString(); - $segSize = $segmentsFile->readInt(); - $this->_docCount += $segSize; - - $this->_segmentInfos[$segName] = - new Zend_Search_Lucene_Index_SegmentInfo($this->_directory, - $segName, - $segSize); - } - - // Use 2.1 as a target version. Index will be reorganized at update time. - $this->_formatVersion = self::FORMAT_2_1; - } - - /** - * Read segments file - * - * @throws Zend_Search_Lucene_Exception - */ - private function _readSegmentsFile() - { - $segmentsFile = $this->_directory->getFileObject(self::getSegmentFileName($this->_generation)); - - $format = $segmentsFile->readInt(); - - if ($format == (int)0xFFFFFFFC) { - $this->_formatVersion = self::FORMAT_2_3; - } else if ($format == (int)0xFFFFFFFD) { - $this->_formatVersion = self::FORMAT_2_1; - } else { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Unsupported segments file format'); - } - - // read version - $segmentsFile->readLong(); - - // read segment name counter - $segmentsFile->readInt(); - - $segments = $segmentsFile->readInt(); - - $this->_docCount = 0; - - // read segmentInfos - for ($count = 0; $count < $segments; $count++) { - $segName = $segmentsFile->readString(); - $segSize = $segmentsFile->readInt(); - - // 2.1+ specific properties - $delGen = $segmentsFile->readLong(); - - if ($this->_formatVersion == self::FORMAT_2_3) { - $docStoreOffset = $segmentsFile->readInt(); - - if ($docStoreOffset != (int)0xFFFFFFFF) { - $docStoreSegment = $segmentsFile->readString(); - $docStoreIsCompoundFile = $segmentsFile->readByte(); - - $docStoreOptions = array('offset' => $docStoreOffset, - 'segment' => $docStoreSegment, - 'isCompound' => ($docStoreIsCompoundFile == 1)); - } else { - $docStoreOptions = null; - } - } else { - $docStoreOptions = null; - } - - $hasSingleNormFile = $segmentsFile->readByte(); - $numField = $segmentsFile->readInt(); - - $normGens = array(); - if ($numField != (int)0xFFFFFFFF) { - for ($count1 = 0; $count1 < $numField; $count1++) { - $normGens[] = $segmentsFile->readLong(); - } - - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Separate norm files are not supported. Optimize index to use it with Zend_Search_Lucene.'); - } - - $isCompoundByte = $segmentsFile->readByte(); - - if ($isCompoundByte == 0xFF) { - // The segment is not a compound file - $isCompound = false; - } else if ($isCompoundByte == 0x00) { - // The status is unknown - $isCompound = null; - } else if ($isCompoundByte == 0x01) { - // The segment is a compound file - $isCompound = true; - } - - $this->_docCount += $segSize; - - $this->_segmentInfos[$segName] = - new Zend_Search_Lucene_Index_SegmentInfo($this->_directory, - $segName, - $segSize, - $delGen, - $docStoreOptions, - $hasSingleNormFile, - $isCompound); - } - } - - /** - * Opens the index. - * - * IndexReader constructor needs Directory as a parameter. It should be - * a string with a path to the index folder or a Directory object. - * - * @param Zend_Search_Lucene_Storage_Directory_Filesystem|string $directory - * @throws Zend_Search_Lucene_Exception - */ - public function __construct($directory = null, $create = false) - { - if ($directory === null) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Exception('No index directory specified'); - } - - if (is_string($directory)) { - // require_once 'Zend/Search/Lucene/Storage/Directory/Filesystem.php'; - $this->_directory = new Zend_Search_Lucene_Storage_Directory_Filesystem($directory); - $this->_closeDirOnExit = true; - } else { - $this->_directory = $directory; - $this->_closeDirOnExit = false; - } - - $this->_segmentInfos = array(); - - // Mark index as "under processing" to prevent other processes from premature index cleaning - Zend_Search_Lucene_LockManager::obtainReadLock($this->_directory); - - $this->_generation = self::getActualGeneration($this->_directory); - - if ($create) { - // require_once 'Zend/Search/Lucene/Exception.php'; - try { - Zend_Search_Lucene_LockManager::obtainWriteLock($this->_directory); - } catch (Zend_Search_Lucene_Exception $e) { - Zend_Search_Lucene_LockManager::releaseReadLock($this->_directory); - - if (strpos($e->getMessage(), 'Can\'t obtain exclusive index lock') === false) { - throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e); - } else { - throw new Zend_Search_Lucene_Exception('Can\'t create index. It\'s under processing now', 0, $e); - } - } - - if ($this->_generation == -1) { - // Directory doesn't contain existing index, start from 1 - $this->_generation = 1; - $nameCounter = 0; - } else { - // Directory contains existing index - $segmentsFile = $this->_directory->getFileObject(self::getSegmentFileName($this->_generation)); - $segmentsFile->seek(12); // 12 = 4 (int, file format marker) + 8 (long, index version) - - $nameCounter = $segmentsFile->readInt(); - $this->_generation++; - } - - // require_once 'Zend/Search/Lucene/Index/Writer.php'; - Zend_Search_Lucene_Index_Writer::createIndex($this->_directory, $this->_generation, $nameCounter); - - Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory); - } - - if ($this->_generation == -1) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Index doesn\'t exists in the specified directory.'); - } else if ($this->_generation == 0) { - $this->_readPre21SegmentsFile(); - } else { - $this->_readSegmentsFile(); - } - } - - /** - * Close current index and free resources - */ - private function _close() - { - if ($this->_closed) { - // index is already closed and resources are cleaned up - return; - } - - $this->commit(); - - // Release "under processing" flag - Zend_Search_Lucene_LockManager::releaseReadLock($this->_directory); - - if ($this->_closeDirOnExit) { - $this->_directory->close(); - } - - $this->_directory = null; - $this->_writer = null; - $this->_segmentInfos = null; - - $this->_closed = true; - } - - /** - * Add reference to the index object - * - * @internal - */ - public function addReference() - { - $this->_refCount++; - } - - /** - * Remove reference from the index object - * - * When reference count becomes zero, index is closed and resources are cleaned up - * - * @internal - */ - public function removeReference() - { - $this->_refCount--; - - if ($this->_refCount == 0) { - $this->_close(); - } - } - - /** - * Object destructor - */ - public function __destruct() - { - $this->_close(); - } - - /** - * Returns an instance of Zend_Search_Lucene_Index_Writer for the index - * - * @return Zend_Search_Lucene_Index_Writer - */ - private function _getIndexWriter() - { - if ($this->_writer === null) { - // require_once 'Zend/Search/Lucene/Index/Writer.php'; - $this->_writer = new Zend_Search_Lucene_Index_Writer($this->_directory, - $this->_segmentInfos, - $this->_formatVersion); - } - - return $this->_writer; - } - - - /** - * Returns the Zend_Search_Lucene_Storage_Directory instance for this index. - * - * @return Zend_Search_Lucene_Storage_Directory - */ - public function getDirectory() - { - return $this->_directory; - } - - - /** - * Returns the total number of documents in this index (including deleted documents). - * - * @return integer - */ - public function count() - { - return $this->_docCount; - } - - /** - * Returns one greater than the largest possible document number. - * This may be used to, e.g., determine how big to allocate a structure which will have - * an element for every document number in an index. - * - * @return integer - */ - public function maxDoc() - { - return $this->count(); - } - - /** - * Returns the total number of non-deleted documents in this index. - * - * @return integer - */ - public function numDocs() - { - $numDocs = 0; - - foreach ($this->_segmentInfos as $segmentInfo) { - $numDocs += $segmentInfo->numDocs(); - } - - return $numDocs; - } - - /** - * Checks, that document is deleted - * - * @param integer $id - * @return boolean - * @throws Zend_Search_Lucene_Exception Exception is thrown if $id is out of the range - */ - public function isDeleted($id) - { - $this->commit(); - - if ($id >= $this->_docCount) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Document id is out of the range.'); - } - - $segmentStartId = 0; - foreach ($this->_segmentInfos as $segmentInfo) { - if ($segmentStartId + $segmentInfo->count() > $id) { - break; - } - - $segmentStartId += $segmentInfo->count(); - } - - return $segmentInfo->isDeleted($id - $segmentStartId); - } - - /** - * Set default search field. - * - * Null means, that search is performed through all fields by default - * - * Default value is null - * - * @param string $fieldName - */ - public static function setDefaultSearchField($fieldName) - { - self::$_defaultSearchField = $fieldName; - } - - /** - * Get default search field. - * - * Null means, that search is performed through all fields by default - * - * @return string - */ - public static function getDefaultSearchField() - { - return self::$_defaultSearchField; - } - - /** - * Set result set limit. - * - * 0 (default) means no limit - * - * @param integer $limit - */ - public static function setResultSetLimit($limit) - { - self::$_resultSetLimit = $limit; - } - - /** - * Get result set limit. - * - * 0 means no limit - * - * @return integer - */ - public static function getResultSetLimit() - { - return self::$_resultSetLimit; - } - - /** - * Set terms per query limit. - * - * 0 means no limit - * - * @param integer $limit - */ - public static function setTermsPerQueryLimit($limit) - { - self::$_termsPerQueryLimit = $limit; - } - - /** - * Get result set limit. - * - * 0 (default) means no limit - * - * @return integer - */ - public static function getTermsPerQueryLimit() - { - return self::$_termsPerQueryLimit; - } - - /** - * Retrieve index maxBufferedDocs option - * - * maxBufferedDocs is a minimal number of documents required before - * the buffered in-memory documents are written into a new Segment - * - * Default value is 10 - * - * @return integer - */ - public function getMaxBufferedDocs() - { - return $this->_getIndexWriter()->maxBufferedDocs; - } - - /** - * Set index maxBufferedDocs option - * - * maxBufferedDocs is a minimal number of documents required before - * the buffered in-memory documents are written into a new Segment - * - * Default value is 10 - * - * @param integer $maxBufferedDocs - */ - public function setMaxBufferedDocs($maxBufferedDocs) - { - $this->_getIndexWriter()->maxBufferedDocs = $maxBufferedDocs; - } - - /** - * Retrieve index maxMergeDocs option - * - * maxMergeDocs is a largest number of documents ever merged by addDocument(). - * Small values (e.g., less than 10,000) are best for interactive indexing, - * as this limits the length of pauses while indexing to a few seconds. - * Larger values are best for batched indexing and speedier searches. - * - * Default value is PHP_INT_MAX - * - * @return integer - */ - public function getMaxMergeDocs() - { - return $this->_getIndexWriter()->maxMergeDocs; - } - - /** - * Set index maxMergeDocs option - * - * maxMergeDocs is a largest number of documents ever merged by addDocument(). - * Small values (e.g., less than 10,000) are best for interactive indexing, - * as this limits the length of pauses while indexing to a few seconds. - * Larger values are best for batched indexing and speedier searches. - * - * Default value is PHP_INT_MAX - * - * @param integer $maxMergeDocs - */ - public function setMaxMergeDocs($maxMergeDocs) - { - $this->_getIndexWriter()->maxMergeDocs = $maxMergeDocs; - } - - /** - * Retrieve index mergeFactor option - * - * mergeFactor determines how often segment indices are merged by addDocument(). - * With smaller values, less RAM is used while indexing, - * and searches on unoptimized indices are faster, - * but indexing speed is slower. - * With larger values, more RAM is used during indexing, - * and while searches on unoptimized indices are slower, - * indexing is faster. - * Thus larger values (> 10) are best for batch index creation, - * and smaller values (< 10) for indices that are interactively maintained. - * - * Default value is 10 - * - * @return integer - */ - public function getMergeFactor() - { - return $this->_getIndexWriter()->mergeFactor; - } - - /** - * Set index mergeFactor option - * - * mergeFactor determines how often segment indices are merged by addDocument(). - * With smaller values, less RAM is used while indexing, - * and searches on unoptimized indices are faster, - * but indexing speed is slower. - * With larger values, more RAM is used during indexing, - * and while searches on unoptimized indices are slower, - * indexing is faster. - * Thus larger values (> 10) are best for batch index creation, - * and smaller values (< 10) for indices that are interactively maintained. - * - * Default value is 10 - * - * @param integer $maxMergeDocs - */ - public function setMergeFactor($mergeFactor) - { - $this->_getIndexWriter()->mergeFactor = $mergeFactor; - } - - /** - * Performs a query against the index and returns an array - * of Zend_Search_Lucene_Search_QueryHit objects. - * Input is a string or Zend_Search_Lucene_Search_Query. - * - * @param Zend_Search_Lucene_Search_QueryParser|string $query - * @return array Zend_Search_Lucene_Search_QueryHit - * @throws Zend_Search_Lucene_Exception - */ - public function find($query) - { - if (is_string($query)) { - // require_once 'Zend/Search/Lucene/Search/QueryParser.php'; - - $query = Zend_Search_Lucene_Search_QueryParser::parse($query); - } - - if (!$query instanceof Zend_Search_Lucene_Search_Query) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Query must be a string or Zend_Search_Lucene_Search_Query object'); - } - - $this->commit(); - - $hits = array(); - $scores = array(); - $ids = array(); - - $query = $query->rewrite($this)->optimize($this); - - $query->execute($this); - - $topScore = 0; - - /** Zend_Search_Lucene_Search_QueryHit */ - // require_once 'Zend/Search/Lucene/Search/QueryHit.php'; - - foreach ($query->matchedDocs() as $id => $num) { - $docScore = $query->score($id, $this); - if( $docScore != 0 ) { - $hit = new Zend_Search_Lucene_Search_QueryHit($this); - $hit->id = $id; - $hit->score = $docScore; - - $hits[] = $hit; - $ids[] = $id; - $scores[] = $docScore; - - if ($docScore > $topScore) { - $topScore = $docScore; - } - } - - if (self::$_resultSetLimit != 0 && count($hits) >= self::$_resultSetLimit) { - break; - } - } - - if (count($hits) == 0) { - // skip sorting, which may cause a error on empty index - return array(); - } - - if ($topScore > 1) { - foreach ($hits as $hit) { - $hit->score /= $topScore; - } - } - - if (func_num_args() == 1) { - // sort by scores - array_multisort($scores, SORT_DESC, SORT_NUMERIC, - $ids, SORT_ASC, SORT_NUMERIC, - $hits); - } else { - // sort by given field names - - $argList = func_get_args(); - $fieldNames = $this->getFieldNames(); - $sortArgs = array(); - - // PHP 5.3 now expects all arguments to array_multisort be passed by - // reference (if it's invoked through call_user_func_array()); - // since constants can't be passed by reference, create some placeholder variables. - $sortReg = SORT_REGULAR; - $sortAsc = SORT_ASC; - $sortNum = SORT_NUMERIC; - - $sortFieldValues = array(); - - // require_once 'Zend/Search/Lucene/Exception.php'; - for ($count = 1; $count < count($argList); $count++) { - $fieldName = $argList[$count]; - - if (!is_string($fieldName)) { - throw new Zend_Search_Lucene_Exception('Field name must be a string.'); - } - - if (strtolower($fieldName) == 'score') { - $sortArgs[] = &$scores; - } else { - if (!in_array($fieldName, $fieldNames)) { - throw new Zend_Search_Lucene_Exception('Wrong field name.'); - } - - if (!isset($sortFieldValues[$fieldName])) { - $valuesArray = array(); - foreach ($hits as $hit) { - try { - $value = $hit->getDocument()->getFieldValue($fieldName); - } catch (Zend_Search_Lucene_Exception $e) { - if (strpos($e->getMessage(), 'not found') === false) { - throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e); - } else { - $value = null; - } - } - - $valuesArray[] = $value; - } - - // Collect loaded values in $sortFieldValues - // Required for PHP 5.3 which translates references into values when source - // variable is destroyed - $sortFieldValues[$fieldName] = $valuesArray; - } - - $sortArgs[] = &$sortFieldValues[$fieldName]; - } - - if ($count + 1 < count($argList) && is_integer($argList[$count+1])) { - $count++; - $sortArgs[] = &$argList[$count]; - - if ($count + 1 < count($argList) && is_integer($argList[$count+1])) { - $count++; - $sortArgs[] = &$argList[$count]; - } else { - if ($argList[$count] == SORT_ASC || $argList[$count] == SORT_DESC) { - $sortArgs[] = &$sortReg; - } else { - $sortArgs[] = &$sortAsc; - } - } - } else { - $sortArgs[] = &$sortAsc; - $sortArgs[] = &$sortReg; - } - } - - // Sort by id's if values are equal - $sortArgs[] = &$ids; - $sortArgs[] = &$sortAsc; - $sortArgs[] = &$sortNum; - - // Array to be sorted - $sortArgs[] = &$hits; - - // Do sort - call_user_func_array('array_multisort', $sortArgs); - } - - return $hits; - } - - - /** - * Returns a list of all unique field names that exist in this index. - * - * @param boolean $indexed - * @return array - */ - public function getFieldNames($indexed = false) - { - $result = array(); - foreach( $this->_segmentInfos as $segmentInfo ) { - $result = array_merge($result, $segmentInfo->getFields($indexed)); - } - return $result; - } - - - /** - * Returns a Zend_Search_Lucene_Document object for the document - * number $id in this index. - * - * @param integer|Zend_Search_Lucene_Search_QueryHit $id - * @return Zend_Search_Lucene_Document - * @throws Zend_Search_Lucene_Exception Exception is thrown if $id is out of the range - */ - public function getDocument($id) - { - if ($id instanceof Zend_Search_Lucene_Search_QueryHit) { - /* @var $id Zend_Search_Lucene_Search_QueryHit */ - $id = $id->id; - } - - if ($id >= $this->_docCount) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Document id is out of the range.'); - } - - $segmentStartId = 0; - foreach ($this->_segmentInfos as $segmentInfo) { - if ($segmentStartId + $segmentInfo->count() > $id) { - break; - } - - $segmentStartId += $segmentInfo->count(); - } - - $fdxFile = $segmentInfo->openCompoundFile('.fdx'); - $fdxFile->seek(($id-$segmentStartId)*8, SEEK_CUR); - $fieldValuesPosition = $fdxFile->readLong(); - - $fdtFile = $segmentInfo->openCompoundFile('.fdt'); - $fdtFile->seek($fieldValuesPosition, SEEK_CUR); - $fieldCount = $fdtFile->readVInt(); - - $doc = new Zend_Search_Lucene_Document(); - for ($count = 0; $count < $fieldCount; $count++) { - $fieldNum = $fdtFile->readVInt(); - $bits = $fdtFile->readByte(); - - $fieldInfo = $segmentInfo->getField($fieldNum); - - if (!($bits & 2)) { // Text data - $field = new Zend_Search_Lucene_Field($fieldInfo->name, - $fdtFile->readString(), - 'UTF-8', - true, - $fieldInfo->isIndexed, - $bits & 1 ); - } else { // Binary data - $field = new Zend_Search_Lucene_Field($fieldInfo->name, - $fdtFile->readBinary(), - '', - true, - $fieldInfo->isIndexed, - $bits & 1, - true ); - } - - $doc->addField($field); - } - - return $doc; - } - - - /** - * Returns true if index contain documents with specified term. - * - * Is used for query optimization. - * - * @param Zend_Search_Lucene_Index_Term $term - * @return boolean - */ - public function hasTerm(Zend_Search_Lucene_Index_Term $term) - { - foreach ($this->_segmentInfos as $segInfo) { - if ($segInfo->getTermInfo($term) !== null) { - return true; - } - } - - return false; - } - - /** - * Returns IDs of all documents containing term. - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return array - */ - public function termDocs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null) - { - $subResults = array(); - $segmentStartDocId = 0; - - foreach ($this->_segmentInfos as $segmentInfo) { - $subResults[] = $segmentInfo->termDocs($term, $segmentStartDocId, $docsFilter); - - $segmentStartDocId += $segmentInfo->count(); - } - - if (count($subResults) == 0) { - return array(); - } else if (count($subResults) == 1) { - // Index is optimized (only one segment) - // Do not perform array reindexing - return reset($subResults); - } else { - $result = call_user_func_array('array_merge', $subResults); - } - - return $result; - } - - /** - * Returns documents filter for all documents containing term. - * - * It performs the same operation as termDocs, but return result as - * Zend_Search_Lucene_Index_DocsFilter object - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return Zend_Search_Lucene_Index_DocsFilter - */ - public function termDocsFilter(Zend_Search_Lucene_Index_Term $term, $docsFilter = null) - { - $segmentStartDocId = 0; - $result = new Zend_Search_Lucene_Index_DocsFilter(); - - foreach ($this->_segmentInfos as $segmentInfo) { - $subResults[] = $segmentInfo->termDocs($term, $segmentStartDocId, $docsFilter); - - $segmentStartDocId += $segmentInfo->count(); - } - - if (count($subResults) == 0) { - return array(); - } else if (count($subResults) == 1) { - // Index is optimized (only one segment) - // Do not perform array reindexing - return reset($subResults); - } else { - $result = call_user_func_array('array_merge', $subResults); - } - - return $result; - } - - - /** - * Returns an array of all term freqs. - * Result array structure: array(docId => freq, ...) - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return integer - */ - public function termFreqs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null) - { - $result = array(); - $segmentStartDocId = 0; - foreach ($this->_segmentInfos as $segmentInfo) { - $result += $segmentInfo->termFreqs($term, $segmentStartDocId, $docsFilter); - - $segmentStartDocId += $segmentInfo->count(); - } - - return $result; - } - - /** - * Returns an array of all term positions in the documents. - * Result array structure: array(docId => array(pos1, pos2, ...), ...) - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return array - */ - public function termPositions(Zend_Search_Lucene_Index_Term $term, $docsFilter = null) - { - $result = array(); - $segmentStartDocId = 0; - foreach ($this->_segmentInfos as $segmentInfo) { - $result += $segmentInfo->termPositions($term, $segmentStartDocId, $docsFilter); - - $segmentStartDocId += $segmentInfo->count(); - } - - return $result; - } - - - /** - * Returns the number of documents in this index containing the $term. - * - * @param Zend_Search_Lucene_Index_Term $term - * @return integer - */ - public function docFreq(Zend_Search_Lucene_Index_Term $term) - { - $result = 0; - foreach ($this->_segmentInfos as $segInfo) { - $termInfo = $segInfo->getTermInfo($term); - if ($termInfo !== null) { - $result += $termInfo->docFreq; - } - } - - return $result; - } - - - /** - * Retrive similarity used by index reader - * - * @return Zend_Search_Lucene_Search_Similarity - */ - public function getSimilarity() - { - /** Zend_Search_Lucene_Search_Similarity */ - // require_once 'Zend/Search/Lucene/Search/Similarity.php'; - - return Zend_Search_Lucene_Search_Similarity::getDefault(); - } - - - /** - * Returns a normalization factor for "field, document" pair. - * - * @param integer $id - * @param string $fieldName - * @return float - */ - public function norm($id, $fieldName) - { - if ($id >= $this->_docCount) { - return null; - } - - $segmentStartId = 0; - foreach ($this->_segmentInfos as $segInfo) { - if ($segmentStartId + $segInfo->count() > $id) { - break; - } - - $segmentStartId += $segInfo->count(); - } - - if ($segInfo->isDeleted($id - $segmentStartId)) { - return 0; - } - - return $segInfo->norm($id - $segmentStartId, $fieldName); - } - - /** - * Returns true if any documents have been deleted from this index. - * - * @return boolean - */ - public function hasDeletions() - { - foreach ($this->_segmentInfos as $segmentInfo) { - if ($segmentInfo->hasDeletions()) { - return true; - } - } - - return false; - } - - - /** - * Deletes a document from the index. - * $id is an internal document id - * - * @param integer|Zend_Search_Lucene_Search_QueryHit $id - * @throws Zend_Search_Lucene_Exception - */ - public function delete($id) - { - if ($id instanceof Zend_Search_Lucene_Search_QueryHit) { - /* @var $id Zend_Search_Lucene_Search_QueryHit */ - $id = $id->id; - } - - if ($id >= $this->_docCount) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Document id is out of the range.'); - } - - $segmentStartId = 0; - foreach ($this->_segmentInfos as $segmentInfo) { - if ($segmentStartId + $segmentInfo->count() > $id) { - break; - } - - $segmentStartId += $segmentInfo->count(); - } - $segmentInfo->delete($id - $segmentStartId); - - $this->_hasChanges = true; - } - - - - /** - * Adds a document to this index. - * - * @param Zend_Search_Lucene_Document $document - */ - public function addDocument(Zend_Search_Lucene_Document $document) - { - $this->_getIndexWriter()->addDocument($document); - $this->_docCount++; - - $this->_hasChanges = true; - } - - - /** - * Update document counter - */ - private function _updateDocCount() - { - $this->_docCount = 0; - foreach ($this->_segmentInfos as $segInfo) { - $this->_docCount += $segInfo->count(); - } - } - - /** - * Commit changes resulting from delete() or undeleteAll() operations. - * - * @todo undeleteAll processing. - */ - public function commit() - { - if ($this->_hasChanges) { - $this->_getIndexWriter()->commit(); - - $this->_updateDocCount(); - - $this->_hasChanges = false; - } - } - - - /** - * Optimize index. - * - * Merges all segments into one - */ - public function optimize() - { - // Commit changes if any changes have been made - $this->commit(); - - if (count($this->_segmentInfos) > 1 || $this->hasDeletions()) { - $this->_getIndexWriter()->optimize(); - $this->_updateDocCount(); - } - } - - - /** - * Returns an array of all terms in this index. - * - * @return array - */ - public function terms() - { - $result = array(); - - /** Zend_Search_Lucene_Index_TermsPriorityQueue */ - // require_once 'Zend/Search/Lucene/Index/TermsPriorityQueue.php'; - - $segmentInfoQueue = new Zend_Search_Lucene_Index_TermsPriorityQueue(); - - foreach ($this->_segmentInfos as $segmentInfo) { - $segmentInfo->resetTermsStream(); - - // Skip "empty" segments - if ($segmentInfo->currentTerm() !== null) { - $segmentInfoQueue->put($segmentInfo); - } - } - - while (($segmentInfo = $segmentInfoQueue->pop()) !== null) { - if ($segmentInfoQueue->top() === null || - $segmentInfoQueue->top()->currentTerm()->key() != - $segmentInfo->currentTerm()->key()) { - // We got new term - $result[] = $segmentInfo->currentTerm(); - } - - if ($segmentInfo->nextTerm() !== null) { - // Put segment back into the priority queue - $segmentInfoQueue->put($segmentInfo); - } - } - - return $result; - } - - - /** - * Terms stream priority queue object - * - * @var Zend_Search_Lucene_TermStreamsPriorityQueue - */ - private $_termsStream = null; - - /** - * Reset terms stream. - */ - public function resetTermsStream() - { - if ($this->_termsStream === null) { - /** Zend_Search_Lucene_TermStreamsPriorityQueue */ - // require_once 'Zend/Search/Lucene/TermStreamsPriorityQueue.php'; - - $this->_termsStream = new Zend_Search_Lucene_TermStreamsPriorityQueue($this->_segmentInfos); - } else { - $this->_termsStream->resetTermsStream(); - } - } - - /** - * Skip terms stream up to the specified term preffix. - * - * Prefix contains fully specified field info and portion of searched term - * - * @param Zend_Search_Lucene_Index_Term $prefix - */ - public function skipTo(Zend_Search_Lucene_Index_Term $prefix) - { - $this->_termsStream->skipTo($prefix); - } - - /** - * Scans terms dictionary and returns next term - * - * @return Zend_Search_Lucene_Index_Term|null - */ - public function nextTerm() - { - return $this->_termsStream->nextTerm(); - } - - /** - * Returns term in current position - * - * @return Zend_Search_Lucene_Index_Term|null - */ - public function currentTerm() - { - return $this->_termsStream->currentTerm(); - } - - /** - * Close terms stream - * - * Should be used for resources clean up if stream is not read up to the end - */ - public function closeTermsStream() - { - $this->_termsStream->closeTermsStream(); - $this->_termsStream = null; - } - - - /************************************************************************* - @todo UNIMPLEMENTED - *************************************************************************/ - /** - * Undeletes all documents currently marked as deleted in this index. - * - * @todo Implementation - */ - public function undeleteAll() - {} -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer.php deleted file mode 100755 index 4d3ce743cc42922febaa4c35cd3d927f57141639..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer.php +++ /dev/null @@ -1,175 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** User land classes and interfaces turned on by Zend/Search/Analyzer.php file inclusion. */ -/** @todo Section should be removed with ZF 2.0 release as obsolete */ -if (!defined('ZEND_SEARCH_LUCENE_COMMON_ANALYZER_PROCESSED')) { - /** Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8 */ - // require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8.php'; - - /** Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive */ - // require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8/CaseInsensitive.php'; - - /** Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num */ - // require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num.php'; - - /** Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive */ - // require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num/CaseInsensitive.php'; - - /** Zend_Search_Lucene_Analysis_Analyzer_Common_Text */ - // require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php'; - - /** Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive */ - // require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Text/CaseInsensitive.php'; - - /** Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum */ - // require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum.php'; - - /** Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive */ - // require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum/CaseInsensitive.php'; -} - - -/** - * An Analyzer is used to analyze text. - * It thus represents a policy for extracting index terms from text. - * - * Note: - * Lucene Java implementation is oriented to streams. It provides effective work - * with a huge documents (more then 20Mb). - * But engine itself is not oriented such documents. - * Thus Zend_Search_Lucene analysis API works with data strings and sets (arrays). - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -abstract class Zend_Search_Lucene_Analysis_Analyzer -{ - /** - * The Analyzer implementation used by default. - * - * @var Zend_Search_Lucene_Analysis_Analyzer - */ - private static $_defaultImpl; - - /** - * Input string - * - * @var string - */ - protected $_input = null; - - /** - * Input string encoding - * - * @var string - */ - protected $_encoding = ''; - - /** - * Tokenize text to a terms - * Returns array of Zend_Search_Lucene_Analysis_Token objects - * - * Tokens are returned in UTF-8 (internal Zend_Search_Lucene encoding) - * - * @param string $data - * @return array - */ - public function tokenize($data, $encoding = '') - { - $this->setInput($data, $encoding); - - $tokenList = array(); - while (($nextToken = $this->nextToken()) !== null) { - $tokenList[] = $nextToken; - } - - return $tokenList; - } - - - /** - * Tokenization stream API - * Set input - * - * @param string $data - */ - public function setInput($data, $encoding = '') - { - $this->_input = $data; - $this->_encoding = $encoding; - $this->reset(); - } - - /** - * Reset token stream - */ - abstract public function reset(); - - /** - * Tokenization stream API - * Get next token - * Returns null at the end of stream - * - * Tokens are returned in UTF-8 (internal Zend_Search_Lucene encoding) - * - * @return Zend_Search_Lucene_Analysis_Token|null - */ - abstract public function nextToken(); - - - - - /** - * Set the default Analyzer implementation used by indexing code. - * - * @param Zend_Search_Lucene_Analysis_Analyzer $similarity - */ - public static function setDefault(Zend_Search_Lucene_Analysis_Analyzer $analyzer) - { - self::$_defaultImpl = $analyzer; - } - - - /** - * Return the default Analyzer implementation used by indexing code. - * - * @return Zend_Search_Lucene_Analysis_Analyzer - */ - public static function getDefault() - { - /** Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive */ - // require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Text/CaseInsensitive.php'; - - if (!self::$_defaultImpl instanceof Zend_Search_Lucene_Analysis_Analyzer) { - self::$_defaultImpl = new Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive(); - } - - return self::$_defaultImpl; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common.php deleted file mode 100755 index e4ffcdb213913553614222e9810af15d6ecc571d..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common.php +++ /dev/null @@ -1,94 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Define constant used to provide correct file processing order */ -/** @todo Section should be removed with ZF 2.0 release as obsolete */ -if (!defined('ZEND_SEARCH_LUCENE_COMMON_ANALYZER_PROCESSED')) { - define('ZEND_SEARCH_LUCENE_COMMON_ANALYZER_PROCESSED', true); -} - - -/** Zend_Search_Lucene_Analysis_Analyzer */ -// require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - -/** Zend_Search_Lucene_Analysis_Token */ -// require_once 'Zend/Search/Lucene/Analysis/Token.php'; - -/** Zend_Search_Lucene_Analysis_TokenFilter */ -// require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php'; - - -/** - * Common implementation of the Zend_Search_Lucene_Analysis_Analyzer interface. - * There are several standard standard subclasses provided by Zend_Search_Lucene/Analysis - * subpackage: Zend_Search_Lucene_Analysis_Analyzer_Common_Text, ZSearchHTMLAnalyzer, ZSearchXMLAnalyzer. - * - * @todo ZSearchHTMLAnalyzer and ZSearchXMLAnalyzer implementation - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Search_Lucene_Analysis_Analyzer_Common extends Zend_Search_Lucene_Analysis_Analyzer -{ - /** - * The set of Token filters applied to the Token stream. - * Array of Zend_Search_Lucene_Analysis_TokenFilter objects. - * - * @var array - */ - private $_filters = array(); - - /** - * Add Token filter to the Analyzer - * - * @param Zend_Search_Lucene_Analysis_TokenFilter $filter - */ - public function addFilter(Zend_Search_Lucene_Analysis_TokenFilter $filter) - { - $this->_filters[] = $filter; - } - - /** - * Apply filters to the token. Can return null when the token was removed. - * - * @param Zend_Search_Lucene_Analysis_Token $token - * @return Zend_Search_Lucene_Analysis_Token - */ - public function normalize(Zend_Search_Lucene_Analysis_Token $token) - { - foreach ($this->_filters as $filter) { - $token = $filter->normalize($token); - - // resulting token can be null if the filter removes it - if ($token === null) { - return null; - } - } - - return $token; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php deleted file mode 100755 index acd329f8f3bd6097b79c3100b4cdba3b61c18406..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Analysis_Analyzer_Common */ -// require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -class Zend_Search_Lucene_Analysis_Analyzer_Common_Text extends Zend_Search_Lucene_Analysis_Analyzer_Common -{ - /** - * Current position in a stream - * - * @var integer - */ - private $_position; - - /** - * Reset token stream - */ - public function reset() - { - $this->_position = 0; - - if ($this->_input === null) { - return; - } - - // convert input into ascii - if (PHP_OS != 'AIX') { - $this->_input = iconv($this->_encoding, 'ASCII//TRANSLIT', $this->_input); - } - $this->_encoding = 'ASCII'; - } - - /** - * Tokenization stream API - * Get next token - * Returns null at the end of stream - * - * @return Zend_Search_Lucene_Analysis_Token|null - */ - public function nextToken() - { - if ($this->_input === null) { - return null; - } - - - do { - if (! preg_match('/[a-zA-Z]+/', $this->_input, $match, PREG_OFFSET_CAPTURE, $this->_position)) { - // It covers both cases a) there are no matches (preg_match(...) === 0) - // b) error occured (preg_match(...) === FALSE) - return null; - } - - $str = $match[0][0]; - $pos = $match[0][1]; - $endpos = $pos + strlen($str); - - $this->_position = $endpos; - - $token = $this->normalize(new Zend_Search_Lucene_Analysis_Token($str, $pos, $endpos)); - } while ($token === null); // try again if token is skipped - - return $token; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Text/CaseInsensitive.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Text/CaseInsensitive.php deleted file mode 100755 index 941898da01f31f59721025bc6bd9639cfed63b3f..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Text/CaseInsensitive.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Analysis_Analyzer_Common_Text */ -// require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php'; - -/** Zend_Search_Lucene_Analysis_TokenFilter_LowerCase */ -// require_once 'Zend/Search/Lucene/Analysis/TokenFilter/LowerCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - - -class Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive extends Zend_Search_Lucene_Analysis_Analyzer_Common_Text -{ - public function __construct() - { - $this->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_LowerCase()); - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum.php deleted file mode 100755 index 7ce4d815374e024dcb08a6358c1f7e177f326984..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum.php +++ /dev/null @@ -1,95 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Analysis_Analyzer_Common */ -// require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -class Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum extends Zend_Search_Lucene_Analysis_Analyzer_Common -{ - /** - * Current position in a stream - * - * @var integer - */ - private $_position; - - /** - * Reset token stream - */ - public function reset() - { - $this->_position = 0; - - if ($this->_input === null) { - return; - } - - // convert input into ascii - if (PHP_OS != 'AIX') { - $this->_input = iconv($this->_encoding, 'ASCII//TRANSLIT', $this->_input); - } - $this->_encoding = 'ASCII'; - } - - /** - * Tokenization stream API - * Get next token - * Returns null at the end of stream - * - * @return Zend_Search_Lucene_Analysis_Token|null - */ - public function nextToken() - { - if ($this->_input === null) { - return null; - } - - do { - if (! preg_match('/[a-zA-Z0-9]+/', $this->_input, $match, PREG_OFFSET_CAPTURE, $this->_position)) { - // It covers both cases a) there are no matches (preg_match(...) === 0) - // b) error occured (preg_match(...) === FALSE) - return null; - } - - $str = $match[0][0]; - $pos = $match[0][1]; - $endpos = $pos + strlen($str); - - $this->_position = $endpos; - - $token = $this->normalize(new Zend_Search_Lucene_Analysis_Token($str, $pos, $endpos)); - } while ($token === null); // try again if token is skipped - - return $token; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum/CaseInsensitive.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum/CaseInsensitive.php deleted file mode 100755 index a8322f347c2bcdfb83357a1935482360a95308c8..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum/CaseInsensitive.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum */ -// require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum.php'; - -/** Zend_Search_Lucene_Analysis_TokenFilter_LowerCase */ -// require_once 'Zend/Search/Lucene/Analysis/TokenFilter/LowerCase.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - - -class Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive extends Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum -{ - public function __construct() - { - $this->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_LowerCase()); - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8.php deleted file mode 100755 index 481a86e19f110ada0aa5ea8c71ad9bdec053bc53..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8.php +++ /dev/null @@ -1,126 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Analysis_Analyzer_Common */ -// require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8 extends Zend_Search_Lucene_Analysis_Analyzer_Common -{ - /** - * Current char position in an UTF-8 stream - * - * @var integer - */ - private $_position; - - /** - * Current binary position in an UTF-8 stream - * - * @var integer - */ - private $_bytePosition; - - /** - * Object constructor - * - * @throws Zend_Search_Lucene_Exception - */ - public function __construct() - { - if (@preg_match('/\pL/u', 'a') != 1) { - // PCRE unicode support is turned off - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Utf8 analyzer needs PCRE unicode support to be enabled.'); - } - } - - /** - * Reset token stream - */ - public function reset() - { - $this->_position = 0; - $this->_bytePosition = 0; - - // convert input into UTF-8 - if (strcasecmp($this->_encoding, 'utf8' ) != 0 && - strcasecmp($this->_encoding, 'utf-8') != 0 ) { - $this->_input = iconv($this->_encoding, 'UTF-8', $this->_input); - $this->_encoding = 'UTF-8'; - } - } - - /** - * Tokenization stream API - * Get next token - * Returns null at the end of stream - * - * @return Zend_Search_Lucene_Analysis_Token|null - */ - public function nextToken() - { - if ($this->_input === null) { - return null; - } - - do { - if (! preg_match('/[\p{L}]+/u', $this->_input, $match, PREG_OFFSET_CAPTURE, $this->_bytePosition)) { - // It covers both cases a) there are no matches (preg_match(...) === 0) - // b) error occured (preg_match(...) === FALSE) - return null; - } - - // matched string - $matchedWord = $match[0][0]; - - // binary position of the matched word in the input stream - $binStartPos = $match[0][1]; - - // character position of the matched word in the input stream - $startPos = $this->_position + - iconv_strlen(substr($this->_input, - $this->_bytePosition, - $binStartPos - $this->_bytePosition), - 'UTF-8'); - // character postion of the end of matched word in the input stream - $endPos = $startPos + iconv_strlen($matchedWord, 'UTF-8'); - - $this->_bytePosition = $binStartPos + strlen($matchedWord); - $this->_position = $endPos; - - $token = $this->normalize(new Zend_Search_Lucene_Analysis_Token($matchedWord, $startPos, $endPos)); - } while ($token === null); // try again if token is skipped - - return $token; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8/CaseInsensitive.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8/CaseInsensitive.php deleted file mode 100755 index 0eb09cf1244e91d6c447104eff2d6866572f36ff..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8/CaseInsensitive.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8 */ -// require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8.php'; - -/** Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8 */ -// require_once 'Zend/Search/Lucene/Analysis/TokenFilter/LowerCaseUtf8.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - - -class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive extends Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8 -{ - public function __construct() - { - parent::__construct(); - - $this->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8()); - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num.php deleted file mode 100755 index 3395ec73e738cba4272217463ccac103a4a9ebc2..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num.php +++ /dev/null @@ -1,126 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Analysis_Analyzer_Common */ -// require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num extends Zend_Search_Lucene_Analysis_Analyzer_Common -{ - /** - * Current char position in an UTF-8 stream - * - * @var integer - */ - private $_position; - - /** - * Current binary position in an UTF-8 stream - * - * @var integer - */ - private $_bytePosition; - - /** - * Object constructor - * - * @throws Zend_Search_Lucene_Exception - */ - public function __construct() - { - if (@preg_match('/\pL/u', 'a') != 1) { - // PCRE unicode support is turned off - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Utf8Num analyzer needs PCRE unicode support to be enabled.'); - } - } - - /** - * Reset token stream - */ - public function reset() - { - $this->_position = 0; - $this->_bytePosition = 0; - - // convert input into UTF-8 - if (strcasecmp($this->_encoding, 'utf8' ) != 0 && - strcasecmp($this->_encoding, 'utf-8') != 0 ) { - $this->_input = iconv($this->_encoding, 'UTF-8', $this->_input); - $this->_encoding = 'UTF-8'; - } - } - - /** - * Tokenization stream API - * Get next token - * Returns null at the end of stream - * - * @return Zend_Search_Lucene_Analysis_Token|null - */ - public function nextToken() - { - if ($this->_input === null) { - return null; - } - - do { - if (! preg_match('/[\p{L}\p{N}]+/u', $this->_input, $match, PREG_OFFSET_CAPTURE, $this->_bytePosition)) { - // It covers both cases a) there are no matches (preg_match(...) === 0) - // b) error occured (preg_match(...) === FALSE) - return null; - } - - // matched string - $matchedWord = $match[0][0]; - - // binary position of the matched word in the input stream - $binStartPos = $match[0][1]; - - // character position of the matched word in the input stream - $startPos = $this->_position + - iconv_strlen(substr($this->_input, - $this->_bytePosition, - $binStartPos - $this->_bytePosition), - 'UTF-8'); - // character postion of the end of matched word in the input stream - $endPos = $startPos + iconv_strlen($matchedWord, 'UTF-8'); - - $this->_bytePosition = $binStartPos + strlen($matchedWord); - $this->_position = $endPos; - - $token = $this->normalize(new Zend_Search_Lucene_Analysis_Token($matchedWord, $startPos, $endPos)); - } while ($token === null); // try again if token is skipped - - return $token; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num/CaseInsensitive.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num/CaseInsensitive.php deleted file mode 100755 index 3c8538f8194dc61e6a3af5dfdb81c4671e1a602c..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num/CaseInsensitive.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num */ -// require_once 'Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num.php'; - -/** Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8 */ -// require_once 'Zend/Search/Lucene/Analysis/TokenFilter/LowerCaseUtf8.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - - -class Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive extends Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num -{ - public function __construct() - { - parent::__construct(); - - $this->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8()); - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Token.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Token.php deleted file mode 100755 index dc900d16c629db7aac91043016ceac275a25d917..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/Token.php +++ /dev/null @@ -1,166 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Analysis_Token -{ - /** - * The text of the term. - * - * @var string - */ - private $_termText; - - /** - * Start in source text. - * - * @var integer - */ - private $_startOffset; - - /** - * End in source text - * - * @var integer - */ - private $_endOffset; - - /** - * The position of this token relative to the previous Token. - * - * The default value is one. - * - * Some common uses for this are: - * Set it to zero to put multiple terms in the same position. This is - * useful if, e.g., a word has multiple stems. Searches for phrases - * including either stem will match. In this case, all but the first stem's - * increment should be set to zero: the increment of the first instance - * should be one. Repeating a token with an increment of zero can also be - * used to boost the scores of matches on that token. - * - * Set it to values greater than one to inhibit exact phrase matches. - * If, for example, one does not want phrases to match across removed stop - * words, then one could build a stop word filter that removes stop words and - * also sets the increment to the number of stop words removed before each - * non-stop word. Then exact phrase queries will only match when the terms - * occur with no intervening stop words. - * - * @var integer - */ - private $_positionIncrement; - - - /** - * Object constructor - * - * @param string $text - * @param integer $start - * @param integer $end - * @param string $type - */ - public function __construct($text, $start, $end) - { - $this->_termText = $text; - $this->_startOffset = $start; - $this->_endOffset = $end; - - $this->_positionIncrement = 1; - } - - - /** - * positionIncrement setter - * - * @param integer $positionIncrement - */ - public function setPositionIncrement($positionIncrement) - { - $this->_positionIncrement = $positionIncrement; - } - - /** - * Returns the position increment of this Token. - * - * @return integer - */ - public function getPositionIncrement() - { - return $this->_positionIncrement; - } - - /** - * Returns the Token's term text. - * - * @return string - */ - public function getTermText() - { - return $this->_termText; - } - - /** - * Sets the Token's term text. - * - * @param string $text - * @return this - */ - public function setTermText($text) - { - $this->_termText = $text; - return $this; - } - - /** - * Returns this Token's starting offset, the position of the first character - * corresponding to this token in the source text. - * - * Note: - * The difference between getEndOffset() and getStartOffset() may not be equal - * to strlen(Zend_Search_Lucene_Analysis_Token::getTermText()), as the term text may have been altered - * by a stemmer or some other filter. - * - * @return integer - */ - public function getStartOffset() - { - return $this->_startOffset; - } - - /** - * Returns this Token's ending offset, one greater than the position of the - * last character corresponding to this token in the source text. - * - * @return integer - */ - public function getEndOffset() - { - return $this->_endOffset; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/TokenFilter.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/TokenFilter.php deleted file mode 100755 index 3540adb2a445a14c7b5959fc7730cf64257d0d2b..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/TokenFilter.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Analysis_Token */ -// require_once 'Zend/Search/Lucene/Analysis/Token.php'; - - -/** - * Token filter converts (normalizes) Token ore removes it from a token stream. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Search_Lucene_Analysis_TokenFilter -{ - /** - * Normalize Token or remove it (if null is returned) - * - * @param Zend_Search_Lucene_Analysis_Token $srcToken - * @return Zend_Search_Lucene_Analysis_Token - */ - abstract public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken); -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/TokenFilter/LowerCase.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/TokenFilter/LowerCase.php deleted file mode 100755 index e59e20f045ba8e2749a25be8cd913678c8d84e2c..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/TokenFilter/LowerCase.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Analysis_TokenFilter */ -// require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php'; - - -/** - * Lower case Token filter. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -class Zend_Search_Lucene_Analysis_TokenFilter_LowerCase extends Zend_Search_Lucene_Analysis_TokenFilter -{ - /** - * Normalize Token or remove it (if null is returned) - * - * @param Zend_Search_Lucene_Analysis_Token $srcToken - * @return Zend_Search_Lucene_Analysis_Token - */ - public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken) - { - $srcToken->setTermText(strtolower($srcToken->getTermText())); - return $srcToken; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/TokenFilter/LowerCaseUtf8.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/TokenFilter/LowerCaseUtf8.php deleted file mode 100755 index 8d25081eac6183e10bb294d7172a93c8943fa4ae..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/TokenFilter/LowerCaseUtf8.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Analysis_TokenFilter */ -// require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php'; - - -/** - * Lower case Token filter. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -class Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8 extends Zend_Search_Lucene_Analysis_TokenFilter -{ - /** - * Object constructor - */ - public function __construct() - { - if (!function_exists('mb_strtolower')) { - // mbstring extension is disabled - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Utf8 compatible lower case filter needs mbstring extension to be enabled.'); - } - } - - /** - * Normalize Token or remove it (if null is returned) - * - * @param Zend_Search_Lucene_Analysis_Token $srcToken - * @return Zend_Search_Lucene_Analysis_Token - */ - public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken) - { - $srcToken->setTermText(mb_strtolower($srcToken->getTermText(), 'UTF-8')); - return $srcToken; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/TokenFilter/ShortWords.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/TokenFilter/ShortWords.php deleted file mode 100755 index c1ba66b29662f1c3221eb59852d55fd4ed6753ac..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/TokenFilter/ShortWords.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Analysis_TokenFilter */ -// require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php'; - - -/** - * Token filter that removes short words. What is short word can be configured with constructor. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -class Zend_Search_Lucene_Analysis_TokenFilter_ShortWords extends Zend_Search_Lucene_Analysis_TokenFilter -{ - /** - * Minimum allowed term length - * @var integer - */ - private $length; - - /** - * Constructs new instance of this filter. - * - * @param integer $short minimum allowed length of term which passes this filter (default 2) - */ - public function __construct($length = 2) { - $this->length = $length; - } - - /** - * Normalize Token or remove it (if null is returned) - * - * @param Zend_Search_Lucene_Analysis_Token $srcToken - * @return Zend_Search_Lucene_Analysis_Token - */ - public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken) { - if (strlen($srcToken->getTermText()) < $this->length) { - return null; - } else { - return $srcToken; - } - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/TokenFilter/StopWords.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/TokenFilter/StopWords.php deleted file mode 100755 index b9af506a6c3549038b5ba5c3b19006c079675caf..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Analysis/TokenFilter/StopWords.php +++ /dev/null @@ -1,101 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_Analysis_TokenFilter */ -// require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php'; - -/** - * Token filter that removes stop words. These words must be provided as array (set), example: - * $stopwords = array('the' => 1, 'an' => '1'); - * - * We do recommend to provide all words in lowercase and concatenate this class after the lowercase filter. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Analysis - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ - -class Zend_Search_Lucene_Analysis_TokenFilter_StopWords extends Zend_Search_Lucene_Analysis_TokenFilter -{ - /** - * Stop Words - * @var array - */ - private $_stopSet; - - /** - * Constructs new instance of this filter. - * - * @param array $stopwords array (set) of words that will be filtered out - */ - public function __construct($stopwords = array()) { - $this->_stopSet = array_flip($stopwords); - } - - /** - * Normalize Token or remove it (if null is returned) - * - * @param Zend_Search_Lucene_Analysis_Token $srcToken - * @return Zend_Search_Lucene_Analysis_Token - */ - public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken) { - if (array_key_exists($srcToken->getTermText(), $this->_stopSet)) { - return null; - } else { - return $srcToken; - } - } - - /** - * Fills stopwords set from a text file. Each line contains one stopword, lines with '#' in the first - * column are ignored (as comments). - * - * You can call this method one or more times. New stopwords are always added to current set. - * - * @param string $filepath full path for text file with stopwords - * @throws Zend_Search_Exception When the file doesn`t exists or is not readable. - */ - public function loadFromFile($filepath = null) { - if (! $filepath || ! file_exists($filepath)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('You have to provide valid file path'); - } - $fd = fopen($filepath, "r"); - if (! $fd) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Cannot open file ' . $filepath); - } - while (!feof ($fd)) { - $buffer = trim(fgets($fd)); - if (strlen($buffer) > 0 && $buffer[0] != '#') { - $this->_stopSet[$buffer] = 1; - } - } - if (!fclose($fd)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Cannot close file ' . $filepath); - } - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document.php deleted file mode 100755 index 796d546be3a73e6f735d8b2b01c78348fb6641a8..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document.php +++ /dev/null @@ -1,131 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Document - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Field */ -// require_once 'Zend/Search/Lucene/Field.php'; - - -/** - * A Document is a set of fields. Each field has a name and a textual value. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Document - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Document -{ - - /** - * Associative array Zend_Search_Lucene_Field objects where the keys to the - * array are the names of the fields. - * - * @var array - */ - protected $_fields = array(); - - /** - * Field boost factor - * It's not stored directly in the index, but affects on normalization factor - * - * @var float - */ - public $boost = 1.0; - - /** - * Proxy method for getFieldValue(), provides more convenient access to - * the string value of a field. - * - * @param string $offset - * @return string - */ - public function __get($offset) - { - return $this->getFieldValue($offset); - } - - - /** - * Add a field object to this document. - * - * @param Zend_Search_Lucene_Field $field - * @return Zend_Search_Lucene_Document - */ - public function addField(Zend_Search_Lucene_Field $field) - { - $this->_fields[$field->name] = $field; - - return $this; - } - - - /** - * Return an array with the names of the fields in this document. - * - * @return array - */ - public function getFieldNames() - { - return array_keys($this->_fields); - } - - - /** - * Returns Zend_Search_Lucene_Field object for a named field in this document. - * - * @param string $fieldName - * @return Zend_Search_Lucene_Field - */ - public function getField($fieldName) - { - if (!array_key_exists($fieldName, $this->_fields)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception("Field name \"$fieldName\" not found in document."); - } - return $this->_fields[$fieldName]; - } - - - /** - * Returns the string value of a named field in this document. - * - * @see __get() - * @return string - */ - public function getFieldValue($fieldName) - { - return $this->getField($fieldName)->value; - } - - /** - * Returns the string value of a named field in UTF-8 encoding. - * - * @see __get() - * @return string - */ - public function getFieldUtf8Value($fieldName) - { - return $this->getField($fieldName)->getUtf8Value(); - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/Docx.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/Docx.php deleted file mode 100755 index a48545f5dc40de1011ab3f2c4567f240aa23dd62..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/Docx.php +++ /dev/null @@ -1,154 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Document - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_Document_OpenXml */ -// require_once 'Zend/Search/Lucene/Document/OpenXml.php'; - -/** Zend_Xml_Security */ -// require_once 'Zend/Xml/Security.php'; - -/** - * Docx document. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Document - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Document_Docx extends Zend_Search_Lucene_Document_OpenXml { - /** - * Xml Schema - WordprocessingML - * - * @var string - */ - const SCHEMA_WORDPROCESSINGML = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'; - - /** - * Object constructor - * - * @param string $fileName - * @param boolean $storeContent - * @throws Zend_Search_Lucene_Exception - */ - private function __construct($fileName, $storeContent) { - if (!class_exists('ZipArchive', false)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('MS Office documents processing functionality requires Zip extension to be loaded'); - } - - // Document data holders - $documentBody = array(); - $coreProperties = array(); - - // Open OpenXML package - $package = new ZipArchive(); - $package->open($fileName); - - // Read relations and search for officeDocument - $relationsXml = $package->getFromName('_rels/.rels'); - if ($relationsXml === false) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Invalid archive or corrupted .docx file.'); - } - $relations = Zend_Xml_Security::scan($relationsXml); - foreach($relations->Relationship as $rel) { - if ($rel ["Type"] == Zend_Search_Lucene_Document_OpenXml::SCHEMA_OFFICEDOCUMENT) { - // Found office document! Read in contents... - $contents = Zend_Xml_Security::scan($package->getFromName( - $this->absoluteZipPath(dirname($rel['Target']) - . '/' - . basename($rel['Target'])) - )); - - $contents->registerXPathNamespace('w', Zend_Search_Lucene_Document_Docx::SCHEMA_WORDPROCESSINGML); - $paragraphs = $contents->xpath('//w:body/w:p'); - - foreach ($paragraphs as $paragraph) { - $runs = $paragraph->xpath('.//w:r/*[name() = "w:t" or name() = "w:br"]'); - - if ($runs === false) { - // Paragraph doesn't contain any text or breaks - continue; - } - - foreach ($runs as $run) { - if ($run->getName() == 'br') { - // Break element - $documentBody[] = ' '; - } else { - $documentBody[] = (string)$run; - } - } - - // Add space after each paragraph. So they are not bound together. - $documentBody[] = ' '; - } - - break; - } - } - - // Read core properties - $coreProperties = $this->extractMetaData($package); - - // Close file - $package->close(); - - // Store filename - $this->addField(Zend_Search_Lucene_Field::Text('filename', $fileName, 'UTF-8')); - - // Store contents - if ($storeContent) { - $this->addField(Zend_Search_Lucene_Field::Text('body', implode('', $documentBody), 'UTF-8')); - } else { - $this->addField(Zend_Search_Lucene_Field::UnStored('body', implode('', $documentBody), 'UTF-8')); - } - - // Store meta data properties - foreach ($coreProperties as $key => $value) { - $this->addField(Zend_Search_Lucene_Field::Text($key, $value, 'UTF-8')); - } - - // Store title (if not present in meta data) - if (! isset($coreProperties['title'])) { - $this->addField(Zend_Search_Lucene_Field::Text('title', $fileName, 'UTF-8')); - } - } - - /** - * Load Docx document from a file - * - * @param string $fileName - * @param boolean $storeContent - * @return Zend_Search_Lucene_Document_Docx - * @throws Zend_Search_Lucene_Document_Exception - */ - public static function loadDocxFile($fileName, $storeContent = false) { - if (!is_readable($fileName)) { - // require_once 'Zend/Search/Lucene/Document/Exception.php'; - throw new Zend_Search_Lucene_Document_Exception('Provided file \'' . $fileName . '\' is not readable.'); - } - - return new Zend_Search_Lucene_Document_Docx($fileName, $storeContent); - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/Exception.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/Exception.php deleted file mode 100755 index d89e923a9f75370ecbc0021ae6caf54d1db28560..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/Exception.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * Framework base exception - */ -// require_once 'Zend/Search/Lucene/Exception.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Document_Exception extends Zend_Search_Lucene_Exception -{} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/Html.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/Html.php deleted file mode 100755 index 97a22d6cc453b1fd43c30903d7855a0ccf57105b..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/Html.php +++ /dev/null @@ -1,481 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Document - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Document */ -// require_once 'Zend/Search/Lucene/Document.php'; - - -/** - * HTML document. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Document - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Document_Html extends Zend_Search_Lucene_Document -{ - /** - * List of document links - * - * @var array - */ - private $_links = array(); - - /** - * List of document header links - * - * @var array - */ - private $_headerLinks = array(); - - /** - * Stored DOM representation - * - * @var DOMDocument - */ - private $_doc; - - /** - * Exclud nofollow links flag - * - * If true then links with rel='nofollow' attribute are not included into - * document links. - * - * @var boolean - */ - private static $_excludeNoFollowLinks = false; - - /** - * - * List of inline tags - * - * @var array - */ - private $_inlineTags = array('a', 'abbr', 'acronym', 'dfn', 'em', 'strong', 'code', - 'samp', 'kbd', 'var', 'b', 'i', 'big', 'small', 'strike', - 'tt', 'u', 'font', 'span', 'bdo', 'cite', 'del', 'ins', - 'q', 'sub', 'sup'); - - /** - * Object constructor - * - * @param string $data HTML string (may be HTML fragment, ) - * @param boolean $isFile - * @param boolean $storeContent - * @param string $defaultEncoding HTML encoding, is used if it's not specified using Content-type HTTP-EQUIV meta tag. - */ - private function __construct($data, $isFile, $storeContent, $defaultEncoding = '') - { - $this->_doc = new DOMDocument(); - $this->_doc->substituteEntities = true; - - if ($isFile) { - $htmlData = file_get_contents($data); - } else { - $htmlData = $data; - } - @$this->_doc->loadHTML($htmlData); - - if ($this->_doc->encoding === null) { - // Document encoding is not recognized - - /** @todo improve HTML vs HTML fragment recognition */ - if (preg_match('/<html[^>]*>/i', $htmlData, $matches, PREG_OFFSET_CAPTURE)) { - // It's an HTML document - // Add additional HEAD section and recognize document - $htmlTagOffset = $matches[0][1] + strlen($matches[0][0]); - - @$this->_doc->loadHTML(iconv($defaultEncoding, 'UTF-8//IGNORE', substr($htmlData, 0, $htmlTagOffset)) - . '<head><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"/></head>' - . iconv($defaultEncoding, 'UTF-8//IGNORE', substr($htmlData, $htmlTagOffset))); - - // Remove additional HEAD section - $xpath = new DOMXPath($this->_doc); - $head = $xpath->query('/html/head')->item(0); - $head->parentNode->removeChild($head); - } else { - // It's an HTML fragment - @$this->_doc->loadHTML('<html><head><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"/></head><body>' - . iconv($defaultEncoding, 'UTF-8//IGNORE', $htmlData) - . '</body></html>'); - } - - } - /** @todo Add correction of wrong HTML encoding recognition processing - * The case is: - * Content-type HTTP-EQUIV meta tag is presented, but ISO-8859-5 encoding is actually used, - * even $this->_doc->encoding demonstrates another recognized encoding - */ - - $xpath = new DOMXPath($this->_doc); - - $docTitle = ''; - $titleNodes = $xpath->query('/html/head/title'); - foreach ($titleNodes as $titleNode) { - // title should always have only one entry, but we process all nodeset entries - $docTitle .= $titleNode->nodeValue . ' '; - } - $this->addField(Zend_Search_Lucene_Field::Text('title', $docTitle, 'UTF-8')); - - $metaNodes = $xpath->query('/html/head/meta[@name]'); - foreach ($metaNodes as $metaNode) { - $this->addField(Zend_Search_Lucene_Field::Text($metaNode->getAttribute('name'), - $metaNode->getAttribute('content'), - 'UTF-8')); - } - - $docBody = ''; - $bodyNodes = $xpath->query('/html/body'); - foreach ($bodyNodes as $bodyNode) { - // body should always have only one entry, but we process all nodeset entries - $this->_retrieveNodeText($bodyNode, $docBody); - } - if ($storeContent) { - $this->addField(Zend_Search_Lucene_Field::Text('body', $docBody, 'UTF-8')); - } else { - $this->addField(Zend_Search_Lucene_Field::UnStored('body', $docBody, 'UTF-8')); - } - - $linkNodes = $this->_doc->getElementsByTagName('a'); - foreach ($linkNodes as $linkNode) { - if (($href = $linkNode->getAttribute('href')) != '' && - (!self::$_excludeNoFollowLinks || strtolower($linkNode->getAttribute('rel')) != 'nofollow' ) - ) { - $this->_links[] = $href; - } - } - $linkNodes = $this->_doc->getElementsByTagName('area'); - foreach ($linkNodes as $linkNode) { - if (($href = $linkNode->getAttribute('href')) != '' && - (!self::$_excludeNoFollowLinks || strtolower($linkNode->getAttribute('rel')) != 'nofollow' ) - ) { - $this->_links[] = $href; - } - } - $this->_links = array_unique($this->_links); - - $linkNodes = $xpath->query('/html/head/link'); - foreach ($linkNodes as $linkNode) { - if (($href = $linkNode->getAttribute('href')) != '') { - $this->_headerLinks[] = $href; - } - } - $this->_headerLinks = array_unique($this->_headerLinks); - } - - /** - * Set exclude nofollow links flag - * - * @param boolean $newValue - */ - public static function setExcludeNoFollowLinks($newValue) - { - self::$_excludeNoFollowLinks = $newValue; - } - - /** - * Get exclude nofollow links flag - * - * @return boolean - */ - public static function getExcludeNoFollowLinks() - { - return self::$_excludeNoFollowLinks; - } - - /** - * Get node text - * - * We should exclude scripts, which may be not included into comment tags, CDATA sections, - * - * @param DOMNode $node - * @param string &$text - */ - private function _retrieveNodeText(DOMNode $node, &$text) - { - if ($node->nodeType == XML_TEXT_NODE) { - $text .= $node->nodeValue; - if(!in_array($node->parentNode->tagName, $this->_inlineTags)) { - $text .= ' '; - } - } else if ($node->nodeType == XML_ELEMENT_NODE && $node->nodeName != 'script') { - foreach ($node->childNodes as $childNode) { - $this->_retrieveNodeText($childNode, $text); - } - } - } - - /** - * Get document HREF links - * - * @return array - */ - public function getLinks() - { - return $this->_links; - } - - /** - * Get document header links - * - * @return array - */ - public function getHeaderLinks() - { - return $this->_headerLinks; - } - - /** - * Load HTML document from a string - * - * @param string $data - * @param boolean $storeContent - * @param string $defaultEncoding HTML encoding, is used if it's not specified using Content-type HTTP-EQUIV meta tag. - * @return Zend_Search_Lucene_Document_Html - */ - public static function loadHTML($data, $storeContent = false, $defaultEncoding = '') - { - return new Zend_Search_Lucene_Document_Html($data, false, $storeContent, $defaultEncoding); - } - - /** - * Load HTML document from a file - * - * @param string $file - * @param boolean $storeContent - * @param string $defaultEncoding HTML encoding, is used if it's not specified using Content-type HTTP-EQUIV meta tag. - * @return Zend_Search_Lucene_Document_Html - */ - public static function loadHTMLFile($file, $storeContent = false, $defaultEncoding = '') - { - return new Zend_Search_Lucene_Document_Html($file, true, $storeContent, $defaultEncoding); - } - - - /** - * Highlight text in text node - * - * @param DOMText $node - * @param array $wordsToHighlight - * @param callback $callback Callback method, used to transform (highlighting) text. - * @param array $params Array of additionall callback parameters (first non-optional parameter is a text to transform) - * @throws Zend_Search_Lucene_Exception - */ - protected function _highlightTextNode(DOMText $node, $wordsToHighlight, $callback, $params) - { - /** Zend_Search_Lucene_Analysis_Analyzer */ - // require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - - $analyzer = Zend_Search_Lucene_Analysis_Analyzer::getDefault(); - $analyzer->setInput($node->nodeValue, 'UTF-8'); - - $matchedTokens = array(); - - while (($token = $analyzer->nextToken()) !== null) { - if (isset($wordsToHighlight[$token->getTermText()])) { - $matchedTokens[] = $token; - } - } - - if (count($matchedTokens) == 0) { - return; - } - - $matchedTokens = array_reverse($matchedTokens); - - foreach ($matchedTokens as $token) { - // Cut text after matched token - $node->splitText($token->getEndOffset()); - - // Cut matched node - $matchedWordNode = $node->splitText($token->getStartOffset()); - - // Retrieve HTML string representation for highlihted word - $fullCallbackparamsList = $params; - array_unshift($fullCallbackparamsList, $matchedWordNode->nodeValue); - $highlightedWordNodeSetHtml = call_user_func_array($callback, $fullCallbackparamsList); - - // Transform HTML string to a DOM representation and automatically transform retrieved string - // into valid XHTML (It's automatically done by loadHTML() method) - $highlightedWordNodeSetDomDocument = new DOMDocument('1.0', 'UTF-8'); - $success = @$highlightedWordNodeSetDomDocument-> - loadHTML('<html><head><meta http-equiv="Content-type" content="text/html; charset=UTF-8"/></head><body>' - . $highlightedWordNodeSetHtml - . '</body></html>'); - if (!$success) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception("Error occured while loading highlighted text fragment: '$highlightedWordNodeSetHtml'."); - } - $highlightedWordNodeSetXpath = new DOMXPath($highlightedWordNodeSetDomDocument); - $highlightedWordNodeSet = $highlightedWordNodeSetXpath->query('/html/body')->item(0)->childNodes; - - for ($count = 0; $count < $highlightedWordNodeSet->length; $count++) { - $nodeToImport = $highlightedWordNodeSet->item($count); - $node->parentNode->insertBefore($this->_doc->importNode($nodeToImport, true /* deep copy */), - $matchedWordNode); - } - - $node->parentNode->removeChild($matchedWordNode); - } - } - - - /** - * highlight words in content of the specified node - * - * @param DOMNode $contextNode - * @param array $wordsToHighlight - * @param callback $callback Callback method, used to transform (highlighting) text. - * @param array $params Array of additionall callback parameters (first non-optional parameter is a text to transform) - */ - protected function _highlightNodeRecursive(DOMNode $contextNode, $wordsToHighlight, $callback, $params) - { - $textNodes = array(); - - if (!$contextNode->hasChildNodes()) { - return; - } - - foreach ($contextNode->childNodes as $childNode) { - if ($childNode->nodeType == XML_TEXT_NODE) { - // process node later to leave childNodes structure untouched - $textNodes[] = $childNode; - } else { - // Process node if it's not a script node - if ($childNode->nodeName != 'script') { - $this->_highlightNodeRecursive($childNode, $wordsToHighlight, $callback, $params); - } - } - } - - foreach ($textNodes as $textNode) { - $this->_highlightTextNode($textNode, $wordsToHighlight, $callback, $params); - } - } - - /** - * Standard callback method used to highlight words. - * - * @param string $stringToHighlight - * @return string - * @internal - */ - public function applyColour($stringToHighlight, $colour) - { - return '<b style="color:black;background-color:' . $colour . '">' . $stringToHighlight . '</b>'; - } - - /** - * Highlight text with specified color - * - * @param string|array $words - * @param string $colour - * @return string - */ - public function highlight($words, $colour = '#66ffff') - { - return $this->highlightExtended($words, array($this, 'applyColour'), array($colour)); - } - - - - /** - * Highlight text using specified View helper or callback function. - * - * @param string|array $words Words to highlight. Words could be organized using the array or string. - * @param callback $callback Callback method, used to transform (highlighting) text. - * @param array $params Array of additionall callback parameters passed through into it - * (first non-optional parameter is an HTML fragment for highlighting) - * @return string - * @throws Zend_Search_Lucene_Exception - */ - public function highlightExtended($words, $callback, $params = array()) - { - /** Zend_Search_Lucene_Analysis_Analyzer */ - // require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - - if (!is_array($words)) { - $words = array($words); - } - - $wordsToHighlightList = array(); - $analyzer = Zend_Search_Lucene_Analysis_Analyzer::getDefault(); - foreach ($words as $wordString) { - $wordsToHighlightList[] = $analyzer->tokenize($wordString); - } - $wordsToHighlight = call_user_func_array('array_merge', $wordsToHighlightList); - - if (count($wordsToHighlight) == 0) { - return $this->_doc->saveHTML(); - } - - $wordsToHighlightFlipped = array(); - foreach ($wordsToHighlight as $id => $token) { - $wordsToHighlightFlipped[$token->getTermText()] = $id; - } - - if (!is_callable($callback)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('$viewHelper parameter must be a View Helper name, View Helper object or callback.'); - } - - $xpath = new DOMXPath($this->_doc); - - $matchedNodes = $xpath->query("/html/body"); - foreach ($matchedNodes as $matchedNode) { - $this->_highlightNodeRecursive($matchedNode, $wordsToHighlightFlipped, $callback, $params); - } - } - - - /** - * Get HTML - * - * @return string - */ - public function getHTML() - { - return $this->_doc->saveHTML(); - } - - /** - * Get HTML body - * - * @return string - */ - public function getHtmlBody() - { - $xpath = new DOMXPath($this->_doc); - $bodyNodes = $xpath->query('/html/body')->item(0)->childNodes; - - $outputFragments = array(); - for ($count = 0; $count < $bodyNodes->length; $count++) { - $outputFragments[] = $this->_doc->saveXML($bodyNodes->item($count)); - } - - return implode($outputFragments); - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/OpenXml.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/OpenXml.php deleted file mode 100755 index d234e9a7a38f57ddd7b8b5b6237b0c866f93c58f..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/OpenXml.php +++ /dev/null @@ -1,131 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Document - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Document */ -// require_once 'Zend/Search/Lucene/Document.php'; - -/** Zend_Xml_Security */ -// require_once 'Zend/Xml/Security.php'; - -/** - * OpenXML document. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Document - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Search_Lucene_Document_OpenXml extends Zend_Search_Lucene_Document -{ - /** - * Xml Schema - Relationships - * - * @var string - */ - const SCHEMA_RELATIONSHIP = 'http://schemas.openxmlformats.org/package/2006/relationships'; - - /** - * Xml Schema - Office document - * - * @var string - */ - const SCHEMA_OFFICEDOCUMENT = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument'; - - /** - * Xml Schema - Core properties - * - * @var string - */ - const SCHEMA_COREPROPERTIES = 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties'; - - /** - * Xml Schema - Dublin Core - * - * @var string - */ - const SCHEMA_DUBLINCORE = 'http://purl.org/dc/elements/1.1/'; - - /** - * Xml Schema - Dublin Core Terms - * - * @var string - */ - const SCHEMA_DUBLINCORETERMS = 'http://purl.org/dc/terms/'; - - /** - * Extract metadata from document - * - * @param ZipArchive $package ZipArchive OpenXML package - * @return array Key-value pairs containing document meta data - */ - protected function extractMetaData(ZipArchive $package) - { - // Data holders - $coreProperties = array(); - - // Read relations and search for core properties - $relations = Zend_Xml_Security::scan($package->getFromName("_rels/.rels")); - foreach ($relations->Relationship as $rel) { - if ($rel["Type"] == Zend_Search_Lucene_Document_OpenXml::SCHEMA_COREPROPERTIES) { - // Found core properties! Read in contents... - $contents = Zend_Xml_Security::scan( - $package->getFromName(dirname($rel["Target"]) . "/" . basename($rel["Target"])) - ); - - foreach ($contents->children(Zend_Search_Lucene_Document_OpenXml::SCHEMA_DUBLINCORE) as $child) { - $coreProperties[$child->getName()] = (string)$child; - } - foreach ($contents->children(Zend_Search_Lucene_Document_OpenXml::SCHEMA_COREPROPERTIES) as $child) { - $coreProperties[$child->getName()] = (string)$child; - } - foreach ($contents->children(Zend_Search_Lucene_Document_OpenXml::SCHEMA_DUBLINCORETERMS) as $child) { - $coreProperties[$child->getName()] = (string)$child; - } - } - } - - return $coreProperties; - } - - /** - * Determine absolute zip path - * - * @param string $path - * @return string - */ - protected function absoluteZipPath($path) { - $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); - $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen'); - $absolutes = array(); - foreach ($parts as $part) { - if ('.' == $part) continue; - if ('..' == $part) { - array_pop($absolutes); - } else { - $absolutes[] = $part; - } - } - return implode('/', $absolutes); - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/Pptx.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/Pptx.php deleted file mode 100755 index b450840b8fbac33c2778a003856aa958d064fea8..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/Pptx.php +++ /dev/null @@ -1,202 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Document - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Xml_Security */ -// require_once 'Zend/Xml/Security.php'; - -/** Zend_Search_Lucene_Document_OpenXml */ -// require_once 'Zend/Search/Lucene/Document/OpenXml.php'; - -/** - * Pptx document. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Document - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Document_Pptx extends Zend_Search_Lucene_Document_OpenXml -{ - /** - * Xml Schema - PresentationML - * - * @var string - */ - const SCHEMA_PRESENTATIONML = 'http://schemas.openxmlformats.org/presentationml/2006/main'; - - /** - * Xml Schema - DrawingML - * - * @var string - */ - const SCHEMA_DRAWINGML = 'http://schemas.openxmlformats.org/drawingml/2006/main'; - - /** - * Xml Schema - Slide relation - * - * @var string - */ - const SCHEMA_SLIDERELATION = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide'; - - /** - * Xml Schema - Slide notes relation - * - * @var string - */ - const SCHEMA_SLIDENOTESRELATION = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide'; - - /** - * Object constructor - * - * @param string $fileName - * @param boolean $storeContent - * @throws Zend_Search_Lucene_Exception - */ - private function __construct($fileName, $storeContent) - { - if (!class_exists('ZipArchive', false)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('MS Office documents processing functionality requires Zip extension to be loaded'); - } - - // Document data holders - $slides = array(); - $slideNotes = array(); - $documentBody = array(); - $coreProperties = array(); - - // Open OpenXML package - $package = new ZipArchive(); - $package->open($fileName); - - // Read relations and search for officeDocument - $relationsXml = $package->getFromName('_rels/.rels'); - if ($relationsXml === false) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Invalid archive or corrupted .pptx file.'); - } - $relations = Zend_Xml_Security::scan($relationsXml); - foreach ($relations->Relationship as $rel) { - if ($rel["Type"] == Zend_Search_Lucene_Document_OpenXml::SCHEMA_OFFICEDOCUMENT) { - // Found office document! Search for slides... - $slideRelations = Zend_Xml_Security::scan($package->getFromName( $this->absoluteZipPath(dirname($rel["Target"]) . "/_rels/" . basename($rel["Target"]) . ".rels")) ); - foreach ($slideRelations->Relationship as $slideRel) { - if ($slideRel["Type"] == Zend_Search_Lucene_Document_Pptx::SCHEMA_SLIDERELATION) { - // Found slide! - $slides[ str_replace( 'rId', '', (string)$slideRel["Id"] ) ] = Zend_Xml_Security::scan( - $package->getFromName( $this->absoluteZipPath(dirname($rel["Target"]) . "/" . dirname($slideRel["Target"]) . "/" . basename($slideRel["Target"])) ) - ); - - // Search for slide notes - $slideNotesRelations = Zend_Xml_Security::scan($package->getFromName( $this->absoluteZipPath(dirname($rel["Target"]) . "/" . dirname($slideRel["Target"]) . "/_rels/" . basename($slideRel["Target"]) . ".rels")) ); - foreach ($slideNotesRelations->Relationship as $slideNoteRel) { - if ($slideNoteRel["Type"] == Zend_Search_Lucene_Document_Pptx::SCHEMA_SLIDENOTESRELATION) { - // Found slide notes! - $slideNotes[ str_replace( 'rId', '', (string)$slideRel["Id"] ) ] = Zend_Xml_Security::scan( - $package->getFromName( $this->absoluteZipPath(dirname($rel["Target"]) . "/" . dirname($slideRel["Target"]) . "/" . dirname($slideNoteRel["Target"]) . "/" . basename($slideNoteRel["Target"])) ) - ); - - break; - } - } - } - } - - break; - } - } - - // Sort slides - ksort($slides); - ksort($slideNotes); - - // Extract contents from slides - foreach ($slides as $slideKey => $slide) { - // Register namespaces - $slide->registerXPathNamespace("p", Zend_Search_Lucene_Document_Pptx::SCHEMA_PRESENTATIONML); - $slide->registerXPathNamespace("a", Zend_Search_Lucene_Document_Pptx::SCHEMA_DRAWINGML); - - // Fetch all text - $textElements = $slide->xpath('//a:t'); - foreach ($textElements as $textElement) { - $documentBody[] = (string)$textElement; - } - - // Extract contents from slide notes - if (isset($slideNotes[$slideKey])) { - // Fetch slide note - $slideNote = $slideNotes[$slideKey]; - - // Register namespaces - $slideNote->registerXPathNamespace("p", Zend_Search_Lucene_Document_Pptx::SCHEMA_PRESENTATIONML); - $slideNote->registerXPathNamespace("a", Zend_Search_Lucene_Document_Pptx::SCHEMA_DRAWINGML); - - // Fetch all text - $textElements = $slideNote->xpath('//a:t'); - foreach ($textElements as $textElement) { - $documentBody[] = (string)$textElement; - } - } - } - - // Read core properties - $coreProperties = $this->extractMetaData($package); - - // Close file - $package->close(); - - // Store filename - $this->addField(Zend_Search_Lucene_Field::Text('filename', $fileName, 'UTF-8')); - - // Store contents - if ($storeContent) { - $this->addField(Zend_Search_Lucene_Field::Text('body', implode(' ', $documentBody), 'UTF-8')); - } else { - $this->addField(Zend_Search_Lucene_Field::UnStored('body', implode(' ', $documentBody), 'UTF-8')); - } - - // Store meta data properties - foreach ($coreProperties as $key => $value) - { - $this->addField(Zend_Search_Lucene_Field::Text($key, $value, 'UTF-8')); - } - - // Store title (if not present in meta data) - if (!isset($coreProperties['title'])) - { - $this->addField(Zend_Search_Lucene_Field::Text('title', $fileName, 'UTF-8')); - } - } - - /** - * Load Pptx document from a file - * - * @param string $fileName - * @param boolean $storeContent - * @return Zend_Search_Lucene_Document_Pptx - */ - public static function loadPptxFile($fileName, $storeContent = false) - { - return new Zend_Search_Lucene_Document_Pptx($fileName, $storeContent); - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/Xlsx.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/Xlsx.php deleted file mode 100755 index c8e3b421ebd57cef724cd621335a39597dab69fe..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Document/Xlsx.php +++ /dev/null @@ -1,266 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Document - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Document_OpenXml */ -// require_once 'Zend/Search/Lucene/Document/OpenXml.php'; - -/** Zend_Xml_Security */ -// require_once 'Zend/Xml/Security.php'; - -/** - * Xlsx document. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Document - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Document_Xlsx extends Zend_Search_Lucene_Document_OpenXml -{ - /** - * Xml Schema - SpreadsheetML - * - * @var string - */ - const SCHEMA_SPREADSHEETML = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'; - - /** - * Xml Schema - DrawingML - * - * @var string - */ - const SCHEMA_DRAWINGML = 'http://schemas.openxmlformats.org/drawingml/2006/main'; - - /** - * Xml Schema - Shared Strings - * - * @var string - */ - const SCHEMA_SHAREDSTRINGS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings'; - - /** - * Xml Schema - Worksheet relation - * - * @var string - */ - const SCHEMA_WORKSHEETRELATION = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet'; - - /** - * Xml Schema - Slide notes relation - * - * @var string - */ - const SCHEMA_SLIDENOTESRELATION = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide'; - - /** - * Object constructor - * - * @param string $fileName - * @param boolean $storeContent - * @throws Zend_Search_Lucene_Exception - */ - private function __construct($fileName, $storeContent) - { - if (!class_exists('ZipArchive', false)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('MS Office documents processing functionality requires Zip extension to be loaded'); - } - - // Document data holders - $sharedStrings = array(); - $worksheets = array(); - $documentBody = array(); - $coreProperties = array(); - - // Open OpenXML package - $package = new ZipArchive(); - $package->open($fileName); - - // Read relations and search for officeDocument - $relationsXml = $package->getFromName('_rels/.rels'); - if ($relationsXml === false) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Invalid archive or corrupted .xlsx file.'); - } - $relations = Zend_Xml_Security::scan($relationsXml); - foreach ($relations->Relationship as $rel) { - if ($rel["Type"] == Zend_Search_Lucene_Document_OpenXml::SCHEMA_OFFICEDOCUMENT) { - // Found office document! Read relations for workbook... - $workbookRelations = Zend_Xml_Security::scan($package->getFromName( $this->absoluteZipPath(dirname($rel["Target"]) . "/_rels/" . basename($rel["Target"]) . ".rels")) ); - $workbookRelations->registerXPathNamespace("rel", Zend_Search_Lucene_Document_OpenXml::SCHEMA_RELATIONSHIP); - - // Read shared strings - $sharedStringsPath = $workbookRelations->xpath("rel:Relationship[@Type='" . Zend_Search_Lucene_Document_Xlsx::SCHEMA_SHAREDSTRINGS . "']"); - $sharedStringsPath = (string)$sharedStringsPath[0]['Target']; - $xmlStrings = Zend_Xml_Security::scan($package->getFromName( $this->absoluteZipPath(dirname($rel["Target"]) . "/" . $sharedStringsPath)) ); - if (isset($xmlStrings) && isset($xmlStrings->si)) { - foreach ($xmlStrings->si as $val) { - if (isset($val->t)) { - $sharedStrings[] = (string)$val->t; - } elseif (isset($val->r)) { - $sharedStrings[] = $this->_parseRichText($val); - } - } - } - - // Loop relations for workbook and extract worksheets... - foreach ($workbookRelations->Relationship as $workbookRelation) { - if ($workbookRelation["Type"] == Zend_Search_Lucene_Document_Xlsx::SCHEMA_WORKSHEETRELATION) { - $worksheets[ str_replace( 'rId', '', (string)$workbookRelation["Id"]) ] = Zend_Xml_Security::scan( - $package->getFromName( $this->absoluteZipPath(dirname($rel["Target"]) . "/" . dirname($workbookRelation["Target"]) . "/" . basename($workbookRelation["Target"])) ) - ); - } - } - - break; - } - } - - // Sort worksheets - ksort($worksheets); - - // Extract contents from worksheets - foreach ($worksheets as $sheetKey => $worksheet) { - foreach ($worksheet->sheetData->row as $row) { - foreach ($row->c as $c) { - // Determine data type - $dataType = (string)$c["t"]; - switch ($dataType) { - case "s": - // Value is a shared string - if ((string)$c->v != '') { - $value = $sharedStrings[intval($c->v)]; - } else { - $value = ''; - } - - break; - - case "b": - // Value is boolean - $value = (string)$c->v; - if ($value == '0') { - $value = false; - } else if ($value == '1') { - $value = true; - } else { - $value = (bool)$c->v; - } - - break; - - case "inlineStr": - // Value is rich text inline - $value = $this->_parseRichText($c->is); - - break; - - case "e": - // Value is an error message - if ((string)$c->v != '') { - $value = (string)$c->v; - } else { - $value = ''; - } - - break; - - default: - // Value is a string - $value = (string)$c->v; - - // Check for numeric values - if (is_numeric($value) && $dataType != 's') { - if ($value == (int)$value) $value = (int)$value; - elseif ($value == (float)$value) $value = (float)$value; - elseif ($value == (double)$value) $value = (double)$value; - } - } - - $documentBody[] = $value; - } - } - } - - // Read core properties - $coreProperties = $this->extractMetaData($package); - - // Close file - $package->close(); - - // Store filename - $this->addField(Zend_Search_Lucene_Field::Text('filename', $fileName, 'UTF-8')); - - // Store contents - if ($storeContent) { - $this->addField(Zend_Search_Lucene_Field::Text('body', implode(' ', $documentBody), 'UTF-8')); - } else { - $this->addField(Zend_Search_Lucene_Field::UnStored('body', implode(' ', $documentBody), 'UTF-8')); - } - - // Store meta data properties - foreach ($coreProperties as $key => $value) - { - $this->addField(Zend_Search_Lucene_Field::Text($key, $value, 'UTF-8')); - } - - // Store title (if not present in meta data) - if (!isset($coreProperties['title'])) - { - $this->addField(Zend_Search_Lucene_Field::Text('title', $fileName, 'UTF-8')); - } - } - - /** - * Parse rich text XML - * - * @param SimpleXMLElement $is - * @return string - */ - private function _parseRichText($is = null) { - $value = array(); - - if (isset($is->t)) { - $value[] = (string)$is->t; - } else { - foreach ($is->r as $run) { - $value[] = (string)$run->t; - } - } - - return implode('', $value); - } - - /** - * Load Xlsx document from a file - * - * @param string $fileName - * @param boolean $storeContent - * @return Zend_Search_Lucene_Document_Xlsx - */ - public static function loadXlsxFile($fileName, $storeContent = false) - { - return new Zend_Search_Lucene_Document_Xlsx($fileName, $storeContent); - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Exception.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Exception.php deleted file mode 100755 index 6d4c383e20fd01e58f163a46652d2d7d4a7bfff7..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Exception.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * Framework base exception - */ -// require_once 'Zend/Search/Exception.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Exception extends Zend_Search_Exception -{} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/FSM.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/FSM.php deleted file mode 100755 index 48e9e0ab807c2f2abcfae4d6f954a61fcc8f01df..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/FSM.php +++ /dev/null @@ -1,443 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_FSMAction */ -// require_once 'Zend/Search/Lucene/FSMAction.php'; - -/** - * Abstract Finite State Machine - * - * Take a look on Wikipedia state machine description: http://en.wikipedia.org/wiki/Finite_state_machine - * - * Any type of Transducers (Moore machine or Mealy machine) also may be implemented by using this abstract FSM. - * process() methods invokes a specified actions which may construct FSM output. - * Actions may be also used to signal, that we have reached Accept State - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Search_Lucene_FSM -{ - /** - * Machine States alphabet - * - * @var array - */ - private $_states = array(); - - /** - * Current state - * - * @var integer|string - */ - private $_currentState = null; - - /** - * Input alphabet - * - * @var array - */ - private $_inputAphabet = array(); - - /** - * State transition table - * - * [sourceState][input] => targetState - * - * @var array - */ - private $_rules = array(); - - /** - * List of entry actions - * Each action executes when entering the state - * - * [state] => action - * - * @var array - */ - private $_entryActions = array(); - - /** - * List of exit actions - * Each action executes when exiting the state - * - * [state] => action - * - * @var array - */ - private $_exitActions = array(); - - /** - * List of input actions - * Each action executes when entering the state - * - * [state][input] => action - * - * @var array - */ - private $_inputActions = array(); - - /** - * List of input actions - * Each action executes when entering the state - * - * [state1][state2] => action - * - * @var array - */ - private $_transitionActions = array(); - - /** - * Finite State machine constructor - * - * $states is an array of integers or strings with a list of possible machine states - * constructor treats fist list element as a sturt state (assignes it to $_current state). - * It may be reassigned by setState() call. - * States list may be empty and can be extended later by addState() or addStates() calls. - * - * $inputAphabet is the same as $states, but represents input alphabet - * it also may be extended later by addInputSymbols() or addInputSymbol() calls. - * - * $rules parameter describes FSM transitions and has a structure: - * array( array(sourseState, input, targetState[, inputAction]), - * array(sourseState, input, targetState[, inputAction]), - * array(sourseState, input, targetState[, inputAction]), - * ... - * ) - * Rules also can be added later by addRules() and addRule() calls. - * - * FSM actions are very flexible and may be defined by addEntryAction(), addExitAction(), - * addInputAction() and addTransitionAction() calls. - * - * @param array $states - * @param array $inputAphabet - * @param array $rules - */ - public function __construct($states = array(), $inputAphabet = array(), $rules = array()) - { - $this->addStates($states); - $this->addInputSymbols($inputAphabet); - $this->addRules($rules); - } - - /** - * Add states to the state machine - * - * @param array $states - */ - public function addStates($states) - { - foreach ($states as $state) { - $this->addState($state); - } - } - - /** - * Add state to the state machine - * - * @param integer|string $state - */ - public function addState($state) - { - $this->_states[$state] = $state; - - if ($this->_currentState === null) { - $this->_currentState = $state; - } - } - - /** - * Set FSM state. - * No any action is invoked - * - * @param integer|string $state - * @throws Zend_Search_Exception - */ - public function setState($state) - { - if (!isset($this->_states[$state])) { - // require_once 'Zend/Search/Exception.php'; - throw new Zend_Search_Exception('State \'' . $state . '\' is not on of the possible FSM states.'); - } - - $this->_currentState = $state; - } - - /** - * Get FSM state. - * - * @return integer|string $state|null - */ - public function getState() - { - return $this->_currentState; - } - - /** - * Add symbols to the input alphabet - * - * @param array $inputAphabet - */ - public function addInputSymbols($inputAphabet) - { - foreach ($inputAphabet as $inputSymbol) { - $this->addInputSymbol($inputSymbol); - } - } - - /** - * Add symbol to the input alphabet - * - * @param integer|string $inputSymbol - */ - public function addInputSymbol($inputSymbol) - { - $this->_inputAphabet[$inputSymbol] = $inputSymbol; - } - - - /** - * Add transition rules - * - * array structure: - * array( array(sourseState, input, targetState[, inputAction]), - * array(sourseState, input, targetState[, inputAction]), - * array(sourseState, input, targetState[, inputAction]), - * ... - * ) - * - * @param array $rules - */ - public function addRules($rules) - { - foreach ($rules as $rule) { - $this->addrule($rule[0], $rule[1], $rule[2], isset($rule[3])?$rule[3]:null); - } - } - - /** - * Add symbol to the input alphabet - * - * @param integer|string $sourceState - * @param integer|string $input - * @param integer|string $targetState - * @param Zend_Search_Lucene_FSMAction|null $inputAction - * @throws Zend_Search_Exception - */ - public function addRule($sourceState, $input, $targetState, $inputAction = null) - { - if (!isset($this->_states[$sourceState])) { - // require_once 'Zend/Search/Exception.php'; - throw new Zend_Search_Exception('Undefined source state (' . $sourceState . ').'); - } - if (!isset($this->_states[$targetState])) { - // require_once 'Zend/Search/Exception.php'; - throw new Zend_Search_Exception('Undefined target state (' . $targetState . ').'); - } - if (!isset($this->_inputAphabet[$input])) { - // require_once 'Zend/Search/Exception.php'; - throw new Zend_Search_Exception('Undefined input symbol (' . $input . ').'); - } - - if (!isset($this->_rules[$sourceState])) { - $this->_rules[$sourceState] = array(); - } - if (isset($this->_rules[$sourceState][$input])) { - // require_once 'Zend/Search/Exception.php'; - throw new Zend_Search_Exception('Rule for {state,input} pair (' . $sourceState . ', '. $input . ') is already defined.'); - } - - $this->_rules[$sourceState][$input] = $targetState; - - - if ($inputAction !== null) { - $this->addInputAction($sourceState, $input, $inputAction); - } - } - - - /** - * Add state entry action. - * Several entry actions are allowed. - * Action execution order is defined by addEntryAction() calls - * - * @param integer|string $state - * @param Zend_Search_Lucene_FSMAction $action - */ - public function addEntryAction($state, Zend_Search_Lucene_FSMAction $action) - { - if (!isset($this->_states[$state])) { - // require_once 'Zend/Search/Exception.php'; - throw new Zend_Search_Exception('Undefined state (' . $state. ').'); - } - - if (!isset($this->_entryActions[$state])) { - $this->_entryActions[$state] = array(); - } - - $this->_entryActions[$state][] = $action; - } - - /** - * Add state exit action. - * Several exit actions are allowed. - * Action execution order is defined by addEntryAction() calls - * - * @param integer|string $state - * @param Zend_Search_Lucene_FSMAction $action - */ - public function addExitAction($state, Zend_Search_Lucene_FSMAction $action) - { - if (!isset($this->_states[$state])) { - // require_once 'Zend/Search/Exception.php'; - throw new Zend_Search_Exception('Undefined state (' . $state. ').'); - } - - if (!isset($this->_exitActions[$state])) { - $this->_exitActions[$state] = array(); - } - - $this->_exitActions[$state][] = $action; - } - - /** - * Add input action (defined by {state, input} pair). - * Several input actions are allowed. - * Action execution order is defined by addInputAction() calls - * - * @param integer|string $state - * @param integer|string $input - * @param Zend_Search_Lucene_FSMAction $action - */ - public function addInputAction($state, $inputSymbol, Zend_Search_Lucene_FSMAction $action) - { - if (!isset($this->_states[$state])) { - // require_once 'Zend/Search/Exception.php'; - throw new Zend_Search_Exception('Undefined state (' . $state. ').'); - } - if (!isset($this->_inputAphabet[$inputSymbol])) { - // require_once 'Zend/Search/Exception.php'; - throw new Zend_Search_Exception('Undefined input symbol (' . $inputSymbol. ').'); - } - - if (!isset($this->_inputActions[$state])) { - $this->_inputActions[$state] = array(); - } - if (!isset($this->_inputActions[$state][$inputSymbol])) { - $this->_inputActions[$state][$inputSymbol] = array(); - } - - $this->_inputActions[$state][$inputSymbol][] = $action; - } - - /** - * Add transition action (defined by {state, input} pair). - * Several transition actions are allowed. - * Action execution order is defined by addTransitionAction() calls - * - * @param integer|string $sourceState - * @param integer|string $targetState - * @param Zend_Search_Lucene_FSMAction $action - */ - public function addTransitionAction($sourceState, $targetState, Zend_Search_Lucene_FSMAction $action) - { - if (!isset($this->_states[$sourceState])) { - // require_once 'Zend/Search/Exception.php'; - throw new Zend_Search_Exception('Undefined source state (' . $sourceState. ').'); - } - if (!isset($this->_states[$targetState])) { - // require_once 'Zend/Search/Exception.php'; - throw new Zend_Search_Exception('Undefined source state (' . $targetState. ').'); - } - - if (!isset($this->_transitionActions[$sourceState])) { - $this->_transitionActions[$sourceState] = array(); - } - if (!isset($this->_transitionActions[$sourceState][$targetState])) { - $this->_transitionActions[$sourceState][$targetState] = array(); - } - - $this->_transitionActions[$sourceState][$targetState][] = $action; - } - - - /** - * Process an input - * - * @param mixed $input - * @throws Zend_Search_Exception - */ - public function process($input) - { - if (!isset($this->_rules[$this->_currentState])) { - // require_once 'Zend/Search/Exception.php'; - throw new Zend_Search_Exception('There is no any rule for current state (' . $this->_currentState . ').'); - } - if (!isset($this->_rules[$this->_currentState][$input])) { - // require_once 'Zend/Search/Exception.php'; - throw new Zend_Search_Exception('There is no any rule for {current state, input} pair (' . $this->_currentState . ', ' . $input . ').'); - } - - $sourceState = $this->_currentState; - $targetState = $this->_rules[$this->_currentState][$input]; - - if ($sourceState != $targetState && isset($this->_exitActions[$sourceState])) { - foreach ($this->_exitActions[$sourceState] as $action) { - $action->doAction(); - } - } - if (isset($this->_inputActions[$sourceState]) && - isset($this->_inputActions[$sourceState][$input])) { - foreach ($this->_inputActions[$sourceState][$input] as $action) { - $action->doAction(); - } - } - - - $this->_currentState = $targetState; - - if (isset($this->_transitionActions[$sourceState]) && - isset($this->_transitionActions[$sourceState][$targetState])) { - foreach ($this->_transitionActions[$sourceState][$targetState] as $action) { - $action->doAction(); - } - } - if ($sourceState != $targetState && isset($this->_entryActions[$targetState])) { - foreach ($this->_entryActions[$targetState] as $action) { - $action->doAction(); - } - } - } - - public function reset() - { - if (count($this->_states) == 0) { - // require_once 'Zend/Search/Exception.php'; - throw new Zend_Search_Exception('There is no any state defined for FSM.'); - } - - $this->_currentState = $this->_states[0]; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/FSMAction.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/FSMAction.php deleted file mode 100755 index aee126320e64d2e6e9f60462a15a2d4744cdf724..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/FSMAction.php +++ /dev/null @@ -1,66 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * Abstract Finite State Machine - * - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_FSMAction -{ - /** - * Object reference - * - * @var object - */ - private $_object; - - /** - * Method name - * - * @var string - */ - private $_method; - - /** - * Object constructor - * - * @param object $object - * @param string $method - */ - public function __construct($object, $method) - { - $this->_object = $object; - $this->_method = $method; - } - - public function doAction() - { - $methodName = $this->_method; - $this->_object->$methodName(); - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Field.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Field.php deleted file mode 100755 index 2c187dcea2f57ea517bc970dcb19f3ad76b3cb8e..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Field.php +++ /dev/null @@ -1,226 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Document - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * A field is a section of a Document. Each field has two parts, - * a name and a value. Values may be free text or they may be atomic - * keywords, which are not further processed. Such keywords may - * be used to represent dates, urls, etc. Fields are optionally - * stored in the index, so that they may be returned with hits - * on the document. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Document - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Field -{ - /** - * Field name - * - * @var string - */ - public $name; - - /** - * Field value - * - * @var boolean - */ - public $value; - - /** - * Field is to be stored in the index for return with search hits. - * - * @var boolean - */ - public $isStored = false; - - /** - * Field is to be indexed, so that it may be searched on. - * - * @var boolean - */ - public $isIndexed = true; - - /** - * Field should be tokenized as text prior to indexing. - * - * @var boolean - */ - public $isTokenized = true; - /** - * Field is stored as binary. - * - * @var boolean - */ - public $isBinary = false; - - /** - * Field are stored as a term vector - * - * @var boolean - */ - public $storeTermVector = false; - - /** - * Field boost factor - * It's not stored directly in the index, but affects on normalization factor - * - * @var float - */ - public $boost = 1.0; - - /** - * Field value encoding. - * - * @var string - */ - public $encoding; - - /** - * Object constructor - * - * @param string $name - * @param string $value - * @param string $encoding - * @param boolean $isStored - * @param boolean $isIndexed - * @param boolean $isTokenized - * @param boolean $isBinary - */ - public function __construct($name, $value, $encoding, $isStored, $isIndexed, $isTokenized, $isBinary = false) - { - $this->name = $name; - $this->value = $value; - - if (!$isBinary) { - $this->encoding = $encoding; - $this->isTokenized = $isTokenized; - } else { - $this->encoding = ''; - $this->isTokenized = false; - } - - $this->isStored = $isStored; - $this->isIndexed = $isIndexed; - $this->isBinary = $isBinary; - - $this->storeTermVector = false; - $this->boost = 1.0; - } - - - /** - * Constructs a String-valued Field that is not tokenized, but is indexed - * and stored. Useful for non-text fields, e.g. date or url. - * - * @param string $name - * @param string $value - * @param string $encoding - * @return Zend_Search_Lucene_Field - */ - public static function keyword($name, $value, $encoding = '') - { - return new self($name, $value, $encoding, true, true, false); - } - - - /** - * Constructs a String-valued Field that is not tokenized nor indexed, - * but is stored in the index, for return with hits. - * - * @param string $name - * @param string $value - * @param string $encoding - * @return Zend_Search_Lucene_Field - */ - public static function unIndexed($name, $value, $encoding = '') - { - return new self($name, $value, $encoding, true, false, false); - } - - - /** - * Constructs a Binary String valued Field that is not tokenized nor indexed, - * but is stored in the index, for return with hits. - * - * @param string $name - * @param string $value - * @param string $encoding - * @return Zend_Search_Lucene_Field - */ - public static function binary($name, $value) - { - return new self($name, $value, '', true, false, false, true); - } - - /** - * Constructs a String-valued Field that is tokenized and indexed, - * and is stored in the index, for return with hits. Useful for short text - * fields, like "title" or "subject". Term vector will not be stored for this field. - * - * @param string $name - * @param string $value - * @param string $encoding - * @return Zend_Search_Lucene_Field - */ - public static function text($name, $value, $encoding = '') - { - return new self($name, $value, $encoding, true, true, true); - } - - - /** - * Constructs a String-valued Field that is tokenized and indexed, - * but that is not stored in the index. - * - * @param string $name - * @param string $value - * @param string $encoding - * @return Zend_Search_Lucene_Field - */ - public static function unStored($name, $value, $encoding = '') - { - return new self($name, $value, $encoding, false, true, true); - } - - /** - * Get field value in UTF-8 encoding - * - * @return string - */ - public function getUtf8Value() - { - if (strcasecmp($this->encoding, 'utf8' ) == 0 || - strcasecmp($this->encoding, 'utf-8') == 0 ) { - return $this->value; - } else { - - return (PHP_OS != 'AIX') ? iconv($this->encoding, 'UTF-8', $this->value) : iconv('ISO8859-1', 'UTF-8', $this->value); - } - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/DictionaryLoader.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/DictionaryLoader.php deleted file mode 100755 index df5bde1a6431a69b5d1cefdab06e6fb6e6042f45..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/DictionaryLoader.php +++ /dev/null @@ -1,268 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** - * Dictionary loader - * - * It's a dummy class which is created to encapsulate non-good structured code. - * Manual "method inlining" is performed to increase dictionary index loading operation - * which is major bottelneck for search performance. - * - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Index_DictionaryLoader -{ - /** - * Dictionary index loader. - * - * It takes a string which is actually <segment_name>.tii index file data and - * returns two arrays - term and tremInfo lists. - * - * See Zend_Search_Lucene_Index_SegmintInfo class for details - * - * @param string $data - * @return array - * @throws Zend_Search_Lucene_Exception - */ - public static function load($data) - { - $termDictionary = array(); - $termInfos = array(); - $pos = 0; - - // $tiVersion = $tiiFile->readInt(); - $tiVersion = ord($data[0]) << 24 | ord($data[1]) << 16 | ord($data[2]) << 8 | ord($data[3]); - $pos += 4; - if ($tiVersion != (int)0xFFFFFFFE /* pre-2.1 format */ && - $tiVersion != (int)0xFFFFFFFD /* 2.1+ format */) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Wrong TermInfoIndexFile file format'); - } - - // $indexTermCount = $tiiFile->readLong(); - if (PHP_INT_SIZE > 4) { - $indexTermCount = ord($data[$pos]) << 56 | - ord($data[$pos+1]) << 48 | - ord($data[$pos+2]) << 40 | - ord($data[$pos+3]) << 32 | - ord($data[$pos+4]) << 24 | - ord($data[$pos+5]) << 16 | - ord($data[$pos+6]) << 8 | - ord($data[$pos+7]); - } else { - if ((ord($data[$pos]) != 0) || - (ord($data[$pos+1]) != 0) || - (ord($data[$pos+2]) != 0) || - (ord($data[$pos+3]) != 0) || - ((ord($data[$pos+4]) & 0x80) != 0)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Largest supported segment size (for 32-bit mode) is 2Gb'); - } - - $indexTermCount = ord($data[$pos+4]) << 24 | - ord($data[$pos+5]) << 16 | - ord($data[$pos+6]) << 8 | - ord($data[$pos+7]); - } - $pos += 8; - - // $tiiFile->readInt(); // IndexInterval - $pos += 4; - - // $skipInterval = $tiiFile->readInt(); - $skipInterval = ord($data[$pos]) << 24 | ord($data[$pos+1]) << 16 | ord($data[$pos+2]) << 8 | ord($data[$pos+3]); - $pos += 4; - if ($indexTermCount < 1) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Wrong number of terms in a term dictionary index'); - } - - if ($tiVersion == (int)0xFFFFFFFD /* 2.1+ format */) { - /* Skip MaxSkipLevels value */ - $pos += 4; - } - - $prevTerm = ''; - $freqPointer = 0; - $proxPointer = 0; - $indexPointer = 0; - for ($count = 0; $count < $indexTermCount; $count++) { - //$termPrefixLength = $tiiFile->readVInt(); - $nbyte = ord($data[$pos++]); - $termPrefixLength = $nbyte & 0x7F; - for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) { - $nbyte = ord($data[$pos++]); - $termPrefixLength |= ($nbyte & 0x7F) << $shift; - } - - // $termSuffix = $tiiFile->readString(); - $nbyte = ord($data[$pos++]); - $len = $nbyte & 0x7F; - for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) { - $nbyte = ord($data[$pos++]); - $len |= ($nbyte & 0x7F) << $shift; - } - if ($len == 0) { - $termSuffix = ''; - } else { - $termSuffix = substr($data, $pos, $len); - $pos += $len; - for ($count1 = 0; $count1 < $len; $count1++ ) { - if (( ord($termSuffix[$count1]) & 0xC0 ) == 0xC0) { - $addBytes = 1; - if (ord($termSuffix[$count1]) & 0x20 ) { - $addBytes++; - - // Never used for Java Lucene created index. - // Java2 doesn't encode strings in four bytes - if (ord($termSuffix[$count1]) & 0x10 ) { - $addBytes++; - } - } - $termSuffix .= substr($data, $pos, $addBytes); - $pos += $addBytes; - $len += $addBytes; - - // Check for null character. Java2 encodes null character - // in two bytes. - if (ord($termSuffix[$count1]) == 0xC0 && - ord($termSuffix[$count1+1]) == 0x80 ) { - $termSuffix[$count1] = 0; - $termSuffix = substr($termSuffix,0,$count1+1) - . substr($termSuffix,$count1+2); - } - $count1 += $addBytes; - } - } - } - - // $termValue = Zend_Search_Lucene_Index_Term::getPrefix($prevTerm, $termPrefixLength) . $termSuffix; - $pb = 0; $pc = 0; - while ($pb < strlen($prevTerm) && $pc < $termPrefixLength) { - $charBytes = 1; - if ((ord($prevTerm[$pb]) & 0xC0) == 0xC0) { - $charBytes++; - if (ord($prevTerm[$pb]) & 0x20 ) { - $charBytes++; - if (ord($prevTerm[$pb]) & 0x10 ) { - $charBytes++; - } - } - } - - if ($pb + $charBytes > strlen($data)) { - // wrong character - break; - } - - $pc++; - $pb += $charBytes; - } - $termValue = substr($prevTerm, 0, $pb) . $termSuffix; - - // $termFieldNum = $tiiFile->readVInt(); - $nbyte = ord($data[$pos++]); - $termFieldNum = $nbyte & 0x7F; - for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) { - $nbyte = ord($data[$pos++]); - $termFieldNum |= ($nbyte & 0x7F) << $shift; - } - - // $docFreq = $tiiFile->readVInt(); - $nbyte = ord($data[$pos++]); - $docFreq = $nbyte & 0x7F; - for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) { - $nbyte = ord($data[$pos++]); - $docFreq |= ($nbyte & 0x7F) << $shift; - } - - // $freqPointer += $tiiFile->readVInt(); - $nbyte = ord($data[$pos++]); - $vint = $nbyte & 0x7F; - for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) { - $nbyte = ord($data[$pos++]); - $vint |= ($nbyte & 0x7F) << $shift; - } - $freqPointer += $vint; - - // $proxPointer += $tiiFile->readVInt(); - $nbyte = ord($data[$pos++]); - $vint = $nbyte & 0x7F; - for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) { - $nbyte = ord($data[$pos++]); - $vint |= ($nbyte & 0x7F) << $shift; - } - $proxPointer += $vint; - - if( $docFreq >= $skipInterval ) { - // $skipDelta = $tiiFile->readVInt(); - $nbyte = ord($data[$pos++]); - $vint = $nbyte & 0x7F; - for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) { - $nbyte = ord($data[$pos++]); - $vint |= ($nbyte & 0x7F) << $shift; - } - $skipDelta = $vint; - } else { - $skipDelta = 0; - } - - // $indexPointer += $tiiFile->readVInt(); - $nbyte = ord($data[$pos++]); - $vint = $nbyte & 0x7F; - for ($shift=7; ($nbyte & 0x80) != 0; $shift += 7) { - $nbyte = ord($data[$pos++]); - $vint |= ($nbyte & 0x7F) << $shift; - } - $indexPointer += $vint; - - - // $this->_termDictionary[] = new Zend_Search_Lucene_Index_Term($termValue, $termFieldNum); - $termDictionary[] = array($termFieldNum, $termValue); - - $termInfos[] = - // new Zend_Search_Lucene_Index_TermInfo($docFreq, $freqPointer, $proxPointer, $skipDelta, $indexPointer); - array($docFreq, $freqPointer, $proxPointer, $skipDelta, $indexPointer); - - $prevTerm = $termValue; - } - - // Check special index entry mark - if ($termDictionary[0][0] != (int)0xFFFFFFFF) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Wrong TermInfoIndexFile file format'); - } - - if (PHP_INT_SIZE > 4) { - // Treat 64-bit 0xFFFFFFFF as -1 - $termDictionary[0][0] = -1; - } - - return array($termDictionary, $termInfos); - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/DocsFilter.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/DocsFilter.php deleted file mode 100755 index 17d9e4e29ada1c0189d03fc9e138a289551b3526..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/DocsFilter.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * A Zend_Search_Lucene_Index_DocsFilter is used to filter documents while searching. - * - * It may or _may_not_ be used for actual filtering, so it's just a hint that upper query limits - * search result by specified list. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Index_DocsFilter -{ - /** - * Set of segment filters: - * array( <segmentName> => array(<docId> => <undefined_value>, - * <docId> => <undefined_value>, - * <docId> => <undefined_value>, - * ... ), - * <segmentName> => array(<docId> => <undefined_value>, - * <docId> => <undefined_value>, - * <docId> => <undefined_value>, - * ... ), - * <segmentName> => array(<docId> => <undefined_value>, - * <docId> => <undefined_value>, - * <docId> => <undefined_value>, - * ... ), - * ... - * ) - * - * @var array - */ - public $segmentFilters = array(); -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/FieldInfo.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/FieldInfo.php deleted file mode 100755 index 7eeaba242508aa13c4af3342049ed60b3884f141..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/FieldInfo.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Index_FieldInfo -{ - public $name; - public $isIndexed; - public $number; - public $storeTermVector; - public $normsOmitted; - public $payloadsStored; - - public function __construct($name, $isIndexed, $number, $storeTermVector, $normsOmitted = false, $payloadsStored = false) - { - $this->name = $name; - $this->isIndexed = $isIndexed; - $this->number = $number; - $this->storeTermVector = $storeTermVector; - $this->normsOmitted = $normsOmitted; - $this->payloadsStored = $payloadsStored; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/SegmentInfo.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/SegmentInfo.php deleted file mode 100755 index 7ae47fb50491ee27e8ce9647c9892b52f5503485..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/SegmentInfo.php +++ /dev/null @@ -1,2132 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_Index_TermsStream_Interface */ -// require_once 'Zend/Search/Lucene/Index/TermsStream/Interface.php'; - - -/** Zend_Search_Lucene_Search_Similarity */ -// require_once 'Zend/Search/Lucene/Search/Similarity.php'; - -/** Zend_Search_Lucene_Index_FieldInfo */ -// require_once 'Zend/Search/Lucene/Index/FieldInfo.php'; - -/** Zend_Search_Lucene_Index_Term */ -// require_once 'Zend/Search/Lucene/Index/Term.php'; - -/** Zend_Search_Lucene_Index_TermInfo */ -// require_once 'Zend/Search/Lucene/Index/TermInfo.php'; - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Index_SegmentInfo implements Zend_Search_Lucene_Index_TermsStream_Interface -{ - /** - * "Full scan vs fetch" boundary. - * - * If filter selectivity is less than this value, then full scan is performed - * (since term entries fetching has some additional overhead). - */ - const FULL_SCAN_VS_FETCH_BOUNDARY = 5; - - /** - * Number of docs in a segment - * - * @var integer - */ - private $_docCount; - - /** - * Segment name - * - * @var string - */ - private $_name; - - /** - * Term Dictionary Index - * - * Array of arrays (Zend_Search_Lucene_Index_Term objects are represented as arrays because - * of performance considerations) - * [0] -> $termValue - * [1] -> $termFieldNum - * - * Corresponding Zend_Search_Lucene_Index_TermInfo object stored in the $_termDictionaryInfos - * - * @var array - */ - private $_termDictionary; - - /** - * Term Dictionary Index TermInfos - * - * Array of arrays (Zend_Search_Lucene_Index_TermInfo objects are represented as arrays because - * of performance considerations) - * [0] -> $docFreq - * [1] -> $freqPointer - * [2] -> $proxPointer - * [3] -> $skipOffset - * [4] -> $indexPointer - * - * @var array - */ - private $_termDictionaryInfos; - - /** - * Segment fields. Array of Zend_Search_Lucene_Index_FieldInfo objects for this segment - * - * @var array - */ - private $_fields; - - /** - * Field positions in a dictionary. - * (Term dictionary contains filelds ordered by names) - * - * @var array - */ - private $_fieldsDicPositions; - - - /** - * Associative array where the key is the file name and the value is data offset - * in a compound segment file (.csf). - * - * @var array - */ - private $_segFiles; - - /** - * Associative array where the key is the file name and the value is file size (.csf). - * - * @var array - */ - private $_segFileSizes; - - /** - * Delete file generation number - * - * -2 means autodetect latest delete generation - * -1 means 'there is no delete file' - * 0 means pre-2.1 format delete file - * X specifies used delete file - * - * @var integer - */ - private $_delGen; - - /** - * Segment has single norms file - * - * If true then one .nrm file is used for all fields - * Otherwise .fN files are used - * - * @var boolean - */ - private $_hasSingleNormFile; - - /** - * Use compound segment file (*.cfs) to collect all other segment files - * (excluding .del files) - * - * @var boolean - */ - private $_isCompound; - - - /** - * File system adapter. - * - * @var Zend_Search_Lucene_Storage_Directory_Filesystem - */ - private $_directory; - - /** - * Normalization factors. - * An array fieldName => normVector - * normVector is a binary string. - * Each byte corresponds to an indexed document in a segment and - * encodes normalization factor (float value, encoded by - * Zend_Search_Lucene_Search_Similarity::encodeNorm()) - * - * @var array - */ - private $_norms = array(); - - /** - * List of deleted documents. - * bitset if bitset extension is loaded or array otherwise. - * - * @var mixed - */ - private $_deleted = null; - - /** - * $this->_deleted update flag - * - * @var boolean - */ - private $_deletedDirty = false; - - /** - * True if segment uses shared doc store - * - * @var boolean - */ - private $_usesSharedDocStore; - - /* - * Shared doc store options. - * It's an assotiative array with the following items: - * - 'offset' => $docStoreOffset The starting document in the shared doc store files where this segment's documents begin - * - 'segment' => $docStoreSegment The name of the segment that has the shared doc store files. - * - 'isCompound' => $docStoreIsCompoundFile True, if compound file format is used for the shared doc store files (.cfx file). - */ - private $_sharedDocStoreOptions; - - - /** - * Zend_Search_Lucene_Index_SegmentInfo constructor - * - * @param Zend_Search_Lucene_Storage_Directory $directory - * @param string $name - * @param integer $docCount - * @param integer $delGen - * @param array|null $docStoreOptions - * @param boolean $hasSingleNormFile - * @param boolean $isCompound - */ - public function __construct(Zend_Search_Lucene_Storage_Directory $directory, $name, $docCount, $delGen = 0, $docStoreOptions = null, $hasSingleNormFile = false, $isCompound = null) - { - $this->_directory = $directory; - $this->_name = $name; - $this->_docCount = $docCount; - - if ($docStoreOptions !== null) { - $this->_usesSharedDocStore = true; - $this->_sharedDocStoreOptions = $docStoreOptions; - - if ($docStoreOptions['isCompound']) { - $cfxFile = $this->_directory->getFileObject($docStoreOptions['segment'] . '.cfx'); - $cfxFilesCount = $cfxFile->readVInt(); - - $cfxFiles = array(); - $cfxFileSizes = array(); - - for ($count = 0; $count < $cfxFilesCount; $count++) { - $dataOffset = $cfxFile->readLong(); - if ($count != 0) { - $cfxFileSizes[$fileName] = $dataOffset - end($cfxFiles); - } - $fileName = $cfxFile->readString(); - $cfxFiles[$fileName] = $dataOffset; - } - if ($count != 0) { - $cfxFileSizes[$fileName] = $this->_directory->fileLength($docStoreOptions['segment'] . '.cfx') - $dataOffset; - } - - $this->_sharedDocStoreOptions['files'] = $cfxFiles; - $this->_sharedDocStoreOptions['fileSizes'] = $cfxFileSizes; - } - } - - $this->_hasSingleNormFile = $hasSingleNormFile; - $this->_delGen = $delGen; - $this->_termDictionary = null; - - - if ($isCompound !== null) { - $this->_isCompound = $isCompound; - } else { - // It's a pre-2.1 segment or isCompound is set to 'unknown' - // Detect if segment uses compound file - // require_once 'Zend/Search/Lucene/Exception.php'; - try { - // Try to open compound file - $this->_directory->getFileObject($name . '.cfs'); - - // Compound file is found - $this->_isCompound = true; - } catch (Zend_Search_Lucene_Exception $e) { - if (strpos($e->getMessage(), 'is not readable') !== false) { - // Compound file is not found or is not readable - $this->_isCompound = false; - } else { - throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e); - } - } - } - - $this->_segFiles = array(); - if ($this->_isCompound) { - $cfsFile = $this->_directory->getFileObject($name . '.cfs'); - $segFilesCount = $cfsFile->readVInt(); - - for ($count = 0; $count < $segFilesCount; $count++) { - $dataOffset = $cfsFile->readLong(); - if ($count != 0) { - $this->_segFileSizes[$fileName] = $dataOffset - end($this->_segFiles); - } - $fileName = $cfsFile->readString(); - $this->_segFiles[$fileName] = $dataOffset; - } - if ($count != 0) { - $this->_segFileSizes[$fileName] = $this->_directory->fileLength($name . '.cfs') - $dataOffset; - } - } - - $fnmFile = $this->openCompoundFile('.fnm'); - $fieldsCount = $fnmFile->readVInt(); - $fieldNames = array(); - $fieldNums = array(); - $this->_fields = array(); - - for ($count=0; $count < $fieldsCount; $count++) { - $fieldName = $fnmFile->readString(); - $fieldBits = $fnmFile->readByte(); - $this->_fields[$count] = new Zend_Search_Lucene_Index_FieldInfo($fieldName, - $fieldBits & 0x01 /* field is indexed */, - $count, - $fieldBits & 0x02 /* termvectors are stored */, - $fieldBits & 0x10 /* norms are omitted */, - $fieldBits & 0x20 /* payloads are stored */); - if ($fieldBits & 0x10) { - // norms are omitted for the indexed field - $this->_norms[$count] = str_repeat(chr(Zend_Search_Lucene_Search_Similarity::encodeNorm(1.0)), $docCount); - } - - $fieldNums[$count] = $count; - $fieldNames[$count] = $fieldName; - } - array_multisort($fieldNames, SORT_ASC, SORT_REGULAR, $fieldNums); - $this->_fieldsDicPositions = array_flip($fieldNums); - - if ($this->_delGen == -2) { - // SegmentInfo constructor is invoked from index writer - // Autodetect current delete file generation number - $this->_delGen = $this->_detectLatestDelGen(); - } - - // Load deletions - $this->_deleted = $this->_loadDelFile(); - } - - /** - * Load detetions file - * - * Returns bitset or an array depending on bitset extension availability - * - * @return mixed - * @throws Zend_Search_Lucene_Exception - */ - private function _loadDelFile() - { - if ($this->_delGen == -1) { - // There is no delete file for this segment - return null; - } else if ($this->_delGen == 0) { - // It's a segment with pre-2.1 format delete file - // Try to load deletions file - return $this->_loadPre21DelFile(); - } else { - // It's 2.1+ format deleteions file - return $this->_load21DelFile(); - } - } - - /** - * Load pre-2.1 detetions file - * - * Returns bitset or an array depending on bitset extension availability - * - * @return mixed - * @throws Zend_Search_Lucene_Exception - */ - private function _loadPre21DelFile() - { - // require_once 'Zend/Search/Lucene/Exception.php'; - try { - // '.del' files always stored in a separate file - // Segment compound is not used - $delFile = $this->_directory->getFileObject($this->_name . '.del'); - - $byteCount = $delFile->readInt(); - $byteCount = ceil($byteCount/8); - $bitCount = $delFile->readInt(); - - if ($bitCount == 0) { - $delBytes = ''; - } else { - $delBytes = $delFile->readBytes($byteCount); - } - - if (extension_loaded('bitset')) { - return $delBytes; - } else { - $deletions = array(); - for ($count = 0; $count < $byteCount; $count++) { - $byte = ord($delBytes[$count]); - for ($bit = 0; $bit < 8; $bit++) { - if ($byte & (1<<$bit)) { - $deletions[$count*8 + $bit] = 1; - } - } - } - - return $deletions; - } - } catch(Zend_Search_Lucene_Exception $e) { - if (strpos($e->getMessage(), 'is not readable') === false) { - throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e); - } - // There is no deletion file - $this->_delGen = -1; - - return null; - } - } - - /** - * Load 2.1+ format detetions file - * - * Returns bitset or an array depending on bitset extension availability - * - * @return mixed - */ - private function _load21DelFile() - { - $delFile = $this->_directory->getFileObject($this->_name . '_' . base_convert($this->_delGen, 10, 36) . '.del'); - - $format = $delFile->readInt(); - - if ($format == (int)0xFFFFFFFF) { - if (extension_loaded('bitset')) { - $deletions = bitset_empty(); - } else { - $deletions = array(); - } - - $byteCount = $delFile->readInt(); - $bitCount = $delFile->readInt(); - - $delFileSize = $this->_directory->fileLength($this->_name . '_' . base_convert($this->_delGen, 10, 36) . '.del'); - $byteNum = 0; - - do { - $dgap = $delFile->readVInt(); - $nonZeroByte = $delFile->readByte(); - - $byteNum += $dgap; - - - if (extension_loaded('bitset')) { - for ($bit = 0; $bit < 8; $bit++) { - if ($nonZeroByte & (1<<$bit)) { - bitset_incl($deletions, $byteNum*8 + $bit); - } - } - return $deletions; - } else { - for ($bit = 0; $bit < 8; $bit++) { - if ($nonZeroByte & (1<<$bit)) { - $deletions[$byteNum*8 + $bit] = 1; - } - } - return (count($deletions) > 0) ? $deletions : null; - } - - } while ($delFile->tell() < $delFileSize); - } else { - // $format is actually byte count - $byteCount = ceil($format/8); - $bitCount = $delFile->readInt(); - - if ($bitCount == 0) { - $delBytes = ''; - } else { - $delBytes = $delFile->readBytes($byteCount); - } - - if (extension_loaded('bitset')) { - return $delBytes; - } else { - $deletions = array(); - for ($count = 0; $count < $byteCount; $count++) { - $byte = ord($delBytes[$count]); - for ($bit = 0; $bit < 8; $bit++) { - if ($byte & (1<<$bit)) { - $deletions[$count*8 + $bit] = 1; - } - } - } - - return (count($deletions) > 0) ? $deletions : null; - } - } - } - - /** - * Opens index file stoted within compound index file - * - * @param string $extension - * @param boolean $shareHandler - * @throws Zend_Search_Lucene_Exception - * @return Zend_Search_Lucene_Storage_File - */ - public function openCompoundFile($extension, $shareHandler = true) - { - if (($extension == '.fdx' || $extension == '.fdt') && $this->_usesSharedDocStore) { - $fdxFName = $this->_sharedDocStoreOptions['segment'] . '.fdx'; - $fdtFName = $this->_sharedDocStoreOptions['segment'] . '.fdt'; - - if (!$this->_sharedDocStoreOptions['isCompound']) { - $fdxFile = $this->_directory->getFileObject($fdxFName, $shareHandler); - $fdxFile->seek($this->_sharedDocStoreOptions['offset']*8, SEEK_CUR); - - if ($extension == '.fdx') { - // '.fdx' file is requested - return $fdxFile; - } else { - // '.fdt' file is requested - $fdtStartOffset = $fdxFile->readLong(); - - $fdtFile = $this->_directory->getFileObject($fdtFName, $shareHandler); - $fdtFile->seek($fdtStartOffset, SEEK_CUR); - - return $fdtFile; - } - } - - if( !isset($this->_sharedDocStoreOptions['files'][$fdxFName]) ) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Shared doc storage segment compound file doesn\'t contain ' - . $fdxFName . ' file.' ); - } - if( !isset($this->_sharedDocStoreOptions['files'][$fdtFName]) ) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Shared doc storage segment compound file doesn\'t contain ' - . $fdtFName . ' file.' ); - } - - // Open shared docstore segment file - $cfxFile = $this->_directory->getFileObject($this->_sharedDocStoreOptions['segment'] . '.cfx', $shareHandler); - // Seek to the start of '.fdx' file within compound file - $cfxFile->seek($this->_sharedDocStoreOptions['files'][$fdxFName]); - // Seek to the start of current segment documents section - $cfxFile->seek($this->_sharedDocStoreOptions['offset']*8, SEEK_CUR); - - if ($extension == '.fdx') { - // '.fdx' file is requested - return $cfxFile; - } else { - // '.fdt' file is requested - $fdtStartOffset = $cfxFile->readLong(); - - // Seek to the start of '.fdt' file within compound file - $cfxFile->seek($this->_sharedDocStoreOptions['files'][$fdtFName]); - // Seek to the start of current segment documents section - $cfxFile->seek($fdtStartOffset, SEEK_CUR); - - return $fdtFile; - } - } - - $filename = $this->_name . $extension; - - if (!$this->_isCompound) { - return $this->_directory->getFileObject($filename, $shareHandler); - } - - if( !isset($this->_segFiles[$filename]) ) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Segment compound file doesn\'t contain ' - . $filename . ' file.' ); - } - - $file = $this->_directory->getFileObject($this->_name . '.cfs', $shareHandler); - $file->seek($this->_segFiles[$filename]); - return $file; - } - - /** - * Get compound file length - * - * @param string $extension - * @return integer - */ - public function compoundFileLength($extension) - { - if (($extension == '.fdx' || $extension == '.fdt') && $this->_usesSharedDocStore) { - $filename = $this->_sharedDocStoreOptions['segment'] . $extension; - - if (!$this->_sharedDocStoreOptions['isCompound']) { - return $this->_directory->fileLength($filename); - } - - if( !isset($this->_sharedDocStoreOptions['fileSizes'][$filename]) ) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Shared doc store compound file doesn\'t contain ' - . $filename . ' file.' ); - } - - return $this->_sharedDocStoreOptions['fileSizes'][$filename]; - } - - - $filename = $this->_name . $extension; - - // Try to get common file first - if ($this->_directory->fileExists($filename)) { - return $this->_directory->fileLength($filename); - } - - if( !isset($this->_segFileSizes[$filename]) ) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Index compound file doesn\'t contain ' - . $filename . ' file.' ); - } - - return $this->_segFileSizes[$filename]; - } - - /** - * Returns field index or -1 if field is not found - * - * @param string $fieldName - * @return integer - */ - public function getFieldNum($fieldName) - { - foreach( $this->_fields as $field ) { - if( $field->name == $fieldName ) { - return $field->number; - } - } - - return -1; - } - - /** - * Returns field info for specified field - * - * @param integer $fieldNum - * @return Zend_Search_Lucene_Index_FieldInfo - */ - public function getField($fieldNum) - { - return $this->_fields[$fieldNum]; - } - - /** - * Returns array of fields. - * if $indexed parameter is true, then returns only indexed fields. - * - * @param boolean $indexed - * @return array - */ - public function getFields($indexed = false) - { - $result = array(); - foreach( $this->_fields as $field ) { - if( (!$indexed) || $field->isIndexed ) { - $result[ $field->name ] = $field->name; - } - } - return $result; - } - - /** - * Returns array of FieldInfo objects. - * - * @return array - */ - public function getFieldInfos() - { - return $this->_fields; - } - - /** - * Returns actual deletions file generation number. - * - * @return integer - */ - public function getDelGen() - { - return $this->_delGen; - } - - /** - * Returns the total number of documents in this segment (including deleted documents). - * - * @return integer - */ - public function count() - { - return $this->_docCount; - } - - /** - * Returns number of deleted documents. - * - * @return integer - */ - private function _deletedCount() - { - if ($this->_deleted === null) { - return 0; - } - - if (extension_loaded('bitset')) { - return count(bitset_to_array($this->_deleted)); - } else { - return count($this->_deleted); - } - } - - /** - * Returns the total number of non-deleted documents in this segment. - * - * @return integer - */ - public function numDocs() - { - if ($this->hasDeletions()) { - return $this->_docCount - $this->_deletedCount(); - } else { - return $this->_docCount; - } - } - - /** - * Get field position in a fields dictionary - * - * @param integer $fieldNum - * @return integer - */ - private function _getFieldPosition($fieldNum) { - // Treat values which are not in a translation table as a 'direct value' - return isset($this->_fieldsDicPositions[$fieldNum]) ? - $this->_fieldsDicPositions[$fieldNum] : $fieldNum; - } - - /** - * Return segment name - * - * @return string - */ - public function getName() - { - return $this->_name; - } - - - /** - * TermInfo cache - * - * Size is 1024. - * Numbers are used instead of class constants because of performance considerations - * - * @var array - */ - private $_termInfoCache = array(); - - private function _cleanUpTermInfoCache() - { - // Clean 256 term infos - foreach ($this->_termInfoCache as $key => $termInfo) { - unset($this->_termInfoCache[$key]); - - // leave 768 last used term infos - if (count($this->_termInfoCache) == 768) { - break; - } - } - } - - /** - * Load terms dictionary index - * - * @throws Zend_Search_Lucene_Exception - */ - private function _loadDictionaryIndex() - { - // Check, if index is already serialized - if ($this->_directory->fileExists($this->_name . '.sti')) { - // Load serialized dictionary index data - $stiFile = $this->_directory->getFileObject($this->_name . '.sti'); - $stiFileData = $stiFile->readBytes($this->_directory->fileLength($this->_name . '.sti')); - - // Load dictionary index data - if (($unserializedData = @unserialize($stiFileData)) !== false) { - list($this->_termDictionary, $this->_termDictionaryInfos) = $unserializedData; - return; - } - } - - // Load data from .tii file and generate .sti file - - // Prefetch dictionary index data - $tiiFile = $this->openCompoundFile('.tii'); - $tiiFileData = $tiiFile->readBytes($this->compoundFileLength('.tii')); - - /** Zend_Search_Lucene_Index_DictionaryLoader */ - // require_once 'Zend/Search/Lucene/Index/DictionaryLoader.php'; - - // Load dictionary index data - list($this->_termDictionary, $this->_termDictionaryInfos) = - Zend_Search_Lucene_Index_DictionaryLoader::load($tiiFileData); - - $stiFileData = serialize(array($this->_termDictionary, $this->_termDictionaryInfos)); - $stiFile = $this->_directory->createFile($this->_name . '.sti'); - $stiFile->writeBytes($stiFileData); - } - - /** - * Scans terms dictionary and returns term info - * - * @param Zend_Search_Lucene_Index_Term $term - * @return Zend_Search_Lucene_Index_TermInfo - */ - public function getTermInfo(Zend_Search_Lucene_Index_Term $term) - { - $termKey = $term->key(); - if (isset($this->_termInfoCache[$termKey])) { - $termInfo = $this->_termInfoCache[$termKey]; - - // Move termInfo to the end of cache - unset($this->_termInfoCache[$termKey]); - $this->_termInfoCache[$termKey] = $termInfo; - - return $termInfo; - } - - - if ($this->_termDictionary === null) { - $this->_loadDictionaryIndex(); - } - - $searchField = $this->getFieldNum($term->field); - - if ($searchField == -1) { - return null; - } - $searchDicField = $this->_getFieldPosition($searchField); - - // search for appropriate value in dictionary - $lowIndex = 0; - $highIndex = count($this->_termDictionary)-1; - while ($highIndex >= $lowIndex) { - // $mid = ($highIndex - $lowIndex)/2; - $mid = ($highIndex + $lowIndex) >> 1; - $midTerm = $this->_termDictionary[$mid]; - - $fieldNum = $this->_getFieldPosition($midTerm[0] /* field */); - $delta = $searchDicField - $fieldNum; - if ($delta == 0) { - $delta = strcmp($term->text, $midTerm[1] /* text */); - } - - if ($delta < 0) { - $highIndex = $mid-1; - } elseif ($delta > 0) { - $lowIndex = $mid+1; - } else { - // return $this->_termDictionaryInfos[$mid]; // We got it! - $a = $this->_termDictionaryInfos[$mid]; - $termInfo = new Zend_Search_Lucene_Index_TermInfo($a[0], $a[1], $a[2], $a[3], $a[4]); - - // Put loaded termInfo into cache - $this->_termInfoCache[$termKey] = $termInfo; - - return $termInfo; - } - } - - if ($highIndex == -1) { - // Term is out of the dictionary range - return null; - } - - $prevPosition = $highIndex; - $prevTerm = $this->_termDictionary[$prevPosition]; - $prevTermInfo = $this->_termDictionaryInfos[$prevPosition]; - - $tisFile = $this->openCompoundFile('.tis'); - $tiVersion = $tisFile->readInt(); - if ($tiVersion != (int)0xFFFFFFFE /* pre-2.1 format */ && - $tiVersion != (int)0xFFFFFFFD /* 2.1+ format */) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Wrong TermInfoFile file format'); - } - - $termCount = $tisFile->readLong(); - $indexInterval = $tisFile->readInt(); - $skipInterval = $tisFile->readInt(); - if ($tiVersion == (int)0xFFFFFFFD /* 2.1+ format */) { - $maxSkipLevels = $tisFile->readInt(); - } - - $tisFile->seek($prevTermInfo[4] /* indexPointer */ - (($tiVersion == (int)0xFFFFFFFD)? 24 : 20) /* header size*/, SEEK_CUR); - - $termValue = $prevTerm[1] /* text */; - $termFieldNum = $prevTerm[0] /* field */; - $freqPointer = $prevTermInfo[1] /* freqPointer */; - $proxPointer = $prevTermInfo[2] /* proxPointer */; - for ($count = $prevPosition*$indexInterval + 1; - $count <= $termCount && - ( $this->_getFieldPosition($termFieldNum) < $searchDicField || - ($this->_getFieldPosition($termFieldNum) == $searchDicField && - strcmp($termValue, $term->text) < 0) ); - $count++) { - $termPrefixLength = $tisFile->readVInt(); - $termSuffix = $tisFile->readString(); - $termFieldNum = $tisFile->readVInt(); - $termValue = Zend_Search_Lucene_Index_Term::getPrefix($termValue, $termPrefixLength) . $termSuffix; - - $docFreq = $tisFile->readVInt(); - $freqPointer += $tisFile->readVInt(); - $proxPointer += $tisFile->readVInt(); - if( $docFreq >= $skipInterval ) { - $skipOffset = $tisFile->readVInt(); - } else { - $skipOffset = 0; - } - } - - if ($termFieldNum == $searchField && $termValue == $term->text) { - $termInfo = new Zend_Search_Lucene_Index_TermInfo($docFreq, $freqPointer, $proxPointer, $skipOffset); - } else { - $termInfo = null; - } - - // Put loaded termInfo into cache - $this->_termInfoCache[$termKey] = $termInfo; - - if (count($this->_termInfoCache) == 1024) { - $this->_cleanUpTermInfoCache(); - } - - return $termInfo; - } - - /** - * Returns IDs of all the documents containing term. - * - * @param Zend_Search_Lucene_Index_Term $term - * @param integer $shift - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return array - */ - public function termDocs(Zend_Search_Lucene_Index_Term $term, $shift = 0, $docsFilter = null) - { - $termInfo = $this->getTermInfo($term); - - if (!$termInfo instanceof Zend_Search_Lucene_Index_TermInfo) { - if ($docsFilter !== null && $docsFilter instanceof Zend_Search_Lucene_Index_DocsFilter) { - $docsFilter->segmentFilters[$this->_name] = array(); - } - return array(); - } - - $frqFile = $this->openCompoundFile('.frq'); - $frqFile->seek($termInfo->freqPointer,SEEK_CUR); - $docId = 0; - $result = array(); - - if ($docsFilter !== null) { - if (!$docsFilter instanceof Zend_Search_Lucene_Index_DocsFilter) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Documents filter must be an instance of Zend_Search_Lucene_Index_DocsFilter or null.'); - } - - if (isset($docsFilter->segmentFilters[$this->_name])) { - // Filter already has some data for the current segment - - // Make short name for the filter (which doesn't need additional dereferencing) - $filter = &$docsFilter->segmentFilters[$this->_name]; - - // Check if filter is not empty - if (count($filter) == 0) { - return array(); - } - - if ($this->_docCount/count($filter) < self::FULL_SCAN_VS_FETCH_BOUNDARY) { - // Perform fetching -// --------------------------------------------------------------- - $updatedFilterData = array(); - - for( $count=0; $count < $termInfo->docFreq; $count++ ) { - $docDelta = $frqFile->readVInt(); - if( $docDelta % 2 == 1 ) { - $docId += ($docDelta-1)/2; - } else { - $docId += $docDelta/2; - // read freq - $frqFile->readVInt(); - } - - if (isset($filter[$docId])) { - $result[] = $shift + $docId; - $updatedFilterData[$docId] = 1; // 1 is just a some constant value, so we don't need additional var dereference here - } - } - $docsFilter->segmentFilters[$this->_name] = $updatedFilterData; -// --------------------------------------------------------------- - } else { - // Perform full scan - $updatedFilterData = array(); - - for( $count=0; $count < $termInfo->docFreq; $count++ ) { - $docDelta = $frqFile->readVInt(); - if( $docDelta % 2 == 1 ) { - $docId += ($docDelta-1)/2; - } else { - $docId += $docDelta/2; - // read freq - $frqFile->readVInt(); - } - - if (isset($filter[$docId])) { - $result[] = $shift + $docId; - $updatedFilterData[$docId] = 1; // 1 is just a some constant value, so we don't need additional var dereference here - } - } - $docsFilter->segmentFilters[$this->_name] = $updatedFilterData; - } - } else { - // Filter is present, but doesn't has data for the current segment yet - $filterData = array(); - for( $count=0; $count < $termInfo->docFreq; $count++ ) { - $docDelta = $frqFile->readVInt(); - if( $docDelta % 2 == 1 ) { - $docId += ($docDelta-1)/2; - } else { - $docId += $docDelta/2; - // read freq - $frqFile->readVInt(); - } - - $result[] = $shift + $docId; - $filterData[$docId] = 1; // 1 is just a some constant value, so we don't need additional var dereference here - } - $docsFilter->segmentFilters[$this->_name] = $filterData; - } - } else { - for( $count=0; $count < $termInfo->docFreq; $count++ ) { - $docDelta = $frqFile->readVInt(); - if( $docDelta % 2 == 1 ) { - $docId += ($docDelta-1)/2; - } else { - $docId += $docDelta/2; - // read freq - $frqFile->readVInt(); - } - - $result[] = $shift + $docId; - } - } - - return $result; - } - - /** - * Returns term freqs array. - * Result array structure: array(docId => freq, ...) - * - * @param Zend_Search_Lucene_Index_Term $term - * @param integer $shift - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return Zend_Search_Lucene_Index_TermInfo - */ - public function termFreqs(Zend_Search_Lucene_Index_Term $term, $shift = 0, $docsFilter = null) - { - $termInfo = $this->getTermInfo($term); - - if (!$termInfo instanceof Zend_Search_Lucene_Index_TermInfo) { - if ($docsFilter !== null && $docsFilter instanceof Zend_Search_Lucene_Index_DocsFilter) { - $docsFilter->segmentFilters[$this->_name] = array(); - } - return array(); - } - - $frqFile = $this->openCompoundFile('.frq'); - $frqFile->seek($termInfo->freqPointer,SEEK_CUR); - $result = array(); - $docId = 0; - - $result = array(); - - if ($docsFilter !== null) { - if (!$docsFilter instanceof Zend_Search_Lucene_Index_DocsFilter) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Documents filter must be an instance of Zend_Search_Lucene_Index_DocsFilter or null.'); - } - - if (isset($docsFilter->segmentFilters[$this->_name])) { - // Filter already has some data for the current segment - - // Make short name for the filter (which doesn't need additional dereferencing) - $filter = &$docsFilter->segmentFilters[$this->_name]; - - // Check if filter is not empty - if (count($filter) == 0) { - return array(); - } - - - if ($this->_docCount/count($filter) < self::FULL_SCAN_VS_FETCH_BOUNDARY) { - // Perform fetching -// --------------------------------------------------------------- - $updatedFilterData = array(); - - for ($count = 0; $count < $termInfo->docFreq; $count++) { - $docDelta = $frqFile->readVInt(); - if ($docDelta % 2 == 1) { - $docId += ($docDelta-1)/2; - if (isset($filter[$docId])) { - $result[$shift + $docId] = 1; - $updatedFilterData[$docId] = 1; // 1 is just a some constant value, so we don't need additional var dereference here - } - } else { - $docId += $docDelta/2; - $freq = $frqFile->readVInt(); - if (isset($filter[$docId])) { - $result[$shift + $docId] = $freq; - $updatedFilterData[$docId] = 1; // 1 is just a some constant value, so we don't need additional var dereference here - } - } - } - $docsFilter->segmentFilters[$this->_name] = $updatedFilterData; -// --------------------------------------------------------------- - } else { - // Perform full scan - $updatedFilterData = array(); - - for ($count = 0; $count < $termInfo->docFreq; $count++) { - $docDelta = $frqFile->readVInt(); - if ($docDelta % 2 == 1) { - $docId += ($docDelta-1)/2; - if (isset($filter[$docId])) { - $result[$shift + $docId] = 1; - $updatedFilterData[$docId] = 1; // 1 is just some constant value, so we don't need additional var dereference here - } - } else { - $docId += $docDelta/2; - $freq = $frqFile->readVInt(); - if (isset($filter[$docId])) { - $result[$shift + $docId] = $freq; - $updatedFilterData[$docId] = 1; // 1 is just some constant value, so we don't need additional var dereference here - } - } - } - $docsFilter->segmentFilters[$this->_name] = $updatedFilterData; - } - } else { - // Filter doesn't has data for current segment - $filterData = array(); - - for ($count = 0; $count < $termInfo->docFreq; $count++) { - $docDelta = $frqFile->readVInt(); - if ($docDelta % 2 == 1) { - $docId += ($docDelta-1)/2; - $result[$shift + $docId] = 1; - $filterData[$docId] = 1; // 1 is just a some constant value, so we don't need additional var dereference here - } else { - $docId += $docDelta/2; - $result[$shift + $docId] = $frqFile->readVInt(); - $filterData[$docId] = 1; // 1 is just a some constant value, so we don't need additional var dereference here - } - } - - $docsFilter->segmentFilters[$this->_name] = $filterData; - } - } else { - for ($count = 0; $count < $termInfo->docFreq; $count++) { - $docDelta = $frqFile->readVInt(); - if ($docDelta % 2 == 1) { - $docId += ($docDelta-1)/2; - $result[$shift + $docId] = 1; - } else { - $docId += $docDelta/2; - $result[$shift + $docId] = $frqFile->readVInt(); - } - } - } - - return $result; - } - - /** - * Returns term positions array. - * Result array structure: array(docId => array(pos1, pos2, ...), ...) - * - * @param Zend_Search_Lucene_Index_Term $term - * @param integer $shift - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return Zend_Search_Lucene_Index_TermInfo - */ - public function termPositions(Zend_Search_Lucene_Index_Term $term, $shift = 0, $docsFilter = null) - { - $termInfo = $this->getTermInfo($term); - - if (!$termInfo instanceof Zend_Search_Lucene_Index_TermInfo) { - if ($docsFilter !== null && $docsFilter instanceof Zend_Search_Lucene_Index_DocsFilter) { - $docsFilter->segmentFilters[$this->_name] = array(); - } - return array(); - } - - $frqFile = $this->openCompoundFile('.frq'); - $frqFile->seek($termInfo->freqPointer,SEEK_CUR); - - $docId = 0; - $freqs = array(); - - - if ($docsFilter !== null) { - if (!$docsFilter instanceof Zend_Search_Lucene_Index_DocsFilter) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Documents filter must be an instance of Zend_Search_Lucene_Index_DocsFilter or null.'); - } - - if (isset($docsFilter->segmentFilters[$this->_name])) { - // Filter already has some data for the current segment - - // Make short name for the filter (which doesn't need additional dereferencing) - $filter = &$docsFilter->segmentFilters[$this->_name]; - - // Check if filter is not empty - if (count($filter) == 0) { - return array(); - } - - if ($this->_docCount/count($filter) < self::FULL_SCAN_VS_FETCH_BOUNDARY) { - // Perform fetching -// --------------------------------------------------------------- - for ($count = 0; $count < $termInfo->docFreq; $count++) { - $docDelta = $frqFile->readVInt(); - if ($docDelta % 2 == 1) { - $docId += ($docDelta-1)/2; - $freqs[$docId] = 1; - } else { - $docId += $docDelta/2; - $freqs[$docId] = $frqFile->readVInt(); - } - } - - $updatedFilterData = array(); - $result = array(); - $prxFile = $this->openCompoundFile('.prx'); - $prxFile->seek($termInfo->proxPointer, SEEK_CUR); - foreach ($freqs as $docId => $freq) { - $termPosition = 0; - $positions = array(); - - // we have to read .prx file to get right position for next doc - // even filter doesn't match current document - for ($count = 0; $count < $freq; $count++ ) { - $termPosition += $prxFile->readVInt(); - $positions[] = $termPosition; - } - - // Include into updated filter and into result only if doc is matched by filter - if (isset($filter[$docId])) { - $updatedFilterData[$docId] = 1; // 1 is just a some constant value, so we don't need additional var dereference here - $result[$shift + $docId] = $positions; - } - } - - $docsFilter->segmentFilters[$this->_name] = $updatedFilterData; -// --------------------------------------------------------------- - } else { - // Perform full scan - for ($count = 0; $count < $termInfo->docFreq; $count++) { - $docDelta = $frqFile->readVInt(); - if ($docDelta % 2 == 1) { - $docId += ($docDelta-1)/2; - $freqs[$docId] = 1; - } else { - $docId += $docDelta/2; - $freqs[$docId] = $frqFile->readVInt(); - } - } - - $updatedFilterData = array(); - $result = array(); - $prxFile = $this->openCompoundFile('.prx'); - $prxFile->seek($termInfo->proxPointer, SEEK_CUR); - foreach ($freqs as $docId => $freq) { - $termPosition = 0; - $positions = array(); - - // we have to read .prx file to get right position for next doc - // even filter doesn't match current document - for ($count = 0; $count < $freq; $count++ ) { - $termPosition += $prxFile->readVInt(); - $positions[] = $termPosition; - } - - // Include into updated filter and into result only if doc is matched by filter - if (isset($filter[$docId])) { - $updatedFilterData[$docId] = 1; // 1 is just a some constant value, so we don't need additional var dereference here - $result[$shift + $docId] = $positions; - } - } - - $docsFilter->segmentFilters[$this->_name] = $updatedFilterData; - } - } else { - // Filter doesn't has data for current segment - for ($count = 0; $count < $termInfo->docFreq; $count++) { - $docDelta = $frqFile->readVInt(); - if ($docDelta % 2 == 1) { - $docId += ($docDelta-1)/2; - $freqs[$docId] = 1; - } else { - $docId += $docDelta/2; - $freqs[$docId] = $frqFile->readVInt(); - } - } - - $filterData = array(); - $result = array(); - $prxFile = $this->openCompoundFile('.prx'); - $prxFile->seek($termInfo->proxPointer, SEEK_CUR); - foreach ($freqs as $docId => $freq) { - $filterData[$docId] = 1; // 1 is just a some constant value, so we don't need additional var dereference here - - $termPosition = 0; - $positions = array(); - - for ($count = 0; $count < $freq; $count++ ) { - $termPosition += $prxFile->readVInt(); - $positions[] = $termPosition; - } - - $result[$shift + $docId] = $positions; - } - - $docsFilter->segmentFilters[$this->_name] = $filterData; - } - } else { - for ($count = 0; $count < $termInfo->docFreq; $count++) { - $docDelta = $frqFile->readVInt(); - if ($docDelta % 2 == 1) { - $docId += ($docDelta-1)/2; - $freqs[$docId] = 1; - } else { - $docId += $docDelta/2; - $freqs[$docId] = $frqFile->readVInt(); - } - } - - $result = array(); - $prxFile = $this->openCompoundFile('.prx'); - $prxFile->seek($termInfo->proxPointer, SEEK_CUR); - foreach ($freqs as $docId => $freq) { - $termPosition = 0; - $positions = array(); - - for ($count = 0; $count < $freq; $count++ ) { - $termPosition += $prxFile->readVInt(); - $positions[] = $termPosition; - } - - $result[$shift + $docId] = $positions; - } - } - - return $result; - } - - /** - * Load normalizatin factors from an index file - * - * @param integer $fieldNum - * @throws Zend_Search_Lucene_Exception - */ - private function _loadNorm($fieldNum) - { - if ($this->_hasSingleNormFile) { - $normfFile = $this->openCompoundFile('.nrm'); - - $header = $normfFile->readBytes(3); - $headerFormatVersion = $normfFile->readByte(); - - if ($header != 'NRM' || $headerFormatVersion != (int)0xFF) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Wrong norms file format.'); - } - - foreach ($this->_fields as $fNum => $fieldInfo) { - if ($fieldInfo->isIndexed) { - $this->_norms[$fNum] = $normfFile->readBytes($this->_docCount); - } - } - } else { - $fFile = $this->openCompoundFile('.f' . $fieldNum); - $this->_norms[$fieldNum] = $fFile->readBytes($this->_docCount); - } - } - - /** - * Returns normalization factor for specified documents - * - * @param integer $id - * @param string $fieldName - * @return float - */ - public function norm($id, $fieldName) - { - $fieldNum = $this->getFieldNum($fieldName); - - if ( !($this->_fields[$fieldNum]->isIndexed) ) { - return null; - } - - if (!isset($this->_norms[$fieldNum])) { - $this->_loadNorm($fieldNum); - } - - return Zend_Search_Lucene_Search_Similarity::decodeNorm( ord($this->_norms[$fieldNum][$id]) ); - } - - /** - * Returns norm vector, encoded in a byte string - * - * @param string $fieldName - * @return string - */ - public function normVector($fieldName) - { - $fieldNum = $this->getFieldNum($fieldName); - - if ($fieldNum == -1 || !($this->_fields[$fieldNum]->isIndexed)) { - $similarity = Zend_Search_Lucene_Search_Similarity::getDefault(); - - return str_repeat(chr($similarity->encodeNorm( $similarity->lengthNorm($fieldName, 0) )), - $this->_docCount); - } - - if (!isset($this->_norms[$fieldNum])) { - $this->_loadNorm($fieldNum); - } - - return $this->_norms[$fieldNum]; - } - - - /** - * Returns true if any documents have been deleted from this index segment. - * - * @return boolean - */ - public function hasDeletions() - { - return $this->_deleted !== null; - } - - - /** - * Returns true if segment has single norms file. - * - * @return boolean - */ - public function hasSingleNormFile() - { - return $this->_hasSingleNormFile ? true : false; - } - - /** - * Returns true if segment is stored using compound segment file. - * - * @return boolean - */ - public function isCompound() - { - return $this->_isCompound; - } - - /** - * Deletes a document from the index segment. - * $id is an internal document id - * - * @param integer - */ - public function delete($id) - { - $this->_deletedDirty = true; - - if (extension_loaded('bitset')) { - if ($this->_deleted === null) { - $this->_deleted = bitset_empty($id); - } - bitset_incl($this->_deleted, $id); - } else { - if ($this->_deleted === null) { - $this->_deleted = array(); - } - - $this->_deleted[$id] = 1; - } - } - - /** - * Checks, that document is deleted - * - * @param integer - * @return boolean - */ - public function isDeleted($id) - { - if ($this->_deleted === null) { - return false; - } - - if (extension_loaded('bitset')) { - return bitset_in($this->_deleted, $id); - } else { - return isset($this->_deleted[$id]); - } - } - - /** - * Detect latest delete generation - * - * Is actualy used from writeChanges() method or from the constructor if it's invoked from - * Index writer. In both cases index write lock is already obtained, so we shouldn't care - * about it - * - * @return integer - */ - private function _detectLatestDelGen() - { - $delFileList = array(); - foreach ($this->_directory->fileList() as $file) { - if ($file == $this->_name . '.del') { - // Matches <segment_name>.del file name - $delFileList[] = 0; - } else if (preg_match('/^' . $this->_name . '_([a-zA-Z0-9]+)\.del$/i', $file, $matches)) { - // Matches <segment_name>_NNN.del file names - $delFileList[] = (int)base_convert($matches[1], 36, 10); - } - } - - if (count($delFileList) == 0) { - // There is no deletions file for current segment in the directory - // Set deletions file generation number to 1 - return -1; - } else { - // There are some deletions files for current segment in the directory - // Set deletions file generation number to the highest nuber - return max($delFileList); - } - } - - /** - * Write changes if it's necessary. - * - * This method must be invoked only from the Writer _updateSegments() method, - * so index Write lock has to be already obtained. - * - * @internal - * @throws Zend_Search_Lucene_Exceptions - */ - public function writeChanges() - { - // Get new generation number - $latestDelGen = $this->_detectLatestDelGen(); - - if (!$this->_deletedDirty) { - // There was no deletions by current process - - if ($latestDelGen == $this->_delGen) { - // Delete file hasn't been updated by any concurrent process - return; - } else if ($latestDelGen > $this->_delGen) { - // Delete file has been updated by some concurrent process - // Reload deletions file - $this->_delGen = $latestDelGen; - $this->_deleted = $this->_loadDelFile(); - - return; - } else { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Delete file processing workflow is corrupted for the segment \'' . $this->_name . '\'.'); - } - } - - if ($latestDelGen > $this->_delGen) { - // Merge current deletions with latest deletions file - $this->_delGen = $latestDelGen; - - $latestDelete = $this->_loadDelFile(); - - if (extension_loaded('bitset')) { - $this->_deleted = bitset_union($this->_deleted, $latestDelete); - } else { - $this->_deleted += $latestDelete; - } - } - - if (extension_loaded('bitset')) { - $delBytes = $this->_deleted; - $bitCount = count(bitset_to_array($delBytes)); - } else { - $byteCount = floor($this->_docCount/8)+1; - $delBytes = str_repeat(chr(0), $byteCount); - for ($count = 0; $count < $byteCount; $count++) { - $byte = 0; - for ($bit = 0; $bit < 8; $bit++) { - if (isset($this->_deleted[$count*8 + $bit])) { - $byte |= (1<<$bit); - } - } - $delBytes[$count] = chr($byte); - } - $bitCount = count($this->_deleted); - } - - if ($this->_delGen == -1) { - // Set delete file generation number to 1 - $this->_delGen = 1; - } else { - // Increase delete file generation number by 1 - $this->_delGen++; - } - - $delFile = $this->_directory->createFile($this->_name . '_' . base_convert($this->_delGen, 10, 36) . '.del'); - $delFile->writeInt($this->_docCount); - $delFile->writeInt($bitCount); - $delFile->writeBytes($delBytes); - - $this->_deletedDirty = false; - } - - - /** - * Term Dictionary File object for stream like terms reading - * - * @var Zend_Search_Lucene_Storage_File - */ - private $_tisFile = null; - - /** - * Actual offset of the .tis file data - * - * @var integer - */ - private $_tisFileOffset; - - /** - * Frequencies File object for stream like terms reading - * - * @var Zend_Search_Lucene_Storage_File - */ - private $_frqFile = null; - - /** - * Actual offset of the .frq file data - * - * @var integer - */ - private $_frqFileOffset; - - /** - * Positions File object for stream like terms reading - * - * @var Zend_Search_Lucene_Storage_File - */ - private $_prxFile = null; - - /** - * Actual offset of the .prx file in the compound file - * - * @var integer - */ - private $_prxFileOffset; - - - /** - * Actual number of terms in term stream - * - * @var integer - */ - private $_termCount = 0; - - /** - * Overall number of terms in term stream - * - * @var integer - */ - private $_termNum = 0; - - /** - * Segment index interval - * - * @var integer - */ - private $_indexInterval; - - /** - * Segment skip interval - * - * @var integer - */ - private $_skipInterval; - - /** - * Last TermInfo in a terms stream - * - * @var Zend_Search_Lucene_Index_TermInfo - */ - private $_lastTermInfo = null; - - /** - * Last Term in a terms stream - * - * @var Zend_Search_Lucene_Index_Term - */ - private $_lastTerm = null; - - /** - * Map of the document IDs - * Used to get new docID after removing deleted documents. - * It's not very effective from memory usage point of view, - * but much more faster, then other methods - * - * @var array|null - */ - private $_docMap = null; - - /** - * An array of all term positions in the documents. - * Array structure: array( docId => array( pos1, pos2, ...), ...) - * - * Is set to null if term positions loading has to be skipped - * - * @var array|null - */ - private $_lastTermPositions; - - - /** - * Terms scan mode - * - * Values: - * - * self::SM_TERMS_ONLY - terms are scanned, no additional info is retrieved - * self::SM_FULL_INFO - terms are scanned, frequency and position info is retrieved - * self::SM_MERGE_INFO - terms are scanned, frequency and position info is retrieved - * document numbers are compacted (shifted if segment has deleted documents) - * - * @var integer - */ - private $_termsScanMode; - - /** Scan modes */ - const SM_TERMS_ONLY = 0; // terms are scanned, no additional info is retrieved - const SM_FULL_INFO = 1; // terms are scanned, frequency and position info is retrieved - const SM_MERGE_INFO = 2; // terms are scanned, frequency and position info is retrieved - // document numbers are compacted (shifted if segment contains deleted documents) - - /** - * Reset terms stream - * - * $startId - id for the fist document - * $compact - remove deleted documents - * - * Returns start document id for the next segment - * - * @param integer $startId - * @param integer $mode - * @throws Zend_Search_Lucene_Exception - * @return integer - */ - public function resetTermsStream(/** $startId = 0, $mode = self::SM_TERMS_ONLY */) - { - /** - * SegmentInfo->resetTermsStream() method actually takes two optional parameters: - * $startId (default value is 0) - * $mode (default value is self::SM_TERMS_ONLY) - */ - $argList = func_get_args(); - if (count($argList) > 2) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Wrong number of arguments'); - } else if (count($argList) == 2) { - $startId = $argList[0]; - $mode = $argList[1]; - } else if (count($argList) == 1) { - $startId = $argList[0]; - $mode = self::SM_TERMS_ONLY; - } else { - $startId = 0; - $mode = self::SM_TERMS_ONLY; - } - - if ($this->_tisFile !== null) { - $this->_tisFile = null; - } - - $this->_tisFile = $this->openCompoundFile('.tis', false); - $this->_tisFileOffset = $this->_tisFile->tell(); - - $tiVersion = $this->_tisFile->readInt(); - if ($tiVersion != (int)0xFFFFFFFE /* pre-2.1 format */ && - $tiVersion != (int)0xFFFFFFFD /* 2.1+ format */) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Wrong TermInfoFile file format'); - } - - $this->_termCount = - $this->_termNum = $this->_tisFile->readLong(); // Read terms count - $this->_indexInterval = $this->_tisFile->readInt(); // Read Index interval - $this->_skipInterval = $this->_tisFile->readInt(); // Read skip interval - if ($tiVersion == (int)0xFFFFFFFD /* 2.1+ format */) { - $maxSkipLevels = $this->_tisFile->readInt(); - } - - if ($this->_frqFile !== null) { - $this->_frqFile = null; - } - if ($this->_prxFile !== null) { - $this->_prxFile = null; - } - $this->_docMap = array(); - - $this->_lastTerm = new Zend_Search_Lucene_Index_Term('', -1); - $this->_lastTermInfo = new Zend_Search_Lucene_Index_TermInfo(0, 0, 0, 0); - $this->_lastTermPositions = null; - - $this->_termsScanMode = $mode; - - switch ($mode) { - case self::SM_TERMS_ONLY: - // Do nothing - break; - - case self::SM_FULL_INFO: - // break intentionally omitted - case self::SM_MERGE_INFO: - $this->_frqFile = $this->openCompoundFile('.frq', false); - $this->_frqFileOffset = $this->_frqFile->tell(); - - $this->_prxFile = $this->openCompoundFile('.prx', false); - $this->_prxFileOffset = $this->_prxFile->tell(); - - for ($count = 0; $count < $this->_docCount; $count++) { - if (!$this->isDeleted($count)) { - $this->_docMap[$count] = $startId + (($mode == self::SM_MERGE_INFO) ? count($this->_docMap) : $count); - } - } - break; - - default: - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Wrong terms scaning mode specified.'); - break; - } - - // Calculate next segment start id (since $this->_docMap structure may be cleaned by $this->nextTerm() call) - $nextSegmentStartId = $startId + (($mode == self::SM_MERGE_INFO) ? count($this->_docMap) : $this->_docCount); - $this->nextTerm(); - - return $nextSegmentStartId; - } - - - /** - * Skip terms stream up to the specified term preffix. - * - * Prefix contains fully specified field info and portion of searched term - * - * @param Zend_Search_Lucene_Index_Term $prefix - * @throws Zend_Search_Lucene_Exception - */ - public function skipTo(Zend_Search_Lucene_Index_Term $prefix) - { - if ($this->_termDictionary === null) { - $this->_loadDictionaryIndex(); - } - - $searchField = $this->getFieldNum($prefix->field); - - if ($searchField == -1) { - /** - * Field is not presented in this segment - * Go to the end of dictionary - */ - $this->_tisFile = null; - $this->_frqFile = null; - $this->_prxFile = null; - - $this->_lastTerm = null; - $this->_lastTermInfo = null; - $this->_lastTermPositions = null; - - return; - } - $searchDicField = $this->_getFieldPosition($searchField); - - // search for appropriate value in dictionary - $lowIndex = 0; - $highIndex = count($this->_termDictionary)-1; - while ($highIndex >= $lowIndex) { - // $mid = ($highIndex - $lowIndex)/2; - $mid = ($highIndex + $lowIndex) >> 1; - $midTerm = $this->_termDictionary[$mid]; - - $fieldNum = $this->_getFieldPosition($midTerm[0] /* field */); - $delta = $searchDicField - $fieldNum; - if ($delta == 0) { - $delta = strcmp($prefix->text, $midTerm[1] /* text */); - } - - if ($delta < 0) { - $highIndex = $mid-1; - } elseif ($delta > 0) { - $lowIndex = $mid+1; - } else { - // We have reached term we are looking for - break; - } - } - - if ($highIndex == -1) { - // Term is out of the dictionary range - $this->_tisFile = null; - $this->_frqFile = null; - $this->_prxFile = null; - - $this->_lastTerm = null; - $this->_lastTermInfo = null; - $this->_lastTermPositions = null; - - return; - } - - $prevPosition = $highIndex; - $prevTerm = $this->_termDictionary[$prevPosition]; - $prevTermInfo = $this->_termDictionaryInfos[$prevPosition]; - - if ($this->_tisFile === null) { - // The end of terms stream is reached and terms dictionary file is closed - // Perform mini-reset operation - $this->_tisFile = $this->openCompoundFile('.tis', false); - - if ($this->_termsScanMode == self::SM_FULL_INFO || $this->_termsScanMode == self::SM_MERGE_INFO) { - $this->_frqFile = $this->openCompoundFile('.frq', false); - $this->_prxFile = $this->openCompoundFile('.prx', false); - } - } - $this->_tisFile->seek($this->_tisFileOffset + $prevTermInfo[4], SEEK_SET); - - $this->_lastTerm = new Zend_Search_Lucene_Index_Term($prevTerm[1] /* text */, - ($prevTerm[0] == -1) ? '' : $this->_fields[$prevTerm[0] /* field */]->name); - $this->_lastTermInfo = new Zend_Search_Lucene_Index_TermInfo($prevTermInfo[0] /* docFreq */, - $prevTermInfo[1] /* freqPointer */, - $prevTermInfo[2] /* proxPointer */, - $prevTermInfo[3] /* skipOffset */); - $this->_termCount = $this->_termNum - $prevPosition*$this->_indexInterval; - - if ($highIndex == 0) { - // skip start entry - $this->nextTerm(); - } else if ($prefix->field == $this->_lastTerm->field && $prefix->text == $this->_lastTerm->text) { - // We got exact match in the dictionary index - - if ($this->_termsScanMode == self::SM_FULL_INFO || $this->_termsScanMode == self::SM_MERGE_INFO) { - $this->_lastTermPositions = array(); - - $this->_frqFile->seek($this->_lastTermInfo->freqPointer + $this->_frqFileOffset, SEEK_SET); - $freqs = array(); $docId = 0; - for( $count = 0; $count < $this->_lastTermInfo->docFreq; $count++ ) { - $docDelta = $this->_frqFile->readVInt(); - if( $docDelta % 2 == 1 ) { - $docId += ($docDelta-1)/2; - $freqs[ $docId ] = 1; - } else { - $docId += $docDelta/2; - $freqs[ $docId ] = $this->_frqFile->readVInt(); - } - } - - $this->_prxFile->seek($this->_lastTermInfo->proxPointer + $this->_prxFileOffset, SEEK_SET); - foreach ($freqs as $docId => $freq) { - $termPosition = 0; $positions = array(); - - for ($count = 0; $count < $freq; $count++ ) { - $termPosition += $this->_prxFile->readVInt(); - $positions[] = $termPosition; - } - - if (isset($this->_docMap[$docId])) { - $this->_lastTermPositions[$this->_docMap[$docId]] = $positions; - } - } - } - - return; - } - - // Search term matching specified prefix - while ($this->_lastTerm !== null) { - if ( strcmp($this->_lastTerm->field, $prefix->field) > 0 || - ($prefix->field == $this->_lastTerm->field && strcmp($this->_lastTerm->text, $prefix->text) >= 0) ) { - // Current term matches or greate than the pattern - return; - } - - $this->nextTerm(); - } - } - - - /** - * Scans terms dictionary and returns next term - * - * @return Zend_Search_Lucene_Index_Term|null - */ - public function nextTerm() - { - if ($this->_tisFile === null || $this->_termCount == 0) { - $this->_lastTerm = null; - $this->_lastTermInfo = null; - $this->_lastTermPositions = null; - $this->_docMap = null; - - // may be necessary for "empty" segment - $this->_tisFile = null; - $this->_frqFile = null; - $this->_prxFile = null; - - return null; - } - - $termPrefixLength = $this->_tisFile->readVInt(); - $termSuffix = $this->_tisFile->readString(); - $termFieldNum = $this->_tisFile->readVInt(); - $termValue = Zend_Search_Lucene_Index_Term::getPrefix($this->_lastTerm->text, $termPrefixLength) . $termSuffix; - - $this->_lastTerm = new Zend_Search_Lucene_Index_Term($termValue, $this->_fields[$termFieldNum]->name); - - $docFreq = $this->_tisFile->readVInt(); - $freqPointer = $this->_lastTermInfo->freqPointer + $this->_tisFile->readVInt(); - $proxPointer = $this->_lastTermInfo->proxPointer + $this->_tisFile->readVInt(); - if ($docFreq >= $this->_skipInterval) { - $skipOffset = $this->_tisFile->readVInt(); - } else { - $skipOffset = 0; - } - - $this->_lastTermInfo = new Zend_Search_Lucene_Index_TermInfo($docFreq, $freqPointer, $proxPointer, $skipOffset); - - - if ($this->_termsScanMode == self::SM_FULL_INFO || $this->_termsScanMode == self::SM_MERGE_INFO) { - $this->_lastTermPositions = array(); - - $this->_frqFile->seek($this->_lastTermInfo->freqPointer + $this->_frqFileOffset, SEEK_SET); - $freqs = array(); $docId = 0; - for( $count = 0; $count < $this->_lastTermInfo->docFreq; $count++ ) { - $docDelta = $this->_frqFile->readVInt(); - if( $docDelta % 2 == 1 ) { - $docId += ($docDelta-1)/2; - $freqs[ $docId ] = 1; - } else { - $docId += $docDelta/2; - $freqs[ $docId ] = $this->_frqFile->readVInt(); - } - } - - $this->_prxFile->seek($this->_lastTermInfo->proxPointer + $this->_prxFileOffset, SEEK_SET); - foreach ($freqs as $docId => $freq) { - $termPosition = 0; $positions = array(); - - for ($count = 0; $count < $freq; $count++ ) { - $termPosition += $this->_prxFile->readVInt(); - $positions[] = $termPosition; - } - - if (isset($this->_docMap[$docId])) { - $this->_lastTermPositions[$this->_docMap[$docId]] = $positions; - } - } - } - - $this->_termCount--; - if ($this->_termCount == 0) { - $this->_tisFile = null; - $this->_frqFile = null; - $this->_prxFile = null; - } - - return $this->_lastTerm; - } - - /** - * Close terms stream - * - * Should be used for resources clean up if stream is not read up to the end - */ - public function closeTermsStream() - { - $this->_tisFile = null; - $this->_frqFile = null; - $this->_prxFile = null; - - $this->_lastTerm = null; - $this->_lastTermInfo = null; - $this->_lastTermPositions = null; - - $this->_docMap = null; - } - - - /** - * Returns term in current position - * - * @return Zend_Search_Lucene_Index_Term|null - */ - public function currentTerm() - { - return $this->_lastTerm; - } - - - /** - * Returns an array of all term positions in the documents. - * Return array structure: array( docId => array( pos1, pos2, ...), ...) - * - * @return array - */ - public function currentTermPositions() - { - return $this->_lastTermPositions; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/SegmentMerger.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/SegmentMerger.php deleted file mode 100755 index c96eadc611456a46c0671838c535f8f4007a5900..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/SegmentMerger.php +++ /dev/null @@ -1,271 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_Index_SegmentInfo */ -// require_once 'Zend/Search/Lucene/Index/SegmentInfo.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Index_SegmentMerger -{ - /** - * Target segment writer - * - * @var Zend_Search_Lucene_Index_SegmentWriter_StreamWriter - */ - private $_writer; - - /** - * Number of docs in a new segment - * - * @var integer - */ - private $_docCount; - - /** - * A set of segments to be merged - * - * @var array Zend_Search_Lucene_Index_SegmentInfo - */ - private $_segmentInfos = array(); - - /** - * Flag to signal, that merge is already done - * - * @var boolean - */ - private $_mergeDone = false; - - /** - * Field map - * [<segment_name>][<field_number>] => <target_field_number> - * - * @var array - */ - private $_fieldsMap = array(); - - - - /** - * Object constructor. - * - * Creates new segment merger with $directory as target to merge segments into - * and $name as a name of new segment - * - * @param Zend_Search_Lucene_Storage_Directory $directory - * @param string $name - */ - public function __construct($directory, $name) - { - /** Zend_Search_Lucene_Index_SegmentWriter_StreamWriter */ - // require_once 'Zend/Search/Lucene/Index/SegmentWriter/StreamWriter.php'; - $this->_writer = new Zend_Search_Lucene_Index_SegmentWriter_StreamWriter($directory, $name); - } - - - /** - * Add segmnet to a collection of segments to be merged - * - * @param Zend_Search_Lucene_Index_SegmentInfo $segment - */ - public function addSource(Zend_Search_Lucene_Index_SegmentInfo $segmentInfo) - { - $this->_segmentInfos[$segmentInfo->getName()] = $segmentInfo; - } - - - /** - * Do merge. - * - * Returns number of documents in newly created segment - * - * @return Zend_Search_Lucene_Index_SegmentInfo - * @throws Zend_Search_Lucene_Exception - */ - public function merge() - { - if ($this->_mergeDone) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Merge is already done.'); - } - - if (count($this->_segmentInfos) < 1) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Wrong number of segments to be merged (' - . count($this->_segmentInfos) - . ').'); - } - - $this->_mergeFields(); - $this->_mergeNorms(); - $this->_mergeStoredFields(); - $this->_mergeTerms(); - - $this->_mergeDone = true; - - return $this->_writer->close(); - } - - - /** - * Merge fields information - */ - private function _mergeFields() - { - foreach ($this->_segmentInfos as $segName => $segmentInfo) { - foreach ($segmentInfo->getFieldInfos() as $fieldInfo) { - $this->_fieldsMap[$segName][$fieldInfo->number] = $this->_writer->addFieldInfo($fieldInfo); - } - } - } - - /** - * Merge field's normalization factors - */ - private function _mergeNorms() - { - foreach ($this->_writer->getFieldInfos() as $fieldInfo) { - if ($fieldInfo->isIndexed) { - foreach ($this->_segmentInfos as $segName => $segmentInfo) { - if ($segmentInfo->hasDeletions()) { - $srcNorm = $segmentInfo->normVector($fieldInfo->name); - $norm = ''; - $docs = $segmentInfo->count(); - for ($count = 0; $count < $docs; $count++) { - if (!$segmentInfo->isDeleted($count)) { - $norm .= $srcNorm[$count]; - } - } - $this->_writer->addNorm($fieldInfo->name, $norm); - } else { - $this->_writer->addNorm($fieldInfo->name, $segmentInfo->normVector($fieldInfo->name)); - } - } - } - } - } - - /** - * Merge fields information - */ - private function _mergeStoredFields() - { - $this->_docCount = 0; - - foreach ($this->_segmentInfos as $segName => $segmentInfo) { - $fdtFile = $segmentInfo->openCompoundFile('.fdt'); - - for ($count = 0; $count < $segmentInfo->count(); $count++) { - $fieldCount = $fdtFile->readVInt(); - $storedFields = array(); - - for ($count2 = 0; $count2 < $fieldCount; $count2++) { - $fieldNum = $fdtFile->readVInt(); - $bits = $fdtFile->readByte(); - $fieldInfo = $segmentInfo->getField($fieldNum); - - if (!($bits & 2)) { // Text data - $storedFields[] = - new Zend_Search_Lucene_Field($fieldInfo->name, - $fdtFile->readString(), - 'UTF-8', - true, - $fieldInfo->isIndexed, - $bits & 1 ); - } else { // Binary data - $storedFields[] = - new Zend_Search_Lucene_Field($fieldInfo->name, - $fdtFile->readBinary(), - '', - true, - $fieldInfo->isIndexed, - $bits & 1, - true); - } - } - - if (!$segmentInfo->isDeleted($count)) { - $this->_docCount++; - $this->_writer->addStoredFields($storedFields); - } - } - } - } - - - /** - * Merge fields information - */ - private function _mergeTerms() - { - /** Zend_Search_Lucene_Index_TermsPriorityQueue */ - // require_once 'Zend/Search/Lucene/Index/TermsPriorityQueue.php'; - - $segmentInfoQueue = new Zend_Search_Lucene_Index_TermsPriorityQueue(); - - $segmentStartId = 0; - foreach ($this->_segmentInfos as $segName => $segmentInfo) { - $segmentStartId = $segmentInfo->resetTermsStream($segmentStartId, Zend_Search_Lucene_Index_SegmentInfo::SM_MERGE_INFO); - - // Skip "empty" segments - if ($segmentInfo->currentTerm() !== null) { - $segmentInfoQueue->put($segmentInfo); - } - } - - $this->_writer->initializeDictionaryFiles(); - - $termDocs = array(); - while (($segmentInfo = $segmentInfoQueue->pop()) !== null) { - // Merge positions array - $termDocs += $segmentInfo->currentTermPositions(); - - if ($segmentInfoQueue->top() === null || - $segmentInfoQueue->top()->currentTerm()->key() != - $segmentInfo->currentTerm()->key()) { - // We got new term - ksort($termDocs, SORT_NUMERIC); - - // Add term if it's contained in any document - if (count($termDocs) > 0) { - $this->_writer->addTerm($segmentInfo->currentTerm(), $termDocs); - } - $termDocs = array(); - } - - $segmentInfo->nextTerm(); - // check, if segment dictionary is finished - if ($segmentInfo->currentTerm() !== null) { - // Put segment back into the priority queue - $segmentInfoQueue->put($segmentInfo); - } - } - - $this->_writer->closeDictionaryFiles(); - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/SegmentWriter.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/SegmentWriter.php deleted file mode 100755 index 4d36fc04eb08ffd63e5e1f57624e72ce962b77ce..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/SegmentWriter.php +++ /dev/null @@ -1,634 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Index_FieldInfo */ -// require_once 'Zend/Search/Lucene/Index/FieldInfo.php'; - -/** Zend_Search_Lucene_Index_Term */ -// require_once 'Zend/Search/Lucene/Index/Term.php'; - -/** Zend_Search_Lucene_Index_TermInfo */ -// require_once 'Zend/Search/Lucene/Index/TermInfo.php'; - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Search_Lucene_Index_SegmentWriter -{ - /** - * Expert: The fraction of terms in the "dictionary" which should be stored - * in RAM. Smaller values use more memory, but make searching slightly - * faster, while larger values use less memory and make searching slightly - * slower. Searching is typically not dominated by dictionary lookup, so - * tweaking this is rarely useful. - * - * @var integer - */ - public static $indexInterval = 128; - - /** - * Expert: The fraction of TermDocs entries stored in skip tables. - * Larger values result in smaller indexes, greater acceleration, but fewer - * accelerable cases, while smaller values result in bigger indexes, - * less acceleration and more - * accelerable cases. More detailed experiments would be useful here. - * - * 0x7FFFFFFF indicates that we don't use skip data - * - * Note: not used in current implementation - * - * @var integer - */ - public static $skipInterval = 0x7FFFFFFF; - - /** - * Expert: The maximum number of skip levels. Smaller values result in - * slightly smaller indexes, but slower skipping in big posting lists. - * - * 0 indicates that we don't use skip data - * - * Note: not used in current implementation - * - * @var integer - */ - public static $maxSkipLevels = 0; - - /** - * Number of docs in a segment - * - * @var integer - */ - protected $_docCount = 0; - - /** - * Segment name - * - * @var string - */ - protected $_name; - - /** - * File system adapter. - * - * @var Zend_Search_Lucene_Storage_Directory - */ - protected $_directory; - - /** - * List of the index files. - * Used for automatic compound file generation - * - * @var unknown_type - */ - protected $_files = array(); - - /** - * Segment fields. Array of Zend_Search_Lucene_Index_FieldInfo objects for this segment - * - * @var array - */ - protected $_fields = array(); - - /** - * Normalization factors. - * An array fieldName => normVector - * normVector is a binary string. - * Each byte corresponds to an indexed document in a segment and - * encodes normalization factor (float value, encoded by - * Zend_Search_Lucene_Search_Similarity::encodeNorm()) - * - * @var array - */ - protected $_norms = array(); - - - /** - * '.fdx' file - Stored Fields, the field index. - * - * @var Zend_Search_Lucene_Storage_File - */ - protected $_fdxFile = null; - - /** - * '.fdt' file - Stored Fields, the field data. - * - * @var Zend_Search_Lucene_Storage_File - */ - protected $_fdtFile = null; - - - /** - * Object constructor. - * - * @param Zend_Search_Lucene_Storage_Directory $directory - * @param string $name - */ - public function __construct(Zend_Search_Lucene_Storage_Directory $directory, $name) - { - $this->_directory = $directory; - $this->_name = $name; - } - - - /** - * Add field to the segment - * - * Returns actual field number - * - * @param Zend_Search_Lucene_Field $field - * @return integer - */ - public function addField(Zend_Search_Lucene_Field $field) - { - if (!isset($this->_fields[$field->name])) { - $fieldNumber = count($this->_fields); - $this->_fields[$field->name] = - new Zend_Search_Lucene_Index_FieldInfo($field->name, - $field->isIndexed, - $fieldNumber, - $field->storeTermVector); - - return $fieldNumber; - } else { - $this->_fields[$field->name]->isIndexed |= $field->isIndexed; - $this->_fields[$field->name]->storeTermVector |= $field->storeTermVector; - - return $this->_fields[$field->name]->number; - } - } - - /** - * Add fieldInfo to the segment - * - * Returns actual field number - * - * @param Zend_Search_Lucene_Index_FieldInfo $fieldInfo - * @return integer - */ - public function addFieldInfo(Zend_Search_Lucene_Index_FieldInfo $fieldInfo) - { - if (!isset($this->_fields[$fieldInfo->name])) { - $fieldNumber = count($this->_fields); - $this->_fields[$fieldInfo->name] = - new Zend_Search_Lucene_Index_FieldInfo($fieldInfo->name, - $fieldInfo->isIndexed, - $fieldNumber, - $fieldInfo->storeTermVector); - - return $fieldNumber; - } else { - $this->_fields[$fieldInfo->name]->isIndexed |= $fieldInfo->isIndexed; - $this->_fields[$fieldInfo->name]->storeTermVector |= $fieldInfo->storeTermVector; - - return $this->_fields[$fieldInfo->name]->number; - } - } - - /** - * Returns array of FieldInfo objects. - * - * @return array - */ - public function getFieldInfos() - { - return $this->_fields; - } - - /** - * Add stored fields information - * - * @param array $storedFields array of Zend_Search_Lucene_Field objects - */ - public function addStoredFields($storedFields) - { - if (!isset($this->_fdxFile)) { - $this->_fdxFile = $this->_directory->createFile($this->_name . '.fdx'); - $this->_fdtFile = $this->_directory->createFile($this->_name . '.fdt'); - - $this->_files[] = $this->_name . '.fdx'; - $this->_files[] = $this->_name . '.fdt'; - } - - $this->_fdxFile->writeLong($this->_fdtFile->tell()); - $this->_fdtFile->writeVInt(count($storedFields)); - foreach ($storedFields as $field) { - $this->_fdtFile->writeVInt($this->_fields[$field->name]->number); - $fieldBits = ($field->isTokenized ? 0x01 : 0x00) | - ($field->isBinary ? 0x02 : 0x00) | - 0x00; /* 0x04 - third bit, compressed (ZLIB) */ - $this->_fdtFile->writeByte($fieldBits); - if ($field->isBinary) { - $this->_fdtFile->writeVInt(strlen($field->value)); - $this->_fdtFile->writeBytes($field->value); - } else { - $this->_fdtFile->writeString($field->getUtf8Value()); - } - } - - $this->_docCount++; - } - - /** - * Returns the total number of documents in this segment. - * - * @return integer - */ - public function count() - { - return $this->_docCount; - } - - /** - * Return segment name - * - * @return string - */ - public function getName() - { - return $this->_name; - } - - /** - * Dump Field Info (.fnm) segment file - */ - protected function _dumpFNM() - { - $fnmFile = $this->_directory->createFile($this->_name . '.fnm'); - $fnmFile->writeVInt(count($this->_fields)); - - $nrmFile = $this->_directory->createFile($this->_name . '.nrm'); - // Write header - $nrmFile->writeBytes('NRM'); - // Write format specifier - $nrmFile->writeByte((int)0xFF); - - foreach ($this->_fields as $field) { - $fnmFile->writeString($field->name); - $fnmFile->writeByte(($field->isIndexed ? 0x01 : 0x00) | - ($field->storeTermVector ? 0x02 : 0x00) -// not supported yet 0x04 /* term positions are stored with the term vectors */ | -// not supported yet 0x08 /* term offsets are stored with the term vectors */ | - ); - - if ($field->isIndexed) { - // pre-2.1 index mode (not used now) - // $normFileName = $this->_name . '.f' . $field->number; - // $fFile = $this->_directory->createFile($normFileName); - // $fFile->writeBytes($this->_norms[$field->name]); - // $this->_files[] = $normFileName; - - $nrmFile->writeBytes($this->_norms[$field->name]); - } - } - - $this->_files[] = $this->_name . '.fnm'; - $this->_files[] = $this->_name . '.nrm'; - } - - - - /** - * Term Dictionary file - * - * @var Zend_Search_Lucene_Storage_File - */ - private $_tisFile = null; - - /** - * Term Dictionary index file - * - * @var Zend_Search_Lucene_Storage_File - */ - private $_tiiFile = null; - - /** - * Frequencies file - * - * @var Zend_Search_Lucene_Storage_File - */ - private $_frqFile = null; - - /** - * Positions file - * - * @var Zend_Search_Lucene_Storage_File - */ - private $_prxFile = null; - - /** - * Number of written terms - * - * @var integer - */ - private $_termCount; - - - /** - * Last saved term - * - * @var Zend_Search_Lucene_Index_Term - */ - private $_prevTerm; - - /** - * Last saved term info - * - * @var Zend_Search_Lucene_Index_TermInfo - */ - private $_prevTermInfo; - - /** - * Last saved index term - * - * @var Zend_Search_Lucene_Index_Term - */ - private $_prevIndexTerm; - - /** - * Last saved index term info - * - * @var Zend_Search_Lucene_Index_TermInfo - */ - private $_prevIndexTermInfo; - - /** - * Last term dictionary file position - * - * @var integer - */ - private $_lastIndexPosition; - - /** - * Create dicrionary, frequency and positions files and write necessary headers - */ - public function initializeDictionaryFiles() - { - $this->_tisFile = $this->_directory->createFile($this->_name . '.tis'); - $this->_tisFile->writeInt((int)0xFFFFFFFD); - $this->_tisFile->writeLong(0 /* dummy data for terms count */); - $this->_tisFile->writeInt(self::$indexInterval); - $this->_tisFile->writeInt(self::$skipInterval); - $this->_tisFile->writeInt(self::$maxSkipLevels); - - $this->_tiiFile = $this->_directory->createFile($this->_name . '.tii'); - $this->_tiiFile->writeInt((int)0xFFFFFFFD); - $this->_tiiFile->writeLong(0 /* dummy data for terms count */); - $this->_tiiFile->writeInt(self::$indexInterval); - $this->_tiiFile->writeInt(self::$skipInterval); - $this->_tiiFile->writeInt(self::$maxSkipLevels); - - /** Dump dictionary header */ - $this->_tiiFile->writeVInt(0); // preffix length - $this->_tiiFile->writeString(''); // suffix - $this->_tiiFile->writeInt((int)0xFFFFFFFF); // field number - $this->_tiiFile->writeByte((int)0x0F); - $this->_tiiFile->writeVInt(0); // DocFreq - $this->_tiiFile->writeVInt(0); // FreqDelta - $this->_tiiFile->writeVInt(0); // ProxDelta - $this->_tiiFile->writeVInt(24); // IndexDelta - - $this->_frqFile = $this->_directory->createFile($this->_name . '.frq'); - $this->_prxFile = $this->_directory->createFile($this->_name . '.prx'); - - $this->_files[] = $this->_name . '.tis'; - $this->_files[] = $this->_name . '.tii'; - $this->_files[] = $this->_name . '.frq'; - $this->_files[] = $this->_name . '.prx'; - - $this->_prevTerm = null; - $this->_prevTermInfo = null; - $this->_prevIndexTerm = null; - $this->_prevIndexTermInfo = null; - $this->_lastIndexPosition = 24; - $this->_termCount = 0; - - } - - /** - * Add term - * - * Term positions is an array( docId => array(pos1, pos2, pos3, ...), ... ) - * - * @param Zend_Search_Lucene_Index_Term $termEntry - * @param array $termDocs - */ - public function addTerm($termEntry, $termDocs) - { - $freqPointer = $this->_frqFile->tell(); - $proxPointer = $this->_prxFile->tell(); - - $prevDoc = 0; - foreach ($termDocs as $docId => $termPositions) { - $docDelta = ($docId - $prevDoc)*2; - $prevDoc = $docId; - if (count($termPositions) > 1) { - $this->_frqFile->writeVInt($docDelta); - $this->_frqFile->writeVInt(count($termPositions)); - } else { - $this->_frqFile->writeVInt($docDelta + 1); - } - - $prevPosition = 0; - foreach ($termPositions as $position) { - $this->_prxFile->writeVInt($position - $prevPosition); - $prevPosition = $position; - } - } - - if (count($termDocs) >= self::$skipInterval) { - /** - * @todo Write Skip Data to a freq file. - * It's not used now, but make index more optimal - */ - $skipOffset = $this->_frqFile->tell() - $freqPointer; - } else { - $skipOffset = 0; - } - - $term = new Zend_Search_Lucene_Index_Term($termEntry->text, - $this->_fields[$termEntry->field]->number); - $termInfo = new Zend_Search_Lucene_Index_TermInfo(count($termDocs), - $freqPointer, $proxPointer, $skipOffset); - - $this->_dumpTermDictEntry($this->_tisFile, $this->_prevTerm, $term, $this->_prevTermInfo, $termInfo); - - if (($this->_termCount + 1) % self::$indexInterval == 0) { - $this->_dumpTermDictEntry($this->_tiiFile, $this->_prevIndexTerm, $term, $this->_prevIndexTermInfo, $termInfo); - - $indexPosition = $this->_tisFile->tell(); - $this->_tiiFile->writeVInt($indexPosition - $this->_lastIndexPosition); - $this->_lastIndexPosition = $indexPosition; - - } - $this->_termCount++; - } - - /** - * Close dictionary - */ - public function closeDictionaryFiles() - { - $this->_tisFile->seek(4); - $this->_tisFile->writeLong($this->_termCount); - - $this->_tiiFile->seek(4); - // + 1 is used to count an additional special index entry (empty term at the start of the list) - $this->_tiiFile->writeLong(($this->_termCount - $this->_termCount % self::$indexInterval)/self::$indexInterval + 1); - } - - - /** - * Dump Term Dictionary segment file entry. - * Used to write entry to .tis or .tii files - * - * @param Zend_Search_Lucene_Storage_File $dicFile - * @param Zend_Search_Lucene_Index_Term $prevTerm - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_TermInfo $prevTermInfo - * @param Zend_Search_Lucene_Index_TermInfo $termInfo - */ - protected function _dumpTermDictEntry(Zend_Search_Lucene_Storage_File $dicFile, - &$prevTerm, Zend_Search_Lucene_Index_Term $term, - &$prevTermInfo, Zend_Search_Lucene_Index_TermInfo $termInfo) - { - if (isset($prevTerm) && $prevTerm->field == $term->field) { - $matchedBytes = 0; - $maxBytes = min(strlen($prevTerm->text), strlen($term->text)); - while ($matchedBytes < $maxBytes && - $prevTerm->text[$matchedBytes] == $term->text[$matchedBytes]) { - $matchedBytes++; - } - - // Calculate actual matched UTF-8 pattern - $prefixBytes = 0; - $prefixChars = 0; - while ($prefixBytes < $matchedBytes) { - $charBytes = 1; - if ((ord($term->text[$prefixBytes]) & 0xC0) == 0xC0) { - $charBytes++; - if (ord($term->text[$prefixBytes]) & 0x20 ) { - $charBytes++; - if (ord($term->text[$prefixBytes]) & 0x10 ) { - $charBytes++; - } - } - } - - if ($prefixBytes + $charBytes > $matchedBytes) { - // char crosses matched bytes boundary - // skip char - break; - } - - $prefixChars++; - $prefixBytes += $charBytes; - } - - // Write preffix length - $dicFile->writeVInt($prefixChars); - // Write suffix - $dicFile->writeString(substr($term->text, $prefixBytes)); - } else { - // Write preffix length - $dicFile->writeVInt(0); - // Write suffix - $dicFile->writeString($term->text); - } - // Write field number - $dicFile->writeVInt($term->field); - // DocFreq (the count of documents which contain the term) - $dicFile->writeVInt($termInfo->docFreq); - - $prevTerm = $term; - - if (!isset($prevTermInfo)) { - // Write FreqDelta - $dicFile->writeVInt($termInfo->freqPointer); - // Write ProxDelta - $dicFile->writeVInt($termInfo->proxPointer); - } else { - // Write FreqDelta - $dicFile->writeVInt($termInfo->freqPointer - $prevTermInfo->freqPointer); - // Write ProxDelta - $dicFile->writeVInt($termInfo->proxPointer - $prevTermInfo->proxPointer); - } - // Write SkipOffset - it's not 0 when $termInfo->docFreq > self::$skipInterval - if ($termInfo->skipOffset != 0) { - $dicFile->writeVInt($termInfo->skipOffset); - } - - $prevTermInfo = $termInfo; - } - - - /** - * Generate compound index file - */ - protected function _generateCFS() - { - $cfsFile = $this->_directory->createFile($this->_name . '.cfs'); - $cfsFile->writeVInt(count($this->_files)); - - $dataOffsetPointers = array(); - foreach ($this->_files as $fileName) { - $dataOffsetPointers[$fileName] = $cfsFile->tell(); - $cfsFile->writeLong(0); // write dummy data - $cfsFile->writeString($fileName); - } - - foreach ($this->_files as $fileName) { - // Get actual data offset - $dataOffset = $cfsFile->tell(); - // Seek to the data offset pointer - $cfsFile->seek($dataOffsetPointers[$fileName]); - // Write actual data offset value - $cfsFile->writeLong($dataOffset); - // Seek back to the end of file - $cfsFile->seek($dataOffset); - - $dataFile = $this->_directory->getFileObject($fileName); - - $byteCount = $this->_directory->fileLength($fileName); - while ($byteCount > 0) { - $data = $dataFile->readBytes(min($byteCount, 131072 /*128Kb*/)); - $byteCount -= strlen($data); - $cfsFile->writeBytes($data); - } - - $this->_directory->deleteFile($fileName); - } - } - - - /** - * Close segment, write it to disk and return segment info - * - * @return Zend_Search_Lucene_Index_SegmentInfo - */ - abstract public function close(); -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/SegmentWriter/DocumentWriter.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/SegmentWriter/DocumentWriter.php deleted file mode 100755 index eced5a61b388777fc3d8dd5386e786a39370518c..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/SegmentWriter/DocumentWriter.php +++ /dev/null @@ -1,230 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_Index_SegmentWriter */ -// require_once 'Zend/Search/Lucene/Index/SegmentWriter.php'; - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter extends Zend_Search_Lucene_Index_SegmentWriter -{ - /** - * Term Dictionary - * Array of the Zend_Search_Lucene_Index_Term objects - * Corresponding Zend_Search_Lucene_Index_TermInfo object stored in the $_termDictionaryInfos - * - * @var array - */ - protected $_termDictionary; - - /** - * Documents, which contain the term - * - * @var array - */ - protected $_termDocs; - - /** - * Object constructor. - * - * @param Zend_Search_Lucene_Storage_Directory $directory - * @param string $name - */ - public function __construct(Zend_Search_Lucene_Storage_Directory $directory, $name) - { - parent::__construct($directory, $name); - - $this->_termDocs = array(); - $this->_termDictionary = array(); - } - - - /** - * Adds a document to this segment. - * - * @param Zend_Search_Lucene_Document $document - * @throws Zend_Search_Lucene_Exception - */ - public function addDocument(Zend_Search_Lucene_Document $document) - { - /** Zend_Search_Lucene_Search_Similarity */ - // require_once 'Zend/Search/Lucene/Search/Similarity.php'; - - $storedFields = array(); - $docNorms = array(); - $similarity = Zend_Search_Lucene_Search_Similarity::getDefault(); - - foreach ($document->getFieldNames() as $fieldName) { - $field = $document->getField($fieldName); - - if ($field->storeTermVector) { - /** - * @todo term vector storing support - */ - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Store term vector functionality is not supported yet.'); - } - - if ($field->isIndexed) { - if ($field->isTokenized) { - /** Zend_Search_Lucene_Analysis_Analyzer */ - // require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - - $analyzer = Zend_Search_Lucene_Analysis_Analyzer::getDefault(); - $analyzer->setInput($field->value, $field->encoding); - - $position = 0; - $tokenCounter = 0; - while (($token = $analyzer->nextToken()) !== null) { - $tokenCounter++; - - $term = new Zend_Search_Lucene_Index_Term($token->getTermText(), $field->name); - $termKey = $term->key(); - - if (!isset($this->_termDictionary[$termKey])) { - // New term - $this->_termDictionary[$termKey] = $term; - $this->_termDocs[$termKey] = array(); - $this->_termDocs[$termKey][$this->_docCount] = array(); - } else if (!isset($this->_termDocs[$termKey][$this->_docCount])) { - // Existing term, but new term entry - $this->_termDocs[$termKey][$this->_docCount] = array(); - } - $position += $token->getPositionIncrement(); - $this->_termDocs[$termKey][$this->_docCount][] = $position; - } - - if ($tokenCounter == 0) { - // Field contains empty value. Treat it as non-indexed and non-tokenized - $field = clone($field); - $field->isIndexed = $field->isTokenized = false; - } else { - $docNorms[$field->name] = chr($similarity->encodeNorm( $similarity->lengthNorm($field->name, - $tokenCounter)* - $document->boost* - $field->boost )); - } - } else if (($fieldUtf8Value = $field->getUtf8Value()) == '') { - // Field contains empty value. Treat it as non-indexed and non-tokenized - $field = clone($field); - $field->isIndexed = $field->isTokenized = false; - } else { - $term = new Zend_Search_Lucene_Index_Term($fieldUtf8Value, $field->name); - $termKey = $term->key(); - - if (!isset($this->_termDictionary[$termKey])) { - // New term - $this->_termDictionary[$termKey] = $term; - $this->_termDocs[$termKey] = array(); - $this->_termDocs[$termKey][$this->_docCount] = array(); - } else if (!isset($this->_termDocs[$termKey][$this->_docCount])) { - // Existing term, but new term entry - $this->_termDocs[$termKey][$this->_docCount] = array(); - } - $this->_termDocs[$termKey][$this->_docCount][] = 0; // position - - $docNorms[$field->name] = chr($similarity->encodeNorm( $similarity->lengthNorm($field->name, 1)* - $document->boost* - $field->boost )); - } - } - - if ($field->isStored) { - $storedFields[] = $field; - } - - $this->addField($field); - } - - foreach ($this->_fields as $fieldName => $field) { - if (!$field->isIndexed) { - continue; - } - - if (!isset($this->_norms[$fieldName])) { - $this->_norms[$fieldName] = str_repeat(chr($similarity->encodeNorm( $similarity->lengthNorm($fieldName, 0) )), - $this->_docCount); - } - - if (isset($docNorms[$fieldName])){ - $this->_norms[$fieldName] .= $docNorms[$fieldName]; - } else { - $this->_norms[$fieldName] .= chr($similarity->encodeNorm( $similarity->lengthNorm($fieldName, 0) )); - } - } - - $this->addStoredFields($storedFields); - } - - - /** - * Dump Term Dictionary (.tis) and Term Dictionary Index (.tii) segment files - */ - protected function _dumpDictionary() - { - ksort($this->_termDictionary, SORT_STRING); - - $this->initializeDictionaryFiles(); - - foreach ($this->_termDictionary as $termId => $term) { - $this->addTerm($term, $this->_termDocs[$termId]); - } - - $this->closeDictionaryFiles(); - } - - - /** - * Close segment, write it to disk and return segment info - * - * @return Zend_Search_Lucene_Index_SegmentInfo - */ - public function close() - { - if ($this->_docCount == 0) { - return null; - } - - $this->_dumpFNM(); - $this->_dumpDictionary(); - - $this->_generateCFS(); - - /** Zend_Search_Lucene_Index_SegmentInfo */ - // require_once 'Zend/Search/Lucene/Index/SegmentInfo.php'; - - return new Zend_Search_Lucene_Index_SegmentInfo($this->_directory, - $this->_name, - $this->_docCount, - -1, - null, - true, - true); - } - -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/SegmentWriter/StreamWriter.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/SegmentWriter/StreamWriter.php deleted file mode 100755 index 3471ccf7efc046d80f1e2231aacd7c4a25a2741c..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/SegmentWriter/StreamWriter.php +++ /dev/null @@ -1,94 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_Index_SegmentWriter */ -// require_once 'Zend/Search/Lucene/Index/SegmentWriter.php'; - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Index_SegmentWriter_StreamWriter extends Zend_Search_Lucene_Index_SegmentWriter -{ - /** - * Object constructor. - * - * @param Zend_Search_Lucene_Storage_Directory $directory - * @param string $name - */ - public function __construct(Zend_Search_Lucene_Storage_Directory $directory, $name) - { - parent::__construct($directory, $name); - } - - - /** - * Create stored fields files and open them for write - */ - public function createStoredFieldsFiles() - { - $this->_fdxFile = $this->_directory->createFile($this->_name . '.fdx'); - $this->_fdtFile = $this->_directory->createFile($this->_name . '.fdt'); - - $this->_files[] = $this->_name . '.fdx'; - $this->_files[] = $this->_name . '.fdt'; - } - - public function addNorm($fieldName, $normVector) - { - if (isset($this->_norms[$fieldName])) { - $this->_norms[$fieldName] .= $normVector; - } else { - $this->_norms[$fieldName] = $normVector; - } - } - - /** - * Close segment, write it to disk and return segment info - * - * @return Zend_Search_Lucene_Index_SegmentInfo - */ - public function close() - { - if ($this->_docCount == 0) { - return null; - } - - $this->_dumpFNM(); - $this->_generateCFS(); - - /** Zend_Search_Lucene_Index_SegmentInfo */ - // require_once 'Zend/Search/Lucene/Index/SegmentInfo.php'; - - return new Zend_Search_Lucene_Index_SegmentInfo($this->_directory, - $this->_name, - $this->_docCount, - -1, - null, - true, - true); - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/Term.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/Term.php deleted file mode 100755 index b2328384dc4e96ef4e2fdd63a378ff5155abe473..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/Term.php +++ /dev/null @@ -1,144 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * A Term represents a word from text. This is the unit of search. It is - * composed of two elements, the text of the word, as a string, and the name of - * the field that the text occured in, an interned string. - * - * Note that terms may represent more than words from text fields, but also - * things like dates, email addresses, urls, etc. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Index_Term -{ - /** - * Field name or field number (depending from context) - * - * @var mixed - */ - public $field; - - /** - * Term value - * - * @var string - */ - public $text; - - - /** - * Object constructor - */ - public function __construct($text, $field = null) - { - $this->field = ($field === null)? Zend_Search_Lucene::getDefaultSearchField() : $field; - $this->text = $text; - } - - - /** - * Returns term key - * - * @return string - */ - public function key() - { - return $this->field . chr(0) . $this->text; - } - - /** - * Get term prefix - * - * @param string $str - * @param integer $length - * @return string - */ - public static function getPrefix($str, $length) - { - $prefixBytes = 0; - $prefixChars = 0; - while ($prefixBytes < strlen($str) && $prefixChars < $length) { - $charBytes = 1; - if ((ord($str[$prefixBytes]) & 0xC0) == 0xC0) { - $charBytes++; - if (ord($str[$prefixBytes]) & 0x20 ) { - $charBytes++; - if (ord($str[$prefixBytes]) & 0x10 ) { - $charBytes++; - } - } - } - - if ($prefixBytes + $charBytes > strlen($str)) { - // wrong character - break; - } - - $prefixChars++; - $prefixBytes += $charBytes; - } - - return substr($str, 0, $prefixBytes); - } - - /** - * Get UTF-8 string length - * - * @param string $str - * @return string - */ - public static function getLength($str) - { - $bytes = 0; - $chars = 0; - while ($bytes < strlen($str)) { - $charBytes = 1; - if ((ord($str[$bytes]) & 0xC0) == 0xC0) { - $charBytes++; - if (ord($str[$bytes]) & 0x20 ) { - $charBytes++; - if (ord($str[$bytes]) & 0x10 ) { - $charBytes++; - } - } - } - - if ($bytes + $charBytes > strlen($str)) { - // wrong character - break; - } - - $chars++; - $bytes += $charBytes; - } - - return $chars; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/TermInfo.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/TermInfo.php deleted file mode 100755 index 824980883a5a9ff34638770d5b3096e0adcfa654..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/TermInfo.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * A Zend_Search_Lucene_Index_TermInfo represents a record of information stored for a term. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Index_TermInfo -{ - /** - * The number of documents which contain the term. - * - * @var integer - */ - public $docFreq; - - /** - * Data offset in a Frequencies file. - * - * @var integer - */ - public $freqPointer; - - /** - * Data offset in a Positions file. - * - * @var integer - */ - public $proxPointer; - - /** - * ScipData offset in a Frequencies file. - * - * @var integer - */ - public $skipOffset; - - /** - * Term offset of the _next_ term in a TermDictionary file. - * Used only for Term Index - * - * @var integer - */ - public $indexPointer; - - public function __construct($docFreq, $freqPointer, $proxPointer, $skipOffset, $indexPointer = null) - { - $this->docFreq = $docFreq; - $this->freqPointer = $freqPointer; - $this->proxPointer = $proxPointer; - $this->skipOffset = $skipOffset; - $this->indexPointer = $indexPointer; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/TermsPriorityQueue.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/TermsPriorityQueue.php deleted file mode 100755 index f0c3aaa1d72fd6337389f669441a2de7499cdd67..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/TermsPriorityQueue.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_PriorityQueue */ -// require_once 'Zend/Search/Lucene/PriorityQueue.php'; - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Index_TermsPriorityQueue extends Zend_Search_Lucene_PriorityQueue -{ - /** - * Compare elements - * - * Returns true, if $termsStream1 is "less" than $termsStream2; else otherwise - * - * @param mixed $termsStream1 - * @param mixed $termsStream2 - * @return boolean - */ - protected function _less($termsStream1, $termsStream2) - { - return strcmp($termsStream1->currentTerm()->key(), $termsStream2->currentTerm()->key()) < 0; - } - -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/TermsStream/Interface.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/TermsStream/Interface.php deleted file mode 100755 index 67952bbf8a48a7ecb19409bc72fa8653f2b6a04f..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/TermsStream/Interface.php +++ /dev/null @@ -1,66 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -interface Zend_Search_Lucene_Index_TermsStream_Interface -{ - /** - * Reset terms stream. - */ - public function resetTermsStream(); - - /** - * Skip terms stream up to the specified term preffix. - * - * Prefix contains fully specified field info and portion of searched term - * - * @param Zend_Search_Lucene_Index_Term $prefix - */ - public function skipTo(Zend_Search_Lucene_Index_Term $prefix); - - /** - * Scans terms dictionary and returns next term - * - * @return Zend_Search_Lucene_Index_Term|null - */ - public function nextTerm(); - - /** - * Returns term in current position - * - * @return Zend_Search_Lucene_Index_Term|null - */ - public function currentTerm(); - - /** - * Close terms stream - * - * Should be used for resources clean up if stream is not read up to the end - */ - public function closeTermsStream(); -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/Writer.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/Writer.php deleted file mode 100755 index e7b69605fd93a432924224c7712ba5ebaa76afbf..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Index/Writer.php +++ /dev/null @@ -1,841 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_LockManager */ -// require_once 'Zend/Search/Lucene/LockManager.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Index_Writer -{ - /** - * @todo Implement Analyzer substitution - * @todo Implement Zend_Search_Lucene_Storage_DirectoryRAM and Zend_Search_Lucene_Storage_FileRAM to use it for - * temporary index files - * @todo Directory lock processing - */ - - /** - * Number of documents required before the buffered in-memory - * documents are written into a new Segment - * - * Default value is 10 - * - * @var integer - */ - public $maxBufferedDocs = 10; - - /** - * Largest number of documents ever merged by addDocument(). - * Small values (e.g., less than 10,000) are best for interactive indexing, - * as this limits the length of pauses while indexing to a few seconds. - * Larger values are best for batched indexing and speedier searches. - * - * Default value is PHP_INT_MAX - * - * @var integer - */ - public $maxMergeDocs = PHP_INT_MAX; - - /** - * Determines how often segment indices are merged by addDocument(). - * - * With smaller values, less RAM is used while indexing, - * and searches on unoptimized indices are faster, - * but indexing speed is slower. - * - * With larger values, more RAM is used during indexing, - * and while searches on unoptimized indices are slower, - * indexing is faster. - * - * Thus larger values (> 10) are best for batch index creation, - * and smaller values (< 10) for indices that are interactively maintained. - * - * Default value is 10 - * - * @var integer - */ - public $mergeFactor = 10; - - /** - * File system adapter. - * - * @var Zend_Search_Lucene_Storage_Directory - */ - private $_directory = null; - - - /** - * Changes counter. - * - * @var integer - */ - private $_versionUpdate = 0; - - /** - * List of the segments, created by index writer - * Array of Zend_Search_Lucene_Index_SegmentInfo objects - * - * @var array - */ - private $_newSegments = array(); - - /** - * List of segments to be deleted on commit - * - * @var array - */ - private $_segmentsToDelete = array(); - - /** - * Current segment to add documents - * - * @var Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter - */ - private $_currentSegment = null; - - /** - * Array of Zend_Search_Lucene_Index_SegmentInfo objects for this index. - * - * It's a reference to the corresponding Zend_Search_Lucene::$_segmentInfos array - * - * @var array Zend_Search_Lucene_Index_SegmentInfo - */ - private $_segmentInfos; - - /** - * Index target format version - * - * @var integer - */ - private $_targetFormatVersion; - - /** - * List of indexfiles extensions - * - * @var array - */ - private static $_indexExtensions = array('.cfs' => '.cfs', - '.cfx' => '.cfx', - '.fnm' => '.fnm', - '.fdx' => '.fdx', - '.fdt' => '.fdt', - '.tis' => '.tis', - '.tii' => '.tii', - '.frq' => '.frq', - '.prx' => '.prx', - '.tvx' => '.tvx', - '.tvd' => '.tvd', - '.tvf' => '.tvf', - '.del' => '.del', - '.sti' => '.sti' ); - - - /** - * Create empty index - * - * @param Zend_Search_Lucene_Storage_Directory $directory - * @param integer $generation - * @param integer $nameCount - */ - public static function createIndex(Zend_Search_Lucene_Storage_Directory $directory, $generation, $nameCount) - { - if ($generation == 0) { - // Create index in pre-2.1 mode - foreach ($directory->fileList() as $file) { - if ($file == 'deletable' || - $file == 'segments' || - isset(self::$_indexExtensions[ substr($file, strlen($file)-4)]) || - preg_match('/\.f\d+$/i', $file) /* matches <segment_name>.f<decimal_nmber> file names */) { - $directory->deleteFile($file); - } - } - - $segmentsFile = $directory->createFile('segments'); - $segmentsFile->writeInt((int)0xFFFFFFFF); - - // write version (initialized by current time) - $segmentsFile->writeLong(round(microtime(true))); - - // write name counter - $segmentsFile->writeInt($nameCount); - // write segment counter - $segmentsFile->writeInt(0); - - $deletableFile = $directory->createFile('deletable'); - // write counter - $deletableFile->writeInt(0); - } else { - $genFile = $directory->createFile('segments.gen'); - - $genFile->writeInt((int)0xFFFFFFFE); - // Write generation two times - $genFile->writeLong($generation); - $genFile->writeLong($generation); - - $segmentsFile = $directory->createFile(Zend_Search_Lucene::getSegmentFileName($generation)); - $segmentsFile->writeInt((int)0xFFFFFFFD); - - // write version (initialized by current time) - $segmentsFile->writeLong(round(microtime(true))); - - // write name counter - $segmentsFile->writeInt($nameCount); - // write segment counter - $segmentsFile->writeInt(0); - } - } - - /** - * Open the index for writing - * - * @param Zend_Search_Lucene_Storage_Directory $directory - * @param array $segmentInfos - * @param integer $targetFormatVersion - * @param Zend_Search_Lucene_Storage_File $cleanUpLock - */ - public function __construct(Zend_Search_Lucene_Storage_Directory $directory, &$segmentInfos, $targetFormatVersion) - { - $this->_directory = $directory; - $this->_segmentInfos = &$segmentInfos; - $this->_targetFormatVersion = $targetFormatVersion; - } - - /** - * Adds a document to this index. - * - * @param Zend_Search_Lucene_Document $document - */ - public function addDocument(Zend_Search_Lucene_Document $document) - { - /** Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter */ - // require_once 'Zend/Search/Lucene/Index/SegmentWriter/DocumentWriter.php'; - - if ($this->_currentSegment === null) { - $this->_currentSegment = - new Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter($this->_directory, $this->_newSegmentName()); - } - $this->_currentSegment->addDocument($document); - - if ($this->_currentSegment->count() >= $this->maxBufferedDocs) { - $this->commit(); - } - - $this->_maybeMergeSegments(); - - $this->_versionUpdate++; - } - - - /** - * Check if we have anything to merge - * - * @return boolean - */ - private function _hasAnythingToMerge() - { - $segmentSizes = array(); - foreach ($this->_segmentInfos as $segName => $segmentInfo) { - $segmentSizes[$segName] = $segmentInfo->count(); - } - - $mergePool = array(); - $poolSize = 0; - $sizeToMerge = $this->maxBufferedDocs; - asort($segmentSizes, SORT_NUMERIC); - foreach ($segmentSizes as $segName => $size) { - // Check, if segment comes into a new merging block - while ($size >= $sizeToMerge) { - // Merge previous block if it's large enough - if ($poolSize >= $sizeToMerge) { - return true; - } - $mergePool = array(); - $poolSize = 0; - - $sizeToMerge *= $this->mergeFactor; - - if ($sizeToMerge > $this->maxMergeDocs) { - return false; - } - } - - $mergePool[] = $this->_segmentInfos[$segName]; - $poolSize += $size; - } - - if ($poolSize >= $sizeToMerge) { - return true; - } - - return false; - } - - /** - * Merge segments if necessary - */ - private function _maybeMergeSegments() - { - if (Zend_Search_Lucene_LockManager::obtainOptimizationLock($this->_directory) === false) { - return; - } - - if (!$this->_hasAnythingToMerge()) { - Zend_Search_Lucene_LockManager::releaseOptimizationLock($this->_directory); - return; - } - - // Update segments list to be sure all segments are not merged yet by another process - // - // Segment merging functionality is concentrated in this class and surrounded - // by optimization lock obtaining/releasing. - // _updateSegments() refreshes segments list from the latest index generation. - // So only new segments can be added to the index while we are merging some already existing - // segments. - // Newly added segments will be also included into the index by the _updateSegments() call - // either by another process or by the current process with the commit() call at the end of _mergeSegments() method. - // That's guaranteed by the serialisation of _updateSegments() execution using exclusive locks. - $this->_updateSegments(); - - // Perform standard auto-optimization procedure - $segmentSizes = array(); - foreach ($this->_segmentInfos as $segName => $segmentInfo) { - $segmentSizes[$segName] = $segmentInfo->count(); - } - - $mergePool = array(); - $poolSize = 0; - $sizeToMerge = $this->maxBufferedDocs; - asort($segmentSizes, SORT_NUMERIC); - foreach ($segmentSizes as $segName => $size) { - // Check, if segment comes into a new merging block - while ($size >= $sizeToMerge) { - // Merge previous block if it's large enough - if ($poolSize >= $sizeToMerge) { - $this->_mergeSegments($mergePool); - } - $mergePool = array(); - $poolSize = 0; - - $sizeToMerge *= $this->mergeFactor; - - if ($sizeToMerge > $this->maxMergeDocs) { - Zend_Search_Lucene_LockManager::releaseOptimizationLock($this->_directory); - return; - } - } - - $mergePool[] = $this->_segmentInfos[$segName]; - $poolSize += $size; - } - - if ($poolSize >= $sizeToMerge) { - $this->_mergeSegments($mergePool); - } - - Zend_Search_Lucene_LockManager::releaseOptimizationLock($this->_directory); - } - - /** - * Merge specified segments - * - * $segments is an array of SegmentInfo objects - * - * @param array $segments - */ - private function _mergeSegments($segments) - { - $newName = $this->_newSegmentName(); - - /** Zend_Search_Lucene_Index_SegmentMerger */ - // require_once 'Zend/Search/Lucene/Index/SegmentMerger.php'; - $merger = new Zend_Search_Lucene_Index_SegmentMerger($this->_directory, - $newName); - foreach ($segments as $segmentInfo) { - $merger->addSource($segmentInfo); - $this->_segmentsToDelete[$segmentInfo->getName()] = $segmentInfo->getName(); - } - - $newSegment = $merger->merge(); - if ($newSegment !== null) { - $this->_newSegments[$newSegment->getName()] = $newSegment; - } - - $this->commit(); - } - - /** - * Update segments file by adding current segment to a list - * - * @throws Zend_Search_Lucene_Exception - */ - private function _updateSegments() - { - // Get an exclusive index lock - Zend_Search_Lucene_LockManager::obtainWriteLock($this->_directory); - - // Write down changes for the segments - foreach ($this->_segmentInfos as $segInfo) { - $segInfo->writeChanges(); - } - - - $generation = Zend_Search_Lucene::getActualGeneration($this->_directory); - $segmentsFile = $this->_directory->getFileObject(Zend_Search_Lucene::getSegmentFileName($generation), false); - $newSegmentFile = $this->_directory->createFile(Zend_Search_Lucene::getSegmentFileName(++$generation), false); - - try { - $genFile = $this->_directory->getFileObject('segments.gen', false); - } catch (Zend_Search_Lucene_Exception $e) { - if (strpos($e->getMessage(), 'is not readable') !== false) { - $genFile = $this->_directory->createFile('segments.gen'); - } else { - throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e); - } - } - - $genFile->writeInt((int)0xFFFFFFFE); - // Write generation (first copy) - $genFile->writeLong($generation); - - try { - // Write format marker - if ($this->_targetFormatVersion == Zend_Search_Lucene::FORMAT_2_1) { - $newSegmentFile->writeInt((int)0xFFFFFFFD); - } else if ($this->_targetFormatVersion == Zend_Search_Lucene::FORMAT_2_3) { - $newSegmentFile->writeInt((int)0xFFFFFFFC); - } - - // Read src file format identifier - $format = $segmentsFile->readInt(); - if ($format == (int)0xFFFFFFFF) { - $srcFormat = Zend_Search_Lucene::FORMAT_PRE_2_1; - } else if ($format == (int)0xFFFFFFFD) { - $srcFormat = Zend_Search_Lucene::FORMAT_2_1; - } else if ($format == (int)0xFFFFFFFC) { - $srcFormat = Zend_Search_Lucene::FORMAT_2_3; - } else { - throw new Zend_Search_Lucene_Exception('Unsupported segments file format'); - } - - $version = $segmentsFile->readLong() + $this->_versionUpdate; - $this->_versionUpdate = 0; - $newSegmentFile->writeLong($version); - - // Write segment name counter - $newSegmentFile->writeInt($segmentsFile->readInt()); - - // Get number of segments offset - $numOfSegmentsOffset = $newSegmentFile->tell(); - // Write dummy data (segment counter) - $newSegmentFile->writeInt(0); - - // Read number of segemnts - $segmentsCount = $segmentsFile->readInt(); - - $segments = array(); - for ($count = 0; $count < $segmentsCount; $count++) { - $segName = $segmentsFile->readString(); - $segSize = $segmentsFile->readInt(); - - if ($srcFormat == Zend_Search_Lucene::FORMAT_PRE_2_1) { - // pre-2.1 index format - $delGen = 0; - $hasSingleNormFile = false; - $numField = (int)0xFFFFFFFF; - $isCompoundByte = 0; - $docStoreOptions = null; - } else { - $delGen = $segmentsFile->readLong(); - - if ($srcFormat == Zend_Search_Lucene::FORMAT_2_3) { - $docStoreOffset = $segmentsFile->readInt(); - - if ($docStoreOffset != (int)0xFFFFFFFF) { - $docStoreSegment = $segmentsFile->readString(); - $docStoreIsCompoundFile = $segmentsFile->readByte(); - - $docStoreOptions = array('offset' => $docStoreOffset, - 'segment' => $docStoreSegment, - 'isCompound' => ($docStoreIsCompoundFile == 1)); - } else { - $docStoreOptions = null; - } - } else { - $docStoreOptions = null; - } - - $hasSingleNormFile = $segmentsFile->readByte(); - $numField = $segmentsFile->readInt(); - - $normGens = array(); - if ($numField != (int)0xFFFFFFFF) { - for ($count1 = 0; $count1 < $numField; $count1++) { - $normGens[] = $segmentsFile->readLong(); - } - } - $isCompoundByte = $segmentsFile->readByte(); - } - - if (!in_array($segName, $this->_segmentsToDelete)) { - // Load segment if necessary - if (!isset($this->_segmentInfos[$segName])) { - if ($isCompoundByte == 0xFF) { - // The segment is not a compound file - $isCompound = false; - } else if ($isCompoundByte == 0x00) { - // The status is unknown - $isCompound = null; - } else if ($isCompoundByte == 0x01) { - // The segment is a compound file - $isCompound = true; - } - - /** Zend_Search_Lucene_Index_SegmentInfo */ - // require_once 'Zend/Search/Lucene/Index/SegmentInfo.php'; - $this->_segmentInfos[$segName] = - new Zend_Search_Lucene_Index_SegmentInfo($this->_directory, - $segName, - $segSize, - $delGen, - $docStoreOptions, - $hasSingleNormFile, - $isCompound); - } else { - // Retrieve actual deletions file generation number - $delGen = $this->_segmentInfos[$segName]->getDelGen(); - } - - $newSegmentFile->writeString($segName); - $newSegmentFile->writeInt($segSize); - $newSegmentFile->writeLong($delGen); - if ($this->_targetFormatVersion == Zend_Search_Lucene::FORMAT_2_3) { - if ($docStoreOptions !== null) { - $newSegmentFile->writeInt($docStoreOffset); - $newSegmentFile->writeString($docStoreSegment); - $newSegmentFile->writeByte($docStoreIsCompoundFile); - } else { - // Set DocStoreOffset to -1 - $newSegmentFile->writeInt((int)0xFFFFFFFF); - } - } else if ($docStoreOptions !== null) { - // Release index write lock - Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory); - - throw new Zend_Search_Lucene_Exception('Index conversion to lower format version is not supported.'); - } - - $newSegmentFile->writeByte($hasSingleNormFile); - $newSegmentFile->writeInt($numField); - if ($numField != (int)0xFFFFFFFF) { - foreach ($normGens as $normGen) { - $newSegmentFile->writeLong($normGen); - } - } - $newSegmentFile->writeByte($isCompoundByte); - - $segments[$segName] = $segSize; - } - } - $segmentsFile->close(); - - $segmentsCount = count($segments) + count($this->_newSegments); - - foreach ($this->_newSegments as $segName => $segmentInfo) { - $newSegmentFile->writeString($segName); - $newSegmentFile->writeInt($segmentInfo->count()); - - // delete file generation: -1 (there is no delete file yet) - $newSegmentFile->writeInt((int)0xFFFFFFFF);$newSegmentFile->writeInt((int)0xFFFFFFFF); - if ($this->_targetFormatVersion == Zend_Search_Lucene::FORMAT_2_3) { - // docStoreOffset: -1 (segment doesn't use shared doc store) - $newSegmentFile->writeInt((int)0xFFFFFFFF); - } - // HasSingleNormFile - $newSegmentFile->writeByte($segmentInfo->hasSingleNormFile()); - // NumField - $newSegmentFile->writeInt((int)0xFFFFFFFF); - // IsCompoundFile - $newSegmentFile->writeByte($segmentInfo->isCompound() ? 1 : -1); - - $segments[$segmentInfo->getName()] = $segmentInfo->count(); - $this->_segmentInfos[$segName] = $segmentInfo; - } - $this->_newSegments = array(); - - $newSegmentFile->seek($numOfSegmentsOffset); - $newSegmentFile->writeInt($segmentsCount); // Update segments count - $newSegmentFile->close(); - } catch (Exception $e) { - /** Restore previous index generation */ - $generation--; - $genFile->seek(4, SEEK_SET); - // Write generation number twice - $genFile->writeLong($generation); $genFile->writeLong($generation); - - // Release index write lock - Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory); - - // Throw the exception - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e); - } - - // Write generation (second copy) - $genFile->writeLong($generation); - - - // Check if another update or read process is not running now - // If yes, skip clean-up procedure - if (Zend_Search_Lucene_LockManager::escalateReadLock($this->_directory)) { - /** - * Clean-up directory - */ - $filesToDelete = array(); - $filesTypes = array(); - $filesNumbers = array(); - - // list of .del files of currently used segments - // each segment can have several generations of .del files - // only last should not be deleted - $delFiles = array(); - - foreach ($this->_directory->fileList() as $file) { - if ($file == 'deletable') { - // 'deletable' file - $filesToDelete[] = $file; - $filesTypes[] = 0; // delete this file first, since it's not used starting from Lucene v2.1 - $filesNumbers[] = 0; - } else if ($file == 'segments') { - // 'segments' file - $filesToDelete[] = $file; - $filesTypes[] = 1; // second file to be deleted "zero" version of segments file (Lucene pre-2.1) - $filesNumbers[] = 0; - } else if (preg_match('/^segments_[a-zA-Z0-9]+$/i', $file)) { - // 'segments_xxx' file - // Check if it's not a just created generation file - if ($file != Zend_Search_Lucene::getSegmentFileName($generation)) { - $filesToDelete[] = $file; - $filesTypes[] = 2; // first group of files for deletions - $filesNumbers[] = (int)base_convert(substr($file, 9), 36, 10); // ordered by segment generation numbers - } - } else if (preg_match('/(^_([a-zA-Z0-9]+))\.f\d+$/i', $file, $matches)) { - // one of per segment files ('<segment_name>.f<decimal_number>') - // Check if it's not one of the segments in the current segments set - if (!isset($segments[$matches[1]])) { - $filesToDelete[] = $file; - $filesTypes[] = 3; // second group of files for deletions - $filesNumbers[] = (int)base_convert($matches[2], 36, 10); // order by segment number - } - } else if (preg_match('/(^_([a-zA-Z0-9]+))(_([a-zA-Z0-9]+))\.del$/i', $file, $matches)) { - // one of per segment files ('<segment_name>_<del_generation>.del' where <segment_name> is '_<segment_number>') - // Check if it's not one of the segments in the current segments set - if (!isset($segments[$matches[1]])) { - $filesToDelete[] = $file; - $filesTypes[] = 3; // second group of files for deletions - $filesNumbers[] = (int)base_convert($matches[2], 36, 10); // order by segment number - } else { - $segmentNumber = (int)base_convert($matches[2], 36, 10); - $delGeneration = (int)base_convert($matches[4], 36, 10); - if (!isset($delFiles[$segmentNumber])) { - $delFiles[$segmentNumber] = array(); - } - $delFiles[$segmentNumber][$delGeneration] = $file; - } - } else if (isset(self::$_indexExtensions[substr($file, strlen($file)-4)])) { - // one of per segment files ('<segment_name>.<ext>') - $segmentName = substr($file, 0, strlen($file) - 4); - // Check if it's not one of the segments in the current segments set - if (!isset($segments[$segmentName]) && - ($this->_currentSegment === null || $this->_currentSegment->getName() != $segmentName)) { - $filesToDelete[] = $file; - $filesTypes[] = 3; // second group of files for deletions - $filesNumbers[] = (int)base_convert(substr($file, 1 /* skip '_' */, strlen($file)-5), 36, 10); // order by segment number - } - } - } - - $maxGenNumber = 0; - // process .del files of currently used segments - foreach ($delFiles as $segmentNumber => $segmentDelFiles) { - ksort($delFiles[$segmentNumber], SORT_NUMERIC); - array_pop($delFiles[$segmentNumber]); // remove last delete file generation from candidates for deleting - - end($delFiles[$segmentNumber]); - $lastGenNumber = key($delFiles[$segmentNumber]); - if ($lastGenNumber > $maxGenNumber) { - $maxGenNumber = $lastGenNumber; - } - } - foreach ($delFiles as $segmentNumber => $segmentDelFiles) { - foreach ($segmentDelFiles as $delGeneration => $file) { - $filesToDelete[] = $file; - $filesTypes[] = 4; // third group of files for deletions - $filesNumbers[] = $segmentNumber*$maxGenNumber + $delGeneration; // order by <segment_number>,<del_generation> pair - } - } - - // Reorder files for deleting - array_multisort($filesTypes, SORT_ASC, SORT_NUMERIC, - $filesNumbers, SORT_ASC, SORT_NUMERIC, - $filesToDelete, SORT_ASC, SORT_STRING); - - foreach ($filesToDelete as $file) { - try { - /** Skip shared docstore segments deleting */ - /** @todo Process '.cfx' files to check if them are already unused */ - if (substr($file, strlen($file)-4) != '.cfx') { - $this->_directory->deleteFile($file); - } - } catch (Zend_Search_Lucene_Exception $e) { - if (strpos($e->getMessage(), 'Can\'t delete file') === false) { - // That's not "file is under processing or already deleted" exception - // Pass it through - throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e); - } - } - } - - // Return read lock into the previous state - Zend_Search_Lucene_LockManager::deEscalateReadLock($this->_directory); - } else { - // Only release resources if another index reader is running now - foreach ($this->_segmentsToDelete as $segName) { - foreach (self::$_indexExtensions as $ext) { - $this->_directory->purgeFile($segName . $ext); - } - } - } - - // Clean-up _segmentsToDelete container - $this->_segmentsToDelete = array(); - - - // Release index write lock - Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory); - - // Remove unused segments from segments list - foreach ($this->_segmentInfos as $segName => $segmentInfo) { - if (!isset($segments[$segName])) { - unset($this->_segmentInfos[$segName]); - } - } - } - - /** - * Commit current changes - */ - public function commit() - { - if ($this->_currentSegment !== null) { - $newSegment = $this->_currentSegment->close(); - if ($newSegment !== null) { - $this->_newSegments[$newSegment->getName()] = $newSegment; - } - $this->_currentSegment = null; - } - - $this->_updateSegments(); - } - - - /** - * Merges the provided indexes into this index. - * - * @param array $readers - * @return void - */ - public function addIndexes($readers) - { - /** - * @todo implementation - */ - } - - /** - * Merges all segments together into new one - * - * Returns true on success and false if another optimization or auto-optimization process - * is running now - * - * @return boolean - */ - public function optimize() - { - if (Zend_Search_Lucene_LockManager::obtainOptimizationLock($this->_directory) === false) { - return false; - } - - // Update segments list to be sure all segments are not merged yet by another process - // - // Segment merging functionality is concentrated in this class and surrounded - // by optimization lock obtaining/releasing. - // _updateSegments() refreshes segments list from the latest index generation. - // So only new segments can be added to the index while we are merging some already existing - // segments. - // Newly added segments will be also included into the index by the _updateSegments() call - // either by another process or by the current process with the commit() call at the end of _mergeSegments() method. - // That's guaranteed by the serialisation of _updateSegments() execution using exclusive locks. - $this->_updateSegments(); - - $this->_mergeSegments($this->_segmentInfos); - - Zend_Search_Lucene_LockManager::releaseOptimizationLock($this->_directory); - - return true; - } - - /** - * Get name for new segment - * - * @return string - */ - private function _newSegmentName() - { - Zend_Search_Lucene_LockManager::obtainWriteLock($this->_directory); - - $generation = Zend_Search_Lucene::getActualGeneration($this->_directory); - $segmentsFile = $this->_directory->getFileObject(Zend_Search_Lucene::getSegmentFileName($generation), false); - - $segmentsFile->seek(12); // 12 = 4 (int, file format marker) + 8 (long, index version) - $segmentNameCounter = $segmentsFile->readInt(); - - $segmentsFile->seek(12); // 12 = 4 (int, file format marker) + 8 (long, index version) - $segmentsFile->writeInt($segmentNameCounter + 1); - - // Flash output to guarantee that wrong value will not be loaded between unlock and - // return (which calls $segmentsFile destructor) - $segmentsFile->flush(); - - Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory); - - return '_' . base_convert($segmentNameCounter, 10, 36); - } - -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Interface.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Interface.php deleted file mode 100755 index 8a441fbc6dbba63e60afbe4c25c280e226de9c1e..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Interface.php +++ /dev/null @@ -1,417 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Index_TermsStream_Interface */ -// require_once 'Zend/Search/Lucene/Index/TermsStream/Interface.php'; - - -/** Classes used within Zend_Search_Lucene_Interface API */ - -/** Zend_Search_Lucene_Document */ -// require_once 'Zend/Search/Lucene/Document.php'; - -/** Zend_Search_Lucene_Index_Term */ -// require_once 'Zend/Search/Lucene/Index/Term.php'; - -/** Zend_Search_Lucene_Index_DocsFilter */ -// require_once 'Zend/Search/Lucene/Index/DocsFilter.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -interface Zend_Search_Lucene_Interface extends Zend_Search_Lucene_Index_TermsStream_Interface -{ - /** - * Get current generation number - * - * Returns generation number - * 0 means pre-2.1 index format - * -1 means there are no segments files. - * - * @param Zend_Search_Lucene_Storage_Directory $directory - * @return integer - * @throws Zend_Search_Lucene_Exception - */ - public static function getActualGeneration(Zend_Search_Lucene_Storage_Directory $directory); - - /** - * Get segments file name - * - * @param integer $generation - * @return string - */ - public static function getSegmentFileName($generation); - - /** - * Get index format version - * - * @return integer - */ - public function getFormatVersion(); - - /** - * Set index format version. - * Index is converted to this format at the nearest upfdate time - * - * @param int $formatVersion - * @throws Zend_Search_Lucene_Exception - */ - public function setFormatVersion($formatVersion); - - /** - * Returns the Zend_Search_Lucene_Storage_Directory instance for this index. - * - * @return Zend_Search_Lucene_Storage_Directory - */ - public function getDirectory(); - - /** - * Returns the total number of documents in this index (including deleted documents). - * - * @return integer - */ - public function count(); - - /** - * Returns one greater than the largest possible document number. - * This may be used to, e.g., determine how big to allocate a structure which will have - * an element for every document number in an index. - * - * @return integer - */ - public function maxDoc(); - - /** - * Returns the total number of non-deleted documents in this index. - * - * @return integer - */ - public function numDocs(); - - /** - * Checks, that document is deleted - * - * @param integer $id - * @return boolean - * @throws Zend_Search_Lucene_Exception Exception is thrown if $id is out of the range - */ - public function isDeleted($id); - - /** - * Set default search field. - * - * Null means, that search is performed through all fields by default - * - * Default value is null - * - * @param string $fieldName - */ - public static function setDefaultSearchField($fieldName); - - /** - * Get default search field. - * - * Null means, that search is performed through all fields by default - * - * @return string - */ - public static function getDefaultSearchField(); - - /** - * Set result set limit. - * - * 0 (default) means no limit - * - * @param integer $limit - */ - public static function setResultSetLimit($limit); - - /** - * Set result set limit. - * - * 0 means no limit - * - * @return integer - */ - public static function getResultSetLimit(); - - /** - * Retrieve index maxBufferedDocs option - * - * maxBufferedDocs is a minimal number of documents required before - * the buffered in-memory documents are written into a new Segment - * - * Default value is 10 - * - * @return integer - */ - public function getMaxBufferedDocs(); - - /** - * Set index maxBufferedDocs option - * - * maxBufferedDocs is a minimal number of documents required before - * the buffered in-memory documents are written into a new Segment - * - * Default value is 10 - * - * @param integer $maxBufferedDocs - */ - public function setMaxBufferedDocs($maxBufferedDocs); - - /** - * Retrieve index maxMergeDocs option - * - * maxMergeDocs is a largest number of documents ever merged by addDocument(). - * Small values (e.g., less than 10,000) are best for interactive indexing, - * as this limits the length of pauses while indexing to a few seconds. - * Larger values are best for batched indexing and speedier searches. - * - * Default value is PHP_INT_MAX - * - * @return integer - */ - public function getMaxMergeDocs(); - - /** - * Set index maxMergeDocs option - * - * maxMergeDocs is a largest number of documents ever merged by addDocument(). - * Small values (e.g., less than 10,000) are best for interactive indexing, - * as this limits the length of pauses while indexing to a few seconds. - * Larger values are best for batched indexing and speedier searches. - * - * Default value is PHP_INT_MAX - * - * @param integer $maxMergeDocs - */ - public function setMaxMergeDocs($maxMergeDocs); - - /** - * Retrieve index mergeFactor option - * - * mergeFactor determines how often segment indices are merged by addDocument(). - * With smaller values, less RAM is used while indexing, - * and searches on unoptimized indices are faster, - * but indexing speed is slower. - * With larger values, more RAM is used during indexing, - * and while searches on unoptimized indices are slower, - * indexing is faster. - * Thus larger values (> 10) are best for batch index creation, - * and smaller values (< 10) for indices that are interactively maintained. - * - * Default value is 10 - * - * @return integer - */ - public function getMergeFactor(); - - /** - * Set index mergeFactor option - * - * mergeFactor determines how often segment indices are merged by addDocument(). - * With smaller values, less RAM is used while indexing, - * and searches on unoptimized indices are faster, - * but indexing speed is slower. - * With larger values, more RAM is used during indexing, - * and while searches on unoptimized indices are slower, - * indexing is faster. - * Thus larger values (> 10) are best for batch index creation, - * and smaller values (< 10) for indices that are interactively maintained. - * - * Default value is 10 - * - * @param integer $maxMergeDocs - */ - public function setMergeFactor($mergeFactor); - - /** - * Performs a query against the index and returns an array - * of Zend_Search_Lucene_Search_QueryHit objects. - * Input is a string or Zend_Search_Lucene_Search_Query. - * - * @param mixed $query - * @return array Zend_Search_Lucene_Search_QueryHit - * @throws Zend_Search_Lucene_Exception - */ - public function find($query); - - /** - * Returns a list of all unique field names that exist in this index. - * - * @param boolean $indexed - * @return array - */ - public function getFieldNames($indexed = false); - - /** - * Returns a Zend_Search_Lucene_Document object for the document - * number $id in this index. - * - * @param integer|Zend_Search_Lucene_Search_QueryHit $id - * @return Zend_Search_Lucene_Document - */ - public function getDocument($id); - - /** - * Returns true if index contain documents with specified term. - * - * Is used for query optimization. - * - * @param Zend_Search_Lucene_Index_Term $term - * @return boolean - */ - public function hasTerm(Zend_Search_Lucene_Index_Term $term); - - /** - * Returns IDs of all the documents containing term. - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return array - */ - public function termDocs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null); - - /** - * Returns documents filter for all documents containing term. - * - * It performs the same operation as termDocs, but return result as - * Zend_Search_Lucene_Index_DocsFilter object - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return Zend_Search_Lucene_Index_DocsFilter - */ - public function termDocsFilter(Zend_Search_Lucene_Index_Term $term, $docsFilter = null); - - /** - * Returns an array of all term freqs. - * Return array structure: array( docId => freq, ...) - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return integer - */ - public function termFreqs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null); - - /** - * Returns an array of all term positions in the documents. - * Return array structure: array( docId => array( pos1, pos2, ...), ...) - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return array - */ - public function termPositions(Zend_Search_Lucene_Index_Term $term, $docsFilter = null); - - /** - * Returns the number of documents in this index containing the $term. - * - * @param Zend_Search_Lucene_Index_Term $term - * @return integer - */ - public function docFreq(Zend_Search_Lucene_Index_Term $term); - - /** - * Retrive similarity used by index reader - * - * @return Zend_Search_Lucene_Search_Similarity - */ - public function getSimilarity(); - - /** - * Returns a normalization factor for "field, document" pair. - * - * @param integer $id - * @param string $fieldName - * @return float - */ - public function norm($id, $fieldName); - - /** - * Returns true if any documents have been deleted from this index. - * - * @return boolean - */ - public function hasDeletions(); - - /** - * Deletes a document from the index. - * $id is an internal document id - * - * @param integer|Zend_Search_Lucene_Search_QueryHit $id - * @throws Zend_Search_Lucene_Exception - */ - public function delete($id); - - /** - * Adds a document to this index. - * - * @param Zend_Search_Lucene_Document $document - */ - public function addDocument(Zend_Search_Lucene_Document $document); - - /** - * Commit changes resulting from delete() or undeleteAll() operations. - */ - public function commit(); - - /** - * Optimize index. - * - * Merges all segments into one - */ - public function optimize(); - - /** - * Returns an array of all terms in this index. - * - * @return array - */ - public function terms(); - - /** - * Undeletes all documents currently marked as deleted in this index. - */ - public function undeleteAll(); - - - /** - * Add reference to the index object - * - * @internal - */ - public function addReference(); - - /** - * Remove reference from the index object - * - * When reference count becomes zero, index is closed and resources are cleaned up - * - * @internal - */ - public function removeReference(); -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Interface/MultiSearcher.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Interface/MultiSearcher.php deleted file mode 100755 index 62693fd7dea56b2d8926b815bfe9775e48040683..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Interface/MultiSearcher.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MultiSearcher.php 24593 2012-01-05 20:35:02Z matthew $ - */ - - -/** Zend_Search_Lucene_MultiSearcher */ -// require_once 'Zend/Search/Lucene/MultiSearcher.php'; - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/LockManager.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/LockManager.php deleted file mode 100755 index f4d3760fc0f9a1624b11b42738c86e0b5ffc5ac0..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/LockManager.php +++ /dev/null @@ -1,236 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_Storage_Directory */ -// require_once 'Zend/Search/Lucene/Storage/Directory.php'; - -/** Zend_Search_Lucene_Storage_File */ -// require_once 'Zend/Search/Lucene/Storage/File.php'; - -/** - * This is an utility class which provides index locks processing functionality - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_LockManager -{ - /** - * consts for name of file to show lock status - */ - const WRITE_LOCK_FILE = 'write.lock.file'; - const READ_LOCK_FILE = 'read.lock.file'; - const READ_LOCK_PROCESSING_LOCK_FILE = 'read-lock-processing.lock.file'; - const OPTIMIZATION_LOCK_FILE = 'optimization.lock.file'; - - /** - * Obtain exclusive write lock on the index - * - * @param Zend_Search_Lucene_Storage_Directory $lockDirectory - * @return Zend_Search_Lucene_Storage_File - * @throws Zend_Search_Lucene_Exception - */ - public static function obtainWriteLock(Zend_Search_Lucene_Storage_Directory $lockDirectory) - { - $lock = $lockDirectory->createFile(self::WRITE_LOCK_FILE); - if (!$lock->lock(LOCK_EX)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Can\'t obtain exclusive index lock'); - } - return $lock; - } - - /** - * Release exclusive write lock - * - * @param Zend_Search_Lucene_Storage_Directory $lockDirectory - */ - public static function releaseWriteLock(Zend_Search_Lucene_Storage_Directory $lockDirectory) - { - $lock = $lockDirectory->getFileObject(self::WRITE_LOCK_FILE); - $lock->unlock(); - } - - /** - * Obtain the exclusive "read escalation/de-escalation" lock - * - * Required to protect the escalate/de-escalate read lock process - * on GFS (and potentially other) mounted filesystems. - * - * Why we need this: - * While GFS supports cluster-wide locking via flock(), it's - * implementation isn't quite what it should be. The locking - * semantics that work consistently on a local filesystem tend to - * fail on GFS mounted filesystems. This appears to be a design defect - * in the implementation of GFS. How this manifests itself is that - * conditional promotion of a shared lock to exclusive will always - * fail, lock release requests are honored but not immediately - * processed (causing erratic failures of subsequent conditional - * requests) and the releasing of the exclusive lock before the - * shared lock is set when a lock is demoted (which can open a window - * of opportunity for another process to gain an exclusive lock when - * it shoudln't be allowed to). - * - * @param Zend_Search_Lucene_Storage_Directory $lockDirectory - * @return Zend_Search_Lucene_Storage_File - * @throws Zend_Search_Lucene_Exception - */ - private static function _startReadLockProcessing(Zend_Search_Lucene_Storage_Directory $lockDirectory) - { - $lock = $lockDirectory->createFile(self::READ_LOCK_PROCESSING_LOCK_FILE); - if (!$lock->lock(LOCK_EX)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Can\'t obtain exclusive lock for the read lock processing file'); - } - return $lock; - } - - /** - * Release the exclusive "read escalation/de-escalation" lock - * - * Required to protect the escalate/de-escalate read lock process - * on GFS (and potentially other) mounted filesystems. - * - * @param Zend_Search_Lucene_Storage_Directory $lockDirectory - */ - private static function _stopReadLockProcessing(Zend_Search_Lucene_Storage_Directory $lockDirectory) - { - $lock = $lockDirectory->getFileObject(self::READ_LOCK_PROCESSING_LOCK_FILE); - $lock->unlock(); - } - - - /** - * Obtain shared read lock on the index - * - * It doesn't block other read or update processes, but prevent index from the premature cleaning-up - * - * @param Zend_Search_Lucene_Storage_Directory $defaultLockDirectory - * @return Zend_Search_Lucene_Storage_File - * @throws Zend_Search_Lucene_Exception - */ - public static function obtainReadLock(Zend_Search_Lucene_Storage_Directory $lockDirectory) - { - $lock = $lockDirectory->createFile(self::READ_LOCK_FILE); - if (!$lock->lock(LOCK_SH)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Can\'t obtain shared reading index lock'); - } - return $lock; - } - - /** - * Release shared read lock - * - * @param Zend_Search_Lucene_Storage_Directory $lockDirectory - */ - public static function releaseReadLock(Zend_Search_Lucene_Storage_Directory $lockDirectory) - { - $lock = $lockDirectory->getFileObject(self::READ_LOCK_FILE); - $lock->unlock(); - } - - /** - * Escalate Read lock to exclusive level - * - * @param Zend_Search_Lucene_Storage_Directory $lockDirectory - * @return boolean - */ - public static function escalateReadLock(Zend_Search_Lucene_Storage_Directory $lockDirectory) - { - self::_startReadLockProcessing($lockDirectory); - - $lock = $lockDirectory->getFileObject(self::READ_LOCK_FILE); - - // First, release the shared lock for the benefit of GFS since - // it will fail the conditional request to promote the lock to - // "exclusive" while the shared lock is held (even when we are - // the only holder). - $lock->unlock(); - - // GFS is really poor. While the above "unlock" returns, GFS - // doesn't clean up it's tables right away (which will potentially - // cause the conditional locking for the "exclusive" lock to fail. - // We will retry the conditional lock request several times on a - // failure to get past this. The performance hit is negligible - // in the grand scheme of things and only will occur with GFS - // filesystems or if another local process has the shared lock - // on local filesystems. - for ($retries = 0; $retries < 10; $retries++) { - if ($lock->lock(LOCK_EX, true)) { - // Exclusive lock is obtained! - self::_stopReadLockProcessing($lockDirectory); - return true; - } - - // wait 1 microsecond - usleep(1); - } - - // Restore lock state - $lock->lock(LOCK_SH); - - self::_stopReadLockProcessing($lockDirectory); - return false; - } - - /** - * De-escalate Read lock to shared level - * - * @param Zend_Search_Lucene_Storage_Directory $lockDirectory - */ - public static function deEscalateReadLock(Zend_Search_Lucene_Storage_Directory $lockDirectory) - { - $lock = $lockDirectory->getFileObject(self::READ_LOCK_FILE); - $lock->lock(LOCK_SH); - } - - /** - * Obtain exclusive optimization lock on the index - * - * Returns lock object on success and false otherwise (doesn't block execution) - * - * @param Zend_Search_Lucene_Storage_Directory $lockDirectory - * @return mixed - */ - public static function obtainOptimizationLock(Zend_Search_Lucene_Storage_Directory $lockDirectory) - { - $lock = $lockDirectory->createFile(self::OPTIMIZATION_LOCK_FILE); - if (!$lock->lock(LOCK_EX, true)) { - return false; - } - return $lock; - } - - /** - * Release exclusive optimization lock - * - * @param Zend_Search_Lucene_Storage_Directory $lockDirectory - */ - public static function releaseOptimizationLock(Zend_Search_Lucene_Storage_Directory $lockDirectory) - { - $lock = $lockDirectory->getFileObject(self::OPTIMIZATION_LOCK_FILE); - $lock->unlock(); - } - -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/MultiSearcher.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/MultiSearcher.php deleted file mode 100755 index 3486456999f52e4ddf4e3964a85174d9eee57358..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/MultiSearcher.php +++ /dev/null @@ -1,992 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Interface */ -// require_once 'Zend/Search/Lucene/Interface.php'; - -/** - * Import Zend_Search_Lucene_Interface_MultiSearcher for BC (see ZF-12067) - * @see Zend_Search_Lucene_Interface_MultiSearcher - */ -// require_once 'Zend/Search/Lucene/Interface/MultiSearcher.php'; - -/** - * Multisearcher allows to search through several independent indexes. - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_MultiSearcher implements Zend_Search_Lucene_Interface -{ - /** - * List of indices for searching. - * Array of Zend_Search_Lucene_Interface objects - * - * @var array - */ - protected $_indices; - - /** - * Object constructor. - * - * @param array $indices Arrays of indices for search - * @throws Zend_Search_Lucene_Exception - */ - public function __construct($indices = array()) - { - $this->_indices = $indices; - - foreach ($this->_indices as $index) { - if (!$index instanceof Zend_Search_Lucene_Interface) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('sub-index objects have to implement Zend_Search_Lucene_Interface.'); - } - } - } - - /** - * Add index for searching. - * - * @param Zend_Search_Lucene_Interface $index - */ - public function addIndex(Zend_Search_Lucene_Interface $index) - { - $this->_indices[] = $index; - } - - - /** - * Get current generation number - * - * Returns generation number - * 0 means pre-2.1 index format - * -1 means there are no segments files. - * - * @param Zend_Search_Lucene_Storage_Directory $directory - * @return integer - * @throws Zend_Search_Lucene_Exception - */ - public static function getActualGeneration(Zend_Search_Lucene_Storage_Directory $directory) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception("Generation number can't be retrieved for multi-searcher"); - } - - /** - * Get segments file name - * - * @param integer $generation - * @return string - */ - public static function getSegmentFileName($generation) - { - return Zend_Search_Lucene::getSegmentFileName($generation); - } - - /** - * Get index format version - * - * @return integer - * @throws Zend_Search_Lucene_Exception - */ - public function getFormatVersion() - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception("Format version can't be retrieved for multi-searcher"); - } - - /** - * Set index format version. - * Index is converted to this format at the nearest upfdate time - * - * @param int $formatVersion - */ - public function setFormatVersion($formatVersion) - { - foreach ($this->_indices as $index) { - $index->setFormatVersion($formatVersion); - } - } - - /** - * Returns the Zend_Search_Lucene_Storage_Directory instance for this index. - * - * @return Zend_Search_Lucene_Storage_Directory - */ - public function getDirectory() - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception("Index directory can't be retrieved for multi-searcher"); - } - - /** - * Returns the total number of documents in this index (including deleted documents). - * - * @return integer - */ - public function count() - { - $count = 0; - - foreach ($this->_indices as $index) { - $count += $index->count(); - } - - return $count; - } - - /** - * Returns one greater than the largest possible document number. - * This may be used to, e.g., determine how big to allocate a structure which will have - * an element for every document number in an index. - * - * @return integer - */ - public function maxDoc() - { - return $this->count(); - } - - /** - * Returns the total number of non-deleted documents in this index. - * - * @return integer - */ - public function numDocs() - { - $docs = 0; - - foreach ($this->_indices as $index) { - $docs += $index->numDocs(); - } - - return $docs; - } - - /** - * Checks, that document is deleted - * - * @param integer $id - * @return boolean - * @throws Zend_Search_Lucene_Exception Exception is thrown if $id is out of the range - */ - public function isDeleted($id) - { - foreach ($this->_indices as $index) { - $indexCount = $index->count(); - - if ($indexCount > $id) { - return $index->isDeleted($id); - } - - $id -= $indexCount; - } - - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Document id is out of the range.'); - } - - /** - * Set default search field. - * - * Null means, that search is performed through all fields by default - * - * Default value is null - * - * @param string $fieldName - */ - public static function setDefaultSearchField($fieldName) - { - foreach ($this->_indices as $index) { - $index->setDefaultSearchField($fieldName); - } - } - - - /** - * Get default search field. - * - * Null means, that search is performed through all fields by default - * - * @return string - * @throws Zend_Search_Lucene_Exception - */ - public static function getDefaultSearchField() - { - if (count($this->_indices) == 0) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Indices list is empty'); - } - - $defaultSearchField = reset($this->_indices)->getDefaultSearchField(); - - foreach ($this->_indices as $index) { - if ($index->getDefaultSearchField() !== $defaultSearchField) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Indices have different default search field.'); - } - } - - return $defaultSearchField; - } - - /** - * Set result set limit. - * - * 0 (default) means no limit - * - * @param integer $limit - */ - public static function setResultSetLimit($limit) - { - foreach ($this->_indices as $index) { - $index->setResultSetLimit($limit); - } - } - - /** - * Set result set limit. - * - * 0 means no limit - * - * @return integer - * @throws Zend_Search_Lucene_Exception - */ - public static function getResultSetLimit() - { - if (count($this->_indices) == 0) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Indices list is empty'); - } - - $defaultResultSetLimit = reset($this->_indices)->getResultSetLimit(); - - foreach ($this->_indices as $index) { - if ($index->getResultSetLimit() !== $defaultResultSetLimit) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Indices have different default search field.'); - } - } - - return $defaultResultSetLimit; - } - - /** - * Retrieve index maxBufferedDocs option - * - * maxBufferedDocs is a minimal number of documents required before - * the buffered in-memory documents are written into a new Segment - * - * Default value is 10 - * - * @return integer - * @throws Zend_Search_Lucene_Exception - */ - public function getMaxBufferedDocs() - { - if (count($this->_indices) == 0) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Indices list is empty'); - } - - $maxBufferedDocs = reset($this->_indices)->getMaxBufferedDocs(); - - foreach ($this->_indices as $index) { - if ($index->getMaxBufferedDocs() !== $maxBufferedDocs) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Indices have different default search field.'); - } - } - - return $maxBufferedDocs; - } - - /** - * Set index maxBufferedDocs option - * - * maxBufferedDocs is a minimal number of documents required before - * the buffered in-memory documents are written into a new Segment - * - * Default value is 10 - * - * @param integer $maxBufferedDocs - */ - public function setMaxBufferedDocs($maxBufferedDocs) - { - foreach ($this->_indices as $index) { - $index->setMaxBufferedDocs($maxBufferedDocs); - } - } - - /** - * Retrieve index maxMergeDocs option - * - * maxMergeDocs is a largest number of documents ever merged by addDocument(). - * Small values (e.g., less than 10,000) are best for interactive indexing, - * as this limits the length of pauses while indexing to a few seconds. - * Larger values are best for batched indexing and speedier searches. - * - * Default value is PHP_INT_MAX - * - * @return integer - * @throws Zend_Search_Lucene_Exception - */ - public function getMaxMergeDocs() - { - if (count($this->_indices) == 0) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Indices list is empty'); - } - - $maxMergeDocs = reset($this->_indices)->getMaxMergeDocs(); - - foreach ($this->_indices as $index) { - if ($index->getMaxMergeDocs() !== $maxMergeDocs) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Indices have different default search field.'); - } - } - - return $maxMergeDocs; - } - - /** - * Set index maxMergeDocs option - * - * maxMergeDocs is a largest number of documents ever merged by addDocument(). - * Small values (e.g., less than 10,000) are best for interactive indexing, - * as this limits the length of pauses while indexing to a few seconds. - * Larger values are best for batched indexing and speedier searches. - * - * Default value is PHP_INT_MAX - * - * @param integer $maxMergeDocs - */ - public function setMaxMergeDocs($maxMergeDocs) - { - foreach ($this->_indices as $index) { - $index->setMaxMergeDocs($maxMergeDocs); - } - } - - /** - * Retrieve index mergeFactor option - * - * mergeFactor determines how often segment indices are merged by addDocument(). - * With smaller values, less RAM is used while indexing, - * and searches on unoptimized indices are faster, - * but indexing speed is slower. - * With larger values, more RAM is used during indexing, - * and while searches on unoptimized indices are slower, - * indexing is faster. - * Thus larger values (> 10) are best for batch index creation, - * and smaller values (< 10) for indices that are interactively maintained. - * - * Default value is 10 - * - * @return integer - * @throws Zend_Search_Lucene_Exception - */ - public function getMergeFactor() - { - if (count($this->_indices) == 0) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Indices list is empty'); - } - - $mergeFactor = reset($this->_indices)->getMergeFactor(); - - foreach ($this->_indices as $index) { - if ($index->getMergeFactor() !== $mergeFactor) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Indices have different default search field.'); - } - } - - return $mergeFactor; - } - - /** - * Set index mergeFactor option - * - * mergeFactor determines how often segment indices are merged by addDocument(). - * With smaller values, less RAM is used while indexing, - * and searches on unoptimized indices are faster, - * but indexing speed is slower. - * With larger values, more RAM is used during indexing, - * and while searches on unoptimized indices are slower, - * indexing is faster. - * Thus larger values (> 10) are best for batch index creation, - * and smaller values (< 10) for indices that are interactively maintained. - * - * Default value is 10 - * - * @param integer $maxMergeDocs - */ - public function setMergeFactor($mergeFactor) - { - foreach ($this->_indices as $index) { - $index->setMaxMergeDocs($mergeFactor); - } - } - - /** - * Performs a query against the index and returns an array - * of Zend_Search_Lucene_Search_QueryHit objects. - * Input is a string or Zend_Search_Lucene_Search_Query. - * - * @param mixed $query - * @return array Zend_Search_Lucene_Search_QueryHit - * @throws Zend_Search_Lucene_Exception - */ - public function find($query) - { - if (count($this->_indices) == 0) { - return array(); - } - - $hitsList = array(); - - $indexShift = 0; - foreach ($this->_indices as $index) { - $hits = $index->find($query); - - if ($indexShift != 0) { - foreach ($hits as $hit) { - $hit->id += $indexShift; - } - } - - $indexShift += $index->count(); - $hitsList[] = $hits; - } - - /** @todo Implement advanced sorting */ - - return call_user_func_array('array_merge', $hitsList); - } - - /** - * Returns a list of all unique field names that exist in this index. - * - * @param boolean $indexed - * @return array - */ - public function getFieldNames($indexed = false) - { - $fieldNamesList = array(); - - foreach ($this->_indices as $index) { - $fieldNamesList[] = $index->getFieldNames($indexed); - } - - return array_unique(call_user_func_array('array_merge', $fieldNamesList)); - } - - /** - * Returns a Zend_Search_Lucene_Document object for the document - * number $id in this index. - * - * @param integer|Zend_Search_Lucene_Search_QueryHit $id - * @return Zend_Search_Lucene_Document - * @throws Zend_Search_Lucene_Exception Exception is thrown if $id is out of the range - */ - public function getDocument($id) - { - if ($id instanceof Zend_Search_Lucene_Search_QueryHit) { - /* @var $id Zend_Search_Lucene_Search_QueryHit */ - $id = $id->id; - } - - foreach ($this->_indices as $index) { - $indexCount = $index->count(); - - if ($indexCount > $id) { - return $index->getDocument($id); - } - - $id -= $indexCount; - } - - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Document id is out of the range.'); - } - - /** - * Returns true if index contain documents with specified term. - * - * Is used for query optimization. - * - * @param Zend_Search_Lucene_Index_Term $term - * @return boolean - */ - public function hasTerm(Zend_Search_Lucene_Index_Term $term) - { - foreach ($this->_indices as $index) { - if ($index->hasTerm($term)) { - return true; - } - } - - return false; - } - - /** - * Returns IDs of all the documents containing term. - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return array - * @throws Zend_Search_Lucene_Exception - */ - public function termDocs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null) - { - if ($docsFilter != null) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Document filters could not used with multi-searcher'); - } - - $docsList = array(); - - $indexShift = 0; - foreach ($this->_indices as $index) { - $docs = $index->termDocs($term); - - if ($indexShift != 0) { - foreach ($docs as $id => $docId) { - $docs[$id] += $indexShift; - } - } - - $indexShift += $index->count(); - $docsList[] = $docs; - } - - return call_user_func_array('array_merge', $docsList); - } - - /** - * Returns documents filter for all documents containing term. - * - * It performs the same operation as termDocs, but return result as - * Zend_Search_Lucene_Index_DocsFilter object - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return Zend_Search_Lucene_Index_DocsFilter - * @throws Zend_Search_Lucene_Exception - */ - public function termDocsFilter(Zend_Search_Lucene_Index_Term $term, $docsFilter = null) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Document filters could not used with multi-searcher'); - } - - /** - * Returns an array of all term freqs. - * Return array structure: array( docId => freq, ...) - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return integer - * @throws Zend_Search_Lucene_Exception - */ - public function termFreqs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null) - { - if ($docsFilter != null) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Document filters could not used with multi-searcher'); - } - - $freqsList = array(); - - $indexShift = 0; - foreach ($this->_indices as $index) { - $freqs = $index->termFreqs($term); - - if ($indexShift != 0) { - $freqsShifted = array(); - - foreach ($freqs as $docId => $freq) { - $freqsShifted[$docId + $indexShift] = $freq; - } - $freqs = $freqsShifted; - } - - $indexShift += $index->count(); - $freqsList[] = $freqs; - } - - return call_user_func_array('array_merge', $freqsList); - } - - /** - * Returns an array of all term positions in the documents. - * Return array structure: array( docId => array( pos1, pos2, ...), ...) - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return array - * @throws Zend_Search_Lucene_Exception - */ - public function termPositions(Zend_Search_Lucene_Index_Term $term, $docsFilter = null) - { - if ($docsFilter != null) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Document filters could not used with multi-searcher'); - } - - $termPositionsList = array(); - - $indexShift = 0; - foreach ($this->_indices as $index) { - $termPositions = $index->termPositions($term); - - if ($indexShift != 0) { - $termPositionsShifted = array(); - - foreach ($termPositions as $docId => $positions) { - $termPositions[$docId + $indexShift] = $positions; - } - $termPositions = $termPositionsShifted; - } - - $indexShift += $index->count(); - $termPositionsList[] = $termPositions; - } - - return call_user_func_array('array_merge', $termPositions); - } - - /** - * Returns the number of documents in this index containing the $term. - * - * @param Zend_Search_Lucene_Index_Term $term - * @return integer - */ - public function docFreq(Zend_Search_Lucene_Index_Term $term) - { - $docFreq = 0; - - foreach ($this->_indices as $index) { - $docFreq += $index->docFreq($term); - } - - return $docFreq; - } - - /** - * Retrive similarity used by index reader - * - * @return Zend_Search_Lucene_Search_Similarity - * @throws Zend_Search_Lucene_Exception - */ - public function getSimilarity() - { - if (count($this->_indices) == 0) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Indices list is empty'); - } - - $similarity = reset($this->_indices)->getSimilarity(); - - foreach ($this->_indices as $index) { - if ($index->getSimilarity() !== $similarity) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Indices have different similarity.'); - } - } - - return $similarity; - } - - /** - * Returns a normalization factor for "field, document" pair. - * - * @param integer $id - * @param string $fieldName - * @return float - */ - public function norm($id, $fieldName) - { - foreach ($this->_indices as $index) { - $indexCount = $index->count(); - - if ($indexCount > $id) { - return $index->norm($id, $fieldName); - } - - $id -= $indexCount; - } - - return null; - } - - /** - * Returns true if any documents have been deleted from this index. - * - * @return boolean - */ - public function hasDeletions() - { - foreach ($this->_indices as $index) { - if ($index->hasDeletions()) { - return true; - } - } - - return false; - } - - /** - * Deletes a document from the index. - * $id is an internal document id - * - * @param integer|Zend_Search_Lucene_Search_QueryHit $id - * @throws Zend_Search_Lucene_Exception - */ - public function delete($id) - { - foreach ($this->_indices as $index) { - $indexCount = $index->count(); - - if ($indexCount > $id) { - $index->delete($id); - return; - } - - $id -= $indexCount; - } - - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Document id is out of the range.'); - } - - - /** - * Callback used to choose target index for new documents - * - * Function/method signature: - * Zend_Search_Lucene_Interface callbackFunction(Zend_Search_Lucene_Document $document, array $indices); - * - * null means "default documents distributing algorithm" - * - * @var callback - */ - protected $_documentDistributorCallBack = null; - - /** - * Set callback for choosing target index. - * - * @param callback $callback - * @throws Zend_Search_Lucene_Exception - */ - public function setDocumentDistributorCallback($callback) - { - if ($callback !== null && !is_callable($callback)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('$callback parameter must be a valid callback.'); - } - - $this->_documentDistributorCallBack = $callback; - } - - /** - * Get callback for choosing target index. - * - * @return callback - */ - public function getDocumentDistributorCallback() - { - return $this->_documentDistributorCallBack; - } - - /** - * Adds a document to this index. - * - * @param Zend_Search_Lucene_Document $document - * @throws Zend_Search_Lucene_Exception - */ - public function addDocument(Zend_Search_Lucene_Document $document) - { - if ($this->_documentDistributorCallBack !== null) { - $index = call_user_func($this->_documentDistributorCallBack, $document, $this->_indices); - } else { - $index = $this->_indices[array_rand($this->_indices)]; - } - - $index->addDocument($document); - } - - /** - * Commit changes resulting from delete() or undeleteAll() operations. - */ - public function commit() - { - foreach ($this->_indices as $index) { - $index->commit(); - } - } - - /** - * Optimize index. - * - * Merges all segments into one - */ - public function optimize() - { - foreach ($this->_indices as $index) { - $index->optimise(); - } - } - - /** - * Returns an array of all terms in this index. - * - * @return array - */ - public function terms() - { - $termsList = array(); - - foreach ($this->_indices as $index) { - $termsList[] = $index->terms(); - } - - return array_unique(call_user_func_array('array_merge', $termsList)); - } - - - /** - * Terms stream priority queue object - * - * @var Zend_Search_Lucene_TermStreamsPriorityQueue - */ - private $_termsStream = null; - - /** - * Reset terms stream. - */ - public function resetTermsStream() - { - if ($this->_termsStream === null) { - /** Zend_Search_Lucene_TermStreamsPriorityQueue */ - // require_once 'Zend/Search/Lucene/TermStreamsPriorityQueue.php'; - - $this->_termsStream = new Zend_Search_Lucene_TermStreamsPriorityQueue($this->_indices); - } else { - $this->_termsStream->resetTermsStream(); - } - } - - /** - * Skip terms stream up to specified term preffix. - * - * Prefix contains fully specified field info and portion of searched term - * - * @param Zend_Search_Lucene_Index_Term $prefix - */ - public function skipTo(Zend_Search_Lucene_Index_Term $prefix) - { - $this->_termsStream->skipTo($prefix); - } - - /** - * Scans terms dictionary and returns next term - * - * @return Zend_Search_Lucene_Index_Term|null - */ - public function nextTerm() - { - return $this->_termsStream->nextTerm(); - } - - /** - * Returns term in current position - * - * @return Zend_Search_Lucene_Index_Term|null - */ - public function currentTerm() - { - return $this->_termsStream->currentTerm(); - } - - /** - * Close terms stream - * - * Should be used for resources clean up if stream is not read up to the end - */ - public function closeTermsStream() - { - $this->_termsStream->closeTermsStream(); - $this->_termsStream = null; - } - - - /** - * Undeletes all documents currently marked as deleted in this index. - */ - public function undeleteAll() - { - foreach ($this->_indices as $index) { - $index->undeleteAll(); - } - } - - - /** - * Add reference to the index object - * - * @internal - */ - public function addReference() - { - // Do nothing, since it's never referenced by indices - } - - /** - * Remove reference from the index object - * - * When reference count becomes zero, index is closed and resources are cleaned up - * - * @internal - */ - public function removeReference() - { - // Do nothing, since it's never referenced by indices - } -} - -/** - * This class is provided for backwards-compatibility (See ZF-12067) - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Interface_MultiSearcher - extends Zend_Search_Lucene_MultiSearcher -{ -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/PriorityQueue.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/PriorityQueue.php deleted file mode 100755 index f34c1cbdaaeeebd6f4dd0c4a8e168bde37b4de96..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/PriorityQueue.php +++ /dev/null @@ -1,171 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * Abstract Priority Queue - * - * It implements a priority queue. - * Please go to "Data Structures and Algorithms", - * Aho, Hopcroft, and Ullman, Addison-Wesley, 1983 (corrected 1987 edition), - * for implementation details. - * - * It provides O(log(N)) time of put/pop operations, where N is a size of queue - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Search_Lucene_PriorityQueue -{ - /** - * Queue heap - * - * Heap contains balanced partial ordered binary tree represented in array - * [0] - top of the tree - * [1] - first child of [0] - * [2] - second child of [0] - * ... - * [2*n + 1] - first child of [n] - * [2*n + 2] - second child of [n] - * - * @var array - */ - private $_heap = array(); - - - /** - * Add element to the queue - * - * O(log(N)) time - * - * @param mixed $element - */ - public function put($element) - { - $nodeId = count($this->_heap); - $parentId = ($nodeId-1) >> 1; // floor( ($nodeId-1)/2 ) - - while ($nodeId != 0 && $this->_less($element, $this->_heap[$parentId])) { - // Move parent node down - $this->_heap[$nodeId] = $this->_heap[$parentId]; - - // Move pointer to the next level of tree - $nodeId = $parentId; - $parentId = ($nodeId-1) >> 1; // floor( ($nodeId-1)/2 ) - } - - // Put new node into the tree - $this->_heap[$nodeId] = $element; - } - - - /** - * Return least element of the queue - * - * Constant time - * - * @return mixed - */ - public function top() - { - if (count($this->_heap) == 0) { - return null; - } - - return $this->_heap[0]; - } - - - /** - * Removes and return least element of the queue - * - * O(log(N)) time - * - * @return mixed - */ - public function pop() - { - if (count($this->_heap) == 0) { - return null; - } - - $top = $this->_heap[0]; - $lastId = count($this->_heap) - 1; - - /** - * Find appropriate position for last node - */ - $nodeId = 0; // Start from a top - $childId = 1; // First child - - // Choose smaller child - if ($lastId > 2 && $this->_less($this->_heap[2], $this->_heap[1])) { - $childId = 2; - } - - while ($childId < $lastId && - $this->_less($this->_heap[$childId], $this->_heap[$lastId]) - ) { - // Move child node up - $this->_heap[$nodeId] = $this->_heap[$childId]; - - $nodeId = $childId; // Go down - $childId = ($nodeId << 1) + 1; // First child - - // Choose smaller child - if (($childId+1) < $lastId && - $this->_less($this->_heap[$childId+1], $this->_heap[$childId]) - ) { - $childId++; - } - } - - // Move last element to the new position - $this->_heap[$nodeId] = $this->_heap[$lastId]; - unset($this->_heap[$lastId]); - - return $top; - } - - - /** - * Clear queue - */ - public function clear() - { - $this->_heap = array(); - } - - - /** - * Compare elements - * - * Returns true, if $el1 is less than $el2; else otherwise - * - * @param mixed $el1 - * @param mixed $el2 - * @return boolean - */ - abstract protected function _less($el1, $el2); -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Proxy.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Proxy.php deleted file mode 100755 index f60f06a75905d02660ca66a82b750fb1a9ce4d45..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Proxy.php +++ /dev/null @@ -1,612 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_Interface */ -// require_once 'Zend/Search/Lucene/Interface.php'; - - -/** - * Proxy class intended to be used in userland. - * - * It tracks, when index object goes out of scope and forces ndex closing - * - * @category Zend - * @package Zend_Search_Lucene - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Proxy implements Zend_Search_Lucene_Interface -{ - /** - * Index object - * - * @var Zend_Search_Lucene_Interface - */ - private $_index; - - /** - * Object constructor - * - * @param Zend_Search_Lucene_Interface $index - */ - public function __construct(Zend_Search_Lucene_Interface $index) - { - $this->_index = $index; - $this->_index->addReference(); - } - - /** - * Object destructor - */ - public function __destruct() - { - if ($this->_index !== null) { - // This code is invoked if Zend_Search_Lucene_Interface object constructor throws an exception - $this->_index->removeReference(); - } - $this->_index = null; - } - - /** - * Get current generation number - * - * Returns generation number - * 0 means pre-2.1 index format - * -1 means there are no segments files. - * - * @param Zend_Search_Lucene_Storage_Directory $directory - * @return integer - * @throws Zend_Search_Lucene_Exception - */ - public static function getActualGeneration(Zend_Search_Lucene_Storage_Directory $directory) - { - Zend_Search_Lucene::getActualGeneration($directory); - } - - /** - * Get segments file name - * - * @param integer $generation - * @return string - */ - public static function getSegmentFileName($generation) - { - Zend_Search_Lucene::getSegmentFileName($generation); - } - - /** - * Get index format version - * - * @return integer - */ - public function getFormatVersion() - { - return $this->_index->getFormatVersion(); - } - - /** - * Set index format version. - * Index is converted to this format at the nearest upfdate time - * - * @param int $formatVersion - * @throws Zend_Search_Lucene_Exception - */ - public function setFormatVersion($formatVersion) - { - $this->_index->setFormatVersion($formatVersion); - } - - /** - * Returns the Zend_Search_Lucene_Storage_Directory instance for this index. - * - * @return Zend_Search_Lucene_Storage_Directory - */ - public function getDirectory() - { - return $this->_index->getDirectory(); - } - - /** - * Returns the total number of documents in this index (including deleted documents). - * - * @return integer - */ - public function count() - { - return $this->_index->count(); - } - - /** - * Returns one greater than the largest possible document number. - * This may be used to, e.g., determine how big to allocate a structure which will have - * an element for every document number in an index. - * - * @return integer - */ - public function maxDoc() - { - return $this->_index->maxDoc(); - } - - /** - * Returns the total number of non-deleted documents in this index. - * - * @return integer - */ - public function numDocs() - { - return $this->_index->numDocs(); - } - - /** - * Checks, that document is deleted - * - * @param integer $id - * @return boolean - * @throws Zend_Search_Lucene_Exception Exception is thrown if $id is out of the range - */ - public function isDeleted($id) - { - return $this->_index->isDeleted($id); - } - - /** - * Set default search field. - * - * Null means, that search is performed through all fields by default - * - * Default value is null - * - * @param string $fieldName - */ - public static function setDefaultSearchField($fieldName) - { - Zend_Search_Lucene::setDefaultSearchField($fieldName); - } - - /** - * Get default search field. - * - * Null means, that search is performed through all fields by default - * - * @return string - */ - public static function getDefaultSearchField() - { - return Zend_Search_Lucene::getDefaultSearchField(); - } - - /** - * Set result set limit. - * - * 0 (default) means no limit - * - * @param integer $limit - */ - public static function setResultSetLimit($limit) - { - Zend_Search_Lucene::setResultSetLimit($limit); - } - - /** - * Set result set limit. - * - * 0 means no limit - * - * @return integer - */ - public static function getResultSetLimit() - { - return Zend_Search_Lucene::getResultSetLimit(); - } - - /** - * Retrieve index maxBufferedDocs option - * - * maxBufferedDocs is a minimal number of documents required before - * the buffered in-memory documents are written into a new Segment - * - * Default value is 10 - * - * @return integer - */ - public function getMaxBufferedDocs() - { - return $this->_index->getMaxBufferedDocs(); - } - - /** - * Set index maxBufferedDocs option - * - * maxBufferedDocs is a minimal number of documents required before - * the buffered in-memory documents are written into a new Segment - * - * Default value is 10 - * - * @param integer $maxBufferedDocs - */ - public function setMaxBufferedDocs($maxBufferedDocs) - { - $this->_index->setMaxBufferedDocs($maxBufferedDocs); - } - - - /** - * Retrieve index maxMergeDocs option - * - * maxMergeDocs is a largest number of documents ever merged by addDocument(). - * Small values (e.g., less than 10,000) are best for interactive indexing, - * as this limits the length of pauses while indexing to a few seconds. - * Larger values are best for batched indexing and speedier searches. - * - * Default value is PHP_INT_MAX - * - * @return integer - */ - public function getMaxMergeDocs() - { - return $this->_index->getMaxMergeDocs(); - } - - /** - * Set index maxMergeDocs option - * - * maxMergeDocs is a largest number of documents ever merged by addDocument(). - * Small values (e.g., less than 10,000) are best for interactive indexing, - * as this limits the length of pauses while indexing to a few seconds. - * Larger values are best for batched indexing and speedier searches. - * - * Default value is PHP_INT_MAX - * - * @param integer $maxMergeDocs - */ - public function setMaxMergeDocs($maxMergeDocs) - { - $this->_index->setMaxMergeDocs($maxMergeDocs); - } - - - /** - * Retrieve index mergeFactor option - * - * mergeFactor determines how often segment indices are merged by addDocument(). - * With smaller values, less RAM is used while indexing, - * and searches on unoptimized indices are faster, - * but indexing speed is slower. - * With larger values, more RAM is used during indexing, - * and while searches on unoptimized indices are slower, - * indexing is faster. - * Thus larger values (> 10) are best for batch index creation, - * and smaller values (< 10) for indices that are interactively maintained. - * - * Default value is 10 - * - * @return integer - */ - public function getMergeFactor() - { - return $this->_index->getMergeFactor(); - } - - /** - * Set index mergeFactor option - * - * mergeFactor determines how often segment indices are merged by addDocument(). - * With smaller values, less RAM is used while indexing, - * and searches on unoptimized indices are faster, - * but indexing speed is slower. - * With larger values, more RAM is used during indexing, - * and while searches on unoptimized indices are slower, - * indexing is faster. - * Thus larger values (> 10) are best for batch index creation, - * and smaller values (< 10) for indices that are interactively maintained. - * - * Default value is 10 - * - * @param integer $maxMergeDocs - */ - public function setMergeFactor($mergeFactor) - { - $this->_index->setMergeFactor($mergeFactor); - } - - /** - * Performs a query against the index and returns an array - * of Zend_Search_Lucene_Search_QueryHit objects. - * Input is a string or Zend_Search_Lucene_Search_Query. - * - * @param mixed $query - * @return array Zend_Search_Lucene_Search_QueryHit - * @throws Zend_Search_Lucene_Exception - */ - public function find($query) - { - // actual parameter list - $parameters = func_get_args(); - - // invoke $this->_index->find() method with specified parameters - return call_user_func_array(array(&$this->_index, 'find'), $parameters); - } - - /** - * Returns a list of all unique field names that exist in this index. - * - * @param boolean $indexed - * @return array - */ - public function getFieldNames($indexed = false) - { - return $this->_index->getFieldNames($indexed); - } - - /** - * Returns a Zend_Search_Lucene_Document object for the document - * number $id in this index. - * - * @param integer|Zend_Search_Lucene_Search_QueryHit $id - * @return Zend_Search_Lucene_Document - */ - public function getDocument($id) - { - return $this->_index->getDocument($id); - } - - /** - * Returns true if index contain documents with specified term. - * - * Is used for query optimization. - * - * @param Zend_Search_Lucene_Index_Term $term - * @return boolean - */ - public function hasTerm(Zend_Search_Lucene_Index_Term $term) - { - return $this->_index->hasTerm($term); - } - - /** - * Returns IDs of all the documents containing term. - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return array - */ - public function termDocs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null) - { - return $this->_index->termDocs($term, $docsFilter); - } - - /** - * Returns documents filter for all documents containing term. - * - * It performs the same operation as termDocs, but return result as - * Zend_Search_Lucene_Index_DocsFilter object - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return Zend_Search_Lucene_Index_DocsFilter - */ - public function termDocsFilter(Zend_Search_Lucene_Index_Term $term, $docsFilter = null) - { - return $this->_index->termDocsFilter($term, $docsFilter); - } - - /** - * Returns an array of all term freqs. - * Return array structure: array( docId => freq, ...) - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return integer - */ - public function termFreqs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null) - { - return $this->_index->termFreqs($term, $docsFilter); - } - - /** - * Returns an array of all term positions in the documents. - * Return array structure: array( docId => array( pos1, pos2, ...), ...) - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @return array - */ - public function termPositions(Zend_Search_Lucene_Index_Term $term, $docsFilter = null) - { - return $this->_index->termPositions($term, $docsFilter); - } - - /** - * Returns the number of documents in this index containing the $term. - * - * @param Zend_Search_Lucene_Index_Term $term - * @return integer - */ - public function docFreq(Zend_Search_Lucene_Index_Term $term) - { - return $this->_index->docFreq($term); - } - - /** - * Retrive similarity used by index reader - * - * @return Zend_Search_Lucene_Search_Similarity - */ - public function getSimilarity() - { - return $this->_index->getSimilarity(); - } - - /** - * Returns a normalization factor for "field, document" pair. - * - * @param integer $id - * @param string $fieldName - * @return float - */ - public function norm($id, $fieldName) - { - return $this->_index->norm($id, $fieldName); - } - - /** - * Returns true if any documents have been deleted from this index. - * - * @return boolean - */ - public function hasDeletions() - { - return $this->_index->hasDeletions(); - } - - /** - * Deletes a document from the index. - * $id is an internal document id - * - * @param integer|Zend_Search_Lucene_Search_QueryHit $id - * @throws Zend_Search_Lucene_Exception - */ - public function delete($id) - { - return $this->_index->delete($id); - } - - /** - * Adds a document to this index. - * - * @param Zend_Search_Lucene_Document $document - */ - public function addDocument(Zend_Search_Lucene_Document $document) - { - $this->_index->addDocument($document); - } - - /** - * Commit changes resulting from delete() or undeleteAll() operations. - */ - public function commit() - { - $this->_index->commit(); - } - - /** - * Optimize index. - * - * Merges all segments into one - */ - public function optimize() - { - $this->_index->optimize(); - } - - /** - * Returns an array of all terms in this index. - * - * @return array - */ - public function terms() - { - return $this->_index->terms(); - } - - - /** - * Reset terms stream. - */ - public function resetTermsStream() - { - $this->_index->resetTermsStream(); - } - - /** - * Skip terms stream up to specified term preffix. - * - * Prefix contains fully specified field info and portion of searched term - * - * @param Zend_Search_Lucene_Index_Term $prefix - */ - public function skipTo(Zend_Search_Lucene_Index_Term $prefix) - { - return $this->_index->skipTo($prefix); - } - - /** - * Scans terms dictionary and returns next term - * - * @return Zend_Search_Lucene_Index_Term|null - */ - public function nextTerm() - { - return $this->_index->nextTerm(); - } - - /** - * Returns term in current position - * - * @return Zend_Search_Lucene_Index_Term|null - */ - public function currentTerm() - { - return $this->_index->currentTerm(); - } - - /** - * Close terms stream - * - * Should be used for resources clean up if stream is not read up to the end - */ - public function closeTermsStream() - { - $this->_index->closeTermsStream(); - } - - - /** - * Undeletes all documents currently marked as deleted in this index. - */ - public function undeleteAll() - { - return $this->_index->undeleteAll(); - } - - /** - * Add reference to the index object - * - * @internal - */ - public function addReference() - { - return $this->_index->addReference(); - } - - /** - * Remove reference from the index object - * - * When reference count becomes zero, index is closed and resources are cleaned up - * - * @internal - */ - public function removeReference() - { - return $this->_index->removeReference(); - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/BooleanExpressionRecognizer.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/BooleanExpressionRecognizer.php deleted file mode 100755 index 347a3c72bca8c65c7675c92ba8295c2e2b44e7b6..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/BooleanExpressionRecognizer.php +++ /dev/null @@ -1,278 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_FSM */ -// require_once 'Zend/Search/Lucene/FSM.php'; - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_BooleanExpressionRecognizer extends Zend_Search_Lucene_FSM -{ - /** State Machine states */ - const ST_START = 0; - const ST_LITERAL = 1; - const ST_NOT_OPERATOR = 2; - const ST_AND_OPERATOR = 3; - const ST_OR_OPERATOR = 4; - - /** Input symbols */ - const IN_LITERAL = 0; - const IN_NOT_OPERATOR = 1; - const IN_AND_OPERATOR = 2; - const IN_OR_OPERATOR = 3; - - - /** - * NOT operator signal - * - * @var boolean - */ - private $_negativeLiteral = false; - - /** - * Current literal - * - * @var mixed - */ - private $_literal; - - - /** - * Set of boolean query conjunctions - * - * Each conjunction is an array of conjunction elements - * Each conjunction element is presented with two-elements array: - * array(<literal>, <is_negative>) - * - * So, it has a structure: - * array( array( array(<literal>, <is_negative>), // first literal of first conjuction - * array(<literal>, <is_negative>), // second literal of first conjuction - * ... - * array(<literal>, <is_negative>) - * ), // end of first conjuction - * array( array(<literal>, <is_negative>), // first literal of second conjuction - * array(<literal>, <is_negative>), // second literal of second conjuction - * ... - * array(<literal>, <is_negative>) - * ), // end of second conjuction - * ... - * ) // end of structure - * - * @var array - */ - private $_conjunctions = array(); - - /** - * Current conjuction - * - * @var array - */ - private $_currentConjunction = array(); - - - /** - * Object constructor - */ - public function __construct() - { - parent::__construct( array(self::ST_START, - self::ST_LITERAL, - self::ST_NOT_OPERATOR, - self::ST_AND_OPERATOR, - self::ST_OR_OPERATOR), - array(self::IN_LITERAL, - self::IN_NOT_OPERATOR, - self::IN_AND_OPERATOR, - self::IN_OR_OPERATOR)); - - $emptyOperatorAction = new Zend_Search_Lucene_FSMAction($this, 'emptyOperatorAction'); - $emptyNotOperatorAction = new Zend_Search_Lucene_FSMAction($this, 'emptyNotOperatorAction'); - - $this->addRules(array( array(self::ST_START, self::IN_LITERAL, self::ST_LITERAL), - array(self::ST_START, self::IN_NOT_OPERATOR, self::ST_NOT_OPERATOR), - - array(self::ST_LITERAL, self::IN_AND_OPERATOR, self::ST_AND_OPERATOR), - array(self::ST_LITERAL, self::IN_OR_OPERATOR, self::ST_OR_OPERATOR), - array(self::ST_LITERAL, self::IN_LITERAL, self::ST_LITERAL, $emptyOperatorAction), - array(self::ST_LITERAL, self::IN_NOT_OPERATOR, self::ST_NOT_OPERATOR, $emptyNotOperatorAction), - - array(self::ST_NOT_OPERATOR, self::IN_LITERAL, self::ST_LITERAL), - - array(self::ST_AND_OPERATOR, self::IN_LITERAL, self::ST_LITERAL), - array(self::ST_AND_OPERATOR, self::IN_NOT_OPERATOR, self::ST_NOT_OPERATOR), - - array(self::ST_OR_OPERATOR, self::IN_LITERAL, self::ST_LITERAL), - array(self::ST_OR_OPERATOR, self::IN_NOT_OPERATOR, self::ST_NOT_OPERATOR), - )); - - $notOperatorAction = new Zend_Search_Lucene_FSMAction($this, 'notOperatorAction'); - $orOperatorAction = new Zend_Search_Lucene_FSMAction($this, 'orOperatorAction'); - $literalAction = new Zend_Search_Lucene_FSMAction($this, 'literalAction'); - - - $this->addEntryAction(self::ST_NOT_OPERATOR, $notOperatorAction); - $this->addEntryAction(self::ST_OR_OPERATOR, $orOperatorAction); - $this->addEntryAction(self::ST_LITERAL, $literalAction); - } - - - /** - * Process next operator. - * - * Operators are defined by class constants: IN_AND_OPERATOR, IN_OR_OPERATOR and IN_NOT_OPERATOR - * - * @param integer $operator - */ - public function processOperator($operator) - { - $this->process($operator); - } - - /** - * Process expression literal. - * - * @param integer $operator - */ - public function processLiteral($literal) - { - $this->_literal = $literal; - - $this->process(self::IN_LITERAL); - } - - /** - * Finish an expression and return result - * - * Result is a set of boolean query conjunctions - * - * Each conjunction is an array of conjunction elements - * Each conjunction element is presented with two-elements array: - * array(<literal>, <is_negative>) - * - * So, it has a structure: - * array( array( array(<literal>, <is_negative>), // first literal of first conjuction - * array(<literal>, <is_negative>), // second literal of first conjuction - * ... - * array(<literal>, <is_negative>) - * ), // end of first conjuction - * array( array(<literal>, <is_negative>), // first literal of second conjuction - * array(<literal>, <is_negative>), // second literal of second conjuction - * ... - * array(<literal>, <is_negative>) - * ), // end of second conjuction - * ... - * ) // end of structure - * - * @return array - * @throws Zend_Search_Lucene_Exception - */ - public function finishExpression() - { - if ($this->getState() != self::ST_LITERAL) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Literal expected.'); - } - - $this->_conjunctions[] = $this->_currentConjunction; - - return $this->_conjunctions; - } - - - - /********************************************************************* - * Actions implementation - *********************************************************************/ - - /** - * default (omitted) operator processing - */ - public function emptyOperatorAction() - { - /** Zend_Search_Lucene_Search_QueryParser */ - // require_once 'Zend/Search/Lucene/Search/QueryParser.php'; - - if (Zend_Search_Lucene_Search_QueryParser::getDefaultOperator() == Zend_Search_Lucene_Search_QueryParser::B_AND) { - // Do nothing - } else { - $this->orOperatorAction(); - } - - // Process literal - $this->literalAction(); - } - - /** - * default (omitted) + NOT operator processing - */ - public function emptyNotOperatorAction() - { - /** Zend_Search_Lucene_Search_QueryParser */ - // require_once 'Zend/Search/Lucene/Search/QueryParser.php'; - - if (Zend_Search_Lucene_Search_QueryParser::getDefaultOperator() == Zend_Search_Lucene_Search_QueryParser::B_AND) { - // Do nothing - } else { - $this->orOperatorAction(); - } - - // Process NOT operator - $this->notOperatorAction(); - } - - - /** - * NOT operator processing - */ - public function notOperatorAction() - { - $this->_negativeLiteral = true; - } - - /** - * OR operator processing - * Close current conjunction - */ - public function orOperatorAction() - { - $this->_conjunctions[] = $this->_currentConjunction; - $this->_currentConjunction = array(); - } - - /** - * Literal processing - */ - public function literalAction() - { - // Add literal to the current conjunction - $this->_currentConjunction[] = array($this->_literal, !$this->_negativeLiteral); - - // Switch off negative signal - $this->_negativeLiteral = false; - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Highlighter/Default.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Highlighter/Default.php deleted file mode 100755 index f36b65625ad3e401a6e6a4a25953b545eeb1e6f3..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Highlighter/Default.php +++ /dev/null @@ -1,94 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** @see Zend_Search_Lucene_Search_Highlighter_Interface */ -// require_once 'Zend/Search/Lucene/Search/Highlighter/Interface.php'; -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Highlighter_Default implements Zend_Search_Lucene_Search_Highlighter_Interface -{ - /** - * List of colors for text highlighting - * - * @var array - */ - protected $_highlightColors = array('#66ffff', '#ff66ff', '#ffff66', - '#ff8888', '#88ff88', '#8888ff', - '#88dddd', '#dd88dd', '#dddd88', - '#aaddff', '#aaffdd', '#ddaaff', - '#ddffaa', '#ffaadd', '#ffddaa'); - - /** - * Index of current color for highlighting - * - * Index is increased at each highlight() call, so terms matching different queries are highlighted using different colors. - * - * @var integer - */ - protected $_currentColorIndex = 0; - - /** - * HTML document for highlighting - * - * @var Zend_Search_Lucene_Document_Html - */ - protected $_doc; - - /** - * Set document for highlighting. - * - * @param Zend_Search_Lucene_Document_Html $document - */ - public function setDocument(Zend_Search_Lucene_Document_Html $document) - { - $this->_doc = $document; - } - - /** - * Get document for highlighting. - * - * @return Zend_Search_Lucene_Document_Html $document - */ - public function getDocument() - { - return $this->_doc; - } - - /** - * Highlight specified words - * - * @param string|array $words Words to highlight. They could be organized using the array or string. - */ - public function highlight($words) - { - $color = $this->_highlightColors[$this->_currentColorIndex]; - $this->_currentColorIndex = ($this->_currentColorIndex + 1) % count($this->_highlightColors); - - $this->_doc->highlight($words, $color); - } - -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Highlighter/Interface.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Highlighter/Interface.php deleted file mode 100755 index 99fe12ee0cdc97e37fc7aec904e90a519386dba2..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Highlighter/Interface.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -interface Zend_Search_Lucene_Search_Highlighter_Interface -{ - /** - * Set document for highlighting. - * - * @param Zend_Search_Lucene_Document_Html $document - */ - public function setDocument(Zend_Search_Lucene_Document_Html $document); - - /** - * Get document for highlighting. - * - * @return Zend_Search_Lucene_Document_Html $document - */ - public function getDocument(); - - /** - * Highlight specified words (method is invoked once per subquery) - * - * @param string|array $words Words to highlight. They could be organized using the array or string. - */ - public function highlight($words); -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query.php deleted file mode 100755 index 9a14dfdc36276b02956d464274a778d7ff3eb23a..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query.php +++ /dev/null @@ -1,233 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Search_Lucene_Search_Query -{ - /** - * query boost factor - * - * @var float - */ - private $_boost = 1; - - /** - * Query weight - * - * @var Zend_Search_Lucene_Search_Weight - */ - protected $_weight = null; - - /** - * Current highlight color - * - * @var integer - */ - private $_currentColorIndex = 0; - - /** - * Gets the boost for this clause. Documents matching - * this clause will (in addition to the normal weightings) have their score - * multiplied by boost. The boost is 1.0 by default. - * - * @return float - */ - public function getBoost() - { - return $this->_boost; - } - - /** - * Sets the boost for this query clause to $boost. - * - * @param float $boost - */ - public function setBoost($boost) - { - $this->_boost = $boost; - } - - /** - * Score specified document - * - * @param integer $docId - * @param Zend_Search_Lucene_Interface $reader - * @return float - */ - abstract public function score($docId, Zend_Search_Lucene_Interface $reader); - - /** - * Get document ids likely matching the query - * - * It's an array with document ids as keys (performance considerations) - * - * @return array - */ - abstract public function matchedDocs(); - - /** - * Execute query in context of index reader - * It also initializes necessary internal structures - * - * Query specific implementation - * - * @param Zend_Search_Lucene_Interface $reader - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - */ - abstract public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null); - - /** - * Constructs an appropriate Weight implementation for this query. - * - * @param Zend_Search_Lucene_Interface $reader - * @return Zend_Search_Lucene_Search_Weight - */ - abstract public function createWeight(Zend_Search_Lucene_Interface $reader); - - /** - * Constructs an initializes a Weight for a _top-level_query_. - * - * @param Zend_Search_Lucene_Interface $reader - */ - protected function _initWeight(Zend_Search_Lucene_Interface $reader) - { - // Check, that it's a top-level query and query weight is not initialized yet. - if ($this->_weight !== null) { - return $this->_weight; - } - - $this->createWeight($reader); - $sum = $this->_weight->sumOfSquaredWeights(); - $queryNorm = $reader->getSimilarity()->queryNorm($sum); - $this->_weight->normalize($queryNorm); - } - - /** - * Re-write query into primitive queries in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - abstract public function rewrite(Zend_Search_Lucene_Interface $index); - - /** - * Optimize query in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - abstract public function optimize(Zend_Search_Lucene_Interface $index); - - /** - * Reset query, so it can be reused within other queries or - * with other indeces - */ - public function reset() - { - $this->_weight = null; - } - - - /** - * Print a query - * - * @return string - */ - abstract public function __toString(); - - /** - * Return query terms - * - * @return array - */ - abstract public function getQueryTerms(); - - /** - * Query specific matches highlighting - * - * @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) - */ - abstract protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter); - - /** - * Highlight matches in $inputHTML - * - * @param string $inputHTML - * @param string $defaultEncoding HTML encoding, is used if it's not specified using Content-type HTTP-EQUIV meta tag. - * @param Zend_Search_Lucene_Search_Highlighter_Interface|null $highlighter - * @return string - */ - public function highlightMatches($inputHTML, $defaultEncoding = '', $highlighter = null) - { - if ($highlighter === null) { - // require_once 'Zend/Search/Lucene/Search/Highlighter/Default.php'; - $highlighter = new Zend_Search_Lucene_Search_Highlighter_Default(); - } - - /** Zend_Search_Lucene_Document_Html */ - // require_once 'Zend/Search/Lucene/Document/Html.php'; - - $doc = Zend_Search_Lucene_Document_Html::loadHTML($inputHTML, false, $defaultEncoding); - $highlighter->setDocument($doc); - - $this->_highlightMatches($highlighter); - - return $doc->getHTML(); - } - - /** - * Highlight matches in $inputHtmlFragment and return it (without HTML header and body tag) - * - * @param string $inputHtmlFragment - * @param string $encoding Input HTML string encoding - * @param Zend_Search_Lucene_Search_Highlighter_Interface|null $highlighter - * @return string - */ - public function htmlFragmentHighlightMatches($inputHtmlFragment, $encoding = 'UTF-8', $highlighter = null) - { - if ($highlighter === null) { - // require_once 'Zend/Search/Lucene/Search/Highlighter/Default.php'; - $highlighter = new Zend_Search_Lucene_Search_Highlighter_Default(); - } - - $inputHTML = '<html><head><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"/></head><body>' - . iconv($encoding, 'UTF-8//IGNORE', $inputHtmlFragment) . '</body></html>'; - - /** Zend_Search_Lucene_Document_Html */ - // require_once 'Zend/Search/Lucene/Document/Html.php'; - - $doc = Zend_Search_Lucene_Document_Html::loadHTML($inputHTML); - $highlighter->setDocument($doc); - - $this->_highlightMatches($highlighter); - - return $doc->getHtmlBody(); - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Boolean.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Boolean.php deleted file mode 100755 index 21df67e894b27fecb13f73fe9b51c28b8ad376d8..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Boolean.php +++ /dev/null @@ -1,815 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Query */ -// require_once 'Zend/Search/Lucene/Search/Query.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Query_Boolean extends Zend_Search_Lucene_Search_Query -{ - - /** - * Subqueries - * Array of Zend_Search_Lucene_Search_Query - * - * @var array - */ - private $_subqueries = array(); - - /** - * Subqueries signs. - * If true then subquery is required. - * If false then subquery is prohibited. - * If null then subquery is neither prohibited, nor required - * - * If array is null then all subqueries are required - * - * @var array - */ - private $_signs = array(); - - /** - * Result vector. - * - * @var array - */ - private $_resVector = null; - - /** - * A score factor based on the fraction of all query subqueries - * that a document contains. - * float for conjunction queries - * array of float for non conjunction queries - * - * @var mixed - */ - private $_coord = null; - - - /** - * Class constructor. Create a new Boolean query object. - * - * if $signs array is omitted then all subqueries are required - * it differs from addSubquery() behavior, but should never be used - * - * @param array $subqueries Array of Zend_Search_Search_Query objects - * @param array $signs Array of signs. Sign is boolean|null. - * @return void - */ - public function __construct($subqueries = null, $signs = null) - { - if (is_array($subqueries)) { - $this->_subqueries = $subqueries; - - $this->_signs = null; - // Check if all subqueries are required - if (is_array($signs)) { - foreach ($signs as $sign ) { - if ($sign !== true) { - $this->_signs = $signs; - break; - } - } - } - } - } - - - /** - * Add a $subquery (Zend_Search_Lucene_Search_Query) to this query. - * - * The sign is specified as: - * TRUE - subquery is required - * FALSE - subquery is prohibited - * NULL - subquery is neither prohibited, nor required - * - * @param Zend_Search_Lucene_Search_Query $subquery - * @param boolean|null $sign - * @return void - */ - public function addSubquery(Zend_Search_Lucene_Search_Query $subquery, $sign=null) { - if ($sign !== true || $this->_signs !== null) { // Skip, if all subqueries are required - if ($this->_signs === null) { // Check, If all previous subqueries are required - $this->_signs = array(); - foreach ($this->_subqueries as $prevSubquery) { - $this->_signs[] = true; - } - } - $this->_signs[] = $sign; - } - - $this->_subqueries[] = $subquery; - } - - /** - * Re-write queries into primitive queries - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function rewrite(Zend_Search_Lucene_Interface $index) - { - $query = new Zend_Search_Lucene_Search_Query_Boolean(); - $query->setBoost($this->getBoost()); - - foreach ($this->_subqueries as $subqueryId => $subquery) { - $query->addSubquery($subquery->rewrite($index), - ($this->_signs === null)? true : $this->_signs[$subqueryId]); - } - - return $query; - } - - /** - * Optimize query in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function optimize(Zend_Search_Lucene_Interface $index) - { - $subqueries = array(); - $signs = array(); - - // Optimize all subqueries - foreach ($this->_subqueries as $id => $subquery) { - $subqueries[] = $subquery->optimize($index); - $signs[] = ($this->_signs === null)? true : $this->_signs[$id]; - } - - // Remove insignificant subqueries - foreach ($subqueries as $id => $subquery) { - if ($subquery instanceof Zend_Search_Lucene_Search_Query_Insignificant) { - // Insignificant subquery has to be removed anyway - unset($subqueries[$id]); - unset($signs[$id]); - } - } - if (count($subqueries) == 0) { - // Boolean query doesn't has non-insignificant subqueries - // require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php'; - return new Zend_Search_Lucene_Search_Query_Insignificant(); - } - // Check if all non-insignificant subqueries are prohibited - $allProhibited = true; - foreach ($signs as $sign) { - if ($sign !== false) { - $allProhibited = false; - break; - } - } - if ($allProhibited) { - // require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php'; - return new Zend_Search_Lucene_Search_Query_Insignificant(); - } - - - // Check for empty subqueries - foreach ($subqueries as $id => $subquery) { - if ($subquery instanceof Zend_Search_Lucene_Search_Query_Empty) { - if ($signs[$id] === true) { - // Matching is required, but is actually empty - // require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - return new Zend_Search_Lucene_Search_Query_Empty(); - } else { - // Matching is optional or prohibited, but is empty - // Remove it from subqueries and signs list - unset($subqueries[$id]); - unset($signs[$id]); - } - } - } - - // Check, if reduced subqueries list is empty - if (count($subqueries) == 0) { - // require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - return new Zend_Search_Lucene_Search_Query_Empty(); - } - - // Check if all non-empty subqueries are prohibited - $allProhibited = true; - foreach ($signs as $sign) { - if ($sign !== false) { - $allProhibited = false; - break; - } - } - if ($allProhibited) { - // require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - return new Zend_Search_Lucene_Search_Query_Empty(); - } - - - // Check, if reduced subqueries list has only one entry - if (count($subqueries) == 1) { - // It's a query with only one required or optional clause - // (it's already checked, that it's not a prohibited clause) - - if ($this->getBoost() == 1) { - return reset($subqueries); - } - - $optimizedQuery = clone reset($subqueries); - $optimizedQuery->setBoost($optimizedQuery->getBoost()*$this->getBoost()); - - return $optimizedQuery; - } - - - // Prepare first candidate for optimized query - $optimizedQuery = new Zend_Search_Lucene_Search_Query_Boolean($subqueries, $signs); - $optimizedQuery->setBoost($this->getBoost()); - - - $terms = array(); - $tsigns = array(); - $boostFactors = array(); - - // Try to decompose term and multi-term subqueries - foreach ($subqueries as $id => $subquery) { - if ($subquery instanceof Zend_Search_Lucene_Search_Query_Term) { - $terms[] = $subquery->getTerm(); - $tsigns[] = $signs[$id]; - $boostFactors[] = $subquery->getBoost(); - - // remove subquery from a subqueries list - unset($subqueries[$id]); - unset($signs[$id]); - } else if ($subquery instanceof Zend_Search_Lucene_Search_Query_MultiTerm) { - $subTerms = $subquery->getTerms(); - $subSigns = $subquery->getSigns(); - - if ($signs[$id] === true) { - // It's a required multi-term subquery. - // Something like '... +(+term1 -term2 term3 ...) ...' - - // Multi-term required subquery can be decomposed only if it contains - // required terms and doesn't contain prohibited terms: - // ... +(+term1 term2 ...) ... => ... +term1 term2 ... - // - // Check this - $hasRequired = false; - $hasProhibited = false; - if ($subSigns === null) { - // All subterms are required - $hasRequired = true; - } else { - foreach ($subSigns as $sign) { - if ($sign === true) { - $hasRequired = true; - } else if ($sign === false) { - $hasProhibited = true; - break; - } - } - } - // Continue if subquery has prohibited terms or doesn't have required terms - if ($hasProhibited || !$hasRequired) { - continue; - } - - foreach ($subTerms as $termId => $term) { - $terms[] = $term; - $tsigns[] = ($subSigns === null)? true : $subSigns[$termId]; - $boostFactors[] = $subquery->getBoost(); - } - - // remove subquery from a subqueries list - unset($subqueries[$id]); - unset($signs[$id]); - - } else { // $signs[$id] === null || $signs[$id] === false - // It's an optional or prohibited multi-term subquery. - // Something like '... (+term1 -term2 term3 ...) ...' - // or - // something like '... -(+term1 -term2 term3 ...) ...' - - // Multi-term optional and required subqueries can be decomposed - // only if all terms are optional. - // - // Check if all terms are optional. - $onlyOptional = true; - if ($subSigns === null) { - // All subterms are required - $onlyOptional = false; - } else { - foreach ($subSigns as $sign) { - if ($sign !== null) { - $onlyOptional = false; - break; - } - } - } - - // Continue if non-optional terms are presented in this multi-term subquery - if (!$onlyOptional) { - continue; - } - - foreach ($subTerms as $termId => $term) { - $terms[] = $term; - $tsigns[] = ($signs[$id] === null)? null /* optional */ : - false /* prohibited */; - $boostFactors[] = $subquery->getBoost(); - } - - // remove subquery from a subqueries list - unset($subqueries[$id]); - unset($signs[$id]); - } - } - } - - - // Check, if there are no decomposed subqueries - if (count($terms) == 0 ) { - // return prepared candidate - return $optimizedQuery; - } - - - // Check, if all subqueries have been decomposed and all terms has the same boost factor - if (count($subqueries) == 0 && count(array_unique($boostFactors)) == 1) { - // require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php'; - $optimizedQuery = new Zend_Search_Lucene_Search_Query_MultiTerm($terms, $tsigns); - $optimizedQuery->setBoost(reset($boostFactors)*$this->getBoost()); - - return $optimizedQuery; - } - - - // This boolean query can't be transformed to Term/MultiTerm query and still contains - // several subqueries - - // Separate prohibited terms - $prohibitedTerms = array(); - foreach ($terms as $id => $term) { - if ($tsigns[$id] === false) { - $prohibitedTerms[] = $term; - - unset($terms[$id]); - unset($tsigns[$id]); - unset($boostFactors[$id]); - } - } - - if (count($terms) == 1) { - // require_once 'Zend/Search/Lucene/Search/Query/Term.php'; - $clause = new Zend_Search_Lucene_Search_Query_Term(reset($terms)); - $clause->setBoost(reset($boostFactors)); - - $subqueries[] = $clause; - $signs[] = reset($tsigns); - - // Clear terms list - $terms = array(); - } else if (count($terms) > 1 && count(array_unique($boostFactors)) == 1) { - // require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php'; - $clause = new Zend_Search_Lucene_Search_Query_MultiTerm($terms, $tsigns); - $clause->setBoost(reset($boostFactors)); - - $subqueries[] = $clause; - // Clause sign is 'required' if clause contains required terms. 'Optional' otherwise. - $signs[] = (in_array(true, $tsigns))? true : null; - - // Clear terms list - $terms = array(); - } - - if (count($prohibitedTerms) == 1) { - // (boost factors are not significant for prohibited clauses) - // require_once 'Zend/Search/Lucene/Search/Query/Term.php'; - $subqueries[] = new Zend_Search_Lucene_Search_Query_Term(reset($prohibitedTerms)); - $signs[] = false; - - // Clear prohibited terms list - $prohibitedTerms = array(); - } else if (count($prohibitedTerms) > 1) { - // prepare signs array - $prohibitedSigns = array(); - foreach ($prohibitedTerms as $id => $term) { - // all prohibited term are grouped as optional into multi-term query - $prohibitedSigns[$id] = null; - } - - // (boost factors are not significant for prohibited clauses) - // require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php'; - $subqueries[] = new Zend_Search_Lucene_Search_Query_MultiTerm($prohibitedTerms, $prohibitedSigns); - // Clause sign is 'prohibited' - $signs[] = false; - - // Clear terms list - $prohibitedTerms = array(); - } - - /** @todo Group terms with the same boost factors together */ - - // Check, that all terms are processed - // Replace candidate for optimized query - if (count($terms) == 0 && count($prohibitedTerms) == 0) { - $optimizedQuery = new Zend_Search_Lucene_Search_Query_Boolean($subqueries, $signs); - $optimizedQuery->setBoost($this->getBoost()); - } - - return $optimizedQuery; - } - - /** - * Returns subqueries - * - * @return array - */ - public function getSubqueries() - { - return $this->_subqueries; - } - - - /** - * Return subqueries signs - * - * @return array - */ - public function getSigns() - { - return $this->_signs; - } - - - /** - * Constructs an appropriate Weight implementation for this query. - * - * @param Zend_Search_Lucene_Interface $reader - * @return Zend_Search_Lucene_Search_Weight - */ - public function createWeight(Zend_Search_Lucene_Interface $reader) - { - // require_once 'Zend/Search/Lucene/Search/Weight/Boolean.php'; - $this->_weight = new Zend_Search_Lucene_Search_Weight_Boolean($this, $reader); - return $this->_weight; - } - - - /** - * Calculate result vector for Conjunction query - * (like '<subquery1> AND <subquery2> AND <subquery3>') - */ - private function _calculateConjunctionResult() - { - $this->_resVector = null; - - if (count($this->_subqueries) == 0) { - $this->_resVector = array(); - } - - $resVectors = array(); - $resVectorsSizes = array(); - $resVectorsIds = array(); // is used to prevent arrays comparison - foreach ($this->_subqueries as $subqueryId => $subquery) { - $resVectors[] = $subquery->matchedDocs(); - $resVectorsSizes[] = count(end($resVectors)); - $resVectorsIds[] = $subqueryId; - } - // sort resvectors in order of subquery cardinality increasing - array_multisort($resVectorsSizes, SORT_ASC, SORT_NUMERIC, - $resVectorsIds, SORT_ASC, SORT_NUMERIC, - $resVectors); - - foreach ($resVectors as $nextResVector) { - if($this->_resVector === null) { - $this->_resVector = $nextResVector; - } else { - //$this->_resVector = array_intersect_key($this->_resVector, $nextResVector); - - /** - * This code is used as workaround for array_intersect_key() slowness problem. - */ - $updatedVector = array(); - foreach ($this->_resVector as $id => $value) { - if (isset($nextResVector[$id])) { - $updatedVector[$id] = $value; - } - } - $this->_resVector = $updatedVector; - } - - if (count($this->_resVector) == 0) { - // Empty result set, we don't need to check other terms - break; - } - } - - // ksort($this->_resVector, SORT_NUMERIC); - // Used algorithm doesn't change elements order - } - - - /** - * Calculate result vector for non Conjunction query - * (like '<subquery1> AND <subquery2> AND NOT <subquery3> OR <subquery4>') - */ - private function _calculateNonConjunctionResult() - { - $requiredVectors = array(); - $requiredVectorsSizes = array(); - $requiredVectorsIds = array(); // is used to prevent arrays comparison - - $optional = array(); - - foreach ($this->_subqueries as $subqueryId => $subquery) { - if ($this->_signs[$subqueryId] === true) { - // required - $requiredVectors[] = $subquery->matchedDocs(); - $requiredVectorsSizes[] = count(end($requiredVectors)); - $requiredVectorsIds[] = $subqueryId; - } elseif ($this->_signs[$subqueryId] === false) { - // prohibited - // Do nothing. matchedDocs() may include non-matching id's - // Calculating prohibited vector may take significant time, but do not affect the result - // Skipped. - } else { - // neither required, nor prohibited - // array union - $optional += $subquery->matchedDocs(); - } - } - - // sort resvectors in order of subquery cardinality increasing - array_multisort($requiredVectorsSizes, SORT_ASC, SORT_NUMERIC, - $requiredVectorsIds, SORT_ASC, SORT_NUMERIC, - $requiredVectors); - - $required = null; - foreach ($requiredVectors as $nextResVector) { - if($required === null) { - $required = $nextResVector; - } else { - //$required = array_intersect_key($required, $nextResVector); - - /** - * This code is used as workaround for array_intersect_key() slowness problem. - */ - $updatedVector = array(); - foreach ($required as $id => $value) { - if (isset($nextResVector[$id])) { - $updatedVector[$id] = $value; - } - } - $required = $updatedVector; - } - - if (count($required) == 0) { - // Empty result set, we don't need to check other terms - break; - } - } - - - if ($required !== null) { - $this->_resVector = &$required; - } else { - $this->_resVector = &$optional; - } - - ksort($this->_resVector, SORT_NUMERIC); - } - - - /** - * Score calculator for conjunction queries (all subqueries are required) - * - * @param integer $docId - * @param Zend_Search_Lucene_Interface $reader - * @return float - */ - public function _conjunctionScore($docId, Zend_Search_Lucene_Interface $reader) - { - if ($this->_coord === null) { - $this->_coord = $reader->getSimilarity()->coord(count($this->_subqueries), - count($this->_subqueries) ); - } - - $score = 0; - - foreach ($this->_subqueries as $subquery) { - $subscore = $subquery->score($docId, $reader); - - if ($subscore == 0) { - return 0; - } - - $score += $subquery->score($docId, $reader) * $this->_coord; - } - - return $score * $this->_coord * $this->getBoost(); - } - - - /** - * Score calculator for non conjunction queries (not all subqueries are required) - * - * @param integer $docId - * @param Zend_Search_Lucene_Interface $reader - * @return float - */ - public function _nonConjunctionScore($docId, Zend_Search_Lucene_Interface $reader) - { - if ($this->_coord === null) { - $this->_coord = array(); - - $maxCoord = 0; - foreach ($this->_signs as $sign) { - if ($sign !== false /* not prohibited */) { - $maxCoord++; - } - } - - for ($count = 0; $count <= $maxCoord; $count++) { - $this->_coord[$count] = $reader->getSimilarity()->coord($count, $maxCoord); - } - } - - $score = 0; - $matchedSubqueries = 0; - foreach ($this->_subqueries as $subqueryId => $subquery) { - $subscore = $subquery->score($docId, $reader); - - // Prohibited - if ($this->_signs[$subqueryId] === false && $subscore != 0) { - return 0; - } - - // is required, but doen't match - if ($this->_signs[$subqueryId] === true && $subscore == 0) { - return 0; - } - - if ($subscore != 0) { - $matchedSubqueries++; - $score += $subscore; - } - } - - return $score * $this->_coord[$matchedSubqueries] * $this->getBoost(); - } - - /** - * Execute query in context of index reader - * It also initializes necessary internal structures - * - * @param Zend_Search_Lucene_Interface $reader - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - */ - public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null) - { - // Initialize weight if it's not done yet - $this->_initWeight($reader); - - if ($docsFilter === null) { - // Create local documents filter if it's not provided by upper query - // require_once 'Zend/Search/Lucene/Index/DocsFilter.php'; - $docsFilter = new Zend_Search_Lucene_Index_DocsFilter(); - } - - foreach ($this->_subqueries as $subqueryId => $subquery) { - if ($this->_signs == null || $this->_signs[$subqueryId] === true) { - // Subquery is required - $subquery->execute($reader, $docsFilter); - } else { - $subquery->execute($reader); - } - } - - if ($this->_signs === null) { - $this->_calculateConjunctionResult(); - } else { - $this->_calculateNonConjunctionResult(); - } - } - - - - /** - * Get document ids likely matching the query - * - * It's an array with document ids as keys (performance considerations) - * - * @return array - */ - public function matchedDocs() - { - return $this->_resVector; - } - - /** - * Score specified document - * - * @param integer $docId - * @param Zend_Search_Lucene_Interface $reader - * @return float - */ - public function score($docId, Zend_Search_Lucene_Interface $reader) - { - if (isset($this->_resVector[$docId])) { - if ($this->_signs === null) { - return $this->_conjunctionScore($docId, $reader); - } else { - return $this->_nonConjunctionScore($docId, $reader); - } - } else { - return 0; - } - } - - /** - * Return query terms - * - * @return array - */ - public function getQueryTerms() - { - $terms = array(); - - foreach ($this->_subqueries as $id => $subquery) { - if ($this->_signs === null || $this->_signs[$id] !== false) { - $terms = array_merge($terms, $subquery->getQueryTerms()); - } - } - - return $terms; - } - - /** - * Query specific matches highlighting - * - * @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) - */ - protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter) - { - foreach ($this->_subqueries as $id => $subquery) { - if ($this->_signs === null || $this->_signs[$id] !== false) { - $subquery->_highlightMatches($highlighter); - } - } - } - - /** - * Print a query - * - * @return string - */ - public function __toString() - { - // It's used only for query visualisation, so we don't care about characters escaping - - $query = ''; - - foreach ($this->_subqueries as $id => $subquery) { - if ($id != 0) { - $query .= ' '; - } - - if ($this->_signs === null || $this->_signs[$id] === true) { - $query .= '+'; - } else if ($this->_signs[$id] === false) { - $query .= '-'; - } - - $query .= '(' . $subquery->__toString() . ')'; - } - - if ($this->getBoost() != 1) { - $query = '(' . $query . ')^' . round($this->getBoost(), 4); - } - - return $query; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Empty.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Empty.php deleted file mode 100755 index 8a2e4099c589ee69036ed2ab5a401d81e0089cae..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Empty.php +++ /dev/null @@ -1,138 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Query */ -// require_once 'Zend/Search/Lucene/Search/Query.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Query_Empty extends Zend_Search_Lucene_Search_Query -{ - /** - * Re-write query into primitive queries in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function rewrite(Zend_Search_Lucene_Interface $index) - { - return $this; - } - - /** - * Optimize query in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function optimize(Zend_Search_Lucene_Interface $index) - { - // "Empty" query is a primitive query and don't need to be optimized - return $this; - } - - /** - * Constructs an appropriate Weight implementation for this query. - * - * @param Zend_Search_Lucene_Interface $reader - * @return Zend_Search_Lucene_Search_Weight - */ - public function createWeight(Zend_Search_Lucene_Interface $reader) - { - // require_once 'Zend/Search/Lucene/Search/Weight/Empty.php'; - return new Zend_Search_Lucene_Search_Weight_Empty(); - } - - /** - * Execute query in context of index reader - * It also initializes necessary internal structures - * - * @param Zend_Search_Lucene_Interface $reader - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - */ - public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null) - { - // Do nothing - } - - /** - * Get document ids likely matching the query - * - * It's an array with document ids as keys (performance considerations) - * - * @return array - */ - public function matchedDocs() - { - return array(); - } - - /** - * Score specified document - * - * @param integer $docId - * @param Zend_Search_Lucene_Interface $reader - * @return float - */ - public function score($docId, Zend_Search_Lucene_Interface $reader) - { - return 0; - } - - /** - * Return query terms - * - * @return array - */ - public function getQueryTerms() - { - return array(); - } - - /** - * Query specific matches highlighting - * - * @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) - */ - protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter) - { - // Do nothing - } - - /** - * Print a query - * - * @return string - */ - public function __toString() - { - return '<EmptyQuery>'; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Fuzzy.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Fuzzy.php deleted file mode 100755 index 2982a0afb8032e031b77958eb2aca40be45943df..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Fuzzy.php +++ /dev/null @@ -1,493 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Query */ -// require_once 'Zend/Search/Lucene/Search/Query.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Query_Fuzzy extends Zend_Search_Lucene_Search_Query -{ - /** Default minimum similarity */ - const DEFAULT_MIN_SIMILARITY = 0.5; - - /** - * Maximum number of matched terms. - * Apache Lucene defines this limitation as boolean query maximum number of clauses: - * org.apache.lucene.search.BooleanQuery.getMaxClauseCount() - */ - const MAX_CLAUSE_COUNT = 1024; - - /** - * Array of precalculated max distances - * - * keys are integers representing a word size - */ - private $_maxDistances = array(); - - /** - * Base searching term. - * - * @var Zend_Search_Lucene_Index_Term - */ - private $_term; - - /** - * A value between 0 and 1 to set the required similarity - * between the query term and the matching terms. For example, for a - * _minimumSimilarity of 0.5 a term of the same length - * as the query term is considered similar to the query term if the edit distance - * between both terms is less than length(term)*0.5 - * - * @var float - */ - private $_minimumSimilarity; - - /** - * The length of common (non-fuzzy) prefix - * - * @var integer - */ - private $_prefixLength; - - /** - * Matched terms. - * - * Matched terms list. - * It's filled during the search (rewrite operation) and may be used for search result - * post-processing - * - * Array of Zend_Search_Lucene_Index_Term objects - * - * @var array - */ - private $_matches = null; - - /** - * Matched terms scores - * - * @var array - */ - private $_scores = null; - - /** - * Array of the term keys. - * Used to sort terms in alphabetical order if terms have the same socres - * - * @var array - */ - private $_termKeys = null; - - /** - * Default non-fuzzy prefix length - * - * @var integer - */ - private static $_defaultPrefixLength = 3; - - /** - * Zend_Search_Lucene_Search_Query_Wildcard constructor. - * - * @param Zend_Search_Lucene_Index_Term $term - * @param float $minimumSimilarity - * @param integer $prefixLength - * @throws Zend_Search_Lucene_Exception - */ - public function __construct(Zend_Search_Lucene_Index_Term $term, $minimumSimilarity = self::DEFAULT_MIN_SIMILARITY, $prefixLength = null) - { - if ($minimumSimilarity < 0) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('minimumSimilarity cannot be less than 0'); - } - if ($minimumSimilarity >= 1) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('minimumSimilarity cannot be greater than or equal to 1'); - } - if ($prefixLength < 0) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('prefixLength cannot be less than 0'); - } - - $this->_term = $term; - $this->_minimumSimilarity = $minimumSimilarity; - $this->_prefixLength = ($prefixLength !== null)? $prefixLength : self::$_defaultPrefixLength; - } - - /** - * Get default non-fuzzy prefix length - * - * @return integer - */ - public static function getDefaultPrefixLength() - { - return self::$_defaultPrefixLength; - } - - /** - * Set default non-fuzzy prefix length - * - * @param integer $defaultPrefixLength - */ - public static function setDefaultPrefixLength($defaultPrefixLength) - { - self::$_defaultPrefixLength = $defaultPrefixLength; - } - - /** - * Calculate maximum distance for specified word length - * - * @param integer $prefixLength - * @param integer $termLength - * @param integer $length - * @return integer - */ - private function _calculateMaxDistance($prefixLength, $termLength, $length) - { - $this->_maxDistances[$length] = (int) ((1 - $this->_minimumSimilarity)*(min($termLength, $length) + $prefixLength)); - return $this->_maxDistances[$length]; - } - - /** - * Re-write query into primitive queries in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - * @throws Zend_Search_Lucene_Exception - */ - public function rewrite(Zend_Search_Lucene_Interface $index) - { - $this->_matches = array(); - $this->_scores = array(); - $this->_termKeys = array(); - - if ($this->_term->field === null) { - // Search through all fields - $fields = $index->getFieldNames(true /* indexed fields list */); - } else { - $fields = array($this->_term->field); - } - - // require_once 'Zend/Search/Lucene/Index/Term.php'; - $prefix = Zend_Search_Lucene_Index_Term::getPrefix($this->_term->text, $this->_prefixLength); - $prefixByteLength = strlen($prefix); - $prefixUtf8Length = Zend_Search_Lucene_Index_Term::getLength($prefix); - - $termLength = Zend_Search_Lucene_Index_Term::getLength($this->_term->text); - - $termRest = substr($this->_term->text, $prefixByteLength); - // we calculate length of the rest in bytes since levenshtein() is not UTF-8 compatible - $termRestLength = strlen($termRest); - - $scaleFactor = 1/(1 - $this->_minimumSimilarity); - - // require_once 'Zend/Search/Lucene.php'; - $maxTerms = Zend_Search_Lucene::getTermsPerQueryLimit(); - foreach ($fields as $field) { - $index->resetTermsStream(); - - // require_once 'Zend/Search/Lucene/Index/Term.php'; - if ($prefix != '') { - $index->skipTo(new Zend_Search_Lucene_Index_Term($prefix, $field)); - - while ($index->currentTerm() !== null && - $index->currentTerm()->field == $field && - substr($index->currentTerm()->text, 0, $prefixByteLength) == $prefix) { - // Calculate similarity - $target = substr($index->currentTerm()->text, $prefixByteLength); - - $maxDistance = isset($this->_maxDistances[strlen($target)])? - $this->_maxDistances[strlen($target)] : - $this->_calculateMaxDistance($prefixUtf8Length, $termRestLength, strlen($target)); - - if ($termRestLength == 0) { - // we don't have anything to compare. That means if we just add - // the letters for current term we get the new word - $similarity = (($prefixUtf8Length == 0)? 0 : 1 - strlen($target)/$prefixUtf8Length); - } else if (strlen($target) == 0) { - $similarity = (($prefixUtf8Length == 0)? 0 : 1 - $termRestLength/$prefixUtf8Length); - } else if ($maxDistance < abs($termRestLength - strlen($target))){ - //just adding the characters of term to target or vice-versa results in too many edits - //for example "pre" length is 3 and "prefixes" length is 8. We can see that - //given this optimal circumstance, the edit distance cannot be less than 5. - //which is 8-3 or more precisesly abs(3-8). - //if our maximum edit distance is 4, then we can discard this word - //without looking at it. - $similarity = 0; - } else { - $similarity = 1 - levenshtein($termRest, $target)/($prefixUtf8Length + min($termRestLength, strlen($target))); - } - - if ($similarity > $this->_minimumSimilarity) { - $this->_matches[] = $index->currentTerm(); - $this->_termKeys[] = $index->currentTerm()->key(); - $this->_scores[] = ($similarity - $this->_minimumSimilarity)*$scaleFactor; - - if ($maxTerms != 0 && count($this->_matches) > $maxTerms) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Terms per query limit is reached.'); - } - } - - $index->nextTerm(); - } - } else { - $index->skipTo(new Zend_Search_Lucene_Index_Term('', $field)); - - while ($index->currentTerm() !== null && $index->currentTerm()->field == $field) { - // Calculate similarity - $target = $index->currentTerm()->text; - - $maxDistance = isset($this->_maxDistances[strlen($target)])? - $this->_maxDistances[strlen($target)] : - $this->_calculateMaxDistance(0, $termRestLength, strlen($target)); - - if ($maxDistance < abs($termRestLength - strlen($target))){ - //just adding the characters of term to target or vice-versa results in too many edits - //for example "pre" length is 3 and "prefixes" length is 8. We can see that - //given this optimal circumstance, the edit distance cannot be less than 5. - //which is 8-3 or more precisesly abs(3-8). - //if our maximum edit distance is 4, then we can discard this word - //without looking at it. - $similarity = 0; - } else { - $similarity = 1 - levenshtein($termRest, $target)/min($termRestLength, strlen($target)); - } - - if ($similarity > $this->_minimumSimilarity) { - $this->_matches[] = $index->currentTerm(); - $this->_termKeys[] = $index->currentTerm()->key(); - $this->_scores[] = ($similarity - $this->_minimumSimilarity)*$scaleFactor; - - if ($maxTerms != 0 && count($this->_matches) > $maxTerms) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Terms per query limit is reached.'); - } - } - - $index->nextTerm(); - } - } - - $index->closeTermsStream(); - } - - if (count($this->_matches) == 0) { - // require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - return new Zend_Search_Lucene_Search_Query_Empty(); - } else if (count($this->_matches) == 1) { - // require_once 'Zend/Search/Lucene/Search/Query/Term.php'; - return new Zend_Search_Lucene_Search_Query_Term(reset($this->_matches)); - } else { - // require_once 'Zend/Search/Lucene/Search/Query/Boolean.php'; - $rewrittenQuery = new Zend_Search_Lucene_Search_Query_Boolean(); - - array_multisort($this->_scores, SORT_DESC, SORT_NUMERIC, - $this->_termKeys, SORT_ASC, SORT_STRING, - $this->_matches); - - $termCount = 0; - // require_once 'Zend/Search/Lucene/Search/Query/Term.php'; - foreach ($this->_matches as $id => $matchedTerm) { - $subquery = new Zend_Search_Lucene_Search_Query_Term($matchedTerm); - $subquery->setBoost($this->_scores[$id]); - - $rewrittenQuery->addSubquery($subquery); - - $termCount++; - if ($termCount >= self::MAX_CLAUSE_COUNT) { - break; - } - } - - return $rewrittenQuery; - } - } - - /** - * Optimize query in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function optimize(Zend_Search_Lucene_Interface $index) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Fuzzy query should not be directly used for search. Use $query->rewrite($index)'); - } - - /** - * Return query terms - * - * @return array - * @throws Zend_Search_Lucene_Exception - */ - public function getQueryTerms() - { - if ($this->_matches === null) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Search or rewrite operations have to be performed before.'); - } - - return $this->_matches; - } - - /** - * Constructs an appropriate Weight implementation for this query. - * - * @param Zend_Search_Lucene_Interface $reader - * @return Zend_Search_Lucene_Search_Weight - * @throws Zend_Search_Lucene_Exception - */ - public function createWeight(Zend_Search_Lucene_Interface $reader) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Fuzzy query should not be directly used for search. Use $query->rewrite($index)'); - } - - - /** - * Execute query in context of index reader - * It also initializes necessary internal structures - * - * @param Zend_Search_Lucene_Interface $reader - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @throws Zend_Search_Lucene_Exception - */ - public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Fuzzy query should not be directly used for search. Use $query->rewrite($index)'); - } - - /** - * Get document ids likely matching the query - * - * It's an array with document ids as keys (performance considerations) - * - * @return array - * @throws Zend_Search_Lucene_Exception - */ - public function matchedDocs() - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Fuzzy query should not be directly used for search. Use $query->rewrite($index)'); - } - - /** - * Score specified document - * - * @param integer $docId - * @param Zend_Search_Lucene_Interface $reader - * @return float - * @throws Zend_Search_Lucene_Exception - */ - public function score($docId, Zend_Search_Lucene_Interface $reader) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Fuzzy query should not be directly used for search. Use $query->rewrite($index)'); - } - - /** - * Query specific matches highlighting - * - * @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) - */ - protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter) - { - $words = array(); - - // require_once 'Zend/Search/Lucene/Index/Term.php'; - $prefix = Zend_Search_Lucene_Index_Term::getPrefix($this->_term->text, $this->_prefixLength); - $prefixByteLength = strlen($prefix); - $prefixUtf8Length = Zend_Search_Lucene_Index_Term::getLength($prefix); - - $termLength = Zend_Search_Lucene_Index_Term::getLength($this->_term->text); - - $termRest = substr($this->_term->text, $prefixByteLength); - // we calculate length of the rest in bytes since levenshtein() is not UTF-8 compatible - $termRestLength = strlen($termRest); - - $scaleFactor = 1/(1 - $this->_minimumSimilarity); - - $docBody = $highlighter->getDocument()->getFieldUtf8Value('body'); - // require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($docBody, 'UTF-8'); - foreach ($tokens as $token) { - $termText = $token->getTermText(); - - if (substr($termText, 0, $prefixByteLength) == $prefix) { - // Calculate similarity - $target = substr($termText, $prefixByteLength); - - $maxDistance = isset($this->_maxDistances[strlen($target)])? - $this->_maxDistances[strlen($target)] : - $this->_calculateMaxDistance($prefixUtf8Length, $termRestLength, strlen($target)); - - if ($termRestLength == 0) { - // we don't have anything to compare. That means if we just add - // the letters for current term we get the new word - $similarity = (($prefixUtf8Length == 0)? 0 : 1 - strlen($target)/$prefixUtf8Length); - } else if (strlen($target) == 0) { - $similarity = (($prefixUtf8Length == 0)? 0 : 1 - $termRestLength/$prefixUtf8Length); - } else if ($maxDistance < abs($termRestLength - strlen($target))){ - //just adding the characters of term to target or vice-versa results in too many edits - //for example "pre" length is 3 and "prefixes" length is 8. We can see that - //given this optimal circumstance, the edit distance cannot be less than 5. - //which is 8-3 or more precisesly abs(3-8). - //if our maximum edit distance is 4, then we can discard this word - //without looking at it. - $similarity = 0; - } else { - $similarity = 1 - levenshtein($termRest, $target)/($prefixUtf8Length + min($termRestLength, strlen($target))); - } - - if ($similarity > $this->_minimumSimilarity) { - $words[] = $termText; - } - } - } - - $highlighter->highlight($words); - } - - /** - * Print a query - * - * @return string - */ - public function __toString() - { - // It's used only for query visualisation, so we don't care about characters escaping - return (($this->_term->field === null)? '' : $this->_term->field . ':') - . $this->_term->text . '~' - . (($this->_minimumSimilarity != self::DEFAULT_MIN_SIMILARITY)? round($this->_minimumSimilarity, 4) : '') - . (($this->getBoost() != 1)? '^' . round($this->getBoost(), 4) : ''); - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Insignificant.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Insignificant.php deleted file mode 100755 index 5029326b0d6630b8a28e2e1220ecd12892613436..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Insignificant.php +++ /dev/null @@ -1,139 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Query */ -// require_once 'Zend/Search/Lucene/Search/Query.php'; - - -/** - * The insignificant query returns empty result, but doesn't limit result set as a part of other queries - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Query_Insignificant extends Zend_Search_Lucene_Search_Query -{ - /** - * Re-write query into primitive queries in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function rewrite(Zend_Search_Lucene_Interface $index) - { - return $this; - } - - /** - * Optimize query in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function optimize(Zend_Search_Lucene_Interface $index) - { - return $this; - } - - /** - * Constructs an appropriate Weight implementation for this query. - * - * @param Zend_Search_Lucene_Interface $reader - * @return Zend_Search_Lucene_Search_Weight - */ - public function createWeight(Zend_Search_Lucene_Interface $reader) - { - // require_once 'Zend/Search/Lucene/Search/Weight/Empty.php'; - return new Zend_Search_Lucene_Search_Weight_Empty(); - } - - /** - * Execute query in context of index reader - * It also initializes necessary internal structures - * - * @param Zend_Search_Lucene_Interface $reader - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - */ - public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null) - { - // Do nothing - } - - /** - * Get document ids likely matching the query - * - * It's an array with document ids as keys (performance considerations) - * - * @return array - */ - public function matchedDocs() - { - return array(); - } - - /** - * Score specified document - * - * @param integer $docId - * @param Zend_Search_Lucene_Interface $reader - * @return float - */ - public function score($docId, Zend_Search_Lucene_Interface $reader) - { - return 0; - } - - /** - * Return query terms - * - * @return array - */ - public function getQueryTerms() - { - return array(); - } - - /** - * Query specific matches highlighting - * - * @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) - */ - protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter) - { - // Do nothing - } - - /** - * Print a query - * - * @return string - */ - public function __toString() - { - return '<InsignificantQuery>'; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/MultiTerm.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/MultiTerm.php deleted file mode 100755 index 01e864f28a0a03fbd0fe27d2e39d0b53a6368078..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/MultiTerm.php +++ /dev/null @@ -1,668 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Query */ -// require_once 'Zend/Search/Lucene/Search/Query.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Query_MultiTerm extends Zend_Search_Lucene_Search_Query -{ - - /** - * Terms to find. - * Array of Zend_Search_Lucene_Index_Term - * - * @var array - */ - private $_terms = array(); - - /** - * Term signs. - * If true then term is required. - * If false then term is prohibited. - * If null then term is neither prohibited, nor required - * - * If array is null then all terms are required - * - * @var array - */ - private $_signs; - - /** - * Result vector. - * - * @var array - */ - private $_resVector = null; - - /** - * Terms positions vectors. - * Array of Arrays: - * term1Id => (docId => freq, ...) - * term2Id => (docId => freq, ...) - * - * @var array - */ - private $_termsFreqs = array(); - - - /** - * A score factor based on the fraction of all query terms - * that a document contains. - * float for conjunction queries - * array of float for non conjunction queries - * - * @var mixed - */ - private $_coord = null; - - - /** - * Terms weights - * array of Zend_Search_Lucene_Search_Weight - * - * @var array - */ - private $_weights = array(); - - - /** - * Class constructor. Create a new multi-term query object. - * - * if $signs array is omitted then all terms are required - * it differs from addTerm() behavior, but should never be used - * - * @param array $terms Array of Zend_Search_Lucene_Index_Term objects - * @param array $signs Array of signs. Sign is boolean|null. - * @throws Zend_Search_Lucene_Exception - */ - public function __construct($terms = null, $signs = null) - { - if (is_array($terms)) { - // require_once 'Zend/Search/Lucene.php'; - if (count($terms) > Zend_Search_Lucene::getTermsPerQueryLimit()) { - throw new Zend_Search_Lucene_Exception('Terms per query limit is reached.'); - } - - $this->_terms = $terms; - - $this->_signs = null; - // Check if all terms are required - if (is_array($signs)) { - foreach ($signs as $sign ) { - if ($sign !== true) { - $this->_signs = $signs; - break; - } - } - } - } - } - - - /** - * Add a $term (Zend_Search_Lucene_Index_Term) to this query. - * - * The sign is specified as: - * TRUE - term is required - * FALSE - term is prohibited - * NULL - term is neither prohibited, nor required - * - * @param Zend_Search_Lucene_Index_Term $term - * @param boolean|null $sign - * @return void - */ - public function addTerm(Zend_Search_Lucene_Index_Term $term, $sign = null) { - if ($sign !== true || $this->_signs !== null) { // Skip, if all terms are required - if ($this->_signs === null) { // Check, If all previous terms are required - $this->_signs = array(); - foreach ($this->_terms as $prevTerm) { - $this->_signs[] = true; - } - } - $this->_signs[] = $sign; - } - - $this->_terms[] = $term; - } - - - /** - * Re-write query into primitive queries in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function rewrite(Zend_Search_Lucene_Interface $index) - { - if (count($this->_terms) == 0) { - // require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - return new Zend_Search_Lucene_Search_Query_Empty(); - } - - // Check, that all fields are qualified - $allQualified = true; - foreach ($this->_terms as $term) { - if ($term->field === null) { - $allQualified = false; - break; - } - } - - if ($allQualified) { - return $this; - } else { - /** transform multiterm query to boolean and apply rewrite() method to subqueries. */ - // require_once 'Zend/Search/Lucene/Search/Query/Boolean.php'; - $query = new Zend_Search_Lucene_Search_Query_Boolean(); - $query->setBoost($this->getBoost()); - - // require_once 'Zend/Search/Lucene/Search/Query/Term.php'; - foreach ($this->_terms as $termId => $term) { - $subquery = new Zend_Search_Lucene_Search_Query_Term($term); - - $query->addSubquery($subquery->rewrite($index), - ($this->_signs === null)? true : $this->_signs[$termId]); - } - - return $query; - } - } - - /** - * Optimize query in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function optimize(Zend_Search_Lucene_Interface $index) - { - $terms = $this->_terms; - $signs = $this->_signs; - - foreach ($terms as $id => $term) { - if (!$index->hasTerm($term)) { - if ($signs === null || $signs[$id] === true) { - // Term is required - // require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - return new Zend_Search_Lucene_Search_Query_Empty(); - } else { - // Term is optional or prohibited - // Remove it from terms and signs list - unset($terms[$id]); - unset($signs[$id]); - } - } - } - - // Check if all presented terms are prohibited - $allProhibited = true; - if ($signs === null) { - $allProhibited = false; - } else { - foreach ($signs as $sign) { - if ($sign !== false) { - $allProhibited = false; - break; - } - } - } - if ($allProhibited) { - // require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - return new Zend_Search_Lucene_Search_Query_Empty(); - } - - /** - * @todo make an optimization for repeated terms - * (they may have different signs) - */ - - if (count($terms) == 1) { - // It's already checked, that it's not a prohibited term - - // It's one term query with one required or optional element - // require_once 'Zend/Search/Lucene/Search/Query/Term.php'; - $optimizedQuery = new Zend_Search_Lucene_Search_Query_Term(reset($terms)); - $optimizedQuery->setBoost($this->getBoost()); - - return $optimizedQuery; - } - - if (count($terms) == 0) { - // require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - return new Zend_Search_Lucene_Search_Query_Empty(); - } - - $optimizedQuery = new Zend_Search_Lucene_Search_Query_MultiTerm($terms, $signs); - $optimizedQuery->setBoost($this->getBoost()); - return $optimizedQuery; - } - - - /** - * Returns query term - * - * @return array - */ - public function getTerms() - { - return $this->_terms; - } - - - /** - * Return terms signs - * - * @return array - */ - public function getSigns() - { - return $this->_signs; - } - - - /** - * Set weight for specified term - * - * @param integer $num - * @param Zend_Search_Lucene_Search_Weight_Term $weight - */ - public function setWeight($num, $weight) - { - $this->_weights[$num] = $weight; - } - - - /** - * Constructs an appropriate Weight implementation for this query. - * - * @param Zend_Search_Lucene_Interface $reader - * @return Zend_Search_Lucene_Search_Weight - */ - public function createWeight(Zend_Search_Lucene_Interface $reader) - { - // require_once 'Zend/Search/Lucene/Search/Weight/MultiTerm.php'; - $this->_weight = new Zend_Search_Lucene_Search_Weight_MultiTerm($this, $reader); - return $this->_weight; - } - - - /** - * Calculate result vector for Conjunction query - * (like '+something +another') - * - * @param Zend_Search_Lucene_Interface $reader - */ - private function _calculateConjunctionResult(Zend_Search_Lucene_Interface $reader) - { - $this->_resVector = null; - - if (count($this->_terms) == 0) { - $this->_resVector = array(); - } - - // Order terms by selectivity - $docFreqs = array(); - $ids = array(); - foreach ($this->_terms as $id => $term) { - $docFreqs[] = $reader->docFreq($term); - $ids[] = $id; // Used to keep original order for terms with the same selectivity and omit terms comparison - } - array_multisort($docFreqs, SORT_ASC, SORT_NUMERIC, - $ids, SORT_ASC, SORT_NUMERIC, - $this->_terms); - - // require_once 'Zend/Search/Lucene/Index/DocsFilter.php'; - $docsFilter = new Zend_Search_Lucene_Index_DocsFilter(); - foreach ($this->_terms as $termId => $term) { - $termDocs = $reader->termDocs($term, $docsFilter); - } - // Treat last retrieved docs vector as a result set - // (filter collects data for other terms) - $this->_resVector = array_flip($termDocs); - - foreach ($this->_terms as $termId => $term) { - $this->_termsFreqs[$termId] = $reader->termFreqs($term, $docsFilter); - } - - // ksort($this->_resVector, SORT_NUMERIC); - // Docs are returned ordered. Used algorithms doesn't change elements order. - } - - - /** - * Calculate result vector for non Conjunction query - * (like '+something -another') - * - * @param Zend_Search_Lucene_Interface $reader - */ - private function _calculateNonConjunctionResult(Zend_Search_Lucene_Interface $reader) - { - $requiredVectors = array(); - $requiredVectorsSizes = array(); - $requiredVectorsIds = array(); // is used to prevent arrays comparison - - $optional = array(); - $prohibited = array(); - - foreach ($this->_terms as $termId => $term) { - $termDocs = array_flip($reader->termDocs($term)); - - if ($this->_signs[$termId] === true) { - // required - $requiredVectors[] = $termDocs; - $requiredVectorsSizes[] = count($termDocs); - $requiredVectorsIds[] = $termId; - } elseif ($this->_signs[$termId] === false) { - // prohibited - // array union - $prohibited += $termDocs; - } else { - // neither required, nor prohibited - // array union - $optional += $termDocs; - } - - $this->_termsFreqs[$termId] = $reader->termFreqs($term); - } - - // sort resvectors in order of subquery cardinality increasing - array_multisort($requiredVectorsSizes, SORT_ASC, SORT_NUMERIC, - $requiredVectorsIds, SORT_ASC, SORT_NUMERIC, - $requiredVectors); - - $required = null; - foreach ($requiredVectors as $nextResVector) { - if($required === null) { - $required = $nextResVector; - } else { - //$required = array_intersect_key($required, $nextResVector); - - /** - * This code is used as workaround for array_intersect_key() slowness problem. - */ - $updatedVector = array(); - foreach ($required as $id => $value) { - if (isset($nextResVector[$id])) { - $updatedVector[$id] = $value; - } - } - $required = $updatedVector; - } - - if (count($required) == 0) { - // Empty result set, we don't need to check other terms - break; - } - } - - if ($required !== null) { - $this->_resVector = $required; - } else { - $this->_resVector = $optional; - } - - if (count($prohibited) != 0) { - // $this->_resVector = array_diff_key($this->_resVector, $prohibited); - - /** - * This code is used as workaround for array_diff_key() slowness problem. - */ - if (count($this->_resVector) < count($prohibited)) { - $updatedVector = $this->_resVector; - foreach ($this->_resVector as $id => $value) { - if (isset($prohibited[$id])) { - unset($updatedVector[$id]); - } - } - $this->_resVector = $updatedVector; - } else { - $updatedVector = $this->_resVector; - foreach ($prohibited as $id => $value) { - unset($updatedVector[$id]); - } - $this->_resVector = $updatedVector; - } - } - - ksort($this->_resVector, SORT_NUMERIC); - } - - - /** - * Score calculator for conjunction queries (all terms are required) - * - * @param integer $docId - * @param Zend_Search_Lucene_Interface $reader - * @return float - */ - public function _conjunctionScore($docId, Zend_Search_Lucene_Interface $reader) - { - if ($this->_coord === null) { - $this->_coord = $reader->getSimilarity()->coord(count($this->_terms), - count($this->_terms) ); - } - - $score = 0.0; - - foreach ($this->_terms as $termId => $term) { - /** - * We don't need to check that term freq is not 0 - * Score calculation is performed only for matched docs - */ - $score += $reader->getSimilarity()->tf($this->_termsFreqs[$termId][$docId]) * - $this->_weights[$termId]->getValue() * - $reader->norm($docId, $term->field); - } - - return $score * $this->_coord * $this->getBoost(); - } - - - /** - * Score calculator for non conjunction queries (not all terms are required) - * - * @param integer $docId - * @param Zend_Search_Lucene_Interface $reader - * @return float - */ - public function _nonConjunctionScore($docId, $reader) - { - if ($this->_coord === null) { - $this->_coord = array(); - - $maxCoord = 0; - foreach ($this->_signs as $sign) { - if ($sign !== false /* not prohibited */) { - $maxCoord++; - } - } - - for ($count = 0; $count <= $maxCoord; $count++) { - $this->_coord[$count] = $reader->getSimilarity()->coord($count, $maxCoord); - } - } - - $score = 0.0; - $matchedTerms = 0; - foreach ($this->_terms as $termId=>$term) { - // Check if term is - if ($this->_signs[$termId] !== false && // not prohibited - isset($this->_termsFreqs[$termId][$docId]) // matched - ) { - $matchedTerms++; - - /** - * We don't need to check that term freq is not 0 - * Score calculation is performed only for matched docs - */ - $score += - $reader->getSimilarity()->tf($this->_termsFreqs[$termId][$docId]) * - $this->_weights[$termId]->getValue() * - $reader->norm($docId, $term->field); - } - } - - return $score * $this->_coord[$matchedTerms] * $this->getBoost(); - } - - /** - * Execute query in context of index reader - * It also initializes necessary internal structures - * - * @param Zend_Search_Lucene_Interface $reader - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - */ - public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null) - { - if ($this->_signs === null) { - $this->_calculateConjunctionResult($reader); - } else { - $this->_calculateNonConjunctionResult($reader); - } - - // Initialize weight if it's not done yet - $this->_initWeight($reader); - } - - /** - * Get document ids likely matching the query - * - * It's an array with document ids as keys (performance considerations) - * - * @return array - */ - public function matchedDocs() - { - return $this->_resVector; - } - - /** - * Score specified document - * - * @param integer $docId - * @param Zend_Search_Lucene_Interface $reader - * @return float - */ - public function score($docId, Zend_Search_Lucene_Interface $reader) - { - if (isset($this->_resVector[$docId])) { - if ($this->_signs === null) { - return $this->_conjunctionScore($docId, $reader); - } else { - return $this->_nonConjunctionScore($docId, $reader); - } - } else { - return 0; - } - } - - /** - * Return query terms - * - * @return array - */ - public function getQueryTerms() - { - if ($this->_signs === null) { - return $this->_terms; - } - - $terms = array(); - - foreach ($this->_signs as $id => $sign) { - if ($sign !== false) { - $terms[] = $this->_terms[$id]; - } - } - - return $terms; - } - - /** - * Query specific matches highlighting - * - * @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) - */ - protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter) - { - $words = array(); - - if ($this->_signs === null) { - foreach ($this->_terms as $term) { - $words[] = $term->text; - } - } else { - foreach ($this->_signs as $id => $sign) { - if ($sign !== false) { - $words[] = $this->_terms[$id]->text; - } - } - } - - $highlighter->highlight($words); - } - - /** - * Print a query - * - * @return string - */ - public function __toString() - { - // It's used only for query visualisation, so we don't care about characters escaping - - $query = ''; - - foreach ($this->_terms as $id => $term) { - if ($id != 0) { - $query .= ' '; - } - - if ($this->_signs === null || $this->_signs[$id] === true) { - $query .= '+'; - } else if ($this->_signs[$id] === false) { - $query .= '-'; - } - - if ($term->field !== null) { - $query .= $term->field . ':'; - } - $query .= $term->text; - } - - if ($this->getBoost() != 1) { - $query = '(' . $query . ')^' . round($this->getBoost(), 4); - } - - return $query; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Phrase.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Phrase.php deleted file mode 100755 index 85b2f4f81247ea9a293def5217877208bffdc60a..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Phrase.php +++ /dev/null @@ -1,576 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Query */ -// require_once 'Zend/Search/Lucene/Search/Query.php'; - - -/** - * A Query that matches documents containing a particular sequence of terms. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Query_Phrase extends Zend_Search_Lucene_Search_Query -{ - /** - * Terms to find. - * Array of Zend_Search_Lucene_Index_Term objects. - * - * @var array - */ - private $_terms; - - /** - * Term positions (relative positions of terms within the phrase). - * Array of integers - * - * @var array - */ - private $_offsets; - - /** - * Sets the number of other words permitted between words in query phrase. - * If zero, then this is an exact phrase search. For larger values this works - * like a WITHIN or NEAR operator. - * - * The slop is in fact an edit-distance, where the units correspond to - * moves of terms in the query phrase out of position. For example, to switch - * the order of two words requires two moves (the first move places the words - * atop one another), so to permit re-orderings of phrases, the slop must be - * at least two. - * More exact matches are scored higher than sloppier matches, thus search - * results are sorted by exactness. - * - * The slop is zero by default, requiring exact matches. - * - * @var integer - */ - private $_slop; - - /** - * Result vector. - * - * @var array - */ - private $_resVector = null; - - /** - * Terms positions vectors. - * Array of Arrays: - * term1Id => (docId => array( pos1, pos2, ... ), ...) - * term2Id => (docId => array( pos1, pos2, ... ), ...) - * - * @var array - */ - private $_termsPositions = array(); - - /** - * Class constructor. Create a new prase query. - * - * @param string $field Field to search. - * @param array $terms Terms to search Array of strings. - * @param array $offsets Relative term positions. Array of integers. - * @throws Zend_Search_Lucene_Exception - */ - public function __construct($terms = null, $offsets = null, $field = null) - { - $this->_slop = 0; - - if (is_array($terms)) { - $this->_terms = array(); - // require_once 'Zend/Search/Lucene/Index/Term.php'; - foreach ($terms as $termId => $termText) { - $this->_terms[$termId] = ($field !== null)? new Zend_Search_Lucene_Index_Term($termText, $field): - new Zend_Search_Lucene_Index_Term($termText); - } - } else if ($terms === null) { - $this->_terms = array(); - } else { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('terms argument must be array of strings or null'); - } - - if (is_array($offsets)) { - if (count($this->_terms) != count($offsets)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('terms and offsets arguments must have the same size.'); - } - $this->_offsets = $offsets; - } else if ($offsets === null) { - $this->_offsets = array(); - foreach ($this->_terms as $termId => $term) { - $position = count($this->_offsets); - $this->_offsets[$termId] = $position; - } - } else { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('offsets argument must be array of strings or null'); - } - } - - /** - * Set slop - * - * @param integer $slop - */ - public function setSlop($slop) - { - $this->_slop = $slop; - } - - - /** - * Get slop - * - * @return integer - */ - public function getSlop() - { - return $this->_slop; - } - - - /** - * Adds a term to the end of the query phrase. - * The relative position of the term is specified explicitly or the one immediately - * after the last term added. - * - * @param Zend_Search_Lucene_Index_Term $term - * @param integer $position - */ - public function addTerm(Zend_Search_Lucene_Index_Term $term, $position = null) { - if ((count($this->_terms) != 0)&&(end($this->_terms)->field != $term->field)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('All phrase terms must be in the same field: ' . - $term->field . ':' . $term->text); - } - - $this->_terms[] = $term; - if ($position !== null) { - $this->_offsets[] = $position; - } else if (count($this->_offsets) != 0) { - $this->_offsets[] = end($this->_offsets) + 1; - } else { - $this->_offsets[] = 0; - } - } - - - /** - * Re-write query into primitive queries in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function rewrite(Zend_Search_Lucene_Interface $index) - { - if (count($this->_terms) == 0) { - // require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - return new Zend_Search_Lucene_Search_Query_Empty(); - } else if ($this->_terms[0]->field !== null) { - return $this; - } else { - // require_once 'Zend/Search/Lucene/Search/Query/Boolean.php'; - $query = new Zend_Search_Lucene_Search_Query_Boolean(); - $query->setBoost($this->getBoost()); - - foreach ($index->getFieldNames(true) as $fieldName) { - $subquery = new Zend_Search_Lucene_Search_Query_Phrase(); - $subquery->setSlop($this->getSlop()); - - // require_once 'Zend/Search/Lucene/Index/Term.php'; - foreach ($this->_terms as $termId => $term) { - $qualifiedTerm = new Zend_Search_Lucene_Index_Term($term->text, $fieldName); - - $subquery->addTerm($qualifiedTerm, $this->_offsets[$termId]); - } - - $query->addSubquery($subquery); - } - - return $query; - } - } - - /** - * Optimize query in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function optimize(Zend_Search_Lucene_Interface $index) - { - // Check, that index contains all phrase terms - foreach ($this->_terms as $term) { - if (!$index->hasTerm($term)) { - // require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - return new Zend_Search_Lucene_Search_Query_Empty(); - } - } - - if (count($this->_terms) == 1) { - // It's one term query - // require_once 'Zend/Search/Lucene/Search/Query/Term.php'; - $optimizedQuery = new Zend_Search_Lucene_Search_Query_Term(reset($this->_terms)); - $optimizedQuery->setBoost($this->getBoost()); - - return $optimizedQuery; - } - - if (count($this->_terms) == 0) { - // require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - return new Zend_Search_Lucene_Search_Query_Empty(); - } - - - return $this; - } - - /** - * Returns query term - * - * @return array - */ - public function getTerms() - { - return $this->_terms; - } - - - /** - * Set weight for specified term - * - * @param integer $num - * @param Zend_Search_Lucene_Search_Weight_Term $weight - */ - public function setWeight($num, $weight) - { - $this->_weights[$num] = $weight; - } - - - /** - * Constructs an appropriate Weight implementation for this query. - * - * @param Zend_Search_Lucene_Interface $reader - * @return Zend_Search_Lucene_Search_Weight - */ - public function createWeight(Zend_Search_Lucene_Interface $reader) - { - // require_once 'Zend/Search/Lucene/Search/Weight/Phrase.php'; - $this->_weight = new Zend_Search_Lucene_Search_Weight_Phrase($this, $reader); - return $this->_weight; - } - - - /** - * Score calculator for exact phrase queries (terms sequence is fixed) - * - * @param integer $docId - * @return float - */ - public function _exactPhraseFreq($docId) - { - $freq = 0; - - // Term Id with lowest cardinality - $lowCardTermId = null; - - // Calculate $lowCardTermId - foreach ($this->_terms as $termId => $term) { - if ($lowCardTermId === null || - count($this->_termsPositions[$termId][$docId]) < - count($this->_termsPositions[$lowCardTermId][$docId]) ) { - $lowCardTermId = $termId; - } - } - - // Walk through positions of the term with lowest cardinality - foreach ($this->_termsPositions[$lowCardTermId][$docId] as $lowCardPos) { - // We expect phrase to be found - $freq++; - - // Walk through other terms - foreach ($this->_terms as $termId => $term) { - if ($termId != $lowCardTermId) { - $expectedPosition = $lowCardPos + - ($this->_offsets[$termId] - - $this->_offsets[$lowCardTermId]); - - if (!in_array($expectedPosition, $this->_termsPositions[$termId][$docId])) { - $freq--; // Phrase wasn't found. - break; - } - } - } - } - - return $freq; - } - - /** - * Score calculator for sloppy phrase queries (terms sequence is fixed) - * - * @param integer $docId - * @param Zend_Search_Lucene_Interface $reader - * @return float - */ - public function _sloppyPhraseFreq($docId, Zend_Search_Lucene_Interface $reader) - { - $freq = 0; - - $phraseQueue = array(); - $phraseQueue[0] = array(); // empty phrase - $lastTerm = null; - - // Walk through the terms to create phrases. - foreach ($this->_terms as $termId => $term) { - $queueSize = count($phraseQueue); - $firstPass = true; - - // Walk through the term positions. - // Each term position produces a set of phrases. - foreach ($this->_termsPositions[$termId][$docId] as $termPosition ) { - if ($firstPass) { - for ($count = 0; $count < $queueSize; $count++) { - $phraseQueue[$count][$termId] = $termPosition; - } - } else { - for ($count = 0; $count < $queueSize; $count++) { - if ($lastTerm !== null && - abs( $termPosition - $phraseQueue[$count][$lastTerm] - - ($this->_offsets[$termId] - $this->_offsets[$lastTerm])) > $this->_slop) { - continue; - } - - $newPhraseId = count($phraseQueue); - $phraseQueue[$newPhraseId] = $phraseQueue[$count]; - $phraseQueue[$newPhraseId][$termId] = $termPosition; - } - - } - - $firstPass = false; - } - $lastTerm = $termId; - } - - - foreach ($phraseQueue as $phrasePos) { - $minDistance = null; - - for ($shift = -$this->_slop; $shift <= $this->_slop; $shift++) { - $distance = 0; - $start = reset($phrasePos) - reset($this->_offsets) + $shift; - - foreach ($this->_terms as $termId => $term) { - $distance += abs($phrasePos[$termId] - $this->_offsets[$termId] - $start); - - if($distance > $this->_slop) { - break; - } - } - - if ($minDistance === null || $distance < $minDistance) { - $minDistance = $distance; - } - } - - if ($minDistance <= $this->_slop) { - $freq += $reader->getSimilarity()->sloppyFreq($minDistance); - } - } - - return $freq; - } - - /** - * Execute query in context of index reader - * It also initializes necessary internal structures - * - * @param Zend_Search_Lucene_Interface $reader - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - */ - public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null) - { - $this->_resVector = null; - - if (count($this->_terms) == 0) { - $this->_resVector = array(); - } - - $resVectors = array(); - $resVectorsSizes = array(); - $resVectorsIds = array(); // is used to prevent arrays comparison - foreach ($this->_terms as $termId => $term) { - $resVectors[] = array_flip($reader->termDocs($term)); - $resVectorsSizes[] = count(end($resVectors)); - $resVectorsIds[] = $termId; - - $this->_termsPositions[$termId] = $reader->termPositions($term); - } - // sort resvectors in order of subquery cardinality increasing - array_multisort($resVectorsSizes, SORT_ASC, SORT_NUMERIC, - $resVectorsIds, SORT_ASC, SORT_NUMERIC, - $resVectors); - - foreach ($resVectors as $nextResVector) { - if($this->_resVector === null) { - $this->_resVector = $nextResVector; - } else { - //$this->_resVector = array_intersect_key($this->_resVector, $nextResVector); - - /** - * This code is used as workaround for array_intersect_key() slowness problem. - */ - $updatedVector = array(); - foreach ($this->_resVector as $id => $value) { - if (isset($nextResVector[$id])) { - $updatedVector[$id] = $value; - } - } - $this->_resVector = $updatedVector; - } - - if (count($this->_resVector) == 0) { - // Empty result set, we don't need to check other terms - break; - } - } - - // ksort($this->_resVector, SORT_NUMERIC); - // Docs are returned ordered. Used algorithm doesn't change elements order. - - // Initialize weight if it's not done yet - $this->_initWeight($reader); - } - - /** - * Get document ids likely matching the query - * - * It's an array with document ids as keys (performance considerations) - * - * @return array - */ - public function matchedDocs() - { - return $this->_resVector; - } - - /** - * Score specified document - * - * @param integer $docId - * @param Zend_Search_Lucene_Interface $reader - * @return float - */ - public function score($docId, Zend_Search_Lucene_Interface $reader) - { - if (isset($this->_resVector[$docId])) { - if ($this->_slop == 0) { - $freq = $this->_exactPhraseFreq($docId); - } else { - $freq = $this->_sloppyPhraseFreq($docId, $reader); - } - - if ($freq != 0) { - $tf = $reader->getSimilarity()->tf($freq); - $weight = $this->_weight->getValue(); - $norm = $reader->norm($docId, reset($this->_terms)->field); - - return $tf * $weight * $norm * $this->getBoost(); - } - - // Included in result, but culculated freq is zero - return 0; - } else { - return 0; - } - } - - /** - * Return query terms - * - * @return array - */ - public function getQueryTerms() - { - return $this->_terms; - } - - /** - * Query specific matches highlighting - * - * @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) - */ - protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter) - { - $words = array(); - foreach ($this->_terms as $term) { - $words[] = $term->text; - } - - $highlighter->highlight($words); - } - - /** - * Print a query - * - * @return string - */ - public function __toString() - { - // It's used only for query visualisation, so we don't care about characters escaping - if (isset($this->_terms[0]) && $this->_terms[0]->field !== null) { - $query = $this->_terms[0]->field . ':'; - } else { - $query = ''; - } - - $query .= '"'; - - foreach ($this->_terms as $id => $term) { - if ($id != 0) { - $query .= ' '; - } - $query .= $term->text; - } - - $query .= '"'; - - if ($this->_slop != 0) { - $query .= '~' . $this->_slop; - } - - if ($this->getBoost() != 1) { - $query .= '^' . round($this->getBoost(), 4); - } - - return $query; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Preprocessing.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Preprocessing.php deleted file mode 100755 index 6fb3e954918d48f0f3984ef28f57317aa50ce01e..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Preprocessing.php +++ /dev/null @@ -1,127 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Query */ -// require_once 'Zend/Search/Lucene/Search/Query.php'; - - -/** - * It's an internal abstract class intended to finalize ase a query processing after query parsing. - * This type of query is not actually involved into query execution. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @internal - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Search_Lucene_Search_Query_Preprocessing extends Zend_Search_Lucene_Search_Query -{ - /** - * Matched terms. - * - * Matched terms list. - * It's filled during rewrite operation and may be used for search result highlighting - * - * Array of Zend_Search_Lucene_Index_Term objects - * - * @var array - */ - protected $_matches = null; - - /** - * Optimize query in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function optimize(Zend_Search_Lucene_Interface $index) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('This query is not intended to be executed.'); - } - - /** - * Constructs an appropriate Weight implementation for this query. - * - * @param Zend_Search_Lucene_Interface $reader - * @return Zend_Search_Lucene_Search_Weight - */ - public function createWeight(Zend_Search_Lucene_Interface $reader) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('This query is not intended to be executed.'); - } - - /** - * Execute query in context of index reader - * It also initializes necessary internal structures - * - * @param Zend_Search_Lucene_Interface $reader - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - */ - public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('This query is not intended to be executed.'); - } - - /** - * Get document ids likely matching the query - * - * It's an array with document ids as keys (performance considerations) - * - * @return array - */ - public function matchedDocs() - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('This query is not intended to be executed.'); - } - - /** - * Score specified document - * - * @param integer $docId - * @param Zend_Search_Lucene_Interface $reader - * @return float - */ - public function score($docId, Zend_Search_Lucene_Interface $reader) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('This query is not intended to be executed.'); - } - - /** - * Return query terms - * - * @return array - */ - public function getQueryTerms() - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Rewrite operation has to be done before retrieving query terms.'); - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Preprocessing/Fuzzy.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Preprocessing/Fuzzy.php deleted file mode 100755 index 3b534526bb9b2936c8e16bbd7820002f9ad47542..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Preprocessing/Fuzzy.php +++ /dev/null @@ -1,287 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Query_Processing */ -// require_once 'Zend/Search/Lucene/Search/Query/Preprocessing.php'; - - -/** - * It's an internal abstract class intended to finalize ase a query processing after query parsing. - * This type of query is not actually involved into query execution. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @internal - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy extends Zend_Search_Lucene_Search_Query_Preprocessing -{ - /** - * word (query parser lexeme) to find. - * - * @var string - */ - private $_word; - - /** - * Word encoding (field name is always provided using UTF-8 encoding since it may be retrieved from index). - * - * @var string - */ - private $_encoding; - - - /** - * Field name. - * - * @var string - */ - private $_field; - - /** - * A value between 0 and 1 to set the required similarity - * between the query term and the matching terms. For example, for a - * _minimumSimilarity of 0.5 a term of the same length - * as the query term is considered similar to the query term if the edit distance - * between both terms is less than length(term)*0.5 - * - * @var float - */ - private $_minimumSimilarity; - - /** - * Class constructor. Create a new preprocessing object for prase query. - * - * @param string $word Non-tokenized word (query parser lexeme) to search. - * @param string $encoding Word encoding. - * @param string $fieldName Field name. - * @param float $minimumSimilarity minimum similarity - */ - public function __construct($word, $encoding, $fieldName, $minimumSimilarity) - { - $this->_word = $word; - $this->_encoding = $encoding; - $this->_field = $fieldName; - $this->_minimumSimilarity = $minimumSimilarity; - } - - /** - * Re-write query into primitive queries in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function rewrite(Zend_Search_Lucene_Interface $index) - { - if ($this->_field === null) { - // require_once 'Zend/Search/Lucene/Search/Query/Boolean.php'; - $query = new Zend_Search_Lucene_Search_Query_Boolean(); - - $hasInsignificantSubqueries = false; - - // require_once 'Zend/Search/Lucene.php'; - if (Zend_Search_Lucene::getDefaultSearchField() === null) { - $searchFields = $index->getFieldNames(true); - } else { - $searchFields = array(Zend_Search_Lucene::getDefaultSearchField()); - } - - // require_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Fuzzy.php'; - foreach ($searchFields as $fieldName) { - $subquery = new Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy($this->_word, - $this->_encoding, - $fieldName, - $this->_minimumSimilarity); - - $rewrittenSubquery = $subquery->rewrite($index); - - if ( !($rewrittenSubquery instanceof Zend_Search_Lucene_Search_Query_Insignificant || - $rewrittenSubquery instanceof Zend_Search_Lucene_Search_Query_Empty) ) { - $query->addSubquery($rewrittenSubquery); - } - - if ($rewrittenSubquery instanceof Zend_Search_Lucene_Search_Query_Insignificant) { - $hasInsignificantSubqueries = true; - } - } - - $subqueries = $query->getSubqueries(); - - if (count($subqueries) == 0) { - $this->_matches = array(); - if ($hasInsignificantSubqueries) { - // require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php'; - return new Zend_Search_Lucene_Search_Query_Insignificant(); - } else { - // require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - return new Zend_Search_Lucene_Search_Query_Empty(); - } - } - - if (count($subqueries) == 1) { - $query = reset($subqueries); - } - - $query->setBoost($this->getBoost()); - - $this->_matches = $query->getQueryTerms(); - return $query; - } - - // ------------------------------------- - // Recognize exact term matching (it corresponds to Keyword fields stored in the index) - // encoding is not used since we expect binary matching - // require_once 'Zend/Search/Lucene/Index/Term.php'; - $term = new Zend_Search_Lucene_Index_Term($this->_word, $this->_field); - if ($index->hasTerm($term)) { - // require_once 'Zend/Search/Lucene/Search/Query/Fuzzy.php'; - $query = new Zend_Search_Lucene_Search_Query_Fuzzy($term, $this->_minimumSimilarity); - $query->setBoost($this->getBoost()); - - // Get rewritten query. Important! It also fills terms matching container. - $rewrittenQuery = $query->rewrite($index); - $this->_matches = $query->getQueryTerms(); - - return $rewrittenQuery; - } - - - // ------------------------------------- - // Recognize wildcard queries - - /** @todo check for PCRE unicode support may be performed through Zend_Environment in some future */ - if (@preg_match('/\pL/u', 'a') == 1) { - $subPatterns = preg_split('/[*?]/u', iconv($this->_encoding, 'UTF-8', $this->_word)); - } else { - $subPatterns = preg_split('/[*?]/', $this->_word); - } - if (count($subPatterns) > 1) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('Fuzzy search doesn\'t support wildcards (except within Keyword fields).'); - } - - - // ------------------------------------- - // Recognize one-term multi-term and "insignificant" queries - // require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_word, $this->_encoding); - - if (count($tokens) == 0) { - $this->_matches = array(); - // require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php'; - return new Zend_Search_Lucene_Search_Query_Insignificant(); - } - - if (count($tokens) == 1) { - // require_once 'Zend/Search/Lucene/Index/Term.php'; - $term = new Zend_Search_Lucene_Index_Term($tokens[0]->getTermText(), $this->_field); - // require_once 'Zend/Search/Lucene/Search/Query/Fuzzy.php'; - $query = new Zend_Search_Lucene_Search_Query_Fuzzy($term, $this->_minimumSimilarity); - $query->setBoost($this->getBoost()); - - // Get rewritten query. Important! It also fills terms matching container. - $rewrittenQuery = $query->rewrite($index); - $this->_matches = $query->getQueryTerms(); - - return $rewrittenQuery; - } - - // Word is tokenized into several tokens - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('Fuzzy search is supported only for non-multiple word terms'); - } - - /** - * Query specific matches highlighting - * - * @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) - */ - protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter) - { - /** Skip fields detection. We don't need it, since we expect all fields presented in the HTML body and don't differentiate them */ - - /** Skip exact term matching recognition, keyword fields highlighting is not supported */ - - // ------------------------------------- - // Recognize wildcard queries - - /** @todo check for PCRE unicode support may be performed through Zend_Environment in some future */ - if (@preg_match('/\pL/u', 'a') == 1) { - $subPatterns = preg_split('/[*?]/u', iconv($this->_encoding, 'UTF-8', $this->_word)); - } else { - $subPatterns = preg_split('/[*?]/', $this->_word); - } - if (count($subPatterns) > 1) { - // Do nothing - return; - } - - - // ------------------------------------- - // Recognize one-term multi-term and "insignificant" queries - // require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_word, $this->_encoding); - if (count($tokens) == 0) { - // Do nothing - return; - } - if (count($tokens) == 1) { - // require_once 'Zend/Search/Lucene/Index/Term.php'; - $term = new Zend_Search_Lucene_Index_Term($tokens[0]->getTermText(), $this->_field); - // require_once 'Zend/Search/Lucene/Search/Query/Fuzzy.php'; - $query = new Zend_Search_Lucene_Search_Query_Fuzzy($term, $this->_minimumSimilarity); - - $query->_highlightMatches($highlighter); - return; - } - - // Word is tokenized into several tokens - // But fuzzy search is supported only for non-multiple word terms - // Do nothing - } - - /** - * Print a query - * - * @return string - */ - public function __toString() - { - // It's used only for query visualisation, so we don't care about characters escaping - if ($this->_field !== null) { - $query = $this->_field . ':'; - } else { - $query = ''; - } - - $query .= $this->_word; - - if ($this->getBoost() != 1) { - $query .= '^' . round($this->getBoost(), 4); - } - - return $query; - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Preprocessing/Phrase.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Preprocessing/Phrase.php deleted file mode 100755 index e8e06c4371cf829dc44283623de8eeed6a237931..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Preprocessing/Phrase.php +++ /dev/null @@ -1,270 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Query_Processing */ -// require_once 'Zend/Search/Lucene/Search/Query/Preprocessing.php'; - -/** - * It's an internal abstract class intended to finalize ase a query processing after query parsing. - * This type of query is not actually involved into query execution. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @internal - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Query_Preprocessing_Phrase extends Zend_Search_Lucene_Search_Query_Preprocessing -{ - /** - * Phrase to find. - * - * @var string - */ - private $_phrase; - - /** - * Phrase encoding (field name is always provided using UTF-8 encoding since it may be retrieved from index). - * - * @var string - */ - private $_phraseEncoding; - - - /** - * Field name. - * - * @var string - */ - private $_field; - - /** - * Sets the number of other words permitted between words in query phrase. - * If zero, then this is an exact phrase search. For larger values this works - * like a WITHIN or NEAR operator. - * - * The slop is in fact an edit-distance, where the units correspond to - * moves of terms in the query phrase out of position. For example, to switch - * the order of two words requires two moves (the first move places the words - * atop one another), so to permit re-orderings of phrases, the slop must be - * at least two. - * More exact matches are scored higher than sloppier matches, thus search - * results are sorted by exactness. - * - * The slop is zero by default, requiring exact matches. - * - * @var integer - */ - private $_slop; - - /** - * Class constructor. Create a new preprocessing object for prase query. - * - * @param string $phrase Phrase to search. - * @param string $phraseEncoding Phrase encoding. - * @param string $fieldName Field name. - */ - public function __construct($phrase, $phraseEncoding, $fieldName) - { - $this->_phrase = $phrase; - $this->_phraseEncoding = $phraseEncoding; - $this->_field = $fieldName; - } - - /** - * Set slop - * - * @param integer $slop - */ - public function setSlop($slop) - { - $this->_slop = $slop; - } - - - /** - * Get slop - * - * @return integer - */ - public function getSlop() - { - return $this->_slop; - } - - /** - * Re-write query into primitive queries in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function rewrite(Zend_Search_Lucene_Interface $index) - { -// Allow to use wildcards within phrases -// They are either removed by text analyzer or used as a part of keyword for keyword fields -// -// if (strpos($this->_phrase, '?') !== false || strpos($this->_phrase, '*') !== false) { -// // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; -// throw new Zend_Search_Lucene_Search_QueryParserException('Wildcards are only allowed in a single terms.'); -// } - - // Split query into subqueries if field name is not specified - if ($this->_field === null) { - // require_once 'Zend/Search/Lucene/Search/Query/Boolean.php'; - $query = new Zend_Search_Lucene_Search_Query_Boolean(); - $query->setBoost($this->getBoost()); - - // require_once 'Zend/Search/Lucene.php'; - if (Zend_Search_Lucene::getDefaultSearchField() === null) { - $searchFields = $index->getFieldNames(true); - } else { - $searchFields = array(Zend_Search_Lucene::getDefaultSearchField()); - } - - foreach ($searchFields as $fieldName) { - $subquery = new Zend_Search_Lucene_Search_Query_Preprocessing_Phrase($this->_phrase, - $this->_phraseEncoding, - $fieldName); - $subquery->setSlop($this->getSlop()); - - $query->addSubquery($subquery->rewrite($index)); - } - - $this->_matches = $query->getQueryTerms(); - return $query; - } - - // Recognize exact term matching (it corresponds to Keyword fields stored in the index) - // encoding is not used since we expect binary matching - // require_once 'Zend/Search/Lucene/Index/Term.php'; - $term = new Zend_Search_Lucene_Index_Term($this->_phrase, $this->_field); - if ($index->hasTerm($term)) { - // require_once 'Zend/Search/Lucene/Search/Query/Term.php'; - $query = new Zend_Search_Lucene_Search_Query_Term($term); - $query->setBoost($this->getBoost()); - - $this->_matches = $query->getQueryTerms(); - return $query; - } - - - // tokenize phrase using current analyzer and process it as a phrase query - // require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_phrase, $this->_phraseEncoding); - - if (count($tokens) == 0) { - $this->_matches = array(); - // require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php'; - return new Zend_Search_Lucene_Search_Query_Insignificant(); - } - - if (count($tokens) == 1) { - // require_once 'Zend/Search/Lucene/Index/Term.php'; - $term = new Zend_Search_Lucene_Index_Term($tokens[0]->getTermText(), $this->_field); - // require_once 'Zend/Search/Lucene/Search/Query/Term.php'; - $query = new Zend_Search_Lucene_Search_Query_Term($term); - $query->setBoost($this->getBoost()); - - $this->_matches = $query->getQueryTerms(); - return $query; - } - - //It's non-trivial phrase query - $position = -1; - // require_once 'Zend/Search/Lucene/Search/Query/Phrase.php'; - $query = new Zend_Search_Lucene_Search_Query_Phrase(); - // require_once 'Zend/Search/Lucene/Index/Term.php'; - foreach ($tokens as $token) { - $position += $token->getPositionIncrement(); - $term = new Zend_Search_Lucene_Index_Term($token->getTermText(), $this->_field); - $query->addTerm($term, $position); - $query->setSlop($this->getSlop()); - } - $this->_matches = $query->getQueryTerms(); - return $query; - } - - /** - * Query specific matches highlighting - * - * @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) - */ - protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter) - { - /** Skip fields detection. We don't need it, since we expect all fields presented in the HTML body and don't differentiate them */ - - /** Skip exact term matching recognition, keyword fields highlighting is not supported */ - - /** Skip wildcard queries recognition. Supported wildcards are removed by text analyzer */ - - - // tokenize phrase using current analyzer and process it as a phrase query - // require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_phrase, $this->_phraseEncoding); - - if (count($tokens) == 0) { - // Do nothing - return; - } - - if (count($tokens) == 1) { - $highlighter->highlight($tokens[0]->getTermText()); - return; - } - - //It's non-trivial phrase query - $words = array(); - foreach ($tokens as $token) { - $words[] = $token->getTermText(); - } - $highlighter->highlight($words); - } - - /** - * Print a query - * - * @return string - */ - public function __toString() - { - // It's used only for query visualisation, so we don't care about characters escaping - if ($this->_field !== null) { - $query = $this->_field . ':'; - } else { - $query = ''; - } - - $query .= '"' . $this->_phrase . '"'; - - if ($this->_slop != 0) { - $query .= '~' . $this->_slop; - } - - if ($this->getBoost() != 1) { - $query .= '^' . round($this->getBoost(), 4); - } - - return $query; - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Preprocessing/Term.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Preprocessing/Term.php deleted file mode 100755 index feaa89d9299fb1443ce6cfc84716c43927962b77..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Preprocessing/Term.php +++ /dev/null @@ -1,341 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Query_Processing */ -// require_once 'Zend/Search/Lucene/Search/Query/Preprocessing.php'; - - -/** - * It's an internal abstract class intended to finalize ase a query processing after query parsing. - * This type of query is not actually involved into query execution. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @internal - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Query_Preprocessing_Term extends Zend_Search_Lucene_Search_Query_Preprocessing -{ - /** - * word (query parser lexeme) to find. - * - * @var string - */ - private $_word; - - /** - * Word encoding (field name is always provided using UTF-8 encoding since it may be retrieved from index). - * - * @var string - */ - private $_encoding; - - - /** - * Field name. - * - * @var string - */ - private $_field; - - /** - * Class constructor. Create a new preprocessing object for prase query. - * - * @param string $word Non-tokenized word (query parser lexeme) to search. - * @param string $encoding Word encoding. - * @param string $fieldName Field name. - */ - public function __construct($word, $encoding, $fieldName) - { - $this->_word = $word; - $this->_encoding = $encoding; - $this->_field = $fieldName; - } - - /** - * Re-write query into primitive queries in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function rewrite(Zend_Search_Lucene_Interface $index) - { - if ($this->_field === null) { - // require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php'; - $query = new Zend_Search_Lucene_Search_Query_MultiTerm(); - $query->setBoost($this->getBoost()); - - $hasInsignificantSubqueries = false; - - // require_once 'Zend/Search/Lucene.php'; - if (Zend_Search_Lucene::getDefaultSearchField() === null) { - $searchFields = $index->getFieldNames(true); - } else { - $searchFields = array(Zend_Search_Lucene::getDefaultSearchField()); - } - - // require_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Term.php'; - foreach ($searchFields as $fieldName) { - $subquery = new Zend_Search_Lucene_Search_Query_Preprocessing_Term($this->_word, - $this->_encoding, - $fieldName); - $rewrittenSubquery = $subquery->rewrite($index); - foreach ($rewrittenSubquery->getQueryTerms() as $term) { - $query->addTerm($term); - } - - if ($rewrittenSubquery instanceof Zend_Search_Lucene_Search_Query_Insignificant) { - $hasInsignificantSubqueries = true; - } - } - - if (count($query->getTerms()) == 0) { - $this->_matches = array(); - if ($hasInsignificantSubqueries) { - // require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php'; - return new Zend_Search_Lucene_Search_Query_Insignificant(); - } else { - // require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - return new Zend_Search_Lucene_Search_Query_Empty(); - } - } - - $this->_matches = $query->getQueryTerms(); - return $query; - } - - // ------------------------------------- - // Recognize exact term matching (it corresponds to Keyword fields stored in the index) - // encoding is not used since we expect binary matching - // require_once 'Zend/Search/Lucene/Index/Term.php'; - $term = new Zend_Search_Lucene_Index_Term($this->_word, $this->_field); - if ($index->hasTerm($term)) { - // require_once 'Zend/Search/Lucene/Search/Query/Term.php'; - $query = new Zend_Search_Lucene_Search_Query_Term($term); - $query->setBoost($this->getBoost()); - - $this->_matches = $query->getQueryTerms(); - return $query; - } - - - // ------------------------------------- - // Recognize wildcard queries - - /** @todo check for PCRE unicode support may be performed through Zend_Environment in some future */ - if (@preg_match('/\pL/u', 'a') == 1) { - $word = iconv($this->_encoding, 'UTF-8', $this->_word); - $wildcardsPattern = '/[*?]/u'; - $subPatternsEncoding = 'UTF-8'; - } else { - $word = $this->_word; - $wildcardsPattern = '/[*?]/'; - $subPatternsEncoding = $this->_encoding; - } - - $subPatterns = preg_split($wildcardsPattern, $word, -1, PREG_SPLIT_OFFSET_CAPTURE); - - if (count($subPatterns) > 1) { - // Wildcard query is recognized - - $pattern = ''; - - // require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - foreach ($subPatterns as $id => $subPattern) { - // Append corresponding wildcard character to the pattern before each sub-pattern (except first) - if ($id != 0) { - $pattern .= $word[ $subPattern[1] - 1 ]; - } - - // Check if each subputtern is a single word in terms of current analyzer - $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($subPattern[0], $subPatternsEncoding); - if (count($tokens) > 1) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('Wildcard search is supported only for non-multiple word terms'); - } - foreach ($tokens as $token) { - $pattern .= $token->getTermText(); - } - } - - // require_once 'Zend/Search/Lucene/Index/Term.php'; - $term = new Zend_Search_Lucene_Index_Term($pattern, $this->_field); - // require_once 'Zend/Search/Lucene/Search/Query/Wildcard.php'; - $query = new Zend_Search_Lucene_Search_Query_Wildcard($term); - $query->setBoost($this->getBoost()); - - // Get rewritten query. Important! It also fills terms matching container. - $rewrittenQuery = $query->rewrite($index); - $this->_matches = $query->getQueryTerms(); - - return $rewrittenQuery; - } - - - // ------------------------------------- - // Recognize one-term multi-term and "insignificant" queries - // require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_word, $this->_encoding); - - if (count($tokens) == 0) { - $this->_matches = array(); - // require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php'; - return new Zend_Search_Lucene_Search_Query_Insignificant(); - } - - if (count($tokens) == 1) { - // require_once 'Zend/Search/Lucene/Index/Term.php'; - $term = new Zend_Search_Lucene_Index_Term($tokens[0]->getTermText(), $this->_field); - // require_once 'Zend/Search/Lucene/Search/Query/Term.php'; - $query = new Zend_Search_Lucene_Search_Query_Term($term); - $query->setBoost($this->getBoost()); - - $this->_matches = $query->getQueryTerms(); - return $query; - } - - //It's not insignificant or one term query - // require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php'; - $query = new Zend_Search_Lucene_Search_Query_MultiTerm(); - - /** - * @todo Process $token->getPositionIncrement() to support stemming, synonyms and other - * analizer design features - */ - // require_once 'Zend/Search/Lucene/Index/Term.php'; - foreach ($tokens as $token) { - $term = new Zend_Search_Lucene_Index_Term($token->getTermText(), $this->_field); - $query->addTerm($term, true); // all subterms are required - } - - $query->setBoost($this->getBoost()); - - $this->_matches = $query->getQueryTerms(); - return $query; - } - - /** - * Query specific matches highlighting - * - * @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) - */ - protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter) - { - /** Skip fields detection. We don't need it, since we expect all fields presented in the HTML body and don't differentiate them */ - - /** Skip exact term matching recognition, keyword fields highlighting is not supported */ - - // ------------------------------------- - // Recognize wildcard queries - /** @todo check for PCRE unicode support may be performed through Zend_Environment in some future */ - if (@preg_match('/\pL/u', 'a') == 1) { - $word = iconv($this->_encoding, 'UTF-8', $this->_word); - $wildcardsPattern = '/[*?]/u'; - $subPatternsEncoding = 'UTF-8'; - } else { - $word = $this->_word; - $wildcardsPattern = '/[*?]/'; - $subPatternsEncoding = $this->_encoding; - } - $subPatterns = preg_split($wildcardsPattern, $word, -1, PREG_SPLIT_OFFSET_CAPTURE); - if (count($subPatterns) > 1) { - // Wildcard query is recognized - - $pattern = ''; - - // require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - foreach ($subPatterns as $id => $subPattern) { - // Append corresponding wildcard character to the pattern before each sub-pattern (except first) - if ($id != 0) { - $pattern .= $word[ $subPattern[1] - 1 ]; - } - - // Check if each subputtern is a single word in terms of current analyzer - $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($subPattern[0], $subPatternsEncoding); - if (count($tokens) > 1) { - // Do nothing (nothing is highlighted) - return; - } - foreach ($tokens as $token) { - $pattern .= $token->getTermText(); - } - } - - // require_once 'Zend/Search/Lucene/Index/Term.php'; - $term = new Zend_Search_Lucene_Index_Term($pattern, $this->_field); - // require_once 'Zend/Search/Lucene/Search/Query/Wildcard.php'; - $query = new Zend_Search_Lucene_Search_Query_Wildcard($term); - - $query->_highlightMatches($highlighter); - return; - } - - - // ------------------------------------- - // Recognize one-term multi-term and "insignificant" queries - // require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_word, $this->_encoding); - - if (count($tokens) == 0) { - // Do nothing - return; - } - - if (count($tokens) == 1) { - $highlighter->highlight($tokens[0]->getTermText()); - return; - } - - //It's not insignificant or one term query - $words = array(); - foreach ($tokens as $token) { - $words[] = $token->getTermText(); - } - $highlighter->highlight($words); - } - - /** - * Print a query - * - * @return string - */ - public function __toString() - { - // It's used only for query visualisation, so we don't care about characters escaping - if ($this->_field !== null) { - $query = $this->_field . ':'; - } else { - $query = ''; - } - - $query .= $this->_word; - - if ($this->getBoost() != 1) { - $query .= '^' . round($this->getBoost(), 4); - } - - return $query; - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Range.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Range.php deleted file mode 100755 index 441fe3a607bdf27977d1fad336f3aae137eea4ef..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Range.php +++ /dev/null @@ -1,377 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Query */ -// require_once 'Zend/Search/Lucene/Search/Query.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Query_Range extends Zend_Search_Lucene_Search_Query -{ - /** - * Lower term. - * - * @var Zend_Search_Lucene_Index_Term - */ - private $_lowerTerm; - - /** - * Upper term. - * - * @var Zend_Search_Lucene_Index_Term - */ - private $_upperTerm; - - - /** - * Search field - * - * @var string - */ - private $_field; - - /** - * Inclusive - * - * @var boolean - */ - private $_inclusive; - - /** - * Matched terms. - * - * Matched terms list. - * It's filled during the search (rewrite operation) and may be used for search result - * post-processing - * - * Array of Zend_Search_Lucene_Index_Term objects - * - * @var array - */ - private $_matches = null; - - - /** - * Zend_Search_Lucene_Search_Query_Range constructor. - * - * @param Zend_Search_Lucene_Index_Term|null $lowerTerm - * @param Zend_Search_Lucene_Index_Term|null $upperTerm - * @param boolean $inclusive - * @throws Zend_Search_Lucene_Exception - */ - public function __construct($lowerTerm, $upperTerm, $inclusive) - { - if ($lowerTerm === null && $upperTerm === null) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('At least one term must be non-null'); - } - if ($lowerTerm !== null && $upperTerm !== null && $lowerTerm->field != $upperTerm->field) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Both terms must be for the same field'); - } - - $this->_field = ($lowerTerm !== null)? $lowerTerm->field : $upperTerm->field; - $this->_lowerTerm = $lowerTerm; - $this->_upperTerm = $upperTerm; - $this->_inclusive = $inclusive; - } - - /** - * Get query field name - * - * @return string|null - */ - public function getField() - { - return $this->_field; - } - - /** - * Get lower term - * - * @return Zend_Search_Lucene_Index_Term|null - */ - public function getLowerTerm() - { - return $this->_lowerTerm; - } - - /** - * Get upper term - * - * @return Zend_Search_Lucene_Index_Term|null - */ - public function getUpperTerm() - { - return $this->_upperTerm; - } - - /** - * Get upper term - * - * @return boolean - */ - public function isInclusive() - { - return $this->_inclusive; - } - - /** - * Re-write query into primitive queries in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function rewrite(Zend_Search_Lucene_Interface $index) - { - $this->_matches = array(); - - if ($this->_field === null) { - // Search through all fields - $fields = $index->getFieldNames(true /* indexed fields list */); - } else { - $fields = array($this->_field); - } - - // require_once 'Zend/Search/Lucene.php'; - $maxTerms = Zend_Search_Lucene::getTermsPerQueryLimit(); - foreach ($fields as $field) { - $index->resetTermsStream(); - - // require_once 'Zend/Search/Lucene/Index/Term.php'; - if ($this->_lowerTerm !== null) { - $lowerTerm = new Zend_Search_Lucene_Index_Term($this->_lowerTerm->text, $field); - - $index->skipTo($lowerTerm); - - if (!$this->_inclusive && - $index->currentTerm() == $lowerTerm) { - // Skip lower term - $index->nextTerm(); - } - } else { - $index->skipTo(new Zend_Search_Lucene_Index_Term('', $field)); - } - - - if ($this->_upperTerm !== null) { - // Walk up to the upper term - $upperTerm = new Zend_Search_Lucene_Index_Term($this->_upperTerm->text, $field); - - while ($index->currentTerm() !== null && - $index->currentTerm()->field == $field && - strcmp($index->currentTerm()->text, $upperTerm->text) < 0) { - $this->_matches[] = $index->currentTerm(); - - if ($maxTerms != 0 && count($this->_matches) > $maxTerms) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Terms per query limit is reached.'); - } - - $index->nextTerm(); - } - - if ($this->_inclusive && $index->currentTerm() == $upperTerm) { - // Include upper term into result - $this->_matches[] = $upperTerm; - } - } else { - // Walk up to the end of field data - while ($index->currentTerm() !== null && $index->currentTerm()->field == $field) { - $this->_matches[] = $index->currentTerm(); - - if ($maxTerms != 0 && count($this->_matches) > $maxTerms) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Terms per query limit is reached.'); - } - - $index->nextTerm(); - } - } - - $index->closeTermsStream(); - } - - if (count($this->_matches) == 0) { - // require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - return new Zend_Search_Lucene_Search_Query_Empty(); - } else if (count($this->_matches) == 1) { - // require_once 'Zend/Search/Lucene/Search/Query/Term.php'; - return new Zend_Search_Lucene_Search_Query_Term(reset($this->_matches)); - } else { - // require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php'; - $rewrittenQuery = new Zend_Search_Lucene_Search_Query_MultiTerm(); - - foreach ($this->_matches as $matchedTerm) { - $rewrittenQuery->addTerm($matchedTerm); - } - - return $rewrittenQuery; - } - } - - /** - * Optimize query in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function optimize(Zend_Search_Lucene_Interface $index) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Range query should not be directly used for search. Use $query->rewrite($index)'); - } - - /** - * Return query terms - * - * @return array - * @throws Zend_Search_Lucene_Exception - */ - public function getQueryTerms() - { - if ($this->_matches === null) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Search or rewrite operations have to be performed before.'); - } - - return $this->_matches; - } - - /** - * Constructs an appropriate Weight implementation for this query. - * - * @param Zend_Search_Lucene_Interface $reader - * @return Zend_Search_Lucene_Search_Weight - * @throws Zend_Search_Lucene_Exception - */ - public function createWeight(Zend_Search_Lucene_Interface $reader) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Range query should not be directly used for search. Use $query->rewrite($index)'); - } - - - /** - * Execute query in context of index reader - * It also initializes necessary internal structures - * - * @param Zend_Search_Lucene_Interface $reader - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @throws Zend_Search_Lucene_Exception - */ - public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Range query should not be directly used for search. Use $query->rewrite($index)'); - } - - /** - * Get document ids likely matching the query - * - * It's an array with document ids as keys (performance considerations) - * - * @return array - * @throws Zend_Search_Lucene_Exception - */ - public function matchedDocs() - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Range query should not be directly used for search. Use $query->rewrite($index)'); - } - - /** - * Score specified document - * - * @param integer $docId - * @param Zend_Search_Lucene_Interface $reader - * @return float - * @throws Zend_Search_Lucene_Exception - */ - public function score($docId, Zend_Search_Lucene_Interface $reader) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Range query should not be directly used for search. Use $query->rewrite($index)'); - } - - /** - * Query specific matches highlighting - * - * @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) - */ - protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter) - { - $words = array(); - - $docBody = $highlighter->getDocument()->getFieldUtf8Value('body'); - // require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($docBody, 'UTF-8'); - - $lowerTermText = ($this->_lowerTerm !== null)? $this->_lowerTerm->text : null; - $upperTermText = ($this->_upperTerm !== null)? $this->_upperTerm->text : null; - - if ($this->_inclusive) { - foreach ($tokens as $token) { - $termText = $token->getTermText(); - if (($lowerTermText == null || $lowerTermText <= $termText) && - ($upperTermText == null || $termText <= $upperTermText)) { - $words[] = $termText; - } - } - } else { - foreach ($tokens as $token) { - $termText = $token->getTermText(); - if (($lowerTermText == null || $lowerTermText < $termText) && - ($upperTermText == null || $termText < $upperTermText)) { - $words[] = $termText; - } - } - } - - $highlighter->highlight($words); - } - - /** - * Print a query - * - * @return string - */ - public function __toString() - { - // It's used only for query visualisation, so we don't care about characters escaping - return (($this->_field === null)? '' : $this->_field . ':') - . (($this->_inclusive)? '[' : '{') - . (($this->_lowerTerm !== null)? $this->_lowerTerm->text : 'null') - . ' TO ' - . (($this->_upperTerm !== null)? $this->_upperTerm->text : 'null') - . (($this->_inclusive)? ']' : '}') - . (($this->getBoost() != 1)? '^' . round($this->getBoost(), 4) : ''); - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Term.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Term.php deleted file mode 100755 index 40080d8873359434266a074ae47765e81d0311e1..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Term.php +++ /dev/null @@ -1,228 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Query */ -// require_once 'Zend/Search/Lucene/Search/Query.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Query_Term extends Zend_Search_Lucene_Search_Query -{ - /** - * Term to find. - * - * @var Zend_Search_Lucene_Index_Term - */ - private $_term; - - /** - * Documents vector. - * - * @var array - */ - private $_docVector = null; - - /** - * Term freqs vector. - * array(docId => freq, ...) - * - * @var array - */ - private $_termFreqs; - - - /** - * Zend_Search_Lucene_Search_Query_Term constructor - * - * @param Zend_Search_Lucene_Index_Term $term - * @param boolean $sign - */ - public function __construct(Zend_Search_Lucene_Index_Term $term) - { - $this->_term = $term; - } - - /** - * Re-write query into primitive queries in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function rewrite(Zend_Search_Lucene_Interface $index) - { - if ($this->_term->field != null) { - return $this; - } else { - // require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php'; - $query = new Zend_Search_Lucene_Search_Query_MultiTerm(); - $query->setBoost($this->getBoost()); - - // require_once 'Zend/Search/Lucene/Index/Term.php'; - foreach ($index->getFieldNames(true) as $fieldName) { - $term = new Zend_Search_Lucene_Index_Term($this->_term->text, $fieldName); - - $query->addTerm($term); - } - - return $query->rewrite($index); - } - } - - /** - * Optimize query in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function optimize(Zend_Search_Lucene_Interface $index) - { - // Check, that index contains specified term - if (!$index->hasTerm($this->_term)) { - // require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - return new Zend_Search_Lucene_Search_Query_Empty(); - } - - return $this; - } - - - /** - * Constructs an appropriate Weight implementation for this query. - * - * @param Zend_Search_Lucene_Interface $reader - * @return Zend_Search_Lucene_Search_Weight - */ - public function createWeight(Zend_Search_Lucene_Interface $reader) - { - // require_once 'Zend/Search/Lucene/Search/Weight/Term.php'; - $this->_weight = new Zend_Search_Lucene_Search_Weight_Term($this->_term, $this, $reader); - return $this->_weight; - } - - /** - * Execute query in context of index reader - * It also initializes necessary internal structures - * - * @param Zend_Search_Lucene_Interface $reader - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - */ - public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null) - { - $this->_docVector = array_flip($reader->termDocs($this->_term, $docsFilter)); - $this->_termFreqs = $reader->termFreqs($this->_term, $docsFilter); - - // Initialize weight if it's not done yet - $this->_initWeight($reader); - } - - /** - * Get document ids likely matching the query - * - * It's an array with document ids as keys (performance considerations) - * - * @return array - */ - public function matchedDocs() - { - return $this->_docVector; - } - - /** - * Score specified document - * - * @param integer $docId - * @param Zend_Search_Lucene_Interface $reader - * @return float - */ - public function score($docId, Zend_Search_Lucene_Interface $reader) - { - if (isset($this->_docVector[$docId])) { - return $reader->getSimilarity()->tf($this->_termFreqs[$docId]) * - $this->_weight->getValue() * - $reader->norm($docId, $this->_term->field) * - $this->getBoost(); - } else { - return 0; - } - } - - /** - * Return query terms - * - * @return array - */ - public function getQueryTerms() - { - return array($this->_term); - } - - /** - * Return query term - * - * @return Zend_Search_Lucene_Index_Term - */ - public function getTerm() - { - return $this->_term; - } - - /** - * Query specific matches highlighting - * - * @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) - */ - protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter) - { - $highlighter->highlight($this->_term->text); - } - - /** - * Print a query - * - * @return string - */ - public function __toString() - { - // It's used only for query visualisation, so we don't care about characters escaping - if ($this->_term->field !== null) { - $query = $this->_term->field . ':'; - } else { - $query = ''; - } - - $query .= $this->_term->text; - - if ($this->getBoost() != 1) { - $query = $query . '^' . round($this->getBoost(), 4); - } - - return $query; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Wildcard.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Wildcard.php deleted file mode 100755 index a22b4aa097fa0e92918c40377078b9dacef2d458..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Query/Wildcard.php +++ /dev/null @@ -1,362 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Query */ -// require_once 'Zend/Search/Lucene/Search/Query.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Query_Wildcard extends Zend_Search_Lucene_Search_Query -{ - /** - * Search pattern. - * - * Field has to be fully specified or has to be null - * Text may contain '*' or '?' symbols - * - * @var Zend_Search_Lucene_Index_Term - */ - private $_pattern; - - /** - * Matched terms. - * - * Matched terms list. - * It's filled during the search (rewrite operation) and may be used for search result - * post-processing - * - * Array of Zend_Search_Lucene_Index_Term objects - * - * @var array - */ - private $_matches = null; - - /** - * Minimum term prefix length (number of minimum non-wildcard characters) - * - * @var integer - */ - private static $_minPrefixLength = 3; - - /** - * Zend_Search_Lucene_Search_Query_Wildcard constructor. - * - * @param Zend_Search_Lucene_Index_Term $pattern - */ - public function __construct(Zend_Search_Lucene_Index_Term $pattern) - { - $this->_pattern = $pattern; - } - - /** - * Get minimum prefix length - * - * @return integer - */ - public static function getMinPrefixLength() - { - return self::$_minPrefixLength; - } - - /** - * Set minimum prefix length - * - * @param integer $minPrefixLength - */ - public static function setMinPrefixLength($minPrefixLength) - { - self::$_minPrefixLength = $minPrefixLength; - } - - /** - * Get terms prefix - * - * @param string $word - * @return string - */ - private static function _getPrefix($word) - { - $questionMarkPosition = strpos($word, '?'); - $astrericPosition = strpos($word, '*'); - - if ($questionMarkPosition !== false) { - if ($astrericPosition !== false) { - return substr($word, 0, min($questionMarkPosition, $astrericPosition)); - } - - return substr($word, 0, $questionMarkPosition); - } else if ($astrericPosition !== false) { - return substr($word, 0, $astrericPosition); - } - - return $word; - } - - /** - * Re-write query into primitive queries in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - * @throws Zend_Search_Lucene_Exception - */ - public function rewrite(Zend_Search_Lucene_Interface $index) - { - $this->_matches = array(); - - if ($this->_pattern->field === null) { - // Search through all fields - $fields = $index->getFieldNames(true /* indexed fields list */); - } else { - $fields = array($this->_pattern->field); - } - - $prefix = self::_getPrefix($this->_pattern->text); - $prefixLength = strlen($prefix); - $matchExpression = '/^' . str_replace(array('\\?', '\\*'), array('.', '.*') , preg_quote($this->_pattern->text, '/')) . '$/'; - - if ($prefixLength < self::$_minPrefixLength) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('At least ' . self::$_minPrefixLength . ' non-wildcard characters are required at the beginning of pattern.'); - } - - /** @todo check for PCRE unicode support may be performed through Zend_Environment in some future */ - if (@preg_match('/\pL/u', 'a') == 1) { - // PCRE unicode support is turned on - // add Unicode modifier to the match expression - $matchExpression .= 'u'; - } - - $maxTerms = Zend_Search_Lucene::getTermsPerQueryLimit(); - foreach ($fields as $field) { - $index->resetTermsStream(); - - // require_once 'Zend/Search/Lucene/Index/Term.php'; - if ($prefix != '') { - $index->skipTo(new Zend_Search_Lucene_Index_Term($prefix, $field)); - - while ($index->currentTerm() !== null && - $index->currentTerm()->field == $field && - substr($index->currentTerm()->text, 0, $prefixLength) == $prefix) { - if (preg_match($matchExpression, $index->currentTerm()->text) === 1) { - $this->_matches[] = $index->currentTerm(); - - if ($maxTerms != 0 && count($this->_matches) > $maxTerms) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Terms per query limit is reached.'); - } - } - - $index->nextTerm(); - } - } else { - $index->skipTo(new Zend_Search_Lucene_Index_Term('', $field)); - - while ($index->currentTerm() !== null && $index->currentTerm()->field == $field) { - if (preg_match($matchExpression, $index->currentTerm()->text) === 1) { - $this->_matches[] = $index->currentTerm(); - - if ($maxTerms != 0 && count($this->_matches) > $maxTerms) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Terms per query limit is reached.'); - } - } - - $index->nextTerm(); - } - } - - $index->closeTermsStream(); - } - - if (count($this->_matches) == 0) { - // require_once 'Zend/Search/Lucene/Search/Query/Empty.php'; - return new Zend_Search_Lucene_Search_Query_Empty(); - } else if (count($this->_matches) == 1) { - // require_once 'Zend/Search/Lucene/Search/Query/Term.php'; - return new Zend_Search_Lucene_Search_Query_Term(reset($this->_matches)); - } else { - // require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php'; - $rewrittenQuery = new Zend_Search_Lucene_Search_Query_MultiTerm(); - - foreach ($this->_matches as $matchedTerm) { - $rewrittenQuery->addTerm($matchedTerm); - } - - return $rewrittenQuery; - } - } - - /** - * Optimize query in the context of specified index - * - * @param Zend_Search_Lucene_Interface $index - * @return Zend_Search_Lucene_Search_Query - */ - public function optimize(Zend_Search_Lucene_Interface $index) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)'); - } - - - /** - * Returns query pattern - * - * @return Zend_Search_Lucene_Index_Term - */ - public function getPattern() - { - return $this->_pattern; - } - - - /** - * Return query terms - * - * @return array - * @throws Zend_Search_Lucene_Exception - */ - public function getQueryTerms() - { - if ($this->_matches === null) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Search has to be performed first to get matched terms'); - } - - return $this->_matches; - } - - /** - * Constructs an appropriate Weight implementation for this query. - * - * @param Zend_Search_Lucene_Interface $reader - * @return Zend_Search_Lucene_Search_Weight - * @throws Zend_Search_Lucene_Exception - */ - public function createWeight(Zend_Search_Lucene_Interface $reader) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)'); - } - - - /** - * Execute query in context of index reader - * It also initializes necessary internal structures - * - * @param Zend_Search_Lucene_Interface $reader - * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter - * @throws Zend_Search_Lucene_Exception - */ - public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)'); - } - - /** - * Get document ids likely matching the query - * - * It's an array with document ids as keys (performance considerations) - * - * @return array - * @throws Zend_Search_Lucene_Exception - */ - public function matchedDocs() - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)'); - } - - /** - * Score specified document - * - * @param integer $docId - * @param Zend_Search_Lucene_Interface $reader - * @return float - * @throws Zend_Search_Lucene_Exception - */ - public function score($docId, Zend_Search_Lucene_Interface $reader) - { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Wildcard query should not be directly used for search. Use $query->rewrite($index)'); - } - - /** - * Query specific matches highlighting - * - * @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) - */ - protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter) - { - $words = array(); - - $matchExpression = '/^' . str_replace(array('\\?', '\\*'), array('.', '.*') , preg_quote($this->_pattern->text, '/')) . '$/'; - if (@preg_match('/\pL/u', 'a') == 1) { - // PCRE unicode support is turned on - // add Unicode modifier to the match expression - $matchExpression .= 'u'; - } - - $docBody = $highlighter->getDocument()->getFieldUtf8Value('body'); - // require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($docBody, 'UTF-8'); - foreach ($tokens as $token) { - if (preg_match($matchExpression, $token->getTermText()) === 1) { - $words[] = $token->getTermText(); - } - } - - $highlighter->highlight($words); - } - - /** - * Print a query - * - * @return string - */ - public function __toString() - { - // It's used only for query visualisation, so we don't care about characters escaping - if ($this->_pattern->field !== null) { - $query = $this->_pattern->field . ':'; - } else { - $query = ''; - } - - $query .= $this->_pattern->text; - - if ($this->getBoost() != 1) { - $query = $query . '^' . round($this->getBoost(), 4); - } - - return $query; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryEntry.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryEntry.php deleted file mode 100755 index 5214a40d08a6c59edc6f400f91171eab208035e2..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryEntry.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Search_Lucene_Search_QueryEntry -{ - /** - * Query entry boost factor - * - * @var float - */ - protected $_boost = 1.0; - - - /** - * Process modifier ('~') - * - * @param mixed $parameter - */ - abstract public function processFuzzyProximityModifier($parameter = null); - - - /** - * Transform entry to a subquery - * - * @param string $encoding - * @return Zend_Search_Lucene_Search_Query - */ - abstract public function getQuery($encoding); - - /** - * Boost query entry - * - * @param float $boostFactor - */ - public function boost($boostFactor) - { - $this->_boost *= $boostFactor; - } - - -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryEntry/Phrase.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryEntry/Phrase.php deleted file mode 100755 index 400ab3876620db814046a0a8d41c2b1f9e4f4673..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryEntry/Phrase.php +++ /dev/null @@ -1,116 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_Search_QueryEntry */ -// require_once 'Zend/Search/Lucene/Search/QueryEntry.php'; - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_QueryEntry_Phrase extends Zend_Search_Lucene_Search_QueryEntry -{ - /** - * Phrase value - * - * @var string - */ - private $_phrase; - - /** - * Field - * - * @var string|null - */ - private $_field; - - - /** - * Proximity phrase query - * - * @var boolean - */ - private $_proximityQuery = false; - - /** - * Words distance, used for proximiti queries - * - * @var integer - */ - private $_wordsDistance = 0; - - - /** - * Object constractor - * - * @param string $phrase - * @param string $field - */ - public function __construct($phrase, $field) - { - $this->_phrase = $phrase; - $this->_field = $field; - } - - /** - * Process modifier ('~') - * - * @param mixed $parameter - */ - public function processFuzzyProximityModifier($parameter = null) - { - $this->_proximityQuery = true; - - if ($parameter !== null) { - $this->_wordsDistance = $parameter; - } - } - - /** - * Transform entry to a subquery - * - * @param string $encoding - * @return Zend_Search_Lucene_Search_Query - * @throws Zend_Search_Lucene_Search_QueryParserException - */ - public function getQuery($encoding) - { - /** Zend_Search_Lucene_Search_Query_Preprocessing_Phrase */ - // require_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Phrase.php'; - $query = new Zend_Search_Lucene_Search_Query_Preprocessing_Phrase($this->_phrase, - $encoding, - ($this->_field !== null)? - iconv($encoding, 'UTF-8', $this->_field) : - null); - - if ($this->_proximityQuery) { - $query->setSlop($this->_wordsDistance); - } - - $query->setBoost($this->_boost); - - return $query; - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryEntry/Subquery.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryEntry/Subquery.php deleted file mode 100755 index 76d78adeaeef708fea2fd5bdbf20639253283914..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryEntry/Subquery.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_Search_QueryEntry */ -// require_once 'Zend/Search/Lucene/Search/QueryEntry.php'; - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_QueryEntry_Subquery extends Zend_Search_Lucene_Search_QueryEntry -{ - /** - * Query - * - * @var Zend_Search_Lucene_Search_Query - */ - private $_query; - - /** - * Object constractor - * - * @param Zend_Search_Lucene_Search_Query $query - */ - public function __construct(Zend_Search_Lucene_Search_Query $query) - { - $this->_query = $query; - } - - /** - * Process modifier ('~') - * - * @param mixed $parameter - * @throws Zend_Search_Lucene_Search_QueryParserException - */ - public function processFuzzyProximityModifier($parameter = null) - { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('\'~\' sign must follow term or phrase'); - } - - - /** - * Transform entry to a subquery - * - * @param string $encoding - * @return Zend_Search_Lucene_Search_Query - */ - public function getQuery($encoding) - { - $this->_query->setBoost($this->_boost); - - return $this->_query; - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryEntry/Term.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryEntry/Term.php deleted file mode 100755 index 132ff00ab2f27b032fd9965fd18eed32d29af135..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryEntry/Term.php +++ /dev/null @@ -1,130 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_Search_QueryEntry */ -// require_once 'Zend/Search/Lucene/Search/QueryEntry.php'; - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_QueryEntry_Term extends Zend_Search_Lucene_Search_QueryEntry -{ - /** - * Term value - * - * @var string - */ - private $_term; - - /** - * Field - * - * @var string|null - */ - private $_field; - - - /** - * Fuzzy search query - * - * @var boolean - */ - private $_fuzzyQuery = false; - - /** - * Similarity - * - * @var float - */ - private $_similarity = 1.; - - - /** - * Object constractor - * - * @param string $term - * @param string $field - */ - public function __construct($term, $field) - { - $this->_term = $term; - $this->_field = $field; - } - - /** - * Process modifier ('~') - * - * @param mixed $parameter - */ - public function processFuzzyProximityModifier($parameter = null) - { - $this->_fuzzyQuery = true; - - if ($parameter !== null) { - $this->_similarity = $parameter; - } else { - /** Zend_Search_Lucene_Search_Query_Fuzzy */ - // require_once 'Zend/Search/Lucene/Search/Query/Fuzzy.php'; - $this->_similarity = Zend_Search_Lucene_Search_Query_Fuzzy::DEFAULT_MIN_SIMILARITY; - } - } - - /** - * Transform entry to a subquery - * - * @param string $encoding - * @return Zend_Search_Lucene_Search_Query - * @throws Zend_Search_Lucene_Search_QueryParserException - */ - public function getQuery($encoding) - { - if ($this->_fuzzyQuery) { - /** Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy */ - // require_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Fuzzy.php'; - $query = new Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy($this->_term, - $encoding, - ($this->_field !== null)? - iconv($encoding, 'UTF-8', $this->_field) : - null, - $this->_similarity - ); - $query->setBoost($this->_boost); - return $query; - } - - - /** Zend_Search_Lucene_Search_Query_Preprocessing_Term */ - // require_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Term.php'; - $query = new Zend_Search_Lucene_Search_Query_Preprocessing_Term($this->_term, - $encoding, - ($this->_field !== null)? - iconv($encoding, 'UTF-8', $this->_field) : - null - ); - $query->setBoost($this->_boost); - return $query; - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryHit.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryHit.php deleted file mode 100755 index bfcd5163f01440aa4d561e3465c9823d3fa042fb..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryHit.php +++ /dev/null @@ -1,110 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_QueryHit -{ - /** - * Object handle of the index - * @var Zend_Search_Lucene_Interface - */ - protected $_index = null; - - /** - * Object handle of the document associated with this hit - * @var Zend_Search_Lucene_Document - */ - protected $_document = null; - - /** - * Number of the document in the index - * @var integer - */ - public $id; - - /** - * Score of the hit - * @var float - */ - public $score; - - - /** - * Constructor - pass object handle of Zend_Search_Lucene_Interface index that produced - * the hit so the document can be retrieved easily from the hit. - * - * @param Zend_Search_Lucene_Interface $index - */ - - public function __construct(Zend_Search_Lucene_Interface $index) - { - // require_once 'Zend/Search/Lucene/Proxy.php'; - $this->_index = new Zend_Search_Lucene_Proxy($index); - } - - - /** - * Convenience function for getting fields from the document - * associated with this hit. - * - * @param string $offset - * @return string - */ - public function __get($offset) - { - return $this->getDocument()->getFieldValue($offset); - } - - - /** - * Return the document object for this hit - * - * @return Zend_Search_Lucene_Document - */ - public function getDocument() - { - if (!$this->_document instanceof Zend_Search_Lucene_Document) { - $this->_document = $this->_index->getDocument($this->id); - } - - return $this->_document; - } - - - /** - * Return the index object for this hit - * - * @return Zend_Search_Lucene_Interface - */ - public function getIndex() - { - return $this->_index; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryLexer.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryLexer.php deleted file mode 100755 index eebb325e819f0387aae5d1e57fdcf40351cffa4a..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryLexer.php +++ /dev/null @@ -1,510 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_FSM */ -// require_once 'Zend/Search/Lucene/FSM.php'; - -/** Zend_Search_Lucene_Search_QueryParser */ -// require_once 'Zend/Search/Lucene/Search/QueryToken.php'; - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_QueryLexer extends Zend_Search_Lucene_FSM -{ - /** State Machine states */ - const ST_WHITE_SPACE = 0; - const ST_SYNT_LEXEME = 1; - const ST_LEXEME = 2; - const ST_QUOTED_LEXEME = 3; - const ST_ESCAPED_CHAR = 4; - const ST_ESCAPED_QCHAR = 5; - const ST_LEXEME_MODIFIER = 6; - const ST_NUMBER = 7; - const ST_MANTISSA = 8; - const ST_ERROR = 9; - - /** Input symbols */ - const IN_WHITE_SPACE = 0; - const IN_SYNT_CHAR = 1; - const IN_LEXEME_MODIFIER = 2; - const IN_ESCAPE_CHAR = 3; - const IN_QUOTE = 4; - const IN_DECIMAL_POINT = 5; - const IN_ASCII_DIGIT = 6; - const IN_CHAR = 7; - const IN_MUTABLE_CHAR = 8; - - const QUERY_WHITE_SPACE_CHARS = " \n\r\t"; - const QUERY_SYNT_CHARS = ':()[]{}!|&'; - const QUERY_MUTABLE_CHARS = '+-'; - const QUERY_DOUBLECHARLEXEME_CHARS = '|&'; - const QUERY_LEXEMEMODIFIER_CHARS = '~^'; - const QUERY_ASCIIDIGITS_CHARS = '0123456789'; - - /** - * List of recognized lexemes - * - * @var array - */ - private $_lexemes; - - /** - * Query string (array of single- or non single-byte characters) - * - * @var array - */ - private $_queryString; - - /** - * Current position within a query string - * Used to create appropriate error messages - * - * @var integer - */ - private $_queryStringPosition; - - /** - * Recognized part of current lexeme - * - * @var string - */ - private $_currentLexeme; - - public function __construct() - { - parent::__construct( array(self::ST_WHITE_SPACE, - self::ST_SYNT_LEXEME, - self::ST_LEXEME, - self::ST_QUOTED_LEXEME, - self::ST_ESCAPED_CHAR, - self::ST_ESCAPED_QCHAR, - self::ST_LEXEME_MODIFIER, - self::ST_NUMBER, - self::ST_MANTISSA, - self::ST_ERROR), - array(self::IN_WHITE_SPACE, - self::IN_SYNT_CHAR, - self::IN_MUTABLE_CHAR, - self::IN_LEXEME_MODIFIER, - self::IN_ESCAPE_CHAR, - self::IN_QUOTE, - self::IN_DECIMAL_POINT, - self::IN_ASCII_DIGIT, - self::IN_CHAR)); - - - $lexemeModifierErrorAction = new Zend_Search_Lucene_FSMAction($this, 'lexModifierErrException'); - $quoteWithinLexemeErrorAction = new Zend_Search_Lucene_FSMAction($this, 'quoteWithinLexemeErrException'); - $wrongNumberErrorAction = new Zend_Search_Lucene_FSMAction($this, 'wrongNumberErrException'); - - - - $this->addRules(array( array(self::ST_WHITE_SPACE, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE), - array(self::ST_WHITE_SPACE, self::IN_SYNT_CHAR, self::ST_SYNT_LEXEME), - array(self::ST_WHITE_SPACE, self::IN_MUTABLE_CHAR, self::ST_SYNT_LEXEME), - array(self::ST_WHITE_SPACE, self::IN_LEXEME_MODIFIER, self::ST_LEXEME_MODIFIER), - array(self::ST_WHITE_SPACE, self::IN_ESCAPE_CHAR, self::ST_ESCAPED_CHAR), - array(self::ST_WHITE_SPACE, self::IN_QUOTE, self::ST_QUOTED_LEXEME), - array(self::ST_WHITE_SPACE, self::IN_DECIMAL_POINT, self::ST_LEXEME), - array(self::ST_WHITE_SPACE, self::IN_ASCII_DIGIT, self::ST_LEXEME), - array(self::ST_WHITE_SPACE, self::IN_CHAR, self::ST_LEXEME) - )); - $this->addRules(array( array(self::ST_SYNT_LEXEME, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE), - array(self::ST_SYNT_LEXEME, self::IN_SYNT_CHAR, self::ST_SYNT_LEXEME), - array(self::ST_SYNT_LEXEME, self::IN_MUTABLE_CHAR, self::ST_SYNT_LEXEME), - array(self::ST_SYNT_LEXEME, self::IN_LEXEME_MODIFIER, self::ST_LEXEME_MODIFIER), - array(self::ST_SYNT_LEXEME, self::IN_ESCAPE_CHAR, self::ST_ESCAPED_CHAR), - array(self::ST_SYNT_LEXEME, self::IN_QUOTE, self::ST_QUOTED_LEXEME), - array(self::ST_SYNT_LEXEME, self::IN_DECIMAL_POINT, self::ST_LEXEME), - array(self::ST_SYNT_LEXEME, self::IN_ASCII_DIGIT, self::ST_LEXEME), - array(self::ST_SYNT_LEXEME, self::IN_CHAR, self::ST_LEXEME) - )); - $this->addRules(array( array(self::ST_LEXEME, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE), - array(self::ST_LEXEME, self::IN_SYNT_CHAR, self::ST_SYNT_LEXEME), - array(self::ST_LEXEME, self::IN_MUTABLE_CHAR, self::ST_LEXEME), - array(self::ST_LEXEME, self::IN_LEXEME_MODIFIER, self::ST_LEXEME_MODIFIER), - array(self::ST_LEXEME, self::IN_ESCAPE_CHAR, self::ST_ESCAPED_CHAR), - - // IN_QUOTE not allowed - array(self::ST_LEXEME, self::IN_QUOTE, self::ST_ERROR, $quoteWithinLexemeErrorAction), - - array(self::ST_LEXEME, self::IN_DECIMAL_POINT, self::ST_LEXEME), - array(self::ST_LEXEME, self::IN_ASCII_DIGIT, self::ST_LEXEME), - array(self::ST_LEXEME, self::IN_CHAR, self::ST_LEXEME) - )); - $this->addRules(array( array(self::ST_QUOTED_LEXEME, self::IN_WHITE_SPACE, self::ST_QUOTED_LEXEME), - array(self::ST_QUOTED_LEXEME, self::IN_SYNT_CHAR, self::ST_QUOTED_LEXEME), - array(self::ST_QUOTED_LEXEME, self::IN_MUTABLE_CHAR, self::ST_QUOTED_LEXEME), - array(self::ST_QUOTED_LEXEME, self::IN_LEXEME_MODIFIER, self::ST_QUOTED_LEXEME), - array(self::ST_QUOTED_LEXEME, self::IN_ESCAPE_CHAR, self::ST_ESCAPED_QCHAR), - array(self::ST_QUOTED_LEXEME, self::IN_QUOTE, self::ST_WHITE_SPACE), - array(self::ST_QUOTED_LEXEME, self::IN_DECIMAL_POINT, self::ST_QUOTED_LEXEME), - array(self::ST_QUOTED_LEXEME, self::IN_ASCII_DIGIT, self::ST_QUOTED_LEXEME), - array(self::ST_QUOTED_LEXEME, self::IN_CHAR, self::ST_QUOTED_LEXEME) - )); - $this->addRules(array( array(self::ST_ESCAPED_CHAR, self::IN_WHITE_SPACE, self::ST_LEXEME), - array(self::ST_ESCAPED_CHAR, self::IN_SYNT_CHAR, self::ST_LEXEME), - array(self::ST_ESCAPED_CHAR, self::IN_MUTABLE_CHAR, self::ST_LEXEME), - array(self::ST_ESCAPED_CHAR, self::IN_LEXEME_MODIFIER, self::ST_LEXEME), - array(self::ST_ESCAPED_CHAR, self::IN_ESCAPE_CHAR, self::ST_LEXEME), - array(self::ST_ESCAPED_CHAR, self::IN_QUOTE, self::ST_LEXEME), - array(self::ST_ESCAPED_CHAR, self::IN_DECIMAL_POINT, self::ST_LEXEME), - array(self::ST_ESCAPED_CHAR, self::IN_ASCII_DIGIT, self::ST_LEXEME), - array(self::ST_ESCAPED_CHAR, self::IN_CHAR, self::ST_LEXEME) - )); - $this->addRules(array( array(self::ST_ESCAPED_QCHAR, self::IN_WHITE_SPACE, self::ST_QUOTED_LEXEME), - array(self::ST_ESCAPED_QCHAR, self::IN_SYNT_CHAR, self::ST_QUOTED_LEXEME), - array(self::ST_ESCAPED_QCHAR, self::IN_MUTABLE_CHAR, self::ST_QUOTED_LEXEME), - array(self::ST_ESCAPED_QCHAR, self::IN_LEXEME_MODIFIER, self::ST_QUOTED_LEXEME), - array(self::ST_ESCAPED_QCHAR, self::IN_ESCAPE_CHAR, self::ST_QUOTED_LEXEME), - array(self::ST_ESCAPED_QCHAR, self::IN_QUOTE, self::ST_QUOTED_LEXEME), - array(self::ST_ESCAPED_QCHAR, self::IN_DECIMAL_POINT, self::ST_QUOTED_LEXEME), - array(self::ST_ESCAPED_QCHAR, self::IN_ASCII_DIGIT, self::ST_QUOTED_LEXEME), - array(self::ST_ESCAPED_QCHAR, self::IN_CHAR, self::ST_QUOTED_LEXEME) - )); - $this->addRules(array( array(self::ST_LEXEME_MODIFIER, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE), - array(self::ST_LEXEME_MODIFIER, self::IN_SYNT_CHAR, self::ST_SYNT_LEXEME), - array(self::ST_LEXEME_MODIFIER, self::IN_MUTABLE_CHAR, self::ST_SYNT_LEXEME), - array(self::ST_LEXEME_MODIFIER, self::IN_LEXEME_MODIFIER, self::ST_LEXEME_MODIFIER), - - // IN_ESCAPE_CHAR not allowed - array(self::ST_LEXEME_MODIFIER, self::IN_ESCAPE_CHAR, self::ST_ERROR, $lexemeModifierErrorAction), - - // IN_QUOTE not allowed - array(self::ST_LEXEME_MODIFIER, self::IN_QUOTE, self::ST_ERROR, $lexemeModifierErrorAction), - - - array(self::ST_LEXEME_MODIFIER, self::IN_DECIMAL_POINT, self::ST_MANTISSA), - array(self::ST_LEXEME_MODIFIER, self::IN_ASCII_DIGIT, self::ST_NUMBER), - - // IN_CHAR not allowed - array(self::ST_LEXEME_MODIFIER, self::IN_CHAR, self::ST_ERROR, $lexemeModifierErrorAction), - )); - $this->addRules(array( array(self::ST_NUMBER, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE), - array(self::ST_NUMBER, self::IN_SYNT_CHAR, self::ST_SYNT_LEXEME), - array(self::ST_NUMBER, self::IN_MUTABLE_CHAR, self::ST_SYNT_LEXEME), - array(self::ST_NUMBER, self::IN_LEXEME_MODIFIER, self::ST_LEXEME_MODIFIER), - - // IN_ESCAPE_CHAR not allowed - array(self::ST_NUMBER, self::IN_ESCAPE_CHAR, self::ST_ERROR, $wrongNumberErrorAction), - - // IN_QUOTE not allowed - array(self::ST_NUMBER, self::IN_QUOTE, self::ST_ERROR, $wrongNumberErrorAction), - - array(self::ST_NUMBER, self::IN_DECIMAL_POINT, self::ST_MANTISSA), - array(self::ST_NUMBER, self::IN_ASCII_DIGIT, self::ST_NUMBER), - - // IN_CHAR not allowed - array(self::ST_NUMBER, self::IN_CHAR, self::ST_ERROR, $wrongNumberErrorAction), - )); - $this->addRules(array( array(self::ST_MANTISSA, self::IN_WHITE_SPACE, self::ST_WHITE_SPACE), - array(self::ST_MANTISSA, self::IN_SYNT_CHAR, self::ST_SYNT_LEXEME), - array(self::ST_MANTISSA, self::IN_MUTABLE_CHAR, self::ST_SYNT_LEXEME), - array(self::ST_MANTISSA, self::IN_LEXEME_MODIFIER, self::ST_LEXEME_MODIFIER), - - // IN_ESCAPE_CHAR not allowed - array(self::ST_MANTISSA, self::IN_ESCAPE_CHAR, self::ST_ERROR, $wrongNumberErrorAction), - - // IN_QUOTE not allowed - array(self::ST_MANTISSA, self::IN_QUOTE, self::ST_ERROR, $wrongNumberErrorAction), - - // IN_DECIMAL_POINT not allowed - array(self::ST_MANTISSA, self::IN_DECIMAL_POINT, self::ST_ERROR, $wrongNumberErrorAction), - - array(self::ST_MANTISSA, self::IN_ASCII_DIGIT, self::ST_MANTISSA), - - // IN_CHAR not allowed - array(self::ST_MANTISSA, self::IN_CHAR, self::ST_ERROR, $wrongNumberErrorAction), - )); - - - /** Actions */ - $syntaxLexemeAction = new Zend_Search_Lucene_FSMAction($this, 'addQuerySyntaxLexeme'); - $lexemeModifierAction = new Zend_Search_Lucene_FSMAction($this, 'addLexemeModifier'); - $addLexemeAction = new Zend_Search_Lucene_FSMAction($this, 'addLexeme'); - $addQuotedLexemeAction = new Zend_Search_Lucene_FSMAction($this, 'addQuotedLexeme'); - $addNumberLexemeAction = new Zend_Search_Lucene_FSMAction($this, 'addNumberLexeme'); - $addLexemeCharAction = new Zend_Search_Lucene_FSMAction($this, 'addLexemeChar'); - - - /** Syntax lexeme */ - $this->addEntryAction(self::ST_SYNT_LEXEME, $syntaxLexemeAction); - // Two lexemes in succession - $this->addTransitionAction(self::ST_SYNT_LEXEME, self::ST_SYNT_LEXEME, $syntaxLexemeAction); - - - /** Lexeme */ - $this->addEntryAction(self::ST_LEXEME, $addLexemeCharAction); - $this->addTransitionAction(self::ST_LEXEME, self::ST_LEXEME, $addLexemeCharAction); - // ST_ESCAPED_CHAR => ST_LEXEME transition is covered by ST_LEXEME entry action - - $this->addTransitionAction(self::ST_LEXEME, self::ST_WHITE_SPACE, $addLexemeAction); - $this->addTransitionAction(self::ST_LEXEME, self::ST_SYNT_LEXEME, $addLexemeAction); - $this->addTransitionAction(self::ST_LEXEME, self::ST_QUOTED_LEXEME, $addLexemeAction); - $this->addTransitionAction(self::ST_LEXEME, self::ST_LEXEME_MODIFIER, $addLexemeAction); - $this->addTransitionAction(self::ST_LEXEME, self::ST_NUMBER, $addLexemeAction); - $this->addTransitionAction(self::ST_LEXEME, self::ST_MANTISSA, $addLexemeAction); - - - /** Quoted lexeme */ - // We don't need entry action (skeep quote) - $this->addTransitionAction(self::ST_QUOTED_LEXEME, self::ST_QUOTED_LEXEME, $addLexemeCharAction); - $this->addTransitionAction(self::ST_ESCAPED_QCHAR, self::ST_QUOTED_LEXEME, $addLexemeCharAction); - // Closing quote changes state to the ST_WHITE_SPACE other states are not used - $this->addTransitionAction(self::ST_QUOTED_LEXEME, self::ST_WHITE_SPACE, $addQuotedLexemeAction); - - - /** Lexeme modifier */ - $this->addEntryAction(self::ST_LEXEME_MODIFIER, $lexemeModifierAction); - - - /** Number */ - $this->addEntryAction(self::ST_NUMBER, $addLexemeCharAction); - $this->addEntryAction(self::ST_MANTISSA, $addLexemeCharAction); - $this->addTransitionAction(self::ST_NUMBER, self::ST_NUMBER, $addLexemeCharAction); - // ST_NUMBER => ST_MANTISSA transition is covered by ST_MANTISSA entry action - $this->addTransitionAction(self::ST_MANTISSA, self::ST_MANTISSA, $addLexemeCharAction); - - $this->addTransitionAction(self::ST_NUMBER, self::ST_WHITE_SPACE, $addNumberLexemeAction); - $this->addTransitionAction(self::ST_NUMBER, self::ST_SYNT_LEXEME, $addNumberLexemeAction); - $this->addTransitionAction(self::ST_NUMBER, self::ST_LEXEME_MODIFIER, $addNumberLexemeAction); - $this->addTransitionAction(self::ST_MANTISSA, self::ST_WHITE_SPACE, $addNumberLexemeAction); - $this->addTransitionAction(self::ST_MANTISSA, self::ST_SYNT_LEXEME, $addNumberLexemeAction); - $this->addTransitionAction(self::ST_MANTISSA, self::ST_LEXEME_MODIFIER, $addNumberLexemeAction); - } - - - - - /** - * Translate input char to an input symbol of state machine - * - * @param string $char - * @return integer - */ - private function _translateInput($char) - { - if (strpos(self::QUERY_WHITE_SPACE_CHARS, $char) !== false) { return self::IN_WHITE_SPACE; - } else if (strpos(self::QUERY_SYNT_CHARS, $char) !== false) { return self::IN_SYNT_CHAR; - } else if (strpos(self::QUERY_MUTABLE_CHARS, $char) !== false) { return self::IN_MUTABLE_CHAR; - } else if (strpos(self::QUERY_LEXEMEMODIFIER_CHARS, $char) !== false) { return self::IN_LEXEME_MODIFIER; - } else if (strpos(self::QUERY_ASCIIDIGITS_CHARS, $char) !== false) { return self::IN_ASCII_DIGIT; - } else if ($char === '"' ) { return self::IN_QUOTE; - } else if ($char === '.' ) { return self::IN_DECIMAL_POINT; - } else if ($char === '\\') { return self::IN_ESCAPE_CHAR; - } else { return self::IN_CHAR; - } - } - - - /** - * This method is used to tokenize query string into lexemes - * - * @param string $inputString - * @param string $encoding - * @return array - * @throws Zend_Search_Lucene_Search_QueryParserException - */ - public function tokenize($inputString, $encoding) - { - $this->reset(); - - $this->_lexemes = array(); - $this->_queryString = array(); - - if (PHP_OS == 'AIX' && $encoding == '') { - $encoding = 'ISO8859-1'; - } - $strLength = iconv_strlen($inputString, $encoding); - - // Workaround for iconv_substr bug - $inputString .= ' '; - - for ($count = 0; $count < $strLength; $count++) { - $this->_queryString[$count] = iconv_substr($inputString, $count, 1, $encoding); - } - - for ($this->_queryStringPosition = 0; - $this->_queryStringPosition < count($this->_queryString); - $this->_queryStringPosition++) { - $this->process($this->_translateInput($this->_queryString[$this->_queryStringPosition])); - } - - $this->process(self::IN_WHITE_SPACE); - - if ($this->getState() != self::ST_WHITE_SPACE) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('Unexpected end of query'); - } - - $this->_queryString = null; - - return $this->_lexemes; - } - - - - /********************************************************************* - * Actions implementation - * - * Actions affect on recognized lexemes list - *********************************************************************/ - - /** - * Add query syntax lexeme - * - * @throws Zend_Search_Lucene_Search_QueryParserException - */ - public function addQuerySyntaxLexeme() - { - $lexeme = $this->_queryString[$this->_queryStringPosition]; - - // Process two char lexemes - if (strpos(self::QUERY_DOUBLECHARLEXEME_CHARS, $lexeme) !== false) { - // increase current position in a query string - $this->_queryStringPosition++; - - // check, - if ($this->_queryStringPosition == count($this->_queryString) || - $this->_queryString[$this->_queryStringPosition] != $lexeme) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('Two chars lexeme expected. ' . $this->_positionMsg()); - } - - // duplicate character - $lexeme .= $lexeme; - } - - $token = new Zend_Search_Lucene_Search_QueryToken( - Zend_Search_Lucene_Search_QueryToken::TC_SYNTAX_ELEMENT, - $lexeme, - $this->_queryStringPosition); - - // Skip this lexeme if it's a field indicator ':' and treat previous as 'field' instead of 'word' - if ($token->type == Zend_Search_Lucene_Search_QueryToken::TT_FIELD_INDICATOR) { - $token = array_pop($this->_lexemes); - if ($token === null || $token->type != Zend_Search_Lucene_Search_QueryToken::TT_WORD) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('Field mark \':\' must follow field name. ' . $this->_positionMsg()); - } - - $token->type = Zend_Search_Lucene_Search_QueryToken::TT_FIELD; - } - - $this->_lexemes[] = $token; - } - - /** - * Add lexeme modifier - */ - public function addLexemeModifier() - { - $this->_lexemes[] = new Zend_Search_Lucene_Search_QueryToken( - Zend_Search_Lucene_Search_QueryToken::TC_SYNTAX_ELEMENT, - $this->_queryString[$this->_queryStringPosition], - $this->_queryStringPosition); - } - - - /** - * Add lexeme - */ - public function addLexeme() - { - $this->_lexemes[] = new Zend_Search_Lucene_Search_QueryToken( - Zend_Search_Lucene_Search_QueryToken::TC_WORD, - $this->_currentLexeme, - $this->_queryStringPosition - 1); - - $this->_currentLexeme = ''; - } - - /** - * Add quoted lexeme - */ - public function addQuotedLexeme() - { - $this->_lexemes[] = new Zend_Search_Lucene_Search_QueryToken( - Zend_Search_Lucene_Search_QueryToken::TC_PHRASE, - $this->_currentLexeme, - $this->_queryStringPosition); - - $this->_currentLexeme = ''; - } - - /** - * Add number lexeme - */ - public function addNumberLexeme() - { - $this->_lexemes[] = new Zend_Search_Lucene_Search_QueryToken( - Zend_Search_Lucene_Search_QueryToken::TC_NUMBER, - $this->_currentLexeme, - $this->_queryStringPosition - 1); - $this->_currentLexeme = ''; - } - - /** - * Extend lexeme by one char - */ - public function addLexemeChar() - { - $this->_currentLexeme .= $this->_queryString[$this->_queryStringPosition]; - } - - - /** - * Position message - * - * @return string - */ - private function _positionMsg() - { - return 'Position is ' . $this->_queryStringPosition . '.'; - } - - - /********************************************************************* - * Syntax errors actions - *********************************************************************/ - public function lexModifierErrException() - { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('Lexeme modifier character can be followed only by number, white space or query syntax element. ' . $this->_positionMsg()); - } - public function quoteWithinLexemeErrException() - { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('Quote within lexeme must be escaped by \'\\\' char. ' . $this->_positionMsg()); - } - public function wrongNumberErrException() - { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('Wrong number syntax.' . $this->_positionMsg()); - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryParser.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryParser.php deleted file mode 100755 index 90b812524acf8e4a8e1685edc5d4cfc9a6d33393..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryParser.php +++ /dev/null @@ -1,635 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Internally used classes */ - -/** Zend_Search_Lucene_Analysis_Analyzer */ -// require_once 'Zend/Search/Lucene/Analysis/Analyzer.php'; - -/** Zend_Search_Lucene_Search_QueryToken */ -// require_once 'Zend/Search/Lucene/Search/QueryToken.php'; - - - -/** Zend_Search_Lucene_FSM */ -// require_once 'Zend/Search/Lucene/FSM.php'; - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_QueryParser extends Zend_Search_Lucene_FSM -{ - /** - * Parser instance - * - * @var Zend_Search_Lucene_Search_QueryParser - */ - private static $_instance = null; - - - /** - * Query lexer - * - * @var Zend_Search_Lucene_Search_QueryLexer - */ - private $_lexer; - - /** - * Tokens list - * Array of Zend_Search_Lucene_Search_QueryToken objects - * - * @var array - */ - private $_tokens; - - /** - * Current token - * - * @var integer|string - */ - private $_currentToken; - - /** - * Last token - * - * It can be processed within FSM states, but this addirional state simplifies FSM - * - * @var Zend_Search_Lucene_Search_QueryToken - */ - private $_lastToken = null; - - /** - * Range query first term - * - * @var string - */ - private $_rqFirstTerm = null; - - /** - * Current query parser context - * - * @var Zend_Search_Lucene_Search_QueryParserContext - */ - private $_context; - - /** - * Context stack - * - * @var array - */ - private $_contextStack; - - /** - * Query string encoding - * - * @var string - */ - private $_encoding; - - /** - * Query string default encoding - * - * @var string - */ - private $_defaultEncoding = ''; - - /** - * Defines query parsing mode. - * - * If this option is turned on, then query parser suppress query parser exceptions - * and constructs multi-term query using all words from a query. - * - * That helps to avoid exceptions caused by queries, which don't conform to query language, - * but limits possibilities to check, that query entered by user has some inconsistencies. - * - * - * Default is true. - * - * Use {@link Zend_Search_Lucene::suppressQueryParsingExceptions()}, - * {@link Zend_Search_Lucene::dontSuppressQueryParsingExceptions()} and - * {@link Zend_Search_Lucene::checkQueryParsingExceptionsSuppressMode()} to operate - * with this setting. - * - * @var boolean - */ - private $_suppressQueryParsingExceptions = true; - - /** - * Boolean operators constants - */ - const B_OR = 0; - const B_AND = 1; - - /** - * Default boolean queries operator - * - * @var integer - */ - private $_defaultOperator = self::B_OR; - - - /** Query parser State Machine states */ - const ST_COMMON_QUERY_ELEMENT = 0; // Terms, phrases, operators - const ST_CLOSEDINT_RQ_START = 1; // Range query start (closed interval) - '[' - const ST_CLOSEDINT_RQ_FIRST_TERM = 2; // First term in '[term1 to term2]' construction - const ST_CLOSEDINT_RQ_TO_TERM = 3; // 'TO' lexeme in '[term1 to term2]' construction - const ST_CLOSEDINT_RQ_LAST_TERM = 4; // Second term in '[term1 to term2]' construction - const ST_CLOSEDINT_RQ_END = 5; // Range query end (closed interval) - ']' - const ST_OPENEDINT_RQ_START = 6; // Range query start (opened interval) - '{' - const ST_OPENEDINT_RQ_FIRST_TERM = 7; // First term in '{term1 to term2}' construction - const ST_OPENEDINT_RQ_TO_TERM = 8; // 'TO' lexeme in '{term1 to term2}' construction - const ST_OPENEDINT_RQ_LAST_TERM = 9; // Second term in '{term1 to term2}' construction - const ST_OPENEDINT_RQ_END = 10; // Range query end (opened interval) - '}' - - /** - * Parser constructor - */ - public function __construct() - { - parent::__construct(array(self::ST_COMMON_QUERY_ELEMENT, - self::ST_CLOSEDINT_RQ_START, - self::ST_CLOSEDINT_RQ_FIRST_TERM, - self::ST_CLOSEDINT_RQ_TO_TERM, - self::ST_CLOSEDINT_RQ_LAST_TERM, - self::ST_CLOSEDINT_RQ_END, - self::ST_OPENEDINT_RQ_START, - self::ST_OPENEDINT_RQ_FIRST_TERM, - self::ST_OPENEDINT_RQ_TO_TERM, - self::ST_OPENEDINT_RQ_LAST_TERM, - self::ST_OPENEDINT_RQ_END - ), - Zend_Search_Lucene_Search_QueryToken::getTypes()); - - $this->addRules( - array(array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_WORD, self::ST_COMMON_QUERY_ELEMENT), - array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_PHRASE, self::ST_COMMON_QUERY_ELEMENT), - array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_FIELD, self::ST_COMMON_QUERY_ELEMENT), - array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_REQUIRED, self::ST_COMMON_QUERY_ELEMENT), - array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_PROHIBITED, self::ST_COMMON_QUERY_ELEMENT), - array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_FUZZY_PROX_MARK, self::ST_COMMON_QUERY_ELEMENT), - array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_BOOSTING_MARK, self::ST_COMMON_QUERY_ELEMENT), - array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_RANGE_INCL_START, self::ST_CLOSEDINT_RQ_START), - array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_RANGE_EXCL_START, self::ST_OPENEDINT_RQ_START), - array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_SUBQUERY_START, self::ST_COMMON_QUERY_ELEMENT), - array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_SUBQUERY_END, self::ST_COMMON_QUERY_ELEMENT), - array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_AND_LEXEME, self::ST_COMMON_QUERY_ELEMENT), - array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_OR_LEXEME, self::ST_COMMON_QUERY_ELEMENT), - array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_NOT_LEXEME, self::ST_COMMON_QUERY_ELEMENT), - array(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_NUMBER, self::ST_COMMON_QUERY_ELEMENT) - )); - $this->addRules( - array(array(self::ST_CLOSEDINT_RQ_START, Zend_Search_Lucene_Search_QueryToken::TT_WORD, self::ST_CLOSEDINT_RQ_FIRST_TERM), - array(self::ST_CLOSEDINT_RQ_FIRST_TERM, Zend_Search_Lucene_Search_QueryToken::TT_TO_LEXEME, self::ST_CLOSEDINT_RQ_TO_TERM), - array(self::ST_CLOSEDINT_RQ_TO_TERM, Zend_Search_Lucene_Search_QueryToken::TT_WORD, self::ST_CLOSEDINT_RQ_LAST_TERM), - array(self::ST_CLOSEDINT_RQ_LAST_TERM, Zend_Search_Lucene_Search_QueryToken::TT_RANGE_INCL_END, self::ST_COMMON_QUERY_ELEMENT) - )); - $this->addRules( - array(array(self::ST_OPENEDINT_RQ_START, Zend_Search_Lucene_Search_QueryToken::TT_WORD, self::ST_OPENEDINT_RQ_FIRST_TERM), - array(self::ST_OPENEDINT_RQ_FIRST_TERM, Zend_Search_Lucene_Search_QueryToken::TT_TO_LEXEME, self::ST_OPENEDINT_RQ_TO_TERM), - array(self::ST_OPENEDINT_RQ_TO_TERM, Zend_Search_Lucene_Search_QueryToken::TT_WORD, self::ST_OPENEDINT_RQ_LAST_TERM), - array(self::ST_OPENEDINT_RQ_LAST_TERM, Zend_Search_Lucene_Search_QueryToken::TT_RANGE_EXCL_END, self::ST_COMMON_QUERY_ELEMENT) - )); - - - - $addTermEntryAction = new Zend_Search_Lucene_FSMAction($this, 'addTermEntry'); - $addPhraseEntryAction = new Zend_Search_Lucene_FSMAction($this, 'addPhraseEntry'); - $setFieldAction = new Zend_Search_Lucene_FSMAction($this, 'setField'); - $setSignAction = new Zend_Search_Lucene_FSMAction($this, 'setSign'); - $setFuzzyProxAction = new Zend_Search_Lucene_FSMAction($this, 'processFuzzyProximityModifier'); - $processModifierParameterAction = new Zend_Search_Lucene_FSMAction($this, 'processModifierParameter'); - $subqueryStartAction = new Zend_Search_Lucene_FSMAction($this, 'subqueryStart'); - $subqueryEndAction = new Zend_Search_Lucene_FSMAction($this, 'subqueryEnd'); - $logicalOperatorAction = new Zend_Search_Lucene_FSMAction($this, 'logicalOperator'); - $openedRQFirstTermAction = new Zend_Search_Lucene_FSMAction($this, 'openedRQFirstTerm'); - $openedRQLastTermAction = new Zend_Search_Lucene_FSMAction($this, 'openedRQLastTerm'); - $closedRQFirstTermAction = new Zend_Search_Lucene_FSMAction($this, 'closedRQFirstTerm'); - $closedRQLastTermAction = new Zend_Search_Lucene_FSMAction($this, 'closedRQLastTerm'); - - - $this->addInputAction(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_WORD, $addTermEntryAction); - $this->addInputAction(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_PHRASE, $addPhraseEntryAction); - $this->addInputAction(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_FIELD, $setFieldAction); - $this->addInputAction(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_REQUIRED, $setSignAction); - $this->addInputAction(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_PROHIBITED, $setSignAction); - $this->addInputAction(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_FUZZY_PROX_MARK, $setFuzzyProxAction); - $this->addInputAction(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_NUMBER, $processModifierParameterAction); - $this->addInputAction(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_SUBQUERY_START, $subqueryStartAction); - $this->addInputAction(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_SUBQUERY_END, $subqueryEndAction); - $this->addInputAction(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_AND_LEXEME, $logicalOperatorAction); - $this->addInputAction(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_OR_LEXEME, $logicalOperatorAction); - $this->addInputAction(self::ST_COMMON_QUERY_ELEMENT, Zend_Search_Lucene_Search_QueryToken::TT_NOT_LEXEME, $logicalOperatorAction); - - $this->addEntryAction(self::ST_OPENEDINT_RQ_FIRST_TERM, $openedRQFirstTermAction); - $this->addEntryAction(self::ST_OPENEDINT_RQ_LAST_TERM, $openedRQLastTermAction); - $this->addEntryAction(self::ST_CLOSEDINT_RQ_FIRST_TERM, $closedRQFirstTermAction); - $this->addEntryAction(self::ST_CLOSEDINT_RQ_LAST_TERM, $closedRQLastTermAction); - - - // require_once 'Zend/Search/Lucene/Search/QueryLexer.php'; - $this->_lexer = new Zend_Search_Lucene_Search_QueryLexer(); - } - - /** - * Get query parser instance - * - * @return Zend_Search_Lucene_Search_QueryParser - */ - private static function _getInstance() - { - if (self::$_instance === null) { - self::$_instance = new self(); - } - return self::$_instance; - } - - /** - * Set query string default encoding - * - * @param string $encoding - */ - public static function setDefaultEncoding($encoding) - { - self::_getInstance()->_defaultEncoding = $encoding; - } - - /** - * Get query string default encoding - * - * @return string - */ - public static function getDefaultEncoding() - { - return self::_getInstance()->_defaultEncoding; - } - - /** - * Set default boolean operator - * - * @param integer $operator - */ - public static function setDefaultOperator($operator) - { - self::_getInstance()->_defaultOperator = $operator; - } - - /** - * Get default boolean operator - * - * @return integer - */ - public static function getDefaultOperator() - { - return self::_getInstance()->_defaultOperator; - } - - /** - * Turn on 'suppress query parser exceptions' mode. - */ - public static function suppressQueryParsingExceptions() - { - self::_getInstance()->_suppressQueryParsingExceptions = true; - } - /** - * Turn off 'suppress query parser exceptions' mode. - */ - public static function dontSuppressQueryParsingExceptions() - { - self::_getInstance()->_suppressQueryParsingExceptions = false; - } - /** - * Check 'suppress query parser exceptions' mode. - * @return boolean - */ - public static function queryParsingExceptionsSuppressed() - { - return self::_getInstance()->_suppressQueryParsingExceptions; - } - - - /** - * Escape keyword to force it to be parsed as one term - * - * @param string $keyword - * @return string - */ - public static function escape($keyword) - { - return '\\' . implode('\\', str_split($keyword)); - } - - /** - * Parses a query string - * - * @param string $strQuery - * @param string $encoding - * @return Zend_Search_Lucene_Search_Query - * @throws Zend_Search_Lucene_Search_QueryParserException - */ - public static function parse($strQuery, $encoding = null) - { - self::_getInstance(); - - // Reset FSM if previous parse operation didn't return it into a correct state - self::$_instance->reset(); - - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - try { - // require_once 'Zend/Search/Lucene/Search/QueryParserContext.php'; - - self::$_instance->_encoding = ($encoding !== null) ? $encoding : self::$_instance->_defaultEncoding; - self::$_instance->_lastToken = null; - self::$_instance->_context = new Zend_Search_Lucene_Search_QueryParserContext(self::$_instance->_encoding); - self::$_instance->_contextStack = array(); - self::$_instance->_tokens = self::$_instance->_lexer->tokenize($strQuery, self::$_instance->_encoding); - - // Empty query - if (count(self::$_instance->_tokens) == 0) { - // require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php'; - return new Zend_Search_Lucene_Search_Query_Insignificant(); - } - - - foreach (self::$_instance->_tokens as $token) { - try { - self::$_instance->_currentToken = $token; - self::$_instance->process($token->type); - - self::$_instance->_lastToken = $token; - } catch (Exception $e) { - if (strpos($e->getMessage(), 'There is no any rule for') !== false) { - throw new Zend_Search_Lucene_Search_QueryParserException( 'Syntax error at char position ' . $token->position . '.', 0, $e); - } - - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e); - } - } - - if (count(self::$_instance->_contextStack) != 0) { - throw new Zend_Search_Lucene_Search_QueryParserException('Syntax Error: mismatched parentheses, every opening must have closing.' ); - } - - return self::$_instance->_context->getQuery(); - } catch (Zend_Search_Lucene_Search_QueryParserException $e) { - if (self::$_instance->_suppressQueryParsingExceptions) { - $queryTokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($strQuery, self::$_instance->_encoding); - - // require_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php'; - $query = new Zend_Search_Lucene_Search_Query_MultiTerm(); - $termsSign = (self::$_instance->_defaultOperator == self::B_AND) ? true /* required term */ : - null /* optional term */; - - // require_once 'Zend/Search/Lucene/Index/Term.php'; - foreach ($queryTokens as $token) { - $query->addTerm(new Zend_Search_Lucene_Index_Term($token->getTermText()), $termsSign); - } - - - return $query; - } else { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e); - } - } - } - - /********************************************************************* - * Actions implementation - * - * Actions affect on recognized lexemes list - *********************************************************************/ - - /** - * Add term to a query - */ - public function addTermEntry() - { - // require_once 'Zend/Search/Lucene/Search/QueryEntry/Term.php'; - $entry = new Zend_Search_Lucene_Search_QueryEntry_Term($this->_currentToken->text, $this->_context->getField()); - $this->_context->addEntry($entry); - } - - /** - * Add phrase to a query - */ - public function addPhraseEntry() - { - // require_once 'Zend/Search/Lucene/Search/QueryEntry/Phrase.php'; - $entry = new Zend_Search_Lucene_Search_QueryEntry_Phrase($this->_currentToken->text, $this->_context->getField()); - $this->_context->addEntry($entry); - } - - /** - * Set entry field - */ - public function setField() - { - $this->_context->setNextEntryField($this->_currentToken->text); - } - - /** - * Set entry sign - */ - public function setSign() - { - $this->_context->setNextEntrySign($this->_currentToken->type); - } - - - /** - * Process fuzzy search/proximity modifier - '~' - */ - public function processFuzzyProximityModifier() - { - $this->_context->processFuzzyProximityModifier(); - } - - /** - * Process modifier parameter - * - * @throws Zend_Search_Lucene_Exception - */ - public function processModifierParameter() - { - if ($this->_lastToken === null) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('Lexeme modifier parameter must follow lexeme modifier. Char position 0.' ); - } - - switch ($this->_lastToken->type) { - case Zend_Search_Lucene_Search_QueryToken::TT_FUZZY_PROX_MARK: - $this->_context->processFuzzyProximityModifier($this->_currentToken->text); - break; - - case Zend_Search_Lucene_Search_QueryToken::TT_BOOSTING_MARK: - $this->_context->boost($this->_currentToken->text); - break; - - default: - // It's not a user input exception - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Lexeme modifier parameter must follow lexeme modifier. Char position 0.' ); - } - } - - - /** - * Start subquery - */ - public function subqueryStart() - { - // require_once 'Zend/Search/Lucene/Search/QueryParserContext.php'; - - $this->_contextStack[] = $this->_context; - $this->_context = new Zend_Search_Lucene_Search_QueryParserContext($this->_encoding, $this->_context->getField()); - } - - /** - * End subquery - */ - public function subqueryEnd() - { - if (count($this->_contextStack) == 0) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('Syntax Error: mismatched parentheses, every opening must have closing. Char position ' . $this->_currentToken->position . '.' ); - } - - $query = $this->_context->getQuery(); - $this->_context = array_pop($this->_contextStack); - - // require_once 'Zend/Search/Lucene/Search/QueryEntry/Subquery.php'; - $this->_context->addEntry(new Zend_Search_Lucene_Search_QueryEntry_Subquery($query)); - } - - /** - * Process logical operator - */ - public function logicalOperator() - { - $this->_context->addLogicalOperator($this->_currentToken->type); - } - - /** - * Process first range query term (opened interval) - */ - public function openedRQFirstTerm() - { - $this->_rqFirstTerm = $this->_currentToken->text; - } - - /** - * Process last range query term (opened interval) - * - * @throws Zend_Search_Lucene_Search_QueryParserException - */ - public function openedRQLastTerm() - { - $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_rqFirstTerm, $this->_encoding); - if (count($tokens) > 1) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('Range query boundary terms must be non-multiple word terms'); - } else if (count($tokens) == 1) { - // require_once 'Zend/Search/Lucene/Index/Term.php'; - $from = new Zend_Search_Lucene_Index_Term(reset($tokens)->getTermText(), $this->_context->getField()); - } else { - $from = null; - } - - $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_currentToken->text, $this->_encoding); - if (count($tokens) > 1) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('Range query boundary terms must be non-multiple word terms'); - } else if (count($tokens) == 1) { - // require_once 'Zend/Search/Lucene/Index/Term.php'; - $to = new Zend_Search_Lucene_Index_Term(reset($tokens)->getTermText(), $this->_context->getField()); - } else { - $to = null; - } - - if ($from === null && $to === null) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('At least one range query boundary term must be non-empty term'); - } - - // require_once 'Zend/Search/Lucene/Search/Query/Range.php'; - $rangeQuery = new Zend_Search_Lucene_Search_Query_Range($from, $to, false); - // require_once 'Zend/Search/Lucene/Search/QueryEntry/Subquery.php'; - $entry = new Zend_Search_Lucene_Search_QueryEntry_Subquery($rangeQuery); - $this->_context->addEntry($entry); - } - - /** - * Process first range query term (closed interval) - */ - public function closedRQFirstTerm() - { - $this->_rqFirstTerm = $this->_currentToken->text; - } - - /** - * Process last range query term (closed interval) - * - * @throws Zend_Search_Lucene_Search_QueryParserException - */ - public function closedRQLastTerm() - { - $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_rqFirstTerm, $this->_encoding); - if (count($tokens) > 1) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('Range query boundary terms must be non-multiple word terms'); - } else if (count($tokens) == 1) { - // require_once 'Zend/Search/Lucene/Index/Term.php'; - $from = new Zend_Search_Lucene_Index_Term(reset($tokens)->getTermText(), $this->_context->getField()); - } else { - $from = null; - } - - $tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_currentToken->text, $this->_encoding); - if (count($tokens) > 1) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('Range query boundary terms must be non-multiple word terms'); - } else if (count($tokens) == 1) { - // require_once 'Zend/Search/Lucene/Index/Term.php'; - $to = new Zend_Search_Lucene_Index_Term(reset($tokens)->getTermText(), $this->_context->getField()); - } else { - $to = null; - } - - if ($from === null && $to === null) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('At least one range query boundary term must be non-empty term'); - } - - // require_once 'Zend/Search/Lucene/Search/Query/Range.php'; - $rangeQuery = new Zend_Search_Lucene_Search_Query_Range($from, $to, true); - // require_once 'Zend/Search/Lucene/Search/QueryEntry/Subquery.php'; - $entry = new Zend_Search_Lucene_Search_QueryEntry_Subquery($rangeQuery); - $this->_context->addEntry($entry); - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryParserContext.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryParserContext.php deleted file mode 100755 index 307819ae10c55003595fa5739c6ef41e898efe6e..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryParserContext.php +++ /dev/null @@ -1,401 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_Search_QueryToken */ -// require_once 'Zend/Search/Lucene/Search/QueryToken.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_QueryParserContext -{ - /** - * Default field for the context. - * - * null means, that term should be searched through all fields - * Zend_Search_Lucene_Search_Query::rewriteQuery($index) transletes such queries to several - * - * @var string|null - */ - private $_defaultField; - - /** - * Field specified for next entry - * - * @var string - */ - private $_nextEntryField = null; - - /** - * True means, that term is required. - * False means, that term is prohibited. - * null means, that term is neither prohibited, nor required - * - * @var boolean - */ - private $_nextEntrySign = null; - - - /** - * Entries grouping mode - */ - const GM_SIGNS = 0; // Signs mode: '+term1 term2 -term3 +(subquery1) -(subquery2)' - const GM_BOOLEAN = 1; // Boolean operators mode: 'term1 and term2 or (subquery1) and not (subquery2)' - - /** - * Grouping mode - * - * @var integer - */ - private $_mode = null; - - /** - * Entries signs. - * Used in GM_SIGNS grouping mode - * - * @var arrays - */ - private $_signs = array(); - - /** - * Query entries - * Each entry is a Zend_Search_Lucene_Search_QueryEntry object or - * boolean operator (Zend_Search_Lucene_Search_QueryToken class constant) - * - * @var array - */ - private $_entries = array(); - - /** - * Query string encoding - * - * @var string - */ - private $_encoding; - - - /** - * Context object constructor - * - * @param string $encoding - * @param string|null $defaultField - */ - public function __construct($encoding, $defaultField = null) - { - $this->_encoding = $encoding; - $this->_defaultField = $defaultField; - } - - - /** - * Get context default field - * - * @return string|null - */ - public function getField() - { - return ($this->_nextEntryField !== null) ? $this->_nextEntryField : $this->_defaultField; - } - - /** - * Set field for next entry - * - * @param string $field - */ - public function setNextEntryField($field) - { - $this->_nextEntryField = $field; - } - - - /** - * Set sign for next entry - * - * @param integer $sign - * @throws Zend_Search_Lucene_Exception - */ - public function setNextEntrySign($sign) - { - if ($this->_mode === self::GM_BOOLEAN) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('It\'s not allowed to mix boolean and signs styles in the same subquery.'); - } - - $this->_mode = self::GM_SIGNS; - - if ($sign == Zend_Search_Lucene_Search_QueryToken::TT_REQUIRED) { - $this->_nextEntrySign = true; - } else if ($sign == Zend_Search_Lucene_Search_QueryToken::TT_PROHIBITED) { - $this->_nextEntrySign = false; - } else { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Unrecognized sign type.'); - } - } - - - /** - * Add entry to a query - * - * @param Zend_Search_Lucene_Search_QueryEntry $entry - */ - public function addEntry(Zend_Search_Lucene_Search_QueryEntry $entry) - { - if ($this->_mode !== self::GM_BOOLEAN) { - $this->_signs[] = $this->_nextEntrySign; - } - - $this->_entries[] = $entry; - - $this->_nextEntryField = null; - $this->_nextEntrySign = null; - } - - - /** - * Process fuzzy search or proximity search modifier - * - * @throws Zend_Search_Lucene_Search_QueryParserException - */ - public function processFuzzyProximityModifier($parameter = null) - { - // Check, that modifier has came just after word or phrase - if ($this->_nextEntryField !== null || $this->_nextEntrySign !== null) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('\'~\' modifier must follow word or phrase.'); - } - - $lastEntry = array_pop($this->_entries); - - if (!$lastEntry instanceof Zend_Search_Lucene_Search_QueryEntry) { - // there are no entries or last entry is boolean operator - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('\'~\' modifier must follow word or phrase.'); - } - - $lastEntry->processFuzzyProximityModifier($parameter); - - $this->_entries[] = $lastEntry; - } - - /** - * Set boost factor to the entry - * - * @param float $boostFactor - */ - public function boost($boostFactor) - { - // Check, that modifier has came just after word or phrase - if ($this->_nextEntryField !== null || $this->_nextEntrySign !== null) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('\'^\' modifier must follow word, phrase or subquery.'); - } - - $lastEntry = array_pop($this->_entries); - - if (!$lastEntry instanceof Zend_Search_Lucene_Search_QueryEntry) { - // there are no entries or last entry is boolean operator - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('\'^\' modifier must follow word, phrase or subquery.'); - } - - $lastEntry->boost($boostFactor); - - $this->_entries[] = $lastEntry; - } - - /** - * Process logical operator - * - * @param integer $operator - */ - public function addLogicalOperator($operator) - { - if ($this->_mode === self::GM_SIGNS) { - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('It\'s not allowed to mix boolean and signs styles in the same subquery.'); - } - - $this->_mode = self::GM_BOOLEAN; - - $this->_entries[] = $operator; - } - - - /** - * Generate 'signs style' query from the context - * '+term1 term2 -term3 +(<subquery1>) ...' - * - * @return Zend_Search_Lucene_Search_Query - */ - public function _signStyleExpressionQuery() - { - // require_once 'Zend/Search/Lucene/Search/Query/Boolean.php'; - $query = new Zend_Search_Lucene_Search_Query_Boolean(); - - // require_once 'Zend/Search/Lucene/Search/QueryParser.php'; - if (Zend_Search_Lucene_Search_QueryParser::getDefaultOperator() == Zend_Search_Lucene_Search_QueryParser::B_AND) { - $defaultSign = true; // required - } else { - // Zend_Search_Lucene_Search_QueryParser::B_OR - $defaultSign = null; // optional - } - - foreach ($this->_entries as $entryId => $entry) { - $sign = ($this->_signs[$entryId] !== null) ? $this->_signs[$entryId] : $defaultSign; - $query->addSubquery($entry->getQuery($this->_encoding), $sign); - } - - return $query; - } - - - /** - * Generate 'boolean style' query from the context - * 'term1 and term2 or term3 and (<subquery1>) and not (<subquery2>)' - * - * @return Zend_Search_Lucene_Search_Query - * @throws Zend_Search_Lucene - */ - private function _booleanExpressionQuery() - { - /** - * We treat each level of an expression as a boolean expression in - * a Disjunctive Normal Form - * - * AND operator has higher precedence than OR - * - * Thus logical query is a disjunction of one or more conjunctions of - * one or more query entries - */ - - // require_once 'Zend/Search/Lucene/Search/BooleanExpressionRecognizer.php'; - $expressionRecognizer = new Zend_Search_Lucene_Search_BooleanExpressionRecognizer(); - - // require_once 'Zend/Search/Lucene/Exception.php'; - try { - foreach ($this->_entries as $entry) { - if ($entry instanceof Zend_Search_Lucene_Search_QueryEntry) { - $expressionRecognizer->processLiteral($entry); - } else { - switch ($entry) { - case Zend_Search_Lucene_Search_QueryToken::TT_AND_LEXEME: - $expressionRecognizer->processOperator(Zend_Search_Lucene_Search_BooleanExpressionRecognizer::IN_AND_OPERATOR); - break; - - case Zend_Search_Lucene_Search_QueryToken::TT_OR_LEXEME: - $expressionRecognizer->processOperator(Zend_Search_Lucene_Search_BooleanExpressionRecognizer::IN_OR_OPERATOR); - break; - - case Zend_Search_Lucene_Search_QueryToken::TT_NOT_LEXEME: - $expressionRecognizer->processOperator(Zend_Search_Lucene_Search_BooleanExpressionRecognizer::IN_NOT_OPERATOR); - break; - - default: - throw new Zend_Search_Lucene('Boolean expression error. Unknown operator type.'); - } - } - } - - $conjuctions = $expressionRecognizer->finishExpression(); - } catch (Zend_Search_Exception $e) { - // throw new Zend_Search_Lucene_Search_QueryParserException('Boolean expression error. Error message: \'' . - // $e->getMessage() . '\'.' ); - // It's query syntax error message and it should be user friendly. So FSM message is omitted - // require_once 'Zend/Search/Lucene/Search/QueryParserException.php'; - throw new Zend_Search_Lucene_Search_QueryParserException('Boolean expression error.', 0, $e); - } - - // Remove 'only negative' conjunctions - foreach ($conjuctions as $conjuctionId => $conjuction) { - $nonNegativeEntryFound = false; - - foreach ($conjuction as $conjuctionEntry) { - if ($conjuctionEntry[1]) { - $nonNegativeEntryFound = true; - break; - } - } - - if (!$nonNegativeEntryFound) { - unset($conjuctions[$conjuctionId]); - } - } - - - $subqueries = array(); - foreach ($conjuctions as $conjuction) { - // Check, if it's a one term conjuction - if (count($conjuction) == 1) { - $subqueries[] = $conjuction[0][0]->getQuery($this->_encoding); - } else { - // require_once 'Zend/Search/Lucene/Search/Query/Boolean.php'; - $subquery = new Zend_Search_Lucene_Search_Query_Boolean(); - - foreach ($conjuction as $conjuctionEntry) { - $subquery->addSubquery($conjuctionEntry[0]->getQuery($this->_encoding), $conjuctionEntry[1]); - } - - $subqueries[] = $subquery; - } - } - - if (count($subqueries) == 0) { - // require_once 'Zend/Search/Lucene/Search/Query/Insignificant.php'; - return new Zend_Search_Lucene_Search_Query_Insignificant(); - } - - if (count($subqueries) == 1) { - return $subqueries[0]; - } - - - // require_once 'Zend/Search/Lucene/Search/Query/Boolean.php'; - $query = new Zend_Search_Lucene_Search_Query_Boolean(); - - foreach ($subqueries as $subquery) { - // Non-requirered entry/subquery - $query->addSubquery($subquery); - } - - return $query; - } - - /** - * Generate query from current context - * - * @return Zend_Search_Lucene_Search_Query - */ - public function getQuery() - { - if ($this->_mode === self::GM_BOOLEAN) { - return $this->_booleanExpressionQuery(); - } else { - return $this->_signStyleExpressionQuery(); - } - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryParserException.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryParserException.php deleted file mode 100755 index f39819e7e94ad171d77873f177cb23e972394a7a..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryParserException.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * Zend_Search_Lucene base exception - */ -// require_once 'Zend/Search/Lucene/Exception.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * - * Special exception type, which may be used to intercept wrong user input - */ -class Zend_Search_Lucene_Search_QueryParserException extends Zend_Search_Lucene_Exception -{} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryToken.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryToken.php deleted file mode 100755 index a1af7f1f1feff2337ce1c23328156e15f9aa6b82..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/QueryToken.php +++ /dev/null @@ -1,225 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_QueryToken -{ - /** - * Token types. - */ - const TT_WORD = 0; // Word - const TT_PHRASE = 1; // Phrase (one or several quoted words) - const TT_FIELD = 2; // Field name in 'field:word', field:<phrase> or field:(<subquery>) pairs - const TT_FIELD_INDICATOR = 3; // ':' - const TT_REQUIRED = 4; // '+' - const TT_PROHIBITED = 5; // '-' - const TT_FUZZY_PROX_MARK = 6; // '~' - const TT_BOOSTING_MARK = 7; // '^' - const TT_RANGE_INCL_START = 8; // '[' - const TT_RANGE_INCL_END = 9; // ']' - const TT_RANGE_EXCL_START = 10; // '{' - const TT_RANGE_EXCL_END = 11; // '}' - const TT_SUBQUERY_START = 12; // '(' - const TT_SUBQUERY_END = 13; // ')' - const TT_AND_LEXEME = 14; // 'AND' or 'and' - const TT_OR_LEXEME = 15; // 'OR' or 'or' - const TT_NOT_LEXEME = 16; // 'NOT' or 'not' - const TT_TO_LEXEME = 17; // 'TO' or 'to' - const TT_NUMBER = 18; // Number, like: 10, 0.8, .64, .... - - - /** - * Returns all possible lexeme types. - * It's used for syntax analyzer state machine initialization - * - * @return array - */ - public static function getTypes() - { - return array( self::TT_WORD, - self::TT_PHRASE, - self::TT_FIELD, - self::TT_FIELD_INDICATOR, - self::TT_REQUIRED, - self::TT_PROHIBITED, - self::TT_FUZZY_PROX_MARK, - self::TT_BOOSTING_MARK, - self::TT_RANGE_INCL_START, - self::TT_RANGE_INCL_END, - self::TT_RANGE_EXCL_START, - self::TT_RANGE_EXCL_END, - self::TT_SUBQUERY_START, - self::TT_SUBQUERY_END, - self::TT_AND_LEXEME, - self::TT_OR_LEXEME, - self::TT_NOT_LEXEME, - self::TT_TO_LEXEME, - self::TT_NUMBER - ); - } - - - /** - * TokenCategories - */ - const TC_WORD = 0; // Word - const TC_PHRASE = 1; // Phrase (one or several quoted words) - const TC_NUMBER = 2; // Nubers, which are used with syntax elements. Ex. roam~0.8 - const TC_SYNTAX_ELEMENT = 3; // + - ( ) [ ] { } ! || && ~ ^ - - - /** - * Token type. - * - * @var integer - */ - public $type; - - /** - * Token text. - * - * @var integer - */ - public $text; - - /** - * Token position within query. - * - * @var integer - */ - public $position; - - - /** - * IndexReader constructor needs token type and token text as a parameters. - * - * @param integer $tokenCategory - * @param string $tokText - * @param integer $position - */ - public function __construct($tokenCategory, $tokenText, $position) - { - $this->text = $tokenText; - $this->position = $position + 1; // Start from 1 - - switch ($tokenCategory) { - case self::TC_WORD: - if ( strtolower($tokenText) == 'and') { - $this->type = self::TT_AND_LEXEME; - } else if (strtolower($tokenText) == 'or') { - $this->type = self::TT_OR_LEXEME; - } else if (strtolower($tokenText) == 'not') { - $this->type = self::TT_NOT_LEXEME; - } else if (strtolower($tokenText) == 'to') { - $this->type = self::TT_TO_LEXEME; - } else { - $this->type = self::TT_WORD; - } - break; - - case self::TC_PHRASE: - $this->type = self::TT_PHRASE; - break; - - case self::TC_NUMBER: - $this->type = self::TT_NUMBER; - break; - - case self::TC_SYNTAX_ELEMENT: - switch ($tokenText) { - case ':': - $this->type = self::TT_FIELD_INDICATOR; - break; - - case '+': - $this->type = self::TT_REQUIRED; - break; - - case '-': - $this->type = self::TT_PROHIBITED; - break; - - case '~': - $this->type = self::TT_FUZZY_PROX_MARK; - break; - - case '^': - $this->type = self::TT_BOOSTING_MARK; - break; - - case '[': - $this->type = self::TT_RANGE_INCL_START; - break; - - case ']': - $this->type = self::TT_RANGE_INCL_END; - break; - - case '{': - $this->type = self::TT_RANGE_EXCL_START; - break; - - case '}': - $this->type = self::TT_RANGE_EXCL_END; - break; - - case '(': - $this->type = self::TT_SUBQUERY_START; - break; - - case ')': - $this->type = self::TT_SUBQUERY_END; - break; - - case '!': - $this->type = self::TT_NOT_LEXEME; - break; - - case '&&': - $this->type = self::TT_AND_LEXEME; - break; - - case '||': - $this->type = self::TT_OR_LEXEME; - break; - - default: - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Unrecognized query syntax lexeme: \'' . $tokenText . '\''); - } - break; - - case self::TC_NUMBER: - $this->type = self::TT_NUMBER; - - default: - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Unrecognized lexeme type: \'' . $tokenCategory . '\''); - } - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Similarity.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Similarity.php deleted file mode 100755 index 38fddddcadf7d3f8a714b6a08c290580a18b6289..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Similarity.php +++ /dev/null @@ -1,551 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Search_Lucene_Search_Similarity -{ - /** - * The Similarity implementation used by default. - * - * @var Zend_Search_Lucene_Search_Similarity - */ - private static $_defaultImpl; - - /** - * Cache of decoded bytes. - * Array of floats - * - * @var array - */ - private static $_normTable = array( 0 => 0.0, - 1 => 5.820766E-10, - 2 => 6.9849193E-10, - 3 => 8.1490725E-10, - 4 => 9.313226E-10, - 5 => 1.1641532E-9, - 6 => 1.3969839E-9, - 7 => 1.6298145E-9, - 8 => 1.8626451E-9, - 9 => 2.3283064E-9, - 10 => 2.7939677E-9, - 11 => 3.259629E-9, - 12 => 3.7252903E-9, - 13 => 4.656613E-9, - 14 => 5.5879354E-9, - 15 => 6.519258E-9, - 16 => 7.4505806E-9, - 17 => 9.313226E-9, - 18 => 1.1175871E-8, - 19 => 1.3038516E-8, - 20 => 1.4901161E-8, - 21 => 1.8626451E-8, - 22 => 2.2351742E-8, - 23 => 2.6077032E-8, - 24 => 2.9802322E-8, - 25 => 3.7252903E-8, - 26 => 4.4703484E-8, - 27 => 5.2154064E-8, - 28 => 5.9604645E-8, - 29 => 7.4505806E-8, - 30 => 8.940697E-8, - 31 => 1.0430813E-7, - 32 => 1.1920929E-7, - 33 => 1.4901161E-7, - 34 => 1.7881393E-7, - 35 => 2.0861626E-7, - 36 => 2.3841858E-7, - 37 => 2.9802322E-7, - 38 => 3.5762787E-7, - 39 => 4.172325E-7, - 40 => 4.7683716E-7, - 41 => 5.9604645E-7, - 42 => 7.1525574E-7, - 43 => 8.34465E-7, - 44 => 9.536743E-7, - 45 => 1.1920929E-6, - 46 => 1.4305115E-6, - 47 => 1.66893E-6, - 48 => 1.9073486E-6, - 49 => 2.3841858E-6, - 50 => 2.861023E-6, - 51 => 3.33786E-6, - 52 => 3.8146973E-6, - 53 => 4.7683716E-6, - 54 => 5.722046E-6, - 55 => 6.67572E-6, - 56 => 7.6293945E-6, - 57 => 9.536743E-6, - 58 => 1.1444092E-5, - 59 => 1.335144E-5, - 60 => 1.5258789E-5, - 61 => 1.9073486E-5, - 62 => 2.2888184E-5, - 63 => 2.670288E-5, - 64 => 3.0517578E-5, - 65 => 3.8146973E-5, - 66 => 4.5776367E-5, - 67 => 5.340576E-5, - 68 => 6.1035156E-5, - 69 => 7.6293945E-5, - 70 => 9.1552734E-5, - 71 => 1.0681152E-4, - 72 => 1.2207031E-4, - 73 => 1.5258789E-4, - 74 => 1.8310547E-4, - 75 => 2.1362305E-4, - 76 => 2.4414062E-4, - 77 => 3.0517578E-4, - 78 => 3.6621094E-4, - 79 => 4.272461E-4, - 80 => 4.8828125E-4, - 81 => 6.1035156E-4, - 82 => 7.324219E-4, - 83 => 8.544922E-4, - 84 => 9.765625E-4, - 85 => 0.0012207031, - 86 => 0.0014648438, - 87 => 0.0017089844, - 88 => 0.001953125, - 89 => 0.0024414062, - 90 => 0.0029296875, - 91 => 0.0034179688, - 92 => 0.00390625, - 93 => 0.0048828125, - 94 => 0.005859375, - 95 => 0.0068359375, - 96 => 0.0078125, - 97 => 0.009765625, - 98 => 0.01171875, - 99 => 0.013671875, - 100 => 0.015625, - 101 => 0.01953125, - 102 => 0.0234375, - 103 => 0.02734375, - 104 => 0.03125, - 105 => 0.0390625, - 106 => 0.046875, - 107 => 0.0546875, - 108 => 0.0625, - 109 => 0.078125, - 110 => 0.09375, - 111 => 0.109375, - 112 => 0.125, - 113 => 0.15625, - 114 => 0.1875, - 115 => 0.21875, - 116 => 0.25, - 117 => 0.3125, - 118 => 0.375, - 119 => 0.4375, - 120 => 0.5, - 121 => 0.625, - 122 => 0.75, - 123 => 0.875, - 124 => 1.0, - 125 => 1.25, - 126 => 1.5, - 127 => 1.75, - 128 => 2.0, - 129 => 2.5, - 130 => 3.0, - 131 => 3.5, - 132 => 4.0, - 133 => 5.0, - 134 => 6.0, - 135 => 7.0, - 136 => 8.0, - 137 => 10.0, - 138 => 12.0, - 139 => 14.0, - 140 => 16.0, - 141 => 20.0, - 142 => 24.0, - 143 => 28.0, - 144 => 32.0, - 145 => 40.0, - 146 => 48.0, - 147 => 56.0, - 148 => 64.0, - 149 => 80.0, - 150 => 96.0, - 151 => 112.0, - 152 => 128.0, - 153 => 160.0, - 154 => 192.0, - 155 => 224.0, - 156 => 256.0, - 157 => 320.0, - 158 => 384.0, - 159 => 448.0, - 160 => 512.0, - 161 => 640.0, - 162 => 768.0, - 163 => 896.0, - 164 => 1024.0, - 165 => 1280.0, - 166 => 1536.0, - 167 => 1792.0, - 168 => 2048.0, - 169 => 2560.0, - 170 => 3072.0, - 171 => 3584.0, - 172 => 4096.0, - 173 => 5120.0, - 174 => 6144.0, - 175 => 7168.0, - 176 => 8192.0, - 177 => 10240.0, - 178 => 12288.0, - 179 => 14336.0, - 180 => 16384.0, - 181 => 20480.0, - 182 => 24576.0, - 183 => 28672.0, - 184 => 32768.0, - 185 => 40960.0, - 186 => 49152.0, - 187 => 57344.0, - 188 => 65536.0, - 189 => 81920.0, - 190 => 98304.0, - 191 => 114688.0, - 192 => 131072.0, - 193 => 163840.0, - 194 => 196608.0, - 195 => 229376.0, - 196 => 262144.0, - 197 => 327680.0, - 198 => 393216.0, - 199 => 458752.0, - 200 => 524288.0, - 201 => 655360.0, - 202 => 786432.0, - 203 => 917504.0, - 204 => 1048576.0, - 205 => 1310720.0, - 206 => 1572864.0, - 207 => 1835008.0, - 208 => 2097152.0, - 209 => 2621440.0, - 210 => 3145728.0, - 211 => 3670016.0, - 212 => 4194304.0, - 213 => 5242880.0, - 214 => 6291456.0, - 215 => 7340032.0, - 216 => 8388608.0, - 217 => 1.048576E7, - 218 => 1.2582912E7, - 219 => 1.4680064E7, - 220 => 1.6777216E7, - 221 => 2.097152E7, - 222 => 2.5165824E7, - 223 => 2.9360128E7, - 224 => 3.3554432E7, - 225 => 4.194304E7, - 226 => 5.0331648E7, - 227 => 5.8720256E7, - 228 => 6.7108864E7, - 229 => 8.388608E7, - 230 => 1.00663296E8, - 231 => 1.17440512E8, - 232 => 1.34217728E8, - 233 => 1.6777216E8, - 234 => 2.01326592E8, - 235 => 2.34881024E8, - 236 => 2.68435456E8, - 237 => 3.3554432E8, - 238 => 4.02653184E8, - 239 => 4.69762048E8, - 240 => 5.3687091E8, - 241 => 6.7108864E8, - 242 => 8.0530637E8, - 243 => 9.395241E8, - 244 => 1.07374182E9, - 245 => 1.34217728E9, - 246 => 1.61061274E9, - 247 => 1.87904819E9, - 248 => 2.14748365E9, - 249 => 2.68435456E9, - 250 => 3.22122547E9, - 251 => 3.75809638E9, - 252 => 4.2949673E9, - 253 => 5.3687091E9, - 254 => 6.4424509E9, - 255 => 7.5161928E9 ); - - - /** - * Set the default Similarity implementation used by indexing and search - * code. - * - * @param Zend_Search_Lucene_Search_Similarity $similarity - */ - public static function setDefault(Zend_Search_Lucene_Search_Similarity $similarity) - { - self::$_defaultImpl = $similarity; - } - - - /** - * Return the default Similarity implementation used by indexing and search - * code. - * - * @return Zend_Search_Lucene_Search_Similarity - */ - public static function getDefault() - { - if (!self::$_defaultImpl instanceof Zend_Search_Lucene_Search_Similarity) { - // require_once 'Zend/Search/Lucene/Search/Similarity/Default.php'; - self::$_defaultImpl = new Zend_Search_Lucene_Search_Similarity_Default(); - } - - return self::$_defaultImpl; - } - - - /** - * Computes the normalization value for a field given the total number of - * terms contained in a field. These values, together with field boosts, are - * stored in an index and multipled into scores for hits on each field by the - * search code. - * - * Matches in longer fields are less precise, so implemenations of this - * method usually return smaller values when 'numTokens' is large, - * and larger values when 'numTokens' is small. - * - * That these values are computed under - * IndexWriter::addDocument(Document) and stored then using - * encodeNorm(float). Thus they have limited precision, and documents - * must be re-indexed if this method is altered. - * - * fieldName - name of field - * numTokens - the total number of tokens contained in fields named - * 'fieldName' of 'doc'. - * Returns a normalization factor for hits on this field of this document - * - * @param string $fieldName - * @param integer $numTokens - * @return float - */ - abstract public function lengthNorm($fieldName, $numTokens); - - /** - * Computes the normalization value for a query given the sum of the squared - * weights of each of the query terms. This value is then multipled into the - * weight of each query term. - * - * This does not affect ranking, but rather just attempts to make scores - * from different queries comparable. - * - * sumOfSquaredWeights - the sum of the squares of query term weights - * Returns a normalization factor for query weights - * - * @param float $sumOfSquaredWeights - * @return float - */ - abstract public function queryNorm($sumOfSquaredWeights); - - - /** - * Decodes a normalization factor stored in an index. - * - * @param integer $byte - * @return float - */ - public static function decodeNorm($byte) - { - return self::$_normTable[$byte & 0xFF]; - } - - - /** - * Encodes a normalization factor for storage in an index. - * - * The encoding uses a five-bit exponent and three-bit mantissa, thus - * representing values from around 7x10^9 to 2x10^-9 with about one - * significant decimal digit of accuracy. Zero is also represented. - * Negative numbers are rounded up to zero. Values too large to represent - * are rounded down to the largest representable value. Positive values too - * small to represent are rounded up to the smallest positive representable - * value. - * - * @param float $f - * @return integer - */ - static function encodeNorm($f) - { - return self::_floatToByte($f); - } - - /** - * Float to byte conversion - * - * @param integer $b - * @return float - */ - private static function _floatToByte($f) - { - // round negatives up to zero - if ($f <= 0.0) { - return 0; - } - - // search for appropriate value - $lowIndex = 0; - $highIndex = 255; - while ($highIndex >= $lowIndex) { - // $mid = ($highIndex - $lowIndex)/2; - $mid = ($highIndex + $lowIndex) >> 1; - $delta = $f - self::$_normTable[$mid]; - - if ($delta < 0) { - $highIndex = $mid-1; - } elseif ($delta > 0) { - $lowIndex = $mid+1; - } else { - return $mid; // We got it! - } - } - - // round to closest value - if ($highIndex != 255 && - $f - self::$_normTable[$highIndex] > self::$_normTable[$highIndex+1] - $f ) { - return $highIndex + 1; - } else { - return $highIndex; - } - } - - - /** - * Computes a score factor based on a term or phrase's frequency in a - * document. This value is multiplied by the idf(Term, Searcher) - * factor for each term in the query and these products are then summed to - * form the initial score for a document. - * - * Terms and phrases repeated in a document indicate the topic of the - * document, so implementations of this method usually return larger values - * when 'freq' is large, and smaller values when 'freq' - * is small. - * - * freq - the frequency of a term within a document - * Returns a score factor based on a term's within-document frequency - * - * @param float $freq - * @return float - */ - abstract public function tf($freq); - - /** - * Computes the amount of a sloppy phrase match, based on an edit distance. - * This value is summed for each sloppy phrase match in a document to form - * the frequency that is passed to tf(float). - * - * A phrase match with a small edit distance to a document passage more - * closely matches the document, so implementations of this method usually - * return larger values when the edit distance is small and smaller values - * when it is large. - * - * distance - the edit distance of this sloppy phrase match - * Returns the frequency increment for this match - * - * @param integer $distance - * @return float - */ - abstract public function sloppyFreq($distance); - - - /** - * Computes a score factor for a simple term or a phrase. - * - * The default implementation is: - * return idfFreq(searcher.docFreq(term), searcher.maxDoc()); - * - * input - the term in question or array of terms - * reader - reader the document collection being searched - * Returns a score factor for the term - * - * @param mixed $input - * @param Zend_Search_Lucene_Interface $reader - * @return a score factor for the term - */ - public function idf($input, Zend_Search_Lucene_Interface $reader) - { - if (!is_array($input)) { - return $this->idfFreq($reader->docFreq($input), $reader->count()); - } else { - $idf = 0.0; - foreach ($input as $term) { - $idf += $this->idfFreq($reader->docFreq($term), $reader->count()); - } - return $idf; - } - } - - /** - * Computes a score factor based on a term's document frequency (the number - * of documents which contain the term). This value is multiplied by the - * tf(int) factor for each term in the query and these products are - * then summed to form the initial score for a document. - * - * Terms that occur in fewer documents are better indicators of topic, so - * implemenations of this method usually return larger values for rare terms, - * and smaller values for common terms. - * - * docFreq - the number of documents which contain the term - * numDocs - the total number of documents in the collection - * Returns a score factor based on the term's document frequency - * - * @param integer $docFreq - * @param integer $numDocs - * @return float - */ - abstract public function idfFreq($docFreq, $numDocs); - - /** - * Computes a score factor based on the fraction of all query terms that a - * document contains. This value is multiplied into scores. - * - * The presence of a large portion of the query terms indicates a better - * match with the query, so implemenations of this method usually return - * larger values when the ratio between these parameters is large and smaller - * values when the ratio between them is small. - * - * overlap - the number of query terms matched in the document - * maxOverlap - the total number of terms in the query - * Returns a score factor based on term overlap with the query - * - * @param integer $overlap - * @param integer $maxOverlap - * @return float - */ - abstract public function coord($overlap, $maxOverlap); -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Similarity/Default.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Similarity/Default.php deleted file mode 100755 index c84b9d45179f253640b605a47c056b3ac98fb4ae..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Similarity/Default.php +++ /dev/null @@ -1,110 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Similarity */ -// require_once 'Zend/Search/Lucene/Search/Similarity.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Similarity_Default extends Zend_Search_Lucene_Search_Similarity -{ - - /** - * Implemented as '1/sqrt(numTerms)'. - * - * @param string $fieldName - * @param integer $numTerms - * @return float - */ - public function lengthNorm($fieldName, $numTerms) - { - if ($numTerms == 0) { - return 1E10; - } - - return 1.0/sqrt($numTerms); - } - - /** - * Implemented as '1/sqrt(sumOfSquaredWeights)'. - * - * @param float $sumOfSquaredWeights - * @return float - */ - public function queryNorm($sumOfSquaredWeights) - { - return 1.0/sqrt($sumOfSquaredWeights); - } - - /** - * Implemented as 'sqrt(freq)'. - * - * @param float $freq - * @return float - */ - public function tf($freq) - { - return sqrt($freq); - } - - /** - * Implemented as '1/(distance + 1)'. - * - * @param integer $distance - * @return float - */ - public function sloppyFreq($distance) - { - return 1.0/($distance + 1); - } - - /** - * Implemented as 'log(numDocs/(docFreq+1)) + 1'. - * - * @param integer $docFreq - * @param integer $numDocs - * @return float - */ - public function idfFreq($docFreq, $numDocs) - { - return log($numDocs/(float)($docFreq+1)) + 1.0; - } - - /** - * Implemented as 'overlap/maxOverlap'. - * - * @param integer $overlap - * @param integer $maxOverlap - * @return float - */ - public function coord($overlap, $maxOverlap) - { - return $overlap/(float)$maxOverlap; - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight.php deleted file mode 100755 index 21c05185084c55d695c915f372ae3d29abc1f46b..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight.php +++ /dev/null @@ -1,85 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * Calculate query weights and build query scorers. - * - * A Weight is constructed by a query Query->createWeight(). - * The sumOfSquaredWeights() method is then called on the top-level - * query to compute the query normalization factor Similarity->queryNorm(float). - * This factor is then passed to normalize(float). At this point the weighting - * is complete. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Search_Lucene_Search_Weight -{ - /** - * Normalization factor. - * This value is stored only for query expanation purpose and not used in any other place - * - * @var float - */ - protected $_queryNorm; - - /** - * Weight value - * - * Weight value may be initialized in sumOfSquaredWeights() or normalize() - * because they both are invoked either in Query::_initWeight (for top-level query) or - * in corresponding methods of parent query's weights - * - * @var float - */ - protected $_value; - - - /** - * The weight for this query. - * - * @return float - */ - public function getValue() - { - return $this->_value; - } - - /** - * The sum of squared weights of contained query clauses. - * - * @return float - */ - abstract public function sumOfSquaredWeights(); - - /** - * Assigns the query normalization factor to this. - * - * @param float $norm - */ - abstract public function normalize($norm); -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight/Boolean.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight/Boolean.php deleted file mode 100755 index fcb98de13392180c89ad117e8ded0005fd5e0d53..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight/Boolean.php +++ /dev/null @@ -1,137 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Weight */ -// require_once 'Zend/Search/Lucene/Search/Weight.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Weight_Boolean extends Zend_Search_Lucene_Search_Weight -{ - /** - * IndexReader. - * - * @var Zend_Search_Lucene_Interface - */ - private $_reader; - - /** - * The query that this concerns. - * - * @var Zend_Search_Lucene_Search_Query - */ - private $_query; - - /** - * Queries weights - * Array of Zend_Search_Lucene_Search_Weight - * - * @var array - */ - private $_weights; - - - /** - * Zend_Search_Lucene_Search_Weight_Boolean constructor - * query - the query that this concerns. - * reader - index reader - * - * @param Zend_Search_Lucene_Search_Query $query - * @param Zend_Search_Lucene_Interface $reader - */ - public function __construct(Zend_Search_Lucene_Search_Query $query, - Zend_Search_Lucene_Interface $reader) - { - $this->_query = $query; - $this->_reader = $reader; - $this->_weights = array(); - - $signs = $query->getSigns(); - - foreach ($query->getSubqueries() as $num => $subquery) { - if ($signs === null || $signs[$num] === null || $signs[$num]) { - $this->_weights[$num] = $subquery->createWeight($reader); - } - } - } - - - /** - * The weight for this query - * Standard Weight::$_value is not used for boolean queries - * - * @return float - */ - public function getValue() - { - return $this->_query->getBoost(); - } - - - /** - * The sum of squared weights of contained query clauses. - * - * @return float - */ - public function sumOfSquaredWeights() - { - $sum = 0; - foreach ($this->_weights as $weight) { - // sum sub weights - $sum += $weight->sumOfSquaredWeights(); - } - - // boost each sub-weight - $sum *= $this->_query->getBoost() * $this->_query->getBoost(); - - // check for empty query (like '-something -another') - if ($sum == 0) { - $sum = 1.0; - } - return $sum; - } - - - /** - * Assigns the query normalization factor to this. - * - * @param float $queryNorm - */ - public function normalize($queryNorm) - { - // incorporate boost - $queryNorm *= $this->_query->getBoost(); - - foreach ($this->_weights as $weight) { - $weight->normalize($queryNorm); - } - } -} - - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight/Empty.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight/Empty.php deleted file mode 100755 index 94d8a94d9b598b64134b34c0fb8d0ffedcead065..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight/Empty.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Weight */ -// require_once 'Zend/Search/Lucene/Search/Weight.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Weight_Empty extends Zend_Search_Lucene_Search_Weight -{ - /** - * The sum of squared weights of contained query clauses. - * - * @return float - */ - public function sumOfSquaredWeights() - { - return 1; - } - - - /** - * Assigns the query normalization factor to this. - * - * @param float $queryNorm - */ - public function normalize($queryNorm) - { - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight/MultiTerm.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight/MultiTerm.php deleted file mode 100755 index 523fbbdc9a8b48207e26c435e918f0aa0bdfed44..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight/MultiTerm.php +++ /dev/null @@ -1,139 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Weight */ -// require_once 'Zend/Search/Lucene/Search/Weight.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Weight_MultiTerm extends Zend_Search_Lucene_Search_Weight -{ - /** - * IndexReader. - * - * @var Zend_Search_Lucene_Interface - */ - private $_reader; - - /** - * The query that this concerns. - * - * @var Zend_Search_Lucene_Search_Query - */ - private $_query; - - /** - * Query terms weights - * Array of Zend_Search_Lucene_Search_Weight_Term - * - * @var array - */ - private $_weights; - - - /** - * Zend_Search_Lucene_Search_Weight_MultiTerm constructor - * query - the query that this concerns. - * reader - index reader - * - * @param Zend_Search_Lucene_Search_Query $query - * @param Zend_Search_Lucene_Interface $reader - */ - public function __construct(Zend_Search_Lucene_Search_Query $query, - Zend_Search_Lucene_Interface $reader) - { - $this->_query = $query; - $this->_reader = $reader; - $this->_weights = array(); - - $signs = $query->getSigns(); - - foreach ($query->getTerms() as $id => $term) { - if ($signs === null || $signs[$id] === null || $signs[$id]) { - // require_once 'Zend/Search/Lucene/Search/Weight/Term.php'; - $this->_weights[$id] = new Zend_Search_Lucene_Search_Weight_Term($term, $query, $reader); - $query->setWeight($id, $this->_weights[$id]); - } - } - } - - - /** - * The weight for this query - * Standard Weight::$_value is not used for boolean queries - * - * @return float - */ - public function getValue() - { - return $this->_query->getBoost(); - } - - - /** - * The sum of squared weights of contained query clauses. - * - * @return float - */ - public function sumOfSquaredWeights() - { - $sum = 0; - foreach ($this->_weights as $weight) { - // sum sub weights - $sum += $weight->sumOfSquaredWeights(); - } - - // boost each sub-weight - $sum *= $this->_query->getBoost() * $this->_query->getBoost(); - - // check for empty query (like '-something -another') - if ($sum == 0) { - $sum = 1.0; - } - return $sum; - } - - - /** - * Assigns the query normalization factor to this. - * - * @param float $queryNorm - */ - public function normalize($queryNorm) - { - // incorporate boost - $queryNorm *= $this->_query->getBoost(); - - foreach ($this->_weights as $weight) { - $weight->normalize($queryNorm); - } - } -} - - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight/Phrase.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight/Phrase.php deleted file mode 100755 index 6f6c7ea7bc93dce53467907c27e330de4144fbb6..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight/Phrase.php +++ /dev/null @@ -1,108 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * Zend_Search_Lucene_Search_Weight - */ -// require_once 'Zend/Search/Lucene/Search/Weight.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Weight_Phrase extends Zend_Search_Lucene_Search_Weight -{ - /** - * IndexReader. - * - * @var Zend_Search_Lucene_Interface - */ - private $_reader; - - /** - * The query that this concerns. - * - * @var Zend_Search_Lucene_Search_Query_Phrase - */ - private $_query; - - /** - * Score factor - * - * @var float - */ - private $_idf; - - /** - * Zend_Search_Lucene_Search_Weight_Phrase constructor - * - * @param Zend_Search_Lucene_Search_Query_Phrase $query - * @param Zend_Search_Lucene_Interface $reader - */ - public function __construct(Zend_Search_Lucene_Search_Query_Phrase $query, - Zend_Search_Lucene_Interface $reader) - { - $this->_query = $query; - $this->_reader = $reader; - } - - /** - * The sum of squared weights of contained query clauses. - * - * @return float - */ - public function sumOfSquaredWeights() - { - // compute idf - $this->_idf = $this->_reader->getSimilarity()->idf($this->_query->getTerms(), $this->_reader); - - // compute query weight - $this->_queryWeight = $this->_idf * $this->_query->getBoost(); - - // square it - return $this->_queryWeight * $this->_queryWeight; - } - - - /** - * Assigns the query normalization factor to this. - * - * @param float $queryNorm - */ - public function normalize($queryNorm) - { - $this->_queryNorm = $queryNorm; - - // normalize query weight - $this->_queryWeight *= $queryNorm; - - // idf for documents - $this->_value = $this->_queryWeight * $this->_idf; - } -} - - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight/Term.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight/Term.php deleted file mode 100755 index 9912bdc872eae056a7bc1a2398be5b101fd16b3d..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Search/Weight/Term.php +++ /dev/null @@ -1,125 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Search_Weight */ -// require_once 'Zend/Search/Lucene/Search/Weight.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Search_Weight_Term extends Zend_Search_Lucene_Search_Weight -{ - /** - * IndexReader. - * - * @var Zend_Search_Lucene_Interface - */ - private $_reader; - - /** - * Term - * - * @var Zend_Search_Lucene_Index_Term - */ - private $_term; - - /** - * The query that this concerns. - * - * @var Zend_Search_Lucene_Search_Query - */ - private $_query; - - /** - * Score factor - * - * @var float - */ - private $_idf; - - /** - * Query weight - * - * @var float - */ - private $_queryWeight; - - - /** - * Zend_Search_Lucene_Search_Weight_Term constructor - * reader - index reader - * - * @param Zend_Search_Lucene_Index_Term $term - * @param Zend_Search_Lucene_Search_Query $query - * @param Zend_Search_Lucene_Interface $reader - */ - public function __construct(Zend_Search_Lucene_Index_Term $term, - Zend_Search_Lucene_Search_Query $query, - Zend_Search_Lucene_Interface $reader) - { - $this->_term = $term; - $this->_query = $query; - $this->_reader = $reader; - } - - - /** - * The sum of squared weights of contained query clauses. - * - * @return float - */ - public function sumOfSquaredWeights() - { - // compute idf - $this->_idf = $this->_reader->getSimilarity()->idf($this->_term, $this->_reader); - - // compute query weight - $this->_queryWeight = $this->_idf * $this->_query->getBoost(); - - // square it - return $this->_queryWeight * $this->_queryWeight; - } - - - /** - * Assigns the query normalization factor to this. - * - * @param float $queryNorm - */ - public function normalize($queryNorm) - { - $this->_queryNorm = $queryNorm; - - // normalize query weight - $this->_queryWeight *= $queryNorm; - - // idf for documents - $this->_value = $this->_queryWeight * $this->_idf; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Storage/Directory.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Storage/Directory.php deleted file mode 100755 index 1dd550520c7809a6095e253fc4b15ece079295cb..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Storage/Directory.php +++ /dev/null @@ -1,136 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Storage - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Storage - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Search_Lucene_Storage_Directory -{ - - /** - * Closes the store. - * - * @return void - */ - abstract public function close(); - - /** - * Returns an array of strings, one for each file in the directory. - * - * @return array - */ - abstract public function fileList(); - - /** - * Creates a new, empty file in the directory with the given $filename. - * - * @param string $filename - * @return Zend_Search_Lucene_Storage_File - */ - abstract public function createFile($filename); - - - /** - * Removes an existing $filename in the directory. - * - * @param string $filename - * @return void - */ - abstract public function deleteFile($filename); - - /** - * Purge file if it's cached by directory object - * - * Method is used to prevent 'too many open files' error - * - * @param string $filename - * @return void - */ - abstract public function purgeFile($filename); - - /** - * Returns true if a file with the given $filename exists. - * - * @param string $filename - * @return boolean - */ - abstract public function fileExists($filename); - - - /** - * Returns the length of a $filename in the directory. - * - * @param string $filename - * @return integer - */ - abstract public function fileLength($filename); - - - /** - * Returns the UNIX timestamp $filename was last modified. - * - * @param string $filename - * @return integer - */ - abstract public function fileModified($filename); - - - /** - * Renames an existing file in the directory. - * - * @param string $from - * @param string $to - * @return void - */ - abstract public function renameFile($from, $to); - - - /** - * Sets the modified time of $filename to now. - * - * @param string $filename - * @return void - */ - abstract public function touchFile($filename); - - - /** - * Returns a Zend_Search_Lucene_Storage_File object for a given $filename in the directory. - * - * If $shareHandler option is true, then file handler can be shared between File Object - * requests. It speed-ups performance, but makes problems with file position. - * Shared handler are good for short atomic requests. - * Non-shared handlers are useful for stream file reading (especial for compound files). - * - * @param string $filename - * @param boolean $shareHandler - * @return Zend_Search_Lucene_Storage_File - */ - abstract public function getFileObject($filename, $shareHandler = true); - -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Storage/Directory/Filesystem.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Storage/Directory/Filesystem.php deleted file mode 100755 index a622a64333aedfb7c0e5c640d7a5a67b3973d290..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Storage/Directory/Filesystem.php +++ /dev/null @@ -1,364 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Storage - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** Zend_Search_Lucene_Storage_Directory */ -// require_once 'Zend/Search/Lucene/Storage/Directory.php'; - - -/** - * FileSystem implementation of Directory abstraction. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Storage - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Storage_Directory_Filesystem extends Zend_Search_Lucene_Storage_Directory -{ - /** - * Filesystem path to the directory - * - * @var string - */ - protected $_dirPath = null; - - /** - * Cache for Zend_Search_Lucene_Storage_File_Filesystem objects - * Array: filename => Zend_Search_Lucene_Storage_File object - * - * @var array - * @throws Zend_Search_Lucene_Exception - */ - protected $_fileHandlers; - - /** - * Default file permissions - * - * @var integer - */ - protected static $_defaultFilePermissions = 0666; - - - /** - * Get default file permissions - * - * @return integer - */ - public static function getDefaultFilePermissions() - { - return self::$_defaultFilePermissions; - } - - /** - * Set default file permissions - * - * @param integer $mode - */ - public static function setDefaultFilePermissions($mode) - { - self::$_defaultFilePermissions = $mode; - } - - - /** - * Utility function to recursive directory creation - * - * @param string $dir - * @param integer $mode - * @param boolean $recursive - * @return boolean - */ - - public static function mkdirs($dir, $mode = 0775, $recursive = true) - { - $mode = $mode & ~0002; - - if (($dir === null) || $dir === '') { - return false; - } - if (is_dir($dir) || $dir === '/') { - return true; - } - if (self::mkdirs(dirname($dir), $mode, $recursive)) { - return mkdir($dir, $mode); - } - return false; - } - - - /** - * Object constructor - * Checks if $path is a directory or tries to create it. - * - * @param string $path - * @throws Zend_Search_Lucene_Exception - */ - public function __construct($path) - { - if (!is_dir($path)) { - if (file_exists($path)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Path exists, but it\'s not a directory'); - } else { - if (!self::mkdirs($path)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception("Can't create directory '$path'."); - } - } - } - $this->_dirPath = $path; - $this->_fileHandlers = array(); - } - - - /** - * Closes the store. - * - * @return void - */ - public function close() - { - foreach ($this->_fileHandlers as $fileObject) { - $fileObject->close(); - } - - $this->_fileHandlers = array(); - } - - - /** - * Returns an array of strings, one for each file in the directory. - * - * @return array - */ - public function fileList() - { - $result = array(); - - $dirContent = opendir( $this->_dirPath ); - while (($file = readdir($dirContent)) !== false) { - if (($file == '..')||($file == '.')) continue; - - if( !is_dir($this->_dirPath . '/' . $file) ) { - $result[] = $file; - } - } - closedir($dirContent); - - return $result; - } - - /** - * Creates a new, empty file in the directory with the given $filename. - * - * @param string $filename - * @return Zend_Search_Lucene_Storage_File - * @throws Zend_Search_Lucene_Exception - */ - public function createFile($filename) - { - if (isset($this->_fileHandlers[$filename])) { - $this->_fileHandlers[$filename]->close(); - } - unset($this->_fileHandlers[$filename]); - // require_once 'Zend/Search/Lucene/Storage/File/Filesystem.php'; - $this->_fileHandlers[$filename] = new Zend_Search_Lucene_Storage_File_Filesystem($this->_dirPath . '/' . $filename, 'w+b'); - - // Set file permissions, but don't care about any possible failures, since file may be already - // created by anther user which has to care about right permissions - @chmod($this->_dirPath . '/' . $filename, self::$_defaultFilePermissions); - - return $this->_fileHandlers[$filename]; - } - - - /** - * Removes an existing $filename in the directory. - * - * @param string $filename - * @return void - * @throws Zend_Search_Lucene_Exception - */ - public function deleteFile($filename) - { - if (isset($this->_fileHandlers[$filename])) { - $this->_fileHandlers[$filename]->close(); - } - unset($this->_fileHandlers[$filename]); - - global $php_errormsg; - $trackErrors = ini_get('track_errors'); - ini_set('track_errors', '1'); - if (!@unlink($this->_dirPath . '/' . $filename)) { - ini_set('track_errors', $trackErrors); - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Can\'t delete file: ' . $php_errormsg); - } - ini_set('track_errors', $trackErrors); - } - - /** - * Purge file if it's cached by directory object - * - * Method is used to prevent 'too many open files' error - * - * @param string $filename - * @return void - */ - public function purgeFile($filename) - { - if (isset($this->_fileHandlers[$filename])) { - $this->_fileHandlers[$filename]->close(); - } - unset($this->_fileHandlers[$filename]); - } - - - /** - * Returns true if a file with the given $filename exists. - * - * @param string $filename - * @return boolean - */ - public function fileExists($filename) - { - return isset($this->_fileHandlers[$filename]) || - file_exists($this->_dirPath . '/' . $filename); - } - - - /** - * Returns the length of a $filename in the directory. - * - * @param string $filename - * @return integer - */ - public function fileLength($filename) - { - if (isset( $this->_fileHandlers[$filename] )) { - return $this->_fileHandlers[$filename]->size(); - } - return filesize($this->_dirPath .'/'. $filename); - } - - - /** - * Returns the UNIX timestamp $filename was last modified. - * - * @param string $filename - * @return integer - */ - public function fileModified($filename) - { - return filemtime($this->_dirPath .'/'. $filename); - } - - - /** - * Renames an existing file in the directory. - * - * @param string $from - * @param string $to - * @return void - * @throws Zend_Search_Lucene_Exception - */ - public function renameFile($from, $to) - { - global $php_errormsg; - - if (isset($this->_fileHandlers[$from])) { - $this->_fileHandlers[$from]->close(); - } - unset($this->_fileHandlers[$from]); - - if (isset($this->_fileHandlers[$to])) { - $this->_fileHandlers[$to]->close(); - } - unset($this->_fileHandlers[$to]); - - if (file_exists($this->_dirPath . '/' . $to)) { - if (!unlink($this->_dirPath . '/' . $to)) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Delete operation failed'); - } - } - - $trackErrors = ini_get('track_errors'); - ini_set('track_errors', '1'); - - $success = @rename($this->_dirPath . '/' . $from, $this->_dirPath . '/' . $to); - if (!$success) { - ini_set('track_errors', $trackErrors); - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception($php_errormsg); - } - - ini_set('track_errors', $trackErrors); - - return $success; - } - - - /** - * Sets the modified time of $filename to now. - * - * @param string $filename - * @return void - */ - public function touchFile($filename) - { - return touch($this->_dirPath .'/'. $filename); - } - - - /** - * Returns a Zend_Search_Lucene_Storage_File object for a given $filename in the directory. - * - * If $shareHandler option is true, then file handler can be shared between File Object - * requests. It speed-ups performance, but makes problems with file position. - * Shared handler are good for short atomic requests. - * Non-shared handlers are useful for stream file reading (especial for compound files). - * - * @param string $filename - * @param boolean $shareHandler - * @return Zend_Search_Lucene_Storage_File - */ - public function getFileObject($filename, $shareHandler = true) - { - $fullFilename = $this->_dirPath . '/' . $filename; - - // require_once 'Zend/Search/Lucene/Storage/File/Filesystem.php'; - if (!$shareHandler) { - return new Zend_Search_Lucene_Storage_File_Filesystem($fullFilename); - } - - if (isset( $this->_fileHandlers[$filename] )) { - $this->_fileHandlers[$filename]->seek(0); - return $this->_fileHandlers[$filename]; - } - - $this->_fileHandlers[$filename] = new Zend_Search_Lucene_Storage_File_Filesystem($fullFilename); - return $this->_fileHandlers[$filename]; - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Storage/File.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Storage/File.php deleted file mode 100755 index 61fc2c1ab3b39553257fe4a897dccacf7631de3f..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Storage/File.php +++ /dev/null @@ -1,473 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Storage - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Storage - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Search_Lucene_Storage_File -{ - /** - * Reads $length number of bytes at the current position in the - * file and advances the file pointer. - * - * @param integer $length - * @return string - */ - abstract protected function _fread($length=1); - - - /** - * Sets the file position indicator and advances the file pointer. - * The new position, measured in bytes from the beginning of the file, - * is obtained by adding offset to the position specified by whence, - * whose values are defined as follows: - * SEEK_SET - Set position equal to offset bytes. - * SEEK_CUR - Set position to current location plus offset. - * SEEK_END - Set position to end-of-file plus offset. (To move to - * a position before the end-of-file, you need to pass a negative value - * in offset.) - * Upon success, returns 0; otherwise, returns -1 - * - * @param integer $offset - * @param integer $whence - * @return integer - */ - abstract public function seek($offset, $whence=SEEK_SET); - - /** - * Get file position. - * - * @return integer - */ - abstract public function tell(); - - /** - * Flush output. - * - * Returns true on success or false on failure. - * - * @return boolean - */ - abstract public function flush(); - - /** - * Writes $length number of bytes (all, if $length===null) to the end - * of the file. - * - * @param string $data - * @param integer $length - */ - abstract protected function _fwrite($data, $length=null); - - /** - * Lock file - * - * Lock type may be a LOCK_SH (shared lock) or a LOCK_EX (exclusive lock) - * - * @param integer $lockType - * @return boolean - */ - abstract public function lock($lockType, $nonBlockinLock = false); - - /** - * Unlock file - */ - abstract public function unlock(); - - /** - * Reads a byte from the current position in the file - * and advances the file pointer. - * - * @return integer - */ - public function readByte() - { - return ord($this->_fread(1)); - } - - /** - * Writes a byte to the end of the file. - * - * @param integer $byte - */ - public function writeByte($byte) - { - return $this->_fwrite(chr($byte), 1); - } - - /** - * Read num bytes from the current position in the file - * and advances the file pointer. - * - * @param integer $num - * @return string - */ - public function readBytes($num) - { - return $this->_fread($num); - } - - /** - * Writes num bytes of data (all, if $num===null) to the end - * of the string. - * - * @param string $data - * @param integer $num - */ - public function writeBytes($data, $num=null) - { - $this->_fwrite($data, $num); - } - - - /** - * Reads an integer from the current position in the file - * and advances the file pointer. - * - * @return integer - */ - public function readInt() - { - $str = $this->_fread(4); - - return ord($str[0]) << 24 | - ord($str[1]) << 16 | - ord($str[2]) << 8 | - ord($str[3]); - } - - - /** - * Writes an integer to the end of file. - * - * @param integer $value - */ - public function writeInt($value) - { - settype($value, 'integer'); - $this->_fwrite( chr($value>>24 & 0xFF) . - chr($value>>16 & 0xFF) . - chr($value>>8 & 0xFF) . - chr($value & 0xFF), 4 ); - } - - - /** - * Returns a long integer from the current position in the file - * and advances the file pointer. - * - * @return integer|float - * @throws Zend_Search_Lucene_Exception - */ - public function readLong() - { - /** - * Check, that we work in 64-bit mode. - * fseek() uses long for offset. Thus, largest index segment file size in 32bit mode is 2Gb - */ - if (PHP_INT_SIZE > 4) { - $str = $this->_fread(8); - - return ord($str[0]) << 56 | - ord($str[1]) << 48 | - ord($str[2]) << 40 | - ord($str[3]) << 32 | - ord($str[4]) << 24 | - ord($str[5]) << 16 | - ord($str[6]) << 8 | - ord($str[7]); - } else { - return $this->readLong32Bit(); - } - } - - /** - * Writes long integer to the end of file - * - * @param integer $value - * @throws Zend_Search_Lucene_Exception - */ - public function writeLong($value) - { - /** - * Check, that we work in 64-bit mode. - * fseek() and ftell() use long for offset. Thus, largest index segment file size in 32bit mode is 2Gb - */ - if (PHP_INT_SIZE > 4) { - settype($value, 'integer'); - $this->_fwrite( chr($value>>56 & 0xFF) . - chr($value>>48 & 0xFF) . - chr($value>>40 & 0xFF) . - chr($value>>32 & 0xFF) . - chr($value>>24 & 0xFF) . - chr($value>>16 & 0xFF) . - chr($value>>8 & 0xFF) . - chr($value & 0xFF), 8 ); - } else { - $this->writeLong32Bit($value); - } - } - - - /** - * Returns a long integer from the current position in the file, - * advances the file pointer and return it as float (for 32-bit platforms). - * - * @return integer|float - * @throws Zend_Search_Lucene_Exception - */ - public function readLong32Bit() - { - $wordHigh = $this->readInt(); - $wordLow = $this->readInt(); - - if ($wordHigh & (int)0x80000000) { - // It's a negative value since the highest bit is set - if ($wordHigh == (int)0xFFFFFFFF && ($wordLow & (int)0x80000000)) { - return $wordLow; - } else { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Long integers lower than -2147483648 (0x80000000) are not supported on 32-bit platforms.'); - } - - } - - if ($wordLow < 0) { - // Value is large than 0x7FFF FFFF. Represent low word as float. - $wordLow &= 0x7FFFFFFF; - $wordLow += (float)0x80000000; - } - - if ($wordHigh == 0) { - // Return value as integer if possible - return $wordLow; - } - - return $wordHigh*(float)0x100000000/* 0x00000001 00000000 */ + $wordLow; - } - - - /** - * Writes long integer to the end of file (32-bit platforms implementation) - * - * @param integer|float $value - * @throws Zend_Search_Lucene_Exception - */ - public function writeLong32Bit($value) - { - if ($value < (int)0x80000000) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Long integers lower than -2147483648 (0x80000000) are not supported on 32-bit platforms.'); - } - - if ($value < 0) { - $wordHigh = (int)0xFFFFFFFF; - $wordLow = (int)$value; - } else { - $wordHigh = (int)($value/(float)0x100000000/* 0x00000001 00000000 */); - $wordLow = $value - $wordHigh*(float)0x100000000/* 0x00000001 00000000 */; - - if ($wordLow > 0x7FFFFFFF) { - // Highest bit of low word is set. Translate it to the corresponding negative integer value - $wordLow -= 0x80000000; - $wordLow |= 0x80000000; - } - } - - $this->writeInt($wordHigh); - $this->writeInt($wordLow); - } - - - /** - * Returns a variable-length integer from the current - * position in the file and advances the file pointer. - * - * @return integer - */ - public function readVInt() - { - $nextByte = ord($this->_fread(1)); - $val = $nextByte & 0x7F; - - for ($shift=7; ($nextByte & 0x80) != 0; $shift += 7) { - $nextByte = ord($this->_fread(1)); - $val |= ($nextByte & 0x7F) << $shift; - } - return $val; - } - - /** - * Writes a variable-length integer to the end of file. - * - * @param integer $value - */ - public function writeVInt($value) - { - settype($value, 'integer'); - while ($value > 0x7F) { - $this->_fwrite(chr( ($value & 0x7F)|0x80 )); - $value >>= 7; - } - $this->_fwrite(chr($value)); - } - - - /** - * Reads a string from the current position in the file - * and advances the file pointer. - * - * @return string - */ - public function readString() - { - $strlen = $this->readVInt(); - if ($strlen == 0) { - return ''; - } else { - /** - * This implementation supports only Basic Multilingual Plane - * (BMP) characters (from 0x0000 to 0xFFFF) and doesn't support - * "supplementary characters" (characters whose code points are - * greater than 0xFFFF) - * Java 2 represents these characters as a pair of char (16-bit) - * values, the first from the high-surrogates range (0xD800-0xDBFF), - * the second from the low-surrogates range (0xDC00-0xDFFF). Then - * they are encoded as usual UTF-8 characters in six bytes. - * Standard UTF-8 representation uses four bytes for supplementary - * characters. - */ - - $str_val = $this->_fread($strlen); - - for ($count = 0; $count < $strlen; $count++ ) { - if (( ord($str_val[$count]) & 0xC0 ) == 0xC0) { - $addBytes = 1; - if (ord($str_val[$count]) & 0x20 ) { - $addBytes++; - - // Never used. Java2 doesn't encode strings in four bytes - if (ord($str_val[$count]) & 0x10 ) { - $addBytes++; - } - } - $str_val .= $this->_fread($addBytes); - $strlen += $addBytes; - - // Check for null character. Java2 encodes null character - // in two bytes. - if (ord($str_val[$count]) == 0xC0 && - ord($str_val[$count+1]) == 0x80 ) { - $str_val[$count] = 0; - $str_val = substr($str_val,0,$count+1) - . substr($str_val,$count+2); - } - $count += $addBytes; - } - } - - return $str_val; - } - } - - /** - * Writes a string to the end of file. - * - * @param string $str - * @throws Zend_Search_Lucene_Exception - */ - public function writeString($str) - { - /** - * This implementation supports only Basic Multilingual Plane - * (BMP) characters (from 0x0000 to 0xFFFF) and doesn't support - * "supplementary characters" (characters whose code points are - * greater than 0xFFFF) - * Java 2 represents these characters as a pair of char (16-bit) - * values, the first from the high-surrogates range (0xD800-0xDBFF), - * the second from the low-surrogates range (0xDC00-0xDFFF). Then - * they are encoded as usual UTF-8 characters in six bytes. - * Standard UTF-8 representation uses four bytes for supplementary - * characters. - */ - - // convert input to a string before iterating string characters - settype($str, 'string'); - - $chars = $strlen = strlen($str); - $containNullChars = false; - - for ($count = 0; $count < $strlen; $count++ ) { - /** - * String is already in Java 2 representation. - * We should only calculate actual string length and replace - * \x00 by \xC0\x80 - */ - if ((ord($str[$count]) & 0xC0) == 0xC0) { - $addBytes = 1; - if (ord($str[$count]) & 0x20 ) { - $addBytes++; - - // Never used. Java2 doesn't encode strings in four bytes - // and we dont't support non-BMP characters - if (ord($str[$count]) & 0x10 ) { - $addBytes++; - } - } - $chars -= $addBytes; - - if (ord($str[$count]) == 0 ) { - $containNullChars = true; - } - $count += $addBytes; - } - } - - if ($chars < 0) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Invalid UTF-8 string'); - } - - $this->writeVInt($chars); - if ($containNullChars) { - $this->_fwrite(str_replace($str, "\x00", "\xC0\x80")); - } else { - $this->_fwrite($str); - } - } - - - /** - * Reads binary data from the current position in the file - * and advances the file pointer. - * - * @return string - */ - public function readBinary() - { - return $this->_fread($this->readVInt()); - } -} diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Storage/File/Filesystem.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Storage/File/Filesystem.php deleted file mode 100755 index 8caf1c8ca18b3d95413f42134b0b5d07d2475736..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Storage/File/Filesystem.php +++ /dev/null @@ -1,231 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Storage - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_Storage_File */ -// require_once 'Zend/Search/Lucene/Storage/File.php'; - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Storage - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Storage_File_Filesystem extends Zend_Search_Lucene_Storage_File -{ - /** - * Resource of the open file - * - * @var resource - */ - protected $_fileHandle; - - - /** - * Class constructor. Open the file. - * - * @param string $filename - * @param string $mode - */ - public function __construct($filename, $mode='r+b') - { - global $php_errormsg; - - if (strpos($mode, 'w') === false && !is_readable($filename)) { - // opening for reading non-readable file - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('File \'' . $filename . '\' is not readable.'); - } - - $trackErrors = ini_get('track_errors'); - ini_set('track_errors', '1'); - - $this->_fileHandle = @fopen($filename, $mode); - - if ($this->_fileHandle === false) { - ini_set('track_errors', $trackErrors); - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception($php_errormsg); - } - - ini_set('track_errors', $trackErrors); - } - - /** - * Sets the file position indicator and advances the file pointer. - * The new position, measured in bytes from the beginning of the file, - * is obtained by adding offset to the position specified by whence, - * whose values are defined as follows: - * SEEK_SET - Set position equal to offset bytes. - * SEEK_CUR - Set position to current location plus offset. - * SEEK_END - Set position to end-of-file plus offset. (To move to - * a position before the end-of-file, you need to pass a negative value - * in offset.) - * SEEK_CUR is the only supported offset type for compound files - * - * Upon success, returns 0; otherwise, returns -1 - * - * @param integer $offset - * @param integer $whence - * @return integer - */ - public function seek($offset, $whence=SEEK_SET) - { - return fseek($this->_fileHandle, $offset, $whence); - } - - - /** - * Get file position. - * - * @return integer - */ - public function tell() - { - return ftell($this->_fileHandle); - } - - /** - * Flush output. - * - * Returns true on success or false on failure. - * - * @return boolean - */ - public function flush() - { - return fflush($this->_fileHandle); - } - - /** - * Close File object - */ - public function close() - { - if ($this->_fileHandle !== null ) { - @fclose($this->_fileHandle); - $this->_fileHandle = null; - } - } - - /** - * Get the size of the already opened file - * - * @return integer - */ - public function size() - { - $position = ftell($this->_fileHandle); - fseek($this->_fileHandle, 0, SEEK_END); - $size = ftell($this->_fileHandle); - fseek($this->_fileHandle,$position); - - return $size; - } - - /** - * Read a $length bytes from the file and advance the file pointer. - * - * @param integer $length - * @return string - */ - protected function _fread($length=1) - { - if ($length == 0) { - return ''; - } - - if ($length < 1024) { - return fread($this->_fileHandle, $length); - } - - $data = ''; - while ($length > 0 && !feof($this->_fileHandle)) { - $nextBlock = fread($this->_fileHandle, $length); - if ($nextBlock === false) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception( "Error occured while file reading." ); - } - - $data .= $nextBlock; - $length -= strlen($nextBlock); - } - if ($length != 0) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception( "Error occured while file reading." ); - } - - return $data; - } - - - /** - * Writes $length number of bytes (all, if $length===null) to the end - * of the file. - * - * @param string $data - * @param integer $length - */ - protected function _fwrite($data, $length=null) - { - if ($length === null ) { - fwrite($this->_fileHandle, $data); - } else { - fwrite($this->_fileHandle, $data, $length); - } - } - - /** - * Lock file - * - * Lock type may be a LOCK_SH (shared lock) or a LOCK_EX (exclusive lock) - * - * @param integer $lockType - * @param boolean $nonBlockingLock - * @return boolean - */ - public function lock($lockType, $nonBlockingLock = false) - { - if ($nonBlockingLock) { - return flock($this->_fileHandle, $lockType | LOCK_NB); - } else { - return flock($this->_fileHandle, $lockType); - } - } - - /** - * Unlock file - * - * Returns true on success - * - * @return boolean - */ - public function unlock() - { - if ($this->_fileHandle !== null ) { - return flock($this->_fileHandle, LOCK_UN); - } else { - return true; - } - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Storage/File/Memory.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Storage/File/Memory.php deleted file mode 100755 index f6ac2433cf5d8f220ffd11389ac5fa14796d16a0..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/Storage/File/Memory.php +++ /dev/null @@ -1,601 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Storage - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_Storage_File */ -// require_once 'Zend/Search/Lucene/Storage/File.php'; - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Storage - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_Storage_File_Memory extends Zend_Search_Lucene_Storage_File -{ - /** - * FileData - * - * @var string - */ - private $_data; - - /** - * File Position - * - * @var integer - */ - private $_position = 0; - - - /** - * Object constractor - * - * @param string $data - */ - public function __construct($data) - { - $this->_data = $data; - } - - /** - * Reads $length number of bytes at the current position in the - * file and advances the file pointer. - * - * @param integer $length - * @return string - */ - protected function _fread($length = 1) - { - $returnValue = substr($this->_data, $this->_position, $length); - $this->_position += $length; - return $returnValue; - } - - - /** - * Sets the file position indicator and advances the file pointer. - * The new position, measured in bytes from the beginning of the file, - * is obtained by adding offset to the position specified by whence, - * whose values are defined as follows: - * SEEK_SET - Set position equal to offset bytes. - * SEEK_CUR - Set position to current location plus offset. - * SEEK_END - Set position to end-of-file plus offset. (To move to - * a position before the end-of-file, you need to pass a negative value - * in offset.) - * Upon success, returns 0; otherwise, returns -1 - * - * @param integer $offset - * @param integer $whence - * @return integer - */ - public function seek($offset, $whence=SEEK_SET) - { - switch ($whence) { - case SEEK_SET: - $this->_position = $offset; - break; - - case SEEK_CUR: - $this->_position += $offset; - break; - - case SEEK_END: - $this->_position = strlen($this->_data); - $this->_position += $offset; - break; - - default: - break; - } - } - - /** - * Get file position. - * - * @return integer - */ - public function tell() - { - return $this->_position; - } - - /** - * Flush output. - * - * Returns true on success or false on failure. - * - * @return boolean - */ - public function flush() - { - // Do nothing - - return true; - } - - /** - * Writes $length number of bytes (all, if $length===null) to the end - * of the file. - * - * @param string $data - * @param integer $length - */ - protected function _fwrite($data, $length=null) - { - // We do not need to check if file position points to the end of "file". - // Only append operation is supported now - - if ($length !== null) { - $this->_data .= substr($data, 0, $length); - } else { - $this->_data .= $data; - } - - $this->_position = strlen($this->_data); - } - - /** - * Lock file - * - * Lock type may be a LOCK_SH (shared lock) or a LOCK_EX (exclusive lock) - * - * @param integer $lockType - * @return boolean - */ - public function lock($lockType, $nonBlockinLock = false) - { - // Memory files can't be shared - // do nothing - - return true; - } - - /** - * Unlock file - */ - public function unlock() - { - // Memory files can't be shared - // do nothing - } - - /** - * Reads a byte from the current position in the file - * and advances the file pointer. - * - * @return integer - */ - public function readByte() - { - return ord($this->_data[$this->_position++]); - } - - /** - * Writes a byte to the end of the file. - * - * @param integer $byte - */ - public function writeByte($byte) - { - // We do not need to check if file position points to the end of "file". - // Only append operation is supported now - - $this->_data .= chr($byte); - $this->_position = strlen($this->_data); - - return 1; - } - - /** - * Read num bytes from the current position in the file - * and advances the file pointer. - * - * @param integer $num - * @return string - */ - public function readBytes($num) - { - $returnValue = substr($this->_data, $this->_position, $num); - $this->_position += $num; - - return $returnValue; - } - - /** - * Writes num bytes of data (all, if $num===null) to the end - * of the string. - * - * @param string $data - * @param integer $num - */ - public function writeBytes($data, $num=null) - { - // We do not need to check if file position points to the end of "file". - // Only append operation is supported now - - if ($num !== null) { - $this->_data .= substr($data, 0, $num); - } else { - $this->_data .= $data; - } - - $this->_position = strlen($this->_data); - } - - - /** - * Reads an integer from the current position in the file - * and advances the file pointer. - * - * @return integer - */ - public function readInt() - { - $str = substr($this->_data, $this->_position, 4); - $this->_position += 4; - - return ord($str[0]) << 24 | - ord($str[1]) << 16 | - ord($str[2]) << 8 | - ord($str[3]); - } - - - /** - * Writes an integer to the end of file. - * - * @param integer $value - */ - public function writeInt($value) - { - // We do not need to check if file position points to the end of "file". - // Only append operation is supported now - - settype($value, 'integer'); - $this->_data .= chr($value>>24 & 0xFF) . - chr($value>>16 & 0xFF) . - chr($value>>8 & 0xFF) . - chr($value & 0xFF); - - $this->_position = strlen($this->_data); - } - - - /** - * Returns a long integer from the current position in the file - * and advances the file pointer. - * - * @return integer - * @throws Zend_Search_Lucene_Exception - */ - public function readLong() - { - /** - * Check, that we work in 64-bit mode. - * fseek() uses long for offset. Thus, largest index segment file size in 32bit mode is 2Gb - */ - if (PHP_INT_SIZE > 4) { - $str = substr($this->_data, $this->_position, 8); - $this->_position += 8; - - return ord($str[0]) << 56 | - ord($str[1]) << 48 | - ord($str[2]) << 40 | - ord($str[3]) << 32 | - ord($str[4]) << 24 | - ord($str[5]) << 16 | - ord($str[6]) << 8 | - ord($str[7]); - } else { - return $this->readLong32Bit(); - } - } - - /** - * Writes long integer to the end of file - * - * @param integer $value - * @throws Zend_Search_Lucene_Exception - */ - public function writeLong($value) - { - // We do not need to check if file position points to the end of "file". - // Only append operation is supported now - - /** - * Check, that we work in 64-bit mode. - * fseek() and ftell() use long for offset. Thus, largest index segment file size in 32bit mode is 2Gb - */ - if (PHP_INT_SIZE > 4) { - settype($value, 'integer'); - $this->_data .= chr($value>>56 & 0xFF) . - chr($value>>48 & 0xFF) . - chr($value>>40 & 0xFF) . - chr($value>>32 & 0xFF) . - chr($value>>24 & 0xFF) . - chr($value>>16 & 0xFF) . - chr($value>>8 & 0xFF) . - chr($value & 0xFF); - } else { - $this->writeLong32Bit($value); - } - - $this->_position = strlen($this->_data); - } - - - /** - * Returns a long integer from the current position in the file, - * advances the file pointer and return it as float (for 32-bit platforms). - * - * @return integer|float - * @throws Zend_Search_Lucene_Exception - */ - public function readLong32Bit() - { - $wordHigh = $this->readInt(); - $wordLow = $this->readInt(); - - if ($wordHigh & (int)0x80000000) { - // It's a negative value since the highest bit is set - if ($wordHigh == (int)0xFFFFFFFF && ($wordLow & (int)0x80000000)) { - return $wordLow; - } else { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Long integers lower than -2147483648 (0x80000000) are not supported on 32-bit platforms.'); - } - - } - - if ($wordLow < 0) { - // Value is large than 0x7FFF FFFF. Represent low word as float. - $wordLow &= 0x7FFFFFFF; - $wordLow += (float)0x80000000; - } - - if ($wordHigh == 0) { - // Return value as integer if possible - return $wordLow; - } - - return $wordHigh*(float)0x100000000/* 0x00000001 00000000 */ + $wordLow; - } - - - /** - * Writes long integer to the end of file (32-bit platforms implementation) - * - * @param integer|float $value - * @throws Zend_Search_Lucene_Exception - */ - public function writeLong32Bit($value) - { - if ($value < (int)0x80000000) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Long integers lower than -2147483648 (0x80000000) are not supported on 32-bit platforms.'); - } - - if ($value < 0) { - $wordHigh = (int)0xFFFFFFFF; - $wordLow = (int)$value; - } else { - $wordHigh = (int)($value/(float)0x100000000/* 0x00000001 00000000 */); - $wordLow = $value - $wordHigh*(float)0x100000000/* 0x00000001 00000000 */; - - if ($wordLow > 0x7FFFFFFF) { - // Highest bit of low word is set. Translate it to the corresponding negative integer value - $wordLow -= 0x80000000; - $wordLow |= 0x80000000; - } - } - - $this->writeInt($wordHigh); - $this->writeInt($wordLow); - } - - /** - * Returns a variable-length integer from the current - * position in the file and advances the file pointer. - * - * @return integer - */ - public function readVInt() - { - $nextByte = ord($this->_data[$this->_position++]); - $val = $nextByte & 0x7F; - - for ($shift=7; ($nextByte & 0x80) != 0; $shift += 7) { - $nextByte = ord($this->_data[$this->_position++]); - $val |= ($nextByte & 0x7F) << $shift; - } - return $val; - } - - /** - * Writes a variable-length integer to the end of file. - * - * @param integer $value - */ - public function writeVInt($value) - { - // We do not need to check if file position points to the end of "file". - // Only append operation is supported now - - settype($value, 'integer'); - while ($value > 0x7F) { - $this->_data .= chr( ($value & 0x7F)|0x80 ); - $value >>= 7; - } - $this->_data .= chr($value); - - $this->_position = strlen($this->_data); - } - - - /** - * Reads a string from the current position in the file - * and advances the file pointer. - * - * @return string - */ - public function readString() - { - $strlen = $this->readVInt(); - if ($strlen == 0) { - return ''; - } else { - /** - * This implementation supports only Basic Multilingual Plane - * (BMP) characters (from 0x0000 to 0xFFFF) and doesn't support - * "supplementary characters" (characters whose code points are - * greater than 0xFFFF) - * Java 2 represents these characters as a pair of char (16-bit) - * values, the first from the high-surrogates range (0xD800-0xDBFF), - * the second from the low-surrogates range (0xDC00-0xDFFF). Then - * they are encoded as usual UTF-8 characters in six bytes. - * Standard UTF-8 representation uses four bytes for supplementary - * characters. - */ - - $str_val = substr($this->_data, $this->_position, $strlen); - $this->_position += $strlen; - - for ($count = 0; $count < $strlen; $count++ ) { - if (( ord($str_val[$count]) & 0xC0 ) == 0xC0) { - $addBytes = 1; - if (ord($str_val[$count]) & 0x20 ) { - $addBytes++; - - // Never used. Java2 doesn't encode strings in four bytes - if (ord($str_val[$count]) & 0x10 ) { - $addBytes++; - } - } - $str_val .= substr($this->_data, $this->_position, $addBytes); - $this->_position += $addBytes; - $strlen += $addBytes; - - // Check for null character. Java2 encodes null character - // in two bytes. - if (ord($str_val[$count]) == 0xC0 && - ord($str_val[$count+1]) == 0x80 ) { - $str_val[$count] = 0; - $str_val = substr($str_val,0,$count+1) - . substr($str_val,$count+2); - } - $count += $addBytes; - } - } - - return $str_val; - } - } - - /** - * Writes a string to the end of file. - * - * @param string $str - * @throws Zend_Search_Lucene_Exception - */ - public function writeString($str) - { - /** - * This implementation supports only Basic Multilingual Plane - * (BMP) characters (from 0x0000 to 0xFFFF) and doesn't support - * "supplementary characters" (characters whose code points are - * greater than 0xFFFF) - * Java 2 represents these characters as a pair of char (16-bit) - * values, the first from the high-surrogates range (0xD800-0xDBFF), - * the second from the low-surrogates range (0xDC00-0xDFFF). Then - * they are encoded as usual UTF-8 characters in six bytes. - * Standard UTF-8 representation uses four bytes for supplementary - * characters. - */ - - // We do not need to check if file position points to the end of "file". - // Only append operation is supported now - - // convert input to a string before iterating string characters - settype($str, 'string'); - - $chars = $strlen = strlen($str); - $containNullChars = false; - - for ($count = 0; $count < $strlen; $count++ ) { - /** - * String is already in Java 2 representation. - * We should only calculate actual string length and replace - * \x00 by \xC0\x80 - */ - if ((ord($str[$count]) & 0xC0) == 0xC0) { - $addBytes = 1; - if (ord($str[$count]) & 0x20 ) { - $addBytes++; - - // Never used. Java2 doesn't encode strings in four bytes - // and we dont't support non-BMP characters - if (ord($str[$count]) & 0x10 ) { - $addBytes++; - } - } - $chars -= $addBytes; - - if (ord($str[$count]) == 0 ) { - $containNullChars = true; - } - $count += $addBytes; - } - } - - if ($chars < 0) { - // require_once 'Zend/Search/Lucene/Exception.php'; - throw new Zend_Search_Lucene_Exception('Invalid UTF-8 string'); - } - - $this->writeVInt($chars); - if ($containNullChars) { - $this->_data .= str_replace($str, "\x00", "\xC0\x80"); - - } else { - $this->_data .= $str; - } - - $this->_position = strlen($this->_data); - } - - - /** - * Reads binary data from the current position in the file - * and advances the file pointer. - * - * @return string - */ - public function readBinary() - { - $length = $this->readVInt(); - $returnValue = substr($this->_data, $this->_position, $length); - $this->_position += $length; - return $returnValue; - } -} - diff --git a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/TermStreamsPriorityQueue.php b/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/TermStreamsPriorityQueue.php deleted file mode 100755 index b2db6bde87ac1f71d47da22065afb358a9a04dc3..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search-lucene/library/Zend/Search/Lucene/TermStreamsPriorityQueue.php +++ /dev/null @@ -1,172 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - -/** Zend_Search_Lucene_Index_TermsStream_Interface */ -// require_once 'Zend/Search/Lucene/Index/TermsStream/Interface.php'; - - -/** - * @category Zend - * @package Zend_Search_Lucene - * @subpackage Index - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Lucene_TermStreamsPriorityQueue implements Zend_Search_Lucene_Index_TermsStream_Interface -{ - /** - * Array of term streams (Zend_Search_Lucene_Index_TermsStream_Interface objects) - * - * @var array - */ - protected $_termStreams; - - /** - * Terms stream queue - * - * @var Zend_Search_Lucene_Index_TermsPriorityQueue - */ - protected $_termsStreamQueue = null; - - /** - * Last Term in a terms stream - * - * @var Zend_Search_Lucene_Index_Term - */ - protected $_lastTerm = null; - - - /** - * Object constructor - * - * @param array $termStreams array of term streams (Zend_Search_Lucene_Index_TermsStream_Interface objects) - */ - public function __construct(array $termStreams) - { - $this->_termStreams = $termStreams; - - $this->resetTermsStream(); - } - - /** - * Reset terms stream. - */ - public function resetTermsStream() - { - /** Zend_Search_Lucene_Index_TermsPriorityQueue */ - // require_once 'Zend/Search/Lucene/Index/TermsPriorityQueue.php'; - - $this->_termsStreamQueue = new Zend_Search_Lucene_Index_TermsPriorityQueue(); - - foreach ($this->_termStreams as $termStream) { - $termStream->resetTermsStream(); - - // Skip "empty" containers - if ($termStream->currentTerm() !== null) { - $this->_termsStreamQueue->put($termStream); - } - } - - $this->nextTerm(); - } - - /** - * Skip terms stream up to the specified term preffix. - * - * Prefix contains fully specified field info and portion of searched term - * - * @param Zend_Search_Lucene_Index_Term $prefix - */ - public function skipTo(Zend_Search_Lucene_Index_Term $prefix) - { - $this->_termsStreamQueue = new Zend_Search_Lucene_Index_TermsPriorityQueue(); - - foreach ($this->_termStreams as $termStream) { - $termStream->skipTo($prefix); - - if ($termStream->currentTerm() !== null) { - $this->_termsStreamQueue->put($termStream); - } - } - - return $this->nextTerm(); - } - - /** - * Scans term streams and returns next term - * - * @return Zend_Search_Lucene_Index_Term|null - */ - public function nextTerm() - { - while (($termStream = $this->_termsStreamQueue->pop()) !== null) { - if ($this->_termsStreamQueue->top() === null || - $this->_termsStreamQueue->top()->currentTerm()->key() != - $termStream->currentTerm()->key()) { - // We got new term - $this->_lastTerm = $termStream->currentTerm(); - - if ($termStream->nextTerm() !== null) { - // Put segment back into the priority queue - $this->_termsStreamQueue->put($termStream); - } - - return $this->_lastTerm; - } - - if ($termStream->nextTerm() !== null) { - // Put segment back into the priority queue - $this->_termsStreamQueue->put($termStream); - } - } - - // End of stream - $this->_lastTerm = null; - - return null; - } - - /** - * Returns term in current position - * - * @return Zend_Search_Lucene_Index_Term|null - */ - public function currentTerm() - { - return $this->_lastTerm; - } - - /** - * Close terms stream - * - * Should be used for resources clean up if stream is not read up to the end - */ - public function closeTermsStream() - { - while (($termStream = $this->_termsStreamQueue->pop()) !== null) { - $termStream->closeTermsStream(); - } - - $this->_termsStreamQueue = null; - $this->_lastTerm = null; - } -} diff --git a/vendor/zf1/zend-search/LICENSE.txt b/vendor/zf1/zend-search/LICENSE.txt deleted file mode 100755 index 6eab5aa14fd421059dfecada369abb8dd79c8a48..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search/LICENSE.txt +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2005-2015, Zend Technologies USA, Inc. -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. - - * Neither the name of Zend Technologies USA, Inc. nor the names of its - 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 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/zf1/zend-search/README.md b/vendor/zf1/zend-search/README.md deleted file mode 100755 index 26386e54a00bb222a594ec20dba1fab9f4067015..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search/README.md +++ /dev/null @@ -1,22 +0,0 @@ -Zend Framework 1 for Composer -============================= - -This package is a part of the Zend Framework 1. Each component was separated and put into its own composer package. Some modifications were made for improved [Composer](http://getcomposer.org/) integration. This package can also be found at [Packagist](http://packagist.org/packages/zf1). - -## Why? - -**Size!** Zend Framework is very large and contains a huge amount of files (over 72000 files in the main repository!). If you're only using a part of the framework, using the separated packages will greatly reduce the amount of files. This will make setup faster and easier on your disks. - -**Autoloading!** Explicit `require_once` calls in the source code has been commented out to rely on composer autoloading, this reduces the number of included files to a minimum. - -**Migration!** Zend Framework 2 has been around for a while now, and migrating all your projects takes a lot of time. Using these packages makes it easier to migrate each component separately. Also, some packages doesn't exist in zf2 (such as the zend-search-lucene), now you can continue using that package without requiring the entire framework. - -If you're using major parts of the framework, I would recommend checking out the [zendframework1 package](https://github.com/bombayworks/zendframework1), which contains the entire framework optimized for composer usage. - -## How to use - -Add `"zf1/zend-search": "~1.12"` to the require section of your composer.json, include the composer autoloader and you're good to go. - -## Broken dependencies? - -Dependencies have been set automatically based on the [requirements from the zend framework manual](http://framework.zend.com/manual/1.12/en/requirements.introduction.html), if you find any broken dependencies please submit an issue. \ No newline at end of file diff --git a/vendor/zf1/zend-search/composer.json b/vendor/zf1/zend-search/composer.json deleted file mode 100755 index a6f2affa30c40d1f87467585c31af17af5a6c3ac..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search/composer.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "zf1/zend-search", - "description": "Zend Framework 1 Search package", - "keywords": [ - "framework", - "zf1", - "zend", - "search" - ], - "homepage": "http://framework.zend.com/", - "license": "BSD-3-Clause", - "require": { - "php": ">=5.2.11", - "zf1/zend-exception": "self.version" - }, - "autoload": { - "psr-0": { - "Zend_Search": "library/" - } - } -} \ No newline at end of file diff --git a/vendor/zf1/zend-search/library/Zend/Search/Exception.php b/vendor/zf1/zend-search/library/Zend/Search/Exception.php deleted file mode 100755 index b27ec2a1b6119517a29063a1d75cdf06eef9b06e..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-search/library/Zend/Search/Exception.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * Framework base exception - */ -// require_once 'Zend/Exception.php'; - - -/** - * @category Zend - * @package Zend_Search - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Search_Exception extends Zend_Exception -{} - diff --git a/vendor/zf1/zend-xml/LICENSE.txt b/vendor/zf1/zend-xml/LICENSE.txt deleted file mode 100755 index 6eab5aa14fd421059dfecada369abb8dd79c8a48..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-xml/LICENSE.txt +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2005-2015, Zend Technologies USA, Inc. -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. - - * Neither the name of Zend Technologies USA, Inc. nor the names of its - 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 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/zf1/zend-xml/README.md b/vendor/zf1/zend-xml/README.md deleted file mode 100755 index db232f71df022c992d4960ec1c4b826b1d9b9be6..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-xml/README.md +++ /dev/null @@ -1,22 +0,0 @@ -Zend Framework 1 for Composer -============================= - -This package is a part of the Zend Framework 1. Each component was separated and put into its own composer package. Some modifications were made for improved [Composer](http://getcomposer.org/) integration. This package can also be found at [Packagist](http://packagist.org/packages/zf1). - -## Why? - -**Size!** Zend Framework is very large and contains a huge amount of files (over 72000 files in the main repository!). If you're only using a part of the framework, using the separated packages will greatly reduce the amount of files. This will make setup faster and easier on your disks. - -**Autoloading!** Explicit `require_once` calls in the source code has been commented out to rely on composer autoloading, this reduces the number of included files to a minimum. - -**Migration!** Zend Framework 2 has been around for a while now, and migrating all your projects takes a lot of time. Using these packages makes it easier to migrate each component separately. Also, some packages doesn't exist in zf2 (such as the zend-search-lucene), now you can continue using that package without requiring the entire framework. - -If you're using major parts of the framework, I would recommend checking out the [zendframework1 package](https://github.com/bombayworks/zendframework1), which contains the entire framework optimized for composer usage. - -## How to use - -Add `"zf1/zend-xml": "~1.12"` to the require section of your composer.json, include the composer autoloader and you're good to go. - -## Broken dependencies? - -Dependencies have been set automatically based on the [requirements from the zend framework manual](http://framework.zend.com/manual/1.12/en/requirements.introduction.html), if you find any broken dependencies please submit an issue. diff --git a/vendor/zf1/zend-xml/composer.json b/vendor/zf1/zend-xml/composer.json deleted file mode 100755 index 607eb7e3ff0c5a80e8e089bc511294f3c1ffd1fc..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-xml/composer.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "zf1/zend-xml", - "description": "Zend Framework 1 Xml package", - "keywords": [ - "framework", - "zf1", - "zend", - "xml" - ], - "homepage": "http://framework.zend.com/", - "license": "BSD-3-Clause", - "require": { - "php": ">=5.2.11", - "zf1/zend-exception": "self.version" - }, - "autoload": { - "psr-0": { - "Zend_Xml": "library/" - } - } -} diff --git a/vendor/zf1/zend-xml/library/Zend/Xml/Exception.php b/vendor/zf1/zend-xml/library/Zend/Xml/Exception.php deleted file mode 100755 index f43f9cb7b20c70ad7d91dcff92b00d9ca4816ac6..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-xml/library/Zend/Xml/Exception.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Xml - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * @see Zend_Exception - */ -// require_once 'Zend/Exception.php'; - - -/** - * @category Zend - * @package Zend_Xml - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Xml_Exception extends Zend_Exception -{} diff --git a/vendor/zf1/zend-xml/library/Zend/Xml/Security.php b/vendor/zf1/zend-xml/library/Zend/Xml/Security.php deleted file mode 100755 index 424510f638715cdb030d275bf75c97ba893823e0..0000000000000000000000000000000000000000 --- a/vendor/zf1/zend-xml/library/Zend/Xml/Security.php +++ /dev/null @@ -1,488 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Xml - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id$ - */ - - -/** - * @category Zend - * @package Zend_Xml_SecurityScan - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Xml_Security -{ - const ENTITY_DETECT = 'Detected use of ENTITY in XML, disabled to prevent XXE/XEE attacks'; - - /** - * Heuristic scan to detect entity in XML - * - * @param string $xml - * @throws Zend_Xml_Exception If entity expansion or external entity declaration was discovered. - */ - protected static function heuristicScan($xml) - { - foreach (self::getEntityComparison($xml) as $compare) { - if (strpos($xml, $compare) !== false) { - throw new Zend_Xml_Exception(self::ENTITY_DETECT); - } - } - } - - /** - * @param integer $errno - * @param string $errstr - * @param string $errfile - * @param integer $errline - * @return bool - */ - public static function loadXmlErrorHandler($errno, $errstr, $errfile, $errline) - { - if (substr_count($errstr, 'DOMDocument::loadXML()') > 0) { - return true; - } - return false; - } - - /** - * Scan XML string for potential XXE and XEE attacks - * - * @param string $xml - * @param DomDocument $dom - * @throws Zend_Xml_Exception - * @return SimpleXMLElement|DomDocument|boolean - */ - public static function scan($xml, DOMDocument $dom = null) - { - // If running with PHP-FPM we perform an heuristic scan - // We cannot use libxml_disable_entity_loader because of this bug - // @see https://bugs.php.net/bug.php?id=64938 - if (self::isPhpFpm()) { - self::heuristicScan($xml); - } - - if (null === $dom) { - $simpleXml = true; - $dom = new DOMDocument(); - } - - if (!self::isPhpFpm()) { - $loadEntities = libxml_disable_entity_loader(true); - $useInternalXmlErrors = libxml_use_internal_errors(true); - } - - // Load XML with network access disabled (LIBXML_NONET) - // error disabled with @ for PHP-FPM scenario - set_error_handler(array('Zend_Xml_Security', 'loadXmlErrorHandler'), E_WARNING); - - $result = $dom->loadXml($xml, LIBXML_NONET); - restore_error_handler(); - - if (!$result) { - // Entity load to previous setting - if (!self::isPhpFpm()) { - libxml_disable_entity_loader($loadEntities); - libxml_use_internal_errors($useInternalXmlErrors); - } - return false; - } - - // Scan for potential XEE attacks using ENTITY, if not PHP-FPM - if (!self::isPhpFpm()) { - foreach ($dom->childNodes as $child) { - if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) { - if ($child->entities->length > 0) { - // require_once 'Exception.php'; - throw new Zend_Xml_Exception(self::ENTITY_DETECT); - } - } - } - } - - // Entity load to previous setting - if (!self::isPhpFpm()) { - libxml_disable_entity_loader($loadEntities); - libxml_use_internal_errors($useInternalXmlErrors); - } - - if (isset($simpleXml)) { - $result = simplexml_import_dom($dom); - if (!$result instanceof SimpleXMLElement) { - return false; - } - return $result; - } - return $dom; - } - - /** - * Scan XML file for potential XXE/XEE attacks - * - * @param string $file - * @param DOMDocument $dom - * @throws Zend_Xml_Exception - * @return SimpleXMLElement|DomDocument - */ - public static function scanFile($file, DOMDocument $dom = null) - { - if (!file_exists($file)) { - // require_once 'Exception.php'; - throw new Zend_Xml_Exception( - "The file $file specified doesn't exist" - ); - } - return self::scan(file_get_contents($file), $dom); - } - - /** - * Return true if PHP is running with PHP-FPM - * - * This method is mainly used to determine whether or not heuristic checks - * (vs libxml checks) should be made, due to threading issues in libxml; - * under php-fpm, threading becomes a concern. - * - * However, PHP versions 5.5.22+ and 5.6.6+ contain a patch to the - * libxml support in PHP that makes the libxml checks viable; in such - * versions, this method will return false to enforce those checks, which - * are more strict and accurate than the heuristic checks. - * - * @return boolean - */ - public static function isPhpFpm() - { - $isVulnerableVersion = ( - version_compare(PHP_VERSION, '5.5.22', 'lt') - || ( - version_compare(PHP_VERSION, '5.6', 'gte') - && version_compare(PHP_VERSION, '5.6.6', 'lt') - ) - ); - - if (substr(php_sapi_name(), 0, 3) === 'fpm' && $isVulnerableVersion) { - return true; - } - return false; - } - - /** - * Determine and return the string(s) to use for the <!ENTITY comparison. - * - * @param string $xml - * @return string[] - */ - protected static function getEntityComparison($xml) - { - $encodingMap = self::getAsciiEncodingMap(); - return array_map( - array(__CLASS__, 'generateEntityComparison'), - self::detectXmlEncoding($xml, self::detectStringEncoding($xml)) - ); - } - - /** - * Determine the string encoding. - * - * Determines string encoding from either a detected BOM or a - * heuristic. - * - * @param string $xml - * @return string File encoding - */ - protected static function detectStringEncoding($xml) - { - $encoding = self::detectBom($xml); - return ($encoding) ? $encoding : self::detectXmlStringEncoding($xml); - } - - /** - * Attempt to match a known BOM. - * - * Iterates through the return of getBomMap(), comparing the initial bytes - * of the provided string to the BOM of each; if a match is determined, - * it returns the encoding. - * - * @param string $string - * @return false|string Returns encoding on success. - */ - protected static function detectBom($string) - { - foreach (self::getBomMap() as $criteria) { - if (0 === strncmp($string, $criteria['bom'], $criteria['length'])) { - return $criteria['encoding']; - } - } - return false; - } - - /** - * Attempt to detect the string encoding of an XML string. - * - * @param string $xml - * @return string Encoding - */ - protected static function detectXmlStringEncoding($xml) - { - foreach (self::getAsciiEncodingMap() as $encoding => $generator) { - $prefix = call_user_func($generator, '<' . '?xml'); - if (0 === strncmp($xml, $prefix, strlen($prefix))) { - return $encoding; - } - } - - // Fallback - return 'UTF-8'; - } - - /** - * Attempt to detect the specified XML encoding. - * - * Using the file's encoding, determines if an "encoding" attribute is - * present and well-formed in the XML declaration; if so, it returns a - * list with both the ASCII representation of that declaration and the - * original file encoding. - * - * If not, a list containing only the provided file encoding is returned. - * - * @param string $xml - * @param string $fileEncoding - * @return string[] Potential XML encodings - */ - protected static function detectXmlEncoding($xml, $fileEncoding) - { - $encodingMap = self::getAsciiEncodingMap(); - $generator = $encodingMap[$fileEncoding]; - $encAttr = call_user_func($generator, 'encoding="'); - $quote = call_user_func($generator, '"'); - $close = call_user_func($generator, '>'); - - $closePos = strpos($xml, $close); - if (false === $closePos) { - return array($fileEncoding); - } - - $encPos = strpos($xml, $encAttr); - if (false === $encPos - || $encPos > $closePos - ) { - return array($fileEncoding); - } - - $encPos += strlen($encAttr); - $quotePos = strpos($xml, $quote, $encPos); - if (false === $quotePos) { - return array($fileEncoding); - } - - $encoding = self::substr($xml, $encPos, $quotePos); - return array( - // Following line works because we're only supporting 8-bit safe encodings at this time. - str_replace('\0', '', $encoding), // detected encoding - $fileEncoding, // file encoding - ); - } - - /** - * Return a list of BOM maps. - * - * Returns a list of common encoding -> BOM maps, along with the character - * length to compare against. - * - * @link https://en.wikipedia.org/wiki/Byte_order_mark - * @return array - */ - protected static function getBomMap() - { - return array( - array( - 'encoding' => 'UTF-32BE', - 'bom' => pack('CCCC', 0x00, 0x00, 0xfe, 0xff), - 'length' => 4, - ), - array( - 'encoding' => 'UTF-32LE', - 'bom' => pack('CCCC', 0xff, 0xfe, 0x00, 0x00), - 'length' => 4, - ), - array( - 'encoding' => 'GB-18030', - 'bom' => pack('CCCC', 0x84, 0x31, 0x95, 0x33), - 'length' => 4, - ), - array( - 'encoding' => 'UTF-16BE', - 'bom' => pack('CC', 0xfe, 0xff), - 'length' => 2, - ), - array( - 'encoding' => 'UTF-16LE', - 'bom' => pack('CC', 0xff, 0xfe), - 'length' => 2, - ), - array( - 'encoding' => 'UTF-8', - 'bom' => pack('CCC', 0xef, 0xbb, 0xbf), - 'length' => 3, - ), - ); - } - - /** - * Return a map of encoding => generator pairs. - * - * Returns a map of encoding => generator pairs, where the generator is a - * callable that accepts a string and returns the appropriate byte order - * sequence of that string for the encoding. - * - * @return array - */ - protected static function getAsciiEncodingMap() - { - return array( - 'UTF-32BE' => array(__CLASS__, 'encodeToUTF32BE'), - 'UTF-32LE' => array(__CLASS__, 'encodeToUTF32LE'), - 'UTF-32odd1' => array(__CLASS__, 'encodeToUTF32odd1'), - 'UTF-32odd2' => array(__CLASS__, 'encodeToUTF32odd2'), - 'UTF-16BE' => array(__CLASS__, 'encodeToUTF16BE'), - 'UTF-16LE' => array(__CLASS__, 'encodeToUTF16LE'), - 'UTF-8' => array(__CLASS__, 'encodeToUTF8'), - 'GB-18030' => array(__CLASS__, 'encodeToUTF8'), - ); - } - - /** - * Binary-safe substr. - * - * substr() is not binary-safe; this method loops by character to ensure - * multi-byte characters are aggregated correctly. - * - * @param string $string - * @param int $start - * @param int $end - * @return string - */ - protected static function substr($string, $start, $end) - { - $substr = ''; - for ($i = $start; $i < $end; $i += 1) { - $substr .= $string[$i]; - } - return $substr; - } - - /** - * Generate an entity comparison based on the given encoding. - * - * This patch is internal only, and public only so it can be used as a - * callable to pass to array_map. - * - * @internal - * @param string $encoding - * @return string - */ - public static function generateEntityComparison($encoding) - { - $encodingMap = self::getAsciiEncodingMap(); - $generator = isset($encodingMap[$encoding]) ? $encodingMap[$encoding] : $encodingMap['UTF-8']; - return call_user_func($generator, '<!ENTITY'); - } - - /** - * Encode an ASCII string to UTF-32BE - * - * @internal - * @param string $ascii - * @return string - */ - public static function encodeToUTF32BE($ascii) - { - return preg_replace('/(.)/', "\0\0\0\\1", $ascii); - } - - /** - * Encode an ASCII string to UTF-32LE - * - * @internal - * @param string $ascii - * @return string - */ - public static function encodeToUTF32LE($ascii) - { - return preg_replace('/(.)/', "\\1\0\0\0", $ascii); - } - - /** - * Encode an ASCII string to UTF-32odd1 - * - * @internal - * @param string $ascii - * @return string - */ - public static function encodeToUTF32odd1($ascii) - { - return preg_replace('/(.)/', "\0\\1\0\0", $ascii); - } - - /** - * Encode an ASCII string to UTF-32odd2 - * - * @internal - * @param string $ascii - * @return string - */ - public static function encodeToUTF32odd2($ascii) - { - return preg_replace('/(.)/', "\0\0\\1\0", $ascii); - } - - /** - * Encode an ASCII string to UTF-16BE - * - * @internal - * @param string $ascii - * @return string - */ - public static function encodeToUTF16BE($ascii) - { - return preg_replace('/(.)/', "\0\\1", $ascii); - } - - /** - * Encode an ASCII string to UTF-16LE - * - * @internal - * @param string $ascii - * @return string - */ - public static function encodeToUTF16LE($ascii) - { - return preg_replace('/(.)/', "\\1\0", $ascii); - } - - /** - * Encode an ASCII string to UTF-8 - * - * @internal - * @param string $ascii - * @return string - */ - public static function encodeToUTF8($ascii) - { - return $ascii; - } -}