diff options
| author | Andreas Fischer <bantu@phpbb.com> | 2010-12-28 22:40:09 +0100 |
|---|---|---|
| committer | Andreas Fischer <bantu@phpbb.com> | 2010-12-28 22:40:09 +0100 |
| commit | 6e51e52f0c0f34a5dea8e3e1730de039ed5895e6 (patch) | |
| tree | 77a05c95078c7f86bfd1c5ae3780788198694e0e /phpBB/includes/functions.php | |
| parent | 90ccdb4dad6521fe0431ab1e9373c5821156bc46 (diff) | |
| parent | 6b4d0a254218e8d40151ca1bdff8c439f89502e9 (diff) | |
| download | forums-6e51e52f0c0f34a5dea8e3e1730de039ed5895e6.tar forums-6e51e52f0c0f34a5dea8e3e1730de039ed5895e6.tar.gz forums-6e51e52f0c0f34a5dea8e3e1730de039ed5895e6.tar.bz2 forums-6e51e52f0c0f34a5dea8e3e1730de039ed5895e6.tar.xz forums-6e51e52f0c0f34a5dea8e3e1730de039ed5895e6.zip | |
Merge branch 'ticket/igorw/9574' into develop
* ticket/igorw/9574:
[ticket/9574] Add pcre_utf8_support() function
[ticket/9574] Remove conditional PHP<5.2 code
[ticket/9574] Drop fallback implementations
Diffstat (limited to 'phpBB/includes/functions.php')
| -rw-r--r-- | phpBB/includes/functions.php | 139 |
1 files changed, 21 insertions, 118 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 32fff0d715..285c3938c1 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -394,7 +394,7 @@ function _hash_gensalt_private($input, &$itoa64, $iteration_count_log2 = 6) } $output = '$H$'; - $output .= $itoa64[min($iteration_count_log2 + ((PHP_VERSION >= 5) ? 5 : 3), 30)]; + $output .= $itoa64[min($iteration_count_log2 + 5, 30)]; $output .= _hash_encode64($input, 6, $itoa64); return $output; @@ -480,24 +480,12 @@ function _hash_crypt_private($password, $setting, &$itoa64) * consequently in lower iteration counts and hashes that are * quicker to crack (by non-PHP code). */ - if (PHP_VERSION >= 5) - { - $hash = md5($salt . $password, true); - do - { - $hash = md5($hash . $password, true); - } - while (--$count); - } - else + $hash = md5($salt . $password, true); + do { - $hash = pack('H*', md5($salt . $password)); - do - { - $hash = pack('H*', md5($hash . $password)); - } - while (--$count); + $hash = md5($hash . $password, true); } + while (--$count); $output = substr($setting, 0, 12); $output .= _hash_encode64($hash, 16, $itoa64); @@ -752,95 +740,6 @@ function phpbb_is_writable($file) } } -// Compatibility functions - -if (!function_exists('array_combine')) -{ - /** - * A wrapper for the PHP5 function array_combine() - * @param array $keys contains keys for the resulting array - * @param array $values contains values for the resulting array - * - * @return Returns an array by using the values from the keys array as keys and the - * values from the values array as the corresponding values. Returns false if the - * number of elements for each array isn't equal or if the arrays are empty. - */ - function array_combine($keys, $values) - { - $keys = array_values($keys); - $values = array_values($values); - - $n = sizeof($keys); - $m = sizeof($values); - if (!$n || !$m || ($n != $m)) - { - return false; - } - - $combined = array(); - for ($i = 0; $i < $n; $i++) - { - $combined[$keys[$i]] = $values[$i]; - } - return $combined; - } -} - -if (!function_exists('str_split')) -{ - /** - * A wrapper for the PHP5 function str_split() - * @param array $string contains the string to be converted - * @param array $split_length contains the length of each chunk - * - * @return Converts a string to an array. If the optional split_length parameter is specified, - * the returned array will be broken down into chunks with each being split_length in length, - * otherwise each chunk will be one character in length. FALSE is returned if split_length is - * less than 1. If the split_length length exceeds the length of string, the entire string is - * returned as the first (and only) array element. - */ - function str_split($string, $split_length = 1) - { - if ($split_length < 1) - { - return false; - } - else if ($split_length >= strlen($string)) - { - return array($string); - } - else - { - preg_match_all('#.{1,' . $split_length . '}#s', $string, $matches); - return $matches[0]; - } - } -} - -if (!function_exists('stripos')) -{ - /** - * A wrapper for the PHP5 function stripos - * Find position of first occurrence of a case-insensitive string - * - * @param string $haystack is the string to search in - * @param string $needle is the string to search for - * - * @return mixed Returns the numeric position of the first occurrence of needle in the haystack string. Unlike strpos(), stripos() is case-insensitive. - * Note that the needle may be a string of one or more characters. - * If needle is not found, stripos() will return boolean FALSE. - */ - function stripos($haystack, $needle) - { - if (preg_match('#' . preg_quote($needle, '#') . '#i', $haystack, $m)) - { - return strpos($haystack, $m[0]); - } - - return false; - } -} - /** * Checks if a path ($path) is absolute or relative * @@ -1046,18 +945,6 @@ else } } -if (!function_exists('htmlspecialchars_decode')) -{ - /** - * A wrapper for htmlspecialchars_decode - * @ignore - */ - function htmlspecialchars_decode($string, $quote_style = ENT_COMPAT) - { - return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style))); - } -} - // functions used for building option fields /** @@ -4620,3 +4507,19 @@ function phpbb_user_session_handler() return; } + +/** +* Check if PCRE has UTF-8 support +* PHP may not be linked with the bundled PCRE lib and instead with an older version +* +* @return bool Returns true if PCRE (the regular expressions library) supports UTF-8 encoding +*/ +function pcre_utf8_support() +{ + static $utf8_pcre_properties = null; + if (is_null($utf8_pcre_properties)) + { + $utf8_pcre_properties = (@preg_match('/\p{L}/u', 'a') !== false); + } + return $utf8_pcre_properties; +} |
