- Mail headers sometimes maked corrupted
- In "Recent activity" block headers of new forum posts is too math truncated
- pclzip module works wrong
- cryptography function used in make username cookie
- graphlib at non-english text output (after adding function foxy_utf8_to_nce recomended at http://php.net/manual/function.imagettftext.php#57416)
based on http://php.net/manual/function.strlen.php#54906 i make this code and inject it in some places in moodlelib.php, gdlib, pclzip and others:
// <<-- Nashev, from php documentation comments for correct byte countingand replace some strlen calls to call ByteCount, and some calls of substr to ByteSubstr
if (!function_exists('ByteCount') ) {
function ByteCount($s) {
$has_mbstring = extension_loaded('mbstring') ||@dl(PHP_SHLIB_PREFIX.'mbstring.'.PHP_SHLIB_SUFFIX);
$has_mb_shadow = (int) ini_get('mbstring.func_overload');
if ($has_mbstring && ($has_mb_shadow & 2) ) {
$size = mb_strlen($s,'latin1');
} else {
$size = strlen($s);
}
return $size;
}
};
if (!function_exists('ByteSubstr') ) {
function ByteSubstr($s, $start, $length) {
$has_mbstring = extension_loaded('mbstring') ||@dl(PHP_SHLIB_PREFIX.'mbstring.'.PHP_SHLIB_SUFFIX);
$has_mb_shadow = (int) ini_get('mbstring.func_overload');
if ($has_mbstring && ($has_mb_shadow & 2) ) {
$s2 = mb_substr($s, $start, $length, 'latin1');
} else {
$s2 = substr($s, $start, $length);
}
return $s2;
}
};
// -->> Nashev
I think, textlib.php module can make oter, more good decision, that function overriding