From 59effd57af3821103303eefd551abad811ae9379 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Thu, 10 May 2018 10:34:56 +0300 Subject: [PATCH] Moved 2FA authentication to login plugin --- CHANGELOG.md | 5 +- admin.php | 31 +- classes/admin.php | 59 -- classes/admincontroller.php | 401 +++---- classes/baconqrprovider.php | 25 - composer.json | 4 +- composer.lock | 230 ++-- .../fields/2fa_secret/2fa_secret.html.twig | 19 +- vendor/bacon/bacon-qr-code/.gitignore | 9 - vendor/bacon/bacon-qr-code/.travis.yml | 14 - vendor/bacon/bacon-qr-code/LICENSE | 22 - vendor/bacon/bacon-qr-code/Module.php | 37 - vendor/bacon/bacon-qr-code/README.md | 24 - .../bacon/bacon-qr-code/autoload_classmap.php | 43 - .../bacon/bacon-qr-code/autoload_function.php | 12 - .../bacon/bacon-qr-code/autoload_register.php | 2 - vendor/bacon/bacon-qr-code/composer.json | 29 - .../src/BaconQrCode/Common/AbstractEnum.php | 115 -- .../src/BaconQrCode/Common/BitArray.php | 435 -------- .../src/BaconQrCode/Common/BitMatrix.php | 350 ------- .../src/BaconQrCode/Common/BitUtils.php | 51 - .../BaconQrCode/Common/CharacterSetEci.php | 134 --- .../src/BaconQrCode/Common/EcBlock.php | 65 -- .../src/BaconQrCode/Common/EcBlocks.php | 101 -- .../Common/ErrorCorrectionLevel.php | 62 -- .../BaconQrCode/Common/FormatInformation.php | 236 ----- .../src/BaconQrCode/Common/Mode.php | 70 -- .../BaconQrCode/Common/ReedSolomonCodec.php | 476 --------- .../src/BaconQrCode/Common/Version.php | 687 ------------ .../src/BaconQrCode/Encoder/BlockPair.php | 64 -- .../src/BaconQrCode/Encoder/ByteMatrix.php | 158 --- .../src/BaconQrCode/Encoder/Encoder.php | 687 ------------ .../src/BaconQrCode/Encoder/MaskUtil.php | 291 ------ .../src/BaconQrCode/Encoder/MatrixUtil.php | 580 ----------- .../src/BaconQrCode/Encoder/QrCode.php | 201 ---- .../Exception/ExceptionInterface.php | 14 - .../Exception/InvalidArgumentException.php | 14 - .../Exception/OutOfBoundsException.php | 14 - .../Exception/RuntimeException.php | 14 - .../Exception/UnexpectedValueException.php | 14 - .../BaconQrCode/Exception/WriterException.php | 14 - .../src/BaconQrCode/Renderer/Color/Cmyk.php | 160 --- .../Renderer/Color/ColorInterface.php | 37 - .../src/BaconQrCode/Renderer/Color/Gray.php | 84 -- .../src/BaconQrCode/Renderer/Color/Rgb.php | 148 --- .../Renderer/Image/AbstractRenderer.php | 338 ------ .../Image/Decorator/DecoratorInterface.php | 63 -- .../Image/Decorator/FinderPattern.php | 210 ---- .../src/BaconQrCode/Renderer/Image/Eps.php | 152 --- .../src/BaconQrCode/Renderer/Image/Png.php | 115 -- .../Renderer/Image/RendererInterface.php | 61 -- .../src/BaconQrCode/Renderer/Image/Svg.php | 146 --- .../Renderer/RendererInterface.php | 26 - .../src/BaconQrCode/Renderer/Text/Html.php | 91 -- .../src/BaconQrCode/Renderer/Text/Plain.php | 150 --- .../bacon-qr-code/src/BaconQrCode/Writer.php | 105 -- .../tests/BaconQrCode/Common/BitArrayTest.php | 201 ---- .../BaconQrCode/Common/BitMatrixTest.php | 119 --- .../tests/BaconQrCode/Common/BitUtilsTest.php | 30 - .../Common/ErrorCorrectionLevelTest.php | 40 - .../Common/FormatInformationTest.php | 104 -- .../tests/BaconQrCode/Common/ModeTest.php | 42 - .../Common/ReedSolomonCodecTest.php | 111 -- .../tests/BaconQrCode/Common/VersionTest.php | 88 -- .../tests/BaconQrCode/Encoder/EncoderTest.php | 468 --------- .../BaconQrCode/Encoder/MaskUtilTest.php | 281 ----- .../BaconQrCode/Encoder/MatrixUtilTest.php | 336 ------ .../BaconQrCode/Renderer/Text/HtmlTest.php | 99 -- .../BaconQrCode/Renderer/Text/TextTest.php | 149 --- .../bacon/bacon-qr-code/tests/bootstrap.php | 10 - vendor/bacon/bacon-qr-code/tests/phpunit.xml | 11 - vendor/composer/autoload_namespaces.php | 2 - vendor/composer/autoload_psr4.php | 2 +- vendor/composer/autoload_static.php | 22 +- vendor/composer/installed.json | 130 +-- vendor/robthree/twofactorauth/.gitignore | 189 ---- vendor/robthree/twofactorauth/.travis.yml | 18 - vendor/robthree/twofactorauth/LICENSE | 22 - vendor/robthree/twofactorauth/README.md | 197 ---- .../twofactorauth/TwoFactorAuth.phpproj | 69 -- .../robthree/twofactorauth/TwoFactorAuth.sln | 22 - vendor/robthree/twofactorauth/composer.json | 36 - vendor/robthree/twofactorauth/composer.lock | 980 ------------------ vendor/robthree/twofactorauth/demo/demo.php | 35 - vendor/robthree/twofactorauth/demo/loader.php | 50 - .../Providers/Qr/BaseHTTPQRCodeProvider.php | 27 - .../lib/Providers/Qr/GoogleQRCodeProvider.php | 39 - .../lib/Providers/Qr/IQRCodeProvider.php | 9 - .../lib/Providers/Qr/QRException.php | 5 - .../lib/Providers/Qr/QRServerProvider.php | 71 -- .../lib/Providers/Qr/QRicketProvider.php | 54 - .../lib/Providers/Rng/CSRNGProvider.php | 14 - .../lib/Providers/Rng/HashRNGProvider.php | 28 - .../lib/Providers/Rng/IRNGProvider.php | 9 - .../lib/Providers/Rng/MCryptRNGProvider.php | 23 - .../lib/Providers/Rng/OpenSSLRNGProvider.php | 25 - .../lib/Providers/Rng/RNGException.php | 5 - .../ConvertUnixTimeDotComTimeProvider.php | 15 - .../lib/Providers/Time/HttpTimeProvider.php | 54 - .../lib/Providers/Time/ITimeProvider.php | 8 - .../Time/LocalMachineTimeProvider.php | 9 - .../lib/Providers/Time/TimeException.php | 5 - .../twofactorauth/lib/TwoFactorAuth.php | 249 ----- .../lib/TwoFactorAuthException.php | 7 - vendor/robthree/twofactorauth/logo.png | Bin 2636 -> 0 bytes .../multifactorauthforeveryone.png | Bin 20735 -> 0 bytes .../twofactorauth/tests/TwoFactorAuthTest.php | 381 ------- vendor/zendframework/zendxml/.gitignore | 5 - vendor/zendframework/zendxml/.travis.yml | 43 - vendor/zendframework/zendxml/CHANGELOG.md | 24 + vendor/zendframework/zendxml/LICENSE.md | 27 +- vendor/zendframework/zendxml/README.md | 14 +- vendor/zendframework/zendxml/composer.json | 50 +- .../ZendXml/Exception/ExceptionInterface.php | 14 - .../Exception/InvalidArgumentException.php | 17 - .../ZendXml/Exception/RuntimeException.php | 17 - .../src/Exception/ExceptionInterface.php | 12 + .../Exception/InvalidArgumentException.php | 15 + .../src/Exception/RuntimeException.php | 15 + .../{library/ZendXml => src}/Security.php | 65 +- .../zendframework/zendxml/tests/Bootstrap.php | 92 -- .../tests/ZendXmlTest/MultibyteTest.php | 125 --- .../tests/ZendXmlTest/SecurityTest.php | 135 --- .../zendxml/tests/phpunit.xml.dist | 27 - 124 files changed, 481 insertions(+), 12815 deletions(-) delete mode 100644 classes/baconqrprovider.php delete mode 100644 vendor/bacon/bacon-qr-code/.gitignore delete mode 100644 vendor/bacon/bacon-qr-code/.travis.yml delete mode 100644 vendor/bacon/bacon-qr-code/LICENSE delete mode 100644 vendor/bacon/bacon-qr-code/Module.php delete mode 100644 vendor/bacon/bacon-qr-code/README.md delete mode 100644 vendor/bacon/bacon-qr-code/autoload_classmap.php delete mode 100644 vendor/bacon/bacon-qr-code/autoload_function.php delete mode 100644 vendor/bacon/bacon-qr-code/autoload_register.php delete mode 100644 vendor/bacon/bacon-qr-code/composer.json delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/AbstractEnum.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/BitArray.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/BitMatrix.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/BitUtils.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/CharacterSetEci.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/EcBlock.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/EcBlocks.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/ErrorCorrectionLevel.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/FormatInformation.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/Mode.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/ReedSolomonCodec.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/Version.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/BlockPair.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/ByteMatrix.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/Encoder.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/MaskUtil.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/MatrixUtil.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/QrCode.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Exception/ExceptionInterface.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Exception/InvalidArgumentException.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Exception/OutOfBoundsException.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Exception/RuntimeException.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Exception/UnexpectedValueException.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Exception/WriterException.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Color/Cmyk.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Color/ColorInterface.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Color/Gray.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Color/Rgb.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/AbstractRenderer.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Decorator/DecoratorInterface.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Decorator/FinderPattern.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Eps.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Png.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/RendererInterface.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Svg.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/RendererInterface.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Text/Html.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Text/Plain.php delete mode 100644 vendor/bacon/bacon-qr-code/src/BaconQrCode/Writer.php delete mode 100644 vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitArrayTest.php delete mode 100644 vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitMatrixTest.php delete mode 100644 vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitUtilsTest.php delete mode 100644 vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ErrorCorrectionLevelTest.php delete mode 100644 vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/FormatInformationTest.php delete mode 100644 vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ModeTest.php delete mode 100644 vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ReedSolomonCodecTest.php delete mode 100644 vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/VersionTest.php delete mode 100644 vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/EncoderTest.php delete mode 100644 vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/MaskUtilTest.php delete mode 100644 vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/MatrixUtilTest.php delete mode 100644 vendor/bacon/bacon-qr-code/tests/BaconQrCode/Renderer/Text/HtmlTest.php delete mode 100644 vendor/bacon/bacon-qr-code/tests/BaconQrCode/Renderer/Text/TextTest.php delete mode 100644 vendor/bacon/bacon-qr-code/tests/bootstrap.php delete mode 100644 vendor/bacon/bacon-qr-code/tests/phpunit.xml delete mode 100644 vendor/robthree/twofactorauth/.gitignore delete mode 100644 vendor/robthree/twofactorauth/.travis.yml delete mode 100644 vendor/robthree/twofactorauth/LICENSE delete mode 100644 vendor/robthree/twofactorauth/README.md delete mode 100644 vendor/robthree/twofactorauth/TwoFactorAuth.phpproj delete mode 100644 vendor/robthree/twofactorauth/TwoFactorAuth.sln delete mode 100644 vendor/robthree/twofactorauth/composer.json delete mode 100644 vendor/robthree/twofactorauth/composer.lock delete mode 100644 vendor/robthree/twofactorauth/demo/demo.php delete mode 100644 vendor/robthree/twofactorauth/demo/loader.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Qr/BaseHTTPQRCodeProvider.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Qr/GoogleQRCodeProvider.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Qr/IQRCodeProvider.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Qr/QRException.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Qr/QRServerProvider.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Qr/QRicketProvider.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Rng/CSRNGProvider.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Rng/HashRNGProvider.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Rng/IRNGProvider.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Rng/MCryptRNGProvider.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Rng/OpenSSLRNGProvider.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Rng/RNGException.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Time/ConvertUnixTimeDotComTimeProvider.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Time/HttpTimeProvider.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Time/ITimeProvider.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Time/LocalMachineTimeProvider.php delete mode 100644 vendor/robthree/twofactorauth/lib/Providers/Time/TimeException.php delete mode 100644 vendor/robthree/twofactorauth/lib/TwoFactorAuth.php delete mode 100644 vendor/robthree/twofactorauth/lib/TwoFactorAuthException.php delete mode 100644 vendor/robthree/twofactorauth/logo.png delete mode 100644 vendor/robthree/twofactorauth/multifactorauthforeveryone.png delete mode 100644 vendor/robthree/twofactorauth/tests/TwoFactorAuthTest.php delete mode 100644 vendor/zendframework/zendxml/.gitignore delete mode 100644 vendor/zendframework/zendxml/.travis.yml delete mode 100644 vendor/zendframework/zendxml/library/ZendXml/Exception/ExceptionInterface.php delete mode 100644 vendor/zendframework/zendxml/library/ZendXml/Exception/InvalidArgumentException.php delete mode 100644 vendor/zendframework/zendxml/library/ZendXml/Exception/RuntimeException.php create mode 100644 vendor/zendframework/zendxml/src/Exception/ExceptionInterface.php create mode 100644 vendor/zendframework/zendxml/src/Exception/InvalidArgumentException.php create mode 100644 vendor/zendframework/zendxml/src/Exception/RuntimeException.php rename vendor/zendframework/zendxml/{library/ZendXml => src}/Security.php (91%) delete mode 100644 vendor/zendframework/zendxml/tests/Bootstrap.php delete mode 100644 vendor/zendframework/zendxml/tests/ZendXmlTest/MultibyteTest.php delete mode 100644 vendor/zendframework/zendxml/tests/ZendXmlTest/SecurityTest.php delete mode 100755 vendor/zendframework/zendxml/tests/phpunit.xml.dist diff --git a/CHANGELOG.md b/CHANGELOG.md index 404081e6..4006d875 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,7 @@ 1. [](#new) * Updated plugin dependencies (Form >=2.13.0, Login >=2.7.0, Email >=2.7.0) * Updated `pagemedia` form field so it can be used with non-Page objects - -# v1.7.5 -## XX/XX/2018 - + * Moved 2FA authentication to login plugin 1. [](#bugfix) * Fixed Firefox issue with the Regenerate button for 2FA. Forcing the page to reload * Fixed jumpiness behavior for Regenerate button when on active state. diff --git a/admin.php b/admin.php index e4710b91..25a4072f 100644 --- a/admin.php +++ b/admin.php @@ -12,7 +12,6 @@ use Grav\Common\Uri; use Grav\Common\Utils; use Grav\Common\User\User; use Grav\Plugin\Admin\Admin; -use Grav\Plugin\Admin\AdminTwigExtension; use Grav\Plugin\Admin\Popularity; use Grav\Plugin\Admin\Themes; use Grav\Plugin\Admin\AdminController; @@ -168,39 +167,17 @@ class AdminPlugin extends Plugin */ protected function validate($type, $value, $extra = '') { - $username_regex = '/' . $this->config->get('system.username_regex') . '/'; - $pwd_regex = '/' . $this->config->get('system.pwd_regex') . '/'; + /** @var Login $login */ + $login = $this->grav['login']; - switch ($type) { - case 'username_format': - if (!preg_match($username_regex, $value)) { - return false; - } - - return true; - - case 'password1': - if (!preg_match($pwd_regex, $value)) { - return false; - } - - return true; - - case 'password2': - if (strcmp($value, $extra)) { - return false; - } - - return true; - } - - return false; + return $login->validateField($type, $value, $extra); } /** * Process the admin registration form. * * @param Event $event + * @FIXME: login */ public function onFormProcessed(Event $event) { diff --git a/classes/admin.php b/classes/admin.php index 04c7681f..4a0e9b27 100644 --- a/classes/admin.php +++ b/classes/admin.php @@ -29,7 +29,6 @@ use RocketTheme\Toolbox\Session\Session; use Symfony\Component\Yaml\Yaml; use Composer\Semver\Semver; use PicoFeed\Reader\Reader; -use RobThree\Auth\TwoFactorAuth; define('LOGIN_REDIRECT_COOKIE', 'grav-login-redirect'); @@ -1737,64 +1736,6 @@ class Admin return $pagesWithFiles; } - /** - * Get an instance of the TwoFactorAuth object - * - * @return TwoFactorAuth - */ - public function get2FA() - { - $provider = new BaconQRProvider(); - $twofa = new TwoFactorAuth('Grav', 6, 30, 'sha1', $provider); - return $twofa; - } - - /** - * Get's an array of secret QRCode + chunked secret - * - * @param null $secret if not provided a new secret will be generated - * @return bool - */ - public function get2FAData($secret = null) - { - try { - $user = clone($this->grav['user']); - $twofa = $this->get2FA(); - - // generate secret if needed - if (!$secret) { - $secret = $twofa->createSecret(160); - } - - $label = $user->username . ':' . $this->grav['config']->get('site.title'); - $image = $twofa->getQRCodeImageAsDataUri($label, $secret); - - $user->twofa_secret = str_replace(' ','',$secret); - - unset($user->authenticated); - $user->save(); - - $this->json_response = ['status' => 'success', 'image' => $image, 'secret' => trim(chunk_split($secret, 4, ' '))]; - } catch (\Exception $e) { - $this->json_response = ['status' => 'error', 'message' => $e->getMessage()]; - return false; - } - return true; - } - - public static function doAnyUsersExist() - { - // check for existence of a user account - $account_dir = $file_path = Grav::instance()['locator']->findResource('account://'); - $user_check = glob($account_dir . '/*.yaml'); - - if ($user_check != false && count((array)$user_check) > 0) { - return true; - } - - return false; - } - /** * Return HTTP_REFERRER if set * diff --git a/classes/admincontroller.php b/classes/admincontroller.php index 69aca93f..fc483762 100644 --- a/classes/admincontroller.php +++ b/classes/admincontroller.php @@ -17,6 +17,8 @@ use Grav\Common\Page\Collection; use Grav\Common\User\User; use Grav\Common\Utils; use Grav\Common\Backup\ZipBackup; +use Grav\Plugin\Admin\Twig\AdminTwigExtension; +use Grav\Plugin\Login\TwoFactorAuth\TwoFactorAuth; use RocketTheme\Toolbox\Event\Event; use RocketTheme\Toolbox\File\File; use RocketTheme\Toolbox\File\JsonFile; @@ -118,10 +120,112 @@ class AdminController extends AdminBaseController $this->grav->fireEvent('onAdminControllerInit', new Event(['controller' => &$this])); } + /** + * Handle login. + * + * @return bool True if the action was performed. + * @todo LOGIN + */ + protected function taskLogin() + { + $this->data['username'] = strip_tags(strtolower($this->data['username'])); + if ($this->admin->authenticate($this->data, $this->post)) { + // should never reach here, redirects first + } else { + $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.LOGIN_FAILED'), 'error'); + } + + return true; + } + + /** + * @return bool + * @todo LOGIN + */ + protected function task2faverify() + { + /** @var TwoFactorAuth $twoFa */ + $twoFa = $this->grav['login']->twoFactorAuth(); + $user = $this->grav['user']; + + $secret = isset($user->twofa_secret) ? $user->twofa_secret : null; + + if (!(isset($this->data['2fa_code']) && $secret && $twoFa->verifyCode($secret, $this->data['2fa_code']))) { + $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.2FA_FAILED'), 'error'); + return true; + } + + $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.LOGIN_LOGGED_IN'), 'info'); + + $user->authenticated = true; + $this->grav->redirect($this->post['redirect']); + + return true; + } + + /** + * @param null $secret + * @return bool + * @todo LOGIN + */ + public function taskRegenerate2FASecret() + { + if (!$this->authorizeTask('regenerate 2FA Secret', ['admin.login'])) { + return false; + } + + try { + /** @var User $user */ + $user = clone $this->grav['user']; + + /** @var TwoFactorAuth $twoFa */ + $twoFa = $this->grav['login']->twoFactorAuth(); + $secret = $twoFa->createSecret(160); + $image = $twoFa->getQrImageData($user->username, $secret); + + $user->twofa_secret = str_replace(' ','', $secret); + unset($user->authenticated); + + $file = $user->file(); + if ($file->exists()) { + $content = $file->content(); + $content['twofa_secret'] = $user->twofa_secret; + $file->save($content); + $file->free(); + } + + $this->admin->json_response = ['status' => 'success', 'image' => $image, 'secret' => trim(chunk_split($secret, 4, ' '))]; + } catch (\Exception $e) { + $this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()]; + return false; + } + + return true; + } + + /** + * Handle logout. + * + * @return bool True if the action was performed. + * @todo LOGIN + */ + protected function taskLogout() + { + $message = $this->admin->translate('PLUGIN_ADMIN.LOGGED_OUT'); + + $this->admin->session()->invalidate()->start(); + $this->grav['session']->setFlashCookieObject(Admin::TMP_COOKIE_NAME, ['message' => $message, 'status' => 'info']); + + $this->setRedirect('/'); + + return true; + } + /** * Handle the reset password action. * * @return bool True if the action was performed. + * @todo LOGIN */ public function taskReset() { @@ -129,11 +233,11 @@ class AdminController extends AdminBaseController if (isset($data['password'])) { $username = isset($data['username']) ? strip_tags(strtolower($data['username'])) : null; - $user = !empty($username) ? User::load($username) : null; + $user = $username ? User::load($username) : null; $password = isset($data['password']) ? $data['password'] : null; $token = isset($data['token']) ? $data['token'] : null; - if (!empty($user) && $user->exists() && !empty($user->reset)) { + if ($user && $user->exists() && !empty($user->reset)) { list($good_token, $expire) = explode('::', $user->reset); if ($good_token === $token) { @@ -144,8 +248,7 @@ class AdminController extends AdminBaseController return true; } - unset($user->hashed_password); - unset($user->reset); + unset($user->hashed_password, $user->reset); $user->password = $password; $user->validate(); @@ -164,22 +267,121 @@ class AdminController extends AdminBaseController return true; - } else { - $user = $this->grav['uri']->param('user'); - $token = $this->grav['uri']->param('token'); - - if (empty($user) || empty($token)) { - $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.RESET_INVALID_LINK'), 'error'); - $this->setRedirect('/forgot'); - - return true; - } else { - $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.RESET_NEW_PASSWORD'), 'info'); - } - - $this->admin->forgot = ['username' => $user, 'token' => $token]; } + $user = $this->grav['uri']->param('user'); + $token = $this->grav['uri']->param('token'); + + if (empty($user) || empty($token)) { + $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.RESET_INVALID_LINK'), 'error'); + $this->setRedirect('/forgot'); + + return true; + } + + $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.RESET_NEW_PASSWORD'), 'info'); + + $this->admin->forgot = ['username' => $user, 'token' => $token]; + + return true; + } + + /** + * Handle the email password recovery procedure. + * + * @return bool True if the action was performed. + * @todo LOGIN + */ + protected function taskForgot() + { + $param_sep = $this->grav['config']->get('system.param_sep', ':'); + $post = $this->post; + $data = $this->data; + $login = $this->grav['login']; + + $username = isset($data['username']) ? strip_tags(strtolower($data['username'])) : ''; + $user = !empty($username) ? User::load($username) : null; + + if (!isset($this->grav['Email'])) { + $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.FORGOT_EMAIL_NOT_CONFIGURED'), 'error'); + $this->setRedirect($post['redirect']); + + return true; + } + + if (!$user || !$user->exists()) { + $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.FORGOT_INSTRUCTIONS_SENT_VIA_EMAIL'), + 'info'); + $this->setRedirect($post['redirect']); + + return true; + } + + if (empty($user->email)) { + $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.FORGOT_INSTRUCTIONS_SENT_VIA_EMAIL'), + 'info'); + $this->setRedirect($post['redirect']); + + return true; + } + + $count = $this->grav['config']->get('plugins.login.max_pw_resets_count', 0); + $interval =$this->grav['config']->get('plugins.login.max_pw_resets_interval', 2); + + if ($login->isUserRateLimited($user, 'pw_resets', $count, $interval)) { + $this->admin->setMessage($this->admin->translate(['PLUGIN_LOGIN.FORGOT_CANNOT_RESET_IT_IS_BLOCKED', $user->email, $interval]), 'error'); + $this->setRedirect($post['redirect']); + + return true; + } + + $token = md5(uniqid(mt_rand(), true)); + $expire = time() + 604800; // next week + + $user->reset = $token . '::' . $expire; + $user->save(); + + $author = $this->grav['config']->get('site.author.name', ''); + $fullname = $user->fullname ?: $username; + $reset_link = rtrim($this->grav['uri']->rootUrl(true), '/') . '/' . trim($this->admin->base, + '/') . '/reset/task' . $param_sep . 'reset/user' . $param_sep . $username . '/token' . $param_sep . $token . '/admin-nonce' . $param_sep . Utils::getNonce('admin-form'); + + $sitename = $this->grav['config']->get('site.title', 'Website'); + $from = $this->grav['config']->get('plugins.email.from'); + + if (empty($from)) { + $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.FORGOT_EMAIL_NOT_CONFIGURED'), 'error'); + $this->setRedirect($post['redirect']); + + return true; + } + + $to = $user->email; + + $subject = $this->admin->translate(['PLUGIN_ADMIN.FORGOT_EMAIL_SUBJECT', $sitename]); + $content = $this->admin->translate([ + 'PLUGIN_ADMIN.FORGOT_EMAIL_BODY', + $fullname, + $reset_link, + $author, + $sitename + ]); + + $body = $this->grav['twig']->processTemplate('email/base.html.twig', ['content' => $content]); + + $message = $this->grav['Email']->message($subject, $body, 'text/html')->setFrom($from)->setTo($to); + + $sent = $this->grav['Email']->send($message); + + if ($sent < 1) { + $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.FORGOT_FAILED_TO_EMAIL'), 'error'); + } else { + $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.FORGOT_INSTRUCTIONS_SENT_VIA_EMAIL'), + 'info'); + } + + $this->setRedirect('/'); + return true; } @@ -649,58 +851,6 @@ class AdminController extends AdminBaseController return true; } - /** - * Handle login. - * - * @return bool True if the action was performed. - */ - protected function taskLogin() - { - $this->data['username'] = strip_tags(strtolower($this->data['username'])); - if ($this->admin->authenticate($this->data, $this->post)) { - // should never reach here, redirects first - } else { - $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.LOGIN_FAILED'), 'error'); - } - - return true; - } - - protected function task2faverify() - { - $twofa = $this->admin->get2FA(); - $user = $this->grav['user']; - - $secret = isset($user->twofa_secret) ? $user->twofa_secret : null; - - if (!(isset($this->data['2fa_code']) && $twofa->verifyCode($secret, $this->data['2fa_code']))) { - $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.2FA_FAILED'), 'error'); - return true; - } - - $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.LOGIN_LOGGED_IN'), 'info'); - - $user->authenticated = true; - $this->grav->redirect($this->post['redirect']); - } - - /** - * Handle logout. - * - * @return bool True if the action was performed. - */ - protected function taskLogout() - { - $message = $this->admin->translate('PLUGIN_ADMIN.LOGGED_OUT'); - - $this->admin->session()->invalidate()->start(); - $this->grav['session']->setFlashCookieObject(Admin::TMP_COOKIE_NAME, ['message' => $message, 'status' => 'info']); - - $this->setRedirect('/'); - - return true; - } - /** * Toggle the gpm.releases setting */ @@ -1111,104 +1261,6 @@ class AdminController extends AdminBaseController } } - /** - * Handle the email password recovery procedure. - * - * @return bool True if the action was performed. - */ - protected function taskForgot() - { - $param_sep = $this->grav['config']->get('system.param_sep', ':'); - $post = $this->post; - $data = $this->data; - $login = $this->grav['login']; - - $username = isset($data['username']) ? strip_tags(strtolower($data['username'])) : ''; - $user = !empty($username) ? User::load($username) : null; - - if (!isset($this->grav['Email'])) { - $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.FORGOT_EMAIL_NOT_CONFIGURED'), 'error'); - $this->setRedirect($post['redirect']); - - return true; - } - - if (!$user || !$user->exists()) { - $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.FORGOT_INSTRUCTIONS_SENT_VIA_EMAIL'), - 'info'); - $this->setRedirect($post['redirect']); - - return true; - } - - if (empty($user->email)) { - $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.FORGOT_INSTRUCTIONS_SENT_VIA_EMAIL'), - 'info'); - $this->setRedirect($post['redirect']); - - return true; - } - - $count = $this->grav['config']->get('plugins.login.max_pw_resets_count', 0); - $interval =$this->grav['config']->get('plugins.login.max_pw_resets_interval', 2); - - if ($login->isUserRateLimited($user, 'pw_resets', $count, $interval)) { - $this->admin->setMessage($this->admin->translate(['PLUGIN_LOGIN.FORGOT_CANNOT_RESET_IT_IS_BLOCKED', $user->email, $interval]), 'error'); - $this->setRedirect($post['redirect']); - - return true; - } - - $token = md5(uniqid(mt_rand(), true)); - $expire = time() + 604800; // next week - - $user->reset = $token . '::' . $expire; - $user->save(); - - $author = $this->grav['config']->get('site.author.name', ''); - $fullname = $user->fullname ?: $username; - $reset_link = rtrim($this->grav['uri']->rootUrl(true), '/') . '/' . trim($this->admin->base, - '/') . '/reset/task' . $param_sep . 'reset/user' . $param_sep . $username . '/token' . $param_sep . $token . '/admin-nonce' . $param_sep . Utils::getNonce('admin-form'); - - $sitename = $this->grav['config']->get('site.title', 'Website'); - $from = $this->grav['config']->get('plugins.email.from'); - - if (empty($from)) { - $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.FORGOT_EMAIL_NOT_CONFIGURED'), 'error'); - $this->setRedirect($post['redirect']); - - return true; - } - - $to = $user->email; - - $subject = $this->admin->translate(['PLUGIN_ADMIN.FORGOT_EMAIL_SUBJECT', $sitename]); - $content = $this->admin->translate([ - 'PLUGIN_ADMIN.FORGOT_EMAIL_BODY', - $fullname, - $reset_link, - $author, - $sitename - ]); - - $body = $this->grav['twig']->processTemplate('email/base.html.twig', ['content' => $content]); - - $message = $this->grav['Email']->message($subject, $body, 'text/html')->setFrom($from)->setTo($to); - - $sent = $this->grav['Email']->send($message); - - if ($sent < 1) { - $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.FORGOT_FAILED_TO_EMAIL'), 'error'); - } else { - $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.FORGOT_INSTRUCTIONS_SENT_VIA_EMAIL'), - 'info'); - } - - $this->setRedirect('/'); - - return true; - } - /** * Clear the cache. * @@ -2267,16 +2319,7 @@ class AdminController extends AdminBaseController } $this->setRedirect('/tools'); + + return true; } - - public function taskRegenerate2FASecret($secret = null) - { - if (!$this->authorizeTask('regenerate 2FA Secret', ['admin.login'])) { - return false; - } - - return $this->admin->get2FAData($secret); - - } - } diff --git a/classes/baconqrprovider.php b/classes/baconqrprovider.php deleted file mode 100644 index 5dd5da74..00000000 --- a/classes/baconqrprovider.php +++ /dev/null @@ -1,25 +0,0 @@ -setHeight($size); - $renderer->setWidth($size); - $writer = new BaconWriter($renderer); - $result = $writer->writeString($qrtext); - - return $result; - } -} diff --git a/composer.json b/composer.json index 441ac56a..c8786b66 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,7 @@ { "require": { "composer/semver": "^1.4", - "fguillot/picofeed": "@stable", - "robthree/twofactorauth": "^1.6", - "bacon/bacon-qr-code": "^1.0" + "fguillot/picofeed": "@stable" }, "require-dev": { "codeception/codeception": "^2.1", diff --git a/composer.lock b/composer.lock index 776a402c..6852cb17 100644 --- a/composer.lock +++ b/composer.lock @@ -1,57 +1,11 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "20422b73ece969b58e32511cbcc54346", + "content-hash": "9d176f21be9e6aa53b047ac12215bb45", "packages": [ - { - "name": "bacon/bacon-qr-code", - "version": "1.0.3", - "source": { - "type": "git", - "url": "https://github.com/Bacon/BaconQrCode.git", - "reference": "5a91b62b9d37cee635bbf8d553f4546057250bee" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/5a91b62b9d37cee635bbf8d553f4546057250bee", - "reference": "5a91b62b9d37cee635bbf8d553f4546057250bee", - "shasum": "" - }, - "require": { - "ext-iconv": "*", - "php": "^5.4|^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8" - }, - "suggest": { - "ext-gd": "to generate QR code images" - }, - "type": "library", - "autoload": { - "psr-0": { - "BaconQrCode": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Ben Scholzen 'DASPRiD'", - "email": "mail@dasprids.de", - "homepage": "http://www.dasprids.de", - "role": "Developer" - } - ], - "description": "BaconQrCode is a QR code generator for PHP.", - "homepage": "https://github.com/Bacon/BaconQrCode", - "time": "2017-10-17T09:59:25+00:00" - }, { "name": "composer/semver", "version": "1.4.2", @@ -168,87 +122,37 @@ "abandoned": true, "time": "2017-11-02T03:20:36+00:00" }, - { - "name": "robthree/twofactorauth", - "version": "1.6.1", - "source": { - "type": "git", - "url": "https://github.com/RobThree/TwoFactorAuth.git", - "reference": "a77e7d822343bb88112baef808839cfae7bc5abb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/RobThree/TwoFactorAuth/zipball/a77e7d822343bb88112baef808839cfae7bc5abb", - "reference": "a77e7d822343bb88112baef808839cfae7bc5abb", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "@stable" - }, - "type": "library", - "autoload": { - "psr-4": { - "RobThree\\Auth\\": "lib" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Rob Janssen", - "homepage": "http://robiii.me", - "role": "Developer" - } - ], - "description": "Two Factor Authentication", - "homepage": "https://github.com/RobThree/TwoFactorAuth", - "keywords": [ - "Authentication", - "MFA", - "Multi Factor Authentication", - "Two Factor Authentication", - "authenticator", - "authy", - "php", - "tfa" - ], - "time": "2017-11-06T17:55:56+00:00" - }, { "name": "zendframework/zendxml", - "version": "1.0.2", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/zendframework/ZendXml.git", - "reference": "7b64507bc35d841c9c5802d67f6f87ef8e1a58c9" + "reference": "267db6a2c431a08a8f8ff0f1f4c302a5ba6f5b99" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/ZendXml/zipball/7b64507bc35d841c9c5802d67f6f87ef8e1a58c9", - "reference": "7b64507bc35d841c9c5802d67f6f87ef8e1a58c9", + "url": "https://api.github.com/repos/zendframework/ZendXml/zipball/267db6a2c431a08a8f8ff0f1f4c302a5ba6f5b99", + "reference": "267db6a2c431a08a8f8ff0f1f4c302a5ba6f5b99", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^5.6 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "^3.7 || ^4.0", - "squizlabs/php_codesniffer": "^1.5" + "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.4", + "zendframework/zend-coding-standard": "~1.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.1.x-dev", + "dev-develop": "1.2.x-dev" } }, "autoload": { - "psr-0": { - "ZendXml\\": "library/" + "psr-4": { + "ZendXml\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -256,13 +160,13 @@ "BSD-3-Clause" ], "description": "Utility library for XML usage, best practices, and security in PHP", - "homepage": "http://packages.zendframework.com/", "keywords": [ + "ZendFramework", "security", "xml", - "zf2" + "zf" ], - "time": "2016-02-04T21:02:08+00:00" + "time": "2018-04-30T15:11:04+00:00" } ], "packages-dev": [ @@ -418,16 +322,16 @@ }, { "name": "codeception/phpunit-wrapper", - "version": "7.1.0", + "version": "7.1.1", "source": { "type": "git", "url": "https://github.com/Codeception/phpunit-wrapper.git", - "reference": "cde840638d021804ce93e8f98bcb7edbf6935423" + "reference": "33e8ccf2f7abf5c031eeae9802b821d30ec0f7fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/phpunit-wrapper/zipball/cde840638d021804ce93e8f98bcb7edbf6935423", - "reference": "cde840638d021804ce93e8f98bcb7edbf6935423", + "url": "https://api.github.com/repos/Codeception/phpunit-wrapper/zipball/33e8ccf2f7abf5c031eeae9802b821d30ec0f7fc", + "reference": "33e8ccf2f7abf5c031eeae9802b821d30ec0f7fc", "shasum": "" }, "require": { @@ -457,7 +361,7 @@ } ], "description": "PHPUnit classes used by Codeception", - "time": "2018-04-10T09:05:14+00:00" + "time": "2018-04-20T10:17:13+00:00" }, { "name": "codeception/stub", @@ -653,16 +557,16 @@ }, { "name": "guzzlehttp/guzzle", - "version": "6.3.2", + "version": "6.3.3", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "68d0ea14d5a3f42a20e87632a5f84931e2709c90" + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/68d0ea14d5a3f42a20e87632a5f84931e2709c90", - "reference": "68d0ea14d5a3f42a20e87632a5f84931e2709c90", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba", "shasum": "" }, "require": { @@ -672,7 +576,7 @@ }, "require-dev": { "ext-curl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", "psr/log": "^1.0" }, "suggest": { @@ -714,7 +618,7 @@ "rest", "web service" ], - "time": "2018-03-26T16:33:04+00:00" + "time": "2018-04-22T15:46:56+00:00" }, { "name": "guzzlehttp/promises", @@ -1133,23 +1037,23 @@ }, { "name": "phpspec/prophecy", - "version": "1.7.5", + "version": "1.7.6", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401" + "reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/dfd6be44111a7c41c2e884a336cc4f461b3b2401", - "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/33a7e3c4fda54e912ff6338c48823bd5c0f0b712", + "reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { @@ -1192,20 +1096,20 @@ "spy", "stub" ], - "time": "2018-02-19T10:16:54+00:00" + "time": "2018-04-18T13:57:24+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "6.0.3", + "version": "6.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "774a82c0c5da4c1c7701790c262035d235ab7856" + "reference": "52187754b0eed0b8159f62a6fa30073327e8c2ca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/774a82c0c5da4c1c7701790c262035d235ab7856", - "reference": "774a82c0c5da4c1c7701790c262035d235ab7856", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/52187754b0eed0b8159f62a6fa30073327e8c2ca", + "reference": "52187754b0eed0b8159f62a6fa30073327e8c2ca", "shasum": "" }, "require": { @@ -1255,7 +1159,7 @@ "testing", "xunit" ], - "time": "2018-04-06T15:39:20+00:00" + "time": "2018-04-29T14:59:09+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1445,16 +1349,16 @@ }, { "name": "phpunit/phpunit", - "version": "7.1.3", + "version": "7.1.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a7834993ddbf4b0ed2c3b2dc1f3b1d093ef910a9" + "reference": "6d51299e307dc510149e0b7cd1931dd11770e1cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a7834993ddbf4b0ed2c3b2dc1f3b1d093ef910a9", - "reference": "a7834993ddbf4b0ed2c3b2dc1f3b1d093ef910a9", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6d51299e307dc510149e0b7cd1931dd11770e1cb", + "reference": "6d51299e307dc510149e0b7cd1931dd11770e1cb", "shasum": "" }, "require": { @@ -1473,7 +1377,7 @@ "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^2.0", "phpunit/phpunit-mock-objects": "^6.1.1", - "sebastian/comparator": "^2.1", + "sebastian/comparator": "^2.1 || ^3.0", "sebastian/diff": "^3.0", "sebastian/environment": "^3.1", "sebastian/exporter": "^3.1", @@ -1521,7 +1425,7 @@ "testing", "xunit" ], - "time": "2018-04-13T02:28:50+00:00" + "time": "2018-04-18T13:41:53+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -2241,7 +2145,7 @@ }, { "name": "symfony/browser-kit", - "version": "v4.0.8", + "version": "v4.0.9", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", @@ -2298,16 +2202,16 @@ }, { "name": "symfony/console", - "version": "v2.8.38", + "version": "v2.8.39", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "7f78892d900c72a40acd1fe793c856ef0c110f26" + "reference": "932d1e4f7f33ee37d3534f5f452474daa66283c2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/7f78892d900c72a40acd1fe793c856ef0c110f26", - "reference": "7f78892d900c72a40acd1fe793c856ef0c110f26", + "url": "https://api.github.com/repos/symfony/console/zipball/932d1e4f7f33ee37d3534f5f452474daa66283c2", + "reference": "932d1e4f7f33ee37d3534f5f452474daa66283c2", "shasum": "" }, "require": { @@ -2321,7 +2225,7 @@ "symfony/process": "~2.1|~3.0.0" }, "suggest": { - "psr/log": "For using the console logger", + "psr/log-implementation": "For using the console logger", "symfony/event-dispatcher": "", "symfony/process": "" }, @@ -2355,11 +2259,11 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2018-04-03T05:20:27+00:00" + "time": "2018-04-30T01:21:07+00:00" }, { "name": "symfony/css-selector", - "version": "v4.0.8", + "version": "v4.0.9", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", @@ -2469,7 +2373,7 @@ }, { "name": "symfony/dom-crawler", - "version": "v4.0.8", + "version": "v4.0.9", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", @@ -2525,7 +2429,7 @@ }, { "name": "symfony/event-dispatcher", - "version": "v2.8.38", + "version": "v2.8.39", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -2585,7 +2489,7 @@ }, { "name": "symfony/finder", - "version": "v2.8.38", + "version": "v2.8.39", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", @@ -2634,16 +2538,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.7.0", + "version": "v1.8.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b" + "reference": "3296adf6a6454a050679cde90f95350ad604b171" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/78be803ce01e55d3491c1397cf1c64beb9c1b63b", - "reference": "78be803ce01e55d3491c1397cf1c64beb9c1b63b", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3296adf6a6454a050679cde90f95350ad604b171", + "reference": "3296adf6a6454a050679cde90f95350ad604b171", "shasum": "" }, "require": { @@ -2655,7 +2559,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "1.8-dev" } }, "autoload": { @@ -2689,11 +2593,11 @@ "portable", "shim" ], - "time": "2018-01-30T19:27:44+00:00" + "time": "2018-04-26T10:06:28+00:00" }, { "name": "symfony/process", - "version": "v4.0.8", + "version": "v4.0.9", "source": { "type": "git", "url": "https://github.com/symfony/process.git", @@ -2742,16 +2646,16 @@ }, { "name": "symfony/yaml", - "version": "v2.8.38", + "version": "v2.8.39", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "be720fcfae4614df204190d57795351059946a77" + "reference": "d20bd2bdee063863e426297af41eda45ccad6f7e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/be720fcfae4614df204190d57795351059946a77", - "reference": "be720fcfae4614df204190d57795351059946a77", + "url": "https://api.github.com/repos/symfony/yaml/zipball/d20bd2bdee063863e426297af41eda45ccad6f7e", + "reference": "d20bd2bdee063863e426297af41eda45ccad6f7e", "shasum": "" }, "require": { @@ -2787,7 +2691,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2018-01-03T07:36:31+00:00" + "time": "2018-04-08T07:53:13+00:00" }, { "name": "theseer/tokenizer", diff --git a/themes/grav/templates/forms/fields/2fa_secret/2fa_secret.html.twig b/themes/grav/templates/forms/fields/2fa_secret/2fa_secret.html.twig index 7bf0c499..59ec39c5 100644 --- a/themes/grav/templates/forms/fields/2fa_secret/2fa_secret.html.twig +++ b/themes/grav/templates/forms/fields/2fa_secret/2fa_secret.html.twig @@ -2,23 +2,22 @@ {% block input %}
- {% do admin.get2FAData(value) %} - {% set data = admin.json_response %} - {% if data.status == 'success' %} - - + {% try %} + {% set user = grav.user %} + {% set image = grav.login.twoFactorAuth.getQrImageData(user.username, user.twofa_secret) %} +
- {{ 'PLUGIN_ADMIN.2FA_SECRET'|tu }}: {{ data.secret }} + {{ 'PLUGIN_ADMIN.2FA_SECRET'|tu }}: {{ user.twofa_secret }}
- + - {% else %} + {% catch %}
-

{{ data.message }}

+

{{ e.message }}

- {% endif %} + {% endcatch %}
{% endblock %} diff --git a/vendor/bacon/bacon-qr-code/.gitignore b/vendor/bacon/bacon-qr-code/.gitignore deleted file mode 100644 index c4fcf188..00000000 --- a/vendor/bacon/bacon-qr-code/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -composer.lock -vendor -nbproject -.idea -.buildpath -.project -.DS_Store -.*.sw* -.*.un~ diff --git a/vendor/bacon/bacon-qr-code/.travis.yml b/vendor/bacon/bacon-qr-code/.travis.yml deleted file mode 100644 index 242163ab..00000000 --- a/vendor/bacon/bacon-qr-code/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: php -php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - hhvm - -install: - - travis_retry composer install --no-interaction - - composer info -i - -script: vendor/bin/phpunit --bootstrap tests/bootstrap.php --configuration tests/phpunit.xml tests diff --git a/vendor/bacon/bacon-qr-code/LICENSE b/vendor/bacon/bacon-qr-code/LICENSE deleted file mode 100644 index a72461a0..00000000 --- a/vendor/bacon/bacon-qr-code/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2013, Ben 'DASPRiD' Scholzen -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -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/bacon/bacon-qr-code/Module.php b/vendor/bacon/bacon-qr-code/Module.php deleted file mode 100644 index ad7798c0..00000000 --- a/vendor/bacon/bacon-qr-code/Module.php +++ /dev/null @@ -1,37 +0,0 @@ - array( - __DIR__ . '/autoload_classmap.php', - ), - 'Zend\Loader\StandardAutoloader' => array( - 'namespaces' => array( - __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, - ), - ), - ); - } -} diff --git a/vendor/bacon/bacon-qr-code/README.md b/vendor/bacon/bacon-qr-code/README.md deleted file mode 100644 index a836bd61..00000000 --- a/vendor/bacon/bacon-qr-code/README.md +++ /dev/null @@ -1,24 +0,0 @@ -QR Code generator -================= - -Master: [![Build Status](https://api.travis-ci.org/Bacon/BaconQrCode.png?branch=master)](http://travis-ci.org/Bacon/BaconQrCode) - -Introduction ------------- -BaconQrCode is a port of QR code portion of the ZXing library. It currently -only features the encoder part, but could later receive the decoder part as -well. - -As the Reed Solomon codec implementation of the ZXing library performs quite -slow in PHP, it was exchanged with the implementation by Phil Karn. - - -Example usage -------------- -```php -$renderer = new \BaconQrCode\Renderer\Image\Png(); -$renderer->setHeight(256); -$renderer->setWidth(256); -$writer = new \BaconQrCode\Writer($renderer); -$writer->writeFile('Hello World!', 'qrcode.png'); -``` diff --git a/vendor/bacon/bacon-qr-code/autoload_classmap.php b/vendor/bacon/bacon-qr-code/autoload_classmap.php deleted file mode 100644 index 9fbeb35b..00000000 --- a/vendor/bacon/bacon-qr-code/autoload_classmap.php +++ /dev/null @@ -1,43 +0,0 @@ - __DIR__ . '/src/BaconQrCode/Common/AbstractEnum.php', - 'BaconQrCode\Common\BitArray' => __DIR__ . '/src/BaconQrCode/Common/BitArray.php', - 'BaconQrCode\Common\BitMatrix' => __DIR__ . '/src/BaconQrCode/Common/BitMatrix.php', - 'BaconQrCode\Common\BitUtils' => __DIR__ . '/src/BaconQrCode/Common/BitUtils.php', - 'BaconQrCode\Common\CharacterSetEci' => __DIR__ . '/src/BaconQrCode/Common/CharacterSetEci.php', - 'BaconQrCode\Common\EcBlock' => __DIR__ . '/src/BaconQrCode/Common/EcBlock.php', - 'BaconQrCode\Common\EcBlocks' => __DIR__ . '/src/BaconQrCode/Common/EcBlocks.php', - 'BaconQrCode\Common\ErrorCorrectionLevel' => __DIR__ . '/src/BaconQrCode/Common/ErrorCorrectionLevel.php', - 'BaconQrCode\Common\FormatInformation' => __DIR__ . '/src/BaconQrCode/Common/FormatInformation.php', - 'BaconQrCode\Common\Mode' => __DIR__ . '/src/BaconQrCode/Common/Mode.php', - 'BaconQrCode\Common\ReedSolomonCodec' => __DIR__ . '/src/BaconQrCode/Common/ReedSolomonCodec.php', - 'BaconQrCode\Common\Version' => __DIR__ . '/src/BaconQrCode/Common/Version.php', - 'BaconQrCode\Encoder\BlockPair' => __DIR__ . '/src/BaconQrCode/Encoder/BlockPair.php', - 'BaconQrCode\Encoder\ByteMatrix' => __DIR__ . '/src/BaconQrCode/Encoder/ByteMatrix.php', - 'BaconQrCode\Encoder\Encoder' => __DIR__ . '/src/BaconQrCode/Encoder/Encoder.php', - 'BaconQrCode\Encoder\MaskUtil' => __DIR__ . '/src/BaconQrCode/Encoder/MaskUtil.php', - 'BaconQrCode\Encoder\MatrixUtil' => __DIR__ . '/src/BaconQrCode/Encoder/MatrixUtil.php', - 'BaconQrCode\Encoder\QrCode' => __DIR__ . '/src/BaconQrCode/Encoder/QrCode.php', - 'BaconQrCode\Exception\ExceptionInterface' => __DIR__ . '/src/BaconQrCode/Exception/ExceptionInterface.php', - 'BaconQrCode\Exception\InvalidArgumentException' => __DIR__ . '/src/BaconQrCode/Exception/InvalidArgumentException.php', - 'BaconQrCode\Exception\OutOfBoundsException' => __DIR__ . '/src/BaconQrCode/Exception/OutOfBoundsException.php', - 'BaconQrCode\Exception\RuntimeException' => __DIR__ . '/src/BaconQrCode/Exception/RuntimeException.php', - 'BaconQrCode\Exception\UnexpectedValueException' => __DIR__ . '/src/BaconQrCode/Exception/UnexpectedValueException.php', - 'BaconQrCode\Exception\WriterException' => __DIR__ . '/src/BaconQrCode/Exception/WriterException.php', - 'BaconQrCode\Renderer\Color\Cmyk' => __DIR__ . '/src/BaconQrCode/Renderer/Color/Cmyk.php', - 'BaconQrCode\Renderer\Color\ColorInterface' => __DIR__ . '/src/BaconQrCode/Renderer/Color/ColorInterface.php', - 'BaconQrCode\Renderer\Color\Gray' => __DIR__ . '/src/BaconQrCode/Renderer/Color/Gray.php', - 'BaconQrCode\Renderer\Color\Rgb' => __DIR__ . '/src/BaconQrCode/Renderer/Color/Rgb.php', - 'BaconQrCode\Renderer\Image\AbstractRenderer' => __DIR__ . '/src/BaconQrCode/Renderer/Image/AbstractRenderer.php', - 'BaconQrCode\Renderer\Image\Decorator\DecoratorInterface' => __DIR__ . '/src/BaconQrCode/Renderer/Image/Decorator/DecoratorInterface.php', - 'BaconQrCode\Renderer\Image\Decorator\FinderPattern' => __DIR__ . '/src/BaconQrCode/Renderer/Image/Decorator/FinderPattern.php', - 'BaconQrCode\Renderer\Image\Eps' => __DIR__ . '/src/BaconQrCode/Renderer/Image/Eps.php', - 'BaconQrCode\Renderer\Image\Png' => __DIR__ . '/src/BaconQrCode/Renderer/Image/Png.php', - 'BaconQrCode\Renderer\Image\RendererInterface' => __DIR__ . '/src/BaconQrCode/Renderer/Image/RendererInterface.php', - 'BaconQrCode\Renderer\Image\Svg' => __DIR__ . '/src/BaconQrCode/Renderer/Image/Svg.php', - 'BaconQrCode\Renderer\RendererInterface' => __DIR__ . '/src/BaconQrCode/Renderer/RendererInterface.php', - 'BaconQrCode\Renderer\Text\Plain' => __DIR__ . '/src/BaconQrCode/Renderer/Text/Plain.php', - 'BaconQrCode\Renderer\Text\Html' => __DIR__ . '/src/BaconQrCode/Renderer/Text/Html.php', - 'BaconQrCode\Writer' => __DIR__ . '/src/BaconQrCode/Writer.php', -); \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/autoload_function.php b/vendor/bacon/bacon-qr-code/autoload_function.php deleted file mode 100644 index 9148da38..00000000 --- a/vendor/bacon/bacon-qr-code/autoload_function.php +++ /dev/null @@ -1,12 +0,0 @@ -strict = $strict; - $this->change($initialValue); - } - - /** - * Changes the value of the enum. - * - * @param mixed $value - * @return void - */ - public function change($value) - { - if (!in_array($value, $this->getConstList(), $this->strict)) { - throw new Exception\UnexpectedValueException('Value not a const in enum ' . get_class($this)); - } - - $this->value = $value; - } - - /** - * Gets current value. - * - * @return mixed - */ - public function get() - { - return $this->value; - } - - /** - * Gets all constants (possible values) as an array. - * - * @param boolean $includeDefault - * @return array - */ - public function getConstList($includeDefault = true) - { - if ($this->constants === null) { - $reflection = new ReflectionClass($this); - $this->constants = $reflection->getConstants(); - } - - if ($includeDefault) { - return $this->constants; - } - - $constants = $this->constants; - unset($constants['__default']); - - return $constants; - } - - /** - * Gets the name of the enum. - * - * @return string - */ - public function __toString() - { - return array_search($this->value, $this->getConstList()); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/BitArray.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/BitArray.php deleted file mode 100644 index 0a99d9a9..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/BitArray.php +++ /dev/null @@ -1,435 +0,0 @@ -size = $size; - $this->bits = new SplFixedArray(($this->size + 31) >> 3); - } - - /** - * Gets the size in bits. - * - * @return integer - */ - public function getSize() - { - return $this->size; - } - - /** - * Gets the size in bytes. - * - * @return integer - */ - public function getSizeInBytes() - { - return ($this->size + 7) >> 3; - } - - /** - * Ensures that the array has a minimum capacity. - * - * @param integer $size - * @return void - */ - public function ensureCapacity($size) - { - if ($size > count($this->bits) << 5) { - $this->bits->setSize(($size + 31) >> 5); - } - } - - /** - * Gets a specific bit. - * - * @param integer $i - * @return boolean - */ - public function get($i) - { - return ($this->bits[$i >> 5] & (1 << ($i & 0x1f))) !== 0; - } - - /** - * Sets a specific bit. - * - * @param integer $i - * @return void - */ - public function set($i) - { - $this->bits[$i >> 5] = $this->bits[$i >> 5] | 1 << ($i & 0x1f); - } - - /** - * Flips a specific bit. - * - * @param integer $i - * @return void - */ - public function flip($i) - { - $this->bits[$i >> 5] ^= 1 << ($i & 0x1f); - } - - /** - * Gets the next set bit position from a given position. - * - * @param integer $from - * @return integer - */ - public function getNextSet($from) - { - if ($from >= $this->size) { - return $this->size; - } - - $bitsOffset = $from >> 5; - $currentBits = $this->bits[$bitsOffset]; - $bitsLength = count($this->bits); - - $currentBits &= ~((1 << ($from & 0x1f)) - 1); - - while ($currentBits === 0) { - if (++$bitsOffset === $bitsLength) { - return $this->size; - } - - $currentBits = $this->bits[$bitsOffset]; - } - - $result = ($bitsOffset << 5) + BitUtils::numberOfTrailingZeros($currentBits); - - return $result > $this->size ? $this->size : $result; - } - - /** - * Gets the next unset bit position from a given position. - * - * @param integer $from - * @return integer - */ - public function getNextUnset($from) - { - if ($from >= $this->size) { - return $this->size; - } - - $bitsOffset = $from >> 5; - $currentBits = ~$this->bits[$bitsOffset]; - $bitsLength = count($this->bits); - - $currentBits &= ~((1 << ($from & 0x1f)) - 1); - - while ($currentBits === 0) { - if (++$bitsOffset === $bitsLength) { - return $this->size; - } - - $currentBits = ~$this->bits[$bitsOffset]; - } - - $result = ($bitsOffset << 5) + BitUtils::numberOfTrailingZeros($currentBits); - - return $result > $this->size ? $this->size : $result; - } - - /** - * Sets a bulk of bits. - * - * @param integer $i - * @param integer $newBits - * @return void - */ - public function setBulk($i, $newBits) - { - $this->bits[$i >> 5] = $newBits; - } - - /** - * Sets a range of bits. - * - * @param integer $start - * @param integer $end - * @return void - * @throws Exception\InvalidArgumentException - */ - public function setRange($start, $end) - { - if ($end < $start) { - throw new Exception\InvalidArgumentException('End must be greater or equal to start'); - } - - if ($end === $start) { - return; - } - - $end--; - - $firstInt = $start >> 5; - $lastInt = $end >> 5; - - for ($i = $firstInt; $i <= $lastInt; $i++) { - $firstBit = $i > $firstInt ? 0 : $start & 0x1f; - $lastBit = $i < $lastInt ? 31 : $end & 0x1f; - - if ($firstBit === 0 && $lastBit === 31) { - $mask = 0x7fffffff; - } else { - $mask = 0; - - for ($j = $firstBit; $j < $lastBit; $j++) { - $mask |= 1 << $j; - } - } - - $this->bits[$i] = $this->bits[$i] | $mask; - } - } - - /** - * Clears the bit array, unsetting every bit. - * - * @return void - */ - public function clear() - { - $bitsLength = count($this->bits); - - for ($i = 0; $i < $bitsLength; $i++) { - $this->bits[$i] = 0; - } - } - - /** - * Checks if a range of bits is set or not set. - * - * @param integer $start - * @param integer $end - * @param integer $value - * @return boolean - * @throws Exception\InvalidArgumentException - */ - public function isRange($start, $end, $value) - { - if ($end < $start) { - throw new Exception\InvalidArgumentException('End must be greater or equal to start'); - } - - if ($end === $start) { - return; - } - - $end--; - - $firstInt = $start >> 5; - $lastInt = $end >> 5; - - for ($i = $firstInt; $i <= $lastInt; $i++) { - $firstBit = $i > $firstInt ? 0 : $start & 0x1f; - $lastBit = $i < $lastInt ? 31 : $end & 0x1f; - - if ($firstBit === 0 && $lastBit === 31) { - $mask = 0x7fffffff; - } else { - $mask = 0; - - for ($j = $firstBit; $j <= $lastBit; $j++) { - $mask |= 1 << $j; - } - } - - if (($this->bits[$i] & $mask) !== ($value ? $mask : 0)) { - return false; - } - } - - return true; - } - - /** - * Appends a bit to the array. - * - * @param boolean $bit - * @return void - */ - public function appendBit($bit) - { - $this->ensureCapacity($this->size + 1); - - if ($bit) { - $this->bits[$this->size >> 5] = $this->bits[$this->size >> 5] | (1 << ($this->size & 0x1f)); - } - - $this->size++; - } - - /** - * Appends a number of bits (up to 32) to the array. - * - * @param integer $value - * @param integer $numBits - * @return void - * @throws Exception\InvalidArgumentException - */ - public function appendBits($value, $numBits) - { - if ($numBits < 0 || $numBits > 32) { - throw new Exception\InvalidArgumentException('Num bits must be between 0 and 32'); - } - - $this->ensureCapacity($this->size + $numBits); - - for ($numBitsLeft = $numBits; $numBitsLeft > 0; $numBitsLeft--) { - $this->appendBit((($value >> ($numBitsLeft - 1)) & 0x01) === 1); - } - } - - /** - * Appends another bit array to this array. - * - * @param BitArray $other - * @return void - */ - public function appendBitArray(self $other) - { - $otherSize = $other->getSize(); - $this->ensureCapacity($this->size + $other->getSize()); - - for ($i = 0; $i < $otherSize; $i++) { - $this->appendBit($other->get($i)); - } - } - - /** - * Makes an exclusive-or comparision on the current bit array. - * - * @param BitArray $other - * @return void - * @throws Exception\InvalidArgumentException - */ - public function xorBits(self $other) - { - $bitsLength = count($this->bits); - $otherBits = $other->getBitArray(); - - if ($bitsLength !== count($otherBits)) { - throw new Exception\InvalidArgumentException('Sizes don\'t match'); - } - - for ($i = 0; $i < $bitsLength; $i++) { - $this->bits[$i] = $this->bits[$i] ^ $otherBits[$i]; - } - } - - /** - * Converts the bit array to a byte array. - * - * @param integer $bitOffset - * @param integer $numBytes - * @return SplFixedArray - */ - public function toBytes($bitOffset, $numBytes) - { - $bytes = new SplFixedArray($numBytes); - - for ($i = 0; $i < $numBytes; $i++) { - $byte = 0; - - for ($j = 0; $j < 8; $j++) { - if ($this->get($bitOffset)) { - $byte |= 1 << (7 - $j); - } - - $bitOffset++; - } - - $bytes[$i] = $byte; - } - - return $bytes; - } - - /** - * Gets the internal bit array. - * - * @return SplFixedArray - */ - public function getBitArray() - { - return $this->bits; - } - - /** - * Reverses the array. - * - * @return void - */ - public function reverse() - { - $newBits = new SplFixedArray(count($this->bits)); - - for ($i = 0; $i < $this->size; $i++) { - if ($this->get($this->size - $i - 1)) { - $newBits[$i >> 5] = $newBits[$i >> 5] | (1 << ($i & 0x1f)); - } - } - - $this->bits = newBits; - } - - /** - * Returns a string representation of the bit array. - * - * @return string - */ - public function __toString() - { - $result = ''; - - for ($i = 0; $i < $this->size; $i++) { - if (($i & 0x07) === 0) { - $result .= ' '; - } - - $result .= $this->get($i) ? 'X' : '.'; - } - - return $result; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/BitMatrix.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/BitMatrix.php deleted file mode 100644 index b930f88b..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/BitMatrix.php +++ /dev/null @@ -1,350 +0,0 @@ -width = $width; - $this->height = $height; - $this->rowSize = ($width + 31) >> 5; - $this->bits = new SplFixedArray($this->rowSize * $height); - } - - /** - * Gets the requested bit, where true means black. - * - * @param integer $x - * @param integer $y - * @return boolean - */ - public function get($x, $y) - { - $offset = $y * $this->rowSize + ($x >> 5); - return (BitUtils::unsignedRightShift($this->bits[$offset], ($x & 0x1f)) & 1) !== 0; - } - - /** - * Sets the given bit to true. - * - * @param integer $x - * @param integer $y - * @return void - */ - public function set($x, $y) - { - $offset = $y * $this->rowSize + ($x >> 5); - $this->bits[$offset] = $this->bits[$offset] | (1 << ($x & 0x1f)); - } - - /** - * Flips the given bit. - * - * @param integer $x - * @param integer $y - * @return void - */ - public function flip($x, $y) - { - $offset = $y * $this->rowSize + ($x >> 5); - $this->bits[$offset] = $this->bits[$offset] ^ (1 << ($x & 0x1f)); - } - - /** - * Clears all bits (set to false). - * - * @return void - */ - public function clear() - { - $max = count($this->bits); - - for ($i = 0; $i < $max; $i++) { - $this->bits[$i] = 0; - } - } - - /** - * Sets a square region of the bit matrix to true. - * - * @param integer $left - * @param integer $top - * @param integer $width - * @param integer $height - * @return void - */ - public function setRegion($left, $top, $width, $height) - { - if ($top < 0 || $left < 0) { - throw new Exception\InvalidArgumentException('Left and top must be non-negative'); - } - - if ($height < 1 || $width < 1) { - throw new Exception\InvalidArgumentException('Width and height must be at least 1'); - } - - $right = $left + $width; - $bottom = $top + $height; - - if ($bottom > $this->height || $right > $this->width) { - throw new Exception\InvalidArgumentException('The region must fit inside the matrix'); - } - - for ($y = $top; $y < $bottom; $y++) { - $offset = $y * $this->rowSize; - - for ($x = $left; $x < $right; $x++) { - $index = $offset + ($x >> 5); - $this->bits[$index] = $this->bits[$index] | (1 << ($x & 0x1f)); - } - } - } - - /** - * A fast method to retrieve one row of data from the matrix as a BitArray. - * - * @param integer $y - * @param BitArray $row - * @return BitArray - */ - public function getRow($y, BitArray $row = null) - { - if ($row === null || $row->getSize() < $this->width) { - $row = new BitArray($this->width); - } - - $offset = $y * $this->rowSize; - - for ($x = 0; $x < $this->rowSize; $x++) { - $row->setBulk($x << 5, $this->bits[$offset + $x]); - } - - return $row; - } - - /** - * Sets a row of data from a BitArray. - * - * @param integer $y - * @param BitArray $row - * @return void - */ - public function setRow($y, BitArray $row) - { - $bits = $row->getBitArray(); - - for ($i = 0; $i < $this->rowSize; $i++) { - $this->bits[$y * $this->rowSize + $i] = $bits[$i]; - } - } - - /** - * This is useful in detecting the enclosing rectangle of a 'pure' barcode. - * - * @return SplFixedArray - */ - public function getEnclosingRectangle() - { - $left = $this->width; - $top = $this->height; - $right = -1; - $bottom = -1; - - for ($y = 0; $y < $this->height; $y++) { - for ($x32 = 0; $x32 < $this->rowSize; $x32++) { - $bits = $this->bits[$y * $this->rowSize + $x32]; - - if ($bits !== 0) { - if ($y < $top) { - $top = $y; - } - - if ($y > $bottom) { - $bottom = $y; - } - - if ($x32 * 32 < $left) { - $bit = 0; - - while (($bits << (31 - $bit)) === 0) { - $bit++; - } - - if (($x32 * 32 + $bit) < $left) { - $left = $x32 * 32 + $bit; - } - } - } - - if ($x32 * 32 + 31 > $right) { - $bit = 31; - - while (BitUtils::unsignedRightShift($bits, $bit) === 0) { - $bit--; - } - - if (($x32 * 32 + $bit) > $right) { - $right = $x32 * 32 + $bit; - } - } - } - } - - $width = $right - $left; - $height = $bottom - $top; - - if ($width < 0 || $height < 0) { - return null; - } - - return SplFixedArray::fromArray(array($left, $top, $width, $height), false); - } - - /** - * Gets the most top left set bit. - * - * This is useful in detecting a corner of a 'pure' barcode. - * - * @return SplFixedArray - */ - public function getTopLeftOnBit() - { - $bitsOffset = 0; - - while ($bitsOffset < count($this->bits) && $this->bits[$bitsOffset] === 0) { - $bitsOffset++; - } - - if ($bitsOffset === count($this->bits)) { - return null; - } - - $x = intval($bitsOffset / $this->rowSize); - $y = ($bitsOffset % $this->rowSize) << 5; - - $bits = $this->bits[$bitsOffset]; - $bit = 0; - - while (($bits << (31 - $bit)) === 0) { - $bit++; - } - - $x += $bit; - - return SplFixedArray::fromArray(array($x, $y), false); - } - - /** - * Gets the most bottom right set bit. - * - * This is useful in detecting a corner of a 'pure' barcode. - * - * @return SplFixedArray - */ - public function getBottomRightOnBit() - { - $bitsOffset = count($this->bits) - 1; - - while ($bitsOffset >= 0 && $this->bits[$bitsOffset] === 0) { - $bitsOffset--; - } - - if ($bitsOffset < 0) { - return null; - } - - $x = intval($bitsOffset / $this->rowSize); - $y = ($bitsOffset % $this->rowSize) << 5; - - $bits = $this->bits[$bitsOffset]; - $bit = 0; - - while (BitUtils::unsignedRightShift($bits, $bit) === 0) { - $bit--; - } - - $x += $bit; - - return SplFixedArray::fromArray(array($x, $y), false); - } - - /** - * Gets the width of the matrix, - * - * @return integer - */ - public function getWidth() - { - return $this->width; - } - - /** - * Gets the height of the matrix. - * - * @return integer - */ - public function getHeight() - { - return $this->height; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/BitUtils.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/BitUtils.php deleted file mode 100644 index a6412440..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/BitUtils.php +++ /dev/null @@ -1,51 +0,0 @@ ->>" in other - * languages. - * - * @param integer $a - * @param integer $b - * @return integer - */ - public static function unsignedRightShift($a, $b) - { - return ( - $a >= 0 - ? $a >> $b - : (($a & 0x7fffffff) >> $b) | (0x40000000 >> ($b - 1)) - ); - } - - /** - * Gets the number of trailing zeros. - * - * @param integer $i - * @return integer - */ - public static function numberOfTrailingZeros($i) - { - $lastPos = strrpos(str_pad(decbin($i), 32, '0', STR_PAD_LEFT), '1'); - - return $lastPos === false ? 32 : 31 - $lastPos; - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/CharacterSetEci.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/CharacterSetEci.php deleted file mode 100644 index 77662360..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/CharacterSetEci.php +++ /dev/null @@ -1,134 +0,0 @@ - self::ISO8859_1, - 'ISO-8859-2' => self::ISO8859_2, - 'ISO-8859-3' => self::ISO8859_3, - 'ISO-8859-4' => self::ISO8859_4, - 'ISO-8859-5' => self::ISO8859_5, - 'ISO-8859-6' => self::ISO8859_6, - 'ISO-8859-7' => self::ISO8859_7, - 'ISO-8859-8' => self::ISO8859_8, - 'ISO-8859-9' => self::ISO8859_9, - 'ISO-8859-10' => self::ISO8859_10, - 'ISO-8859-11' => self::ISO8859_11, - 'ISO-8859-12' => self::ISO8859_12, - 'ISO-8859-13' => self::ISO8859_13, - 'ISO-8859-14' => self::ISO8859_14, - 'ISO-8859-15' => self::ISO8859_15, - 'ISO-8859-16' => self::ISO8859_16, - 'SHIFT-JIS' => self::SJIS, - 'WINDOWS-1250' => self::CP1250, - 'WINDOWS-1251' => self::CP1251, - 'WINDOWS-1252' => self::CP1252, - 'WINDOWS-1256' => self::CP1256, - 'UTF-16BE' => self::UNICODE_BIG_UNMARKED, - 'UTF-8' => self::UTF8, - 'ASCII' => self::ASCII, - 'GBK' => self::GB18030, - 'EUC-KR' => self::EUC_KR, - ); - - /** - * Additional possible values for character sets. - * - * @var array - */ - protected $additionalValues = array( - self::CP437 => 2, - self::ASCII => 170, - ); - - /** - * Gets character set ECI by value. - * - * @param string $name - * @return CharacterSetEci|null - */ - public static function getCharacterSetECIByValue($value) - { - if ($value < 0 || $value >= 900) { - throw new Exception\InvalidArgumentException('Value must be between 0 and 900'); - } - - if (false !== ($key = array_search($value, self::$additionalValues))) { - $value = $key; - } - - try { - return new self($value); - } catch (Exception\UnexpectedValueException $e) { - return null; - } - } - - /** - * Gets character set ECI by name. - * - * @param string $name - * @return CharacterSetEci|null - */ - public static function getCharacterSetECIByName($name) - { - $name = strtoupper($name); - - if (isset(self::$nameToEci[$name])) { - return new self(self::$nameToEci[$name]); - } - - return null; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/EcBlock.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/EcBlock.php deleted file mode 100644 index cbcc2ba0..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/EcBlock.php +++ /dev/null @@ -1,65 +0,0 @@ -count = $count; - $this->dataCodewords = $dataCodewords; - } - - /** - * Returns how many times the block is used. - * - * @return integer - */ - public function getCount() - { - return $this->count; - } - - /** - * Returns the number of data codewords. - * - * @return integer - */ - public function getDataCodewords() - { - return $this->dataCodewords; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/EcBlocks.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/EcBlocks.php deleted file mode 100644 index 87cef5d0..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/EcBlocks.php +++ /dev/null @@ -1,101 +0,0 @@ -ecCodewordsPerBlock = $ecCodewordsPerBlock; - - $this->ecBlocks = new SplFixedArray($ecb2 === null ? 1 : 2); - $this->ecBlocks[0] = $ecb1; - - if ($ecb2 !== null) { - $this->ecBlocks[1] = $ecb2; - } - } - - /** - * Gets the number of EC codewords per block. - * - * @return integer - */ - public function getEcCodewordsPerBlock() - { - return $this->ecCodewordsPerBlock; - } - - /** - * Gets the total number of EC block appearances. - * - * @return integer - */ - public function getNumBlocks() - { - $total = 0; - - foreach ($this->ecBlocks as $ecBlock) { - $total += $ecBlock->getCount(); - } - - return $total; - } - - /** - * Gets the total count of EC codewords. - * - * @return integer - */ - public function getTotalEcCodewords() - { - return $this->ecCodewordsPerBlock * $this->getNumBlocks(); - } - - /** - * Gets the EC blocks included in this collection. - * - * @return SplFixedArray - */ - public function getEcBlocks() - { - return $this->ecBlocks; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/ErrorCorrectionLevel.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/ErrorCorrectionLevel.php deleted file mode 100644 index bd0a60a3..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/ErrorCorrectionLevel.php +++ /dev/null @@ -1,62 +0,0 @@ -value) { - case self::L: - return 0; - break; - - case self::M: - return 1; - break; - - case self::Q: - return 2; - break; - - case self::H: - return 3; - break; - } - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/FormatInformation.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/FormatInformation.php deleted file mode 100644 index 5ec9ffd4..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/FormatInformation.php +++ /dev/null @@ -1,236 +0,0 @@ -ecLevel = new ErrorCorrectionLevel(($formatInfo >> 3) & 0x3); - $this->dataMask = $formatInfo & 0x7; - } - - /** - * Checks how many bits are different between two integers. - * - * @param integer $a - * @param integer $b - * @return integer - */ - public static function numBitsDiffering($a, $b) - { - $a ^= $b; - - return ( - self::$bitsSetInHalfByte[$a & 0xf] - + self::$bitsSetInHalfByte[(BitUtils::unsignedRightShift($a, 4) & 0xf)] - + self::$bitsSetInHalfByte[(BitUtils::unsignedRightShift($a, 8) & 0xf)] - + self::$bitsSetInHalfByte[(BitUtils::unsignedRightShift($a, 12) & 0xf)] - + self::$bitsSetInHalfByte[(BitUtils::unsignedRightShift($a, 16) & 0xf)] - + self::$bitsSetInHalfByte[(BitUtils::unsignedRightShift($a, 20) & 0xf)] - + self::$bitsSetInHalfByte[(BitUtils::unsignedRightShift($a, 24) & 0xf)] - + self::$bitsSetInHalfByte[(BitUtils::unsignedRightShift($a, 28) & 0xf)] - ); - } - - /** - * Decodes format information. - * - * @param integer $maskedFormatInfo1 - * @param integer $maskedFormatInfo2 - * @return FormatInformation|null - */ - public static function decodeFormatInformation($maskedFormatInfo1, $maskedFormatInfo2) - { - $formatInfo = self::doDecodeFormatInformation($maskedFormatInfo1, $maskedFormatInfo2); - - if ($formatInfo !== null) { - return $formatInfo; - } - - // Should return null, but, some QR codes apparently do not mask this - // info. Try again by actually masking the pattern first. - return self::doDecodeFormatInformation( - $maskedFormatInfo1 ^ self::FORMAT_INFO_MASK_QR, - $maskedFormatInfo2 ^ self::FORMAT_INFO_MASK_QR - ); - } - - /** - * Internal method for decoding format information. - * - * @param integer $maskedFormatInfo1 - * @param integer $maskedFormatInfo2 - * @return FormatInformation|null - */ - protected static function doDecodeFormatInformation($maskedFormatInfo1, $maskedFormatInfo2) - { - $bestDifference = PHP_INT_MAX; - $bestFormatInfo = 0; - - foreach (self::$formatInfoDecodeLookup as $decodeInfo) { - $targetInfo = $decodeInfo[0]; - - if ($targetInfo === $maskedFormatInfo1 || $targetInfo === $maskedFormatInfo2) { - // Found an exact match - return new self($decodeInfo[1]); - } - - $bitsDifference = self::numBitsDiffering($maskedFormatInfo1, $targetInfo); - - if ($bitsDifference < $bestDifference) { - $bestFormatInfo = $decodeInfo[1]; - $bestDifference = $bitsDifference; - } - - if ($maskedFormatInfo1 !== $maskedFormatInfo2) { - // Also try the other option - $bitsDifference = self::numBitsDiffering($maskedFormatInfo2, $targetInfo); - - if ($bitsDifference < $bestDifference) { - $bestFormatInfo = $decodeInfo[1]; - $bestDifference = $bitsDifference; - } - } - } - - // Hamming distance of the 32 masked codes is 7, by construction, so - // <= 3 bits differing means we found a match. - if ($bestDifference <= 3) { - return new self($bestFormatInfo); - } - - return null; - } - - /** - * Gets the error correction level. - * - * @return ErrorCorrectionLevel - */ - public function getErrorCorrectionLevel() - { - return $this->ecLevel; - } - - /** - * Gets the data mask. - * - * @return integer - */ - public function getDataMask() - { - return $this->dataMask; - } - - /** - * Hashes the code of the EC level. - * - * @return integer - */ - public function hashCode() - { - return ($this->ecLevel->get() << 3) | $this->dataMask; - } - - /** - * Verifies if this instance equals another one. - * - * @param mixed $other - * @return boolean - */ - public function equals($other) { - if (!$other instanceof self) { - return false; - } - - return ( - $this->ecLevel->get() === $other->getErrorCorrectionLevel()->get() - && $this->dataMask === $other->getDataMask() - ); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/Mode.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/Mode.php deleted file mode 100644 index 8faf344e..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/Mode.php +++ /dev/null @@ -1,70 +0,0 @@ - array(0, 0, 0), - self::NUMERIC => array(10, 12, 14), - self::ALPHANUMERIC => array(9, 11, 13), - self::STRUCTURED_APPEND => array(0, 0, 0), - self::BYTE => array(8, 16, 16), - self::ECI => array(0, 0, 0), - self::KANJI => array(8, 10, 12), - self::FNC1_FIRST_POSITION => array(0, 0, 0), - self::FNC1_SECOND_POSITION => array(0, 0, 0), - self::HANZI => array(8, 10, 12), - ); - - /** - * Gets the number of bits used in a specific QR code version. - * - * @param Version $version - * @return integer - */ - public function getCharacterCountBits(Version $version) - { - $number = $version->getVersionNumber(); - - if ($number <= 9) { - $offset = 0; - } elseif ($number <= 26) { - $offset = 1; - } else { - $offset = 2; - } - - return self::$characterCountBitsForVersions[$this->value][$offset]; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/ReedSolomonCodec.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/ReedSolomonCodec.php deleted file mode 100644 index e8d45b94..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/ReedSolomonCodec.php +++ /dev/null @@ -1,476 +0,0 @@ - 8) { - throw new Exception\InvalidArgumentException('Symbol size must be between 0 and 8'); - } - - if ($firstRoot < 0 || $firstRoot >= (1 << $symbolSize)) { - throw new Exception\InvalidArgumentException('First root must be between 0 and ' . (1 << $symbolSize)); - } - - if ($numRoots < 0 || $numRoots >= (1 << $symbolSize)) { - throw new Exception\InvalidArgumentException('Num roots must be between 0 and ' . (1 << $symbolSize)); - } - - if ($padding < 0 || $padding >= ((1 << $symbolSize) - 1 - $numRoots)) { - throw new Exception\InvalidArgumentException('Padding must be between 0 and ' . ((1 << $symbolSize) - 1 - $numRoots)); - } - - $this->symbolSize = $symbolSize; - $this->blockSize = (1 << $symbolSize) - 1; - $this->padding = $padding; - $this->alphaTo = SplFixedArray::fromArray(array_fill(0, $this->blockSize + 1, 0), false); - $this->indexOf = SplFixedArray::fromArray(array_fill(0, $this->blockSize + 1, 0), false); - - // Generate galous field lookup table - $this->indexOf[0] = $this->blockSize; - $this->alphaTo[$this->blockSize] = 0; - - $sr = 1; - - for ($i = 0; $i < $this->blockSize; $i++) { - $this->indexOf[$sr] = $i; - $this->alphaTo[$i] = $sr; - - $sr <<= 1; - - if ($sr & (1 << $symbolSize)) { - $sr ^= $gfPoly; - } - - $sr &= $this->blockSize; - } - - if ($sr !== 1) { - throw new Exception\RuntimeException('Field generator polynomial is not primitive'); - } - - // Form RS code generator polynomial from its roots - $this->generatorPoly = SplFixedArray::fromArray(array_fill(0, $numRoots + 1, 0), false); - $this->firstRoot = $firstRoot; - $this->primitive = $primitive; - $this->numRoots = $numRoots; - - // Find prim-th root of 1, used in decoding - for ($iPrimitive = 1; ($iPrimitive % $primitive) !== 0; $iPrimitive += $this->blockSize); - $this->iPrimitive = intval($iPrimitive / $primitive); - - $this->generatorPoly[0] = 1; - - for ($i = 0, $root = $firstRoot * $primitive; $i < $numRoots; $i++, $root += $primitive) { - $this->generatorPoly[$i + 1] = 1; - - for ($j = $i; $j > 0; $j--) { - if ($this->generatorPoly[$j] !== 0) { - $this->generatorPoly[$j] = $this->generatorPoly[$j - 1] ^ $this->alphaTo[$this->modNn($this->indexOf[$this->generatorPoly[$j]] + $root)]; - } else { - $this->generatorPoly[$j] = $this->generatorPoly[$j - 1]; - } - } - - $this->generatorPoly[$j] = $this->alphaTo[$this->modNn($this->indexOf[$this->generatorPoly[0]] + $root)]; - } - - // Convert generator poly to index form for quicker encoding - for ($i = 0; $i <= $numRoots; $i++) { - $this->generatorPoly[$i] = $this->indexOf[$this->generatorPoly[$i]]; - } - } - - /** - * Encodes data and writes result back into parity array. - * - * @param SplFixedArray $data - * @param SplFixedArray $parity - * @return void - */ - public function encode(SplFixedArray $data, SplFixedArray $parity) - { - for ($i = 0; $i < $this->numRoots; $i++) { - $parity[$i] = 0; - } - - $iterations = $this->blockSize - $this->numRoots - $this->padding; - - for ($i = 0; $i < $iterations; $i++) { - $feedback = $this->indexOf[$data[$i] ^ $parity[0]]; - - if ($feedback !== $this->blockSize) { - // Feedback term is non-zero - $feedback = $this->modNn($this->blockSize - $this->generatorPoly[$this->numRoots] + $feedback); - - for ($j = 1; $j < $this->numRoots; $j++) { - $parity[$j] = $parity[$j] ^ $this->alphaTo[$this->modNn($feedback + $this->generatorPoly[$this->numRoots - $j])]; - } - } - - for ($j = 0; $j < $this->numRoots - 1; $j++) { - $parity[$j] = $parity[$j + 1]; - } - - if ($feedback !== $this->blockSize) { - $parity[$this->numRoots - 1] = $this->alphaTo[$this->modNn($feedback + $this->generatorPoly[0])]; - } else { - $parity[$this->numRoots - 1] = 0; - } - } - } - - /** - * Decodes received data. - * - * @param SplFixedArray $data - * @param SplFixedArray|null $erasures - * @return null|integer - */ - public function decode(SplFixedArray $data, SplFixedArray $erasures = null) - { - // This speeds up the initialization a bit. - $numRootsPlusOne = SplFixedArray::fromArray(array_fill(0, $this->numRoots + 1, 0), false); - $numRoots = SplFixedArray::fromArray(array_fill(0, $this->numRoots, 0), false); - - $lambda = clone $numRootsPlusOne; - $b = clone $numRootsPlusOne; - $t = clone $numRootsPlusOne; - $omega = clone $numRootsPlusOne; - $root = clone $numRoots; - $loc = clone $numRoots; - - $numErasures = ($erasures !== null ? count($erasures) : 0); - - // Form the Syndromes; i.e., evaluate data(x) at roots of g(x) - $syndromes = SplFixedArray::fromArray(array_fill(0, $this->numRoots, $data[0]), false); - - for ($i = 1; $i < $this->blockSize - $this->padding; $i++) { - for ($j = 0; $j < $this->numRoots; $j++) { - if ($syndromes[$j] === 0) { - $syndromes[$j] = $data[$i]; - } else { - $syndromes[$j] = $data[$i] ^ $this->alphaTo[ - $this->modNn($this->indexOf[$syndromes[$j]] + ($this->firstRoot + $j) * $this->primitive) - ]; - } - } - } - - // Convert syndromes to index form, checking for nonzero conditions - $syndromeError = 0; - - for ($i = 0; $i < $this->numRoots; $i++) { - $syndromeError |= $syndromes[$i]; - $syndromes[$i] = $this->indexOf[$syndromes[$i]]; - } - - if (!$syndromeError) { - // If syndrome is zero, data[] is a codeword and there are no errors - // to correct, so return data[] unmodified. - return 0; - } - - $lambda[0] = 1; - - if ($numErasures > 0) { - // Init lambda to be the erasure locator polynomial - $lambda[1] = $this->alphaTo[$this->modNn($this->primitive * ($this->blockSize - 1 - $erasures[0]))]; - - for ($i = 1; $i < $numErasures; $i++) { - $u = $this->modNn($this->primitive * ($this->blockSize - 1 - $erasures[$i])); - - for ($j = $i + 1; $j > 0; $j--) { - $tmp = $this->indexOf[$lambda[$j - 1]]; - - if ($tmp !== $this->blockSize) { - $lambda[$j] = $lambda[$j] ^ $this->alphaTo[$this->modNn($u + $tmp)]; - } - } - } - } - - for ($i = 0; $i <= $this->numRoots; $i++) { - $b[$i] = $this->indexOf[$lambda[$i]]; - } - - // Begin Berlekamp-Massey algorithm to determine error+erasure locator - // polynomial - $r = $numErasures; - $el = $numErasures; - - while (++$r <= $this->numRoots) { - // Compute discrepancy at the r-th step in poly form - $discrepancyR = 0; - - for ($i = 0; $i < $r; $i++) { - if ($lambda[$i] !== 0 && $syndromes[$r - $i - 1] !== $this->blockSize) { - $discrepancyR ^= $this->alphaTo[$this->modNn($this->indexOf[$lambda[$i]] + $syndromes[$r - $i - 1])]; - } - } - - $discrepancyR = $this->indexOf[$discrepancyR]; - - if ($discrepancyR === $this->blockSize) { - $tmp = $b->toArray(); - array_unshift($tmp, $this->blockSize); - array_pop($tmp); - $b = SplFixedArray::fromArray($tmp, false); - } else { - $t[0] = $lambda[0]; - - for ($i = 0; $i < $this->numRoots; $i++) { - if ($b[$i] !== $this->blockSize) { - $t[$i + 1] = $lambda[$i + 1] ^ $this->alphaTo[$this->modNn($discrepancyR + $b[$i])]; - } else { - $t[$i + 1] = $lambda[$i + 1]; - } - } - - if (2 * $el <= $r + $numErasures - 1) { - $el = $r + $numErasures - $el; - - for ($i = 0; $i <= $this->numRoots; $i++) { - $b[$i] = ( - $lambda[$i] === 0 - ? $this->blockSize - : $this->modNn($this->indexOf[$lambda[$i]] - $discrepancyR + $this->blockSize) - ); - } - } else { - $tmp = $b->toArray(); - array_unshift($tmp, $this->blockSize); - array_pop($tmp); - $b = SplFixedArray::fromArray($tmp, false); - } - - $lambda = clone $t; - } - } - - // Convert lambda to index form and compute deg(lambda(x)) - $degLambda = 0; - - for ($i = 0; $i <= $this->numRoots; $i++) { - $lambda[$i] = $this->indexOf[$lambda[$i]]; - - if ($lambda[$i] !== $this->blockSize) { - $degLambda = $i; - } - } - - // Find roots of the error+erasure locator polynomial by Chien search. - $reg = clone $lambda; - $reg[0] = 0; - $count = 0; - - for ($i = 1, $k = $this->iPrimitive - 1; $i <= $this->blockSize; $i++, $k = $this->modNn($k + $this->iPrimitive)) { - $q = 1; - - for ($j = $degLambda; $j > 0; $j--) { - if ($reg[$j] !== $this->blockSize) { - $reg[$j] = $this->modNn($reg[$j] + $j); - $q ^= $this->alphaTo[$reg[$j]]; - } - } - - if ($q !== 0) { - // Not a root - continue; - } - - // Store root (index-form) and error location number - $root[$count] = $i; - $loc[$count] = $k; - - if (++$count === $degLambda) { - break; - } - } - - if ($degLambda !== $count) { - // deg(lambda) unequal to number of roots: uncorreactable error - // detected - return null; - } - - // Compute err+eras evaluate poly omega(x) = s(x)*lambda(x) (modulo - // x**numRoots). In index form. Also find deg(omega). - $degOmega = $degLambda - 1; - - for ($i = 0; $i <= $degOmega; $i++) { - $tmp = 0; - - for ($j = $i; $j >= 0; $j--) { - if ($syndromes[$i - $j] !== $this->blockSize && $lambda[$j] !== $this->blockSize) { - $tmp ^= $this->alphaTo[$this->modNn($syndromes[$i - $j] + $lambda[$j])]; - } - } - - $omega[$i] = $this->indexOf[$tmp]; - } - - // Compute error values in poly-form. num1 = omega(inv(X(l))), num2 = - // inv(X(l))**(firstRoot-1) and den = lambda_pr(inv(X(l))) all in poly - // form. - for ($j = $count - 1; $j >= 0; $j--) { - $num1 = 0; - - for ($i = $degOmega; $i >= 0; $i--) { - if ($omega[$i] !== $this->blockSize) { - $num1 ^= $this->alphaTo[$this->modNn($omega[$i] + $i * $root[$j])]; - } - } - - $num2 = $this->alphaTo[$this->modNn($root[$j] * ($this->firstRoot - 1) + $this->blockSize)]; - $den = 0; - - // lambda[i+1] for i even is the formal derivativelambda_pr of - // lambda[i] - for ($i = min($degLambda, $this->numRoots - 1) & ~1; $i >= 0; $i -= 2) { - if ($lambda[$i + 1] !== $this->blockSize) { - $den ^= $this->alphaTo[$this->modNn($lambda[$i + 1] + $i * $root[$j])]; - } - } - - // Apply error to data - if ($num1 !== 0 && $loc[$j] >= $this->padding) { - $data[$loc[$j] - $this->padding] = $data[$loc[$j] - $this->padding] ^ ( - $this->alphaTo[ - $this->modNn( - $this->indexOf[$num1] + $this->indexOf[$num2] + $this->blockSize - $this->indexOf[$den] - ) - ] - ); - } - } - - if ($erasures !== null) { - if (count($erasures) < $count) { - $erasures->setSize($count); - } - - for ($i = 0; $i < $count; $i++) { - $erasures[$i] = $loc[$i]; - } - } - - return $count; - } - - /** - * Computes $x % GF_SIZE, where GF_SIZE is 2**GF_BITS - 1, without a slow - * divide. - * - * @param itneger $x - * @return integer - */ - protected function modNn($x) - { - while ($x >= $this->blockSize) { - $x -= $this->blockSize; - $x = ($x >> $this->symbolSize) + ($x & $this->blockSize); - } - - return $x; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/Version.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/Version.php deleted file mode 100644 index d6986399..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Common/Version.php +++ /dev/null @@ -1,687 +0,0 @@ -versionNumber = $versionNumber; - $this->alignmentPatternCenters = $alignmentPatternCenters; - $this->errorCorrectionBlocks = $ecBlocks; - - $totalCodewords = 0; - $ecCodewords = $ecBlocks[0]->getEcCodewordsPerBlock(); - - foreach ($ecBlocks[0]->getEcBlocks() as $ecBlock) { - $totalCodewords += $ecBlock->getCount() * ($ecBlock->getDataCodewords() + $ecCodewords); - } - - $this->totalCodewords = $totalCodewords; - } - - /** - * Gets the version number. - * - * @return integer - */ - public function getVersionNumber() - { - return $this->versionNumber; - } - - /** - * Gets the alignment pattern centers. - * - * @return SplFixedArray - */ - public function getAlignmentPatternCenters() - { - return $this->alignmentPatternCenters; - } - - /** - * Gets the total number of codewords. - * - * @return integer - */ - public function getTotalCodewords() - { - return $this->totalCodewords; - } - - /** - * Gets the dimension for the current version. - * - * @return integer - */ - public function getDimensionForVersion() - { - return 17 + 4 * $this->versionNumber; - } - - /** - * Gets the number of EC blocks for a specific EC level. - * - * @param ErrorCorrectionLevel $ecLevel - * @return integer - */ - public function getEcBlocksForLevel(ErrorCorrectionLevel $ecLevel) - { - return $this->errorCorrectionBlocks[$ecLevel->getOrdinal()]; - } - - /** - * Gets a provisional version number for a specific dimension. - * - * @param integer $dimension - * @return Version - * @throws Exception\InvalidArgumentException - */ - public static function getProvisionalVersionForDimension($dimension) - { - if ($dimension % 4 !== 1) { - throw new Exception\InvalidArgumentException('Dimension is not 1 mod 4'); - } - - return self::getVersionForNumber(($dimension - 17) >> 2); - } - - /** - * Gets a version instance for a specific version number. - * - * @param integer $versionNumber - * @return Version - * @throws Exception\InvalidArgumentException - */ - public static function getVersionForNumber($versionNumber) - { - if ($versionNumber < 1 || $versionNumber > 40) { - throw new Exception\InvalidArgumentException('Version number must be between 1 and 40'); - } - - if (!isset(self::$versions[$versionNumber])) { - self::buildVersion($versionNumber); - } - - return self::$versions[$versionNumber - 1]; - } - - /** - * Decodes version information from an integer and returns the version. - * - * @param integer $versionBits - * @return Version|null - */ - public static function decodeVersionInformation($versionBits) - { - $bestDifference = PHP_INT_MAX; - $bestVersion = 0; - - foreach (self::$versionDecodeInfo as $i => $targetVersion) { - if ($targetVersion === $versionBits) { - return self::getVersionForNumber($i + 7); - } - - $bitsDifference = FormatInformation::numBitsDiffering($versionBits, $targetVersion); - - if ($bitsDifference < $bestDifference) { - $bestVersion = $i + 7; - $bestDifference = $bitsDifference; - } - } - - if ($bestDifference <= 3) { - return self::getVersionForNumber($bestVersion); - } - - return null; - } - - /** - * Builds the function pattern for the current version. - * - * @return BitMatrix - */ - public function buildFunctionPattern() - { - $dimension = $this->getDimensionForVersion(); - $bitMatrix = new BitMatrix($dimension); - - // Top left finder pattern + separator + format - $bitMatrix->setRegion(0, 0, 9, 9); - // Top right finder pattern + separator + format - $bitMatrix->setRegion($dimension - 8, 0, 8, 9); - // Bottom left finder pattern + separator + format - $bitMatrix->setRegion(0, $dimension - 8, 9, 8); - - // Alignment patterns - $max = count($this->alignmentPatternCenters); - - for ($x = 0; $x < $max; $x++) { - $i = $this->alignmentPatternCenters[$x] - 2; - - for ($y = 0; $y < $max; $y++) { - if (($x === 0 && ($y === 0 || $y === $max - 1)) || ($x === $max - 1 && $y === 0)) { - // No alignment patterns near the three finder paterns - continue; - } - - $bitMatrix->setRegion($this->alignmentPatternCenters[$y] - 2, $i, 5, 5); - } - } - - // Vertical timing pattern - $bitMatrix->setRegion(6, 9, 1, $dimension - 17); - // Horizontal timing pattern - $bitMatrix->setRegion(9, 6, $dimension - 17, 1); - - if ($this->versionNumber > 6) { - // Version info, top right - $bitMatrix->setRegion($dimension - 11, 0, 3, 6); - // Version info, bottom left - $bitMatrix->setRegion(0, $dimension - 11, 6, 3); - } - - return $bitMatrix; - } - - /** - * Returns a string representation for the version. - * - * @return string - */ - public function __toString() - { - return (string) $this->versionNumber; - } - - /** - * Build and cache a specific version. - * - * See ISO 18004:2006 6.5.1 Table 9. - * - * @param integer $versionNumber - * @return void - */ - protected static function buildVersion($versionNumber) - { - switch ($versionNumber) { - case 1: - $patterns = array(); - $ecBlocks = array( - new EcBlocks(7, new EcBlock(1, 19)), - new EcBlocks(10, new EcBlock(1, 16)), - new EcBlocks(13, new EcBlock(1, 13)), - new EcBlocks(17, new EcBlock(1, 9)), - ); - break; - - case 2: - $patterns = array(6, 18); - $ecBlocks = array( - new EcBlocks(10, new EcBlock(1, 34)), - new EcBlocks(16, new EcBlock(1, 28)), - new EcBlocks(22, new EcBlock(1, 22)), - new EcBlocks(28, new EcBlock(1, 16)), - ); - break; - - case 3: - $patterns = array(6, 22); - $ecBlocks = array( - new EcBlocks(15, new EcBlock(1, 55)), - new EcBlocks(26, new EcBlock(1, 44)), - new EcBlocks(18, new EcBlock(2, 17)), - new EcBlocks(22, new EcBlock(2, 13)), - ); - break; - - case 4: - $patterns = array(6, 26); - $ecBlocks = array( - new EcBlocks(20, new EcBlock(1, 80)), - new EcBlocks(18, new EcBlock(2, 32)), - new EcBlocks(26, new EcBlock(3, 24)), - new EcBlocks(16, new EcBlock(4, 9)), - ); - break; - - case 5: - $patterns = array(6, 30); - $ecBlocks = array( - new EcBlocks(26, new EcBlock(1, 108)), - new EcBlocks(24, new EcBlock(2, 43)), - new EcBlocks(18, new EcBlock(2, 15), new EcBlock(2, 16)), - new EcBlocks(22, new EcBlock(2, 11), new EcBlock(2, 12)), - ); - break; - - case 6: - $patterns = array(6, 34); - $ecBlocks = array( - new EcBlocks(18, new EcBlock(2, 68)), - new EcBlocks(16, new EcBlock(4, 27)), - new EcBlocks(24, new EcBlock(4, 19)), - new EcBlocks(28, new EcBlock(4, 15)), - ); - break; - - case 7: - $patterns = array(6, 22, 38); - $ecBlocks = array( - new EcBlocks(20, new EcBlock(2, 78)), - new EcBlocks(18, new EcBlock(4, 31)), - new EcBlocks(18, new EcBlock(2, 14), new EcBlock(4, 15)), - new EcBlocks(26, new EcBlock(4, 13), new EcBlock(1, 14)), - ); - break; - - case 8: - $patterns = array(6, 24, 42); - $ecBlocks = array( - new EcBlocks(24, new EcBlock(2, 97)), - new EcBlocks(22, new EcBlock(2, 38), new EcBlock(2, 39)), - new EcBlocks(22, new EcBlock(4, 18), new EcBlock(2, 19)), - new EcBlocks(26, new EcBlock(4, 14), new EcBlock(2, 15)), - ); - break; - - case 9: - $patterns = array(6, 26, 46); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(2, 116)), - new EcBlocks(22, new EcBlock(3, 36), new EcBlock(2, 37)), - new EcBlocks(20, new EcBlock(4, 16), new EcBlock(4, 17)), - new EcBlocks(24, new EcBlock(4, 12), new EcBlock(4, 13)), - ); - break; - - case 10: - $patterns = array(6, 28, 50); - $ecBlocks = array( - new EcBlocks(18, new EcBlock(2, 68), new EcBlock(2, 69)), - new EcBlocks(26, new EcBlock(4, 43), new EcBlock(1, 44)), - new EcBlocks(24, new EcBlock(6, 19), new EcBlock(2, 20)), - new EcBlocks(28, new EcBlock(6, 15), new EcBlock(2, 16)), - ); - break; - - case 11: - $patterns = array(6, 30, 54); - $ecBlocks = array( - new EcBlocks(20, new EcBlock(4, 81)), - new EcBlocks(30, new EcBlock(1, 50), new EcBlock(4, 51)), - new EcBlocks(28, new EcBlock(4, 22), new EcBlock(4, 23)), - new EcBlocks(24, new EcBlock(3, 12), new EcBlock(8, 13)), - ); - break; - - case 12: - $patterns = array(6, 32, 58); - $ecBlocks = array( - new EcBlocks(24, new EcBlock(2, 92), new EcBlock(2, 93)), - new EcBlocks(22, new EcBlock(6, 36), new EcBlock(2, 37)), - new EcBlocks(26, new EcBlock(4, 20), new EcBlock(6, 21)), - new EcBlocks(28, new EcBlock(7, 14), new EcBlock(4, 15)), - ); - break; - - case 13: - $patterns = array(6, 34, 62); - $ecBlocks = array( - new EcBlocks(26, new EcBlock(4, 107)), - new EcBlocks(22, new EcBlock(8, 37), new EcBlock(1, 38)), - new EcBlocks(24, new EcBlock(8, 20), new EcBlock(4, 21)), - new EcBlocks(22, new EcBlock(12, 11), new EcBlock(4, 12)), - ); - break; - - case 14: - $patterns = array(6, 26, 46, 66); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(3, 115), new EcBlock(1, 116)), - new EcBlocks(24, new EcBlock(4, 40), new EcBlock(5, 41)), - new EcBlocks(20, new EcBlock(11, 16), new EcBlock(5, 17)), - new EcBlocks(24, new EcBlock(11, 12), new EcBlock(5, 13)), - ); - break; - - case 15: - $patterns = array(6, 26, 48, 70); - $ecBlocks = array( - new EcBlocks(22, new EcBlock(5, 87), new EcBlock(1, 88)), - new EcBlocks(24, new EcBlock(5, 41), new EcBlock(5, 42)), - new EcBlocks(30, new EcBlock(5, 24), new EcBlock(7, 25)), - new EcBlocks(24, new EcBlock(11, 12), new EcBlock(7, 13)), - ); - break; - - case 16: - $patterns = array(6, 26, 50, 74); - $ecBlocks = array( - new EcBlocks(24, new EcBlock(5, 98), new EcBlock(1, 99)), - new EcBlocks(28, new EcBlock(7, 45), new EcBlock(3, 46)), - new EcBlocks(24, new EcBlock(15, 19), new EcBlock(2, 20)), - new EcBlocks(30, new EcBlock(3, 15), new EcBlock(13, 16)), - ); - break; - - case 17: - $patterns = array(6, 30, 54, 78); - $ecBlocks = array( - new EcBlocks(28, new EcBlock(1, 107), new EcBlock(5, 108)), - new EcBlocks(28, new EcBlock(10, 46), new EcBlock(1, 47)), - new EcBlocks(28, new EcBlock(1, 22), new EcBlock(15, 23)), - new EcBlocks(28, new EcBlock(2, 14), new EcBlock(17, 15)), - ); - break; - - case 18: - $patterns = array(6, 30, 56, 82); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(5, 120), new EcBlock(1, 121)), - new EcBlocks(26, new EcBlock(9, 43), new EcBlock(4, 44)), - new EcBlocks(28, new EcBlock(17, 22), new EcBlock(1, 23)), - new EcBlocks(28, new EcBlock(2, 14), new EcBlock(19, 15)), - ); - break; - - case 19: - $patterns = array(6, 30, 58, 86); - $ecBlocks = array( - new EcBlocks(28, new EcBlock(3, 113), new EcBlock(4, 114)), - new EcBlocks(26, new EcBlock(3, 44), new EcBlock(11, 45)), - new EcBlocks(26, new EcBlock(17, 21), new EcBlock(4, 22)), - new EcBlocks(26, new EcBlock(9, 13), new EcBlock(16, 14)), - ); - break; - - case 20: - $patterns = array(6, 34, 62, 90); - $ecBlocks = array( - new EcBlocks(28, new EcBlock(3, 107), new EcBlock(5, 108)), - new EcBlocks(26, new EcBlock(3, 41), new EcBlock(13, 42)), - new EcBlocks(30, new EcBlock(15, 24), new EcBlock(5, 25)), - new EcBlocks(28, new EcBlock(15, 15), new EcBlock(10, 16)), - ); - break; - - case 21: - $patterns = array(6, 28, 50, 72, 94); - $ecBlocks = array( - new EcBlocks(28, new EcBlock(4, 116), new EcBlock(4, 117)), - new EcBlocks(26, new EcBlock(17, 42)), - new EcBlocks(28, new EcBlock(17, 22), new EcBlock(6, 23)), - new EcBlocks(30, new EcBlock(19, 16), new EcBlock(6, 17)), - ); - break; - - case 22: - $patterns = array(6, 26, 50, 74, 98); - $ecBlocks = array( - new EcBlocks(28, new EcBlock(2, 111), new EcBlock(7, 112)), - new EcBlocks(28, new EcBlock(17, 46)), - new EcBlocks(30, new EcBlock(7, 24), new EcBlock(16, 25)), - new EcBlocks(24, new EcBlock(34, 13)), - ); - break; - - case 23: - $patterns = array(6, 30, 54, 78, 102); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(4, 121), new EcBlock(5, 122)), - new EcBlocks(28, new EcBlock(4, 47), new EcBlock(14, 48)), - new EcBlocks(30, new EcBlock(11, 24), new EcBlock(14, 25)), - new EcBlocks(30, new EcBlock(16, 15), new EcBlock(14, 16)), - ); - break; - - case 24: - $patterns = array(6, 28, 54, 80, 106); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(6, 117), new EcBlock(4, 118)), - new EcBlocks(28, new EcBlock(6, 45), new EcBlock(14, 46)), - new EcBlocks(30, new EcBlock(11, 24), new EcBlock(16, 25)), - new EcBlocks(30, new EcBlock(30, 16), new EcBlock(2, 17)), - ); - break; - - case 25: - $patterns = array(6, 32, 58, 84, 110); - $ecBlocks = array( - new EcBlocks(26, new EcBlock(8, 106), new EcBlock(4, 107)), - new EcBlocks(28, new EcBlock(8, 47), new EcBlock(13, 48)), - new EcBlocks(30, new EcBlock(7, 24), new EcBlock(22, 25)), - new EcBlocks(30, new EcBlock(22, 15), new EcBlock(13, 16)), - ); - break; - - case 26: - $patterns = array(6, 30, 58, 86, 114); - $ecBlocks = array( - new EcBlocks(28, new EcBlock(10, 114), new EcBlock(2, 115)), - new EcBlocks(28, new EcBlock(19, 46), new EcBlock(4, 47)), - new EcBlocks(28, new EcBlock(28, 22), new EcBlock(6, 23)), - new EcBlocks(30, new EcBlock(33, 16), new EcBlock(4, 17)), - ); - break; - - case 27: - $patterns = array(6, 34, 62, 90, 118); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(8, 122), new EcBlock(4, 123)), - new EcBlocks(28, new EcBlock(22, 45), new EcBlock(3, 46)), - new EcBlocks(30, new EcBlock(8, 23), new EcBlock(26, 24)), - new EcBlocks(30, new EcBlock(12, 15), new EcBlock(28, 16)), - ); - break; - - case 28: - $patterns = array(6, 26, 50, 74, 98, 122); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(3, 117), new EcBlock(10, 118)), - new EcBlocks(28, new EcBlock(3, 45), new EcBlock(23, 46)), - new EcBlocks(30, new EcBlock(4, 24), new EcBlock(31, 25)), - new EcBlocks(30, new EcBlock(11, 15), new EcBlock(31, 16)), - ); - break; - - case 29: - $patterns = array(6, 30, 54, 78, 102, 126); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(7, 116), new EcBlock(7, 117)), - new EcBlocks(28, new EcBlock(21, 45), new EcBlock(7, 46)), - new EcBlocks(30, new EcBlock(1, 23), new EcBlock(37, 24)), - new EcBlocks(30, new EcBlock(19, 15), new EcBlock(26, 16)), - ); - break; - - case 30: - $patterns = array(6, 26, 52, 78, 104, 130); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(5, 115), new EcBlock(10, 116)), - new EcBlocks(28, new EcBlock(19, 47), new EcBlock(10, 48)), - new EcBlocks(30, new EcBlock(15, 24), new EcBlock(25, 25)), - new EcBlocks(30, new EcBlock(23, 15), new EcBlock(25, 16)), - ); - break; - - case 31: - $patterns = array(6, 30, 56, 82, 108, 134); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(13, 115), new EcBlock(3, 116)), - new EcBlocks(28, new EcBlock(2, 46), new EcBlock(29, 47)), - new EcBlocks(30, new EcBlock(42, 24), new EcBlock(1, 25)), - new EcBlocks(30, new EcBlock(23, 15), new EcBlock(28, 16)), - ); - break; - - case 32: - $patterns = array(6, 34, 60, 86, 112, 138); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(17, 115)), - new EcBlocks(28, new EcBlock(10, 46), new EcBlock(23, 47)), - new EcBlocks(30, new EcBlock(10, 24), new EcBlock(35, 25)), - new EcBlocks(30, new EcBlock(19, 15), new EcBlock(35, 16)), - ); - break; - - case 33: - $patterns = array(6, 30, 58, 86, 114, 142); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(17, 115), new EcBlock(1, 116)), - new EcBlocks(28, new EcBlock(14, 46), new EcBlock(21, 47)), - new EcBlocks(30, new EcBlock(29, 24), new EcBlock(19, 25)), - new EcBlocks(30, new EcBlock(11, 15), new EcBlock(46, 16)), - ); - break; - - case 34: - $patterns = array(6, 34, 62, 90, 118, 146); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(13, 115), new EcBlock(6, 116)), - new EcBlocks(28, new EcBlock(14, 46), new EcBlock(23, 47)), - new EcBlocks(30, new EcBlock(44, 24), new EcBlock(7, 25)), - new EcBlocks(30, new EcBlock(59, 16), new EcBlock(1, 17)), - ); - break; - - case 35: - $patterns = array(6, 30, 54, 78, 102, 126, 150); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(12, 121), new EcBlock(7, 122)), - new EcBlocks(28, new EcBlock(12, 47), new EcBlock(26, 48)), - new EcBlocks(30, new EcBlock(39, 24), new EcBlock(14, 25)), - new EcBlocks(30, new EcBlock(22, 15), new EcBlock(41, 16)), - ); - break; - - case 36: - $patterns = array(6, 24, 50, 76, 102, 128, 154); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(6, 121), new EcBlock(14, 122)), - new EcBlocks(28, new EcBlock(6, 47), new EcBlock(34, 48)), - new EcBlocks(30, new EcBlock(46, 24), new EcBlock(10, 25)), - new EcBlocks(30, new EcBlock(2, 15), new EcBlock(64, 16)), - ); - break; - - case 37: - $patterns = array(6, 28, 54, 80, 106, 132, 158); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(17, 122), new EcBlock(4, 123)), - new EcBlocks(28, new EcBlock(29, 46), new EcBlock(14, 47)), - new EcBlocks(30, new EcBlock(49, 24), new EcBlock(10, 25)), - new EcBlocks(30, new EcBlock(24, 15), new EcBlock(46, 16)), - ); - break; - - case 38: - $patterns = array(6, 32, 58, 84, 110, 136, 162); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(4, 122), new EcBlock(18, 123)), - new EcBlocks(28, new EcBlock(13, 46), new EcBlock(32, 47)), - new EcBlocks(30, new EcBlock(48, 24), new EcBlock(14, 25)), - new EcBlocks(30, new EcBlock(42, 15), new EcBlock(32, 16)), - ); - break; - - case 39: - $patterns = array(6, 26, 54, 82, 110, 138, 166); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(20, 117), new EcBlock(4, 118)), - new EcBlocks(28, new EcBlock(40, 47), new EcBlock(7, 48)), - new EcBlocks(30, new EcBlock(43, 24), new EcBlock(22, 25)), - new EcBlocks(30, new EcBlock(10, 15), new EcBlock(67, 16)), - ); - break; - - case 40: - $patterns = array(6, 30, 58, 86, 114, 142, 170); - $ecBlocks = array( - new EcBlocks(30, new EcBlock(19, 118), new EcBlock(6, 119)), - new EcBlocks(28, new EcBlock(18, 47), new EcBlock(31, 48)), - new EcBlocks(30, new EcBlock(34, 24), new EcBlock(34, 25)), - new EcBlocks(30, new EcBlock(20, 15), new EcBlock(61, 16)), - ); - break; - } - - self::$versions[$versionNumber - 1] = new self( - $versionNumber, - SplFixedArray::fromArray($patterns, false), - SplFixedArray::fromArray($ecBlocks, false) - ); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/BlockPair.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/BlockPair.php deleted file mode 100644 index 090db297..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/BlockPair.php +++ /dev/null @@ -1,64 +0,0 @@ -dataBytes = $data; - $this->errorCorrectionBytes = $errorCorrection; - } - - /** - * Gets the data bytes. - * - * @return SplFixedArray - */ - public function getDataBytes() - { - return $this->dataBytes; - } - - /** - * Gets the error correction bytes. - * - * @return SplFixedArray - */ - public function getErrorCorrectionBytes() - { - return $this->errorCorrectionBytes; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/ByteMatrix.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/ByteMatrix.php deleted file mode 100644 index a378f083..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/ByteMatrix.php +++ /dev/null @@ -1,158 +0,0 @@ -height = $height; - $this->width = $width; - $this->bytes = new SplFixedArray($height); - - for ($y = 0; $y < $height; $y++) { - $this->bytes[$y] = new SplFixedArray($width); - } - } - - /** - * Gets the width of the matrix. - * - * @return integer - */ - public function getWidth() - { - return $this->width; - } - - /** - * Gets the height of the matrix. - * - * @return integer - */ - public function getHeight() - { - return $this->height; - } - - /** - * Gets the internal representation of the matrix. - * - * @return SplFixedArray - */ - public function getArray() - { - return $this->bytes; - } - - /** - * Gets the byte for a specific position. - * - * @param integer $x - * @param integer $y - * @return integer - */ - public function get($x, $y) - { - return $this->bytes[$y][$x]; - } - - /** - * Sets the byte for a specific position. - * - * @param integer $x - * @param integer $y - * @param integer $value - * @return void - */ - public function set($x, $y, $value) - { - $this->bytes[$y][$x] = (int) $value; - } - - /** - * Clears the matrix with a specific value. - * - * @param integer $value - * @return void - */ - public function clear($value) - { - for ($y = 0; $y < $this->height; $y++) { - for ($x = 0; $x < $this->width; $x++) { - $this->bytes[$y][$x] = $value; - } - } - } - - /** - * Returns a string representation of the matrix. - * - * @return string - */ - public function __toString() - { - $result = ''; - - for ($y = 0; $y < $this->height; $y++) { - for ($x = 0; $x < $this->width; $x++) { - switch ($this->bytes[$y][$x]) { - case 0: - $result .= ' 0'; - break; - - case 1: - $result .= ' 1'; - break; - - default: - $result .= ' '; - break; - } - } - - $result .= "\n"; - } - - return $result; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/Encoder.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/Encoder.php deleted file mode 100644 index c8efc35d..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/Encoder.php +++ /dev/null @@ -1,687 +0,0 @@ -get() === Mode::BYTE && $encoding !== self::DEFAULT_BYTE_MODE_ECODING) { - $eci = CharacterSetEci::getCharacterSetEciByName($encoding); - - if ($eci !== null) { - self::appendEci($eci, $headerBits); - } - } - - // (With ECI in place,) Write the mode marker - self::appendModeInfo($mode, $headerBits); - - // Collect data within the main segment, separately, to count its size - // if needed. Don't add it to main payload yet. - $dataBits = new BitArray(); - self::appendBytes($content, $mode, $dataBits, $encoding); - - // Hard part: need to know version to know how many bits length takes. - // But need to know how many bits it takes to know version. First we - // take a guess at version by assuming version will be the minimum, 1: - $provisionalBitsNeeded = $headerBits->getSize() - + $mode->getCharacterCountBits(Version::getVersionForNumber(1)) - + $dataBits->getSize(); - $provisionalVersion = self::chooseVersion($provisionalBitsNeeded, $ecLevel); - - // Use that guess to calculate the right version. I am still not sure - // this works in 100% of cases. - $bitsNeeded = $headerBits->getSize() - + $mode->getCharacterCountBits($provisionalVersion) - + $dataBits->getSize(); - $version = self::chooseVersion($bitsNeeded, $ecLevel); - - $headerAndDataBits = new BitArray(); - $headerAndDataBits->appendBitArray($headerBits); - - // Find "length" of main segment and write it. - $numLetters = ($mode->get() === Mode::BYTE ? $dataBits->getSizeInBytes() : strlen($content)); - self::appendLengthInfo($numLetters, $version, $mode, $headerAndDataBits); - - // Put data together into the overall payload. - $headerAndDataBits->appendBitArray($dataBits); - $ecBlocks = $version->getEcBlocksForLevel($ecLevel); - $numDataBytes = $version->getTotalCodewords() - $ecBlocks->getTotalEcCodewords(); - - // Terminate the bits properly. - self::terminateBits($numDataBytes, $headerAndDataBits); - - // Interleave data bits with error correction code. - $finalBits = self::interleaveWithEcBytes( - $headerAndDataBits, - $version->getTotalCodewords(), - $numDataBytes, - $ecBlocks->getNumBlocks() - ); - - $qrCode = new QrCode(); - $qrCode->setErrorCorrectionLevel($ecLevel); - $qrCode->setMode($mode); - $qrCode->setVersion($version); - - // Choose the mask pattern and set to "qrCode". - $dimension = $version->getDimensionForVersion(); - $matrix = new ByteMatrix($dimension, $dimension); - $maskPattern = self::chooseMaskPattern($finalBits, $ecLevel, $version, $matrix); - $qrCode->setMaskPattern($maskPattern); - - // Build the matrix and set it to "qrCode". - MatrixUtil::buildMatrix($finalBits, $ecLevel, $version, $maskPattern, $matrix); - $qrCode->setMatrix($matrix); - - return $qrCode; - } - - /** - * Gets the alphanumeric code for a byte. - * - * @param string|integer $code - * @return integer - */ - protected static function getAlphanumericCode($code) - { - $code = (is_string($code) ? ord($code) : $code); - - if (isset(self::$alphanumericTable[$code])) { - return self::$alphanumericTable[$code]; - } - - return -1; - } - - /** - * Chooses the best mode for a given content. - * - * @param string $content - * @param string $encoding - * @return Mode - */ - protected static function chooseMode($content, $encoding = null) - { - if (strcasecmp($encoding, 'SHIFT-JIS') === 0) { - return self::isOnlyDoubleByteKanji($content) ? new Mode(Mode::KANJI) : new Mode(Mode::BYTE); - } - - $hasNumeric = false; - $hasAlphanumeric = false; - $contentLength = strlen($content); - - for ($i = 0; $i < $contentLength; $i++) { - $char = $content[$i]; - - if (ctype_digit($char)) { - $hasNumeric = true; - } elseif (self::getAlphanumericCode($char) !== -1) { - $hasAlphanumeric = true; - } else { - return new Mode(Mode::BYTE); - } - } - - if ($hasAlphanumeric) { - return new Mode(Mode::ALPHANUMERIC); - } elseif ($hasNumeric) { - return new Mode(Mode::NUMERIC); - } - - return new Mode(Mode::BYTE); - } - - /** - * Calculates the mask penalty for a matrix. - * - * @param ByteMatrix $matrix - * @return integer - */ - protected static function calculateMaskPenalty(ByteMatrix $matrix) - { - return ( - MaskUtil::applyMaskPenaltyRule1($matrix) - + MaskUtil::applyMaskPenaltyRule2($matrix) - + MaskUtil::applyMaskPenaltyRule3($matrix) - + MaskUtil::applyMaskPenaltyRule4($matrix) - ); - } - - /** - * Chooses the best mask pattern for a matrix. - * - * @param BitArray $bits - * @param ErrorCorrectionLevel $ecLevel - * @param Version $version - * @param ByteMatrix $matrix - * @return integer - */ - protected static function chooseMaskPattern( - BitArray $bits, - ErrorCorrectionLevel $ecLevel, - Version $version, - ByteMatrix $matrix - ) { - $minPenality = PHP_INT_MAX; - $bestMaskPattern = -1; - - for ($maskPattern = 0; $maskPattern < QrCode::NUM_MASK_PATTERNS; $maskPattern++) { - MatrixUtil::buildMatrix($bits, $ecLevel, $version, $maskPattern, $matrix); - $penalty = self::calculateMaskPenalty($matrix); - - if ($penalty < $minPenality) { - $minPenality = $penalty; - $bestMaskPattern = $maskPattern; - } - } - - return $bestMaskPattern; - } - - /** - * Chooses the best version for the input. - * - * @param integer $numInputBits - * @param ErrorCorrectionLevel $ecLevel - * @return Version - * @throws Exception\WriterException - */ - protected static function chooseVersion($numInputBits, ErrorCorrectionLevel $ecLevel) - { - for ($versionNum = 1; $versionNum <= 40; $versionNum++) { - $version = Version::getVersionForNumber($versionNum); - $numBytes = $version->getTotalCodewords(); - - $ecBlocks = $version->getEcBlocksForLevel($ecLevel); - $numEcBytes = $ecBlocks->getTotalEcCodewords(); - - $numDataBytes = $numBytes - $numEcBytes; - $totalInputBytes = intval(($numInputBits + 8) / 8); - - if ($numDataBytes >= $totalInputBytes) { - return $version; - } - } - - throw new Exception\WriterException('Data too big'); - } - - /** - * Terminates the bits in a bit array. - * - * @param integer $numDataBytes - * @param BitArray $bits - * @throws Exception\WriterException - */ - protected static function terminateBits($numDataBytes, BitArray $bits) - { - $capacity = $numDataBytes << 3; - - if ($bits->getSize() > $capacity) { - throw new Exception\WriterException('Data bits cannot fit in the QR code'); - } - - for ($i = 0; $i < 4 && $bits->getSize() < $capacity; $i++) { - $bits->appendBit(false); - } - - $numBitsInLastByte = $bits->getSize() & 0x7; - - if ($numBitsInLastByte > 0) { - for ($i = $numBitsInLastByte; $i < 8; $i++) { - $bits->appendBit(false); - } - } - - $numPaddingBytes = $numDataBytes - $bits->getSizeInBytes(); - - for ($i = 0; $i < $numPaddingBytes; $i++) { - $bits->appendBits(($i & 0x1) === 0 ? 0xec : 0x11, 8); - } - - if ($bits->getSize() !== $capacity) { - throw new Exception\WriterException('Bits size does not equal capacity'); - } - } - - /** - * Gets number of data- and EC bytes for a block ID. - * - * @param integer $numTotalBytes - * @param integer $numDataBytes - * @param integer $numRsBlocks - * @param integer $blockId - * @return array - * @throws Exception\WriterException - */ - protected static function getNumDataBytesAndNumEcBytesForBlockId( - $numTotalBytes, - $numDataBytes, - $numRsBlocks, - $blockId - ) { - if ($blockId >= $numRsBlocks) { - throw new Exception\WriterException('Block ID too large'); - } - - $numRsBlocksInGroup2 = $numTotalBytes % $numRsBlocks; - $numRsBlocksInGroup1 = $numRsBlocks - $numRsBlocksInGroup2; - $numTotalBytesInGroup1 = intval($numTotalBytes / $numRsBlocks); - $numTotalBytesInGroup2 = $numTotalBytesInGroup1 + 1; - $numDataBytesInGroup1 = intval($numDataBytes / $numRsBlocks); - $numDataBytesInGroup2 = $numDataBytesInGroup1 + 1; - $numEcBytesInGroup1 = $numTotalBytesInGroup1 - $numDataBytesInGroup1; - $numEcBytesInGroup2 = $numTotalBytesInGroup2 - $numDataBytesInGroup2; - - if ($numEcBytesInGroup1 !== $numEcBytesInGroup2) { - throw new Exception\WriterException('EC bytes mismatch'); - } - - if ($numRsBlocks !== $numRsBlocksInGroup1 + $numRsBlocksInGroup2) { - throw new Exception\WriterException('RS blocks mismatch'); - } - - if ($numTotalBytes !== - (($numDataBytesInGroup1 + $numEcBytesInGroup1) * $numRsBlocksInGroup1) - + (($numDataBytesInGroup2 + $numEcBytesInGroup2) * $numRsBlocksInGroup2) - ) { - throw new Exception\WriterException('Total bytes mismatch'); - } - - if ($blockId < $numRsBlocksInGroup1) { - return array($numDataBytesInGroup1, $numEcBytesInGroup1); - } else { - return array($numDataBytesInGroup2, $numEcBytesInGroup2); - } - } - - /** - * Interleaves data with EC bytes. - * - * @param BitArray $bits - * @param integer $numTotalBytes - * @param integer $numDataBytes - * @param integer $numRsBlocks - * @return BitArray - * @throws Exception\WriterException - */ - protected static function interleaveWithEcBytes(BitArray $bits, $numTotalBytes, $numDataBytes, $numRsBlocks) - { - if ($bits->getSizeInBytes() !== $numDataBytes) { - throw new Exception\WriterException('Number of bits and data bytes does not match'); - } - - $dataBytesOffset = 0; - $maxNumDataBytes = 0; - $maxNumEcBytes = 0; - - $blocks = new SplFixedArray($numRsBlocks); - - for ($i = 0; $i < $numRsBlocks; $i++) { - list($numDataBytesInBlock, $numEcBytesInBlock) = self::getNumDataBytesAndNumEcBytesForBlockId( - $numTotalBytes, - $numDataBytes, - $numRsBlocks, - $i - ); - - $size = $numDataBytesInBlock; - $dataBytes = $bits->toBytes(8 * $dataBytesOffset, $size); - $ecBytes = self::generateEcBytes($dataBytes, $numEcBytesInBlock); - $blocks[$i] = new BlockPair($dataBytes, $ecBytes); - - $maxNumDataBytes = max($maxNumDataBytes, $size); - $maxNumEcBytes = max($maxNumEcBytes, count($ecBytes)); - $dataBytesOffset += $numDataBytesInBlock; - } - - if ($numDataBytes !== $dataBytesOffset) { - throw new Exception\WriterException('Data bytes does not match offset'); - } - - $result = new BitArray(); - - for ($i = 0; $i < $maxNumDataBytes; $i++) { - foreach ($blocks as $block) { - $dataBytes = $block->getDataBytes(); - - if ($i < count($dataBytes)) { - $result->appendBits($dataBytes[$i], 8); - } - } - } - - for ($i = 0; $i < $maxNumEcBytes; $i++) { - foreach ($blocks as $block) { - $ecBytes = $block->getErrorCorrectionBytes(); - - if ($i < count($ecBytes)) { - $result->appendBits($ecBytes[$i], 8); - } - } - } - - if ($numTotalBytes !== $result->getSizeInBytes()) { - throw new Exception\WriterException('Interleaving error: ' . $numTotalBytes . ' and ' . $result->getSizeInBytes() . ' differ'); - } - - return $result; - } - - /** - * Generates EC bytes for given data. - * - * @param SplFixedArray $dataBytes - * @param integer $numEcBytesInBlock - * @return SplFixedArray - */ - protected static function generateEcBytes(SplFixedArray $dataBytes, $numEcBytesInBlock) - { - $numDataBytes = count($dataBytes); - $toEncode = new SplFixedArray($numDataBytes + $numEcBytesInBlock); - - for ($i = 0; $i < $numDataBytes; $i++) { - $toEncode[$i] = $dataBytes[$i] & 0xff; - } - - $ecBytes = new SplFixedArray($numEcBytesInBlock); - $codec = self::getCodec($numDataBytes, $numEcBytesInBlock); - $codec->encode($toEncode, $ecBytes); - - return $ecBytes; - } - - /** - * Gets an RS codec and caches it. - * - * @param integer $numDataBytes - * @param integer $numEcBytesInBlock - * @return ReedSolomonCodec - */ - protected static function getCodec($numDataBytes, $numEcBytesInBlock) - { - $cacheId = $numDataBytes . '-' . $numEcBytesInBlock; - - if (!isset(self::$codecs[$cacheId])) { - self::$codecs[$cacheId] = new ReedSolomonCodec( - 8, - 0x11d, - 0, - 1, - $numEcBytesInBlock, - 255 - $numDataBytes - $numEcBytesInBlock - ); - } - - return self::$codecs[$cacheId]; - } - - /** - * Appends mode information to a bit array. - * - * @param Mode $mode - * @param BitArray $bits - * @return void - */ - protected static function appendModeInfo(Mode $mode, BitArray $bits) - { - $bits->appendBits($mode->get(), 4); - } - - /** - * Appends length information to a bit array. - * - * @param integer $numLetters - * @param Version $version - * @param Mode $mode - * @param BitArray $bits - * @return void - * @throws Exception\WriterException - */ - protected static function appendLengthInfo($numLetters, Version $version, Mode $mode, BitArray $bits) - { - $numBits = $mode->getCharacterCountBits($version); - - if ($numLetters >= (1 << $numBits)) { - throw new Exception\WriterException($numLetters . ' is bigger than ' . ((1 << $numBits) - 1)); - } - - $bits->appendBits($numLetters, $numBits); - } - - /** - * Appends bytes to a bit array in a specific mode. - * - * @param stirng $content - * @param Mode $mode - * @param BitArray $bits - * @param string $encoding - * @return void - * @throws Exception\WriterException - */ - protected static function appendBytes($content, Mode $mode, BitArray $bits, $encoding) - { - switch ($mode->get()) { - case Mode::NUMERIC: - self::appendNumericBytes($content, $bits); - break; - - case Mode::ALPHANUMERIC: - self::appendAlphanumericBytes($content, $bits); - break; - - case Mode::BYTE: - self::append8BitBytes($content, $bits, $encoding); - break; - - case Mode::KANJI: - self::appendKanjiBytes($content, $bits); - break; - - default: - throw new Exception\WriterException('Invalid mode: ' . $mode->get()); - } - } - - /** - * Appends numeric bytes to a bit array. - * - * @param string $content - * @param BitArray $bits - * @return void - */ - protected static function appendNumericBytes($content, BitArray $bits) - { - $length = strlen($content); - $i = 0; - - while ($i < $length) { - $num1 = (int) $content[$i]; - - if ($i + 2 < $length) { - // Encode three numeric letters in ten bits. - $num2 = (int) $content[$i + 1]; - $num3 = (int) $content[$i + 2]; - $bits->appendBits($num1 * 100 + $num2 * 10 + $num3, 10); - $i += 3; - } elseif ($i + 1 < $length) { - // Encode two numeric letters in seven bits. - $num2 = (int) $content[$i + 1]; - $bits->appendBits($num1 * 10 + $num2, 7); - $i += 2; - } else { - // Encode one numeric letter in four bits. - $bits->appendBits($num1, 4); - $i++; - } - } - } - - /** - * Appends alpha-numeric bytes to a bit array. - * - * @param string $content - * @param BitArray $bits - * @return void - */ - protected static function appendAlphanumericBytes($content, BitArray $bits) - { - $length = strlen($content); - $i = 0; - - while ($i < $length) { - if (-1 === ($code1 = self::getAlphanumericCode($content[$i]))) { - throw new Exception\WriterException('Invalid alphanumeric code'); - } - - if ($i + 1 < $length) { - if (-1 === ($code2 = self::getAlphanumericCode($content[$i + 1]))) { - throw new Exception\WriterException('Invalid alphanumeric code'); - } - - // Encode two alphanumeric letters in 11 bits. - $bits->appendBits($code1 * 45 + $code2, 11); - $i += 2; - } else { - // Encode one alphanumeric letter in six bits. - $bits->appendBits($code1, 6); - $i++; - } - } - } - - /** - * Appends regular 8-bit bytes to a bit array. - * - * @param string $content - * @param BitArray $bits - * @return void - */ - protected static function append8BitBytes($content, BitArray $bits, $encoding) - { - if (false === ($bytes = @iconv('utf-8', $encoding, $content))) { - throw new Exception\WriterException('Could not encode content to ' . $encoding); - } - - $length = strlen($bytes); - - for ($i = 0; $i < $length; $i++) { - $bits->appendBits(ord($bytes[$i]), 8); - } - } - - /** - * Appends KANJI bytes to a bit array. - * - * @param string $content - * @param BitArray $bits - * @return void - */ - protected static function appendKanjiBytes($content, BitArray $bits) - { - if (strlen($content) % 2 > 0) { - // We just do a simple length check here. The for loop will check - // individual characters. - throw new Exception\WriterException('Content does not seem to be encoded in SHIFT-JIS'); - } - - $length = strlen($content); - - for ($i = 0; $i < $length; $i += 2) { - $byte1 = ord($content[$i]) & 0xff; - $byte2 = ord($content[$i + 1]) & 0xff; - $code = ($byte1 << 8) | $byte2; - - if ($code >= 0x8140 && $code <= 0x9ffc) { - $subtracted = $code - 0x8140; - } elseif ($code >= 0xe040 && $code <= 0xebbf) { - $subtracted = $code - 0xc140; - } else { - throw new Exception\WriterException('Invalid byte sequence'); - } - - $encoded = (($subtracted >> 8) * 0xc0) + ($subtracted & 0xff); - - $bits->appendBits($encoded, 13); - } - } - - /** - * Appends ECI information to a bit array. - * - * @param CharacterSetEci $eci - * @param BitArray $bits - * @return void - */ - protected static function appendEci(CharacterSetEci $eci, BitArray $bits) - { - $mode = new Mode(Mode::ECI); - $bits->appendBits($mode->get(), 4); - $bits->appendBits($eci->get(), 8); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/MaskUtil.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/MaskUtil.php deleted file mode 100644 index c294d557..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/MaskUtil.php +++ /dev/null @@ -1,291 +0,0 @@ -getArray(); - $width = $matrix->getWidth(); - $height = $matrix->getHeight(); - - for ($y = 0; $y < $height - 1; $y++) { - for ($x = 0; $x < $width - 1; $x++) { - $value = $array[$y][$x]; - - if ($value === $array[$y][$x + 1] && $value === $array[$y + 1][$x] && $value === $array[$y + 1][$x + 1]) { - $penalty++; - } - } - } - - return self::N2 * $penalty; - } - - /** - * Applies mask penalty rule 3 and returns the penalty. - * - * Finds consecutive cells of 00001011101 or 10111010000, and gives penalty - * to them. If we find patterns like 000010111010000, we give penalties - * twice (i.e. 40 * 2). - * - * @param ByteMatrix $matrix - * @return integer - */ - public static function applyMaskPenaltyRule3(ByteMatrix $matrix) - { - $penalty = 0; - $array = $matrix->getArray(); - $width = $matrix->getWidth(); - $height = $matrix->getHeight(); - - for ($y = 0; $y < $height; $y++) { - for ($x = 0; $x < $width; $x++) { - if ( - $x + 6 < $width - && $array[$y][$x] === 1 - && $array[$y][$x + 1] === 0 - && $array[$y][$x + 2] === 1 - && $array[$y][$x + 3] === 1 - && $array[$y][$x + 4] === 1 - && $array[$y][$x + 5] === 0 - && $array[$y][$x + 6] === 1 - && ( - ( - $x + 10 < $width - && $array[$y][$x + 7] === 0 - && $array[$y][$x + 8] === 0 - && $array[$y][$x + 9] === 0 - && $array[$y][$x + 10] === 0 - ) - || ( - $x - 4 >= 0 - && $array[$y][$x - 1] === 0 - && $array[$y][$x - 2] === 0 - && $array[$y][$x - 3] === 0 - && $array[$y][$x - 4] === 0 - ) - ) - ) { - $penalty += self::N3; - } - - if ( - $y + 6 < $height - && $array[$y][$x] === 1 - && $array[$y + 1][$x] === 0 - && $array[$y + 2][$x] === 1 - && $array[$y + 3][$x] === 1 - && $array[$y + 4][$x] === 1 - && $array[$y + 5][$x] === 0 - && $array[$y + 6][$x] === 1 - && ( - ( - $y + 10 < $height - && $array[$y + 7][$x] === 0 - && $array[$y + 8][$x] === 0 - && $array[$y + 9][$x] === 0 - && $array[$y + 10][$x] === 0 - ) - || ( - $y - 4 >= 0 - && $array[$y - 1][$x] === 0 - && $array[$y - 2][$x] === 0 - && $array[$y - 3][$x] === 0 - && $array[$y - 4][$x] === 0 - ) - ) - ) { - $penalty += self::N3; - } - } - } - - return $penalty; - } - - /** - * Applies mask penalty rule 4 and returns the penalty. - * - * Calculates the ratio of dark cells and gives penalty if the ratio is far - * from 50%. It gives 10 penalty for 5% distance. - * - * @param ByteMatrix $matrix - * @return integer - */ - public static function applyMaskPenaltyRule4(ByteMatrix $matrix) - { - $numDarkCells = 0; - - $array = $matrix->getArray(); - $width = $matrix->getWidth(); - $height = $matrix->getHeight(); - - for ($y = 0; $y < $height; $y++) { - $arrayY = $array[$y]; - - for ($x = 0; $x < $width; $x++) { - if ($arrayY[$x] === 1) { - $numDarkCells++; - } - } - } - - $numTotalCells = $height * $width; - $darkRatio = $numDarkCells / $numTotalCells; - $fixedPercentVariances = (int) (abs($darkRatio - 0.5) * 20); - - return $fixedPercentVariances * self::N4; - } - - /** - * Returns the mask bit for "getMaskPattern" at "x" and "y". - * - * See 8.8 of JISX0510:2004 for mask pattern conditions. - * - * @param integer $maskPattern - * @param integer $x - * @param integer $y - * @return integer - * @throws Exception\InvalidArgumentException - */ - public static function getDataMaskBit($maskPattern, $x, $y) - { - switch ($maskPattern) { - case 0: - $intermediate = ($y + $x) & 0x1; - break; - - case 1: - $intermediate = $y & 0x1; - break; - - case 2: - $intermediate = $x % 3; - break; - - case 3: - $intermediate = ($y + $x) % 3; - break; - - case 4: - $intermediate = (BitUtils::unsignedRightShift($y, 1) + ($x / 3)) & 0x1; - break; - - case 5: - $temp = $y * $x; - $intermediate = ($temp & 0x1) + ($temp % 3); - break; - - case 6: - $temp = $y * $x; - $intermediate = (($temp & 0x1) + ($temp % 3)) & 0x1; - break; - - case 7: - $temp = $y * $x; - $intermediate = (($temp % 3) + (($y + $x) & 0x1)) & 0x1; - break; - - default: - throw new Exception\InvalidArgumentException('Invalid mask pattern: ' . $maskPattern); - } - - return $intermediate === 0; - } - - /** - * Helper function for applyMaskPenaltyRule1. - * - * We need this for doing this calculation in both vertical and horizontal - * orders respectively. - * - * @param ByteMatrix $matrix - * @param boolean $isHorizontal - * @return integer - */ - protected static function applyMaskPenaltyRule1Internal(ByteMatrix $matrix, $isHorizontal) - { - $penalty = 0; - $iLimit = $isHorizontal ? $matrix->getHeight() : $matrix->getWidth(); - $jLimit = $isHorizontal ? $matrix->getWidth() : $matrix->getHeight(); - $array = $matrix->getArray(); - - for ($i = 0; $i < $iLimit; $i++) { - $numSameBitCells = 0; - $prevBit = -1; - - for ($j = 0; $j < $jLimit; $j++) { - $bit = $isHorizontal ? $array[$i][$j] : $array[$j][$i]; - - if ($bit === $prevBit) { - $numSameBitCells++; - } else { - if ($numSameBitCells >= 5) { - $penalty += self::N1 + ($numSameBitCells - 5); - } - - $numSameBitCells = 1; - $prevBit = $bit; - } - } - - if ($numSameBitCells >= 5) { - $penalty += self::N1 + ($numSameBitCells - 5); - } - } - - return $penalty; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/MatrixUtil.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/MatrixUtil.php deleted file mode 100644 index 83273818..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/MatrixUtil.php +++ /dev/null @@ -1,580 +0,0 @@ -clear(-1); - } - - /** - * Builds a complete matrix. - * - * @param BitArray $dataBits - * @param ErrorCorrectionLevel $level - * @param Version $version - * @param integer $maskPattern - * @param ByteMatrix $matrix - * @return void - */ - public static function buildMatrix( - BitArray $dataBits, - ErrorCorrectionLevel $level, - Version $version, - $maskPattern, - ByteMatrix $matrix - ) { - self::clearMatrix($matrix); - self::embedBasicPatterns($version, $matrix); - self::embedTypeInfo($level, $maskPattern, $matrix); - self::maybeEmbedVersionInfo($version, $matrix); - self::embedDataBits($dataBits, $maskPattern, $matrix); - } - - /** - * Embeds type information into a matrix. - * - * @param ErrorCorrectionLevel $level - * @param integer $maskPattern - * @param ByteMatrix $matrix - * @return void - */ - protected static function embedTypeInfo(ErrorCorrectionLevel $level, $maskPattern, ByteMatrix $matrix) - { - $typeInfoBits = new BitArray(); - self::makeTypeInfoBits($level, $maskPattern, $typeInfoBits); - - $typeInfoBitsSize = $typeInfoBits->getSize(); - - for ($i = 0; $i < $typeInfoBitsSize; $i++) { - $bit = $typeInfoBits->get($typeInfoBitsSize - 1 - $i); - - $x1 = self::$typeInfoCoordinates[$i][0]; - $y1 = self::$typeInfoCoordinates[$i][1]; - - $matrix->set($x1, $y1, $bit); - - if ($i < 8) { - $x2 = $matrix->getWidth() - $i - 1; - $y2 = 8; - } else { - $x2 = 8; - $y2 = $matrix->getHeight() - 7 + ($i - 8); - } - - $matrix->set($x2, $y2, $bit); - } - } - - /** - * Generates type information bits and appends them to a bit array. - * - * @param ErrorCorrectionLevel $level - * @param integer $maskPattern - * @param BitArray $bits - * @return void - * @throws Exception\RuntimeException - */ - protected static function makeTypeInfoBits(ErrorCorrectionLevel $level, $maskPattern, BitArray $bits) - { - $typeInfo = ($level->get() << 3) | $maskPattern; - $bits->appendBits($typeInfo, 5); - - $bchCode = self::calculateBchCode($typeInfo, self::$typeInfoPoly); - $bits->appendBits($bchCode, 10); - - $maskBits = new BitArray(); - $maskBits->appendBits(self::$typeInfoMaskPattern, 15); - $bits->xorBits($maskBits); - - if ($bits->getSize() !== 15) { - throw new Exception\RuntimeException('Bit array resulted in invalid size: ' . $bits->getSize()); - } - } - - /** - * Embeds version information if required. - * - * @param Version $version - * @param ByteMatrix $matrix - * @return void - */ - protected static function maybeEmbedVersionInfo(Version $version, ByteMatrix $matrix) - { - if ($version->getVersionNumber() < 7) { - return; - } - - $versionInfoBits = new BitArray(); - self::makeVersionInfoBits($version, $versionInfoBits); - - $bitIndex = 6 * 3 - 1; - - for ($i = 0; $i < 6; $i++) { - for ($j = 0; $j < 3; $j++) { - $bit = $versionInfoBits->get($bitIndex); - $bitIndex--; - - $matrix->set($i, $matrix->getHeight() - 11 + $j, $bit); - $matrix->set($matrix->getHeight() - 11 + $j, $i, $bit); - } - } - } - - /** - * Generates version information bits and appends them to a bit array. - * - * @param Version $version - * @param BitArray $bits - * @return void - * @throws Exception\RuntimeException - */ - protected static function makeVersionInfoBits(Version $version, BitArray $bits) - { - $bits->appendBits($version->getVersionNumber(), 6); - - $bchCode = self::calculateBchCode($version->getVersionNumber(), self::$versionInfoPoly); - $bits->appendBits($bchCode, 12); - - if ($bits->getSize() !== 18) { - throw new Exception\RuntimeException('Bit array resulted in invalid size: ' . $bits->getSize()); - } - } - - /** - * Calculates the BHC code for a value and a polynomial. - * - * @param integer $value - * @param integer $poly - * @return integer - */ - protected static function calculateBchCode($value, $poly) - { - $msbSetInPoly = self::findMsbSet($poly); - $value <<= $msbSetInPoly - 1; - - while (self::findMsbSet($value) >= $msbSetInPoly) { - $value ^= $poly << (self::findMsbSet($value) - $msbSetInPoly); - } - - return $value; - } - - /** - * Finds and MSB set. - * - * @param integer $value - * @return integer - */ - protected static function findMsbSet($value) - { - $numDigits = 0; - - while ($value !== 0) { - $value >>= 1; - $numDigits++; - } - - return $numDigits; - } - - /** - * Embeds basic patterns into a matrix. - * - * @param Version $version - * @param ByteMatrix $matrix - * @return void - */ - protected static function embedBasicPatterns(Version $version, ByteMatrix $matrix) - { - self::embedPositionDetectionPatternsAndSeparators($matrix); - self::embedDarkDotAtLeftBottomCorner($matrix); - self::maybeEmbedPositionAdjustmentPatterns($version, $matrix); - self::embedTimingPatterns($matrix); - } - - /** - * Embeds position detection patterns and separators into a byte matrix. - * - * @param ByteMatrix $matrix - * @return void - */ - protected static function embedPositionDetectionPatternsAndSeparators(ByteMatrix $matrix) - { - $pdpWidth = count(self::$positionDetectionPattern[0]); - - self::embedPositionDetectionPattern(0, 0, $matrix); - self::embedPositionDetectionPattern($matrix->getWidth() - $pdpWidth, 0, $matrix); - self::embedPositionDetectionPattern(0, $matrix->getWidth() - $pdpWidth, $matrix); - - $hspWidth = 8; - - self::embedHorizontalSeparationPattern(0, $hspWidth - 1, $matrix); - self::embedHorizontalSeparationPattern($matrix->getWidth() - $hspWidth, $hspWidth - 1, $matrix); - self::embedHorizontalSeparationPattern(0, $matrix->getWidth() - $hspWidth, $matrix); - - $vspSize = 7; - - self::embedVerticalSeparationPattern($vspSize, 0, $matrix); - self::embedVerticalSeparationPattern($matrix->getHeight() - $vspSize - 1, 0, $matrix); - self::embedVerticalSeparationPattern($vspSize, $matrix->getHeight() - $vspSize, $matrix); - } - - /** - * Embeds a single position detection pattern into a byte matrix. - * - * @param integer $xStart - * @param integer $yStart - * @param ByteMatrix $matrix - * @return void - */ - protected static function embedPositionDetectionPattern($xStart, $yStart, ByteMatrix $matrix) - { - for ($y = 0; $y < 7; $y++) { - for ($x = 0; $x < 7; $x++) { - $matrix->set($xStart + $x, $yStart + $y, self::$positionDetectionPattern[$y][$x]); - } - } - } - - /** - * Embeds a single horizontal separation pattern. - * - * @param integer $xStart - * @param integer $yStart - * @param ByteMatrix $matrix - * @return void - * @throws Exception\RuntimeException - */ - protected static function embedHorizontalSeparationPattern($xStart, $yStart, ByteMatrix $matrix) - { - for ($x = 0; $x < 8; $x++) { - if ($matrix->get($xStart + $x, $yStart) !== -1) { - throw new Exception\RuntimeException('Byte already set'); - } - - $matrix->set($xStart + $x, $yStart, 0); - } - } - - /** - * Embeds a single vertical separation pattern. - * - * @param integer $xStart - * @param integer $yStart - * @param ByteMatrix $matrix - * @return void - * @throws Exception\RuntimeException - */ - protected static function embedVerticalSeparationPattern($xStart, $yStart, ByteMatrix $matrix) - { - for ($y = 0; $y < 7; $y++) { - if ($matrix->get($xStart, $yStart + $y) !== -1) { - throw new Exception\RuntimeException('Byte already set'); - } - - $matrix->set($xStart, $yStart + $y, 0); - } - } - - /** - * Embeds a dot at the left bottom corner. - * - * @param ByteMatrix $matrix - * @return void - * @throws Exception\RuntimeException - */ - protected static function embedDarkDotAtLeftBottomCorner(ByteMatrix $matrix) - { - if ($matrix->get(8, $matrix->getHeight() - 8) === 0) { - throw new Exception\RuntimeException('Byte already set to 0'); - } - - $matrix->set(8, $matrix->getHeight() - 8, 1); - } - - /** - * Embeds position adjustment patterns if required. - * - * @param Version $version - * @param ByteMatrix $matrix - * @return void - */ - protected static function maybeEmbedPositionAdjustmentPatterns(Version $version, ByteMatrix $matrix) - { - if ($version->getVersionNumber() < 2) { - return; - } - - $index = $version->getVersionNumber() - 1; - - $coordinates = self::$positionAdjustmentPatternCoordinateTable[$index]; - $numCoordinates = count($coordinates); - - for ($i = 0; $i < $numCoordinates; $i++) { - for ($j = 0; $j < $numCoordinates; $j++) { - $y = $coordinates[$i]; - $x = $coordinates[$j]; - - if ($x === null || $y === null) { - continue; - } - - if ($matrix->get($x, $y) === -1) { - self::embedPositionAdjustmentPattern($x - 2, $y - 2, $matrix); - } - } - } - } - - /** - * Embeds a single position adjustment pattern. - * - * @param integer $xStart - * @param intger $yStart - * @param ByteMatrix $matrix - * @return void - */ - protected static function embedPositionAdjustmentPattern($xStart, $yStart, ByteMatrix $matrix) - { - for ($y = 0; $y < 5; $y++) { - for ($x = 0; $x < 5; $x++) { - $matrix->set($xStart + $x, $yStart + $y, self::$positionAdjustmentPattern[$y][$x]); - } - } - } - - /** - * Embeds timing patterns into a matrix. - * - * @param ByteMatrix $matrix - * @return void - */ - protected static function embedTimingPatterns(ByteMatrix $matrix) - { - $matrixWidth = $matrix->getWidth(); - - for ($i = 8; $i < $matrixWidth - 8; $i++) { - $bit = ($i + 1) % 2; - - if ($matrix->get($i, 6) === -1) { - $matrix->set($i, 6, $bit); - } - - if ($matrix->get(6, $i) === -1) { - $matrix->set(6, $i, $bit); - } - } - } - - /** - * Embeds "dataBits" using "getMaskPattern". - * - * For debugging purposes, it skips masking process if "getMaskPattern" is - * -1. See 8.7 of JISX0510:2004 (p.38) for how to embed data bits. - * - * @param BitArray $dataBits - * @param integer $maskPattern - * @param ByteMatrix $matrix - * @return void - * @throws Exception\WriterException - */ - protected static function embedDataBits(BitArray $dataBits, $maskPattern, ByteMatrix $matrix) - { - $bitIndex = 0; - $direction = -1; - - // Start from the right bottom cell. - $x = $matrix->getWidth() - 1; - $y = $matrix->getHeight() - 1; - - while ($x > 0) { - // Skip vertical timing pattern. - if ($x === 6) { - $x--; - } - - while ($y >= 0 && $y < $matrix->getHeight()) { - for ($i = 0; $i < 2; $i++) { - $xx = $x - $i; - - // Skip the cell if it's not empty. - if ($matrix->get($xx, $y) !== -1) { - continue; - } - - if ($bitIndex < $dataBits->getSize()) { - $bit = $dataBits->get($bitIndex); - $bitIndex++; - } else { - // Padding bit. If there is no bit left, we'll fill the - // left cells with 0, as described in 8.4.9 of - // JISX0510:2004 (p. 24). - $bit = false; - } - - // Skip masking if maskPattern is -1. - if ($maskPattern !== -1 && MaskUtil::getDataMaskBit($maskPattern, $xx, $y)) { - $bit = !$bit; - } - - $matrix->set($xx, $y, $bit); - } - - $y += $direction; - } - - $direction = -$direction; - $y += $direction; - $x -= 2; - } - - // All bits should be consumed - if ($bitIndex !== $dataBits->getSize()) { - throw new Exception\WriterException('Not all bits consumed (' . $bitIndex . ' out of ' . $dataBits->getSize() .')'); - } - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/QrCode.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/QrCode.php deleted file mode 100644 index 07e1c385..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/QrCode.php +++ /dev/null @@ -1,201 +0,0 @@ -mode; - } - - /** - * Sets the mode. - * - * @param Mode $mode - * @return void - */ - public function setMode(Mode $mode) - { - $this->mode = $mode; - } - - /** - * Gets the EC level. - * - * @return ErrorCorrectionLevel - */ - public function getErrorCorrectionLevel() - { - return $this->errorCorrectionLevel; - } - - /** - * Sets the EC level. - * - * @param ErrorCorrectionLevel $errorCorrectionLevel - * @return void - */ - public function setErrorCorrectionLevel(ErrorCorrectionLevel $errorCorrectionLevel) - { - $this->errorCorrectionLevel = $errorCorrectionLevel; - } - - /** - * Gets the version. - * - * @return Version - */ - public function getVersion() - { - return $this->version; - } - - /** - * Sets the version. - * - * @param Version $version - * @return void - */ - public function setVersion(Version $version) - { - $this->version = $version; - } - - /** - * Gets the mask pattern. - * - * @return integer - */ - public function getMaskPattern() - { - return $this->maskPattern; - } - - /** - * Sets the mask pattern. - * - * @param integer $maskPattern - * @return void - */ - public function setMaskPattern($maskPattern) - { - $this->maskPattern = $maskPattern; - } - - /** - * Gets the matrix. - * - * @return ByteMatrix - */ - public function getMatrix() - { - return $this->matrix; - } - - /** - * Sets the matrix. - * - * @param ByteMatrix $matrix - * @return void - */ - public function setMatrix(ByteMatrix $matrix) - { - $this->matrix = $matrix; - } - - /** - * Validates whether a mask pattern is valid. - * - * @param integer $maskPattern - * @return boolean - */ - public static function isValidMaskPattern($maskPattern) - { - return $maskPattern > 0 && $maskPattern < self::NUM_MASK_PATTERNS; - } - - /** - * Returns a string representation of the QR code. - * - * @return string - */ - public function __toString() - { - $result = "<<\n" - . " mode: " . $this->mode . "\n" - . " ecLevel: " . $this->errorCorrectionLevel . "\n" - . " version: " . $this->version . "\n" - . " maskPattern: " . $this->maskPattern . "\n"; - - if ($this->matrix === null) { - $result .= " matrix: null\n"; - } else { - $result .= " matrix:\n"; - $result .= $this->matrix; - } - - $result .= ">>\n"; - - return $result; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Exception/ExceptionInterface.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Exception/ExceptionInterface.php deleted file mode 100644 index 5c58fc51..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Exception/ExceptionInterface.php +++ /dev/null @@ -1,14 +0,0 @@ - 100) { - throw new Exception\InvalidArgumentException('Cyan must be between 0 and 100'); - } - - if ($magenta < 0 || $magenta > 100) { - throw new Exception\InvalidArgumentException('Magenta must be between 0 and 100'); - } - - if ($yellow < 0 || $yellow > 100) { - throw new Exception\InvalidArgumentException('Yellow must be between 0 and 100'); - } - - if ($black < 0 || $black > 100) { - throw new Exception\InvalidArgumentException('Black must be between 0 and 100'); - } - - $this->cyan = (int) $cyan; - $this->magenta = (int) $magenta; - $this->yellow = (int) $yellow; - $this->black = (int) $black; - } - - /** - * Returns the cyan value. - * - * @return integer - */ - public function getCyan() - { - return $this->cyan; - } - - /** - * Returns the magenta value. - * - * @return integer - */ - public function getMagenta() - { - return $this->magenta; - } - - /** - * Returns the yellow value. - * - * @return integer - */ - public function getYellow() - { - return $this->yellow; - } - - /** - * Returns the black value. - * - * @return integer - */ - public function getBlack() - { - return $this->black; - } - - /** - * toRgb(): defined by ColorInterface. - * - * @see ColorInterface::toRgb() - * @return Rgb - */ - public function toRgb() - { - $k = $this->black / 100; - $c = (-$k * $this->cyan + $k * 100 + $this->cyan) / 100; - $m = (-$k * $this->magenta + $k * 100 + $this->magenta) / 100; - $y = (-$k * $this->yellow + $k * 100 + $this->yellow) / 100; - - return new Rgb( - -$c * 255 + 255, - -$m * 255 + 255, - -$y * 255 + 255 - ); - } - - /** - * toCmyk(): defined by ColorInterface. - * - * @see ColorInterface::toCmyk() - * @return Cmyk - */ - public function toCmyk() - { - return $this; - } - - /** - * toGray(): defined by ColorInterface. - * - * @see ColorInterface::toGray() - * @return Gray - */ - public function toGray() - { - return $this->toRgb()->toGray(); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Color/ColorInterface.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Color/ColorInterface.php deleted file mode 100644 index 747accc1..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Color/ColorInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - 100) { - throw new Exception\InvalidArgumentException('Gray must be between 0 and 100'); - } - - $this->gray = (int) $gray; - } - - /** - * Returns the gray value. - * - * @return integer - */ - public function getGray() - { - return $this->gray; - } - - /** - * toRgb(): defined by ColorInterface. - * - * @see ColorInterface::toRgb() - * @return Rgb - */ - public function toRgb() - { - return new Rgb($this->gray * 2.55, $this->gray * 2.55, $this->gray * 2.55); - } - - /** - * toCmyk(): defined by ColorInterface. - * - * @see ColorInterface::toCmyk() - * @return Cmyk - */ - public function toCmyk() - { - return new Cmyk(0, 0, 0, 100 - $this->gray); - } - - /** - * toGray(): defined by ColorInterface. - * - * @see ColorInterface::toGray() - * @return Gray - */ - public function toGray() - { - return $this; - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Color/Rgb.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Color/Rgb.php deleted file mode 100644 index 44e4060c..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Color/Rgb.php +++ /dev/null @@ -1,148 +0,0 @@ - 255) { - throw new Exception\InvalidArgumentException('Red must be between 0 and 255'); - } - - if ($green < 0 || $green > 255) { - throw new Exception\InvalidArgumentException('Green must be between 0 and 255'); - } - - if ($blue < 0 || $blue > 255) { - throw new Exception\InvalidArgumentException('Blue must be between 0 and 255'); - } - - $this->red = (int) $red; - $this->green = (int) $green; - $this->blue = (int) $blue; - } - - /** - * Returns the red value. - * - * @return integer - */ - public function getRed() - { - return $this->red; - } - - /** - * Returns the green value. - * - * @return integer - */ - public function getGreen() - { - return $this->green; - } - - /** - * Returns the blue value. - * - * @return integer - */ - public function getBlue() - { - return $this->blue; - } - - /** - * Returns a hexadecimal string representation of the RGB value. - * - * @return string - */ - public function __toString() - { - return sprintf('%02x%02x%02x', $this->red, $this->green, $this->blue); - } - - /** - * toRgb(): defined by ColorInterface. - * - * @see ColorInterface::toRgb() - * @return Rgb - */ - public function toRgb() - { - return $this; - } - - /** - * toCmyk(): defined by ColorInterface. - * - * @see ColorInterface::toCmyk() - * @return Cmyk - */ - public function toCmyk() - { - $c = 1 - ($this->red / 255); - $m = 1 - ($this->green / 255); - $y = 1 - ($this->blue / 255); - $k = min($c, $m, $y); - - return new Cmyk( - 100 * ($c - $k) / (1 - $k), - 100 * ($m - $k) / (1 - $k), - 100 * ($y - $k) / (1 - $k), - 100 * $k - ); - } - - /** - * toGray(): defined by ColorInterface. - * - * @see ColorInterface::toGray() - * @return Gray - */ - public function toGray() - { - return new Gray(($this->red * 0.21 + $this->green * 0.71 + $this->blue * 0.07) / 2.55); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/AbstractRenderer.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/AbstractRenderer.php deleted file mode 100644 index b0bb02ac..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/AbstractRenderer.php +++ /dev/null @@ -1,338 +0,0 @@ -margin = (int) $margin; - return $this; - } - - /** - * Gets the margin around the QR code. - * - * @return integer - */ - public function getMargin() - { - return $this->margin; - } - - /** - * Sets the height around the renderd image. - * - * If the width is smaller than the matrix width plus padding, the renderer - * will automatically use that as the width instead of the specified one. - * - * @param integer $width - * @return AbstractRenderer - */ - public function setWidth($width) - { - $this->width = (int) $width; - return $this; - } - - /** - * Gets the width of the rendered image. - * - * @return integer - */ - public function getWidth() - { - return $this->width; - } - - /** - * Sets the height around the renderd image. - * - * If the height is smaller than the matrix height plus padding, the - * renderer will automatically use that as the height instead of the - * specified one. - * - * @param integer $height - * @return AbstractRenderer - */ - public function setHeight($height) - { - $this->height = (int) $height; - return $this; - } - - /** - * Gets the height around the rendered image. - * - * @return integer - */ - public function getHeight() - { - return $this->height; - } - - /** - * Sets whether dimensions should be rounded down. - * - * @param boolean $flag - * @return AbstractRenderer - */ - public function setRoundDimensions($flag) - { - $this->floorToClosestDimension = $flag; - return $this; - } - - /** - * Gets whether dimensions should be rounded down. - * - * @return boolean - */ - public function shouldRoundDimensions() - { - return $this->floorToClosestDimension; - } - - /** - * Sets background color. - * - * @param Color\ColorInterface $color - * @return AbstractRenderer - */ - public function setBackgroundColor(Color\ColorInterface $color) - { - $this->backgroundColor = $color; - return $this; - } - - /** - * Gets background color. - * - * @return Color\ColorInterface - */ - public function getBackgroundColor() - { - if ($this->backgroundColor === null) { - $this->backgroundColor = new Color\Gray(100); - } - - return $this->backgroundColor; - } - - /** - * Sets foreground color. - * - * @param Color\ColorInterface $color - * @return AbstractRenderer - */ - public function setForegroundColor(Color\ColorInterface $color) - { - $this->foregroundColor = $color; - return $this; - } - - /** - * Gets foreground color. - * - * @return Color\ColorInterface - */ - public function getForegroundColor() - { - if ($this->foregroundColor === null) { - $this->foregroundColor = new Color\Gray(0); - } - - return $this->foregroundColor; - } - - /** - * Adds a decorator to the renderer. - * - * @param DecoratorInterface $decorator - * @return AbstractRenderer - */ - public function addDecorator(DecoratorInterface $decorator) - { - $this->decorators[] = $decorator; - return $this; - } - - /** - * render(): defined by RendererInterface. - * - * @see RendererInterface::render() - * @param QrCode $qrCode - * @return string - */ - public function render(QrCode $qrCode) - { - $input = $qrCode->getMatrix(); - $inputWidth = $input->getWidth(); - $inputHeight = $input->getHeight(); - $qrWidth = $inputWidth + ($this->getMargin() << 1); - $qrHeight = $inputHeight + ($this->getMargin() << 1); - $outputWidth = max($this->getWidth(), $qrWidth); - $outputHeight = max($this->getHeight(), $qrHeight); - $multiple = (int) min($outputWidth / $qrWidth, $outputHeight / $qrHeight); - - if ($this->shouldRoundDimensions()) { - $outputWidth -= $outputWidth % $multiple; - $outputHeight -= $outputHeight % $multiple; - } - - // Padding includes both the quiet zone and the extra white pixels to - // accommodate the requested dimensions. For example, if input is 25x25 - // the QR will be 33x33 including the quiet zone. If the requested size - // is 200x160, the multiple will be 4, for a QR of 132x132. These will - // handle all the padding from 100x100 (the actual QR) up to 200x160. - $leftPadding = (int) (($outputWidth - ($inputWidth * $multiple)) / 2); - $topPadding = (int) (($outputHeight - ($inputHeight * $multiple)) / 2); - - // Store calculated parameters - $this->finalWidth = $outputWidth; - $this->finalHeight = $outputHeight; - $this->blockSize = $multiple; - - $this->init(); - $this->addColor('background', $this->getBackgroundColor()); - $this->addColor('foreground', $this->getForegroundColor()); - $this->drawBackground('background'); - - foreach ($this->decorators as $decorator) { - $decorator->preProcess( - $qrCode, - $this, - $outputWidth, - $outputHeight, - $leftPadding, - $topPadding, - $multiple - ); - } - - for ($inputY = 0, $outputY = $topPadding; $inputY < $inputHeight; $inputY++, $outputY += $multiple) { - for ($inputX = 0, $outputX = $leftPadding; $inputX < $inputWidth; $inputX++, $outputX += $multiple) { - if ($input->get($inputX, $inputY) === 1) { - $this->drawBlock($outputX, $outputY, 'foreground'); - } - } - } - - foreach ($this->decorators as $decorator) { - $decorator->postProcess( - $qrCode, - $this, - $outputWidth, - $outputHeight, - $leftPadding, - $topPadding, - $multiple - ); - } - - return $this->getByteStream(); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Decorator/DecoratorInterface.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Decorator/DecoratorInterface.php deleted file mode 100644 index e67268b5..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Decorator/DecoratorInterface.php +++ /dev/null @@ -1,63 +0,0 @@ -outerColor = $color; - return $this; - } - - /** - * Gets outer color. - * - * @return Color\ColorInterface - */ - public function getOuterColor() - { - if ($this->outerColor === null) { - $this->outerColor = new Color\Gray(100); - } - - return $this->outerColor; - } - - /** - * Sets inner color. - * - * @param Color\ColorInterface $color - * @return FinderPattern - */ - public function setInnerColor(Color\ColorInterface $color) - { - $this->innerColor = $color; - return $this; - } - - /** - * Gets inner color. - * - * @return Color\ColorInterface - */ - public function getInnerColor() - { - if ($this->innerColor === null) { - $this->innerColor = new Color\Gray(0); - } - - return $this->innerColor; - } - - /** - * preProcess(): defined by DecoratorInterface. - * - * @see DecoratorInterface::preProcess() - * @param QrCode $qrCode - * @param RendererInterface $renderer - * @param integer $outputWidth - * @param integer $outputHeight - * @param integer $leftPadding - * @param integer $topPadding - * @param integer $multiple - * @return void - */ - public function preProcess( - QrCode $qrCode, - RendererInterface $renderer, - $outputWidth, - $outputHeight, - $leftPadding, - $topPadding, - $multiple - ) { - $matrix = $qrCode->getMatrix(); - $positions = array( - array(0, 0), - array($matrix->getWidth() - 7, 0), - array(0, $matrix->getHeight() - 7), - ); - - foreach (self::$outerPositionDetectionPattern as $y => $row) { - foreach ($row as $x => $isSet) { - foreach ($positions as $position) { - $matrix->set($x + $position[0], $y + $position[1], 0); - } - } - } - } - - /** - * postProcess(): defined by DecoratorInterface. - * - * @see DecoratorInterface::postProcess() - * - * @param QrCode $qrCode - * @param RendererInterface $renderer - * @param integer $outputWidth - * @param integer $outputHeight - * @param integer $leftPadding - * @param integer $topPadding - * @param integer $multiple - * @return void - */ - public function postProcess( - QrCode $qrCode, - RendererInterface $renderer, - $outputWidth, - $outputHeight, - $leftPadding, - $topPadding, - $multiple - ) { - $matrix = $qrCode->getMatrix(); - $positions = array( - array(0, 0), - array($matrix->getWidth() - 7, 0), - array(0, $matrix->getHeight() - 7), - ); - - $renderer->addColor('finder-outer', $this->getOuterColor()); - $renderer->addColor('finder-inner', $this->getInnerColor()); - - foreach (self::$outerPositionDetectionPattern as $y => $row) { - foreach ($row as $x => $isOuterSet) { - $isInnerSet = self::$innerPositionDetectionPattern[$y][$x]; - - if ($isOuterSet) { - foreach ($positions as $position) { - $renderer->drawBlock( - $leftPadding + $x * $multiple + $position[0] * $multiple, - $topPadding + $y * $multiple + $position[1] * $multiple, - 'finder-outer' - ); - } - } - - if ($isInnerSet) { - foreach ($positions as $position) { - $renderer->drawBlock( - $leftPadding + $x * $multiple + $position[0] * $multiple, - $topPadding + $y * $multiple + $position[1] * $multiple, - 'finder-inner' - ); - } - } - } - } - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Eps.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Eps.php deleted file mode 100644 index 97661951..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Eps.php +++ /dev/null @@ -1,152 +0,0 @@ -eps = "%!PS-Adobe-3.0 EPSF-3.0\n" - . "%%BoundingBox: 0 0 " . $this->finalWidth . " " . $this->finalHeight . "\n" - . "/F { rectfill } def\n"; - } - - /** - * addColor(): defined by RendererInterface. - * - * @see ImageRendererInterface::addColor() - * @param string $id - * @param ColorInterface $color - * @return void - */ - public function addColor($id, ColorInterface $color) - { - if ( - !$color instanceof Rgb - && !$color instanceof Cmyk - && !$color instanceof Gray - ) { - $color = $color->toCmyk(); - } - - $this->colors[$id] = $color; - } - - /** - * drawBackground(): defined by RendererInterface. - * - * @see ImageRendererInterface::drawBackground() - * @param string $colorId - * @return void - */ - public function drawBackground($colorId) - { - $this->setColor($colorId); - $this->eps .= "0 0 " . $this->finalWidth . " " . $this->finalHeight . " F\n"; - } - - /** - * drawBlock(): defined by RendererInterface. - * - * @see ImageRendererInterface::drawBlock() - * @param integer $x - * @param integer $y - * @param string $colorId - * @return void - */ - public function drawBlock($x, $y, $colorId) - { - $this->setColor($colorId); - $this->eps .= $x . " " . ($this->finalHeight - $y - $this->blockSize) . " " . $this->blockSize . " " . $this->blockSize . " F\n"; - } - - /** - * getByteStream(): defined by RendererInterface. - * - * @see ImageRendererInterface::getByteStream() - * @return string - */ - public function getByteStream() - { - return $this->eps; - } - - /** - * Sets color to use. - * - * @param string $colorId - * @return void - */ - protected function setColor($colorId) - { - if ($colorId !== $this->currentColor) { - $color = $this->colors[$colorId]; - - if ($color instanceof Rgb) { - $this->eps .= sprintf( - "%F %F %F setrgbcolor\n", - $color->getRed() / 100, - $color->getGreen() / 100, - $color->getBlue() / 100 - ); - } elseif ($color instanceof Cmyk) { - $this->eps .= sprintf( - "%F %F %F %F setcmykcolor\n", - $color->getCyan() / 100, - $color->getMagenta() / 100, - $color->getYellow() / 100, - $color->getBlack() / 100 - ); - } elseif ($color instanceof Gray) { - $this->eps .= sprintf( - "%F setgray\n", - $color->getGray() / 100 - ); - } - - $this->currentColor = $colorId; - } - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Png.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Png.php deleted file mode 100644 index dd593a8b..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Png.php +++ /dev/null @@ -1,115 +0,0 @@ -image = imagecreatetruecolor($this->finalWidth, $this->finalHeight); - } - - /** - * addColor(): defined by RendererInterface. - * - * @see ImageRendererInterface::addColor() - * @param string $id - * @param ColorInterface $color - * @return void - * @throws Exception\RuntimeException - */ - public function addColor($id, ColorInterface $color) - { - if ($this->image === null) { - throw new Exception\RuntimeException('Colors can only be added after init'); - } - - $color = $color->toRgb(); - - $this->colors[$id] = imagecolorallocate( - $this->image, - $color->getRed(), - $color->getGreen(), - $color->getBlue() - ); - } - - /** - * drawBackground(): defined by RendererInterface. - * - * @see ImageRendererInterface::drawBackground() - * @param string $colorId - * @return void - */ - public function drawBackground($colorId) - { - imagefill($this->image, 0, 0, $this->colors[$colorId]); - } - - /** - * drawBlock(): defined by RendererInterface. - * - * @see ImageRendererInterface::drawBlock() - * @param integer $x - * @param integer $y - * @param string $colorId - * @return void - */ - public function drawBlock($x, $y, $colorId) - { - imagefilledrectangle( - $this->image, - $x, - $y, - $x + $this->blockSize - 1, - $y + $this->blockSize - 1, - $this->colors[$colorId] - ); - } - - /** - * getByteStream(): defined by RendererInterface. - * - * @see ImageRendererInterface::getByteStream() - * @return string - */ - public function getByteStream() - { - ob_start(); - imagepng($this->image); - return ob_get_clean(); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/RendererInterface.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/RendererInterface.php deleted file mode 100644 index 52101a65..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/RendererInterface.php +++ /dev/null @@ -1,61 +0,0 @@ -svg = new SimpleXMLElement( - '' - . '' - ); - $this->svg->addAttribute('version', '1.1'); - $this->svg->addAttribute('width', $this->finalWidth . 'px'); - $this->svg->addAttribute('height', $this->finalHeight . 'px'); - $this->svg->addAttribute('viewBox', '0 0 ' . $this->finalWidth . ' ' . $this->finalHeight); - $this->svg->addChild('defs'); - } - - /** - * addColor(): defined by RendererInterface. - * - * @see ImageRendererInterface::addColor() - * @param string $id - * @param ColorInterface $color - * @return void - * @throws Exception\InvalidArgumentException - */ - public function addColor($id, ColorInterface $color) - { - $this->colors[$id] = (string) $color->toRgb(); - } - - /** - * drawBackground(): defined by RendererInterface. - * - * @see ImageRendererInterface::drawBackground() - * @param string $colorId - * @return void - */ - public function drawBackground($colorId) - { - $rect = $this->svg->addChild('rect'); - $rect->addAttribute('x', 0); - $rect->addAttribute('y', 0); - $rect->addAttribute('width', $this->finalWidth); - $rect->addAttribute('height', $this->finalHeight); - $rect->addAttribute('fill', '#' . $this->colors[$colorId]); - } - - /** - * drawBlock(): defined by RendererInterface. - * - * @see ImageRendererInterface::drawBlock() - * @param integer $x - * @param integer $y - * @param string $colorId - * @return void - */ - public function drawBlock($x, $y, $colorId) - { - $use = $this->svg->addChild('use'); - $use->addAttribute('x', $x); - $use->addAttribute('y', $y); - $use->addAttribute( - 'xlink:href', - $this->getRectPrototypeId($colorId), - 'http://www.w3.org/1999/xlink' - ); - } - - /** - * getByteStream(): defined by RendererInterface. - * - * @see ImageRendererInterface::getByteStream() - * @return string - */ - public function getByteStream() - { - return $this->svg->asXML(); - } - - /** - * Get the prototype ID for a color. - * - * @param integer $colorId - * @return string - */ - protected function getRectPrototypeId($colorId) - { - if (!isset($this->prototypeIds[$colorId])) { - $id = 'r' . dechex(count($this->prototypeIds)); - - $rect = $this->svg->defs->addChild('rect'); - $rect->addAttribute('id', $id); - $rect->addAttribute('width', $this->blockSize); - $rect->addAttribute('height', $this->blockSize); - $rect->addAttribute('fill', '#' . $this->colors[$colorId]); - - $this->prototypeIds[$colorId] = '#' . $id; - } - - return $this->prototypeIds[$colorId]; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/RendererInterface.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/RendererInterface.php deleted file mode 100644 index 554e1d88..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/RendererInterface.php +++ /dev/null @@ -1,26 +0,0 @@ -class = $class; - } - - /** - * Get CSS class name. - * - * @return string - */ - public function getClass() - { - return $this->class; - } - - /** - * Set CSS style value. - * - * @param string $style - */ - public function setStyle($style) - { - $this->style = $style; - } - - /** - * Get CSS style value. - * - * @return string - */ - public function getStyle() - { - return $this->style; - } - - /** - * render(): defined by RendererInterface. - * - * @see RendererInterface::render() - * @param QrCode $qrCode - * @return string - */ - public function render(QrCode $qrCode) - { - $textCode = parent::render($qrCode); - - $result = '' . $textCode . ''; - - return $result; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Text/Plain.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Text/Plain.php deleted file mode 100644 index a7e4cfb7..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Text/Plain.php +++ /dev/null @@ -1,150 +0,0 @@ -fullBlock = $fullBlock; - } - - /** - * Get char used as full block (occupied space, "black"). - * - * @return string - */ - public function getFullBlock() - { - return $this->fullBlock; - } - - /** - * Set char used as empty block (empty space, "white"). - * - * @param string $emptyBlock - */ - public function setEmptyBlock($emptyBlock) - { - $this->emptyBlock = $emptyBlock; - } - - /** - * Get char used as empty block (empty space, "white"). - * - * @return string - */ - public function getEmptyBlock() - { - return $this->emptyBlock; - } - - /** - * Sets the margin around the QR code. - * - * @param integer $margin - * @return AbstractRenderer - * @throws Exception\InvalidArgumentException - */ - public function setMargin($margin) - { - if ($margin < 0) { - throw new Exception\InvalidArgumentException('Margin must be equal to greater than 0'); - } - - $this->margin = (int) $margin; - - return $this; - } - - /** - * Gets the margin around the QR code. - * - * @return integer - */ - public function getMargin() - { - return $this->margin; - } - - /** - * render(): defined by RendererInterface. - * - * @see RendererInterface::render() - * @param QrCode $qrCode - * @return string - */ - public function render(QrCode $qrCode) - { - $result = ''; - $matrix = $qrCode->getMatrix(); - $width = $matrix->getWidth(); - - // Top margin - for ($x = 0; $x < $this->margin; $x++) { - $result .= str_repeat($this->emptyBlock, $width + 2 * $this->margin)."\n"; - } - - // Body - $array = $matrix->getArray(); - - foreach ($array as $row) { - $result .= str_repeat($this->emptyBlock, $this->margin); // left margin - foreach ($row as $byte) { - $result .= $byte ? $this->fullBlock : $this->emptyBlock; - } - $result .= str_repeat($this->emptyBlock, $this->margin); // right margin - $result .= "\n"; - } - - // Bottom margin - for ($x = 0; $x < $this->margin; $x++) { - $result .= str_repeat($this->emptyBlock, $width + 2 * $this->margin)."\n"; - } - - return $result; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Writer.php b/vendor/bacon/bacon-qr-code/src/BaconQrCode/Writer.php deleted file mode 100644 index 0f803138..00000000 --- a/vendor/bacon/bacon-qr-code/src/BaconQrCode/Writer.php +++ /dev/null @@ -1,105 +0,0 @@ -renderer = $renderer; - } - - /** - * Sets the renderer used to create a byte stream. - * - * @param RendererInterface $renderer - * @return Writer - */ - public function setRenderer(RendererInterface $renderer) - { - $this->renderer = $renderer; - return $this; - } - - /** - * Gets the renderer used to create a byte stream. - * - * @return RendererInterface - */ - public function getRenderer() - { - return $this->renderer; - } - - /** - * Writes QR code and returns it as string. - * - * Content is a string which *should* be encoded in UTF-8, in case there are - * non ASCII-characters present. - * - * @param string $content - * @param string $encoding - * @param integer $ecLevel - * @return string - * @throws Exception\InvalidArgumentException - */ - public function writeString( - $content, - $encoding = Encoder::DEFAULT_BYTE_MODE_ECODING, - $ecLevel = ErrorCorrectionLevel::L - ) { - if (strlen($content) === 0) { - throw new Exception\InvalidArgumentException('Found empty contents'); - } - - $qrCode = Encoder::encode($content, new ErrorCorrectionLevel($ecLevel), $encoding); - - return $this->getRenderer()->render($qrCode); - } - - /** - * Writes QR code to a file. - * - * @see Writer::writeString() - * @param string $content - * @param string $filename - * @param string $encoding - * @param integer $ecLevel - * @return void - */ - public function writeFile( - $content, - $filename, - $encoding = Encoder::DEFAULT_BYTE_MODE_ECODING, - $ecLevel = ErrorCorrectionLevel::L - ) { - file_put_contents($filename, $this->writeString($content, $encoding, $ecLevel)); - } -} diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitArrayTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitArrayTest.php deleted file mode 100644 index 81bcbce6..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitArrayTest.php +++ /dev/null @@ -1,201 +0,0 @@ -assertFalse($array->get($i)); - $array->set($i); - $this->assertTrue($array->get($i)); - } - } - - public function testGetNextSet1() - { - $array = new BitArray(32); - - for ($i = 0; $i < $array->getSize(); $i++) { - $this->assertEquals($i, 32, '', $array->getNextSet($i)); - } - - $array = new BitArray(33); - - for ($i = 0; $i < $array->getSize(); $i++) { - $this->assertEquals($i, 33, '', $array->getNextSet($i)); - } - } - - public function testGetNextSet2() - { - $array = new BitArray(33); - - for ($i = 0; $i < $array->getSize(); $i++) { - $this->assertEquals($i, $i <= 31 ? 31 : 33, '', $array->getNextSet($i)); - } - - $array = new BitArray(33); - - for ($i = 0; $i < $array->getSize(); $i++) { - $this->assertEquals($i, 32, '', $array->getNextSet($i)); - } - } - - public function testGetNextSet3() - { - $array = new BitArray(63); - $array->set(31); - $array->set(32); - - for ($i = 0; $i < $array->getSize(); $i++) { - if ($i <= 31) { - $expected = 31; - } elseif ($i <= 32) { - $expected = 32; - } else { - $expected = 63; - } - - $this->assertEquals($i, $expected, '', $array->getNextSet($i)); - } - } - - public function testGetNextSet4() - { - $array = new BitArray(63); - $array->set(33); - $array->set(40); - - for ($i = 0; $i < $array->getSize(); $i++) { - if ($i <= 33) { - $expected = 33; - } elseif ($i <= 40) { - $expected = 40; - } else { - $expected = 63; - } - - $this->assertEquals($i, $expected, '', $array->getNextSet($i)); - } - } - - public function testGetNextSet5() - { - if (defined('MT_RAND_PHP')) { - mt_srand(0xdeadbeef, MT_RAND_PHP); - } else { - mt_srand(0xdeadbeef); - } - - for ($i = 0; $i < 10; $i++) { - $array = new BitArray(mt_rand(1, 100)); - $numSet = mt_rand(0, 19); - - for ($j = 0; $j < $numSet; $j++) { - $array->set(mt_rand(0, $array->getSize() - 1)); - } - - $numQueries = mt_rand(0, 19); - - for ($j = 0; $j < $numQueries; $j++) { - $query = mt_rand(0, $array->getSize() - 1); - $expected = $query; - - while ($expected < $array->getSize() && !$array->get($expected)) { - $expected++; - } - - $actual = $array->getNextSet($query); - - if ($actual !== $expected) { - $array->getNextSet($query); - } - - $this->assertEquals($expected, $actual); - } - } - } - - public function testSetBulk() - { - $array = new BitArray(64); - $array->setBulk(32, 0xFFFF0000); - - for ($i = 0; $i < 48; $i++) { - $this->assertFalse($array->get($i)); - } - - for ($i = 48; $i < 64; $i++) { - $this->assertTrue($array->get($i)); - } - } - - public function testClear() - { - $array = new BitArray(32); - - for ($i = 0; $i < 32; $i++) { - $array->set($i); - } - - $array->clear(); - - for ($i = 0; $i < 32; $i++) { - $this->assertFalse($array->get($i)); - } - } - - public function testGetArray() - { - $array = new BitArray(64); - $array->set(0); - $array->set(63); - - $ints = $array->getBitArray(); - - $this->assertEquals(1, $ints[0]); - $this->assertEquals(0x80000000, $ints[1]); - } - - public function testIsRange() - { - $array = new BitArray(64); - $this->assertTrue($array->isRange(0, 64, false)); - $this->assertFalse($array->isRange(0, 64, true)); - - $array->set(32); - $this->assertTrue($array->isRange(32, 33, true)); - - $array->set(31); - $this->assertTrue($array->isRange(31, 33, true)); - - $array->set(34); - $this->assertFalse($array->isRange(31, 35, true)); - - for ($i = 0; $i < 31; $i++) { - $array->set($i); - } - - $this->assertTrue($array->isRange(0, 33, true)); - - for ($i = 33; $i < 64; $i++) { - $array->set($i); - } - - $this->assertTrue($array->isRange(0, 64, true)); - $this->assertFalse($array->isRange(0, 64, false)); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitMatrixTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitMatrixTest.php deleted file mode 100644 index 89a58812..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitMatrixTest.php +++ /dev/null @@ -1,119 +0,0 @@ -assertEquals(33, $matrix->getHeight()); - - for ($y = 0; $y < 33; $y++) { - for ($x = 0; $x < 33; $x++) { - if ($y * $x % 3 === 0) { - $matrix->set($x, $y); - } - } - } - - for ($y = 0; $y < 33; $y++) { - for ($x = 0; $x < 33; $x++) { - $this->assertEquals($x * $y % 3 === 0, $matrix->get($x, $y)); - } - } - } - - public function testSetRegion() - { - $matrix = new BitMatrix(5); - $matrix->setRegion(1, 1, 3, 3); - - for ($y = 0; $y < 5; $y++) { - for ($x = 0; $x < 5; $x++) { - $this->assertEquals($y >= 1 && $y <= 3 && $x >= 1 && $x <= 3, $matrix->get($x, $y)); - } - } - } - - public function testRectangularMatrix() - { - $matrix = new BitMatrix(75, 20); - $this->assertEquals(75, $matrix->getWidth()); - $this->assertEquals(20, $matrix->getHeight()); - - $matrix->set(10, 0); - $matrix->set(11, 1); - $matrix->set(50, 2); - $matrix->set(51, 3); - $matrix->flip(74, 4); - $matrix->flip(0, 5); - - $this->assertTrue($matrix->get(10, 0)); - $this->assertTrue($matrix->get(11, 1)); - $this->assertTrue($matrix->get(50, 2)); - $this->assertTrue($matrix->get(51, 3)); - $this->assertTrue($matrix->get(74, 4)); - $this->assertTrue($matrix->get(0, 5)); - - $matrix->flip(50, 2); - $matrix->flip(51, 3); - - $this->assertFalse($matrix->get(50, 2)); - $this->assertFalse($matrix->get(51, 3)); - } - - public function testRectangularSetRegion() - { - $matrix = new BitMatrix(320, 240); - $this->assertEquals(320, $matrix->getWidth()); - $this->assertEquals(240, $matrix->getHeight()); - - $matrix->setRegion(105, 22, 80, 12); - - for ($y = 0; $y < 240; $y++) { - for ($x = 0; $x < 320; $x++) { - $this->assertEquals($y >= 22 && $y < 34 && $x >= 105 && $x < 185, $matrix->get($x, $y)); - } - } - } - - public function testGetRow() - { - $matrix = new BitMatrix(102, 5); - - for ($x = 0; $x < 102; $x++) { - if ($x & 3 === 0) { - $matrix->set($x, 2); - } - } - - $array1 = $matrix->getRow(2, null); - $this->assertEquals(102, $array1->getSize()); - - $array2 = new BitArray(60); - $array2 = $matrix->getRow(2, $array2); - $this->assertEquals(102, $array2->getSize()); - - $array3 = new BitArray(200); - $array3 = $matrix->getRow(2, $array3); - $this->assertEquals(200, $array3->getSize()); - - for ($x = 0; $x < 102; $x++) { - $on = ($x & 3 === 0); - - $this->assertEquals($on, $array1->get($x)); - $this->assertEquals($on, $array2->get($x)); - $this->assertEquals($on, $array3->get($x)); - } - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitUtilsTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitUtilsTest.php deleted file mode 100644 index b80ff7df..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/BitUtilsTest.php +++ /dev/null @@ -1,30 +0,0 @@ -assertEquals(1, BitUtils::unsignedRightShift(1, 0)); - $this->assertEquals(1, BitUtils::unsignedRightShift(10, 3)); - $this->assertEquals(536870910, BitUtils::unsignedRightShift(-10, 3)); - } - - public function testNumberOfTrailingZeros() - { - $this->assertEquals(32, BitUtils::numberOfTrailingZeros(0)); - $this->assertEquals(1, BitUtils::numberOfTrailingZeros(10)); - $this->assertEquals(0, BitUtils::numberOfTrailingZeros(15)); - $this->assertEquals(2, BitUtils::numberOfTrailingZeros(20)); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ErrorCorrectionLevelTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ErrorCorrectionLevelTest.php deleted file mode 100644 index 736e995d..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ErrorCorrectionLevelTest.php +++ /dev/null @@ -1,40 +0,0 @@ -assertEquals(0x0, ErrorCorrectionLevel::M); - $this->assertEquals(0x1, ErrorCorrectionLevel::L); - $this->assertEquals(0x2, ErrorCorrectionLevel::H); - $this->assertEquals(0x3, ErrorCorrectionLevel::Q); - } - - public function testInvalidErrorCorrectionLevelThrowsException() - { - $this->setExpectedException( - 'BaconQrCode\Exception\UnexpectedValueException', - 'Value not a const in enum BaconQrCode\Common\ErrorCorrectionLevel' - ); - new ErrorCorrectionLevel(4); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/FormatInformationTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/FormatInformationTest.php deleted file mode 100644 index 5f6ee58c..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/FormatInformationTest.php +++ /dev/null @@ -1,104 +0,0 @@ -unmaskedTestFormatInfo = $this->maskedTestFormatInfo ^ 0x5412; - } - - - public function testBitsDiffering() - { - $this->assertEquals(0, FormatInformation::numBitsDiffering(1, 1)); - $this->assertEquals(1, FormatInformation::numBitsDiffering(0, 2)); - $this->assertEquals(2, FormatInformation::numBitsDiffering(1, 2)); - $this->assertEquals(32, FormatInformation::numBitsDiffering(-1, 0)); - } - - public function testDecode() - { - $expected = FormatInformation::decodeFormatInformation( - $this->maskedTestFormatInfo, - $this->maskedTestFormatInfo - ); - - $this->assertNotNull($expected); - $this->assertEquals(7, $expected->getDataMask()); - $this->assertEquals(ErrorCorrectionLevel::Q, $expected->getErrorCorrectionLevel()->get()); - - $this->assertEquals( - $expected, - FormatInformation::decodeFormatInformation( - $this->unmaskedTestFormatInfo, - $this->maskedTestFormatInfo - ) - ); - } - - public function testDecodeWithBitDifference() - { - $expected = FormatInformation::decodeFormatInformation( - $this->maskedTestFormatInfo, - $this->maskedTestFormatInfo - ); - - $this->assertEquals( - $expected, - FormatInformation::decodeFormatInformation( - $this->maskedTestFormatInfo ^ 0x1, - $this->maskedTestFormatInfo ^ 0x1 - ) - ); - $this->assertEquals( - $expected, - FormatInformation::decodeFormatInformation( - $this->maskedTestFormatInfo ^ 0x3, - $this->maskedTestFormatInfo ^ 0x3 - ) - ); - $this->assertEquals( - $expected, - FormatInformation::decodeFormatInformation( - $this->maskedTestFormatInfo ^ 0x7, - $this->maskedTestFormatInfo ^ 0x7 - ) - ); - $this->assertNull( - FormatInformation::decodeFormatInformation( - $this->maskedTestFormatInfo ^ 0xf, - $this->maskedTestFormatInfo ^ 0xf - ) - ); - } - - public function testDecodeWithMisRead() - { - $expected = FormatInformation::decodeFormatInformation( - $this->maskedTestFormatInfo, - $this->maskedTestFormatInfo - ); - - $this->assertEquals( - $expected, - FormatInformation::decodeFormatInformation( - $this->maskedTestFormatInfo ^ 0x3, - $this->maskedTestFormatInfo ^ 0xf - ) - ); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ModeTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ModeTest.php deleted file mode 100644 index 4daab7c3..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ModeTest.php +++ /dev/null @@ -1,42 +0,0 @@ -assertEquals(0x0, Mode::TERMINATOR); - $this->assertEquals(0x1, Mode::NUMERIC); - $this->assertEquals(0x2, Mode::ALPHANUMERIC); - $this->assertEquals(0x4, Mode::BYTE); - $this->assertEquals(0x8, Mode::KANJI); - } - - public function testInvalidModeThrowsException() - { - $this->setExpectedException( - 'BaconQrCode\Exception\UnexpectedValueException', - 'Value not a const in enum BaconQrCode\Common\Mode' - ); - new Mode(10); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ReedSolomonCodecTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ReedSolomonCodecTest.php deleted file mode 100644 index 604641a0..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/ReedSolomonCodecTest.php +++ /dev/null @@ -1,111 +0,0 @@ -encode($block, $parity); - - // Copy parity into test blocks - for ($i = 0; $i < $numRoots; $i++) { - $block[$i + $dataSize] = $parity[$i]; - $tBlock[$i + $dataSize] = $parity[$i]; - } - - // Seed with errors - for ($i = 0; $i < $errors; $i++) { - $errorValue = mt_rand(1, $blockSize); - - do { - $errorLocation = mt_rand(0, $blockSize); - } while ($errorLocations[$errorLocation] !== 0); - - $errorLocations[$errorLocation] = 1; - - if (mt_rand(0, 1)) { - $erasures[] = $errorLocation; - } - - $tBlock[$errorLocation] ^= $errorValue; - } - - $erasures = SplFixedArray::fromArray($erasures, false); - - // Decode the errored block - $foundErrors = $codec->decode($tBlock, $erasures); - - if ($errors > 0 && $foundErrors === null) { - $this->assertEquals($block, $tBlock, 'Decoder failed to correct errors'); - } - - $this->assertEquals($errors, $foundErrors, 'Found errors do not equal expected errors'); - - for ($i = 0; $i < $foundErrors; $i++) { - if ($errorLocations[$erasures[$i]] === 0) { - $this->fail(sprintf('Decoder indicates error in location %d without error', $erasures[$i])); - } - } - - $this->assertEquals($block, $tBlock, 'Decoder did not correct errors'); - } - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/VersionTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/VersionTest.php deleted file mode 100644 index 8b3fc01f..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Common/VersionTest.php +++ /dev/null @@ -1,88 +0,0 @@ -assertNotNull($version); - $this->assertEquals($versionNumber, $version->getVersionNumber()); - $this->assertNotNull($version->getAlignmentPatternCenters()); - - if ($versionNumber > 1) { - $this->assertTrue(count($version->getAlignmentPatternCenters()) > 0); - } - - $this->assertEquals($dimension, $version->getDimensionForVersion()); - $this->assertNotNull($version->getEcBlocksForLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::H))); - $this->assertNotNull($version->getEcBlocksForLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::L))); - $this->assertNotNull($version->getEcBlocksForLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::M))); - $this->assertNotNull($version->getEcBlocksForLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::Q))); - $this->assertNotNull($version->buildFunctionPattern()); - } - - /** - * @dataProvider versionProvider - * @param integer $versionNumber - * @param integer $dimension - */ - public function testGetProvisionalVersionForDimension($versionNumber, $dimension) - { - $this->assertEquals( - $versionNumber, - Version::getProvisionalVersionForDimension($dimension)->getVersionNumber() - ); - } - - /** - * @dataProvider decodeInformationProvider - * @param integer $expectedVersion - * @param integer $mask - */ - public function testDecodeVersionInformation($expectedVersion, $mask) - { - $version = Version::decodeVersionInformation($mask); - $this->assertNotNull($version); - $this->assertEquals($expectedVersion, $version->getVersionNumber()); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/EncoderTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/EncoderTest.php deleted file mode 100644 index 31cdaa4e..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/EncoderTest.php +++ /dev/null @@ -1,468 +0,0 @@ -getMethods(ReflectionMethod::IS_STATIC) as $method) { - $method->setAccessible(true); - $this->methods[$method->getName()] = $method; - } - } - - public function testGetAlphanumericCode() - { - // The first ten code points are numbers. - for ($i = 0; $i < 10; $i++) { - $this->assertEquals($i, $this->methods['getAlphanumericCode']->invoke(null, ord('0') + $i)); - } - - // The next 26 code points are capital alphabet letters. - for ($i = 10; $i < 36; $i++) { - // The first ten code points are numbers - $this->assertEquals($i, $this->methods['getAlphanumericCode']->invoke(null, ord('A') + $i - 10)); - } - - // Others are symbol letters. - $this->assertEquals(36, $this->methods['getAlphanumericCode']->invoke(null, ' ')); - $this->assertEquals(37, $this->methods['getAlphanumericCode']->invoke(null, '$')); - $this->assertEquals(38, $this->methods['getAlphanumericCode']->invoke(null, '%')); - $this->assertEquals(39, $this->methods['getAlphanumericCode']->invoke(null, '*')); - $this->assertEquals(40, $this->methods['getAlphanumericCode']->invoke(null, '+')); - $this->assertEquals(41, $this->methods['getAlphanumericCode']->invoke(null, '-')); - $this->assertEquals(42, $this->methods['getAlphanumericCode']->invoke(null, '.')); - $this->assertEquals(43, $this->methods['getAlphanumericCode']->invoke(null, '/')); - $this->assertEquals(44, $this->methods['getAlphanumericCode']->invoke(null, ':')); - - // Should return -1 for other letters. - $this->assertEquals(-1, $this->methods['getAlphanumericCode']->invoke(null, 'a')); - $this->assertEquals(-1, $this->methods['getAlphanumericCode']->invoke(null, '#')); - $this->assertEquals(-1, $this->methods['getAlphanumericCode']->invoke(null, "\0")); - } - - public function testChooseMode() - { - // Numeric mode - $this->assertSame(Mode::NUMERIC, $this->methods['chooseMode']->invoke(null, '0')->get()); - $this->assertSame(Mode::NUMERIC, $this->methods['chooseMode']->invoke(null, '0123456789')->get()); - - // Alphanumeric mode - $this->assertSame(Mode::ALPHANUMERIC, $this->methods['chooseMode']->invoke(null, 'A')->get()); - $this->assertSame(Mode::ALPHANUMERIC, $this->methods['chooseMode']->invoke(null, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:')->get()); - - // 8-bit byte mode - $this->assertSame(Mode::BYTE, $this->methods['chooseMode']->invoke(null, 'a')->get()); - $this->assertSame(Mode::BYTE, $this->methods['chooseMode']->invoke(null, '#')->get()); - $this->assertSame(Mode::BYTE, $this->methods['chooseMode']->invoke(null, '')->get()); - - // AIUE in Hiragana in SHIFT-JIS - $this->assertSame(Mode::BYTE, $this->methods['chooseMode']->invoke(null, "\x8\xa\x8\xa\x8\xa\x8\xa6")->get()); - - // Nihon in Kanji in SHIFT-JIS - $this->assertSame(Mode::BYTE, $this->methods['chooseMode']->invoke(null, "\x9\xf\x9\x7b")->get()); - - // Sou-Utso-Byou in Kanji in SHIFT-JIS - $this->assertSame(Mode::BYTE, $this->methods['chooseMode']->invoke(null, "\xe\x4\x9\x5\x9\x61")->get()); - } - - public function testEncode() - { - $qrCode = Encoder::encode('ABCDEF', new ErrorCorrectionLevel(ErrorCorrectionLevel::H)); - $expected = "<<\n" - . " mode: ALPHANUMERIC\n" - . " ecLevel: H\n" - . " version: 1\n" - . " maskPattern: 0\n" - . " matrix:\n" - . " 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 1 1 1 0 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0\n" - . " 0 0 1 0 1 1 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1\n" - . " 1 0 1 1 1 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0\n" - . " 0 0 1 1 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 1 0\n" - . " 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 0\n" - . " 0 0 1 1 0 1 1 1 1 0 0 0 1 0 1 0 1 1 1 1 0\n" - . " 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 0 0\n" - . " 1 1 1 1 1 1 1 0 0 0 1 0 1 0 1 1 0 0 0 0 1\n" - . " 1 0 0 0 0 0 1 0 1 1 1 1 0 1 0 1 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 1 0 1 1 0 1 0 1 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 0 1 0\n" - . " 1 0 1 1 1 0 1 0 1 0 0 0 1 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 1 1 0 1 1 0 1 0 0 0 1 1\n" - . " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1\n" - . ">>\n"; - - $this->assertEquals($expected, $qrCode->__toString()); - } - - public function testSimpleUtf8Eci() - { - $qrCode = Encoder::encode('hello', new ErrorCorrectionLevel(ErrorCorrectionLevel::H), 'utf-8'); - $expected = "<<\n" - . " mode: BYTE\n" - . " ecLevel: H\n" - . " version: 1\n" - . " maskPattern: 3\n" - . " matrix:\n" - . " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 1 0 1 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 1 1 0 0 1 1 1 1 0 0 0 1 1 0 1 0 0 0 0\n" - . " 0 0 1 1 1 0 0 0 0 0 1 1 0 0 0 1 0 1 1 1 0\n" - . " 0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 1 1 1\n" - . " 1 1 0 0 1 0 0 1 1 0 0 1 1 1 1 0 1 0 1 1 0\n" - . " 0 0 0 0 1 0 1 1 1 1 0 0 0 0 0 1 0 0 1 0 0\n" - . " 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 0 0 1 0 0\n" - . " 1 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 0 0 0 1 1 0 0 0 0 0\n" - . " 1 0 1 1 1 0 1 0 1 1 1 0 1 0 0 0 1 1 0 0 0\n" - . " 1 0 1 1 1 0 1 0 1 1 0 0 0 1 0 0 1 0 0 0 0\n" - . " 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 1 1 0\n" - . " 1 1 1 1 1 1 1 0 0 1 0 1 1 1 0 1 1 0 0 0 0\n" - . ">>\n"; - - $this->assertEquals($expected, $qrCode->__toString()); - } - - public function testAppendModeInfo() - { - $bits = new BitArray(); - $this->methods['appendModeInfo']->invoke(null, new Mode(Mode::NUMERIC), $bits); - $this->assertEquals(' ...X', $bits->__toString()); - } - - public function testAppendLengthInfo() - { - // 1 letter (1/1), 10 bits. - $bits = new BitArray(); - $this->methods['appendLengthInfo']->invoke( - null, - 1, - Version::getVersionForNumber(1), - new Mode(Mode::NUMERIC), - $bits - ); - $this->assertEquals(' ........ .X', $bits->__toString()); - - // 2 letters (2/1), 11 bits. - $bits = new BitArray(); - $this->methods['appendLengthInfo']->invoke( - null, - 2, - Version::getVersionForNumber(10), - new Mode(Mode::ALPHANUMERIC), - $bits - ); - $this->assertEquals(' ........ .X.', $bits->__toString()); - - // 255 letters (255/1), 16 bits. - $bits = new BitArray(); - $this->methods['appendLengthInfo']->invoke( - null, - 255, - Version::getVersionForNumber(27), - new Mode(Mode::BYTE), - $bits - ); - $this->assertEquals(' ........ XXXXXXXX', $bits->__toString()); - - // 512 letters (1024/2), 12 bits. - $bits = new BitArray(); - $this->methods['appendLengthInfo']->invoke( - null, - 512, - Version::getVersionForNumber(40), - new Mode(Mode::KANJI), - $bits - ); - $this->assertEquals(' ..X..... ....', $bits->__toString()); - } - - public function testAppendBytes() - { - // Should use appendNumericBytes. - // 1 = 01 = 0001 in 4 bits. - $bits = new BitArray(); - $this->methods['appendBytes']->invoke( - null, - '1', - new Mode(Mode::NUMERIC), - $bits, - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->assertEquals(' ...X', $bits->__toString()); - - // Should use appendAlphaNumericBytes. - // A = 10 = 0xa = 001010 in 6 bits. - $bits = new BitArray(); - $this->methods['appendBytes']->invoke( - null, - 'A', - new Mode(Mode::ALPHANUMERIC), - $bits, - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->assertEquals(' ..X.X.', $bits->__toString()); - - // Should use append8BitBytes. - // 0x61, 0x62, 0x63 - $bits = new BitArray(); - $this->methods['appendBytes']->invoke( - null, - 'abc', - new Mode(Mode::BYTE), - $bits, - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->assertEquals(' .XX....X .XX...X. .XX...XX', $bits->__toString()); - - // Should use appendKanjiBytes. - // 0x93, 0x5f - $bits = new BitArray(); - $this->methods['appendBytes']->invoke( - null, - "\x93\x5f", - new Mode(Mode::KANJI), - $bits, - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->assertEquals(' .XX.XX.. XXXXX', $bits->__toString()); - - // Lower letters such as 'a' cannot be encoded in alphanumeric mode. - $this->setExpectedException( - 'BaconQrCode\Exception\WriterException', - 'Invalid alphanumeric code' - ); - $this->methods['appendBytes']->invoke( - null, - "a", - new Mode(Mode::ALPHANUMERIC), - $bits, - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - } - - public function testTerminateBits() - { - $bits = new BitArray(); - $this->methods['terminateBits']->invoke(null, 0, $bits); - $this->assertEquals('', $bits->__toString()); - - $bits = new BitArray(); - $this->methods['terminateBits']->invoke(null, 1, $bits); - $this->assertEquals(' ........', $bits->__toString()); - - $bits = new BitArray(); - $bits->appendBits(0, 3); - $this->methods['terminateBits']->invoke(null, 1, $bits); - $this->assertEquals(' ........', $bits->__toString()); - - $bits = new BitArray(); - $bits->appendBits(0, 5); - $this->methods['terminateBits']->invoke(null, 1, $bits); - $this->assertEquals(' ........', $bits->__toString()); - - $bits = new BitArray(); - $bits->appendBits(0, 8); - $this->methods['terminateBits']->invoke(null, 1, $bits); - $this->assertEquals(' ........', $bits->__toString()); - - $bits = new BitArray(); - $this->methods['terminateBits']->invoke(null, 2, $bits); - $this->assertEquals(' ........ XXX.XX..', $bits->__toString()); - - $bits = new BitArray(); - $bits->appendBits(0, 1); - $this->methods['terminateBits']->invoke(null, 3, $bits); - $this->assertEquals(' ........ XXX.XX.. ...X...X', $bits->__toString()); - } - - public function testGetNumDataBytesAndNumEcBytesForBlockId() - { - // Version 1-H. - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']->invoke(null, 26, 9, 1, 0); - $this->assertEquals(9, $numDataBytes); - $this->assertEquals(17, $numEcBytes); - - // Version 3-H. 2 blocks. - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']->invoke(null, 70, 26, 2, 0); - $this->assertEquals(13, $numDataBytes); - $this->assertEquals(22, $numEcBytes); - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']->invoke(null, 70, 26, 2, 1); - $this->assertEquals(13, $numDataBytes); - $this->assertEquals(22, $numEcBytes); - - // Version 7-H. (4 + 1) blocks. - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']->invoke(null, 196, 66, 5, 0); - $this->assertEquals(13, $numDataBytes); - $this->assertEquals(26, $numEcBytes); - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']->invoke(null, 196, 66, 5, 4); - $this->assertEquals(14, $numDataBytes); - $this->assertEquals(26, $numEcBytes); - - // Version 40-H. (20 + 61) blocks. - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']->invoke(null, 3706, 1276, 81, 0); - $this->assertEquals(15, $numDataBytes); - $this->assertEquals(30, $numEcBytes); - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']->invoke(null, 3706, 1276, 81, 20); - $this->assertEquals(16, $numDataBytes); - $this->assertEquals(30, $numEcBytes); - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId']->invoke(null, 3706, 1276, 81, 80); - $this->assertEquals(16, $numDataBytes); - $this->assertEquals(30, $numEcBytes); - } - - public function testInterleaveWithEcBytes() - { - $dataBytes = SplFixedArray::fromArray(array(32, 65, 205, 69, 41, 220, 46, 128, 236), false); - $in = new BitArray(); - - foreach ($dataBytes as $dataByte) { - $in->appendBits($dataByte, 8); - } - - $outBits = $this->methods['interleaveWithEcBytes']->invoke(null, $in, 26, 9, 1); - $expected = SplFixedArray::fromArray(array( - // Data bytes. - 32, 65, 205, 69, 41, 220, 46, 128, 236, - // Error correction bytes. - 42, 159, 74, 221, 244, 169, 239, 150, 138, 70, 237, 85, 224, 96, 74, 219, 61, - ), false); - - $out = $outBits->toBytes(0, count($expected)); - - $this->assertEquals($expected, $out); - } - - public function testAppendNumericBytes() - { - // 1 = 01 = 0001 in 4 bits. - $bits = new BitArray(); - $this->methods['appendNumericBytes']->invoke(null, '1', $bits); - $this->assertEquals(' ...X', $bits->__toString()); - - // 12 = 0xc = 0001100 in 7 bits. - $bits = new BitArray(); - $this->methods['appendNumericBytes']->invoke(null, '12', $bits); - $this->assertEquals(' ...XX..', $bits->__toString()); - - // 123 = 0x7b = 0001111011 in 10 bits. - $bits = new BitArray(); - $this->methods['appendNumericBytes']->invoke(null, '123', $bits); - $this->assertEquals(' ...XXXX. XX', $bits->__toString()); - - // 1234 = "123" + "4" = 0001111011 + 0100 in 14 bits. - $bits = new BitArray(); - $this->methods['appendNumericBytes']->invoke(null, '1234', $bits); - $this->assertEquals(' ...XXXX. XX.X..', $bits->__toString()); - - // Empty - $bits = new BitArray(); - $this->methods['appendNumericBytes']->invoke(null, '', $bits); - $this->assertEquals('', $bits->__toString()); - } - - public function testAppendAlphanumericBytes() - { - $bits = new BitArray(); - $this->methods['appendAlphanumericBytes']->invoke(null, 'A', $bits); - $this->assertEquals(' ..X.X.', $bits->__toString()); - - $bits = new BitArray(); - $this->methods['appendAlphanumericBytes']->invoke(null, 'AB', $bits); - $this->assertEquals(' ..XXX..X X.X', $bits->__toString()); - - $bits = new BitArray(); - $this->methods['appendAlphanumericBytes']->invoke(null, 'ABC', $bits); - $this->assertEquals(' ..XXX..X X.X..XX. .', $bits->__toString()); - - // Empty - $bits = new BitArray(); - $this->methods['appendAlphanumericBytes']->invoke(null, '', $bits); - $this->assertEquals('', $bits->__toString()); - - // Invalid data - $this->setExpectedException('BaconQrCode\Exception\WriterException', 'Invalid alphanumeric code'); - $bits = new BitArray(); - $this->methods['appendAlphanumericBytes']->invoke(null, 'abc', $bits); - } - - public function testAppend8BitBytes() - { - // 0x61, 0x62, 0x63 - $bits = new BitArray(); - $this->methods['append8BitBytes']->invoke(null, 'abc', $bits, Encoder::DEFAULT_BYTE_MODE_ECODING); - $this->assertEquals(' .XX....X .XX...X. .XX...XX', $bits->__toString()); - - // Empty - $bits = new BitArray(); - $this->methods['append8BitBytes']->invoke(null, '', $bits, Encoder::DEFAULT_BYTE_MODE_ECODING); - $this->assertEquals('', $bits->__toString()); - } - - public function testAppendKanjiBytes() - { - // Numbers are from page 21 of JISX0510:2004 - $bits = new BitArray(); - $this->methods['appendKanjiBytes']->invoke(null, "\x93\x5f", $bits); - $this->assertEquals(' .XX.XX.. XXXXX', $bits->__toString()); - - $this->methods['appendKanjiBytes']->invoke(null, "\xe4\xaa", $bits); - $this->assertEquals(' .XX.XX.. XXXXXXX. X.X.X.X. X.', $bits->__toString()); - } - - public function testGenerateEcBytes() - { - // Numbers are from http://www.swetake.com/qr/qr3.html and - // http://www.swetake.com/qr/qr9.html - $dataBytes = SplFixedArray::fromArray(array(32, 65, 205, 69, 41, 220, 46, 128, 236), false); - $ecBytes = $this->methods['generateEcBytes']->invoke(null, $dataBytes, 17); - $expected = SplFixedArray::fromArray(array(42, 159, 74, 221, 244, 169, 239, 150, 138, 70, 237, 85, 224, 96, 74, 219, 61), false); - $this->assertEquals($expected, $ecBytes); - - $dataBytes = SplFixedArray::fromArray(array(67, 70, 22, 38, 54, 70, 86, 102, 118, 134, 150, 166, 182, 198, 214), false); - $ecBytes = $this->methods['generateEcBytes']->invoke(null, $dataBytes, 18); - $expected = SplFixedArray::fromArray(array(175, 80, 155, 64, 178, 45, 214, 233, 65, 209, 12, 155, 117, 31, 140, 214, 27, 187), false); - $this->assertEquals($expected, $ecBytes); - - // High-order zero coefficient case. - $dataBytes = SplFixedArray::fromArray(array(32, 49, 205, 69, 42, 20, 0, 236, 17), false); - $ecBytes = $this->methods['generateEcBytes']->invoke(null, $dataBytes, 17); - $expected = SplFixedArray::fromArray(array(0, 3, 130, 179, 194, 0, 55, 211, 110, 79, 98, 72, 170, 96, 211, 137, 213), false); - $this->assertEquals($expected, $ecBytes); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/MaskUtilTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/MaskUtilTest.php deleted file mode 100644 index a5c38656..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/MaskUtilTest.php +++ /dev/null @@ -1,281 +0,0 @@ -fail('Data mask bit did not match'); - } - } - } - } - - public function testApplyMaskPenaltyRule1() - { - $matrix = new ByteMatrix(4, 1); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(2, 0, 0); - $matrix->set(3, 0, 0); - - $this->assertEquals(0, MaskUtil::applyMaskPenaltyRule1($matrix)); - - // Horizontal - $matrix = new ByteMatrix(6, 1); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(2, 0, 0); - $matrix->set(3, 0, 0); - $matrix->set(4, 0, 0); - $matrix->set(5, 0, 1); - $this->assertEquals(3, MaskUtil::applyMaskPenaltyRule1($matrix)); - $matrix->set(5, 0, 0); - $this->assertEquals(4, MaskUtil::applyMaskPenaltyRule1($matrix)); - - // Vertical - $matrix = new ByteMatrix(1, 6); - $matrix->set(0, 0, 0); - $matrix->set(0, 1, 0); - $matrix->set(0, 2, 0); - $matrix->set(0, 3, 0); - $matrix->set(0, 4, 0); - $matrix->set(0, 5, 1); - $this->assertEquals(3, MaskUtil::applyMaskPenaltyRule1($matrix)); - $matrix->set(0, 5, 0); - $this->assertEquals(4, MaskUtil::applyMaskPenaltyRule1($matrix)); - } - - public function testApplyMaskPenaltyRule2() - { - $matrix = new ByteMatrix(1, 1); - $matrix->set(0, 0, 0); - $this->assertEquals(0, MaskUtil::applyMaskPenaltyRule2($matrix)); - - $matrix = new ByteMatrix(2, 2); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(0, 1, 0); - $matrix->set(1, 1, 1); - $this->assertEquals(0, MaskUtil::applyMaskPenaltyRule2($matrix)); - - $matrix = new ByteMatrix(2, 2); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(0, 1, 0); - $matrix->set(1, 1, 0); - $this->assertEquals(3, MaskUtil::applyMaskPenaltyRule2($matrix)); - - $matrix = new ByteMatrix(3, 3); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(2, 0, 0); - $matrix->set(0, 1, 0); - $matrix->set(1, 1, 0); - $matrix->set(2, 1, 0); - $matrix->set(0, 2, 0); - $matrix->set(1, 2, 0); - $matrix->set(2, 2, 0); - $this->assertEquals(3 * 4, MaskUtil::applyMaskPenaltyRule2($matrix)); - } - - public function testApplyMaskPenalty3() - { - // Horizontal 00001011101 - $matrix = new ByteMatrix(11, 1); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(2, 0, 0); - $matrix->set(3, 0, 0); - $matrix->set(4, 0, 1); - $matrix->set(5, 0, 0); - $matrix->set(6, 0, 1); - $matrix->set(7, 0, 1); - $matrix->set(8, 0, 1); - $matrix->set(9, 0, 0); - $matrix->set(10, 0, 1); - $this->assertEquals(40, MaskUtil::applyMaskPenaltyRule3($matrix)); - - // Horizontal 10111010000 - $matrix = new ByteMatrix(11, 1); - $matrix->set(0, 0, 1); - $matrix->set(1, 0, 0); - $matrix->set(2, 0, 1); - $matrix->set(3, 0, 1); - $matrix->set(4, 0, 1); - $matrix->set(5, 0, 0); - $matrix->set(6, 0, 1); - $matrix->set(7, 0, 0); - $matrix->set(8, 0, 0); - $matrix->set(9, 0, 0); - $matrix->set(10, 0, 0); - $this->assertEquals(40, MaskUtil::applyMaskPenaltyRule3($matrix)); - - // Vertical 00001011101 - $matrix = new ByteMatrix(1, 11); - $matrix->set(0, 0, 0); - $matrix->set(0, 1, 0); - $matrix->set(0, 2, 0); - $matrix->set(0, 3, 0); - $matrix->set(0, 4, 1); - $matrix->set(0, 5, 0); - $matrix->set(0, 6, 1); - $matrix->set(0, 7, 1); - $matrix->set(0, 8, 1); - $matrix->set(0, 9, 0); - $matrix->set(0, 10, 1); - $this->assertEquals(40, MaskUtil::applyMaskPenaltyRule3($matrix)); - - // Vertical 10111010000 - $matrix = new ByteMatrix(1, 11); - $matrix->set(0, 0, 1); - $matrix->set(0, 1, 0); - $matrix->set(0, 2, 1); - $matrix->set(0, 3, 1); - $matrix->set(0, 4, 1); - $matrix->set(0, 5, 0); - $matrix->set(0, 6, 1); - $matrix->set(0, 7, 0); - $matrix->set(0, 8, 0); - $matrix->set(0, 9, 0); - $matrix->set(0, 10, 0); - $this->assertEquals(40, MaskUtil::applyMaskPenaltyRule3($matrix)); - } - - public function testApplyMaskPenaltyRule4() - { - // Dark cell ratio = 0% - $matrix = new ByteMatrix(1, 1); - $matrix->set(0, 0, 0); - $this->assertEquals(100, MaskUtil::applyMaskPenaltyRule4($matrix)); - - // Dark cell ratio = 5% - $matrix = new ByteMatrix(2, 1); - $matrix->set(0, 0, 0); - $matrix->set(0, 0, 1); - $this->assertEquals(0, MaskUtil::applyMaskPenaltyRule4($matrix)); - - // Dark cell ratio = 66.67% - $matrix = new ByteMatrix(6, 1); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 1); - $matrix->set(2, 0, 1); - $matrix->set(3, 0, 1); - $matrix->set(4, 0, 1); - $matrix->set(5, 0, 0); - $this->assertEquals(30, MaskUtil::applyMaskPenaltyRule4($matrix)); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/MatrixUtilTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/MatrixUtilTest.php deleted file mode 100644 index bf3544f0..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Encoder/MatrixUtilTest.php +++ /dev/null @@ -1,336 +0,0 @@ -getMethods(ReflectionMethod::IS_STATIC) as $method) { - $method->setAccessible(true); - $this->methods[$method->getName()] = $method; - } - } - - public function testToString() - { - $matrix= new ByteMatrix(3, 3); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 1); - $matrix->set(2, 0, 0); - $matrix->set(0, 1, 1); - $matrix->set(1, 1, 0); - $matrix->set(2, 1, 1); - $matrix->set(0, 2, -1); - $matrix->set(1, 2, -1); - $matrix->set(2, 2, -1); - - $expected = " 0 1 0\n 1 0 1\n \n"; - $this->assertEquals($expected, $matrix->__toString()); - } - - public function testClearMatrix() - { - $matrix = new ByteMatrix(2, 2); - MatrixUtil::clearMatrix($matrix); - - $this->assertEquals(-1, $matrix->get(0, 0)); - $this->assertEquals(-1, $matrix->get(1, 0)); - $this->assertEquals(-1, $matrix->get(0, 1)); - $this->assertEquals(-1, $matrix->get(1, 1)); - } - - public function testEmbedBasicPatterns1() - { - $matrix = new ByteMatrix(21, 21); - MatrixUtil::clearMatrix($matrix); - $this->methods['embedBasicPatterns']->invoke( - null, - Version::getVersionForNumber(1), - $matrix - ); - $expected = " 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 \n" - . " 0 \n" - . " 1 \n" - . " 0 \n" - . " 1 \n" - . " 0 0 0 0 0 0 0 0 1 \n" - . " 1 1 1 1 1 1 1 0 \n" - . " 1 0 0 0 0 0 1 0 \n" - . " 1 0 1 1 1 0 1 0 \n" - . " 1 0 1 1 1 0 1 0 \n" - . " 1 0 1 1 1 0 1 0 \n" - . " 1 0 0 0 0 0 1 0 \n" - . " 1 1 1 1 1 1 1 0 \n"; - - $this->assertEquals($expected, $matrix->__toString()); - } - - public function testEmbedBasicPatterns2() - { - $matrix = new ByteMatrix(25, 25); - MatrixUtil::clearMatrix($matrix); - $this->methods['embedBasicPatterns']->invoke( - null, - Version::getVersionForNumber(2), - $matrix - ); - $expected = " 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 \n" - . " 0 \n" - . " 1 \n" - . " 0 \n" - . " 1 \n" - . " 0 \n" - . " 1 \n" - . " 0 \n" - . " 1 1 1 1 1 1 \n" - . " 0 0 0 0 0 0 0 0 1 1 0 0 0 1 \n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 \n" - . " 1 0 0 0 0 0 1 0 1 0 0 0 1 \n" - . " 1 0 1 1 1 0 1 0 1 1 1 1 1 \n" - . " 1 0 1 1 1 0 1 0 \n" - . " 1 0 1 1 1 0 1 0 \n" - . " 1 0 0 0 0 0 1 0 \n" - . " 1 1 1 1 1 1 1 0 \n"; - - $this->assertEquals($expected, $matrix->__toString()); - } - - public function testEmbedTypeInfo() - { - $matrix = new ByteMatrix(21, 21); - MatrixUtil::clearMatrix($matrix); - $this->methods['embedTypeInfo']->invoke( - null, - new ErrorCorrectionLevel(ErrorCorrectionLevel::M), - 5, - $matrix - ); - $expected = " 0 \n" - . " 1 \n" - . " 1 \n" - . " 1 \n" - . " 0 \n" - . " 0 \n" - . " \n" - . " 1 \n" - . " 1 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0\n" - . " \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " 0 \n" - . " 0 \n" - . " 0 \n" - . " 0 \n" - . " 0 \n" - . " 0 \n" - . " 1 \n"; - - $this->assertEquals($expected, $matrix->__toString()); - } - - public function testEmbedVersionInfo() - { - $matrix = new ByteMatrix(21, 21); - MatrixUtil::clearMatrix($matrix); - $this->methods['maybeEmbedVersionInfo']->invoke( - null, - Version::getVersionForNumber(7), - $matrix - ); - $expected = " 0 0 1 \n" - . " 0 1 0 \n" - . " 0 1 0 \n" - . " 0 1 1 \n" - . " 1 1 1 \n" - . " 0 0 0 \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " 0 0 0 0 1 0 \n" - . " 0 1 1 1 1 0 \n" - . " 1 0 0 1 1 0 \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " \n"; - - $this->assertEquals($expected, $matrix->__toString()); - } - - public function testEmbedDataBits() - { - $matrix = new ByteMatrix(21, 21); - MatrixUtil::clearMatrix($matrix); - $this->methods['embedBasicPatterns']->invoke( - null, - Version::getVersionForNumber(1), - $matrix - ); - - $bits = new BitArray(); - $this->methods['embedDataBits']->invoke( - null, - $bits, - -1, - $matrix - ); - - $expected = " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"; - - $this->assertEquals($expected, $matrix->__toString()); - } - - public function testBuildMatrix() - { - $bytes = array( - 32, 65, 205, 69, 41, 220, 46, 128, 236, 42, 159, 74, 221, 244, 169, - 239, 150, 138, 70, 237, 85, 224, 96, 74, 219 , 61 - ); - $bits = new BitArray(); - - foreach ($bytes as $byte) { - $bits->appendBits($byte, 8); - } - - $matrix = new ByteMatrix(21, 21); - MatrixUtil::buildMatrix( - $bits, - new ErrorCorrectionLevel(ErrorCorrectionLevel::H), - Version::getVersionForNumber(1), - 3, - $matrix - ); - - $expected = " 1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 1 1 0 0 1 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0\n" - . " 0 0 1 1 0 0 1 1 1 0 0 1 1 1 1 0 1 0 0 0 0\n" - . " 1 0 1 0 1 0 0 0 0 0 1 1 1 0 0 1 0 1 1 1 0\n" - . " 1 1 1 1 0 1 1 0 1 0 1 1 1 0 0 1 1 1 0 1 0\n" - . " 1 0 1 0 1 1 0 1 1 1 0 0 1 1 1 0 0 1 0 1 0\n" - . " 0 0 1 0 0 1 1 1 0 0 0 0 0 0 1 0 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 1 1\n" - . " 1 1 1 1 1 1 1 0 1 1 1 1 0 0 0 0 1 0 1 1 0\n" - . " 1 0 0 0 0 0 1 0 0 0 0 1 0 1 1 1 0 0 0 0 0\n" - . " 1 0 1 1 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1\n" - . " 1 0 1 1 1 0 1 0 1 1 0 1 0 0 0 0 0 1 1 1 0\n" - . " 1 0 1 1 1 0 1 0 1 1 1 1 0 0 0 0 1 1 1 0 0\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0\n" - . " 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 1 0 0 1 0\n"; - - $this->assertEquals($expected, $matrix->__toString()); - } - - public function testFindMsbSet() - { - $this->assertEquals(0, $this->methods['findMsbSet']->invoke(null, 0)); - $this->assertEquals(1, $this->methods['findMsbSet']->invoke(null, 1)); - $this->assertEquals(8, $this->methods['findMsbSet']->invoke(null, 0x80)); - $this->assertEquals(32, $this->methods['findMsbSet']->invoke(null, 0x80000000)); - } - - public function testCalculateBchCode() - { - // Encoding of type information. - // From Appendix C in JISX0510:2004 (p 65) - $this->assertEquals(0xdc, $this->methods['calculateBchCode']->invoke(null, 5, 0x537)); - // From http://www.swetake.com/qr/qr6.html - $this->assertEquals(0x1c2, $this->methods['calculateBchCode']->invoke(null, 0x13, 0x537)); - // From http://www.swetake.com/qr/qr11.html - $this->assertEquals(0x214, $this->methods['calculateBchCode']->invoke(null, 0x1b, 0x537)); - - // Encoding of version information. - // From Appendix D in JISX0510:2004 (p 68) - $this->assertEquals(0xc94, $this->methods['calculateBchCode']->invoke(null, 7, 0x1f25)); - $this->assertEquals(0x5bc, $this->methods['calculateBchCode']->invoke(null, 8, 0x1f25)); - $this->assertEquals(0xa99, $this->methods['calculateBchCode']->invoke(null, 9, 0x1f25)); - $this->assertEquals(0x4d3, $this->methods['calculateBchCode']->invoke(null, 10, 0x1f25)); - $this->assertEquals(0x9a6, $this->methods['calculateBchCode']->invoke(null, 20, 0x1f25)); - $this->assertEquals(0xd75, $this->methods['calculateBchCode']->invoke(null, 30, 0x1f25)); - $this->assertEquals(0xc69, $this->methods['calculateBchCode']->invoke(null, 40, 0x1f25)); - } - - public function testMakeVersionInfoBits() - { - // From Appendix D in JISX0510:2004 (p 68) - $bits = new BitArray(); - $this->methods['makeVersionInfoBits']->invoke(null, Version::getVersionForNumber(7), $bits); - $this->assertEquals(' ...XXXXX ..X..X.X ..', $bits->__toString()); - } - - public function testMakeTypeInfoBits() - { - // From Appendix D in JISX0510:2004 (p 68) - $bits = new BitArray(); - $this->methods['makeTypeInfoBits']->invoke(null, new ErrorCorrectionLevel(ErrorCorrectionLevel::M), 5, $bits); - $this->assertEquals(' X......X X..XXX.', $bits->__toString()); - } -} \ No newline at end of file diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Renderer/Text/HtmlTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Renderer/Text/HtmlTest.php deleted file mode 100644 index 0c69dd2e..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Renderer/Text/HtmlTest.php +++ /dev/null @@ -1,99 +0,0 @@ -renderer = new Html(); - $this->writer = new Writer($this->renderer); - } - - public function testBasicRender() - { - $content = 'foobar'; - $expected = - '
' .
-            "                       \n" .
-            " ███████ █████ ███████ \n" .
-            " â–ˆ     â–ˆ  â–ˆ â–ˆ  â–ˆ     â–ˆ \n" .
-            " █ ███ █  ██   █ ███ █ \n" .
-            " █ ███ █  ███  █ ███ █ \n" .
-            " █ ███ █   █ █ █ ███ █ \n" .
-            " █     █    ██ █     █ \n" .
-            " ███████ █ █ █ ███████ \n" .
-            "         █████         \n" .
-            " ██ ██ █  ██ █ █     █ \n" .
-            "    ██    ██ █ █ ██    \n" .
-            "  ████████ █  ██ █  ██ \n" .
-            "           ██      █ █ \n" .
-            "  ██  ███  █   █  █  █ \n" .
-            "         █ ███    █ █  \n" .
-            " ███████  ██ ██████    \n" .
-            " █     █   ████   ██   \n" .
-            " █ ███ █ ██ ██ ██ █ ██ \n" .
-            " █ ███ █ ██ ██  █ ██   \n" .
-            " █ ███ █   █   █ ██ ██ \n" .
-            " █     █ ███  ███ ████ \n" .
-            " ███████ ████   ██     \n" .
-            "                       \n" .
-            '
' - ; - - $qrCode = Encoder::encode( - $content, - new ErrorCorrectionLevel(ErrorCorrectionLevel::L), - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->assertEquals($expected, $this->renderer->render($qrCode)); - } - - public function testSetStyle() - { - $content = 'foobar'; - $qrCode = Encoder::encode( - $content, - new ErrorCorrectionLevel(ErrorCorrectionLevel::L), - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->renderer->setStyle('bar'); - $this->assertEquals('bar', $this->renderer->getStyle()); - $this->assertStringMatchesFormat('%astyle="bar"%a', $this->renderer->render($qrCode)); - } - - public function testSetClass() - { - $content = 'foobar'; - $qrCode = Encoder::encode( - $content, - new ErrorCorrectionLevel(ErrorCorrectionLevel::L), - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->renderer->setClass('bar'); - $this->assertEquals('bar', $this->renderer->getClass()); - $this->assertStringMatchesFormat('%aclass="bar"%a', $this->renderer->render($qrCode)); - } -} diff --git a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Renderer/Text/TextTest.php b/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Renderer/Text/TextTest.php deleted file mode 100644 index d94e8e5d..00000000 --- a/vendor/bacon/bacon-qr-code/tests/BaconQrCode/Renderer/Text/TextTest.php +++ /dev/null @@ -1,149 +0,0 @@ -renderer = new Plain(); - $this->writer = new Writer($this->renderer); - } - - public function testBasicRender() - { - $content = 'foobar'; - $expected = - " \n" . - " ███████ █████ ███████ \n" . - " █ █ █ █ █ █ \n" . - " █ ███ █ ██ █ ███ █ \n" . - " █ ███ █ ███ █ ███ █ \n" . - " █ ███ █ █ █ █ ███ █ \n" . - " █ █ ██ █ █ \n" . - " ███████ █ █ █ ███████ \n" . - " █████ \n" . - " ██ ██ █ ██ █ █ █ \n" . - " ██ ██ █ █ ██ \n" . - " ████████ █ ██ █ ██ \n" . - " ██ █ █ \n" . - " ██ ███ █ █ █ █ \n" . - " █ ███ █ █ \n" . - " ███████ ██ ██████ \n" . - " █ █ ████ ██ \n" . - " █ ███ █ ██ ██ ██ █ ██ \n" . - " █ ███ █ ██ ██ █ ██ \n" . - " █ ███ █ █ █ ██ ██ \n" . - " █ █ ███ ███ ████ \n" . - " ███████ ████ ██ \n" . - " \n" - ; - - $qrCode = Encoder::encode( - $content, - new ErrorCorrectionLevel(ErrorCorrectionLevel::L), - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->assertEquals($expected, $this->renderer->render($qrCode)); - } - - public function testBasicRenderNoMargins() - { - $content = 'foobar'; - $expected = - "███████ █████ ███████\n" . - "█ █ █ █ █ █\n" . - "█ ███ █ ██ █ ███ █\n" . - "█ ███ █ ███ █ ███ █\n" . - "█ ███ █ █ █ █ ███ █\n" . - "█ █ ██ █ █\n" . - "███████ █ █ █ ███████\n" . - " █████ \n" . - "██ ██ █ ██ █ █ █\n" . - " ██ ██ █ █ ██ \n" . - " ████████ █ ██ █ ██\n" . - " ██ █ █\n" . - " ██ ███ █ █ █ █\n" . - " █ ███ █ █ \n" . - "███████ ██ ██████ \n" . - "█ █ ████ ██ \n" . - "█ ███ █ ██ ██ ██ █ ██\n" . - "█ ███ █ ██ ██ █ ██ \n" . - "█ ███ █ █ █ ██ ██\n" . - "█ █ ███ ███ ████\n" . - "███████ ████ ██ \n" - ; - - $qrCode = Encoder::encode( - $content, - new ErrorCorrectionLevel(ErrorCorrectionLevel::L), - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->renderer->setMargin(0); - $this->assertEquals(0, $this->renderer->getMargin()); - $this->assertEquals($expected, $this->renderer->render($qrCode)); - } - - public function testBasicRenderCustomChar() - { - $content = 'foobar'; - $expected = - "-----------------------\n" . - "-#######-#####-#######-\n" . - "-#-----#--#-#--#-----#-\n" . - "-#-###-#--##---#-###-#-\n" . - "-#-###-#--###--#-###-#-\n" . - "-#-###-#---#-#-#-###-#-\n" . - "-#-----#----##-#-----#-\n" . - "-#######-#-#-#-#######-\n" . - "---------#####---------\n" . - "-##-##-#--##-#-#-----#-\n" . - "----##----##-#-#-##----\n" . - "--########-#--##-#--##-\n" . - "-----------##------#-#-\n" . - "--##--###--#---#--#--#-\n" . - "---------#-###----#-#--\n" . - "-#######--##-######----\n" . - "-#-----#---####---##---\n" . - "-#-###-#-##-##-##-#-##-\n" . - "-#-###-#-##-##--#-##---\n" . - "-#-###-#---#---#-##-##-\n" . - "-#-----#-###--###-####-\n" . - "-#######-####---##-----\n" . - "-----------------------\n" - ; - - $qrCode = Encoder::encode( - $content, - new ErrorCorrectionLevel(ErrorCorrectionLevel::L), - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->renderer->setFullBlock('#'); - $this->renderer->setEmptyBlock('-'); - $this->assertEquals('#', $this->renderer->getFullBlock()); - $this->assertEquals('-', $this->renderer->getEmptyBlock()); - $this->assertEquals($expected, $this->renderer->render($qrCode)); - } -} diff --git a/vendor/bacon/bacon-qr-code/tests/bootstrap.php b/vendor/bacon/bacon-qr-code/tests/bootstrap.php deleted file mode 100644 index 05a49415..00000000 --- a/vendor/bacon/bacon-qr-code/tests/bootstrap.php +++ /dev/null @@ -1,10 +0,0 @@ - - - - . - - - - ../src/ - - - diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index 43c2713f..9e00f8d3 100644 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -6,7 +6,5 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( - 'ZendXml\\' => array($vendorDir . '/zendframework/zendxml/library'), 'PicoFeed' => array($vendorDir . '/fguillot/picofeed/lib'), - 'BaconQrCode' => array($vendorDir . '/bacon/bacon-qr-code/src'), ); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 00ff6f81..5b6cc63b 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( - 'RobThree\\Auth\\' => array($vendorDir . '/robthree/twofactorauth/lib'), + 'ZendXml\\' => array($vendorDir . '/zendframework/zendxml/src'), 'Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'), ); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 6b54c4e2..47980419 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -7,9 +7,9 @@ namespace Composer\Autoload; class ComposerStaticInitda370287ab6d5b8a28188afe08f659c5 { public static $prefixLengthsPsr4 = array ( - 'R' => + 'Z' => array ( - 'RobThree\\Auth\\' => 14, + 'ZendXml\\' => 8, ), 'C' => array ( @@ -18,9 +18,9 @@ class ComposerStaticInitda370287ab6d5b8a28188afe08f659c5 ); public static $prefixDirsPsr4 = array ( - 'RobThree\\Auth\\' => + 'ZendXml\\' => array ( - 0 => __DIR__ . '/..' . '/robthree/twofactorauth/lib', + 0 => __DIR__ . '/..' . '/zendframework/zendxml/src', ), 'Composer\\Semver\\' => array ( @@ -29,13 +29,6 @@ class ComposerStaticInitda370287ab6d5b8a28188afe08f659c5 ); public static $prefixesPsr0 = array ( - 'Z' => - array ( - 'ZendXml\\' => - array ( - 0 => __DIR__ . '/..' . '/zendframework/zendxml/library', - ), - ), 'P' => array ( 'PicoFeed' => @@ -43,13 +36,6 @@ class ComposerStaticInitda370287ab6d5b8a28188afe08f659c5 0 => __DIR__ . '/..' . '/fguillot/picofeed/lib', ), ), - 'B' => - array ( - 'BaconQrCode' => - array ( - 0 => __DIR__ . '/..' . '/bacon/bacon-qr-code/src', - ), - ), ); public static function getInitializer(ClassLoader $loader) diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 3d350743..9f764edc 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1,52 +1,4 @@ [ - { - "name": "bacon/bacon-qr-code", - "version": "1.0.3", - "version_normalized": "1.0.3.0", - "source": { - "type": "git", - "url": "https://github.com/Bacon/BaconQrCode.git", - "reference": "5a91b62b9d37cee635bbf8d553f4546057250bee" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/5a91b62b9d37cee635bbf8d553f4546057250bee", - "reference": "5a91b62b9d37cee635bbf8d553f4546057250bee", - "shasum": "" - }, - "require": { - "ext-iconv": "*", - "php": "^5.4|^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8" - }, - "suggest": { - "ext-gd": "to generate QR code images" - }, - "time": "2017-10-17T09:59:25+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "BaconQrCode": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Ben Scholzen 'DASPRiD'", - "email": "mail@dasprids.de", - "homepage": "http://www.dasprids.de", - "role": "Developer" - } - ], - "description": "BaconQrCode is a QR code generator for PHP.", - "homepage": "https://github.com/Bacon/BaconQrCode" - }, { "name": "composer/semver", "version": "1.4.2", @@ -167,92 +119,40 @@ "homepage": "https://github.com/miniflux/picoFeed", "abandoned": true }, - { - "name": "robthree/twofactorauth", - "version": "1.6.1", - "version_normalized": "1.6.1.0", - "source": { - "type": "git", - "url": "https://github.com/RobThree/TwoFactorAuth.git", - "reference": "a77e7d822343bb88112baef808839cfae7bc5abb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/RobThree/TwoFactorAuth/zipball/a77e7d822343bb88112baef808839cfae7bc5abb", - "reference": "a77e7d822343bb88112baef808839cfae7bc5abb", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "@stable" - }, - "time": "2017-11-06T17:55:56+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "RobThree\\Auth\\": "lib" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Rob Janssen", - "homepage": "http://robiii.me", - "role": "Developer" - } - ], - "description": "Two Factor Authentication", - "homepage": "https://github.com/RobThree/TwoFactorAuth", - "keywords": [ - "Authentication", - "MFA", - "Multi Factor Authentication", - "Two Factor Authentication", - "authenticator", - "authy", - "php", - "tfa" - ] - }, { "name": "zendframework/zendxml", - "version": "1.0.2", - "version_normalized": "1.0.2.0", + "version": "1.1.0", + "version_normalized": "1.1.0.0", "source": { "type": "git", "url": "https://github.com/zendframework/ZendXml.git", - "reference": "7b64507bc35d841c9c5802d67f6f87ef8e1a58c9" + "reference": "267db6a2c431a08a8f8ff0f1f4c302a5ba6f5b99" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/ZendXml/zipball/7b64507bc35d841c9c5802d67f6f87ef8e1a58c9", - "reference": "7b64507bc35d841c9c5802d67f6f87ef8e1a58c9", + "url": "https://api.github.com/repos/zendframework/ZendXml/zipball/267db6a2c431a08a8f8ff0f1f4c302a5ba6f5b99", + "reference": "267db6a2c431a08a8f8ff0f1f4c302a5ba6f5b99", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^5.6 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "^3.7 || ^4.0", - "squizlabs/php_codesniffer": "^1.5" + "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.4", + "zendframework/zend-coding-standard": "~1.0.0" }, - "time": "2016-02-04T21:02:08+00:00", + "time": "2018-04-30T15:11:04+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.1.x-dev", + "dev-develop": "1.2.x-dev" } }, "installation-source": "dist", "autoload": { - "psr-0": { - "ZendXml\\": "library/" + "psr-4": { + "ZendXml\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -260,11 +160,11 @@ "BSD-3-Clause" ], "description": "Utility library for XML usage, best practices, and security in PHP", - "homepage": "http://packages.zendframework.com/", "keywords": [ + "ZendFramework", "security", "xml", - "zf2" + "zf" ] } ] diff --git a/vendor/robthree/twofactorauth/.gitignore b/vendor/robthree/twofactorauth/.gitignore deleted file mode 100644 index 8a25841c..00000000 --- a/vendor/robthree/twofactorauth/.gitignore +++ /dev/null @@ -1,189 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -build/ -bld/ -[Bb]in/ -[Oo]bj/ - -# Roslyn cache directories -*.ide/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -#NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding addin-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# If using the old MSBuild-Integrated Package Restore, uncomment this: -#!**/packages/repositories.config - -# Windows Azure Build Output -csx/ -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings -node_modules/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# Composer -/vendor - -# .vs -.vs/ \ No newline at end of file diff --git a/vendor/robthree/twofactorauth/.travis.yml b/vendor/robthree/twofactorauth/.travis.yml deleted file mode 100644 index 204dc63a..00000000 --- a/vendor/robthree/twofactorauth/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: php - -dist: trusty -matrix: - include: - - php: 5.3 - dist: precise - -php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - hhvm - -script: - - if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then phpunit --coverage-text tests ; fi \ No newline at end of file diff --git a/vendor/robthree/twofactorauth/LICENSE b/vendor/robthree/twofactorauth/LICENSE deleted file mode 100644 index 75a96312..00000000 --- a/vendor/robthree/twofactorauth/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014-2015 Rob Janssen - -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/robthree/twofactorauth/README.md b/vendor/robthree/twofactorauth/README.md deleted file mode 100644 index ba6cfeab..00000000 --- a/vendor/robthree/twofactorauth/README.md +++ /dev/null @@ -1,197 +0,0 @@ -# ![Logo](https://raw.githubusercontent.com/RobThree/TwoFactorAuth/master/logo.png) PHP library for Two Factor Authentication - -[![Build status](https://img.shields.io/travis/RobThree/TwoFactorAuth.svg?style=flat-square)](https://travis-ci.org/RobThree/TwoFactorAuth/) [![Latest Stable Version](https://img.shields.io/packagist/v/robthree/twofactorauth.svg?style=flat-square)](https://packagist.org/packages/robthree/twofactorauth) [![License](https://img.shields.io/packagist/l/robthree/twofactorauth.svg?style=flat-square)](LICENSE) [![Downloads](https://img.shields.io/packagist/dt/robthree/twofactorauth.svg?style=flat-square)](https://packagist.org/packages/robthree/twofactorauth) [![HHVM Status](https://img.shields.io/hhvm/RobThree/TwoFactorAuth.svg?style=flat-square)](http://hhvm.h4cc.de/package/robthree/twofactorauth) [![Code Climate](https://img.shields.io/codeclimate/github/RobThree/TwoFactorAuth.svg?style=flat-square)](https://codeclimate.com/github/RobThree/TwoFactorAuth) [![PayPal donate button](http://img.shields.io/badge/paypal-donate-orange.svg?style=flat-square)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6MB5M2SQLP636 "Keep me off the streets") - -PHP library for [two-factor (or multi-factor) authentication](http://en.wikipedia.org/wiki/Multi-factor_authentication) using [TOTP](http://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm) and [QR-codes](http://en.wikipedia.org/wiki/QR_code). Inspired by, based on but most importantly an *improvement* on '[PHPGangsta/GoogleAuthenticator](https://github.com/PHPGangsta/GoogleAuthenticator)'. There's a [.Net implementation](https://github.com/RobThree/TwoFactorAuth.Net) of this library as well. - -

- -

- -## Requirements - -* Tested on PHP 5.3, 5.4, 5.5 and 5.6, 7.0, 7.1 and HHVM -* [cURL](http://php.net/manual/en/book.curl.php) when using the provided `GoogleQRCodeProvider` (default), `QRServerProvider` or `QRicketProvider` but you can also provide your own QR-code provider. -* [random_bytes()](http://php.net/manual/en/function.random-bytes.php), [MCrypt](http://php.net/manual/en/book.mcrypt.php), [OpenSSL](http://php.net/manual/en/book.openssl.php) or [Hash](http://php.net/manual/en/book.hash.php) depending on which built-in RNG you use (TwoFactorAuth will try to 'autodetect' and use the best available); however: feel free to provide your own (CS)RNG. - -## Installation - -Run the following command: - -`php composer.phar require robthree/twofactorauth` - -## Quick start - -If you want to hit the ground running then have a look at the [demo](demo/demo.php). It's very simple and easy! - -## Usage - -Here are some code snippets that should help you get started... - -````php -// Create a TwoFactorAuth instance -$tfa = new RobThree\Auth\TwoFactorAuth('My Company'); -```` - -The TwoFactorAuth class constructor accepts 7 parameters (all optional): - -Parameter | Default value | Use -------------------|---------------|-------------------------------------------------- -`$issuer` | `null` | Will be displayed in the app as issuer name -`$digits` | `6` | The number of digits the resulting codes will be -`$period` | `30` | The number of seconds a code will be valid -`$algorithm` | `sha1` | The algorithm used -`$qrcodeprovider` | `null` | QR-code provider (more on this later) -`$rngprovider` | `null` | Random Number Generator provider (more on this later) -`$timeprovider` | `null` | Time provider (more on this later) - -These parameters are all '`write once`'; the class will, for it's lifetime, use these values when generating / calculating codes. The number of digits, the period and algorithm are all set to values Google's Authticator app uses (and supports). You may specify `8` digits, a period of `45` seconds and the `sha256` algorithm but the authenticator app (be it Google's implementation, Authy or any other app) may or may not support these values. Your mileage may vary; keep it on the safe side if you don't control which app your audience uses. - -### Step 1: Set up secret shared key - -When a user wants to setup two-factor auth (or, more correctly, multi-factor auth) you need to create a secret. This will be your **shared secret**. This secret will need to be entered by the user in their app. This can be done manually, in which case you simply display the secret and have the user type it in the app: - -````php -$secret = $tfa->createSecret(); -```` - -The `createSecret()` method accepts two arguments: `$bits` (default: `80`) and `$requirecryptosecure` (default: `true`). The former is the number of bits generated for the shared secret. Make sure this argument is a multiple of 8 and, again, keep in mind that not all combinations may be supported by all apps. Google authenticator seems happy with 80 and 160, the default is set to 80 because that's what most sites (that I know of) currently use; however a value of 160 or higher is recommended (see [RFC 4226 - Algorithm Requirements](https://tools.ietf.org/html/rfc4226#section-4)). The latter is used to ensure that the secret is cryptographically secure; if you don't care very much for cryptographically secure secrets you can specify `false` and use a **non**-cryptographically secure RNG provider. - -````php -// Display shared secret -

Please enter the following code in your app: ''

-```` - -Another, more user-friendly, way to get the shared secret into the app is to generate a [QR-code](http://en.wikipedia.org/wiki/QR_code) which can be scanned by the app. To generate these QR codes you can use any one of the built-in `QRProvider` classes: - -1. `GoogleQRCodeProvider` (default) -2. `QRServerProvider` -3. `QRicketProvider` - -...or implement your own provider. To implement your own provider all you need to do is implement the `IQRCodeProvider` interface. You can use the built-in providers mentioned before to serve as an example or read the next chapter in this file. The built-in classes all use a 3rd (e.g. external) party (Google, QRServer and QRicket) for the hard work of generating QR-codes (note: each of these services might at some point not be available or impose limitations to the number of codes generated per day, hour etc.). You could, however, easily use a project like [PHP QR Code](http://phpqrcode.sourceforge.net/) (or one of the [many others](https://packagist.org/search/?q=qr)) to generate your QR-codes without depending on external sources. Later on we'll [demonstrate](#qr-code-providers) how to do this. - -The built-in providers all have some provider-specific 'tweaks' you can 'apply'. Some provide support for different colors, others may let you specify the desired image-format etc. What they all have in common is that they return a QR-code as binary blob which, in turn, will be turned into a [data URI](http://en.wikipedia.org/wiki/Data_URI_scheme) by the `TwoFactorAuth` class. This makes it easy for you to display the image without requiring extra 'roundtrips' from browser to server and vice versa. - -````php -// Display QR code to user -

Scan the following image with your app:

-

-```` - -When outputting a QR-code you can choose a `$label` for the user (which, when entering a shared secret manually, will have to be chosen by the user). This label may be an empty string or `null`. Also a `$size` may be specified (in pixels, width == height) for which we use a default value of `200`. - -### Step 2: Verify secret shared key - -When the shared secret is added to the app, the app will be ready to start generating codes which 'expire' each '`$period`' number of seconds. To make sure the secret was entered, or scanned, correctly you need to verify this by having the user enter a generated code. To check if the generated code is valid you call the `verifyCode()` method: - -````php -// Verify code -$result = $tfa->verifyCode($_SESSION['secret'], $_POST['verification']); -```` - -`verifyCode()` will return either `true` (the code was valid) or `false` (the code was invalid; no points for you!). You may need to store `$secret` in a `$_SESSION` or other persistent storage between requests. The `verifyCode()` accepts, aside from `$secret` and `$code`, two more parameters. The first being `$discrepancy`. Since TOTP codes are based on time("slices") it is very important that the server (but also client) have a correct date/time. But because the two *may* differ a bit we usually allow a certain amount of leeway. Because generated codes are valid for a specific period (remember the `$period` parameter in the `TwoFactorAuth`'s constructor?) we usually check the period directly before and the period directly after the current time when validating codes. So when the current time is `14:34:21`, which results in a 'current timeslice' of `14:34:00` to `14:34:30` we also calculate/verify the codes for `14:33:30` to `14:34:00` and for `14:34:30` to `14:35:00`. This gives us a 'window' of `14:33:30` to `14:35:00`. The `$discrepancy` parameter specifies how many periods (or: timeslices) we check in either direction of the current time. The default `$discrepancy` of `1` results in (max.) 3 period checks: -1, current and +1 period. A `$discrepancy` of `4` would result in a larger window (or: bigger time difference between client and server) of -4, -3, -2, -1, current, +1, +2, +3 and +4 periods. - -The second parameter `$time` allows you to check a code for a specific point in time. This parameter has no real practical use but can be handy for unittesting etc. The default value, `null`, means: use the current time. - -### Step 3: Store `$secret` with user and we're done! - -Ok, so now the code has been verified and found to be correct. Now we can store the `$secret` with our user in our database (or elsewhere) and whenever the user begins a new session we ask for a code generated by the authentication app of their choice. All we need to do is call `verifyCode()` again with the shared secret and the entered code and we know if the user is legit or not. - -Simple as 1-2-3. - -All we need is 3 methods and a constructor: - -````php -public function __construct( - $issuer = null, - $digits = 6, - $period = 30, - $algorithm = 'sha1', - RobThree\Auth\Providers\Qr\IQRCodeProvider $qrcodeprovider = null, - RobThree\Auth\Providers\Rng\IRNGProvider $rngprovider = null -); -public function createSecret($bits = 80, $requirecryptosecure = true): string; -public function getQRCodeImageAsDataUri($label, $secret, $size = 200): string; -public function verifyCode($secret, $code, $discrepancy = 1, $time = null): bool; -```` - -### QR-code providers - -As mentioned before, this library comes with three 'built-in' QR-code providers. This chapter will touch the subject a bit but most of it should be self-explanatory. The `TwoFactorAuth`-class accepts a `$qrcodeprovider` parameter which lets you specify a built-in or custom QR-code provider. All three built-in providers do a simple HTTP request to retrieve an image using cURL and implement the [`IQRCodeProvider`](lib/Providers/Qr/IQRCodeProvider.php) interface which is all you need to implement to write your own QR-code provider. - -The default provider is the [`GoogleQRCodeProvider`](lib/Providers/Qr/GoogleQRCodeProvider.php) which uses the [Google Chart Tools](https://developers.google.com/chart/infographics/docs/qr_codes) to render QR-codes. Then we have the [`QRServerProvider`](lib/Providers/Qr/QRServerProvider.php) which uses the [goqr.me API](http://goqr.me/api/doc/create-qr-code/) and finally we have the [`QRicketProvider`](lib/Providers/Qr/QRicketProvider.php) which uses the [QRickit API](http://qrickit.com/qrickit_apps/qrickit_api.php). All three inherit from a common (abstract) baseclass named [`BaseHTTPQRCodeProvider`](lib/Providers/Qr/BaseHTTPQRCodeProvider.php) because all three share the same functionality: retrieve an image from a 3rd party over HTTP. All three classes have constructors that allow you to tweak some settings and most, if not all, arguments should speak for themselves. If you're not sure which values are supported, click the links in this paragraph for documentation on the API's that are utilized by these classes. - -If you don't like any of the built-in classes because you don't want to rely on external resources for example or because you're paranoid about sending the TOTP secret to these 3rd parties (which is useless to them since they miss *at least one* other factor in the [MFA process](http://en.wikipedia.org/wiki/Multi-factor_authentication)), feel tree to implement your own. The `IQRCodeProvider` interface couldn't be any simpler. All you need to do is implement 2 methods: - -````php -getMimeType(); -getQRCodeImage($qrtext, $size); -```` - -The `getMimeType()` method should return the [MIME type](http://en.wikipedia.org/wiki/Internet_media_type) of the image that is returned by our implementation of `getQRCodeImage()`. In this example it's simply `image/png`. The `getQRCodeImage()` method is passed two arguments: `$qrtext` and `$size`. The latter, `$size`, is simply the width/height in pixels of the image desired by the caller. The first, `$qrtext` is the text that should be encoded in the QR-code. An example of such a text would be: - -`otpauth://totp/LABEL:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=ISSUER` - -All you need to do is return the QR-code as binary image data and you're done. All parts of the `$qrtext` have been escaped for you (but note: you *may* need to escape the entire `$qrtext` just once more when passing the data to another server as GET-parameter). - -Let's see if we can use [PHP QR Code](http://phpqrcode.sourceforge.net/) to implement our own, custom, no-3rd-parties-allowed-here, provider. We start with downloading the [required (single) file](https://github.com/t0k4rt/phpqrcode/blob/master/phpqrcode.php) and putting it in the directory where `TwoFactorAuth.php` is located as well. Now let's implement the provider: create another file named `myprovider.php` in the `Providers\Qr` directory and paste in this content: - -````php -createSecret(); -?> -

-```` - -Voilà. Couldn't make it any simpler. - -### RNG providers - -This library also comes with three 'built-in' RNG providers ([Random Number Generator](https://en.wikipedia.org/wiki/Random_number_generation)). The RNG provider generates a number of random bytes and returns these bytes as a string. These values are then used to create the secret. By default (no RNG provider specified) TwoFactorAuth will try to determine the best available RNG provider to use. It will, by default, try to use the [`CSRNGProvider`](lib/Providers/Rng/CSRNGProvider.php) for PHP7+ or the [`MCryptRNGProvider`](lib/Providers/Rng/MCryptRNGProvider.php); if this is not available/supported for any reason it will try to use the [`OpenSSLRNGProvider`](lib/Providers/Rng/OpenSSLRNGProvider.php) and if that is also not available/supported it will try to use the final RNG provider: [`HashRNGProvider`](lib/Providers/Rng/HashRNGProvider.php). Each of these providers use their own method of generating a random sequence of bytes. The first three (`CSRNGProvider`, `OpenSSLRNGProvider` and `MCryptRNGProvider`) return a [cryptographically secure](https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator) sequence of random bytes whereas the `HashRNGProvider` returns a **non-cryptographically secure** sequence. - -You can easily implement your own `RNGProvider` by simply implementing the `IRNGProvider` interface. Each of the 'built-in' RNG providers have some constructor parameters that allow you to 'tweak' some of the settings to use when creating the random bytes such as which source to use (`MCryptRNGProvider`) or which hashing algorithm (`HashRNGProvider`). I encourage you to have a look at some of the ['built-in' RNG providers](lib/Providers/Rng) for details and the [`IRNGProvider` interface](lib/Providers/Rng/IRNGProvider.php). - -### Time providers - -Another set of providers in this library are the Time Providers; this library provides three 'built-in' ones. The default Time Provider used is the [`LocalMachineTimeProvider`](lib/Providers/Time/LocalMachineTimeProvider.php); this provider simply returns the output of `Time()` and is *highly recommended* as default provider. The [`HttpTimeProvider`](lib/Providers/Time/HttpTimeProvider.php) executes a `HEAD` request against a given webserver (default: google.com) and tries to extract the `Date:`-HTTP header and returns it's date. Other url's/domains can be used by specifying the url in the constructor. The final Time Provider is the [`ConvertUnixTimeDotComTimeProvider`](lib/Providers/Time/ConvertUnixTimeDotComTimeProvider.php) which does a HTTP request to `convert-unix-time.com/api` and decodes the `JSON` result to retrieve the time. - -You can easily implement your own `TimeProvider` by simply implementing the `ITimeProvider` interface. - -As to *why* these Time Providers are implemented: it allows the TwoFactorAuth library to ensure the hosts time is correct (or rather: within a margin). You can use the `ensureCorrectTime()` method to ensure the hosts time is correct. By default this method will compare the hosts time (returned by calling `time()` on the `LocalMachineTimeProvider`) to Google's and convert-unix-time.com's current time. You can pass an array of `ITimeProvider`s and specify the `leniency` (second argument) allowed (default: 5 seconds). The method will throw when the TwoFactorAuth's timeprovider (which can be any `ITimeProvider`, see constructor) differs more than the given amount of seconds from any of the given `ITimeProviders`. We advise to call this method sparingly when relying on 3rd parties (which both the `HttpTimeProvider` and `ConvertUnixTimeDotComTimeProvider` do) or, if you need to ensure time is correct on a (very) regular basis to implement an `ITimeProvider` that is more efficient than the 'built-in' ones (like use a GPS signal). The `ensureCorrectTime()` method is mostly to be used to make sure the server is configured correctly. - -## Integrations - -- [CakePHP 3](https://github.com/andrej-griniuk/cakephp-two-factor-auth) - -## License - -Licensed under MIT license. See [LICENSE](https://raw.githubusercontent.com/RobThree/TwoFactorAuth/master/LICENSE) for details. - -[Logo / icon](http://www.iconmay.com/Simple/Travel_and_Tourism_Part_2/luggage_lock_safety_baggage_keys_cylinder_lock_hotel_travel_tourism_luggage_lock_icon_465) under CC0 1.0 Universal (CC0 1.0) Public Domain Dedication ([Archived page](http://riii.nl/tm7ap)) diff --git a/vendor/robthree/twofactorauth/TwoFactorAuth.phpproj b/vendor/robthree/twofactorauth/TwoFactorAuth.phpproj deleted file mode 100644 index 7fa2a58e..00000000 --- a/vendor/robthree/twofactorauth/TwoFactorAuth.phpproj +++ /dev/null @@ -1,69 +0,0 @@ - - - - Debug - TwoFactorAuth - {e569f53a-a604-4579-91ce-4e35b27da47b} - TwoFactorAuth - Library - {A0786B88-2ADB-4C21-ABE8-AA2D79766269} - False - PHPDev - None - True - 41315 - localhost - http://localhost:41315/ - PHP - 7.0 - - - true - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/robthree/twofactorauth/TwoFactorAuth.sln b/vendor/robthree/twofactorauth/TwoFactorAuth.sln deleted file mode 100644 index df901f6a..00000000 --- a/vendor/robthree/twofactorauth/TwoFactorAuth.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30723.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{A0786B88-2ADB-4C21-ABE8-AA2D79766269}") = "TwoFactorAuth", "TwoFactorAuth.phpproj", "{E569F53A-A604-4579-91CE-4E35B27DA47B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E569F53A-A604-4579-91CE-4E35B27DA47B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E569F53A-A604-4579-91CE-4E35B27DA47B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E569F53A-A604-4579-91CE-4E35B27DA47B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E569F53A-A604-4579-91CE-4E35B27DA47B}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/vendor/robthree/twofactorauth/composer.json b/vendor/robthree/twofactorauth/composer.json deleted file mode 100644 index 1ea66ab0..00000000 --- a/vendor/robthree/twofactorauth/composer.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "robthree/twofactorauth", - "description": "Two Factor Authentication", - "version": "1.6.1", - "type": "library", - "keywords": [ "Authentication", "Two Factor Authentication", "Multi Factor Authentication", "TFA", "MFA", "PHP", "Authenticator", "Authy" ], - "homepage": "https://github.com/RobThree/TwoFactorAuth", - "license": "MIT", - "authors": [ - { - "name": "Rob Janssen", - "homepage": "http://robiii.me", - "role": "Developer" - } - ], - "support": { - "issues": "https://github.com/RobThree/TwoFactorAuth/issues", - "source": "https://github.com/RobThree/TwoFactorAuth" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "@stable" - }, - "autoload": { - "psr-4": { - "RobThree\\Auth\\": "lib" - } - }, - "autoload-dev": { - "psr-4": { - "RobThree\\Auth\\Test\\": "tests" - } - } -} diff --git a/vendor/robthree/twofactorauth/composer.lock b/vendor/robthree/twofactorauth/composer.lock deleted file mode 100644 index 63df9377..00000000 --- a/vendor/robthree/twofactorauth/composer.lock +++ /dev/null @@ -1,980 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "content-hash": "9647de85f54ba6db237f5ff42ff85a1f", - "packages": [], - "packages-dev": [ - { - "name": "doctrine/instantiator", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", - "shasum": "" - }, - "require": { - "php": ">=5.3,<8.0-DEV" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", - "keywords": [ - "constructor", - "instantiate" - ], - "time": "2015-06-14T21:17:01+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "2.0.4", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "dflydev/markdown": "~1.0", - "erusev/parsedown": "~1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "phpDocumentor": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "mike.vanriel@naenius.com" - } - ], - "time": "2015-02-03T12:10:50+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "v1.6.2", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "6c52c2722f8460122f96f86346600e1077ce22cb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/6c52c2722f8460122f96f86346600e1077ce22cb", - "reference": "6c52c2722f8460122f96f86346600e1077ce22cb", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", - "sebastian/comparator": "^1.1", - "sebastian/recursion-context": "^1.0|^2.0" - }, - "require-dev": { - "phpspec/phpspec": "^2.0", - "phpunit/phpunit": "^4.8 || ^5.6.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6.x-dev" - } - }, - "autoload": { - "psr-0": { - "Prophecy\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "time": "2016-11-21T14:58:47+00:00" - }, - { - "name": "phpunit/php-code-coverage", - "version": "2.2.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "^1.3.2", - "sebastian/version": "~1.0" - }, - "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4" - }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2015-10-06T15:47:00+00:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "1.4.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "time": "2016-10-03T07:40:28+00:00" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2015-06-21T13:50:34+00:00" - }, - { - "name": "phpunit/php-timer", - "version": "1.0.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/38e9124049cf1a164f1e4537caf19c99bf1eb260", - "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4|~5" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "time": "2016-05-12T18:03:57+00:00" - }, - { - "name": "phpunit/php-token-stream", - "version": "1.4.9", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "3b402f65a4cc90abf6e1104e388b896ce209631b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3b402f65a4cc90abf6e1104e388b896ce209631b", - "reference": "3b402f65a4cc90abf6e1104e388b896ce209631b", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2016-11-15T14:06:22+00:00" - }, - { - "name": "phpunit/phpunit", - "version": "4.8.35", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "791b1a67c25af50e230f841ee7a9c6eba507dc87" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/791b1a67c25af50e230f841ee7a9c6eba507dc87", - "reference": "791b1a67c25af50e230f841ee7a9c6eba507dc87", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpspec/prophecy": "^1.3.1", - "phpunit/php-code-coverage": "~2.1", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.2.2", - "sebastian/diff": "~1.2", - "sebastian/environment": "~1.3", - "sebastian/exporter": "~1.2", - "sebastian/global-state": "~1.0", - "sebastian/version": "~1.0", - "symfony/yaml": "~2.1|~3.0" - }, - "suggest": { - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.8.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2017-02-06T05:18:07+00:00" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "2.3.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2", - "sebastian/exporter": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "time": "2015-10-02T06:51:40+00:00" - }, - { - "name": "sebastian/comparator", - "version": "1.2.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2 || ~2.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "time": "2017-01-29T09:50:25+00:00" - }, - { - "name": "sebastian/diff", - "version": "1.4.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff" - ], - "time": "2015-12-08T07:14:41+00:00" - }, - { - "name": "sebastian/environment", - "version": "1.3.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "time": "2016-08-18T05:49:44+00:00" - }, - { - "name": "sebastian/exporter", - "version": "1.2.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~1.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2016-06-17T09:04:28+00:00" - }, - { - "name": "sebastian/global-state", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "time": "2015-10-12T03:26:01+00:00" - }, - { - "name": "sebastian/recursion-context", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2015-11-11T19:50:13+00:00" - }, - { - "name": "sebastian/version", - "version": "1.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "shasum": "" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-06-21T13:59:46+00:00" - }, - { - "name": "symfony/yaml", - "version": "v2.8.17", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "322a8c2dfbca15ad6b1b27e182899f98ec0e0153" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/322a8c2dfbca15ad6b1b27e182899f98ec0e0153", - "reference": "322a8c2dfbca15ad6b1b27e182899f98ec0e0153", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "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 Yaml Component", - "homepage": "https://symfony.com", - "time": "2017-01-21T16:40:50+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": { - "phpunit/phpunit": 0 - }, - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=5.3.0" - }, - "platform-dev": [] -} diff --git a/vendor/robthree/twofactorauth/demo/demo.php b/vendor/robthree/twofactorauth/demo/demo.php deleted file mode 100644 index 996dd928..00000000 --- a/vendor/robthree/twofactorauth/demo/demo.php +++ /dev/null @@ -1,35 +0,0 @@ - - - - Demo - - -
    - First create a secret and associate it with a user'; - $secret = $tfa->createSecret(160); // Though the default is an 80 bits secret (for backwards compatibility reasons) we recommend creating 160+ bits secrets (see RFC 4226 - Algorithm Requirements) - echo '
  1. Next create a QR code and let the user scan it:

    ...or display the secret to the user for manual entry: ' . chunk_split($secret, 4, ' '); - $code = $tfa->getCode($secret); - echo '
  2. Next, have the user verify the code; at this time the code displayed by a 2FA-app would be: ' . $code . ' (but that changes periodically)'; - echo '
  3. When the code checks out, 2FA can be / is enabled; store (encrypted?) secret with user and have the user verify a code each time a new session is started.'; - echo '
  4. When aforementioned code (' . $code . ') was entered, the result would be: ' . (($tfa->verifyCode($secret, $code) === true) ? 'OK' : 'FAIL'); - ?> -
-

Note: Make sure your server-time is NTP-synced! Depending on the $discrepancy allowed your time cannot drift too much from the users' time!

- ensureCorrectTime(); - echo 'Your hosts time seems to be correct / within margin'; - } catch (RobThree\Auth\TwoFactorAuthException $ex) { - echo 'Warning: Your hosts time seems to be off: ' . $ex->getMessage(); - } - ?> - - diff --git a/vendor/robthree/twofactorauth/demo/loader.php b/vendor/robthree/twofactorauth/demo/loader.php deleted file mode 100644 index 208f24d4..00000000 --- a/vendor/robthree/twofactorauth/demo/loader.php +++ /dev/null @@ -1,50 +0,0 @@ -=0;$i--) { - static::$parentPath = dirname(static::$parentPath); - } - static::$paths = array(); - static::$files = array(__FILE__); - } - - public static function register($path,$namespace) { - if (!static::$initialized) static::initialize(); - static::$paths[$namespace] = trim($path,DIRECTORY_SEPARATOR); - } - - public static function load($class) { - if (class_exists($class,false)) return; - if (!static::$initialized) static::initialize(); - - foreach (static::$paths as $namespace => $path) { - if (!$namespace || $namespace.static::$nsChar === substr($class, 0, strlen($namespace.static::$nsChar))) { - - $fileName = substr($class,strlen($namespace.static::$nsChar)-1); - $fileName = str_replace(static::$nsChar, DIRECTORY_SEPARATOR, ltrim($fileName,static::$nsChar)); - $fileName = static::$parentPath.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$fileName.'.php'; - - if (file_exists($fileName)) { - include $fileName; - return true; - } - } - } - return false; - } -} - -spl_autoload_register(array('Loader', 'load')); \ No newline at end of file diff --git a/vendor/robthree/twofactorauth/lib/Providers/Qr/BaseHTTPQRCodeProvider.php b/vendor/robthree/twofactorauth/lib/Providers/Qr/BaseHTTPQRCodeProvider.php deleted file mode 100644 index 5cb3adda..00000000 --- a/vendor/robthree/twofactorauth/lib/Providers/Qr/BaseHTTPQRCodeProvider.php +++ /dev/null @@ -1,27 +0,0 @@ - $url, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_CONNECTTIMEOUT => 10, - CURLOPT_DNS_CACHE_TIMEOUT => 10, - CURLOPT_TIMEOUT => 10, - CURLOPT_SSL_VERIFYPEER => $this->verifyssl, - CURLOPT_USERAGENT => 'TwoFactorAuth' - )); - $data = curl_exec($curlhandle); - - curl_close($curlhandle); - return $data; - } -} \ No newline at end of file diff --git a/vendor/robthree/twofactorauth/lib/Providers/Qr/GoogleQRCodeProvider.php b/vendor/robthree/twofactorauth/lib/Providers/Qr/GoogleQRCodeProvider.php deleted file mode 100644 index 19e086b7..00000000 --- a/vendor/robthree/twofactorauth/lib/Providers/Qr/GoogleQRCodeProvider.php +++ /dev/null @@ -1,39 +0,0 @@ -verifyssl = $verifyssl; - - $this->errorcorrectionlevel = $errorcorrectionlevel; - $this->margin = $margin; - } - - public function getMimeType() - { - return 'image/png'; - } - - public function getQRCodeImage($qrtext, $size) - { - return $this->getContent($this->getUrl($qrtext, $size)); - } - - public function getUrl($qrtext, $size) - { - return 'https://chart.googleapis.com/chart?cht=qr' - . '&chs=' . $size . 'x' . $size - . '&chld=' . $this->errorcorrectionlevel . '|' . $this->margin - . '&chl=' . rawurlencode($qrtext); - } -} \ No newline at end of file diff --git a/vendor/robthree/twofactorauth/lib/Providers/Qr/IQRCodeProvider.php b/vendor/robthree/twofactorauth/lib/Providers/Qr/IQRCodeProvider.php deleted file mode 100644 index 83ed67ba..00000000 --- a/vendor/robthree/twofactorauth/lib/Providers/Qr/IQRCodeProvider.php +++ /dev/null @@ -1,9 +0,0 @@ -verifyssl = $verifyssl; - - $this->errorcorrectionlevel = $errorcorrectionlevel; - $this->margin = $margin; - $this->qzone = $qzone; - $this->bgcolor = $bgcolor; - $this->color = $color; - $this->format = $format; - } - - public function getMimeType() - { - switch (strtolower($this->format)) - { - case 'png': - return 'image/png'; - case 'gif': - return 'image/gif'; - case 'jpg': - case 'jpeg': - return 'image/jpeg'; - case 'svg': - return 'image/svg+xml'; - case 'eps': - return 'application/postscript'; - } - throw new \QRException(sprintf('Unknown MIME-type: %s', $this->format)); - } - - public function getQRCodeImage($qrtext, $size) - { - return $this->getContent($this->getUrl($qrtext, $size)); - } - - private function decodeColor($value) - { - return vsprintf('%d-%d-%d', sscanf($value, "%02x%02x%02x")); - } - - public function getUrl($qrtext, $size) - { - return 'https://api.qrserver.com/v1/create-qr-code/' - . '?size=' . $size . 'x' . $size - . '&ecc=' . strtoupper($this->errorcorrectionlevel) - . '&margin=' . $this->margin - . '&qzone=' . $this->qzone - . '&bgcolor=' . $this->decodeColor($this->bgcolor) - . '&color=' . $this->decodeColor($this->color) - . '&format=' . strtolower($this->format) - . '&data=' . rawurlencode($qrtext); - } -} \ No newline at end of file diff --git a/vendor/robthree/twofactorauth/lib/Providers/Qr/QRicketProvider.php b/vendor/robthree/twofactorauth/lib/Providers/Qr/QRicketProvider.php deleted file mode 100644 index 59e27ccd..00000000 --- a/vendor/robthree/twofactorauth/lib/Providers/Qr/QRicketProvider.php +++ /dev/null @@ -1,54 +0,0 @@ -verifyssl = false; - - $this->errorcorrectionlevel = $errorcorrectionlevel; - $this->bgcolor = $bgcolor; - $this->color = $color; - $this->format = $format; - } - - public function getMimeType() - { - switch (strtolower($this->format)) - { - case 'p': - return 'image/png'; - case 'g': - return 'image/gif'; - case 'j': - return 'image/jpeg'; - } - throw new \QRException(sprintf('Unknown MIME-type: %s', $this->format)); - } - - public function getQRCodeImage($qrtext, $size) - { - return $this->getContent($this->getUrl($qrtext, $size)); - } - - public function getUrl($qrtext, $size) - { - return 'http://qrickit.com/api/qr' - . '?qrsize=' . $size - . '&e=' . strtolower($this->errorcorrectionlevel) - . '&bgdcolor=' . $this->bgcolor - . '&fgdcolor=' . $this->color - . '&t=' . strtolower($this->format) - . '&d=' . rawurlencode($qrtext); - } -} \ No newline at end of file diff --git a/vendor/robthree/twofactorauth/lib/Providers/Rng/CSRNGProvider.php b/vendor/robthree/twofactorauth/lib/Providers/Rng/CSRNGProvider.php deleted file mode 100644 index 8dba7fc9..00000000 --- a/vendor/robthree/twofactorauth/lib/Providers/Rng/CSRNGProvider.php +++ /dev/null @@ -1,14 +0,0 @@ -algorithm = $algorithm; - } - - public function getRandomBytes($bytecount) { - $result = ''; - $hash = mt_rand(); - for ($i = 0; $i < $bytecount; $i++) { - $hash = hash($this->algorithm, $hash.mt_rand(), true); - $result .= $hash[mt_rand(0, sizeof($hash))]; - } - return $result; - } - - public function isCryptographicallySecure() { - return false; - } -} diff --git a/vendor/robthree/twofactorauth/lib/Providers/Rng/IRNGProvider.php b/vendor/robthree/twofactorauth/lib/Providers/Rng/IRNGProvider.php deleted file mode 100644 index 6be28006..00000000 --- a/vendor/robthree/twofactorauth/lib/Providers/Rng/IRNGProvider.php +++ /dev/null @@ -1,9 +0,0 @@ -source = $source; - } - - public function getRandomBytes($bytecount) { - $result = mcrypt_create_iv($bytecount, $this->source); - if ($result === false) - throw new \RNGException('mcrypt_create_iv returned an invalid value'); - return $result; - } - - public function isCryptographicallySecure() { - return true; - } -} \ No newline at end of file diff --git a/vendor/robthree/twofactorauth/lib/Providers/Rng/OpenSSLRNGProvider.php b/vendor/robthree/twofactorauth/lib/Providers/Rng/OpenSSLRNGProvider.php deleted file mode 100644 index dc66c64a..00000000 --- a/vendor/robthree/twofactorauth/lib/Providers/Rng/OpenSSLRNGProvider.php +++ /dev/null @@ -1,25 +0,0 @@ -requirestrong = $requirestrong; - } - - public function getRandomBytes($bytecount) { - $result = openssl_random_pseudo_bytes($bytecount, $crypto_strong); - if ($this->requirestrong && ($crypto_strong === false)) - throw new \RNGException('openssl_random_pseudo_bytes returned non-cryptographically strong value'); - if ($result === false) - throw new \RNGException('openssl_random_pseudo_bytes returned an invalid value'); - return $result; - } - - public function isCryptographicallySecure() { - return $this->requirestrong; - } -} \ No newline at end of file diff --git a/vendor/robthree/twofactorauth/lib/Providers/Rng/RNGException.php b/vendor/robthree/twofactorauth/lib/Providers/Rng/RNGException.php deleted file mode 100644 index eb5e913d..00000000 --- a/vendor/robthree/twofactorauth/lib/Providers/Rng/RNGException.php +++ /dev/null @@ -1,5 +0,0 @@ -timestamp)) - throw new \TimeException('Unable to retrieve time from convert-unix-time.com'); - return $json->timestamp; - } -} \ No newline at end of file diff --git a/vendor/robthree/twofactorauth/lib/Providers/Time/HttpTimeProvider.php b/vendor/robthree/twofactorauth/lib/Providers/Time/HttpTimeProvider.php deleted file mode 100644 index 8e7806e2..00000000 --- a/vendor/robthree/twofactorauth/lib/Providers/Time/HttpTimeProvider.php +++ /dev/null @@ -1,54 +0,0 @@ -url = $url; - $this->expectedtimeformat = $expectedtimeformat; - $this->options = $options; - if ($this->options === null) { - $this->options = array( - 'http' => array( - 'method' => 'HEAD', - 'follow_location' => false, - 'ignore_errors' => true, - 'max_redirects' => 0, - 'request_fulluri' => true, - 'header' => array( - 'Connection: close', - 'User-agent: TwoFactorAuth HttpTimeProvider (https://github.com/RobThree/TwoFactorAuth)', - 'Cache-Control: no-cache' - ) - ) - ); - } - } - - public function getTime() { - try { - $context = stream_context_create($this->options); - $fd = fopen($this->url, 'rb', false, $context); - $headers = stream_get_meta_data($fd); - fclose($fd); - - foreach ($headers['wrapper_data'] as $h) { - if (strcasecmp(substr($h, 0, 5), 'Date:') === 0) - return \DateTime::createFromFormat($this->expectedtimeformat, trim(substr($h,5)))->getTimestamp(); - } - throw new \TimeException(sprintf('Unable to retrieve time from %s (Invalid or no "Date:" header found)', $this->url)); - } - catch (Exception $ex) { - throw new \TimeException(sprintf('Unable to retrieve time from %s (%s)', $this->url, $ex->getMessage())); - } - } -} \ No newline at end of file diff --git a/vendor/robthree/twofactorauth/lib/Providers/Time/ITimeProvider.php b/vendor/robthree/twofactorauth/lib/Providers/Time/ITimeProvider.php deleted file mode 100644 index a3b87a20..00000000 --- a/vendor/robthree/twofactorauth/lib/Providers/Time/ITimeProvider.php +++ /dev/null @@ -1,8 +0,0 @@ -issuer = $issuer; - if (!is_int($digits) || $digits <= 0) - throw new TwoFactorAuthException('Digits must be int > 0'); - $this->digits = $digits; - - if (!is_int($period) || $period <= 0) - throw new TwoFactorAuthException('Period must be int > 0'); - $this->period = $period; - - $algorithm = strtolower(trim($algorithm)); - if (!in_array($algorithm, self::$_supportedalgos)) - throw new TwoFactorAuthException('Unsupported algorithm: ' . $algorithm); - $this->algorithm = $algorithm; - $this->qrcodeprovider = $qrcodeprovider; - $this->rngprovider = $rngprovider; - $this->timeprovider = $timeprovider; - - self::$_base32 = str_split(self::$_base32dict); - self::$_base32lookup = array_flip(self::$_base32); - } - - /** - * Create a new secret - */ - public function createSecret($bits = 80, $requirecryptosecure = true) - { - $secret = ''; - $bytes = ceil($bits / 5); //We use 5 bits of each byte (since we have a 32-character 'alphabet' / BASE32) - $rngprovider = $this->getRngprovider(); - if ($requirecryptosecure && !$rngprovider->isCryptographicallySecure()) - throw new TwoFactorAuthException('RNG provider is not cryptographically secure'); - $rnd = $rngprovider->getRandomBytes($bytes); - for ($i = 0; $i < $bytes; $i++) - $secret .= self::$_base32[ord($rnd[$i]) & 31]; //Mask out left 3 bits for 0-31 values - return $secret; - } - - /** - * Calculate the code with given secret and point in time - */ - public function getCode($secret, $time = null) - { - $secretkey = $this->base32Decode($secret); - - $timestamp = "\0\0\0\0" . pack('N*', $this->getTimeSlice($this->getTime($time))); // Pack time into binary string - $hashhmac = hash_hmac($this->algorithm, $timestamp, $secretkey, true); // Hash it with users secret key - $hashpart = substr($hashhmac, ord(substr($hashhmac, -1)) & 0x0F, 4); // Use last nibble of result as index/offset and grab 4 bytes of the result - $value = unpack('N', $hashpart); // Unpack binary value - $value = $value[1] & 0x7FFFFFFF; // Drop MSB, keep only 31 bits - - return str_pad($value % pow(10, $this->digits), $this->digits, '0', STR_PAD_LEFT); - } - - /** - * Check if the code is correct. This will accept codes starting from ($discrepancy * $period) sec ago to ($discrepancy * period) sec from now - */ - public function verifyCode($secret, $code, $discrepancy = 1, $time = null) - { - $result = false; - $timetamp = $this->getTime($time); - - // To keep safe from timing-attachs we iterate *all* possible codes even though we already may have verified a code is correct - for ($i = -$discrepancy; $i <= $discrepancy; $i++) - $result |= $this->codeEquals($this->getCode($secret, $timetamp + ($i * $this->period)), $code); - - return (bool)$result; - } - - /** - * Timing-attack safe comparison of 2 codes (see http://blog.ircmaxell.com/2014/11/its-all-about-time.html) - */ - private function codeEquals($safe, $user) { - if (function_exists('hash_equals')) { - return hash_equals($safe, $user); - } - // In general, it's not possible to prevent length leaks. So it's OK to leak the length. The important part is that - // we don't leak information about the difference of the two strings. - if (strlen($safe)===strlen($user)) { - $result = 0; - for ($i = 0; $i < strlen($safe); $i++) - $result |= (ord($safe[$i]) ^ ord($user[$i])); - return $result === 0; - } - return false; - } - - /** - * Get data-uri of QRCode - */ - public function getQRCodeImageAsDataUri($label, $secret, $size = 200) - { - if (!is_int($size) || $size <= 0) - throw new TwoFactorAuthException('Size must be int > 0'); - - $qrcodeprovider = $this->getQrCodeProvider(); - return 'data:' - . $qrcodeprovider->getMimeType() - . ';base64,' - . base64_encode($qrcodeprovider->getQRCodeImage($this->getQRText($label, $secret), $size)); - } - - /** - * Compare default timeprovider with specified timeproviders and ensure the time is within the specified number of seconds (leniency) - */ - public function ensureCorrectTime(array $timeproviders = null, $leniency = 5) - { - if ($timeproviders != null && !is_array($timeproviders)) - throw new TwoFactorAuthException('No timeproviders specified'); - - if ($timeproviders == null) - $timeproviders = array( - new Providers\Time\ConvertUnixTimeDotComTimeProvider(), - new Providers\Time\HttpTimeProvider() - ); - - // Get default time provider - $timeprovider = $this->getTimeProvider(); - - // Iterate specified time providers - foreach ($timeproviders as $t) { - if (!($t instanceof ITimeProvider)) - throw new TwoFactorAuthException('Object does not implement ITimeProvider'); - - // Get time from default time provider and compare to specific time provider and throw if time difference is more than specified number of seconds leniency - if (abs($timeprovider->getTime() - $t->getTime()) > $leniency) - throw new TwoFactorAuthException(sprintf('Time for timeprovider is off by more than %d seconds when compared to %s', $leniency, get_class($t))); - } - } - - private function getTime($time) - { - return ($time === null) ? $this->getTimeProvider()->getTime() : $time; - } - - private function getTimeSlice($time = null, $offset = 0) - { - return (int)floor($time / $this->period) + ($offset * $this->period); - } - - /** - * Builds a string to be encoded in a QR code - */ - public function getQRText($label, $secret) - { - return 'otpauth://totp/' . rawurlencode($label) - . '?secret=' . rawurlencode($secret) - . '&issuer=' . rawurlencode($this->issuer) - . '&period=' . intval($this->period) - . '&algorithm=' . rawurlencode(strtoupper($this->algorithm)) - . '&digits=' . intval($this->digits); - } - - private function base32Decode($value) - { - if (strlen($value)==0) return ''; - - if (preg_match('/[^'.preg_quote(self::$_base32dict).']/', $value) !== 0) - throw new TwoFactorAuthException('Invalid base32 string'); - - $buffer = ''; - foreach (str_split($value) as $char) - { - if ($char !== '=') - $buffer .= str_pad(decbin(self::$_base32lookup[$char]), 5, 0, STR_PAD_LEFT); - } - $length = strlen($buffer); - $blocks = trim(chunk_split(substr($buffer, 0, $length - ($length % 8)), 8, ' ')); - - $output = ''; - foreach (explode(' ', $blocks) as $block) - $output .= chr(bindec(str_pad($block, 8, 0, STR_PAD_RIGHT))); - return $output; - } - - /** - * @return IQRCodeProvider - * @throws TwoFactorAuthException - */ - public function getQrCodeProvider() - { - // Set default QR Code provider if none was specified - if (null === $this->qrcodeprovider) { - return $this->qrcodeprovider = new Providers\Qr\GoogleQRCodeProvider(); - } - return $this->qrcodeprovider; - } - - /** - * @return IRNGProvider - * @throws TwoFactorAuthException - */ - public function getRngprovider() - { - if (null !== $this->rngprovider) { - return $this->rngprovider; - } - if (function_exists('random_bytes')) { - return $this->rngprovider = new Providers\Rng\CSRNGProvider(); - } - if (function_exists('mcrypt_create_iv')) { - return $this->rngprovider = new Providers\Rng\MCryptRNGProvider(); - } - if (function_exists('openssl_random_pseudo_bytes')) { - return $this->rngprovider = new Providers\Rng\OpenSSLRNGProvider(); - } - if (function_exists('hash')) { - return $this->rngprovider = new Providers\Rng\HashRNGProvider(); - } - throw new TwoFactorAuthException('Unable to find a suited RNGProvider'); - } - - /** - * @return ITimeProvider - * @throws TwoFactorAuthException - */ - public function getTimeProvider() - { - // Set default time provider if none was specified - if (null === $this->timeprovider) { - return $this->timeprovider = new Providers\Time\LocalMachineTimeProvider(); - } - return $this->timeprovider; - } -} \ No newline at end of file diff --git a/vendor/robthree/twofactorauth/lib/TwoFactorAuthException.php b/vendor/robthree/twofactorauth/lib/TwoFactorAuthException.php deleted file mode 100644 index af51b748..00000000 --- a/vendor/robthree/twofactorauth/lib/TwoFactorAuthException.php +++ /dev/null @@ -1,7 +0,0 @@ -=2C00000001Z^Bme*ahK7I%2?_P}^~A!$jg5x_0s;aE2Ib@9=H%o!J2&R# z<^eO;!oR+~)goAyEi-+9V+0xI?wX&}?J~|#!MS*{N zB34QT77?kZrxr~>8AUt8zP@m7YdmFJfq#5KNk--5guDQ zpsTBp2^B^=7E3=zMMd}a_a`SN zRbN~aM>`cvKNCnh6G=Q3NlaT#^z`)c@bMNFDO?+u7O9%gXTX@8I6v6;44DMLGBO_ZL}87gk3SLpTO2A@lO{-Q3#|K{f>~ zBIV@d*w)t8)6>w*%*@Hk2QMY|_4e-V?&IR&)6vn!!@~|dF&t@E6iYt}H7e53&kQ*( z($3Dz$jHOMz=wo|9A#7qF(>-^`oO%r3^ptVDImzj#UOEB1SlQ^CLF!GyRfgXtgEaa zZCe^%P6QztwzIUTr>D=(&7GQ=mXni!eSRQnSsGzc8#gbcp`@appN@=;gn)r%V`dps zN4mJTrn0Ykc6c0DN&+Pt#LCFR!^D)PqL7Y~ZjXmSbZ9knWmQyJ{QUfYmyutKfVsiH zwZ6QXuBmi>er;=UU20`PWLqUkKv95oGe|;No6ki600512QchC<0t6rm7!zv@Ed&B; zQVchn)y&Jsy|k^XrJI(Ngn@i?bZk&YLpw12 z`|s=P=jYws(b3Jz%g4jNy}h}$m6L~h5UIM$000JeNklnaU%ZTtTy=*NKa zVS%QiV@z>AyxPI;d{aK9lS#_%{5ClznAPe6Dc(-&)e9-9VE zV3z<~7B3eF(6bL_mSnfHqhJz)trku*KF%AJR>JLVmjFf)9|$lCO;ia>~fzeFvcvAcl)unS`b$O5xtNx2Z{ANL^Ou?bcvY3^50qW)eCo ztr*Iy$3nY7q;TH%_f=zITn?*?gV{tu+49}C^F3Ty;o*#&{P$%=Y|;`l0sN>uxE=yp z^x;I}A{qROs`u}`)w9heDlM1a8*96ue`+i)JeCnf&Mhk|dV3XXoTv{K06RJ; z@}VRmQ(ac_MuuOZ&rD=6RgxL?5x@_}MJ6(0qF5dBU&&O<2p=tPC8k%_V`KoE)M ziP5Sm&AWoa>gsCxmG%whw)x;i^sSEoC{cHTXhD_ccZLX0M_4htGY)2X*Gs^CTv}u( z>3$SN>isbzqmWJ@5X#HT!#h(#f%nZA&18tyAcd#XZM+A9908^UvN~x5AygAfMPIU`dz%&TR z%l@KNiU@%Qr~ss4dYuARaSQ@99dZx>fwfp!SHWa*sO|#Mie7?G$_#v9NV1W76bw`` z^b-I}d9T0(P(v&Uq!I|5t>;@WBpL-|y)4L(g#{y+M#Kux$^#ar->~|R= zLa+rPf%MGG@_~)5|AIyV#InV85m?i zGRWgEw6Jbq3dPXNDz`m0QYPqxg5fINN;5MY&AvHF)-Rvs$A zG9N?$7g!7gSm(N4fLJO(1z6^(HUt1p=>$+-OWufNw4ggEHU*ey8HoyDX|gK|K|U@n z?v9CI0pEC&x#` zn-LdGpwp={2c6~dctY2{t*sP<5~HH|MXEP6T401FabShRHoLi|u-O7mituQUf6rkI z1?Io>t_-77Ba%#je0(r9jCy*OtANcBr*OGkVW$?Jp0#~8iRP(9LVtpTE2iy!u?p=D;vV0P-nZ zvZ5$EcX{I`L;4@7c@wvy@0xE(Ne>_Bc>EyYPY#iEpBT;JQbM6;NO-E%K0{eF@O&qs5P}easi_bI z2_-wx0#IYgywT}83`LK?l|CMX`%u6o$dH1};~{y8M6wsX0{E(btdmo7XJ<#pp0hXl+|!}e_GaCuEFX8n-@h5kwd25m*V+IV_wBm^oSYmm z<^@hzXUCo{gS!XJX|`*^Xdj<+pJmG~PdImGLR&yrK-;zh02{k*Z|EN|*rlhVGuFHT zgB}2>03F@u?D6;Wb9ZlO#NFN9&(F`l*`7H8-MbHVLF3KQBbY!9IDwkxSS;2V;8+W1 u02bT4Ify!eFJsK(mO2eMn1Rt#JM|ZOJX2v|M^Y~U0000H7O3`uiKj#l-*r@{r#2d40`(eO8fmQv$C&WUR`$%F#rD+ac^z} z0|MRL+G%EDLpLOe1VdL%L9Pr}Dj^h2ML8lC4j~``{}YG$`h|ysdjJ10(GG3C3Sc`i zCg51m!ove&WCGm?a8C*$ z%E`v??@eT0Fo=OH+1b=pPccnJEQNeF^#y$A=SI@cHva#G<>XPL2v675OQoGOV_YHO z;6d*1Gdcns<>jl;&qJb~KeMebYGp@iI2TV)0N2)<_V;jlF*C)&H!dqF%F2}B-;$l1 zXM=uL^75{)t%~8|0HdP-z`u~cy>XCbE5N+5pLl*%F&@#<0PgOSt*U6JjxcmiDBId| zk&J1IOC`$4QS_3Vs>i}!YO9RL7Ly-7qtRCwC#nz4@J zFc5~VUv6kuvLYG^aO4+QD@96_;tHrzrCubsdjzB{Xznfcy5lwPoW%YOhTTJ(+sc2j zn{mc7&KK;AAtEa)D=RB2D=RB2D=RB2D=RB2D=X_GZ7PiF+TTK)f>~`;H6AJFM}zGQ zk*EqCtf0!>GVzN7EO#Y+k9FI@>20slu5s|~djB@|ua8L{hWNB9P^~zD(mYgRbD$Bo z3&B&=W%r2I4v8uu&a`&K+JQQslCBKC*Pyyxc_+_Cd|E&l9y-xNd2<2C;Yea8zF{7W zxc#r(DT>_}!@&v#TbFpc@+ZR^Eda$l)Ewt&V3C6nUk@v~L(gd4 zzu(=MgA5AXhSeq6C7^DRH8@QOOQD7QdRV7uQ7bjvWNCd9)!cza&xlrgk%yNzA*>P| z>c?UIgps|*D1%YF4@-J!R8a9`Il0TyrN2Vigfp_&%AatWLq7#iMdBe({nv??Hz6!h z0L{a&_%QQ}^q}`)A;>@rN}&?MLUIt0J`Mny^I+1`jEE&+6|R|=Iw35}aX$h}sM%i; z*3y~le}c8#sl5wFX(&-(Hh+&hJ6$k6~S`< zK7!@7^VeIKW6-_mP?DU5kqZFBqd$W6EgrpF>oy1Wi(oBQ9^u=Ruo~1~1&f81pCv~5 zOZtu?4s{+%@NXNDz;d1h!B6A@mwEhcmjhIIgy!17bBhW2YgdkJe(p|a|ISPJF?SWN*V zrh+B=zkTAVVX+RA39L{jSwMvX=3;W4{Z=@I^%Ew>YM>HW%-oif!7_{+V9oy@EIG;{ zqC7SoRYq>-xRL;%ZmwDM6ye#(a=-RPmVptI!9w6}0xTOQ#&(A~g%$1SAB6=keWTJ2 z7j1AljyuOjqD^4&xoKd899n;$>7b26Kf6> z{IU!stA@1 z`5PQI6Tuosp(0qq0J6L+R>Xv`YS_?+t9@@8VBQeG0(eP^(!kjgS2G9NGKTft&1v@e zlq&dwr|@gAl}-+T*aLtZQ~=ly803{SeuY31J0bcKXfWp&KUf5(D*h(S_I(rzhOh@_ z2A~I4Om6Vg*JT|58$1uT&%=?uK#zvI|DTe=s1}2C=NtOd?P&71udPNR!$5vM`*_i3 zKXE#Ht2>Tecy_aYV`A%DT!Z9jKOquDJ|rdl=Hjq3cj9@^gI9zquZop0+&K{P{N|)?_#?8nl_=W~SOH(U zYG!YIqe<4SUZb)Wi)&RERnQ-8k+LiL5swXDl0@>h{NxQM`2Jx6hhJQ`c?7Iv ziSBI{tQJ@%tg;47nEe)5ThZI1@sp#Ug5}S~P<)hpgs@4;HDusH8_2d645Nw?bE4y!Rftg;}in8$@D_n5Z1UaW?R zZJ6Es3SF&DPFR|^^+8yd$SN#rZkASB>E1M0!D+l8j!Lj(SH=)l%(g-5Xbiy8>zb{U zU7E*xuyk+B-$q4Pa+75$`|I(3S6HlkWMMCEhqd%JZ`j2P*(0!YZ_D3CMp$x_l_In9 z=7V6B&of}LsT_vEM$I09C3#zfMJj|PHdzH$_KRiNK<_CBrI5 z+YpEyAi5SfNxvrFR}I_ETn}&ngJ3DCfbV z)^z=#`ZR9~Df>qRmf~$WSb3_$Vxz*UVAm+HH=aNy!kW=%RSp*FS+MMn8=Ozae}Ps{ z5VP+mVX5AhgN3yWi%nLj4{)RGMIx{+EzLBnhOl5}!7BJVf^Rc1`(YB6=54ivRmrf} zWQ~2!1-YdZphZ}5XOiW?D#{tK8Z6zkp|I13T+aS`Hw8=cw%!Q~sRFAJt>!0g#c#OH zOjyFY4pxhL2CO6UAkY#@_Tv<+7scDM$!RqOu=s&w?>}vhI=snmlRLut(=l`$RzkLv zt+edzBrL_-@?iDI16XXb=u6aeMHj*N=yX?Dm(bbmuuk2GR#rjHzMX=lcw0kqsz@ne zjhZapaiS>g%4GavKiqCi+JwJZBg;`dt3 z+ZvK{wU%q?R@8PwUr7|HWZjC7;RR(amZ5gVXX8RKkBiD!Bzxd$@tFc|OIiEJ+xn@$ z?7@Km00000kpF8VsH&=}s;a6AyXN!SN)^TN2{?E3-bwC^i9?+q&J1Eq=os=tLPj$) zNyH>3@x8>5_F;vTqM$wz6`sOVdx{xEjZv0<4(G^~~Lp%o)6ZZD~(VM&@bF~WZ@Q95(WEh4`<0v699h`@z8 z%9o~-$}kk-6mlgqbexuk4I-Qpy?*njx8MBYv#%e~AE+YbIYcrHbF^8UWOm10(~C3z zB9}Vdt*w01r-YmmTX_9FAAJ1Q`I|2N`Z_v10z#iQYU z#cH|dYlfhniZuVxdlx_X;;H*zd-}!0x7mfr@;n+uh4w^OGL!1S6k~_AIj+|$wSnW) zQ<1ZT>u-GWwNGBY_{95P9bxwg5nl%PeC*=W&mPu#_GzCWB$~}aHJ6q%xpLDtX{<&I_J=x!VnbH!N@;jDYGGpi z_nH3s_uhQum8TxNe2ajVH`@ejnr1qKVY_4NN~6uspoL?7c$N6Q(nOJ!bbVX{TAD@v zb6DupTQ9!$$zzw#ES}Y(87wmlok6*nYv{?O-r06ArG%M{IHl5XYcG>brS$B$mXBJH z=Fz|O&MezrMK6VfXRkbe>4V2#JphYP3B=x(;Gmh$pDj&yGfLvNlwH{}`xp~1)&hl~ z0Q%kbM)J0VoXL($g~&&qCkTg!7Xhgt1V5MAaMBkgvEP@_)miwjEu&8!(LQAN1LP*v(1>5QC6q?Gi|wcWsQQ9ssd zju6B&F{4^1v&LyPa@Eaz(?k-+hOw-&5DRNq!louk%UB@RMEOCW!JAygAQp7xx$~dS zVW}eAjBQI_65-bVs9PKFWE*K^jX$*wTO1lxQUxjraSGzr(wxm)I+*~;=|-o*3@Qc= z8tyNFg-t9htJf^r(a0UmV$z~@MUM9pTBtdowdZl_MIlFgiJv}KF zLJ`uawPc~hqLS4*TPi`{>MrJqJTW-i9+!HWs2(?YdLRPlO~Zr`>&}PX`x0PrkP@ZD zL(~kL`5IV-jPg6FJCaE`vs3E@hU&TqQ7vYR2wRFo?36p{_4!sQb`J6-W@U^V;`_^$ zX)W|T7cFjbHF!a%*gZ~UA)b~bKq7%5h6T^B9Q)EPgNx|gs3X!Cbp7F z{H~tmI{MW3okx~$n~(ZUEiISN2cp7fQ672)pl%qx_KN}%w-zB zA4J`)%?ripv{)VqXD)qx`B@fO2GrEnsCTy39#6ArMN#CnKUlFQtt3CHa@w%I1pD{P@e3=fcU|NoR{&&f?7^LB41!kWZQ#IU1IPEYoTBc<9*n zWV|^dZ$JI`tJky0(gG*ya#Lm7=TZq-k)hd0&GuADPoWlh5~lM3^Z}C`3#{#_tut72 zTyi=Kt)fGhj3_CCrKfYHfhjB!ZkDG2t6t5w$dOGE#n>EmhovG59o^2|R~XSppL_hl zGZ6D|Hls~IW$SZ9DH*~m$W?OSolWqYG9T~u;2u$Dl377Hk7$@ zik#5v)gibu2I~sJxCLi(oXzl1+Ao0BsFa&n^-gxW3oA68?T(&ek8o}V>yK6uhBkyZ zgVugnes{bJNdwl#+%u;oirm~2k9mC9{LOxESj}biwN&z8TtVPZpy|h6yajN%ElSG=9%!ReDGfs3=u57;uiX*x0AK+S zJ6GzN0?=XykblIDh~^ab(rarnz}j{+vaGNmm0;iL6{?*^hTj@SYSn?+$A<9so#&tX zzPDY;+K{XkX-#Pq3(>6KI$;r_HOrO8dg5b07C)XCTg5z%haU`BN zE<(*_dCyKR+(SO&3QW_)^Up9P4ZGvk{rxG)g+u_17j)5V$ z11revaG2NNHoCr1=Rr#0Mt8sW!b{)1BSUOLc0UN~oXrZ0&+IHz)RU*hJoko@T9h4Z zHsi`SoiLzi-px^sN7k%p?vh;X^-g4%QDbp@4@sFxU6^n2g$eV^y~KJ!R}nRpJ$h%JK75vL>vrzRqn zm_|b)2Z;VT7%cp~hnJ>7{+N?6$iiX3$^x)Z8K!zW_-nnr5+own>~M3(q$6yRrks$4 zD}Kr2`T3TWa^ayZ1J*K9>IpPB@26ebI(ou0hNW;2^ROjao}9c8kp$4fQU!&?vx0@u z5~X>emWM`V9pl-sV*<2S!UC|9{2-u2=0}ulYTl!aKA309PX4Sh=D!Idj3tA*T#%pK4I1{Khf@(^Q1w|@-8i&BHAskH!>we$o3 zhmAQv(h)q|MTO*fGPir1VxP$#{j!+P*dhmg{Bi4L^<-)YJqvW+OM<1z@5I^Y4cMJyGFC_*jU+cVvzv4{ca6AR; z;R?Vrd~SzjMJ8bFkK<{J6$n~y2Noz4vRK$w_gqY+@p#gmxeQi(Z46GXo!1td?X%uj zdYE$xWQD1z?(T9vzetW_aIlWA03q;pX&T6qdEh;>Gz{iUhu`6~w*^?sy2T|<@#d1{ z10>ddq#xF@cBUU#NDZX#j1}hU?6o{$F~G#;a8{;oEw$ii|KY*4qH?~xB)e1u3)W@} zL`0B>2Xm?zqP)CVxEU;Q&%(`H0-=4v()X_&r9tep_PpK5UZ4i<1}qP{r+{g@(gX^n zQhe#rcv0YQja|+w|g zaAcA_@B7EYJwrORs((WFwE6Y3XD?sAeD?B{R#m?+)AGQN zKLw>J%5IY67hQXBWBKlo{(8@H`vYaSZO-v8-PE6=}wD;&2RKNW3^Q*sCe+|yh&o3=44TG=wGKpmM^)E*|?oRr#*AtP+ zzyQ~M{r!`<`rL{OWt~Y)73#*B8*={C23VZQ>$;XAp&eKkOF;Oh>^WH8z$Qh;CHO{C zsoU$f*eWB93rzNT3$Ug*ONNJEbd0`wRw$FnO0%=S3q?`;?z``bGU27b)jvM^;_jrp zoVmUccnA--*T8*munaLRb#%6f&hF;fh4;F}%psCWx`v6v~Z&sQl zD=v`>7T2I{kA@Pg#8goXNLah9Tg9A5Jzw>{82LLZUIIsHN+TjfnZfWwl$~9gFA4*& zFj|P564Dg{fkJRd7=^I5Y|?6z5cNhdQ}|!qQToa?TzO?`hY+m53ZpZrjEIG`FfEO z@-KZeKXl6uEU501M8vo5-NG{K=AiLKrk3V}heTw9+yEk;)N*E)wzXq1Em`d8Y8K7u zJI#qg`pV;PZVt^Y^f$j;g&LJvD?$Lt@P zAm~yZj~DR(toTrHmNB9Z?FbeQ&x@D7|6zFMvwGFf&*H)DC@KsDxC(=V0Wt_c&i9`7 z{@s=q!(DR>&Cly8Vnwc4{2>f;3`RihtXXez@o8|{CtOVh9p)}0F` zI7#8Iowot&uHF_bhTQBfB<(}s(!gRR7AD7d(!s&Q#&DU>+T)Jc*5L%d1m9j^&Reuv zOgy1L=QKQ2t=9a7!Ga}a)Qmn|=;*J|YA=`$fA~&kdh3yaD>zP_)^?p=2a8NTl3qFB z0M^j(rE=jqhvNav3>+Cf7PRMR!88a92pu9~fnc784s$R#7ySZmM?f-qvGCyrK*-kW zN#n((y(?y7B4zi831H^Aad%E#)%^O`)z?4&^3>noziL#|^g(B5<<;@ifQL1%YPx#g zhcv`iG~{cuOT#Jtts(vJN;iO|!2W3@6vpCnFMAtS!jH^Kgu5buszl}<1>48(HcG}w zaLrOS*DmkGgv3puyz5S9;KYPnwh`B|fJOs$^K9yWDWUfFb`5)FSa1DY-<@C1NG zG0&tVa?`}(dV!A;6fJ>;=3?>s%A%VUHUh?5(tfEF-Z1jS7h0^YV7X$);ADhO6>J`M zUPCwmA_=)jM?}h7MKOOc{CDk(g8B}%w&_mg_|;PzZ;tm}f`xo~fYvEvjmt^YI#A3d zm4;h~OBgJMz_YF$Tp=6Op8&hvQSXl3QTr0!EEZVpWO!}CDgY_o)2{^Jl7JMBGSQYN zl5$hC!C(5e;UTCC_^t0`SI4NS?aD^IL=WjLCF5|z6_P}hsn7N1x^FOTBy#lUpBPf= zx{=W4iNIQX#J7OOiGhBU1q2iJ{gU=2@aacZ9Q0d=hx6Dt%@m4i7q+Q)vCiBH*m!ke=e8|aL~LMo3|+WeO3PJ%qb{I*uBPe@ z^q4rTm*hH}i63aHcX7F_?KJ1j75t5 zR#vHTshJ2ZhUGy~BT*ZizzuQ(yV?4{NC`rRx;%Hw|0#;<#M9H$E8qTkz1}~GuWCrf8&}MAQCDN zSU{b6xYA*mg00Z^fIKq*7TjWn))w7L6#-f~$s#12z|x}Oha|zN-k9C7G<5#Tn!a)2 zzV7}PT{T9+UZBL~D&t;LbJdH2<44uixm8vE6(eIKcib}4FQ{tHcNNrJR%<#Nr0};s zRzder?oq6qyt&W={1+3zg5%<)sc~TKJ&2IPp2*_@TDEITz!8hZaOVbG2qlHG2Ky$< zn+MKqC36?Wy}Rzw@@W$fYlNdf7nY!uha9La=u^&lD!Lj+)6BcZCI1_D; zqanYj2nZZ+pbDwT)Ci86Gp;));*|2+Cv&Ri6IZ->SMGhR>d;gYw)g52NA4K=PZp?6 zmF^=SHjvyhD6~_j8k&z6j8x)3Z5_V~dFw`?);Oa~t-rx8E>=FD(GRB-Va^`k^t9*a zEh*Lu?kVHm=NH*;HpnV91(DvPY4+Lch14#hbq%J*}TcUndmUW z)pHx~d+H7d7WMrjO_j8P3z~6KW#@@>DDq$`euE}wVVh!+4c zpk$W{M@Fg*5568;8|rzCM;|7(uId2O{^h7Kx@~~A#TCIU3d7lbjtUi4UwT@nLKW7C)wa@o8B`Wm9y6H^`E(WZP6@Z2(newD#zi>b}{5 zjP#_k_i}4o9HR!+cqSAB=7!c>X( zMLSi3%Vh-tT5u3zvt<;%0)Zoki=nbh;W{C)U|X>#C&^|cYF zPMAhJ&gVwAl8J^3xkpdBY!&A|Y9j0j9B`<}*VthmrXy3*PFQE#uy*3nzh>TuxdME}D-fBacDEC%l& z(+7#r7S0cz;H{a1^(lgf-3t(osGF~$IOVQUpMU!1?^nOn)Z;r{C=k|95rGA2VrhVr z?tmcxvl{$lJ8iWXOzgpaWKjQm1tk&i0r0&Xn^kGtjib$Fr;p5C@GKAUYNOuAj%p%yLmjb)t9rUIwT!8L1_ct5s)w3C-2Gdyo z+0UK8WZe)q1wKa(U?Ep3Lk_kX^sr8{%b7ew5KQnlz5VHw zag*wNZ^5~3!Rl4DIo#J>*0=cEFS-`6(0F*phT=muaBP_|H!cNRN? z6;=KpZC3&mWf_KxVpq8qp@0NZKtL9=fWk!%QG}5D6at#aI0Uwpr2%vU7LhnsE)ft# zG9VPp0L2PnCQ(5%FSIfnGw&JA8Z4`+X`1QzzJHgWV|QJkUT1WiS(bmF{l4$Lp7;5- z79KZ!E*S60Fg!%9QP!pfjeCohRcbxfBt4V;9HNXXw^}KMhKy!-5wOfLoMCRROE;n- zjbi0ql$=6%G0~1A1M3!U3l~BX$QeRYE-z(=F4SQm4oR=*87!`~H43hf%9|Pp zpTs+NJB1BZ>9j#0e?vS0h28=!Lc|Yd(+3O85eBVG7luWz`1l$b4OK`*qKv4x>jfcC z*w|}nVAfAF0W53W(pFJR#_=B#$dTpe@5x;fsKaAwq!|4n&4MLFr45@*1z3vx$1|}o z!RA{Tv@|9Wl=4^YP_|24F+R;Sl8VJ`bKR4ks~1Z$uiSS!GY1xN#`(^T+d@fRuwoJ8 zcf%b*#2F<9bf1~R=}hhQ)Q_9DlU<0xMld0mYe}pqyUdCh+?vu$5ysv41}UP2UX0AtI*$ctmNI$@y5oFFeU_}v zUL+GXZO-`Z{wP)zgH~eb)!Xl67Bwnl)65~@ti#kjEP@1)(Z+@|1`7nDgk$9=Mux@W zhPIrZiWXE~8iNax7ij`koj3`LX~N-CTPBo|bou}(&R8Hr<-zI0yQ412+~;QD<_3v^ zK(Z^96`;uW!$IW+=`sh0cmdVD12KR8+9OUVB90Fo8l}R{=cJwOO`qQT+945GF@~KO zfAxxWl>0v{RYnI7L3NcEh6-Frdu-+wyAw3Y6Ya7ho5m+9GLn0q@RjaM)6&Rl%D9sQ zs48Ji--VA84Ci}8P!O#XWKmE;A{tvJ1SijhD_5@cvVg-^TH1t}K&-)>3-){=-Mv&WUsnvS{5%wl;OQRro>}hx!yNP`8+7;tb6U z0W3fF!@?2KARZ;Dp}~h!(EzM8vaB354<~|^WLnpLp*jKTNhr>6dE_P%^3|HVc|pw% z<^T&=sQk(pT8mq?BFI0U?!L98|IR3$BoeL_T_0>!hFj5){2*xQ=$SJS5p-R#X!+mU z{7%#$&4k#93}PW}we79_yV{6L9L%_$T$OWOOGB&6+sixt=361b#>ajxdNs*x&`O3TLDgy%%_6_C>DJv;dN1O6D>+ji?)C zo_r*j0v0{xV;(kTCRc_nO0hw#$ef(YSVy* zwSpS0d=MQlr3ezN7bI_E5}jU(bn%Gx@QC)tVNH5bOMw-=F^H(!R$n(zaaWA23|-hM%kJOK)I!@fkgsqoJNc&725JaEK5bf+Ohn}3=xEFXdceqhjREsyGXyJ%fJM=&EtSeD zH2|v;(HUFVL={f_)zJacYE?4zPgS}QhI6T|KMCzwDeo~IMFcW1RL1RG5}`zhkvlS~ zuZ$C3J6Ce$MySAbj%u`=MsLg9ZRyMaqpuE6OWq%;CXsa(gs!jvBBM9pQk-yD`?l!nmo2PX@z1P}<~qIABG6n;(o=qKV{L(uDPySwOR)4_gG5?OzDF94#tS0tAV58P z<5w5vTek#LzBY3ecX8R{(W)E+3n-Iqc&+zb%8%t>wM|}ERQ|$(hwcN9WF1I<7^oa6 zp;>P{Zv)5G9Dgqh-6dRgOhFF3w(#)Hc;tnu9pdOMq5ZSAi0O0*T2M*BIK^y{f)k3( zt?qhfA8yJ)k-(DqD)*K>=G;oF%*+^~-x~uK3isE}ZA$sB1SJ}_$VfUPjHHX3B|g77 z4Rqj`j(B))RqP6bG5t7wXnawLV+0j=5_S9rZJXqi_rsj#s4>B#uE5z4oubrpfdJEJbNB_WA)4#+qwBAH)8~0Ipch&Di>$yoi>7|Lu*N-oEw;J0NXf zAeX=Jchk0l95__np`@r*0eCzf$F^tpE%4hqC^28v$1Tr{~vh8;=!K{=85D zMX^fYrx3JRK2KtO&t%kh8vF=N12%vf<4y09Mx@>-c74-VN%J@hev? z4Dk1NMp$T!tcFe~=uc5&r%n(}4vk1k)Mf9h2E3=`;RzA#2!KzRLR-9=;l6yK;ItRdbu}?j~dhyLoy}uW}kzgkGhG;fK zItQ&lsO}oMZtZ*nGcyI}XQE0~bR?tmkAA=Aya;flg};3rnmFfiV2xe2fErDBsDQFe zXJ@Y`z#%sLP19+)cP>p%Q{BFw`)pEGI`h#uP)XP;z1F+w%@<#MbHlY?jwR^J&qC-? zy2ivW6(9km`rcEsS2IfIj|3%l`bssnPs>g|bO2frD#5}9Z@RiXe4R*0Ni@$x+XC7; zv-OFXn=i?V17lec4UpVEOHG-y)`ogR><9$1whsta9}uuoe*DHRRpDp7T_ObND3b)x zjLoZAs33zwM<^X|0mSsR419BHhVP+ls1mGO;`OCyh48ekXtgvD?IXAun)%EQEd8D5 zw^T|BYVqmEz^YWS2j90(+WYJp%nxwrZ~-1$+TXhoSUm->er>K+OtLygNBS{PAsSRx z%XLJlInpUUh|aold7SCV8G$5K({>|FploSHMBsqGEs+)jEORdNJy_CS(?V92b|z*( zXHXBG-TqG8dW`WZz)DZnQf`ZKN{ih)_u;kLOr?T@6YJdP6f6YszkIBibTaf_Om3OM zjTri>RE!muU@w`rVwZebp$7G=)r9Z%orr1X<~k7I>f zD$}BT*nn_I6^Fp#tpNpMcdDPr*L;JmsSw6+yh2A!uT;sxu7Q7IY3k zlV>K1Z4kpJ9^3lL%|xdO-NOi&6C`48-jx;@;rpEOgBIb8lJ@jVG;rjGj;RSBmY*8w z%kP#Hg(z}WZfVAKd;6(<#H?j&YHeG(JBxg3ITS4Ly6ZbO;B*IAFMhEh<@Yah4VTNk zo`D*ua81{`Y=>|QkRfL%p^5Ut(~I7_d?!@k1c)eLXU?1v2%H3AckW!hm4_l7HsEB6 zA_r8!7@&nXX4+U8r1BFk?LV|DzvI;lQUKWXc zIE)Ym;_bb2`*FNKMZx+2K|JBJJ-!P!A8GR(|5fyEjTwSP&WenhD-VL=myY?w2&XUz zQ(R4Q&p9cpqIu+`>1D79aNir&7D%_68tacB@dPqWUsv;4m-4=-f<`%59GiMsm95S5 zreaClc%pJ}?GrZjl2+tK6f9s?A?koD1XOac4qZ|U7JL6eSimX_o6j69tm=@ShMI=o z?%#w$Q&`NI?9tIje>}W<<8G^c^5)&$Z54!%L0YVY`o+`5-)Js@q2h^4yKte5-ZZQ5 zjtK{=%Re0!9>0A4)q@95cL_6s6_w&WRT=Bc%5t8r=y`tMvM5YfEHlLjoiFM)IW=OG zY`N4(Ip^n;jo5?~EE2?T2kq$ba;Yw^q{+{g{N*hthd(VpcF;JM zf9X)Zq`;Qu6G&k&6xMLEtspp9+S%IDk^?Jxx!9<qJh-wRhLUs<2O z-M{MxOr)qaD#VKl1CO$iIJ3}l09qB&*4FygJXq_M;o;%@%(%F$-QVq4{o0NJMM)Dk zh~u~-@Dk<#u;MOpBg$+B(sY>TVf#GP%O zGNBm6z?Pi#898f;){8QQQeR-jp%E!z8Xev61;vUv;X8JGOC-0{7*h`f0hvel@obDk znmwgH1#60miq@epWTXh2p3`ic(53mJYdWvYVyWTJzHrC_n9 zV8Iz3;P3SK+4 zr>Hk@xV||@u?xq*dU0cK|1W5@K4x8o(TkULOn8B_!%Ds|LmKxGtF>)xw8Erq&F&pQ zYxQg2b&IQvplD=CXT;1++}teOKz)n1=EK6K?VnV?m1-D^Tzok) z#M9feOnb&i3}~^`8VyRL7E!w{6Sd{Fv=mj4J46*uv$jB#LR}#>{7W;Q1>5K@S0_tv zZncEos5o1&rV4t7_=pC87Qot(pDA*0BxHJXH&9g|+ZN=%G*J-o{rBIyEcVbe>v1&R zx$boH;giFMo6mYAq&kucumR%i*n@uzW2SYi#l;Lh4JN_d-IFS8hJ1^QjY7th#_%%V z`rW;sQ>a+5el5Jj*P}&vH5VSBfl50hv)16I!CoLy31&nvbWw_vWl^+Nf7hLbT8ar+ zV&GneqA#1B{nC*)JhpE2-b%(QH1URJ5C}O|eyZ=}@se+%cP5~BNAeLf^bQ`ampRs~D#SRkCWCdTI>C?zrONi82f0eal7>n1;G1SW$x7WK zPkyHm5Or2m7~)zB7C_P0(UI^~G-4@}D0B;=&`+w@ z@*T%3YZ@ll?H{R(>cNsy2s^;WajyXsg^-qZ@&BP5Ne5Es@nCK0z4i;3rK-;>!lj|E z|393OrtDEFj}yprrzDw8J8;MYt(w-avj*a$y)0NXJp@`LJyhcdE&f;a5DphNfez)p z-wm)RTJ5(UMXuZW%zT=unoTRT;uB5QruLBwpLr*w;;fo<)kQ3n=-MSML@qKUgv*(f zU9eIj1gU4;e-a%+3o0gb-;~gS(OTJT7Nqz|1%wCO5S*dbTV>l#(LP z3Ry$O)6rCD7yE(=tQ-~+J(&N^NV~-|2n5ZCBP?2d&Bt~!&SnNtXjk+85BaIFhUiL7 zZC>yXUL4V?TlQRV$h^r%1M9u45Z3qicbwaRVls=BB0cOsL`0&d7`=Pa3(Up;5v)KS zz;bXs5_#-U(->L_oqfBt+lrT5(DZ%$ZOYlT#l z;&S9{$rxG#SzG>CoNz!h@(h{T$j+t8RD70j3aH z@3p+5ig#_P^BcFuxQ#YuZ^Pwd|b?wBTaAT`16%k6zlTS~t1*qN%Y zk0?|PuFo7S@7vwGX;W{P)SaA~43gA=ZU^~6D4 zNtv0?ET90n52JakQYlZD&_D>YUf_5Ba1B8VdC%^w_J2vc){v&cFkGkm+Df|ES}R9| zt(j$6VYN0Ba;8O@XjZGNNGTSIVOlUqWWkasDUj*>mvl45<<`xL47w3kNP$uP>>?B; zR0RF#dC$(-x4E z?bj7x66!>lR^jJ>EGcNtvk*KsqkN#UqaWiC)~e`n>aE1aR7ZLVs#Pfnu{(V|%{P6& z3at&p8ntbR0uGiQd$I)B8xCxbWGS{hB(+kNialAzJq1;e<41D7OH1W;S_S`%QLpetez}{xSs17xmI4$g7t^lWxow$%k}WxAvss6-#=NnhHXzb) zXv3)rn?C~K?r3^#1WjM54kZY)mmr$N)Zci~WAn#Cp+r6$Afx{351-wVgFyC>PR6M1 zQ0LHFf}k%*OUowkA4_@r0ShRLPOIe!|6$e%^m*bhr9?jfP1Q4d<9zE46_A zBco(zPL3JFiY6e%Z1m@+xI&1r@O?H4v9lItCu@`m1RS(JdEcG_R0nL^iP64R3l`y~ z38&oseBiX-Z9n(C(=dsp#e-AinAi(>FZA4p3$E%E$+0TkXtu1=I{+phj3o!;JPbY~ z$wc-xOrV;J5UADEE{SSZlqkpmG)b92eSI>>{o*a>>U3+hs}iaGH3nm-vHW>0-Qt4G z1R<%5!zeZM3|sc3Ws@enS*Msa@91$caO!S;^W0S?%N72>DIADqkEJ?= zMk14%QMaM^`NO$dTP?iMYN7zeXslH0(;xlxLX=}Jwmg)NRB~}tG_Z=&tEeZ1meomz z$frys_M=fkYKBCgl8Ta`h`93mqe{0B3aspL7Ftor!CRMT_<|Q&*Xs8|H3=!P8>{Ss zbC8&iqhx?(4`n0B6-)q$63jpy>Yl>1AZ8P{S&_diy-->%jAq6JD|NpSg7UD|OK<0X zjo(=KF^UB*^mxw;@|!g=Ttvwf0({^Gr3Z&}b#7j-?iu z|I={6Qwz3s?8aitLj#>x7AB==f{V8BiqmK0hpMEHCBZ13sHX61Myeu{u??A5+FQ@| zZx@2{zNc1Fk5fY!3tnhT-EmtxywLr{u$4SO6!6(&dENtC9ra35v*VO0n2BvGz>i zp!x-a>($BQcLZy7w03#kytFkx^d=ja!ycEh&a@0(Dwks{kz8tRlQC(57)wn}k}{3A zva8Sy56eTuZ4_gmF%>aa7|>pe0OE19xt{ZZQyPfP6%}?nd7&=Wsy!|!4avO&@Jr>* zTEv%h4uf3EQV2{t6iO@>e&`|2Wy)Hmpb}V;gHS|_ERS1+1@-?_e+`|z?R=OS#+rNZ zy!~Xa#bsbi*7%^ZKKSuI9%Hdiw$fnQ(99)5;0uk?(;=;rYhI^A^&xaoNc)aF1VzML zA(Y>=x%6m7k7;&#>nb`1w>N%0J9o!Uem#WJ;PyFPw^D>RatKkkO zrzwuUVoc|Vu3(m;#UN?_<&6{B%*39JP{ea!Xl111+ekw9Zin!Fceh`a;f(!!=#F>0 zDL@pcYX9cohQc9iI{o$|+kfmlC^v zQ!-;YxF~qb_K=4f*eb}7$NEAn-A;jryTNDs#EFnRYek?`c9YOXh>XPuPm-9+O&PLf z2KSLa?dUav4BBW28REB^bY#e`>qpPv4t`SxQu7=acJ!Guh3A($jYq4STOe$g+Lhz5 zb1>GhP59UQqiQ&AUf};rT;NFY0;kO9KH(OY2lgEuri;aKbHoF0@E4$>2VWkQo`A-V z;TVIl-VQnba{N}m=~}|?&_QpR$i|v4{AC3$AJ;D&b$V1|F|42eueWmxogs?jIKLIS z-TsACWl~P)gWQ&sUpeP|Cr0f#%Ko+$T>+(Rk6%PvW zO4&icIHnJ=j1wsvA~q39MGE zm=r#+RjYwcvK5t;EhcicP!QAvJrU&)pI?tNR%a$0Ts%mF*v`hX@+GGq$yasV@=N} zbD&TIxgmOCp)gTj&Sy3bYh&RZC6uq0%fz22s$s=cZC7>*gq3~wlc`Pyx7a{V`eZ$D zqzabF^}C_mNE)FSc;kl0KxP*PYozK7pm(zyd8IuFL9rVTroomWFG%|H=Lu6LSZePE##Mk4SecOy)d#K24>ay`hv zfzdEnIz=nh9q@Nx#p!bmSd(?ym%D_2YxU|71Pj5H<~Wq5yN1`Nvm9>HwjB~dDdr&dtpgk(w}lC&z&BGcS3?-B~@2t%9BqxED1Eh3X+DX z5%}B?1M%@zuYrbE8`g0$E4N+KqKP<*9+AN;l6W5Fx*7t@WJizFwL_oMIjlGxdbWp8 zoMrWTZ}&NuY2752_sjZ8#aU4X=)eLVgYl%$rHg?$DtZkxoMAUO&Wcf6oV1H*+XyUT zU6CiaZ2ogrER)etAE>&lGtP?Bp&k83LpYI)rz$%29XJmjmC?|2cUcj}!@iUf1525$ zC9i=7^9vpg<0d6ICT$2-TT7eYe;{4e3yP})fu*W%Qrcc|`sC)}xqbw)@Xb7z$3d2V zl(GJrz>0NK-FeXqD^trrgJar|&|xI$tstFZ(;I?iZ)T2lH7CjSu+dWm%UKsJq&RsL zwASCj@)|b*5ol$d@;J!yg#`&Lq&Qjf!itn?7-$g3zabI4&LvK45EkA?z`B|@J|hGQ zO}b$vRM>NHl1*#R?4gQ)C~Emp(y2QKS%Br6Rba`3a-33LSg9HY8nl58WLTcu&BLBM543VS_lypL_1XEJImoIF>lF1>XAfTYz>1W@4K(QKd@}wE ztZ5UTui`I8!W%e*3sw^MQnBVUi`M#`4}xH|EQ{p`vi<~CnhbTpDKD(86l$PBw_c;) z`=_vY8nJi(=kqD%x`C_-Z7>>fC$g^R+}U$5xzYdd6(O zzMi}3d~sb5(i*We1q;7mF!sYqQpzGSg7WUkld=Rzm9^iWascens?U5S2VPv1S0zrM zo4PKuZkdQ2A?{*jO73a2ANv6-FL&wC@9`>Cu^4$ZOC?&=A+2pinwm4iqWNjognmA0 zE8miZ6MTjbZtpy@zVfR6vye_zHfG2lqy;i>#b-(wq(S;$nh+(-GXJ88qd%N?_?VH$6h2?DBgFjBISKqB| z;9FxtfAP5P!#dVbhlTquUd{1})3paq&l%dKW8GT0_wvUT&A@tzO=-@GQN1i1dJP&e ze8`wacU5WQR%^UK40QP8G_$gx;uo*_&v-F-P`~cAv}Ni2D;qX^`D*FYww-%MT$t0n zZf%+R?FW`RY-&(TGG8CwUG{sS*l&6Ye!9FdR=)r{&^!=#IK=D#0000assertEquals('543160', $tfa->getCode('VMR466AB62ZBOKHE', 1426847216)); - $this->assertEquals('538532', $tfa->getCode('VMR466AB62ZBOKHE', 0)); - } - - /** - * @expectedException \RobThree\Auth\TwoFactorAuthException - */ - public function testCreateSecretThrowsOnInsecureRNGProvider() { - $rng = new TestRNGProvider(); - - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1', null, $rng); - $tfa->createSecret(); - } - - public function testCreateSecretOverrideSecureDoesNotThrowOnInsecureRNG() { - $rng = new TestRNGProvider(); - - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1', null, $rng); - $this->assertEquals('ABCDEFGHIJKLMNOP', $tfa->createSecret(80, false)); - } - - public function testCreateSecretDoesNotThrowOnSecureRNGProvider() { - $rng = new TestRNGProvider(true); - - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1', null, $rng); - $this->assertEquals('ABCDEFGHIJKLMNOP', $tfa->createSecret()); - } - - public function testCreateSecretGeneratesDesiredAmountOfEntropy() { - $rng = new TestRNGProvider(true); - - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1', null, $rng); - $this->assertEquals('A', $tfa->createSecret(5)); - $this->assertEquals('AB', $tfa->createSecret(6)); - $this->assertEquals('ABCDEFGHIJKLMNOPQRSTUVWXYZ', $tfa->createSecret(128)); - $this->assertEquals('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', $tfa->createSecret(160)); - $this->assertEquals('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567ABCDEFGHIJKLMNOPQRSTUVWXYZ234567', $tfa->createSecret(320)); - $this->assertEquals('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567ABCDEFGHIJKLMNOPQRSTUVWXYZ234567A', $tfa->createSecret(321)); - } - - public function testEnsureCorrectTimeDoesNotThrowForCorrectTime() { - $tpr1 = new TestTimeProvider(123); - $tpr2 = new TestTimeProvider(128); - - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1', null, null, $tpr1); - $tfa->ensureCorrectTime(array($tpr2)); // 128 - 123 = 5 => within default leniency - } - - /** - * @expectedException \RobThree\Auth\TwoFactorAuthException - */ - public function testEnsureCorrectTimeThrowsOnIncorrectTime() { - $tpr1 = new TestTimeProvider(123); - $tpr2 = new TestTimeProvider(124); - - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1', null, null, $tpr1); - $tfa->ensureCorrectTime(array($tpr2), 0); // We force a leniency of 0, 124-123 = 1 so this should throw - } - - - public function testEnsureDefaultTimeProviderReturnsCorrectTime() { - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1'); - $tfa->ensureCorrectTime(array(new TestTimeProvider(time())), 1); // Use a leniency of 1, should the time change between both time() calls - } - - public function testEnsureAllTimeProvidersReturnCorrectTime() { - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1'); - $tfa->ensureCorrectTime(array( - new RobThree\Auth\Providers\Time\ConvertUnixTimeDotComTimeProvider(), - new RobThree\Auth\Providers\Time\HttpTimeProvider(), // Uses google.com by default - new RobThree\Auth\Providers\Time\HttpTimeProvider('https://github.com'), - new RobThree\Auth\Providers\Time\HttpTimeProvider('https://yahoo.com'), - )); - } - - public function testVerifyCodeWorksCorrectly() { - - $tfa = new TwoFactorAuth('Test', 6, 30); - $this->assertEquals(true , $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 1, 1426847190)); - $this->assertEquals(true , $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 0, 1426847190 + 29)); //Test discrepancy - $this->assertEquals(false, $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 0, 1426847190 + 30)); //Test discrepancy - $this->assertEquals(false, $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 0, 1426847190 - 1)); //Test discrepancy - - $this->assertEquals(true , $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 1, 1426847205 + 0)); //Test discrepancy - $this->assertEquals(true , $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 1, 1426847205 + 35)); //Test discrepancy - $this->assertEquals(true , $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 1, 1426847205 - 35)); //Test discrepancy - - $this->assertEquals(false, $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 1, 1426847205 + 65)); //Test discrepancy - $this->assertEquals(false, $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 1, 1426847205 - 65)); //Test discrepancy - - $this->assertEquals(true , $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 2, 1426847205 + 65)); //Test discrepancy - $this->assertEquals(true , $tfa->verifyCode('VMR466AB62ZBOKHE', '543160', 2, 1426847205 - 65)); //Test discrepancy - } - - public function testTotpUriIsCorrect() { - $qr = new TestQrProvider(); - - $tfa = new TwoFactorAuth('Test&Issuer', 6, 30, 'sha1', $qr); - $data = $this->DecodeDataUri($tfa->getQRCodeImageAsDataUri('Test&Label', 'VMR466AB62ZBOKHE')); - $this->assertEquals('test/test', $data['mimetype']); - $this->assertEquals('base64', $data['encoding']); - $this->assertEquals('otpauth://totp/Test%26Label?secret=VMR466AB62ZBOKHE&issuer=Test%26Issuer&period=30&algorithm=SHA1&digits=6@200', $data['data']); - } - - /** - * @expectedException \RobThree\Auth\TwoFactorAuthException - */ - public function testGetQRCodeImageAsDataUriThrowsOnInvalidSize() { - $qr = new TestQrProvider(); - - $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1', $qr); - $tfa->getQRCodeImageAsDataUri('Test', 'VMR466AB62ZBOKHE', 0); - } - - /** - * @expectedException \RobThree\Auth\TwoFactorAuthException - */ - public function testGetCodeThrowsOnInvalidBase32String1() { - $tfa = new TwoFactorAuth('Test'); - $tfa->getCode('FOO1BAR8BAZ9'); //1, 8 & 9 are invalid chars - } - - /** - * @expectedException \RobThree\Auth\TwoFactorAuthException - */ - public function testGetCodeThrowsOnInvalidBase32String2() { - $tfa = new TwoFactorAuth('Test'); - $tfa->getCode('mzxw6==='); //Lowercase - } - - public function testKnownBase32DecodeTestVectors() { - // We usually don't test internals (e.g. privates) but since we rely heavily on base32 decoding and don't want - // to expose this method nor do we want to give people the possibility of implementing / providing their own base32 - // decoding/decoder (as we do with Rng/QR providers for example) we simply test the private base32Decode() method - // with some known testvectors **only** to ensure base32 decoding works correctly following RFC's so there won't - // be any bugs hiding in there. We **could** 'fool' ourselves by calling the public getCode() method (which uses - // base32decode internally) and then make sure getCode's output (in digits) equals expected output since that would - // mean the base32Decode() works as expected but that **could** hide some subtle bug(s) in decoding the base32 string. - - // "In general, you don't want to break any encapsulation for the sake of testing (or as Mom used to say, "don't - // expose your privates!"). Most of the time, you should be able to test a class by exercising its public methods." - // Dave Thomas and Andy Hunt -- "Pragmatic Unit Testing - $tfa = new TwoFactorAuth('Test'); - - $method = new ReflectionMethod('RobThree\Auth\TwoFactorAuth', 'base32Decode'); - $method->setAccessible(true); - - // Test vectors from: https://tools.ietf.org/html/rfc4648#page-12 - $this->assertEquals('', $method->invoke($tfa, '')); - $this->assertEquals('f', $method->invoke($tfa, 'MY======')); - $this->assertEquals('fo', $method->invoke($tfa, 'MZXQ====')); - $this->assertEquals('foo', $method->invoke($tfa, 'MZXW6===')); - $this->assertEquals('foob', $method->invoke($tfa, 'MZXW6YQ=')); - $this->assertEquals('fooba', $method->invoke($tfa, 'MZXW6YTB')); - $this->assertEquals('foobar', $method->invoke($tfa, 'MZXW6YTBOI======')); - } - - public function testKnownBase32DecodeUnpaddedTestVectors() { - // See testKnownBase32DecodeTestVectors() for the rationale behind testing the private base32Decode() method. - // This test ensures that strings without the padding-char ('=') are also decoded correctly. - // https://tools.ietf.org/html/rfc4648#page-4: - // "In some circumstances, the use of padding ("=") in base-encoded data is not required or used." - $tfa = new TwoFactorAuth('Test'); - - $method = new ReflectionMethod('RobThree\Auth\TwoFactorAuth', 'base32Decode'); - $method->setAccessible(true); - - // Test vectors from: https://tools.ietf.org/html/rfc4648#page-12 - $this->assertEquals('', $method->invoke($tfa, '')); - $this->assertEquals('f', $method->invoke($tfa, 'MY')); - $this->assertEquals('fo', $method->invoke($tfa, 'MZXQ')); - $this->assertEquals('foo', $method->invoke($tfa, 'MZXW6')); - $this->assertEquals('foob', $method->invoke($tfa, 'MZXW6YQ')); - $this->assertEquals('fooba', $method->invoke($tfa, 'MZXW6YTB')); - $this->assertEquals('foobar', $method->invoke($tfa, 'MZXW6YTBOI')); - } - - - public function testKnownTestVectors_sha1() { - //Known test vectors for SHA1: https://tools.ietf.org/html/rfc6238#page-15 - $secret = 'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ'; //== base32encode('12345678901234567890') - $tfa = new TwoFactorAuth('Test', 8, 30, 'sha1'); - $this->assertEquals('94287082', $tfa->getCode($secret, 59)); - $this->assertEquals('07081804', $tfa->getCode($secret, 1111111109)); - $this->assertEquals('14050471', $tfa->getCode($secret, 1111111111)); - $this->assertEquals('89005924', $tfa->getCode($secret, 1234567890)); - $this->assertEquals('69279037', $tfa->getCode($secret, 2000000000)); - $this->assertEquals('65353130', $tfa->getCode($secret, 20000000000)); - } - - public function testKnownTestVectors_sha256() { - //Known test vectors for SHA256: https://tools.ietf.org/html/rfc6238#page-15 - $secret = 'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZA'; //== base32encode('12345678901234567890123456789012') - $tfa = new TwoFactorAuth('Test', 8, 30, 'sha256'); - $this->assertEquals('46119246', $tfa->getCode($secret, 59)); - $this->assertEquals('68084774', $tfa->getCode($secret, 1111111109)); - $this->assertEquals('67062674', $tfa->getCode($secret, 1111111111)); - $this->assertEquals('91819424', $tfa->getCode($secret, 1234567890)); - $this->assertEquals('90698825', $tfa->getCode($secret, 2000000000)); - $this->assertEquals('77737706', $tfa->getCode($secret, 20000000000)); - } - - public function testKnownTestVectors_sha512() { - //Known test vectors for SHA512: https://tools.ietf.org/html/rfc6238#page-15 - $secret = 'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNA'; //== base32encode('1234567890123456789012345678901234567890123456789012345678901234') - $tfa = new TwoFactorAuth('Test', 8, 30, 'sha512'); - $this->assertEquals('90693936', $tfa->getCode($secret, 59)); - $this->assertEquals('25091201', $tfa->getCode($secret, 1111111109)); - $this->assertEquals('99943326', $tfa->getCode($secret, 1111111111)); - $this->assertEquals('93441116', $tfa->getCode($secret, 1234567890)); - $this->assertEquals('38618901', $tfa->getCode($secret, 2000000000)); - $this->assertEquals('47863826', $tfa->getCode($secret, 20000000000)); - } - - /** - * @requires function random_bytes - */ - public function testCSRNGProvidersReturnExpectedNumberOfBytes() { - $rng = new \RobThree\Auth\Providers\Rng\CSRNGProvider(); - foreach ($this->getRngTestLengths() as $l) - $this->assertEquals($l, strlen($rng->getRandomBytes($l))); - $this->assertEquals(true, $rng->isCryptographicallySecure()); - } - - /** - * @requires function hash_algos - * @requires function hash - */ - public function testHashRNGProvidersReturnExpectedNumberOfBytes() { - $rng = new \RobThree\Auth\Providers\Rng\HashRNGProvider(); - foreach ($this->getRngTestLengths() as $l) - $this->assertEquals($l, strlen($rng->getRandomBytes($l))); - $this->assertEquals(false, $rng->isCryptographicallySecure()); - } - - /** - * @requires function mcrypt_create_iv - */ - public function testMCryptRNGProvidersReturnExpectedNumberOfBytes() { - $rng = new \RobThree\Auth\Providers\Rng\MCryptRNGProvider(); - foreach ($this->getRngTestLengths() as $l) - $this->assertEquals($l, strlen($rng->getRandomBytes($l))); - $this->assertEquals(true, $rng->isCryptographicallySecure()); - } - - /** - * @requires function openssl_random_pseudo_bytes - */ - public function testStrongOpenSSLRNGProvidersReturnExpectedNumberOfBytes() { - $rng = new \RobThree\Auth\Providers\Rng\OpenSSLRNGProvider(true); - foreach ($this->getRngTestLengths() as $l) - $this->assertEquals($l, strlen($rng->getRandomBytes($l))); - $this->assertEquals(true, $rng->isCryptographicallySecure()); - } - - /** - * @requires function openssl_random_pseudo_bytes - */ - public function testNonStrongOpenSSLRNGProvidersReturnExpectedNumberOfBytes() { - $rng = new \RobThree\Auth\Providers\Rng\OpenSSLRNGProvider(false); - foreach ($this->getRngTestLengths() as $l) - $this->assertEquals($l, strlen($rng->getRandomBytes($l))); - $this->assertEquals(false, $rng->isCryptographicallySecure()); - } - - - private function getRngTestLengths() { - return array(1, 16, 32, 256); - } - - private function DecodeDataUri($datauri) { - if (preg_match('/data:(?P[\w\.\-\/]+);(?P\w+),(?P.*)/', $datauri, $m) === 1) { - return array( - 'mimetype' => $m['mimetype'], - 'encoding' => $m['encoding'], - 'data' => base64_decode($m['data']) - ); - } - return null; - } -} - -class TestRNGProvider implements IRNGProvider { - private $isSecure; - - function __construct($isSecure = false) { - $this->isSecure = $isSecure; - } - - public function getRandomBytes($bytecount) { - $result = ''; - for ($i=0; $i<$bytecount; $i++) - $result.=chr($i); - return $result; - - } - - public function isCryptographicallySecure() { - return $this->isSecure; - } -} - -class TestQrProvider implements IQRCodeProvider { - public function getQRCodeImage($qrtext, $size) { - return $qrtext . '@' . $size; - } - - public function getMimeType() { - return 'test/test'; - } -} - -class TestTimeProvider implements ITimeProvider { - private $time; - - function __construct($time) { - $this->time = $time; - } - - public function getTime() { - return $this->time; - } -} \ No newline at end of file diff --git a/vendor/zendframework/zendxml/.gitignore b/vendor/zendframework/zendxml/.gitignore deleted file mode 100644 index 0a4f6e27..00000000 --- a/vendor/zendframework/zendxml/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -composer.lock -vendor -.buildpath -.project -.settings diff --git a/vendor/zendframework/zendxml/.travis.yml b/vendor/zendframework/zendxml/.travis.yml deleted file mode 100644 index 877b0650..00000000 --- a/vendor/zendframework/zendxml/.travis.yml +++ /dev/null @@ -1,43 +0,0 @@ -sudo: false - -language: php - -branches: - except: - - /^release-.*$/ - - /^ghgfk-.*$/ - -cache: - directories: - - $HOME/.composer/cache - -matrix: - allow_failures: - - php: hhvm -matrix: - fast_finish: true - include: - - php: 5.3 - - php: 5.4 - - php: 5.5 - env: - - EXECUTE_CS_CHECK=true - - php: 5.6 - - php: 7 - - php: hhvm - allow_failures: - - php: hhvm - -before_install: - - composer self-update - -install: - - travis_retry composer install --no-interaction --ignore-platform-reqs - -script: - - ./vendor/bin/phpunit -c ./tests - - if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/phpcs --standard=PSR2 --ignore=tests/Bootstrap.php library tests ; fi - -notifications: - irc: "irc.freenode.org#zftalk.dev" - email: false diff --git a/vendor/zendframework/zendxml/CHANGELOG.md b/vendor/zendframework/zendxml/CHANGELOG.md index bca2961b..20395b1e 100644 --- a/vendor/zendframework/zendxml/CHANGELOG.md +++ b/vendor/zendframework/zendxml/CHANGELOG.md @@ -2,6 +2,30 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. +## 1.1.0 - 2018-04-30 + +### Added + +- [#13](https://github.com/zendframework/ZendXml/pull/13) adds support for PHP 7.1 and 7.2. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- [#13](https://github.com/zendframework/ZendXml/pull/13) removes support for PHP 5.3, 5.4, and 5.5. + +- [#13](https://github.com/zendframework/ZendXml/pull/13) removes support for HHVM. + +### Fixed + +- Nothing. + ## 1.0.2 - 2016-02-04 ### Added diff --git a/vendor/zendframework/zendxml/LICENSE.md b/vendor/zendframework/zendxml/LICENSE.md index 141d3a2d..3aa0dce1 100644 --- a/vendor/zendframework/zendxml/LICENSE.md +++ b/vendor/zendframework/zendxml/LICENSE.md @@ -1,12 +1,27 @@ -Copyright (c) 2014-2015, Zend Technologies USA, Inc. +Copyright (c) 2014-2018, 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: +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 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. +- 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. +- 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. +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/zendframework/zendxml/README.md b/vendor/zendframework/zendxml/README.md index 2c67008d..7da0ddfa 100644 --- a/vendor/zendframework/zendxml/README.md +++ b/vendor/zendframework/zendxml/README.md @@ -1,10 +1,11 @@ -ZendXml -======= +# ZendXml + +[![Build Status](https://secure.travis-ci.org/zendframework/ZendXml.svg?branch=master)](https://secure.travis-ci.org/zendframework/ZendXml) +[![Coverage Status](https://coveralls.io/repos/github/zendframework/ZendXml/badge.svg?branch=master)](https://coveralls.io/github/zendframework/ZendXml?branch=master) An utility component for XML usage and best practices in PHP -Installation ------------- +## Installation You can install using: @@ -16,8 +17,7 @@ php composer.phar install Notice that this library doesn't have any external dependencies, the usage of composer is for autoloading and standard purpose. -ZendXml\Security ----------------- +## ZendXml\Security This is a security component to prevent [XML eXternal Entity](https://www.owasp.org/index.php/XML_External_Entity_%28XXE%29_Processing) (XXE) and [XML Entity Expansion](http://projects.webappsec.org/w/page/13247002/XML%20Entity%20Expansion) (XEE) attacks on XML documents. @@ -46,5 +46,3 @@ $dom = new \DOMDocument('1.0'); $dom = XmlSecurity::scan($xml, $dom); printf ("DOMDocument: %s\n", ($dom instanceof \DOMDocument) ? 'yes' : 'no'); ``` - - diff --git a/vendor/zendframework/zendxml/composer.json b/vendor/zendframework/zendxml/composer.json index d9efb222..28b81108 100644 --- a/vendor/zendframework/zendxml/composer.json +++ b/vendor/zendframework/zendxml/composer.json @@ -1,40 +1,54 @@ { "name": "zendframework/zendxml", "description": "Utility library for XML usage, best practices, and security in PHP", - "type": "library", "license": "BSD-3-Clause", "keywords": [ - "zf2", + "zf", + "zendframework", "xml", "security" ], - "homepage": "http://packages.zendframework.com/", + "support": { + "issues": "https://github.com/zendframework/ZendXml/issues", + "source": "https://github.com/zendframework/ZendXml", + "rss": "https://github.com/zendframework/ZendXml/releases.atom", + "chat": "https://zendframework-slack.herokuapp.com", + "forum": "https://discourse.zendframework.com/c/questions/components" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "zendframework/zend-coding-standard": "~1.0.0", + "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.4" + }, "autoload": { - "psr-0": { - "ZendXml\\": "library/" + "psr-4": { + "ZendXml\\": "src/" } }, "autoload-dev": { "psr-4": { - "ZendTest\\Xml\\": "tests/ZendXmlTest/" + "ZendXmlTest\\": "test/" } }, - "repositories": [ - { - "type": "composer", - "url": "http://packages.zendframework.com/" - } - ], - "require": { - "php": "^5.3.3 || ^7.0" + "config": { + "sort-packages": true }, "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.1.x-dev", + "dev-develop": "1.2.x-dev" } }, - "require-dev": { - "phpunit/phpunit": "^3.7 || ^4.0", - "squizlabs/php_codesniffer": "^1.5" + "scripts": { + "check": [ + "@cs-check", + "@test" + ], + "cs-check": "phpcs", + "cs-fix": "phpcbf", + "test": "phpunit --colors=always", + "test-coverage": "phpunit --colors=always --coverage-clover clover.xml" } } diff --git a/vendor/zendframework/zendxml/library/ZendXml/Exception/ExceptionInterface.php b/vendor/zendframework/zendxml/library/ZendXml/Exception/ExceptionInterface.php deleted file mode 100644 index c55eb903..00000000 --- a/vendor/zendframework/zendxml/library/ZendXml/Exception/ExceptionInterface.php +++ /dev/null @@ -1,14 +0,0 @@ -loadXml($xml, LIBXML_NONET); restore_error_handler(); - if (!$result) { + if (! $result) { // Entity load to previous setting - if (!self::isPhpFpm()) { + if (! self::isPhpFpm()) { libxml_disable_entity_loader($loadEntities); libxml_use_internal_errors($useInternalXmlErrors); } @@ -78,7 +77,7 @@ class Security } // Scan for potential XEE attacks using ENTITY, if not PHP-FPM - if (!self::isPhpFpm()) { + if (! self::isPhpFpm()) { foreach ($dom->childNodes as $child) { if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) { if ($child->entities->length > 0) { @@ -89,14 +88,14 @@ class Security } // Entity load to previous setting - if (!self::isPhpFpm()) { + 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) { + if (! $result instanceof SimpleXMLElement) { return false; } return $result; @@ -114,7 +113,7 @@ class Security */ public static function scanFile($file, DOMDocument $dom = null) { - if (!file_exists($file)) { + if (! file_exists($file)) { throw new Exception\InvalidArgumentException( "The file $file specified doesn't exist" ); @@ -244,28 +243,28 @@ class Security $closePos = strpos($xml, $close); if (false === $closePos) { - return array($fileEncoding); + return [$fileEncoding]; } $encPos = strpos($xml, $encAttr); if (false === $encPos || $encPos > $closePos ) { - return array($fileEncoding); + return [$fileEncoding]; } $encPos += strlen($encAttr); $quotePos = strpos($xml, $quote, $encPos); if (false === $quotePos) { - return array($fileEncoding); + return [$fileEncoding]; } $encoding = self::substr($xml, $encPos, $quotePos); - return array( + return [ // Following line works because we're only supporting 8-bit safe encodings at this time. str_replace('\0', '', $encoding), // detected encoding $fileEncoding, // file encoding - ); + ]; } /** @@ -279,38 +278,38 @@ class Security */ protected static function getBomMap() { - return array( - array( + return [ + [ '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, - ), - ); + ], + ]; } /** @@ -324,7 +323,7 @@ class Security */ protected static function getAsciiEncodingMap() { - return array( + return [ 'UTF-32BE' => function ($ascii) { return preg_replace('/(.)/', "\0\0\0\\1", $ascii); }, @@ -349,7 +348,7 @@ class Security 'GB-18030' => function ($ascii) { return $ascii; }, - ); + ]; } /** diff --git a/vendor/zendframework/zendxml/tests/Bootstrap.php b/vendor/zendframework/zendxml/tests/Bootstrap.php deleted file mode 100644 index a9d0e6a5..00000000 --- a/vendor/zendframework/zendxml/tests/Bootstrap.php +++ /dev/null @@ -1,92 +0,0 @@ -addDirectoryToWhitelist($zfCoreLibrary . '/' . $lastArg); - } elseif (is_file($zfCoreTests . '/' . $lastArg)) { - $codeCoverageFilter->addDirectoryToWhitelist(dirname($zfCoreLibrary . '/' . $lastArg)); - } else { - $codeCoverageFilter->addDirectoryToWhitelist($zfCoreLibrary); - } - - /* - * Omit from code coverage reports the contents of the tests directory - */ - $codeCoverageFilter->addDirectoryToBlacklist($zfCoreTests, ''); - $codeCoverageFilter->addDirectoryToBlacklist(PEAR_INSTALL_DIR, ''); - $codeCoverageFilter->addDirectoryToBlacklist(PHP_LIBDIR, ''); - - unset($codeCoverageFilter); -} - -/* - * Unset global variables that are no longer needed. - */ -unset($phpUnitVersion); diff --git a/vendor/zendframework/zendxml/tests/ZendXmlTest/MultibyteTest.php b/vendor/zendframework/zendxml/tests/ZendXmlTest/MultibyteTest.php deleted file mode 100644 index 165e8fa5..00000000 --- a/vendor/zendframework/zendxml/tests/ZendXmlTest/MultibyteTest.php +++ /dev/null @@ -1,125 +0,0 @@ - array('UTF-16LE', pack('CC', 0xff, 0xfe), 3), - 'UTF-16BE' => array('UTF-16BE', pack('CC', 0xfe, 0xff), 3), - 'UTF-32LE' => array('UTF-32LE', pack('CCCC', 0xff, 0xfe, 0x00, 0x00), 4), - 'UTF-32BE' => array('UTF-32BE', pack('CCCC', 0x00, 0x00, 0xfe, 0xff), 4), - ); - } - - public function getXmlWithXXE() - { - return << - -]> - - retrieved: &pocdata; - -XML; - } - - /** - * Invoke ZendXml\Security::heuristicScan with the provided XML. - * - * @param string $xml - * @return void - * @throws Exception\RuntimeException - */ - public function invokeHeuristicScan($xml) - { - $r = new ReflectionMethod('ZendXml\Security', 'heuristicScan'); - $r->setAccessible(true); - return $r->invoke(null, $xml); - } - - /** - * @dataProvider multibyteEncodings - * @group heuristicDetection - */ - public function testDetectsMultibyteXXEVectorsUnderFPMWithEncodedStringMissingBOM($encoding, $bom, $bomLength) - { - $xml = $this->getXmlWithXXE(); - $xml = str_replace('{ENCODING}', $encoding, $xml); - $xml = iconv('UTF-8', $encoding, $xml); - $this->assertNotSame(0, strncmp($xml, $bom, $bomLength)); - $this->setExpectedException('ZendXml\Exception\RuntimeException', 'ENTITY'); - $this->invokeHeuristicScan($xml); - } - - /** - * @dataProvider multibyteEncodings - */ - public function testDetectsMultibyteXXEVectorsUnderFPMWithEncodedStringUsingBOM($encoding, $bom) - { - $xml = $this->getXmlWithXXE(); - $xml = str_replace('{ENCODING}', $encoding, $xml); - $orig = iconv('UTF-8', $encoding, $xml); - $xml = $bom . $orig; - $this->setExpectedException('ZendXml\Exception\RuntimeException', 'ENTITY'); - $this->invokeHeuristicScan($xml); - } - - public function getXmlWithoutXXE() - { - return << - - retrieved: &pocdata; - -XML; - } - - /** - * @dataProvider multibyteEncodings - */ - public function testDoesNotFlagValidMultibyteXmlAsInvalidUnderFPM($encoding) - { - $xml = $this->getXmlWithoutXXE(); - $xml = str_replace('{ENCODING}', $encoding, $xml); - $xml = iconv('UTF-8', $encoding, $xml); - try { - $result = $this->invokeHeuristicScan($xml); - $this->assertNull($result); - } catch (\Exception $e) { - $this->fail('Security scan raised exception when it should not have'); - } - } - - /** - * @dataProvider multibyteEncodings - * @group mixedEncoding - */ - public function testDetectsXXEWhenXMLDocumentEncodingDiffersFromFileEncoding($encoding, $bom) - { - $xml = $this->getXmlWithXXE(); - $xml = str_replace('{ENCODING}', 'UTF-8', $xml); - $xml = iconv('UTF-8', $encoding, $xml); - $xml = $bom . $xml; - $this->setExpectedException('ZendXml\Exception\RuntimeException', 'ENTITY'); - $this->invokeHeuristicScan($xml); - } -} diff --git a/vendor/zendframework/zendxml/tests/ZendXmlTest/SecurityTest.php b/vendor/zendframework/zendxml/tests/ZendXmlTest/SecurityTest.php deleted file mode 100644 index fa3b30bf..00000000 --- a/vendor/zendframework/zendxml/tests/ZendXmlTest/SecurityTest.php +++ /dev/null @@ -1,135 +0,0 @@ - -]> - - This result is &harmless; - -XML; - - $this->setExpectedException('ZendXml\Exception\RuntimeException'); - $result = XmlSecurity::scan($xml); - } - - public function testScanForXXE() - { - $file = tempnam(sys_get_temp_dir(), 'ZendXml_Security'); - file_put_contents($file, 'This is a remote content!'); - $xml = << - -]> - - &foo; - -XML; - - try { - $result = XmlSecurity::scan($xml); - } catch (Exception\RuntimeException $e) { - unlink($file); - return; - } - $this->fail('An expected exception has not been raised.'); - } - - public function testScanSimpleXmlResult() - { - $result = XmlSecurity::scan($this->getXml()); - $this->assertTrue($result instanceof SimpleXMLElement); - $this->assertEquals($result->result, 'test'); - } - - public function testScanDom() - { - $dom = new DOMDocument('1.0'); - $result = XmlSecurity::scan($this->getXml(), $dom); - $this->assertTrue($result instanceof DOMDocument); - $node = $result->getElementsByTagName('result')->item(0); - $this->assertEquals($node->nodeValue, 'test'); - } - - public function testScanInvalidXml() - { - $xml = <<test -XML; - - $result = XmlSecurity::scan($xml); - $this->assertFalse($result); - } - - public function testScanInvalidXmlDom() - { - $xml = <<test -XML; - - $dom = new DOMDocument('1.0'); - $result = XmlSecurity::scan($xml, $dom); - $this->assertFalse($result); - } - - public function testScanFile() - { - $file = tempnam(sys_get_temp_dir(), 'ZendXml_Security'); - file_put_contents($file, $this->getXml()); - - $result = XmlSecurity::scanFile($file); - $this->assertTrue($result instanceof SimpleXMLElement); - $this->assertEquals($result->result, 'test'); - unlink($file); - } - - public function testScanXmlWithDTD() - { - $xml = << - - -]> - - test - -XML; - - $dom = new DOMDocument('1.0'); - $result = XmlSecurity::scan($xml, $dom); - $this->assertTrue($result instanceof DOMDocument); - $this->assertTrue($result->validate()); - } - - protected function getXml() - { - return << - - test - -XML; - } -} diff --git a/vendor/zendframework/zendxml/tests/phpunit.xml.dist b/vendor/zendframework/zendxml/tests/phpunit.xml.dist deleted file mode 100755 index 069784bd..00000000 --- a/vendor/zendframework/zendxml/tests/phpunit.xml.dist +++ /dev/null @@ -1,27 +0,0 @@ - - - - ./ZendXmlTest - ./ZendXmlTest/TestAsset - - - - - - - - - - - - - - ./ZendXmlTest - ../vendor - - - - - - -