관리-도구
편집 파일: polyfill-php56.tar
Php56.php 0000604 00000007454 15224653550 0006174 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Polyfill\Php56; use Symfony\Polyfill\Util\Binary; /** * @internal */ final class Php56 { const LDAP_ESCAPE_FILTER = 1; const LDAP_ESCAPE_DN = 2; public static function hash_equals($knownString, $userInput) { if (!is_string($knownString)) { trigger_error('Expected known_string to be a string, '.gettype($knownString).' given', E_USER_WARNING); return false; } if (!is_string($userInput)) { trigger_error('Expected user_input to be a string, '.gettype($userInput).' given', E_USER_WARNING); return false; } $knownLen = Binary::strlen($knownString); $userLen = Binary::strlen($userInput); if ($knownLen !== $userLen) { return false; } $result = 0; for ($i = 0; $i < $knownLen; ++$i) { $result |= ord($knownString[$i]) ^ ord($userInput[$i]); } return 0 === $result; } /** * Stub implementation of the {@link ldap_escape()} function of the ldap * extension. * * Escape strings for safe use in LDAP filters and DNs. * * @author Chris Wright <ldapi@daverandom.com> * * @param string $subject * @param string $ignore * @param int $flags * * @return string * * @see http://stackoverflow.com/a/8561604 */ public static function ldap_escape($subject, $ignore = '', $flags = 0) { static $charMaps = null; if (null === $charMaps) { $charMaps = array( self::LDAP_ESCAPE_FILTER => array('\\', '*', '(', ')', "\x00"), self::LDAP_ESCAPE_DN => array('\\', ',', '=', '+', '<', '>', ';', '"', '#', "\r"), ); $charMaps[0] = array(); for ($i = 0; $i < 256; ++$i) { $charMaps[0][chr($i)] = sprintf('\\%02x', $i); } for ($i = 0, $l = count($charMaps[self::LDAP_ESCAPE_FILTER]); $i < $l; ++$i) { $chr = $charMaps[self::LDAP_ESCAPE_FILTER][$i]; unset($charMaps[self::LDAP_ESCAPE_FILTER][$i]); $charMaps[self::LDAP_ESCAPE_FILTER][$chr] = $charMaps[0][$chr]; } for ($i = 0, $l = count($charMaps[self::LDAP_ESCAPE_DN]); $i < $l; ++$i) { $chr = $charMaps[self::LDAP_ESCAPE_DN][$i]; unset($charMaps[self::LDAP_ESCAPE_DN][$i]); $charMaps[self::LDAP_ESCAPE_DN][$chr] = $charMaps[0][$chr]; } } // Create the base char map to escape $flags = (int) $flags; $charMap = array(); if ($flags & self::LDAP_ESCAPE_FILTER) { $charMap += $charMaps[self::LDAP_ESCAPE_FILTER]; } if ($flags & self::LDAP_ESCAPE_DN) { $charMap += $charMaps[self::LDAP_ESCAPE_DN]; } if (!$charMap) { $charMap = $charMaps[0]; } // Remove any chars to ignore from the list $ignore = (string) $ignore; for ($i = 0, $l = strlen($ignore); $i < $l; ++$i) { unset($charMap[$ignore[$i]]); } // Do the main replacement $result = strtr($subject, $charMap); // Encode leading/trailing spaces if self::LDAP_ESCAPE_DN is passed if ($flags & self::LDAP_ESCAPE_DN) { if ($result[0] === ' ') { $result = '\\20'.substr($result, 1); } if ($result[strlen($result) - 1] === ' ') { $result = substr($result, 0, -1).'\\20'; } } return $result; } } composer.json 0000604 00000001535 15224653550 0007275 0 ustar 00 { "name": "symfony/polyfill-php56", "type": "library", "description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions", "keywords": ["polyfill", "shim", "compatibility", "portable"], "homepage": "https://symfony.com", "license": "MIT", "authors": [ { "name": "Nicolas Grekas", "email": "p@tchwork.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], "require": { "php": ">=5.3.3", "symfony/polyfill-util": "~1.0" }, "autoload": { "psr-4": { "Symfony\\Polyfill\\Php56\\": "" }, "files": [ "bootstrap.php" ] }, "minimum-stability": "dev", "extra": { "branch-alias": { "dev-master": "1.5-dev" } } } README.md 0000604 00000001003 15224653550 0006020 0 ustar 00 Symfony Polyfill / Php56 ======================== This component provides functions unavailable in releases prior to PHP 5.6: - [`hash_equals`](http://php.net/hash_equals) (part of [hash](http://php.net/hash) extension) - [`ldap_escape`](http://php.net/ldap_escape) (part of [ldap](http://php.net/ldap) extension) More information can be found in the [main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md). License ======= This library is released under the [MIT license](LICENSE). LICENSE 0000604 00000002051 15224653550 0005552 0 ustar 00 Copyright (c) 2014-2016 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. bootstrap.php 0000604 00000002752 15224653550 0007303 0 ustar 00 <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Symfony\Polyfill\Php56 as p; if (PHP_VERSION_ID < 50600) { if (!function_exists('hash_equals')) { function hash_equals($knownString, $userInput) { return p\Php56::hash_equals($knownString, $userInput); } } if (extension_loaded('ldap') && !function_exists('ldap_escape')) { define('LDAP_ESCAPE_FILTER', 1); define('LDAP_ESCAPE_DN', 2); function ldap_escape($subject, $ignore = '', $flags = 0) { return p\Php56::ldap_escape($subject, $ignore, $flags); } } if (50509 === PHP_VERSION_ID && 4 === PHP_INT_SIZE) { // Missing functions in PHP 5.5.9 - affects 32 bit builds of Ubuntu 14.04LTS // See https://bugs.launchpad.net/ubuntu/+source/php5/+bug/1315888 if (!function_exists('gzopen') && function_exists('gzopen64')) { function gzopen($filename, $mode, $use_include_path = 0) { return gzopen64($filename, $mode, $use_include_path); } } if (!function_exists('gzseek') && function_exists('gzseek64')) { function gzseek($zp, $offset, $whence = SEEK_SET) { return gzseek64($zp, $offset, $whence); } } if (!function_exists('gztell') && function_exists('gztell64')) { function gztell($zp) { return gztell64($zp); } } } }