[ Index ] |
|
Code source de Serendipity 1.2 |
1 <?php 2 3 $dh = @opendir('.'); 4 if (!$dh) { 5 die('Failure'); 6 } 7 8 // Only non-UTF languages! 9 $ext = array( 10 'tw' => 'big5', 11 'se' => 'ISO-8859-1', 12 'pt_PT' => 'ISO-8859-1', 13 'pt' => 'ISO-8859-1', 14 'no' => 'ISO-8859-1', 15 'nl' => 'ISO-8859-1', 16 'it' => 'ISO-8859-1', 17 'is' => 'ISO-8859-1', 18 'hu' => 'ISO-8859-2', 19 'fr' => 'ISO-8859-1', 20 'es' => 'ISO-8859-15', 21 'en' => 'ISO-8859-1', 22 'de' => 'ISO-8859-1', 23 'da' => 'ISO-8859-1', 24 'cz' => 'ISO-8859-2', 25 'cs' => 'windows-1250', 26 'bg' => 'windows-1251', 27 'zh' => 'gb2312', 28 'sa' => 'cp1256', 29 'pl' => 'ISO-8859-2' 30 ); 31 32 $htmlarea_iso = array( 33 'da' => 'da-utf', 34 'de' => 'de-utf', 35 'es' => 'es-utf', 36 'fr' => 'fr-utf', 37 'it' => 'it-utf', 38 'nl' => 'nl-utf', 39 'no' => 'no-utf', 40 'pt' => 'pt_pt-utf', 41 'pt_PT' => 'pt_pt-utf', 42 'se' => 'se-utf', 43 'cs' => 'cs-utf', 44 'cz' => 'cs-utf' 45 ); 46 47 $sr = array( 48 'bg_BG.CP1251' => 'bg_BG.UTF-8' 49 ); 50 51 while (($file = readdir($dh)) !== false) { 52 if (!preg_match('@lang_(.+)\.inc\.php$@i', $file, $extmatch)) { 53 continue; 54 } 55 56 if (!isset($ext[$extmatch[1]])) { 57 echo "'$file' already is in UTF-8. Leaving untouched.\n"; 58 } else { 59 $set = $ext[$extmatch[1]]; 60 $cmd = 'iconv -f ' . $set . ' -t UTF-8 -o ' . $file . '.new ' . $file . "\n"; 61 echo $cmd; 62 $return = `$cmd`; 63 chmod($file, 0644); 64 $fc = file_get_contents($file . '.new'); 65 $fc = preg_replace('@' . $set . '@i', 'UTF-8', $fc); 66 $fc = preg_replace('@' . str_replace('ISO-', 'ISO', $set) . '@i', 'UTF8', $fc); 67 68 if (isset($htmlarea_iso[$extmatch[1]])) { 69 $fc = preg_replace( 70 '@define\(\'WYSIWYG_LANG\',\s+\'[^\']+\'\);@i', 71 "define('WYSIWYG_LANG', '" . $htmlarea_iso[$extmatch[1]] . "');", 72 $fc 73 ); 74 } 75 76 $fc = preg_replace( 77 '@define\(\'SQL_CHARSET\',\s+\'[^\']+\'\);@i', 78 "define('SQL_CHARSET', 'utf8');", 79 $fc 80 ); 81 82 $fc = str_replace(array_keys($sr), array_values($sr), $fc); 83 $fp = fopen($file, 'w'); 84 fwrite($fp, $fc); 85 fclose($fp); 86 unlink($file . '.new'); 87 } 88 } 89 90 closedir($dh);
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 09:00:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |