mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
- pretty serious speed improvement for strtoupper/strtolower
- mbstring envrio checks #5774 git-svn-id: file:///svn/phpbb/trunk@6701 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
7a79c74288
commit
e08317eb71
3 changed files with 175 additions and 116 deletions
|
@ -18,6 +18,9 @@ if (!defined('IN_PHPBB'))
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enforce ASCII only string handling
|
||||||
|
setlocale(LC_CTYPE, 'C');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UTF-8 tools
|
* UTF-8 tools
|
||||||
*
|
*
|
||||||
|
@ -104,6 +107,8 @@ if (!extension_loaded('xml'))
|
||||||
// if mbstring is not loaded, we go into native mode.
|
// if mbstring is not loaded, we go into native mode.
|
||||||
if (extension_loaded('mbstring'))
|
if (extension_loaded('mbstring'))
|
||||||
{
|
{
|
||||||
|
mb_internal_encoding('UTF-8');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UTF-8 aware alternative to strrpos
|
* UTF-8 aware alternative to strrpos
|
||||||
* Find position of last occurrence of a char in a string
|
* Find position of last occurrence of a char in a string
|
||||||
|
@ -320,14 +325,21 @@ else
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$UTF8_UPPER_TO_LOWER = array(
|
/**
|
||||||
"\x41" => "\x61", "\x42" => "\x62", "\x43" => "\x63", "\x44" => "\x64",
|
* UTF-8 aware alternative to strtolower
|
||||||
"\x45" => "\x65", "\x46" => "\x66", "\x47" => "\x67", "\x48" => "\x68",
|
* Make a string lowercase
|
||||||
"\x49" => "\x69", "\x4A" => "\x6A", "\x4B" => "\x6B", "\x4C" => "\x6C",
|
* Note: The concept of a characters "case" only exists is some alphabets
|
||||||
"\x4D" => "\x6D", "\x4E" => "\x6E", "\x4F" => "\x6F", "\x50" => "\x70",
|
* such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does
|
||||||
"\x51" => "\x71", "\x52" => "\x72", "\x53" => "\x73", "\x54" => "\x74",
|
* not exist in the Chinese alphabet, for example. See Unicode Standard
|
||||||
"\x55" => "\x75", "\x56" => "\x76", "\x57" => "\x77", "\x58" => "\x78",
|
* Annex #21: Case Mappings
|
||||||
"\x59" => "\x79", "\x5A" => "\x7A", "\xC3\x80" => "\xC3\xA0", "\xC3\x81" => "\xC3\xA1",
|
*
|
||||||
|
* @param string
|
||||||
|
* @return string string in lowercase
|
||||||
|
*/
|
||||||
|
function utf8_strtolower($string)
|
||||||
|
{
|
||||||
|
static $UTF8_UPPER_TO_LOWER = array(
|
||||||
|
"\xC3\x80" => "\xC3\xA0", "\xC3\x81" => "\xC3\xA1",
|
||||||
"\xC3\x82" => "\xC3\xA2", "\xC3\x83" => "\xC3\xA3", "\xC3\x84" => "\xC3\xA4", "\xC3\x85" => "\xC3\xA5",
|
"\xC3\x82" => "\xC3\xA2", "\xC3\x83" => "\xC3\xA3", "\xC3\x84" => "\xC3\xA4", "\xC3\x85" => "\xC3\xA5",
|
||||||
"\xC3\x86" => "\xC3\xA6", "\xC3\x87" => "\xC3\xA7", "\xC3\x88" => "\xC3\xA8", "\xC3\x89" => "\xC3\xA9",
|
"\xC3\x86" => "\xC3\xA6", "\xC3\x87" => "\xC3\xA7", "\xC3\x88" => "\xC3\xA8", "\xC3\x89" => "\xC3\xA9",
|
||||||
"\xC3\x8A" => "\xC3\xAA", "\xC3\x8B" => "\xC3\xAB", "\xC3\x8C" => "\xC3\xAC", "\xC3\x8D" => "\xC3\xAD",
|
"\xC3\x8A" => "\xC3\xAA", "\xC3\x8B" => "\xC3\xAB", "\xC3\x8C" => "\xC3\xAC", "\xC3\x8D" => "\xC3\xAD",
|
||||||
|
@ -375,14 +387,24 @@ else
|
||||||
"\xE1\xBA\x82" => "\xE1\xBA\x83", "\xE1\xBA\x84" => "\xE1\xBA\x85", "\xE1\xBB\xB2" => "\xE1\xBB\xB3"
|
"\xE1\xBA\x82" => "\xE1\xBA\x83", "\xE1\xBA\x84" => "\xE1\xBA\x85", "\xE1\xBB\xB2" => "\xE1\xBB\xB3"
|
||||||
);
|
);
|
||||||
|
|
||||||
$UTF8_LOWER_TO_UPPER = array(
|
return strtr(strtolower($string), $UTF8_UPPER_TO_LOWER);
|
||||||
"\x61" => "\x41", "\x62" => "\x42", "\x63" => "\x43", "\x64" => "\x44",
|
}
|
||||||
"\x65" => "\x45", "\x66" => "\x46", "\x67" => "\x47", "\x68" => "\x48",
|
|
||||||
"\x69" => "\x49", "\x6A" => "\x4A", "\x6B" => "\x4B", "\x6C" => "\x4C",
|
/**
|
||||||
"\x6D" => "\x4D", "\x6E" => "\x4E", "\x6F" => "\x4F", "\x70" => "\x50",
|
* UTF-8 aware alternative to strtoupper
|
||||||
"\x71" => "\x51", "\x72" => "\x52", "\x73" => "\x53", "\x74" => "\x54",
|
* Make a string uppercase
|
||||||
"\x75" => "\x55", "\x76" => "\x56", "\x77" => "\x57", "\x78" => "\x58",
|
* Note: The concept of a characters "case" only exists is some alphabets
|
||||||
"\x79" => "\x59", "\x7A" => "\x5A", "\xC3\xA0" => "\xC3\x80", "\xC3\xA1" => "\xC3\x81",
|
* such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does
|
||||||
|
* not exist in the Chinese alphabet, for example. See Unicode Standard
|
||||||
|
* Annex #21: Case Mappings
|
||||||
|
*
|
||||||
|
* @param string
|
||||||
|
* @return string string in uppercase
|
||||||
|
*/
|
||||||
|
function utf8_strtoupper($string)
|
||||||
|
{
|
||||||
|
static $UTF8_LOWER_TO_UPPER = array(
|
||||||
|
"\xC3\xA0" => "\xC3\x80", "\xC3\xA1" => "\xC3\x81",
|
||||||
"\xC3\xA2" => "\xC3\x82", "\xC3\xA3" => "\xC3\x83", "\xC3\xA4" => "\xC3\x84", "\xC3\xA5" => "\xC3\x85",
|
"\xC3\xA2" => "\xC3\x82", "\xC3\xA3" => "\xC3\x83", "\xC3\xA4" => "\xC3\x84", "\xC3\xA5" => "\xC3\x85",
|
||||||
"\xC3\xA6" => "\xC3\x86", "\xC3\xA7" => "\xC3\x87", "\xC3\xA8" => "\xC3\x88", "\xC3\xA9" => "\xC3\x89",
|
"\xC3\xA6" => "\xC3\x86", "\xC3\xA7" => "\xC3\x87", "\xC3\xA8" => "\xC3\x88", "\xC3\xA9" => "\xC3\x89",
|
||||||
"\xC3\xAA" => "\xC3\x8A", "\xC3\xAB" => "\xC3\x8B", "\xC3\xAC" => "\xC3\x8C", "\xC3\xAD" => "\xC3\x8D",
|
"\xC3\xAA" => "\xC3\x8A", "\xC3\xAB" => "\xC3\x8B", "\xC3\xAC" => "\xC3\x8C", "\xC3\xAD" => "\xC3\x8D",
|
||||||
|
@ -430,40 +452,7 @@ else
|
||||||
"\xE1\xBA\x83" => "\xE1\xBA\x82", "\xE1\xBA\x85" => "\xE1\xBA\x84", "\xE1\xBB\xB3" => "\xE1\xBB\xB2"
|
"\xE1\xBA\x83" => "\xE1\xBA\x82", "\xE1\xBA\x85" => "\xE1\xBA\x84", "\xE1\xBB\xB3" => "\xE1\xBB\xB2"
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
return strtr(strtoupper($string), $UTF8_LOWER_TO_UPPER);
|
||||||
* UTF-8 aware alternative to strtolower
|
|
||||||
* Make a string lowercase
|
|
||||||
* Note: The concept of a characters "case" only exists is some alphabets
|
|
||||||
* such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does
|
|
||||||
* not exist in the Chinese alphabet, for example. See Unicode Standard
|
|
||||||
* Annex #21: Case Mappings
|
|
||||||
*
|
|
||||||
* @param string
|
|
||||||
* @return string string in lowercase
|
|
||||||
*/
|
|
||||||
function utf8_strtolower($string)
|
|
||||||
{
|
|
||||||
global $UTF8_UPPER_TO_LOWER;
|
|
||||||
|
|
||||||
return strtr($string, $UTF8_UPPER_TO_LOWER);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UTF-8 aware alternative to strtoupper
|
|
||||||
* Make a string uppercase
|
|
||||||
* Note: The concept of a characters "case" only exists is some alphabets
|
|
||||||
* such as Latin, Greek, Cyrillic, Armenian and archaic Georgian - it does
|
|
||||||
* not exist in the Chinese alphabet, for example. See Unicode Standard
|
|
||||||
* Annex #21: Case Mappings
|
|
||||||
*
|
|
||||||
* @param string
|
|
||||||
* @return string string in uppercase
|
|
||||||
*/
|
|
||||||
function utf8_strtoupper($string)
|
|
||||||
{
|
|
||||||
global $UTF8_LOWER_TO_UPPER;
|
|
||||||
|
|
||||||
return strtr($string, $UTF8_LOWER_TO_UPPER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -206,6 +206,64 @@ class install_install extends module
|
||||||
'S_LEGEND' => false,
|
'S_LEGEND' => false,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$passed['mbstring'] = true;
|
||||||
|
if (extension_loaded('mbstring'))
|
||||||
|
{
|
||||||
|
// Test for available database modules
|
||||||
|
$template->assign_block_vars('checks', array(
|
||||||
|
'S_LEGEND' => true,
|
||||||
|
'S_FIRST_ROW' => false,
|
||||||
|
'LEGEND' => $lang['MBSTRING_CHECK'],
|
||||||
|
'LEGEND_EXPLAIN' => $lang['MBSTRING_CHECK_EXPLAIN'],
|
||||||
|
));
|
||||||
|
|
||||||
|
$checks = array(
|
||||||
|
array('func_overload', '&', MB_OVERLOAD_MAIL|MB_OVERLOAD_STRING),
|
||||||
|
array('encoding_translation', '!=', 0),
|
||||||
|
array('http_input', '!=', 'pass'),
|
||||||
|
array('http_output', '!=', 'pass')
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($checks as $mb_checks)
|
||||||
|
{
|
||||||
|
$ini_val = ini_get('mbstring.' . $mb_checks[0]);
|
||||||
|
switch ($mb_checks[1])
|
||||||
|
{
|
||||||
|
case '&':
|
||||||
|
if (intval($ini_val) & $mb_checks[2])
|
||||||
|
{
|
||||||
|
$result = '<b style="color:red">' . $lang['NO'] . '</b>';
|
||||||
|
$passed['mbstring'] = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$result = '<b style="color:green">' . $lang['YES'] . '</b>';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '!=':
|
||||||
|
if ($ini_val != $mb_checks[2])
|
||||||
|
{
|
||||||
|
$result = '<b style="color:red">' . $lang['NO'] . '</b>';
|
||||||
|
$passed['mbstring'] = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$result = '<b style="color:green">' . $lang['YES'] . '</b>';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$template->assign_block_vars('checks', array(
|
||||||
|
'TITLE' => $lang['MBSTRING_' . strtoupper($mb_checks[0])],
|
||||||
|
'TITLE_EXPLAIN' => $lang['MBSTRING_' . strtoupper($mb_checks[0]) . '_EXPLAIN'],
|
||||||
|
'RESULT' => $result,
|
||||||
|
|
||||||
|
'S_EXPLAIN' => true,
|
||||||
|
'S_LEGEND' => false,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Test for available database modules
|
// Test for available database modules
|
||||||
$template->assign_block_vars('checks', array(
|
$template->assign_block_vars('checks', array(
|
||||||
'S_LEGEND' => true,
|
'S_LEGEND' => true,
|
||||||
|
@ -415,8 +473,8 @@ class install_install extends module
|
||||||
// And finally where do we want to go next (well today is taken isn't it :P)
|
// And finally where do we want to go next (well today is taken isn't it :P)
|
||||||
$s_hidden_fields = ($img_imagick) ? '<input type="hidden" name="img_imagick" value="' . addslashes($img_imagick) . '" />' : '';
|
$s_hidden_fields = ($img_imagick) ? '<input type="hidden" name="img_imagick" value="' . addslashes($img_imagick) . '" />' : '';
|
||||||
|
|
||||||
$url = ($passed['php'] && $passed['db'] && $passed['files'] && $passed['pcre']) ? $this->p_master->module_url . "?mode=$mode&sub=database&language=$language" : $this->p_master->module_url . "?mode=$mode&sub=requirements&language=$language ";
|
$url = ($passed['php'] && $passed['db'] && $passed['files'] && $passed['pcre'] && $passed['mbstring']) ? $this->p_master->module_url . "?mode=$mode&sub=database&language=$language" : $this->p_master->module_url . "?mode=$mode&sub=requirements&language=$language ";
|
||||||
$submit = ($passed['php'] && $passed['db'] && $passed['files'] && $passed['pcre']) ? $lang['INSTALL_START'] : $lang['INSTALL_TEST'];
|
$submit = ($passed['php'] && $passed['db'] && $passed['files'] && $passed['pcre'] && $passed['mbstring']) ? $lang['INSTALL_START'] : $lang['INSTALL_TEST'];
|
||||||
|
|
||||||
|
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(array(
|
||||||
|
|
|
@ -209,6 +209,18 @@ $lang = array_merge($lang, array(
|
||||||
'INST_ERR_USER_TOO_SHORT' => 'The username you entered is too short. The minimum length is 3 characters.',
|
'INST_ERR_USER_TOO_SHORT' => 'The username you entered is too short. The minimum length is 3 characters.',
|
||||||
'INVALID_PRIMARY_KEY' => 'Invalid primary key : %s',
|
'INVALID_PRIMARY_KEY' => 'Invalid primary key : %s',
|
||||||
|
|
||||||
|
// mbstring
|
||||||
|
'MBSTRING_CHECK' => 'mbstring Extension Check',
|
||||||
|
'MBSTRING_CHECK_EXPLAIN' => 'mbstring is a PHP extension that provides multibyte string functions. Certain features of mbstring are not compatible with phpBB and must be disabled',
|
||||||
|
'MBSTRING_FUNC_OVERLOAD' => 'Function overloading',
|
||||||
|
'MBSTRING_FUNC_OVERLOAD_EXPLAIN' => 'mbstring.func_overload must be set to either 0 or 4',
|
||||||
|
'MBSTRING_ENCODING_TRANSLATION' => 'Transparent character encoding',
|
||||||
|
'MBSTRING_ENCODING_TRANSLATION_EXPLAIN' => 'mbstring.encoding_translation must be set to either 0',
|
||||||
|
'MBSTRING_HTTP_INPUT' => 'HTTP input character conversion',
|
||||||
|
'MBSTRING_HTTP_INPUT_EXPLAIN' => 'mbstring.http_input must be set to pass',
|
||||||
|
'MBSTRING_HTTP_OUTPUT' => 'HTTP output character conversion',
|
||||||
|
'MBSTRING_HTTP_OUTPUT_EXPLAIN' => 'mbstring.http_output must be set to pass',
|
||||||
|
|
||||||
'MAKE_FOLDER_WRITABLE' => 'Please make sure that this folder exists and is writable by the webserver then try again:<br />»<strong>%s</strong>',
|
'MAKE_FOLDER_WRITABLE' => 'Please make sure that this folder exists and is writable by the webserver then try again:<br />»<strong>%s</strong>',
|
||||||
'MAKE_FOLDERS_WRITABLE' => 'Please make sure that these folders exist and are writable by the webserver then try again:<br />»<strong>%s</strong>',
|
'MAKE_FOLDERS_WRITABLE' => 'Please make sure that these folders exist and are writable by the webserver then try again:<br />»<strong>%s</strong>',
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue