X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fi18n.php;h=d7d92ae0796b3f8e2c827273998ff5eb557c5f88;hp=7c99aface939fbf4272fd2f53bfacbb6d9b81348;hb=821d1f1424ce74d60ae3b6e357a148658f17424e;hpb=db08d0c3f784beb27c9a05616146f27210ea7f33 diff --git a/functions/i18n.php b/functions/i18n.php index 7c99afac..d7d92ae0 100644 --- a/functions/i18n.php +++ b/functions/i18n.php @@ -1,910 +1,14 @@ 0) { - $tmpstr = mb_substr($ret, 0, 1); - $prevcsize = strlen($tmpstr); - for ($i = 1; $i < mb_strlen($ret); $i++) { - $tmp = mb_substr($ret, $i, 1); - if (strlen($tmp) == $prevcsize) { - $tmpstr .= $tmp; - } else { - if ($prevcsize == 1) { - $result .= $tmpstr; - } else { - $result .= str_replace(' ', '', - mb_encode_mimeheader($tmpstr,'iso-2022-jp','B','')); - } - $tmpstr = $tmp; - $prevcsize = strlen($tmp); - } - } - if (strlen($tmpstr)) { - if (strlen(mb_substr($tmpstr, 0, 1)) == 1) - $result .= $tmpstr; - else - $result .= str_replace(' ', '', - mb_encode_mimeheader($tmpstr,'iso-2022-jp','B','')); - } - } - $ret = $result; - break; - case 'decodeheader': - $ret = str_replace("\t", "", $ret); - if (eregi('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=', $ret)) - $ret = @mb_decode_mimeheader($ret); - $ret = @mb_convert_encoding($ret, 'EUC-JP', 'AUTO'); - break; - case 'downloadfilename': - $useragent = func_get_arg(2); - if (strstr($useragent, 'Windows') !== false || - strstr($useragent, 'Mac_') !== false) { - $ret = mb_convert_encoding($ret, 'SJIS', 'AUTO'); - } else { - $ret = mb_convert_encoding($ret, 'EUC-JP', 'AUTO'); -} - break; - case 'wordwrap': - $no_begin = "\x21\x25\x29\x2c\x2e\x3a\x3b\x3f\x5d\x7d\xa1\xf1\xa1\xeb\xa1" . - "\xc7\xa1\xc9\xa2\xf3\xa1\xec\xa1\xed\xa1\xee\xa1\xa2\xa1\xa3\xa1\xb9" . - "\xa1\xd3\xa1\xd5\xa1\xd7\xa1\xd9\xa1\xdb\xa1\xcd\xa4\xa1\xa4\xa3\xa4" . - "\xa5\xa4\xa7\xa4\xa9\xa4\xc3\xa4\xe3\xa4\xe5\xa4\xe7\xa4\xee\xa1\xab" . - "\xa1\xac\xa1\xb5\xa1\xb6\xa5\xa1\xa5\xa3\xa5\xa5\xa5\xa7\xa5\xa9\xa5" . - "\xc3\xa5\xe3\xa5\xe5\xa5\xe7\xa5\xee\xa5\xf5\xa5\xf6\xa1\xa6\xa1\xbc" . - "\xa1\xb3\xa1\xb4\xa1\xaa\xa1\xf3\xa1\xcb\xa1\xa4\xa1\xa5\xa1\xa7\xa1" . - "\xa8\xa1\xa9\xa1\xcf\xa1\xd1"; - $no_end = "\x5c\x24\x28\x5b\x7b\xa1\xf2\x5c\xa1\xc6\xa1\xc8\xa1\xd2\xa1" . - "\xd4\xa1\xd6\xa1\xd8\xa1\xda\xa1\xcc\xa1\xf0\xa1\xca\xa1\xce\xa1\xd0\xa1\xef"; - $wrap = func_get_arg(2); - - if (strlen($ret) >= $wrap && - substr($ret, 0, 1) != '>' && - strpos($ret, 'http://') === FALSE && - strpos($ret, 'https://') === FALSE && - strpos($ret, 'ftp://') === FALSE) { - - $ret = mb_convert_kana($ret, "KV"); - - $line_new = ''; - $ptr = 0; - - while ($ptr < strlen($ret) - 1) { - $l = mb_strcut($ret, $ptr, $wrap); - $ptr += strlen($l); - $tmp = $l; - - $l = mb_strcut($ret, $ptr, 2); - while (strlen($l) != 0 && mb_strpos($no_begin, $l) !== FALSE ) { - $tmp .= $l; - $ptr += strlen($l); - $l = mb_strcut($ret, $ptr, 1); - } - $line_new .= $tmp; - if ($ptr < strlen($ret) - 1) - $line_new .= "\n"; - } - $ret = $line_new; - } - break; - case 'utf7-imap_encode': - $ret = mb_convert_encoding($ret, 'UTF7-IMAP', 'EUC-JP'); - break; - case 'utf7-imap_decode': - $ret = mb_convert_encoding($ret, 'EUC-JP', 'UTF7-IMAP'); - break; - } - } - return $ret; -} - - -/* - * Korean charset extra function - * Hangul(Korean Character) Attached File Name Fix. - */ -function korean_charset_xtra() { - - $ret = func_get_arg(1); /* default return value */ - if (func_get_arg(0) == 'downloadfilename') { /* action */ - $ret = str_replace("\x0D\x0A", '', $ret); /* Hanmail's CR/LF Clear */ - for ($i=0;$i= "\xA1" && $ret[$i] <= "\xFE") { /* 0xA1 - 0XFE are Valid */ - $i++; - continue; - } else if (($ret[$i] >= 'a' && $ret[$i] <= 'z') || /* From Original ereg_replace in download.php */ - ($ret[$i] >= 'A' && $ret[$i] <= 'Z') || - ($ret[$i] == '.') || ($ret[$i] == '-')) { - continue; - } else { - $ret[$i] = '_'; - } - } - - } - - return $ret; -} - -/** - * Replaces non-braking spaces inserted by some browsers with regular space - * - * This function can be used to replace non-braking space symbols - * that are inserted in forms by some browsers instead of normal - * space symbol. - * - * @param string $string Text that needs to be cleaned - * @param string $charset Charset used in text - * @return string Cleaned text - */ -function cleanup_nbsp($string,$charset) { - - // reduce number of case statements - if (stristr('iso-8859-',substr($charset,0,9))){ - $output_charset="iso-8859-x"; - } - if (stristr('windows-125',substr($charset,0,11))){ - $output_charset="cp125x"; - } - if (stristr('koi8',substr($charset,0,4))){ - $output_charset="koi8-x"; - } - if (! isset($output_charset)){ - $output_charset=strtolower($charset); - } - -// where is non-braking space symbol -switch($output_charset): - case "iso-8859-x": - case "cp125x": - case "iso-2022-jp": - $nbsp="\xA0"; - break; - case "koi8-x": - $nbsp="\x9A"; - break; - case "utf-8": - $nbsp="\xC2\xA0"; - break; - default: - // don't change string if charset is unmatched - return $string; -endswitch; - -// return space instead of non-braking space. - return str_replace($nbsp,' ',$string); -} - -/** - * Function informs if it is safe to convert given charset to the one that is used by user. - * - * It is safe to use conversion only if user uses utf-8 encoding and when - * converted charset is similar to the one that is used by user. - * - * @param string $input_charset Charset of text that needs to be converted - * @return bool is it possible to convert to user's charset - */ -function is_conversion_safe($input_charset) { - global $languages, $sm_notAlias, $default_charset; - - // convert to lower case - $input_charset = strtolower($input_charset); - - // Is user's locale Unicode based ? - if ( $default_charset == "utf-8" ) { - return true; - } - - // Charsets that are similar -switch ($default_charset): -case "windows-1251": - if ( $input_charset == "iso-8859-5" || - $input_charset == "koi8-r" || - $input_charset == "koi8-u" ) { - return true; - } else { - return false; - } -case "windows-1257": - if ( $input_charset == "iso-8859-13" || - $input_charset == "iso-8859-4" ) { - return true; - } else { - return false; - } -case "iso-8859-4": - if ( $input_charset == "iso-8859-13" || - $input_charset == "windows-1257" ) { - return true; - } else { - return false; - } -case "iso-8859-5": - if ( $input_charset == "windows-1251" || - $input_charset == "koi8-r" || - $input_charset == "koi8-u" ) { - return true; - } else { - return false; - } -case "iso-8859-13": - if ( $input_charset == "iso-8859-4" || - $input_charset == "windows-1257" ) { - return true; - } else { - return false; - } -case "koi8-r": - if ( $input_charset == "windows-1251" || - $input_charset == "iso-8859-5" || - $input_charset == "koi8-u" ) { - return true; - } else { - return false; - } -case "koi8-u": - if ( $input_charset == "windows-1251" || - $input_charset == "iso-8859-5" || - $input_charset == "koi8-r" ) { - return true; - } else { - return false; - } -default: - return false; -endswitch; -} -?> +/** break if somebody tries to load this file */ +die('Rewrite your code, functions/i18n.php file location is changed in 1.5.2.' + .' Direct loading of functions/i18n.php is deprecated.'); +?> \ No newline at end of file