Index: sources/functions.php =================================================================== RCS file: /cvsroot/usebb/UseBB/sources/functions.php,v retrieving revision 1.321 diff -r1.321 functions.php 132c132,139 < while ( $pos < strlen($string) && ( $new_length < $length || $entity_open ) ) { --- > if ( function_exists( "mb_language") && mb_language() != "neutral") { > $strlen = "mb_strlen"; > $substr = "mb_substr"; > } else { > $strlen = "strlen"; > $substr = "substr"; > } > while ( $pos < $strlen($string) && ( $new_length < $length || $entity_open ) ) { 134c141 < $char = $string[$pos]; --- > $char = $substr( $string, $pos, 1); 243a251 > var $is_mbstring; 780d787 < 793,795c800,822 < else < mb_internal_encoding($lang['character_encoding']); < --- > else { > // setting mbstring. > if ( $lang['character_encoding'] == 'iso-8859-8-i' ) > $mb_internal_encoding = 'iso-8859-8'; > else > $mb_internal_encoding = $lang['character_encoding']; > > $is_mb_language = @mb_language( $language); > $is_mb_internal_encoding = @mb_internal_encoding($lang['character_encoding']); > if ( $is_mb_language !== FALSE || $is_mb_internal_encoding !== FALSE) { > $this->is_mbstring = TRUE; > } else { > // mbstring can not be used, it resets then. > mb_language( "neutral"); > mb_internal_encoding( "ISO-8859-1"); > } > > // reset other parameters. > ini_set( 'mbstring.http_input', 'pass'); > ini_set( 'mbstring.http_output', 'pass'); > ini_set( 'mbstring.func_overload', 0); > ini_set( 'mbstring.substitute_character', 'none'); > } 989a1017,1018 > $is_enable_mbstring = function_exists('mb_language') && mb_language() != 'neutral'; > 998c1027 < // Set the correct mb_language when neccessary (only for Japanese, English or UTF-8) --- > // Set the correct mb_language when neccessary (when mbstring enabled) 1000c1029,1030 < if ( function_exists('mb_language') ) { --- > $is_mbstring = FALSE; > if ( $this->is_mbstring) { 1002,1007c1032,1033 < if ( in_array($language, array('Japanese', 'ja', 'English', 'en')) ) < mb_language($language); < elseif ( strtolower($charset) == 'utf-8' ) < mb_language('uni'); < else < mb_language('en'); --- > $backup_mb_language = mb_language(); > $backup_mb_internal_encoding = mb_internal_encoding(); 1008a1035,1036 > if ( @mb_language( $language) !== FALSE && @mb_internal_encoding( $charset) !== FALSE) > $is_mbstring = TRUE; 1028c1056 < if ( function_exists('mb_encode_mimeheader') ) { --- > if ( $is_mbstring && function_exists('mb_encode_mimeheader') ) { 1031d1058 < $subject = mb_encode_mimeheader($subject); 1035d1061 < $headers[] = 'MIME-Version: 1.0'; 1038a1065 > $headers[] = 'Message-Id: '.sprintf("<%s.%s>",substr(md5(time()),4,10),$from_email); 1042c1069 < if ( function_exists('mb_send_mail') ) { --- > if ( $is_mbstring && function_exists('mb_send_mail')) { 1048a1076 > $headers[] = 'MIME-Version: 1.0'; 1051c1079 < --- > 1058c1086 < // Reset to board's default language --- > // Restored language and character encoding. 1060,1061c1088 < $board_default_lang = $this->get_config('language'); < if ( $language != $board_default_lang && function_exists('mb_language') ) { --- > if ( $this->is_mbstring) { 1063,1073c1090,1091 < if ( in_array($board_default_lang, array('Japanese', 'ja', 'English', 'en')) ) < mb_language($board_default_lang); < elseif ( strtolower($board_default_lang) == 'utf-8' ) < mb_language('uni'); < else < mb_language('en'); < < if ( $lang['character_encoding'] == 'iso-8859-8-i' ) < mb_internal_encoding('iso-8859-8'); < else < mb_internal_encoding($lang['character_encoding']); --- > mb_language( $backup_mb_language); > mb_internal_encoding( $backup_mb_internal_encoding);